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