Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +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 | |
| 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
| 19 | |
| 20 | import ( |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 21 | "context" |
| 22 | "errors" |
| 23 | "time" |
| 24 | |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 25 | "github.com/looplab/fsm" |
| 26 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 27 | "github.com/opencord/omci-lib-go" |
| 28 | me "github.com/opencord/omci-lib-go/generated" |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 29 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 30 | //ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 31 | //"github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 32 | //"github.com/opencord/voltha-protos/v3/go/voltha" |
| 33 | ) |
| 34 | |
| 35 | func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(e *fsm.Event) { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 36 | logger.Debugw("MibDownload FSM", log.Fields{"Start downloading OMCI MIB in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID}) |
| 37 | // in case the used channel is not yet defined (can be re-used after restarts) |
| 38 | if onuDeviceEntry.omciMessageReceived == nil { |
| 39 | onuDeviceEntry.omciMessageReceived = make(chan bool) |
| 40 | logger.Debug("MibDownload FSM - defining the BridgeInit RxChannel") |
| 41 | } |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 42 | // start go routine for processing of MibDownload messages |
| 43 | go onuDeviceEntry.ProcessMibDownloadMessages() |
| 44 | } |
| 45 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 46 | func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(e *fsm.Event) { |
| 47 | logger.Debugw("MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID}) |
| 48 | meInstance := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(context.TODO(), ConstDefaultOmciTimeout, true) |
| 49 | //accept also nil as (error) return value for writing to LastTx |
| 50 | // - this avoids misinterpretation of new received OMCI messages |
| 51 | onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance |
| 52 | } |
| 53 | |
| 54 | func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(e *fsm.Event) { |
| 55 | logger.Debugw("MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID}) |
| 56 | meInstance := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(context.TODO(), ConstDefaultOmciTimeout, true) |
| 57 | //accept also nil as (error) return value for writing to LastTx |
| 58 | // - this avoids misinterpretation of new received OMCI messages |
| 59 | onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance |
| 60 | } |
| 61 | |
| 62 | func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(e *fsm.Event) { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 63 | logger.Infow("MibDownload FSM - starting bridge config port loop", log.Fields{ |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 64 | "in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID}) |
| 65 | go onuDeviceEntry.performInitialBridgeSetup() |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(e *fsm.Event) { |
| 69 | logger.Debugw("MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID}) |
| 70 | onuDeviceEntry.transferSystemEvent(MibDownloadDone) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 71 | //let's reset the state machine in order to release all resources now |
| 72 | pMibDlFsm := onuDeviceEntry.pMibDownloadFsm |
| 73 | if pMibDlFsm != nil { |
| 74 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
| 75 | go func(a_pAFsm *AdapterFsm) { |
| 76 | if a_pAFsm != nil && a_pAFsm.pFsm != nil { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 77 | a_pAFsm.pFsm.Event(dlEvReset) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 78 | } |
| 79 | }(pMibDlFsm) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(e *fsm.Event) { |
| 84 | logger.Debugw("MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID}) |
| 85 | pMibDlFsm := onuDeviceEntry.pMibDownloadFsm |
| 86 | if pMibDlFsm != nil { |
| 87 | // abort running message processing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 88 | fsmAbortMsg := Message{ |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 89 | Type: TestMsg, |
| 90 | Data: TestMessage{ |
| 91 | TestMessageVal: AbortMessageProcessing, |
| 92 | }, |
| 93 | } |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 94 | pMibDlFsm.commChan <- fsmAbortMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 95 | |
| 96 | //try to restart the FSM to 'disabled' |
| 97 | // see DownloadedState: decouple event transfer |
| 98 | go func(a_pAFsm *AdapterFsm) { |
| 99 | if a_pAFsm != nil && a_pAFsm.pFsm != nil { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 100 | a_pAFsm.pFsm.Event(dlEvRestart) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 101 | } |
| 102 | }(pMibDlFsm) |
| 103 | } |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | func (onuDeviceEntry *OnuDeviceEntry) ProcessMibDownloadMessages( /*ctx context.Context*/ ) { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 107 | logger.Debugw("Start MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 108 | loop: |
| 109 | for { |
| 110 | select { |
| 111 | // case <-ctx.Done(): |
| 112 | // logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID}) |
| 113 | // break loop |
| 114 | case message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan: |
| 115 | if !ok { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 116 | logger.Info("MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID}) |
| 117 | // but then we have to ensure a restart of the FSM as well - as exceptional procedure |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 118 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 119 | break loop |
| 120 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 121 | logger.Debugw("MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID}) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 122 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 123 | switch message.Type { |
| 124 | case TestMsg: |
| 125 | msg, _ := message.Data.(TestMessage) |
| 126 | if msg.TestMessageVal == AbortMessageProcessing { |
| 127 | logger.Infow("MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
| 128 | break loop |
| 129 | } |
| 130 | logger.Warnw("MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal}) |
| 131 | case OMCI: |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 132 | msg, _ := message.Data.(OmciMessage) |
| 133 | onuDeviceEntry.handleOmciMibDownloadMessage(msg) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 134 | default: |
| 135 | logger.Warn("MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID, |
| 136 | "message.Type": message.Type}) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 140 | logger.Infow("End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(msg OmciMessage) { |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 144 | logger.Debugw("Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID, |
| 145 | "msgType": msg.OmciMsg.MessageType}) |
| 146 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 147 | switch msg.OmciMsg.MessageType { |
| 148 | case omci.CreateResponseType: |
| 149 | { |
| 150 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 151 | if msgLayer == nil { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 152 | logger.Error("Omci Msg layer could not be detected for CreateResponse") |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 153 | return |
| 154 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 155 | msgObj, msgOk := msgLayer.(*omci.CreateResponse) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 156 | if !msgOk { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 157 | logger.Error("Omci Msg layer could not be assigned for CreateResponse") |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 158 | return |
| 159 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 160 | logger.Debugw("CreateResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj}) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 161 | if msgObj.Result != me.Success { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 162 | logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result}) |
| 163 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 164 | return |
| 165 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 166 | // maybe there is a way of pushing the specific create response type generally to the FSM |
| 167 | // and let the FSM verify, if the response was according to current state |
| 168 | // and possibly store the element to DB and progress - maybe some future option ... |
| 169 | // but as that is not straightforward to me I insert the type checkes manually here |
| 170 | // and feed the FSM with only 'pre-defined' events ... |
| 171 | if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() && |
| 172 | msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() { |
| 173 | //store the created ME into DB //TODO??? obviously the Python code does not store the config ... |
| 174 | // if, then something like: |
| 175 | //onuDeviceEntry.pOnuDB.StoreMe(msgObj) |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 176 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 177 | // maybe we can use just the same eventName for different state transitions like "forward" |
| 178 | // - might be checked, but so far I go for sure and have to inspect the concrete state events ... |
| 179 | switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() { |
| 180 | case "GalEthernetProfile": |
| 181 | { // let the FSM proceed ... |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 182 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 183 | } |
| 184 | case "MacBridgeServiceProfile", |
| 185 | "MacBridgePortConfigurationData", |
| 186 | "ExtendedVlanTaggingOperationConfigurationData": |
| 187 | { // let bridge init proceed by stopping the wait function |
| 188 | onuDeviceEntry.omciMessageReceived <- true |
| 189 | } |
| 190 | } |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 191 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 192 | } //CreateResponseType |
| 193 | //TODO |
| 194 | // onuDeviceEntry.pMibDownloadFsm.pFsm.Event("rx_evtocd_resp") |
| 195 | |
| 196 | case omci.SetResponseType: |
| 197 | { |
| 198 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse) |
| 199 | if msgLayer == nil { |
| 200 | logger.Error("Omci Msg layer could not be detected for SetResponse") |
| 201 | return |
| 202 | } |
| 203 | msgObj, msgOk := msgLayer.(*omci.SetResponse) |
| 204 | if !msgOk { |
| 205 | logger.Error("Omci Msg layer could not be assigned for SetResponse") |
| 206 | return |
| 207 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 208 | logger.Debugw("SetResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 209 | if msgObj.Result != me.Success { |
| 210 | logger.Errorw("Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result}) |
| 211 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 212 | return |
| 213 | } |
| 214 | // compare comments above for CreateResponse (apply also here ...) |
| 215 | if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() && |
| 216 | msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() { |
| 217 | //store the created ME into DB //TODO??? obviously the Python code does not store the config ... |
| 218 | // if, then something like: |
| 219 | //onuDeviceEntry.pOnuDB.StoreMe(msgObj) |
| 220 | |
| 221 | switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() { |
| 222 | case "Onu2G": |
| 223 | { // let the FSM proceed ... |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 224 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 225 | } |
| 226 | //so far that was the only MibDownlad Set Element ... |
| 227 | } |
| 228 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 229 | } //SetResponseType |
| 230 | default: |
| 231 | { |
| 232 | logger.Errorw("Rx OMCI MibDownload unhandled MsgType", log.Fields{"omciMsgType": msg.OmciMsg.MessageType}) |
| 233 | return |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 234 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 235 | } // switch msg.OmciMsg.MessageType |
| 236 | } |
| 237 | |
| 238 | func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup() { |
| 239 | for uniNo, uniPort := range onuDeviceEntry.baseDeviceHandler.uniEntityMap { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 240 | logger.Debugw("Starting IntialBridgeSetup", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 241 | "device-id": onuDeviceEntry.deviceID, "for PortNo": uniNo}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 242 | |
| 243 | //create MBSP |
| 244 | meInstance := onuDeviceEntry.PDevOmciCC.sendCreateMBServiceProfile( |
| 245 | context.TODO(), uniPort, ConstDefaultOmciTimeout, true) |
| 246 | onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance |
| 247 | //verify response |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 248 | err := onuDeviceEntry.waitforOmciResponse(meInstance) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 249 | if err != nil { |
| 250 | logger.Error("InitialBridgeSetup failed at MBSP, aborting MIB Download!") |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 251 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 252 | return |
| 253 | } |
| 254 | |
| 255 | //create MBPCD |
| 256 | meInstance = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigData( |
| 257 | context.TODO(), uniPort, ConstDefaultOmciTimeout, true) |
| 258 | onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance |
| 259 | //verify response |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 260 | err = onuDeviceEntry.waitforOmciResponse(meInstance) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 261 | if err != nil { |
| 262 | logger.Error("InitialBridgeSetup failed at MBPCD, aborting MIB Download!") |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 263 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 264 | return |
| 265 | } |
| 266 | |
| 267 | //create EVTOCD |
| 268 | meInstance = onuDeviceEntry.PDevOmciCC.sendCreateEVTOConfigData( |
| 269 | context.TODO(), uniPort, ConstDefaultOmciTimeout, true) |
| 270 | onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance |
| 271 | //verify response |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 272 | err = onuDeviceEntry.waitforOmciResponse(meInstance) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 273 | if err != nil { |
| 274 | logger.Error("InitialBridgeSetup failed at EVTOCD, aborting MIB Download!") |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 275 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 276 | return |
| 277 | } |
| 278 | } |
| 279 | // if Config has been done for all UNI related instances let the FSM proceed |
| 280 | // while we did not check here, if there is some port at all - !? |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 281 | logger.Infow("IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID}) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 282 | onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 283 | return |
| 284 | } |
| 285 | |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 286 | func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(apMeInstance *me.ManagedEntity) error { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 287 | select { |
| 288 | // maybe be also some outside cancel (but no context modelled for the moment ...) |
| 289 | // case <-ctx.Done(): |
| 290 | // logger.Info("MibDownload-bridge-init message reception canceled", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
mpagenko | 3af1f03 | 2020-06-10 08:53:41 +0000 | [diff] [blame] | 291 | case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 292 | logger.Warnw("MibDownload-bridge-init timeout", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
| 293 | return errors.New("MibDownloadBridgeInit timeout") |
| 294 | case success := <-onuDeviceEntry.omciMessageReceived: |
| 295 | if success == true { |
| 296 | logger.Debug("MibDownload-bridge-init response received") |
| 297 | return nil |
| 298 | } |
| 299 | // should not happen so far |
| 300 | logger.Warnw("MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID}) |
| 301 | return errors.New("MibDownloadBridgeInit responseError") |
| 302 | } |
Holger Hildebrandt | 9ac0d0f | 2020-05-13 11:22:02 +0000 | [diff] [blame] | 303 | } |