Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "container/list" |
| 22 | "context" |
| 23 | "encoding/binary" |
| 24 | "encoding/hex" |
| 25 | "errors" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 26 | "strconv" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 27 | "sync" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 28 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 29 | //"time" |
| 30 | |
| 31 | "github.com/google/gopacket" |
| 32 | // TODO!!! Some references could be resolved auto, but some need specific context .... |
| 33 | gp "github.com/google/gopacket" |
| 34 | |
| 35 | "github.com/opencord/omci-lib-go" |
| 36 | me "github.com/opencord/omci-lib-go/generated" |
| 37 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
| 38 | |
| 39 | //"github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
| 40 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 41 | ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 42 | //"github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 43 | //"github.com/opencord/voltha-protos/v3/go/voltha" |
| 44 | ) |
| 45 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 46 | // ### OMCI related definitions - retrieved from Python adapter code/trace #### |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 47 | |
| 48 | //ConstDefaultOmciTimeout - Default OMCI Timeout |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 49 | const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds |
| 50 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 51 | const galEthernetEID = uint16(1) |
| 52 | const maxGemPayloadSize = uint16(48) |
| 53 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 54 | |
| 55 | //const defaultTPID = uint16(0x8100) |
| 56 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 57 | const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning |
| 58 | const ieeeMapperServiceProfileEID = uint16(0x8001) |
| 59 | const macBridgePortAniEID = uint16(0x2102) |
| 60 | |
| 61 | // ### OMCI related definitions - end |
| 62 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 63 | //callbackPairEntry to be used for OMCI send/receive correlation |
| 64 | type callbackPairEntry struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 65 | cbRespChannel chan Message |
| 66 | cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error |
| 67 | } |
| 68 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 69 | //callbackPair to be used for ReceiveCallback init |
| 70 | type callbackPair struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 71 | cbKey uint16 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 72 | cbEntry callbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | type omciTransferStructure struct { |
| 76 | txFrame []byte |
| 77 | timeout int |
| 78 | retry int |
| 79 | highPrio bool |
| 80 | } |
| 81 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 82 | //omciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 83 | type omciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 84 | enabled bool |
| 85 | pOnuDeviceEntry *OnuDeviceEntry |
| 86 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 87 | pBaseDeviceHandler *deviceHandler |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 88 | coreProxy adapterif.CoreProxy |
| 89 | adapterProxy adapterif.AdapterProxy |
| 90 | supportExtMsg bool |
| 91 | //txRequest |
| 92 | //rxResponse |
| 93 | //pendingRequest |
| 94 | txFrames, txOnuFrames uint32 |
| 95 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 96 | |
| 97 | // OMCI params |
| 98 | mutexTid sync.Mutex |
| 99 | tid uint16 |
| 100 | mutexHpTid sync.Mutex |
| 101 | hpTid uint16 |
| 102 | uploadSequNo uint16 |
| 103 | uploadNoOfCmds uint16 |
| 104 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 105 | mutexTxQueue sync.Mutex |
| 106 | txQueue *list.List |
| 107 | mutexRxSchedMap sync.Mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 108 | rxSchedulerMap map[uint16]callbackPairEntry |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 109 | pLastTxMeInstance *me.ManagedEntity |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 112 | //newOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 113 | //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 114 | func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry, |
| 115 | deviceID string, deviceHandler *deviceHandler, |
| 116 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 117 | logger.Infow("init-omciCC", log.Fields{"device-id": deviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 118 | var omciCC omciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 119 | omciCC.enabled = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 120 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 121 | omciCC.deviceID = deviceID |
| 122 | omciCC.pBaseDeviceHandler = deviceHandler |
| 123 | omciCC.coreProxy = coreProxy |
| 124 | omciCC.adapterProxy = adapterProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 125 | omciCC.supportExtMsg = false |
| 126 | omciCC.txFrames = 0 |
| 127 | omciCC.txOnuFrames = 0 |
| 128 | omciCC.rxFrames = 0 |
| 129 | omciCC.rxOnuFrames = 0 |
| 130 | omciCC.rxOnuDiscards = 0 |
| 131 | omciCC.tid = 0x1 |
| 132 | omciCC.hpTid = 0x8000 |
| 133 | omciCC.uploadSequNo = 0 |
| 134 | omciCC.uploadNoOfCmds = 0 |
| 135 | |
| 136 | omciCC.txQueue = list.New() |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 137 | omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 138 | |
| 139 | return &omciCC |
| 140 | } |
| 141 | |
| 142 | // Rx handler for omci messages |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 143 | func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 144 | logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 145 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
| 146 | /* |
| 147 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 148 | rxOnuFrames++ |
| 149 | |
| 150 | switch msgType { |
| 151 | case AlarmNotification: |
| 152 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 153 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 154 | // python code was: |
| 155 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 156 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 157 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 158 | // |
| 159 | return errors.New("RxAlarmNotification unimplemented") |
| 160 | } |
| 161 | case AttributeValueChange: |
| 162 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 163 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 164 | // python code was: |
| 165 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 166 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 167 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 168 | // |
| 169 | return errors.New("RxAttributeValueChange unimplemented") |
| 170 | } |
| 171 | case TestResult: |
| 172 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 173 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 174 | // python code was: |
| 175 | //elif msg_type == EntityOperations.TestResult.value: |
| 176 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 177 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 178 | // |
| 179 | return errors.New("RxTestResult unimplemented") |
| 180 | } |
| 181 | default: |
| 182 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 183 | logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 184 | rxOnuDiscards++ |
| 185 | return errors.New("RxOnuMsgType unimplemented") |
| 186 | } |
| 187 | } |
| 188 | */ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 189 | return errors.New("receiveOnuMessage unimplemented") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | // Rx handler for onu messages |
| 193 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 194 | func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 195 | //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 196 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 197 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 198 | // (am extendedFormat message could be destroyed this way!) |
| 199 | trailerLenData := rxMsg[42:44] |
| 200 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 201 | //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 202 | if trailerLen != 40 { // invalid base Format entry -> autocorrect |
| 203 | binary.BigEndian.PutUint16(rxMsg[42:44], 40) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 204 | logger.Debug("cc-corrected-omci-message: trailer len inserted") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 205 | } |
| 206 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 207 | logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)}) |
| 208 | return errors.New("rxOmciMessage too small for BaseFormat") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 212 | if packet == nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 213 | logger.Error("omci-message could not be decoded") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 214 | return errors.New("could not decode rxMsg as OMCI") |
| 215 | } |
| 216 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 217 | if omciLayer == nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 218 | logger.Error("omci-message could not decode omci layer") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 219 | return errors.New("could not decode omci layer") |
| 220 | } |
| 221 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 222 | if !ok { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 223 | logger.Error("omci-message could not assign omci layer") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 224 | return errors.New("could not assign omci layer") |
| 225 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 226 | logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 227 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 228 | if byte(omciMsg.MessageType) & ^me.AK == 0 { |
| 229 | // Not a response |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 230 | logger.Debug("RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 231 | if omciMsg.TransactionID == 0 { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 232 | return oo.receiveOnuMessage(ctx, omciMsg) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 233 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 234 | logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages", |
| 235 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload)}) |
| 236 | return errors.New("autonomous Omci Message with TranSCorrId != 0 not acccepted") |
| 237 | |
| 238 | } |
| 239 | //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester") |
| 240 | oo.mutexRxSchedMap.Lock() |
| 241 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
| 242 | if ok && rxCallbackEntry.cbFunction != nil { |
| 243 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 244 | // how to react on erroneous frame reception, maybe can simply be ignored |
| 245 | go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel) |
| 246 | // having posted the response the request is regarded as 'done' |
| 247 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 248 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 249 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 250 | oo.mutexRxSchedMap.Unlock() |
| 251 | logger.Error("omci-message-response for not registered transCorrId") |
| 252 | return errors.New("could not find registered response handler tor transCorrId") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | return nil |
| 256 | /* py code was: |
| 257 | Receive and OMCI message from the proxy channel to the OLT. |
| 258 | |
| 259 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 260 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 261 | """ |
| 262 | if not self.enabled: |
| 263 | return |
| 264 | |
| 265 | try: |
| 266 | now = arrow.utcnow() |
| 267 | d = None |
| 268 | |
| 269 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 270 | # save the current value of the entity_id_to_class_map, then |
| 271 | # replace it with our custom one before decode, and then finally |
| 272 | # restore it later. Tried other ways but really made the code messy. |
| 273 | saved_me_map = omci_entities.entity_id_to_class_map |
| 274 | omci_entities.entity_id_to_class_map = self._me_map |
| 275 | |
| 276 | try: |
| 277 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 278 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 279 | except KeyError as e: |
| 280 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 281 | self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 282 | rx_frame = self._decode_unknown_me(msg) |
| 283 | self._rx_unknown_me += 1 |
| 284 | |
| 285 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 286 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 287 | return |
| 288 | |
| 289 | finally: |
| 290 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 291 | |
| 292 | rx_tid = rx_frame.fields['transaction_id'] |
| 293 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 294 | self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 295 | # Filter the Test Result frame and route through receive onu |
| 296 | # message method. |
| 297 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 298 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 299 | return self._receive_onu_message(rx_frame) |
| 300 | |
| 301 | # Previously unreachable if this is the very first round-trip Rx or we |
| 302 | # have been running consecutive errors |
| 303 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 304 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 305 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 306 | |
| 307 | self._rx_frames += 1 |
| 308 | self._consecutive_errors = 0 |
| 309 | |
| 310 | try: |
| 311 | high_priority = self._tid_is_high_priority(rx_tid) |
| 312 | index = self._get_priority_index(high_priority) |
| 313 | |
| 314 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 315 | last_tx_tuple = self._tx_request[index] |
| 316 | |
| 317 | if last_tx_tuple is None or \ |
| 318 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 319 | # Possible late Rx on a message that timed-out |
| 320 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 321 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 322 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 323 | self._rx_unknown_tid += 1 |
| 324 | self._rx_late += 1 |
| 325 | return |
| 326 | |
| 327 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 328 | if dc is not None and not dc.cancelled and not dc.called: |
| 329 | dc.cancel() |
| 330 | |
| 331 | _secs = self._update_rx_tx_stats(now, ts) |
| 332 | |
| 333 | # Late arrival already serviced by a timeout? |
| 334 | if d.called: |
| 335 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 336 | self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 337 | return |
| 338 | |
| 339 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 340 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 341 | if d is not None: |
| 342 | return d.errback(failure.Failure(e)) |
| 343 | return |
| 344 | |
| 345 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 346 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 347 | tx_tid = tx_frame.fields['transaction_id']) |
| 348 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 349 | |
| 350 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 351 | self._rx_response[index] = rx_frame |
| 352 | d.callback(rx_frame) |
| 353 | |
| 354 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 355 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 356 | */ |
| 357 | } |
| 358 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 359 | /* |
| 360 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 361 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 362 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 363 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 364 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 365 | |
| 366 | //Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 367 | func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 368 | receiveCallbackPair callbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 369 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 370 | logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 371 | // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ... |
| 372 | oo.mutexRxSchedMap.Lock() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 373 | oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 374 | oo.mutexRxSchedMap.Unlock() |
| 375 | |
| 376 | //just use a simple list for starting - might need some more effort, especially for multi source write access |
| 377 | omciTxRequest := omciTransferStructure{ |
| 378 | txFrame, |
| 379 | timeout, |
| 380 | retry, |
| 381 | highPrio, |
| 382 | } |
| 383 | oo.mutexTxQueue.Lock() |
| 384 | oo.txQueue.PushBack(omciTxRequest) // enqueue |
| 385 | oo.mutexTxQueue.Unlock() |
| 386 | |
| 387 | // for first test just bypass and send directly: |
| 388 | go oo.sendNextRequest(ctx) |
| 389 | return nil |
| 390 | } |
| 391 | |
| 392 | //Pull next tx request and send it |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 393 | func (oo *omciCC) sendNextRequest(ctx context.Context) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 394 | // return errors.New("sendNextRequest unimplemented") |
| 395 | |
| 396 | // just try to get something transferred !! |
| 397 | // avoid accessing the txQueue from parallel send requests |
| 398 | // block parallel omci send requests at least until SendIAP is 'committed' |
| 399 | // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed |
| 400 | oo.mutexTxQueue.Lock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 401 | defer oo.mutexTxQueue.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 402 | for oo.txQueue.Len() > 0 { |
| 403 | queueElement := oo.txQueue.Front() // First element |
| 404 | omciTxRequest := queueElement.Value.(omciTransferStructure) |
| 405 | /* compare olt device handler code: |
| 406 | func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 407 | logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 408 | var deviceType string |
| 409 | var deviceID string |
| 410 | var proxyDeviceID string |
| 411 | |
| 412 | onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId) |
| 413 | |
| 414 | if onuInCache, ok := dh.onus.Load(onuKey); !ok { |
| 415 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 416 | logger.Debugw("omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 417 | ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT) |
| 418 | kwargs := make(map[string]interface{}) |
| 419 | kwargs["onu_id"] = omciInd.OnuId |
| 420 | kwargs["parent_port_no"] = ponPort |
| 421 | |
| 422 | onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs) |
| 423 | if err != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 424 | logger.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 425 | return |
| 426 | } |
| 427 | deviceType = onuDevice.Type |
| 428 | deviceID = onuDevice.Id |
| 429 | proxyDeviceID = onuDevice.ProxyAddress.DeviceId |
| 430 | //if not exist in cache, then add to cache. |
| 431 | dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)) |
| 432 | } else { |
| 433 | //found in cache |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 434 | logger.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 435 | deviceType = onuInCache.(*OnuDevice).deviceType |
| 436 | deviceID = onuInCache.(*OnuDevice).deviceID |
| 437 | proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID |
| 438 | } |
| 439 | */ |
| 440 | /* and compare onu_adapter py code: |
| 441 | omci_msg = InterAdapterOmciMessage( |
| 442 | message=bytes(frame), |
| 443 | proxy_address=self._proxy_address, |
| 444 | connect_status=self._device.connect_status) |
| 445 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 446 | self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame))) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 447 | |
| 448 | yield self._adapter_proxy.send_inter_adapter_message( |
| 449 | msg=omci_msg, |
| 450 | type=InterAdapterMessageType.OMCI_REQUEST, |
| 451 | from_adapter=self._device.type, |
| 452 | to_adapter=self._proxy_address.device_type, |
| 453 | to_device_id=self._device_id, |
| 454 | proxy_device_id=self._proxy_address.device_id |
| 455 | ) |
| 456 | */ |
| 457 | device, err := oo.coreProxy.GetDevice(ctx, |
| 458 | oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child |
| 459 | if err != nil || device == nil { |
| 460 | /*TODO: needs to handle error scenarios */ |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 461 | logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 462 | "ChildId": oo.deviceID}) |
| 463 | return errors.New("failed to fetch device") |
| 464 | } |
| 465 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 466 | logger.Debugw("omci-message-sending", log.Fields{"fromDeviceType": oo.pBaseDeviceHandler.DeviceType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 467 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 468 | "onuDeviceID": oo.deviceID, "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 469 | logger.Debugw("omci-message-to-send:", |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 470 | log.Fields{"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame)}) |
| 471 | |
| 472 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
| 473 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg, |
| 474 | ic.InterAdapterMessageType_OMCI_REQUEST, |
| 475 | //fromType,toType,toDevId, ProxyDevId |
| 476 | oo.pBaseDeviceHandler.DeviceType, oo.pBaseDeviceHandler.ProxyAddressType, |
| 477 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 478 | logger.Errorw("send omci request error", log.Fields{"error": sendErr}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 479 | return sendErr |
| 480 | } |
| 481 | oo.txQueue.Remove(queueElement) // Dequeue |
| 482 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 483 | return nil |
| 484 | } |
| 485 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 486 | func (oo *omciCC) getNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 487 | var next uint16 |
| 488 | if highPriority { |
| 489 | oo.mutexTid.Lock() |
| 490 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 491 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 492 | if oo.hpTid < 0x8000 { |
| 493 | oo.hpTid = 0x8000 |
| 494 | } |
| 495 | oo.mutexTid.Unlock() |
| 496 | } else { |
| 497 | oo.mutexHpTid.Lock() |
| 498 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 499 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 500 | if oo.tid >= 0x8000 { |
| 501 | oo.tid = 1 |
| 502 | } |
| 503 | oo.mutexHpTid.Unlock() |
| 504 | } |
| 505 | return next |
| 506 | } |
| 507 | |
| 508 | // ################################################################################### |
| 509 | // # utility methods provided to work on OMCI messages |
| 510 | func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) { |
| 511 | omciLayer := &omci.OMCI{ |
| 512 | TransactionID: tid, |
| 513 | MessageType: msgType, |
| 514 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 515 | return serializeOmciLayer(omciLayer, request) |
| 516 | } |
| 517 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 518 | func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 519 | var options gopacket.SerializeOptions |
| 520 | options.FixLengths = true |
| 521 | |
| 522 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 523 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 524 | if err != nil { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 525 | logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 526 | return nil, err |
| 527 | } |
| 528 | return buffer.Bytes(), nil |
| 529 | } |
| 530 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 531 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 532 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 533 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 534 | hex.Encode(dst, omciPkt) |
| 535 | return dst, nil |
| 536 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 537 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 538 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 539 | //supply a response handler for omci response messages to be transferred to the requested FSM |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 540 | func (oo *omciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 541 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 542 | logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType, |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 543 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 544 | |
| 545 | if oo.pOnuDeviceEntry == nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 546 | logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 547 | "device-id": oo.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 548 | return errors.New("deviceEntryPointer is nil") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 552 | // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 553 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 554 | Type: OMCI, |
| 555 | Data: OmciMessage{ |
| 556 | OmciMsg: omciMsg, |
| 557 | OmciPacket: packet, |
| 558 | }, |
| 559 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 560 | //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 561 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 562 | |
| 563 | return nil |
| 564 | } |
| 565 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 566 | func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 567 | |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 568 | logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 569 | request := &omci.MibResetRequest{ |
| 570 | MeBasePacket: omci.MeBasePacket{ |
| 571 | EntityClass: me.OnuDataClassID, |
| 572 | }, |
| 573 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 574 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 575 | pkt, err := serialize(omci.MibResetRequestType, request, tid) |
| 576 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 577 | logger.Errorw("Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 578 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 579 | return err |
| 580 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 581 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 582 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 583 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 584 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 585 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 586 | } |
| 587 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 588 | func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 589 | logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 590 | request := &omci.RebootRequest{ |
| 591 | MeBasePacket: omci.MeBasePacket{ |
| 592 | EntityClass: me.OnuGClassID, |
| 593 | }, |
| 594 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 595 | tid := oo.getNextTid(highPrio) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 596 | pkt, err := serialize(omci.RebootRequestType, request, tid) |
| 597 | if err != nil { |
| 598 | logger.Errorw("Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 599 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 600 | return err |
| 601 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 602 | omciRxCallbackPair := callbackPair{ |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 603 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 604 | cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 605 | } |
| 606 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 607 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 608 | if err != nil { |
| 609 | logger.Errorw("Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 610 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 611 | return err |
| 612 | } |
| 613 | err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel) |
| 614 | if err != nil { |
| 615 | logger.Error("aborting ONU Reboot!") |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 616 | _ = oo.pOnuDeviceEntry.pMibDownloadFsm.pFsm.Event("reset") |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 617 | return err |
| 618 | } |
| 619 | return nil |
| 620 | } |
| 621 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 622 | func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 623 | logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 624 | request := &omci.MibUploadRequest{ |
| 625 | MeBasePacket: omci.MeBasePacket{ |
| 626 | EntityClass: me.OnuDataClassID, |
| 627 | }, |
| 628 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 629 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 630 | pkt, err := serialize(omci.MibUploadRequestType, request, tid) |
| 631 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 632 | logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 633 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 634 | return err |
| 635 | } |
| 636 | oo.uploadSequNo = 0 |
| 637 | oo.uploadNoOfCmds = 0 |
| 638 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 639 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 640 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 641 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 642 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 643 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 644 | } |
| 645 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 646 | func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 647 | logger.Debugw("send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 648 | request := &omci.MibUploadNextRequest{ |
| 649 | MeBasePacket: omci.MeBasePacket{ |
| 650 | EntityClass: me.OnuDataClassID, |
| 651 | }, |
| 652 | CommandSequenceNumber: oo.uploadSequNo, |
| 653 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 654 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 655 | pkt, err := serialize(omci.MibUploadNextRequestType, request, tid) |
| 656 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 657 | logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 658 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 659 | return err |
| 660 | } |
| 661 | oo.uploadSequNo++ |
| 662 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 663 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 664 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 665 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 666 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 667 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 668 | } |
| 669 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 670 | func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 671 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 672 | logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 673 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 674 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 675 | meParams := me.ParamData{ |
| 676 | EntityID: galEthernetEID, |
| 677 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 678 | } |
| 679 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 680 | if omciErr.GetError() == nil { |
| 681 | //all setByCreate parameters already set, no default option required ... |
| 682 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 683 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 684 | logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 685 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 686 | return nil |
| 687 | } |
| 688 | |
| 689 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 690 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 691 | logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 692 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 693 | return nil |
| 694 | } |
| 695 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 696 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 697 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 698 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 699 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 700 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 701 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 702 | logger.Errorw("Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 703 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 704 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 705 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 706 | logger.Debug("send GalEnetProfile-Create-msg done") |
| 707 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 708 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 709 | logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 710 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 711 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 712 | } |
| 713 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 714 | // might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!! |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 715 | func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 716 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 717 | logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 718 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 719 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 720 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 721 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 722 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 723 | // read ONU-2G from DB ???? //TODO!!! |
| 724 | meParams := me.ParamData{ |
| 725 | EntityID: 0, |
| 726 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 727 | } |
| 728 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 729 | if omciErr.GetError() == nil { |
| 730 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 731 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 732 | logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 733 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 734 | return nil |
| 735 | } |
| 736 | |
| 737 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 738 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 739 | logger.Errorw("Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 740 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 741 | return nil |
| 742 | } |
| 743 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 744 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 745 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 746 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 747 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 748 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 749 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 750 | logger.Errorw("Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 751 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 752 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 753 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 754 | logger.Debug("send ONU2-G-Set-msg done") |
| 755 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 756 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 757 | logger.Errorw("Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 758 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 759 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 760 | } |
| 761 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 762 | func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 763 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 764 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 765 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 766 | logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 767 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 768 | |
| 769 | meParams := me.ParamData{ |
| 770 | EntityID: instID, |
| 771 | Attributes: me.AttributeValueMap{ |
| 772 | "Priority": 0x8000, |
| 773 | "MaxAge": 20 * 256, //20s |
| 774 | "HelloTime": 2 * 256, //2s |
| 775 | "ForwardDelay": 15 * 256, //15s |
| 776 | //note: DynamicFilteringAgeingTime is taken from omci lib default as |
| 777 | // which is obviously different from default value used in python lib, |
| 778 | // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ... |
| 779 | }, |
| 780 | } |
| 781 | |
| 782 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 783 | if omciErr.GetError() == nil { |
| 784 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 785 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 786 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 787 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 788 | logger.Errorw("Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 789 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 790 | return nil |
| 791 | } |
| 792 | |
| 793 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 794 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 795 | logger.Errorw("Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 796 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 797 | return nil |
| 798 | } |
| 799 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 800 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 801 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 802 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 803 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 804 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 805 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 806 | logger.Errorw("Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 807 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 808 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 809 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 810 | logger.Debug("send MBSP-Create-msg done") |
| 811 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 812 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 813 | logger.Errorw("Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 814 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 815 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 816 | } |
| 817 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 818 | func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context, |
| 819 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 820 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 821 | instID := macBridgePortAniEID + aPUniPort.entityID |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 822 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 823 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 824 | |
| 825 | meParams := me.ParamData{ |
| 826 | EntityID: instID, |
| 827 | Attributes: me.AttributeValueMap{ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 828 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo), |
| 829 | "PortNum": aPUniPort.macBpNo, |
| 830 | "TpType": uint8(aPUniPort.portType), |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 831 | "TpPointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 832 | }, |
| 833 | } |
| 834 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 835 | if omciErr.GetError() == nil { |
| 836 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 837 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 838 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 839 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 840 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 841 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 842 | return nil |
| 843 | } |
| 844 | |
| 845 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 846 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 847 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 848 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 849 | return nil |
| 850 | } |
| 851 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 852 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 853 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 854 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 855 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 856 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 857 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 858 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 859 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 860 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 861 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 862 | logger.Debug("send MBPCD-Create-msg done") |
| 863 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 864 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 865 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 866 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 867 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 868 | } |
| 869 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 870 | func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 871 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 872 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 873 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 874 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 875 | logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 876 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 877 | |
| 878 | // compare python adapter code WA VOL-1311: this is not done here! |
| 879 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 880 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 881 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 882 | if aPUniPort.portType == uniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 883 | assType = uint8(10) // for VEIP |
| 884 | } |
| 885 | meParams := me.ParamData{ |
| 886 | EntityID: instID, |
| 887 | Attributes: me.AttributeValueMap{ |
| 888 | "AssociationType": assType, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 889 | "AssociatedMePointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 890 | }, |
| 891 | } |
| 892 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 893 | if omciErr.GetError() == nil { |
| 894 | //all setByCreate parameters already set, no default option required ... |
| 895 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 896 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 897 | logger.Errorw("Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 898 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 899 | return nil |
| 900 | } |
| 901 | |
| 902 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 903 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 904 | logger.Errorw("Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 905 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 906 | return nil |
| 907 | } |
| 908 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 909 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 910 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 911 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 912 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 913 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 914 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 915 | logger.Errorw("Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 916 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 917 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 918 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 919 | logger.Debug("send EVTOCD-Create-msg done") |
| 920 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 921 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 922 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 923 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 924 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 925 | } |
| 926 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 927 | func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 928 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 929 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 930 | logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 931 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 932 | |
| 933 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 934 | meParams := me.ParamData{ |
| 935 | EntityID: 0, |
| 936 | Attributes: requestedAttributes, |
| 937 | } |
| 938 | meInstance, omciErr := me.NewOnuG(meParams) |
| 939 | if omciErr.GetError() == nil { |
| 940 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 941 | if err != nil { |
| 942 | logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 943 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 944 | return nil |
| 945 | } |
| 946 | |
| 947 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 948 | if err != nil { |
| 949 | logger.Errorw("Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 950 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 951 | return nil |
| 952 | } |
| 953 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 954 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 955 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 956 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 957 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 958 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 959 | if err != nil { |
| 960 | logger.Errorw("Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 961 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 962 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 963 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 964 | logger.Debug("send ONU-G-Set-msg done") |
| 965 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 966 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 967 | logger.Errorw("Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 968 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 969 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 970 | } |
| 971 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 972 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 973 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 974 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 975 | logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 976 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 977 | |
| 978 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 979 | meParams := me.ParamData{ |
| 980 | EntityID: aInstNo, |
| 981 | Attributes: requestedAttributes, |
| 982 | } |
| 983 | meInstance, omciErr := me.NewUniG(meParams) |
| 984 | if omciErr.GetError() == nil { |
| 985 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 986 | if err != nil { |
| 987 | logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 988 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 989 | return nil |
| 990 | } |
| 991 | |
| 992 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 993 | if err != nil { |
| 994 | logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 995 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 996 | return nil |
| 997 | } |
| 998 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 999 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1000 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1001 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1002 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1003 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1004 | if err != nil { |
| 1005 | logger.Errorw("Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1006 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1007 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1008 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1009 | logger.Debug("send UNI-G-Set-msg done") |
| 1010 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1011 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1012 | logger.Errorw("Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1013 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1014 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1017 | func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1018 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1019 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1020 | logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1021 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1022 | |
| 1023 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1024 | meParams := me.ParamData{ |
| 1025 | EntityID: aInstNo, |
| 1026 | Attributes: requestedAttributes, |
| 1027 | } |
| 1028 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1029 | if omciErr.GetError() == nil { |
| 1030 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1031 | if err != nil { |
| 1032 | logger.Errorw("Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1033 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1034 | return nil |
| 1035 | } |
| 1036 | |
| 1037 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1038 | if err != nil { |
| 1039 | logger.Errorw("Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1040 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1041 | return nil |
| 1042 | } |
| 1043 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1044 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1045 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1046 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1047 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1048 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1049 | if err != nil { |
| 1050 | logger.Errorw("Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1051 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1052 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1053 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1054 | logger.Debug("send VEIP-Set-msg done") |
| 1055 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1056 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1057 | logger.Errorw("Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1058 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1059 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1060 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1061 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1062 | func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1063 | timeout int, highPrio bool) *me.ManagedEntity { |
| 1064 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1065 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1066 | logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1067 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1068 | |
| 1069 | meParams := me.ParamData{ |
| 1070 | EntityID: entityID, |
| 1071 | Attributes: requestedAttributes, |
| 1072 | } |
| 1073 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1074 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1075 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1076 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1077 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1078 | logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1079 | return nil |
| 1080 | } |
| 1081 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1082 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1083 | logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1084 | return nil |
| 1085 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1086 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1087 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1088 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1089 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1090 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1091 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1092 | logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1093 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1094 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1095 | logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1096 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1097 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1098 | logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1099 | return nil |
| 1100 | } |
| 1101 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1102 | func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1103 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1104 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1105 | logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1106 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1107 | |
| 1108 | meParams := me.ParamData{ |
| 1109 | EntityID: aInstID, |
| 1110 | Attributes: me.AttributeValueMap{}, |
| 1111 | } |
| 1112 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1113 | if omciErr.GetError() == nil { |
| 1114 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1115 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1116 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1117 | if err != nil { |
| 1118 | logger.Errorw("Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1119 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1120 | return nil |
| 1121 | } |
| 1122 | |
| 1123 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1124 | if err != nil { |
| 1125 | logger.Errorw("Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1126 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1127 | return nil |
| 1128 | } |
| 1129 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1130 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1131 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1132 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1133 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1134 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1135 | if err != nil { |
| 1136 | logger.Errorw("Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1137 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1138 | return nil |
| 1139 | } |
| 1140 | logger.Debug("send .1pMapper-create-msg done") |
| 1141 | return meInstance |
| 1142 | } |
| 1143 | logger.Errorw("Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1144 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1145 | return nil |
| 1146 | } |
| 1147 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1148 | func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1149 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1150 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1151 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1152 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1153 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1154 | |
| 1155 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1156 | if omciErr.GetError() == nil { |
| 1157 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1158 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1159 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1160 | if err != nil { |
| 1161 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1162 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1163 | return nil |
| 1164 | } |
| 1165 | |
| 1166 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1167 | if err != nil { |
| 1168 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1169 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1170 | return nil |
| 1171 | } |
| 1172 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1173 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1174 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1175 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1176 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1177 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1178 | if err != nil { |
| 1179 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1180 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1181 | return nil |
| 1182 | } |
| 1183 | logger.Debug("send MBPCD-Create-msg done") |
| 1184 | return meInstance |
| 1185 | } |
| 1186 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1187 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1188 | return nil |
| 1189 | } |
| 1190 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1191 | func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1192 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1193 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1194 | logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1195 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1196 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1197 | |
| 1198 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1199 | if omciErr.GetError() == nil { |
| 1200 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1201 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1202 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1203 | if err != nil { |
| 1204 | logger.Errorw("Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1205 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1206 | return nil |
| 1207 | } |
| 1208 | |
| 1209 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1210 | if err != nil { |
| 1211 | logger.Errorw("Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1212 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1213 | return nil |
| 1214 | } |
| 1215 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1216 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1217 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1218 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1219 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1220 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1221 | if err != nil { |
| 1222 | logger.Errorw("Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1223 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1224 | return nil |
| 1225 | } |
| 1226 | logger.Debug("send GemNCTP-Create-msg done") |
| 1227 | return meInstance |
| 1228 | } |
| 1229 | logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1230 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1231 | return nil |
| 1232 | } |
| 1233 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1234 | func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1235 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1236 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1237 | logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1238 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1239 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1240 | |
| 1241 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1242 | if omciErr.GetError() == nil { |
| 1243 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1244 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1245 | omci.TransactionID(tid)) |
| 1246 | if err != nil { |
| 1247 | logger.Errorw("Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1248 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1249 | return nil |
| 1250 | } |
| 1251 | |
| 1252 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1253 | if err != nil { |
| 1254 | logger.Errorw("Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1255 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1256 | return nil |
| 1257 | } |
| 1258 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1259 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1260 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1261 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1262 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1263 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1264 | if err != nil { |
| 1265 | logger.Errorw("Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1266 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1267 | return nil |
| 1268 | } |
| 1269 | logger.Debug("send GemIwTp-Create-msg done") |
| 1270 | return meInstance |
| 1271 | } |
| 1272 | logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1273 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1274 | return nil |
| 1275 | } |
| 1276 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1277 | func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1278 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1279 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1280 | logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1281 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1282 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1283 | |
| 1284 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1285 | if omciErr.GetError() == nil { |
| 1286 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1287 | if err != nil { |
| 1288 | logger.Errorw("Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1289 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1290 | return nil |
| 1291 | } |
| 1292 | |
| 1293 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1294 | if err != nil { |
| 1295 | logger.Errorw("Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1296 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1297 | return nil |
| 1298 | } |
| 1299 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1300 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1301 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1302 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1303 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1304 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1305 | if err != nil { |
| 1306 | logger.Errorw("Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1307 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1308 | return nil |
| 1309 | } |
| 1310 | logger.Debug("send TCont-set msg done") |
| 1311 | return meInstance |
| 1312 | } |
| 1313 | logger.Errorw("Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1314 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1315 | return nil |
| 1316 | } |
| 1317 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1318 | func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1319 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1320 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1321 | logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1322 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1323 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1324 | |
| 1325 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1326 | if omciErr.GetError() == nil { |
| 1327 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1328 | if err != nil { |
| 1329 | logger.Errorw("Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1330 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1331 | return nil |
| 1332 | } |
| 1333 | |
| 1334 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1335 | if err != nil { |
| 1336 | logger.Errorw("Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1337 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1338 | return nil |
| 1339 | } |
| 1340 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1341 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1342 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1343 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1344 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1345 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1346 | if err != nil { |
| 1347 | logger.Errorw("Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1348 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1349 | return nil |
| 1350 | } |
| 1351 | logger.Debug("send PrioQueue-set msg done") |
| 1352 | return meInstance |
| 1353 | } |
| 1354 | logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1355 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1356 | return nil |
| 1357 | } |
| 1358 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1359 | func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1360 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1361 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1362 | logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1363 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1364 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1365 | |
| 1366 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1367 | if omciErr.GetError() == nil { |
| 1368 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1369 | if err != nil { |
| 1370 | logger.Errorw("Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1371 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1372 | return nil |
| 1373 | } |
| 1374 | |
| 1375 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1376 | if err != nil { |
| 1377 | logger.Errorw("Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1378 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1379 | return nil |
| 1380 | } |
| 1381 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1382 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1383 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1384 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1385 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1386 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1387 | if err != nil { |
| 1388 | logger.Errorw("Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1389 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1390 | return nil |
| 1391 | } |
| 1392 | logger.Debug("send 1PMapper-set msg done") |
| 1393 | return meInstance |
| 1394 | } |
| 1395 | logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1396 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1397 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1398 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1399 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1400 | func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1401 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1402 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1403 | logger.Debugw("send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1404 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1405 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1406 | |
| 1407 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1408 | if omciErr.GetError() == nil { |
| 1409 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1410 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1411 | omci.TransactionID(tid)) |
| 1412 | if err != nil { |
| 1413 | logger.Errorw("Cannot encode VTFD for create", log.Fields{ |
| 1414 | "Err": err, "device-id": oo.deviceID}) |
| 1415 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1416 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1417 | // (relevant to all used sendXX() methods and their error conditions) |
| 1418 | return nil |
| 1419 | } |
| 1420 | |
| 1421 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1422 | if err != nil { |
| 1423 | logger.Errorw("Cannot serialize VTFD create", log.Fields{ |
| 1424 | "Err": err, "device-id": oo.deviceID}) |
| 1425 | return nil |
| 1426 | } |
| 1427 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1428 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1429 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1430 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1431 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1432 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1433 | if err != nil { |
| 1434 | logger.Errorw("Cannot send VTFD create", log.Fields{ |
| 1435 | "Err": err, "device-id": oo.deviceID}) |
| 1436 | return nil |
| 1437 | } |
| 1438 | logger.Debug("send VTFD-Create-msg done") |
| 1439 | return meInstance |
| 1440 | } |
| 1441 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1442 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1443 | return nil |
| 1444 | } |
| 1445 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame^] | 1446 | func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
| 1447 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1448 | tid := oo.getNextTid(highPrio) |
| 1449 | logger.Debugw("send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1450 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1451 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1452 | |
| 1453 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1454 | if omciErr.GetError() == nil { |
| 1455 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, |
| 1456 | omci.TransactionID(tid)) |
| 1457 | if err != nil { |
| 1458 | logger.Errorw("Cannot encode VTFD for set", log.Fields{ |
| 1459 | "Err": err, "device-id": oo.deviceID}) |
| 1460 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1461 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1462 | // (relevant to all used sendXX() methods and their error conditions) |
| 1463 | return nil |
| 1464 | } |
| 1465 | |
| 1466 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1467 | if err != nil { |
| 1468 | logger.Errorw("Cannot serialize VTFD set", log.Fields{ |
| 1469 | "Err": err, "device-id": oo.deviceID}) |
| 1470 | return nil |
| 1471 | } |
| 1472 | |
| 1473 | omciRxCallbackPair := callbackPair{ |
| 1474 | cbKey: tid, |
| 1475 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1476 | } |
| 1477 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1478 | if err != nil { |
| 1479 | logger.Errorw("Cannot send VTFD set", log.Fields{ |
| 1480 | "Err": err, "device-id": oo.deviceID}) |
| 1481 | return nil |
| 1482 | } |
| 1483 | logger.Debug("send VTFD-Set-msg done") |
| 1484 | return meInstance |
| 1485 | } |
| 1486 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1487 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1488 | return nil |
| 1489 | } |
| 1490 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1491 | func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1492 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1493 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1494 | logger.Debugw("send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1495 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1496 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1497 | |
| 1498 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1499 | if omciErr.GetError() == nil { |
| 1500 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1501 | if err != nil { |
| 1502 | logger.Errorw("Cannot encode EVTOCD for set", log.Fields{ |
| 1503 | "Err": err, "device-id": oo.deviceID}) |
| 1504 | return nil |
| 1505 | } |
| 1506 | |
| 1507 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1508 | if err != nil { |
| 1509 | logger.Errorw("Cannot serialize EVTOCD set", log.Fields{ |
| 1510 | "Err": err, "device-id": oo.deviceID}) |
| 1511 | return nil |
| 1512 | } |
| 1513 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1514 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1515 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1516 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1517 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1518 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1519 | if err != nil { |
| 1520 | logger.Errorw("Cannot send EVTOCD set", log.Fields{ |
| 1521 | "Err": err, "device-id": oo.deviceID}) |
| 1522 | return nil |
| 1523 | } |
| 1524 | logger.Debug("send EVTOCD-set msg done") |
| 1525 | return meInstance |
| 1526 | } |
| 1527 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
| 1528 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1529 | return nil |
| 1530 | } |