blob: e79abe2fc6da93523d9f2454c3b34974c94368f5 [file] [log] [blame]
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +00001/*
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
18package adaptercoreonu
19
20import (
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000021 "context"
Andrea Campanella6515c582020-10-05 11:25:00 +020022 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000023 "time"
24
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +000025 "github.com/looplab/fsm"
26
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000027 "github.com/opencord/omci-lib-go"
28 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000029 "github.com/opencord/voltha-lib-go/v4/pkg/log"
30 //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
31 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
32 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +000033)
34
dbainbri4d3a0dc2020-12-02 00:33:42 +000035func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(ctx context.Context, e *fsm.Event) {
36 logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Start downloading OMCI MIB in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000037 // 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)
dbainbri4d3a0dc2020-12-02 00:33:42 +000040 logger.Debug(ctx, "MibDownload FSM - defining the BridgeInit RxChannel")
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000041 }
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +000042 // start go routine for processing of MibDownload messages
dbainbri4d3a0dc2020-12-02 00:33:42 +000043 go onuDeviceEntry.processMibDownloadMessages(ctx)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +000044}
45
dbainbri4d3a0dc2020-12-02 00:33:42 +000046func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(ctx context.Context, e *fsm.Event) {
47 logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
Girish Gowdra0b235842021-03-09 13:06:46 -080048 meInstance := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx), onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000049 //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
dbainbri4d3a0dc2020-12-02 00:33:42 +000054func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(ctx context.Context, e *fsm.Event) {
55 logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
Girish Gowdra0b235842021-03-09 13:06:46 -080056 meInstance := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx), onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000057 //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
dbainbri4d3a0dc2020-12-02 00:33:42 +000062func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(ctx context.Context, e *fsm.Event) {
63 logger.Debugw(ctx, "MibDownload FSM - starting bridge config port loop", log.Fields{
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000064 "in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
dbainbri4d3a0dc2020-12-02 00:33:42 +000065 go onuDeviceEntry.performInitialBridgeSetup(ctx)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +000066}
67
dbainbri4d3a0dc2020-12-02 00:33:42 +000068func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(ctx context.Context, e *fsm.Event) {
69 logger.Debugw(ctx, "MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
70 onuDeviceEntry.transferSystemEvent(ctx, MibDownloadDone)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000071 //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 {
Himani Chawla4d908332020-08-31 12:30:20 +053077 _ = a_pAFsm.pFsm.Event(dlEvReset)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000078 }
79 }(pMibDlFsm)
80 }
81}
82
dbainbri4d3a0dc2020-12-02 00:33:42 +000083func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(ctx context.Context, e *fsm.Event) {
84 logger.Debugw(ctx, "MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000085 pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
86 if pMibDlFsm != nil {
87 // abort running message processing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000088 fsmAbortMsg := Message{
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000089 Type: TestMsg,
90 Data: TestMessage{
91 TestMessageVal: AbortMessageProcessing,
92 },
93 }
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000094 pMibDlFsm.commChan <- fsmAbortMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000095
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 {
Himani Chawla4d908332020-08-31 12:30:20 +0530100 _ = a_pAFsm.pFsm.Event(dlEvRestart)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000101 }
102 }(pMibDlFsm)
103 }
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000104}
105
dbainbri4d3a0dc2020-12-02 00:33:42 +0000106func (onuDeviceEntry *OnuDeviceEntry) processMibDownloadMessages(ctx context.Context) {
107 logger.Debugw(ctx, "Start MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000108loop:
109 for {
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000110 // case <-ctx.Done():
111 // logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
112 // break loop
Himani Chawla4d908332020-08-31 12:30:20 +0530113 // unless multiple channels are not involved, we should not use select
114 message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan
115 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000116 logger.Info(ctx, "MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530117 // but then we have to ensure a restart of the FSM as well - as exceptional procedure
118 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart)
119 break loop
120 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000121 logger.Debugw(ctx, "MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530122
123 switch message.Type {
124 case TestMsg:
125 msg, _ := message.Data.(TestMessage)
126 if msg.TestMessageVal == AbortMessageProcessing {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000127 logger.Debugw(ctx, "MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000128 break loop
129 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000130 logger.Warnw(ctx, "MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
Himani Chawla4d908332020-08-31 12:30:20 +0530131 case OMCI:
132 msg, _ := message.Data.(OmciMessage)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000133 onuDeviceEntry.handleOmciMibDownloadMessage(ctx, msg)
Himani Chawla4d908332020-08-31 12:30:20 +0530134 default:
dbainbri4d3a0dc2020-12-02 00:33:42 +0000135 logger.Warn(ctx, "MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
Himani Chawla4d908332020-08-31 12:30:20 +0530136 "message.Type": message.Type})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000137 }
Himani Chawla4d908332020-08-31 12:30:20 +0530138
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000139 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000140 logger.Debugw(ctx, "End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000141}
142
dbainbri4d3a0dc2020-12-02 00:33:42 +0000143func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg OmciMessage) {
144 logger.Debugw(ctx, "Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID,
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000145 "msgType": msg.OmciMsg.MessageType})
146
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000147 switch msg.OmciMsg.MessageType {
148 case omci.CreateResponseType:
149 {
150 msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000151 if msgLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000152 logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000153 return
154 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000155 msgObj, msgOk := msgLayer.(*omci.CreateResponse)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000156 if !msgOk {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000157 logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000158 return
159 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000160 logger.Debugw(ctx, "CreateResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300161 if msgObj.Result != me.Success && msgObj.Result != me.InstanceExists {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000162 logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID, "Error": msgObj.Result})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000163 // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000164 return
165 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000166 // 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 Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000176
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000177 // 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 ...
Himani Chawla4d908332020-08-31 12:30:20 +0530182 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000183 }
184 case "MacBridgeServiceProfile",
185 "MacBridgePortConfigurationData",
186 "ExtendedVlanTaggingOperationConfigurationData":
187 { // let bridge init proceed by stopping the wait function
188 onuDeviceEntry.omciMessageReceived <- true
189 }
190 }
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000191 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000192 } //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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000200 logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000201 return
202 }
203 msgObj, msgOk := msgLayer.(*omci.SetResponse)
204 if !msgOk {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000205 logger.Errorw(ctx, "Omci Msg layer could not be assigned for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000206 return
207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000208 logger.Debugw(ctx, "SetResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000209 if msgObj.Result != me.Success {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000210 logger.Errorw(ctx, "Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID,
Andrea Campanella6515c582020-10-05 11:25:00 +0200211 "Error": msgObj.Result})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000212 // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
213 return
214 }
215 // compare comments above for CreateResponse (apply also here ...)
216 if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() &&
217 msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() {
218 //store the created ME into DB //TODO??? obviously the Python code does not store the config ...
219 // if, then something like:
220 //onuDeviceEntry.pOnuDB.StoreMe(msgObj)
221
222 switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
223 case "Onu2G":
224 { // let the FSM proceed ...
Himani Chawla4d908332020-08-31 12:30:20 +0530225 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000226 }
227 //so far that was the only MibDownlad Set Element ...
228 }
229 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000230 } //SetResponseType
231 default:
232 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000233 logger.Errorw(ctx, "Rx OMCI MibDownload unhandled MsgType", log.Fields{"device-id": onuDeviceEntry.deviceID,
Andrea Campanella6515c582020-10-05 11:25:00 +0200234 "omciMsgType": msg.OmciMsg.MessageType})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000235 return
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000236 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000237 } // switch msg.OmciMsg.MessageType
238}
239
dbainbri4d3a0dc2020-12-02 00:33:42 +0000240func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup(ctx context.Context) {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000241 for uniNo, uniPort := range onuDeviceEntry.baseDeviceHandler.uniEntityMap {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000242 logger.Debugw(ctx, "Starting IntialBridgeSetup", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000243 "device-id": onuDeviceEntry.deviceID, "for PortNo": uniNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000244
245 //create MBSP
246 meInstance := onuDeviceEntry.PDevOmciCC.sendCreateMBServiceProfile(
Girish Gowdra0b235842021-03-09 13:06:46 -0800247 log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000248 onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
249 //verify response
dbainbri4d3a0dc2020-12-02 00:33:42 +0000250 err := onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000251 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000252 logger.Errorw(ctx, "InitialBridgeSetup failed at MBSP, aborting MIB Download!",
Andrea Campanella6515c582020-10-05 11:25:00 +0200253 log.Fields{"device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530254 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000255 return
256 }
257
258 //create MBPCD
259 meInstance = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigData(
Girish Gowdra0b235842021-03-09 13:06:46 -0800260 log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000261 onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
262 //verify response
dbainbri4d3a0dc2020-12-02 00:33:42 +0000263 err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000264 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000265 logger.Errorw(ctx, "InitialBridgeSetup failed at MBPCD, aborting MIB Download!",
Andrea Campanella6515c582020-10-05 11:25:00 +0200266 log.Fields{"device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530267 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000268 return
269 }
270
271 //create EVTOCD
272 meInstance = onuDeviceEntry.PDevOmciCC.sendCreateEVTOConfigData(
Girish Gowdra0b235842021-03-09 13:06:46 -0800273 log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000274 onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
275 //verify response
dbainbri4d3a0dc2020-12-02 00:33:42 +0000276 err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000277 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000278 logger.Errorw(ctx, "InitialBridgeSetup failed at EVTOCD, aborting MIB Download!",
Andrea Campanella6515c582020-10-05 11:25:00 +0200279 log.Fields{"device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530280 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000281 return
282 }
283 }
284 // if Config has been done for all UNI related instances let the FSM proceed
285 // while we did not check here, if there is some port at all - !?
dbainbri4d3a0dc2020-12-02 00:33:42 +0000286 logger.Infow(ctx, "IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
Himani Chawla4d908332020-08-31 12:30:20 +0530287 _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000288}
289
dbainbri4d3a0dc2020-12-02 00:33:42 +0000290func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000291 select {
Himani Chawla4d908332020-08-31 12:30:20 +0530292 // maybe be also some outside cancel (but no context modeled for the moment ...)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000293 // case <-ctx.Done():
294 // logger.Info("MibDownload-bridge-init message reception canceled", log.Fields{"for device-id": onuDeviceEntry.deviceID})
mpagenko3af1f032020-06-10 08:53:41 +0000295 case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
dbainbri4d3a0dc2020-12-02 00:33:42 +0000296 logger.Warnw(ctx, "MibDownload-bridge-init timeout", log.Fields{"for device-id": onuDeviceEntry.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200297 return fmt.Errorf("mibDownloadBridgeInit timeout %s", onuDeviceEntry.deviceID)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000298 case success := <-onuDeviceEntry.omciMessageReceived:
Himani Chawla4d908332020-08-31 12:30:20 +0530299 if success {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000300 logger.Debug(ctx, "MibDownload-bridge-init response received")
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000301 return nil
302 }
303 // should not happen so far
dbainbri4d3a0dc2020-12-02 00:33:42 +0000304 logger.Warnw(ctx, "MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200305 return fmt.Errorf("mibDownloadBridgeInit responseError %s", onuDeviceEntry.deviceID)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000306 }
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000307}