blob: 25ffaa36bf931a4b528f82326fc170525a749114 [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +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
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "context"
Holger Hildebrandt47555e72020-09-21 11:07:24 +000022 "encoding/json"
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000023 "errors"
Holger Hildebrandt47555e72020-09-21 11:07:24 +000024 "fmt"
25 "sync"
Holger Hildebrandt2ff21f12020-08-13 14:38:02 +000026 "time"
27
ozgecanetsiae11479f2020-07-06 09:44:47 +030028 "github.com/opencord/omci-lib-go"
29 me "github.com/opencord/omci-lib-go/generated"
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000030
Holger Hildebrandtfa074992020-03-27 15:42:06 +000031 //"sync"
32 //"time"
33
34 "github.com/looplab/fsm"
dbainbri4d3a0dc2020-12-02 00:33:42 +000035 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
36 "github.com/opencord/voltha-lib-go/v4/pkg/db"
37 "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000038
dbainbri4d3a0dc2020-12-02 00:33:42 +000039 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
40 "github.com/opencord/voltha-lib-go/v4/pkg/log"
41 //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
42 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
43 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000044)
45
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000046const (
mpagenko1cc3cb42020-07-27 15:24:38 +000047 // events of MibUpload FSM
48 ulEvStart = "ulEvStart"
49 ulEvResetMib = "ulEvResetMib"
50 ulEvGetVendorAndSerial = "ulEvGetVendorAndSerial"
Himani Chawla4d908332020-08-31 12:30:20 +053051 ulEvGetEquipmentID = "ulEvGetEquipmentId"
mpagenko1cc3cb42020-07-27 15:24:38 +000052 ulEvGetFirstSwVersion = "ulEvGetFirstSwVersion"
53 ulEvGetSecondSwVersion = "ulEvGetSecondSwVersion"
54 ulEvGetMacAddress = "ulEvGetMacAddress"
55 ulEvGetMibTemplate = "ulEvGetMibTemplate"
56 ulEvUploadMib = "ulEvUploadMib"
57 ulEvExamineMds = "ulEvExamineMds"
58 ulEvSuccess = "ulEvSuccess"
59 ulEvMismatch = "ulEvMismatch"
60 ulEvAuditMib = "ulEvAuditMib"
61 ulEvForceResync = "ulEvForceResync"
62 ulEvDiffsFound = "ulEvDiffsFound"
63 ulEvTimeout = "ulEvTimeout"
64 ulEvStop = "ulEvStop"
65)
66const (
67 // states of MibUpload FSM
68 ulStDisabled = "ulStDisabled"
69 ulStStarting = "ulStStarting"
70 ulStResettingMib = "ulStResettingMib"
71 ulStGettingVendorAndSerial = "ulStGettingVendorAndSerial"
Himani Chawla4d908332020-08-31 12:30:20 +053072 ulStGettingEquipmentID = "ulStGettingEquipmentID"
mpagenko1cc3cb42020-07-27 15:24:38 +000073 ulStGettingFirstSwVersion = "ulStGettingFirstSwVersion"
74 ulStGettingSecondSwVersion = "ulStGettingSecondSwVersion"
75 ulStGettingMacAddress = "ulStGettingMacAddress"
76 ulStGettingMibTemplate = "ulStGettingMibTemplate"
77 ulStUploading = "ulStUploading"
Holger Hildebrandt10d98192021-01-27 15:29:31 +000078 ulStUploadDone = "ulStUploadDone"
mpagenko1cc3cb42020-07-27 15:24:38 +000079 ulStInSync = "ulStInSync"
80 ulStExaminingMds = "ulStExaminingMds"
81 ulStResynchronizing = "ulStResynchronizing"
82 ulStAuditing = "ulStAuditing"
Holger Hildebrandt10d98192021-01-27 15:29:31 +000083 ulStReAuditing = "ulStReAuditing"
mpagenko1cc3cb42020-07-27 15:24:38 +000084 ulStOutOfSync = "ulStOutOfSync"
85)
Holger Hildebrandt10d98192021-01-27 15:29:31 +000086const cMibUlFsmIdleState = ulStInSync
mpagenko1cc3cb42020-07-27 15:24:38 +000087
88const (
89 // events of MibDownload FSM
90 dlEvStart = "dlEvStart"
91 dlEvCreateGal = "dlEvCreateGal"
92 dlEvRxGalResp = "dlEvRxGalResp"
93 dlEvRxOnu2gResp = "dlEvRxOnu2gResp"
94 dlEvRxBridgeResp = "dlEvRxBridgeResp"
95 dlEvTimeoutSimple = "dlEvTimeoutSimple"
96 dlEvTimeoutBridge = "dlEvTimeoutBridge"
97 dlEvReset = "dlEvReset"
98 dlEvRestart = "dlEvRestart"
99)
100const (
101 // states of MibDownload FSM
102 dlStDisabled = "dlStDisabled"
103 dlStStarting = "dlStStarting"
104 dlStCreatingGal = "dlStCreatingGal"
105 dlStSettingOnu2g = "dlStSettingOnu2g"
106 dlStBridgeInit = "dlStBridgeInit"
107 dlStDownloaded = "dlStDownloaded"
108 dlStResetting = "dlStResetting"
109)
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000110const cMibDlFsmIdleState = dlStDisabled
mpagenko1cc3cb42020-07-27 15:24:38 +0000111
112const (
Matteo Scandolof1f39a72020-11-24 12:08:11 -0800113 // NOTE that this hardcoded to service/voltha as the MIB template is shared across stacks
Holger Hildebrandt2ff21f12020-08-13 14:38:02 +0000114 cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates"
mpagenkoaf801632020-07-03 10:00:42 +0000115 cSuffixMibTemplateKvStore = "%s/%s/%s"
Matteo Scandolof1f39a72020-11-24 12:08:11 -0800116 cBasePathOnuKVStore = "%s/openonu"
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000117)
118
Himani Chawla6d2ae152020-09-02 13:11:20 +0530119// OnuDeviceEvent - event of interest to Device Adapters and OpenOMCI State Machines
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000120type OnuDeviceEvent int
121
122const (
123 // Events of interest to Device Adapters and OpenOMCI State Machines
Himani Chawla6d2ae152020-09-02 13:11:20 +0530124
125 // DeviceStatusInit - default start state
mpagenkofc4f56e2020-11-04 17:17:49 +0000126 DeviceStatusInit OnuDeviceEvent = iota
Himani Chawla6d2ae152020-09-02 13:11:20 +0530127 // MibDatabaseSync - MIB database sync (upload done)
mpagenkofc4f56e2020-11-04 17:17:49 +0000128 MibDatabaseSync
Himani Chawla6d2ae152020-09-02 13:11:20 +0530129 // OmciCapabilitiesDone - OMCI ME and message type capabilities known
mpagenkofc4f56e2020-11-04 17:17:49 +0000130 OmciCapabilitiesDone
Himani Chawla6d2ae152020-09-02 13:11:20 +0530131 // MibDownloadDone - // MIB download done
mpagenkofc4f56e2020-11-04 17:17:49 +0000132 MibDownloadDone
Himani Chawla6d2ae152020-09-02 13:11:20 +0530133 // UniLockStateDone - Uni ports admin set to lock
mpagenkofc4f56e2020-11-04 17:17:49 +0000134 UniLockStateDone
Himani Chawla6d2ae152020-09-02 13:11:20 +0530135 // UniUnlockStateDone - Uni ports admin set to unlock
mpagenkofc4f56e2020-11-04 17:17:49 +0000136 UniUnlockStateDone
mpagenko900ee4b2020-10-12 11:56:34 +0000137 // UniDisableStateDone - Uni ports admin set to lock based on device disable
mpagenkofc4f56e2020-11-04 17:17:49 +0000138 UniDisableStateDone
mpagenko900ee4b2020-10-12 11:56:34 +0000139 // UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
mpagenkofc4f56e2020-11-04 17:17:49 +0000140 UniEnableStateDone
Himani Chawla6d2ae152020-09-02 13:11:20 +0530141 // PortLinkUp - Port link state change
mpagenkofc4f56e2020-11-04 17:17:49 +0000142 PortLinkUp
Himani Chawla6d2ae152020-09-02 13:11:20 +0530143 // PortLinkDw - Port link state change
mpagenkofc4f56e2020-11-04 17:17:49 +0000144 PortLinkDw
Himani Chawla6d2ae152020-09-02 13:11:20 +0530145 // OmciAniConfigDone - AniSide config according to TechProfile done
mpagenkofc4f56e2020-11-04 17:17:49 +0000146 OmciAniConfigDone
147 // OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
148 OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
mpagenkof1fc3862021-02-16 10:09:52 +0000149 // OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
mpagenkofc4f56e2020-11-04 17:17:49 +0000150 OmciVlanFilterAddDone
mpagenkof1fc3862021-02-16 10:09:52 +0000151 // OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
152 OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
153 // OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
154 OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
155 // OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
156 OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
mpagenko80622a52021-02-09 16:53:23 +0000157 // OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
158 OmciOnuSwUpgradeDone
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000159 // Add other events here as needed (alarms separate???)
160)
161
162type activityDescr struct {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000163 databaseClass func(context.Context) error
Himani Chawla4d908332020-08-31 12:30:20 +0530164 //advertiseEvents bool
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000165 auditInterval time.Duration
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000166 //tasks map[string]func() error
167}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530168
169// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000170type OmciDeviceFsms map[string]activityDescr
171
Himani Chawla6d2ae152020-09-02 13:11:20 +0530172// AdapterFsm - Adapter FSM details including channel, event and device
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000173type AdapterFsm struct {
174 fsmName string
175 deviceID string
176 commChan chan Message
177 pFsm *fsm.FSM
178}
179
Himani Chawla6d2ae152020-09-02 13:11:20 +0530180//NewAdapterFsm - FSM details including event, device and channel.
181func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm {
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000182 aFsm := &AdapterFsm{
Himani Chawla6d2ae152020-09-02 13:11:20 +0530183 fsmName: aName,
184 deviceID: aDeviceID,
185 commChan: aCommChannel,
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000186 }
187 return aFsm
188}
189
190//Start starts (logs) the omci agent
dbainbri4d3a0dc2020-12-02 00:33:42 +0000191func (oo *AdapterFsm) logFsmStateChange(ctx context.Context, e *fsm.Event) {
192 logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000193 "event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
194}
195
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000196//OntDeviceEntry structure holds information about the attached FSM'as and their communication
Holger Hildebrandtc54939a2020-06-17 08:14:27 +0000197
198const (
Himani Chawla6d2ae152020-09-02 13:11:20 +0530199 firstSwImageMeID = 0
200 secondSwImageMeID = 1
Holger Hildebrandtc54939a2020-06-17 08:14:27 +0000201)
mpagenko15ff4a52021-03-02 10:09:20 +0000202const ( //definitions as per G.988 softwareImage::IsCommitted
203 swIsUncommitted = 0
204 swIsCommitted = 1
205)
206const ( //definitions as per G.988 softwareImage::IsActive
207 //swIsInactive = 0 not yet used
208 swIsActive = 1
209)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000210const onuDataMeID = 0
Himani Chawla6d2ae152020-09-02 13:11:20 +0530211const onugMeID = 0
212const onu2gMeID = 0
213const ipHostConfigDataMeID = 1
214const onugSerialNumberLen = 8
215const omciMacAddressLen = 6
Holger Hildebrandtc54939a2020-06-17 08:14:27 +0000216
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000217const cEmptyMacAddrString = "000000000000"
218const cEmptySerialNumberString = "0000000000000000"
219
mpagenko15ff4a52021-03-02 10:09:20 +0000220type sEntrySwImageIndication struct {
221 valid bool
222 entityID uint16
223 version string
224 isCommitted uint8
225}
226type sSwImageIndications struct {
227 activeEntityEntry sEntrySwImageIndication
228 inactiveEntityEntry sEntrySwImageIndication
Holger Hildebrandtc54939a2020-06-17 08:14:27 +0000229}
230
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000231type uniPersConfig struct {
232 PersUniID uint8 `json:"uni_id"`
Girish Gowdra041dcb32020-11-16 16:54:30 -0800233 PersTpPathMap map[uint8]string `json:"PersTpPathMap"` // tp-id to tp-path map
234 PersFlowParams []uniVlanFlowParams `json:"flow_params"` //as defined in omci_ani_config.go
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000235}
236
237type onuPersistentData struct {
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000238 PersOnuID uint32 `json:"onu_id"`
239 PersIntfID uint32 `json:"intf_id"`
240 PersSnr string `json:"serial_number"`
241 PersAdminState string `json:"admin_state"`
242 PersOperState string `json:"oper_state"`
243 PersUniUnlockDone bool `json:"uni_unlock_done"`
244 PersUniDisableDone bool `json:"uni_disable_done"`
245 PersMibAuditInterval time.Duration `json:"mib_audit_interval"`
246 PersMibLastDbSync uint32 `json:"mib_last_db_sync"`
247 PersMibDataSyncAdpt uint8 `json:"mib_data_sync_adpt"`
248 PersUniConfig []uniPersConfig `json:"uni_config"`
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000249}
250
Himani Chawla6d2ae152020-09-02 13:11:20 +0530251// OnuDeviceEntry - ONU device info and FSM events.
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000252type OnuDeviceEntry struct {
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000253 deviceID string
254 baseDeviceHandler *deviceHandler
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000255 pOpenOnuAc *OpenONUAC
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000256 coreProxy adapterif.CoreProxy
257 adapterProxy adapterif.AdapterProxy
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000258 PDevOmciCC *omciCC
259 pOnuDB *onuDeviceDB
260 mibTemplateKVStore *db.Backend
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000261 persUniConfigMutex sync.RWMutex
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000262 sOnuPersistentData onuPersistentData
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000263 mibTemplatePath string
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000264 onuKVStoreMutex sync.RWMutex
265 onuKVStore *db.Backend
266 onuKVStorePath string
267 onuKVStoreprocResult error //error indication of processing
268 chOnuKvProcessingStep chan uint8
269 vendorID string
270 serialNumber string
271 equipmentID string
mpagenko15ff4a52021-03-02 10:09:20 +0000272 onuSwImageIndications sSwImageIndications
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000273 activeSwVersion string
274 macAddress string
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000275 //lockDeviceEntries sync.RWMutex
dbainbri4d3a0dc2020-12-02 00:33:42 +0000276 mibDbClass func(context.Context) error
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000277 supportedFsms OmciDeviceFsms
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000278 devState OnuDeviceEvent
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000279 // Audit and MDS
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000280 mibAuditInterval time.Duration
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000281 // TODO: periodical mib resync will be implemented with story VOL-3792
282 //mibNextDbResync uint32
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000283
284 // for mibUpload
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000285 pMibUploadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
286 // for mibDownload
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000287 pMibDownloadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
288 //remark: general usage of pAdapterFsm would require generalization of commChan usage and internal event setting
289 // within the FSM event procedures
ozgecanetsiae11479f2020-07-06 09:44:47 +0300290 omciMessageReceived chan bool //seperate channel needed by DownloadFsm
291 omciRebootMessageReceivedChannel chan Message // channel needed by Reboot request
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000292}
293
Himani Chawla6d2ae152020-09-02 13:11:20 +0530294//newOnuDeviceEntry returns a new instance of a OnuDeviceEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000295//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000296func newOnuDeviceEntry(ctx context.Context, dh *deviceHandler) *OnuDeviceEntry {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000297 logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": dh.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000298 var onuDeviceEntry OnuDeviceEntry
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000299 onuDeviceEntry.deviceID = dh.deviceID
300 onuDeviceEntry.baseDeviceHandler = dh
301 onuDeviceEntry.pOpenOnuAc = dh.pOpenOnuAc
302 onuDeviceEntry.coreProxy = dh.coreProxy
303 onuDeviceEntry.adapterProxy = dh.AdapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000304 onuDeviceEntry.devState = DeviceStatusInit
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000305 onuDeviceEntry.sOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
306 onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300307 onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan Message, 2048)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000308 //openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
309 //OMCI related databases are on a per-agent basis. State machines and tasks
310 //are per ONU Vendor
311 //
312 // MIB Synchronization Database - possible overloading from arguments
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000313 if dh.pOpenOnuAc.pSupportedFsms != nil {
314 onuDeviceEntry.supportedFsms = *dh.pOpenOnuAc.pSupportedFsms
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000315 } else {
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000316 // This branch is currently not used and is for potential future usage of alternative MIB Sync FSMs only!
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000317 //var mibSyncFsm = NewMibSynchronizer()
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000318 // use some internal defaults, if not defined from outside
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000319 onuDeviceEntry.supportedFsms = OmciDeviceFsms{
320 "mib-synchronizer": {
321 //mibSyncFsm, // Implements the MIB synchronization state machine
Himani Chawla6d2ae152020-09-02 13:11:20 +0530322 onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
Himani Chawla4d908332020-08-31 12:30:20 +0530323 //true, // Advertise events on OpenOMCI event bus
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000324 dh.pOpenOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000325 // map[string]func() error{
326 // "mib-upload": onuDeviceEntry.MibUploadTask,
327 // "mib-template": onuDeviceEntry.MibTemplateTask,
328 // "get-mds": onuDeviceEntry.GetMdsTask,
329 // "mib-audit": onuDeviceEntry.GetMdsTask,
330 // "mib-resync": onuDeviceEntry.MibResyncTask,
331 // "mib-reconcile": onuDeviceEntry.MibReconcileTask,
332 // },
333 },
334 }
335 }
336 onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].databaseClass
dbainbri4d3a0dc2020-12-02 00:33:42 +0000337 logger.Debug(ctx, "access2mibDbClass")
338 go onuDeviceEntry.mibDbClass(ctx)
Holger Hildebrandtf37b3d72021-02-17 10:25:22 +0000339 if !dh.isReconciling() {
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000340 onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditInterval
341 onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000342 } else {
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000343 logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": dh.deviceID})
344 // TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000345 // vendor- or deviceID-specific configurations via voltctl-commands
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000346 onuDeviceEntry.mibAuditInterval = onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000347 }
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000348 logger.Debugw(ctx, "MibAudit is set to", log.Fields{"Interval": onuDeviceEntry.mibAuditInterval})
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000349 // TODO: periodical mib resync will be implemented with story VOL-3792
350 //onuDeviceEntry.mibNextDbResync = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000351
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000352 // Omci related Mib upload sync state machine
353 mibUploadChan := make(chan Message, 2048)
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000354 onuDeviceEntry.pMibUploadFsm = NewAdapterFsm("MibUpload", dh.deviceID, mibUploadChan)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000355 onuDeviceEntry.pMibUploadFsm.pFsm = fsm.NewFSM(
mpagenko1cc3cb42020-07-27 15:24:38 +0000356 ulStDisabled,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000357 fsm.Events{
358
mpagenko1cc3cb42020-07-27 15:24:38 +0000359 {Name: ulEvStart, Src: []string{ulStDisabled}, Dst: ulStStarting},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000360
mpagenko1cc3cb42020-07-27 15:24:38 +0000361 {Name: ulEvResetMib, Src: []string{ulStStarting}, Dst: ulStResettingMib},
362 {Name: ulEvGetVendorAndSerial, Src: []string{ulStResettingMib}, Dst: ulStGettingVendorAndSerial},
Himani Chawla4d908332020-08-31 12:30:20 +0530363 {Name: ulEvGetEquipmentID, Src: []string{ulStGettingVendorAndSerial}, Dst: ulStGettingEquipmentID},
364 {Name: ulEvGetFirstSwVersion, Src: []string{ulStGettingEquipmentID}, Dst: ulStGettingFirstSwVersion},
mpagenko1cc3cb42020-07-27 15:24:38 +0000365 {Name: ulEvGetSecondSwVersion, Src: []string{ulStGettingFirstSwVersion}, Dst: ulStGettingSecondSwVersion},
366 {Name: ulEvGetMacAddress, Src: []string{ulStGettingSecondSwVersion}, Dst: ulStGettingMacAddress},
367 {Name: ulEvGetMibTemplate, Src: []string{ulStGettingMacAddress}, Dst: ulStGettingMibTemplate},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +0000368
mpagenko1cc3cb42020-07-27 15:24:38 +0000369 {Name: ulEvUploadMib, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploading},
370 {Name: ulEvExamineMds, Src: []string{ulStStarting}, Dst: ulStExaminingMds},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000371
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000372 {Name: ulEvSuccess, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploadDone},
373 {Name: ulEvSuccess, Src: []string{ulStUploading}, Dst: ulStUploadDone},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000374
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000375 {Name: ulEvSuccess, Src: []string{ulStUploadDone}, Dst: ulStInSync},
mpagenko1cc3cb42020-07-27 15:24:38 +0000376 {Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStInSync},
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000377 // TODO: As long as mib-resynchronizing is not implemented, failed MDS-examination triggers
378 // mib-reset and new provisioning at this point
379 //{Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResynchronizing},
380 {Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResettingMib},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000381
mpagenko1cc3cb42020-07-27 15:24:38 +0000382 {Name: ulEvAuditMib, Src: []string{ulStInSync}, Dst: ulStAuditing},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000383
mpagenko1cc3cb42020-07-27 15:24:38 +0000384 {Name: ulEvSuccess, Src: []string{ulStOutOfSync}, Dst: ulStInSync},
385 {Name: ulEvAuditMib, Src: []string{ulStOutOfSync}, Dst: ulStAuditing},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000386
mpagenko1cc3cb42020-07-27 15:24:38 +0000387 {Name: ulEvSuccess, Src: []string{ulStAuditing}, Dst: ulStInSync},
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000388 {Name: ulEvMismatch, Src: []string{ulStAuditing}, Dst: ulStReAuditing},
mpagenko1cc3cb42020-07-27 15:24:38 +0000389 {Name: ulEvForceResync, Src: []string{ulStAuditing}, Dst: ulStResynchronizing},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000390
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000391 {Name: ulEvSuccess, Src: []string{ulStReAuditing}, Dst: ulStInSync},
392 {Name: ulEvMismatch, Src: []string{ulStReAuditing}, Dst: ulStResettingMib},
393
mpagenko1cc3cb42020-07-27 15:24:38 +0000394 {Name: ulEvSuccess, Src: []string{ulStResynchronizing}, Dst: ulStInSync},
395 {Name: ulEvDiffsFound, Src: []string{ulStResynchronizing}, Dst: ulStOutOfSync},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000396
Himani Chawla4d908332020-08-31 12:30:20 +0530397 {Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
mpagenko1cc3cb42020-07-27 15:24:38 +0000398 ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000399 ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStStarting},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000400
Himani Chawla4d908332020-08-31 12:30:20 +0530401 {Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
mpagenko1cc3cb42020-07-27 15:24:38 +0000402 ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000403 ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStDisabled},
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404 },
405
406 fsm.Callbacks{
dbainbri4d3a0dc2020-12-02 00:33:42 +0000407 "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(ctx, e) },
408 "enter_" + ulStStarting: func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
409 "enter_" + ulStResettingMib: func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
410 "enter_" + ulStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
411 "enter_" + ulStGettingEquipmentID: func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
412 "enter_" + ulStGettingFirstSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
413 "enter_" + ulStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
414 "enter_" + ulStGettingMacAddress: func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
415 "enter_" + ulStGettingMibTemplate: func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplate(ctx, e) },
416 "enter_" + ulStUploading: func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000417 "enter_" + ulStUploadDone: func(e *fsm.Event) { onuDeviceEntry.enterUploadDoneState(ctx, e) },
dbainbri4d3a0dc2020-12-02 00:33:42 +0000418 "enter_" + ulStExaminingMds: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
419 "enter_" + ulStResynchronizing: func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
420 "enter_" + ulStAuditing: func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000421 "enter_" + ulStReAuditing: func(e *fsm.Event) { onuDeviceEntry.enterReAuditingState(ctx, e) },
dbainbri4d3a0dc2020-12-02 00:33:42 +0000422 "enter_" + ulStOutOfSync: func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
423 "enter_" + ulStInSync: func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000424 },
425 )
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000426 // Omci related Mib download state machine
427 mibDownloadChan := make(chan Message, 2048)
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000428 onuDeviceEntry.pMibDownloadFsm = NewAdapterFsm("MibDownload", dh.deviceID, mibDownloadChan)
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000429 onuDeviceEntry.pMibDownloadFsm.pFsm = fsm.NewFSM(
mpagenko1cc3cb42020-07-27 15:24:38 +0000430 dlStDisabled,
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000431 fsm.Events{
432
mpagenko1cc3cb42020-07-27 15:24:38 +0000433 {Name: dlEvStart, Src: []string{dlStDisabled}, Dst: dlStStarting},
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000434
mpagenko1cc3cb42020-07-27 15:24:38 +0000435 {Name: dlEvCreateGal, Src: []string{dlStStarting}, Dst: dlStCreatingGal},
436 {Name: dlEvRxGalResp, Src: []string{dlStCreatingGal}, Dst: dlStSettingOnu2g},
437 {Name: dlEvRxOnu2gResp, Src: []string{dlStSettingOnu2g}, Dst: dlStBridgeInit},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000438 // the bridge state is used for multi ME config for alle UNI related ports
439 // maybe such could be reflected in the state machine as well (port number parametrized)
440 // but that looks not straightforward here - so we keep it simple here for the beginning(?)
mpagenko1cc3cb42020-07-27 15:24:38 +0000441 {Name: dlEvRxBridgeResp, Src: []string{dlStBridgeInit}, Dst: dlStDownloaded},
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000442
mpagenko1cc3cb42020-07-27 15:24:38 +0000443 {Name: dlEvTimeoutSimple, Src: []string{dlStCreatingGal, dlStSettingOnu2g}, Dst: dlStStarting},
444 {Name: dlEvTimeoutBridge, Src: []string{dlStBridgeInit}, Dst: dlStStarting},
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000445
mpagenko1cc3cb42020-07-27 15:24:38 +0000446 {Name: dlEvReset, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
447 dlStBridgeInit, dlStDownloaded}, Dst: dlStResetting},
448 // exceptional treatment for all states except dlStResetting
449 {Name: dlEvRestart, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
450 dlStBridgeInit, dlStDownloaded, dlStResetting}, Dst: dlStDisabled},
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000451 },
452
453 fsm.Callbacks{
dbainbri4d3a0dc2020-12-02 00:33:42 +0000454 "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(ctx, e) },
455 "enter_" + dlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
456 "enter_" + dlStCreatingGal: func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
457 "enter_" + dlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
458 "enter_" + dlStBridgeInit: func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
459 "enter_" + dlStDownloaded: func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
460 "enter_" + dlStResetting: func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000461 },
462 )
463 if onuDeviceEntry.pMibDownloadFsm == nil || onuDeviceEntry.pMibDownloadFsm.pFsm == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000464 logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": dh.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +0000465 // TODO some specific error treatment - or waiting for crash ?
Holger Hildebrandt9ac0d0f2020-05-13 11:22:02 +0000466 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000467
dbainbri4d3a0dc2020-12-02 00:33:42 +0000468 onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, cBasePathMibTemplateKvStore)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000469 if onuDeviceEntry.mibTemplateKVStore == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000470 logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
Holger Hildebrandt61b24d02020-11-16 13:36:40 +0000471 log.Fields{"device-id": dh.deviceID, "service": cBasePathMibTemplateKvStore})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000472 }
473
474 onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
Matteo Scandolof1f39a72020-11-24 12:08:11 -0800475 baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.pOpenOnuAc.cm.Backend.PathPrefix)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000476 onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, baseKvStorePath)
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000477 if onuDeviceEntry.onuKVStore == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000478 logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
Matteo Scandolof1f39a72020-11-24 12:08:11 -0800479 log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000480 }
481
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000482 // Alarm Synchronization Database
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530483
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000484 //self._alarm_db = None
485 //self._alarm_database_cls = support_classes['alarm-synchronizer']['database']
486 return &onuDeviceEntry
487}
488
Himani Chawla6d2ae152020-09-02 13:11:20 +0530489//start starts (logs) the omci agent
490func (oo *OnuDeviceEntry) start(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000491 logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000492 if oo.PDevOmciCC == nil {
mpagenko900ee4b2020-10-12 11:56:34 +0000493 oo.PDevOmciCC = newOmciCC(ctx, oo, oo.deviceID, oo.baseDeviceHandler,
494 oo.coreProxy, oo.adapterProxy)
495 if oo.PDevOmciCC == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000496 logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000497 return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
498 }
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000499 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000500 return nil
501}
502
mpagenko900ee4b2020-10-12 11:56:34 +0000503//stop stops/resets the omciCC
504func (oo *OnuDeviceEntry) stop(ctx context.Context, abResetOmciCC bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000505 logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000506 if abResetOmciCC && (oo.PDevOmciCC != nil) {
507 _ = oo.PDevOmciCC.stop(ctx)
508 }
509 //to allow for all event notifications again when re-using the device and omciCC
510 oo.devState = DeviceStatusInit
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000511 return nil
512}
513
Himani Chawla6d2ae152020-09-02 13:11:20 +0530514func (oo *OnuDeviceEntry) reboot(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000515 logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000516 if oo.PDevOmciCC != nil {
517 if err := oo.PDevOmciCC.sendReboot(ctx, ConstDefaultOmciTimeout, true, oo.omciRebootMessageReceivedChannel); err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000518 logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000519 return err
520 }
ozgecanetsiae11479f2020-07-06 09:44:47 +0300521 }
ozgecanetsiae11479f2020-07-06 09:44:47 +0300522 return nil
523}
524
dbainbri4d3a0dc2020-12-02 00:33:42 +0000525func (oo *OnuDeviceEntry) waitForRebootResponse(ctx context.Context, responseChannel chan Message) error {
ozgecanetsiae11479f2020-07-06 09:44:47 +0300526 select {
527 case <-time.After(3 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
dbainbri4d3a0dc2020-12-02 00:33:42 +0000528 logger.Warnw(ctx, "Reboot timeout", log.Fields{"for device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200529 return fmt.Errorf("rebootTimeout")
ozgecanetsiae11479f2020-07-06 09:44:47 +0300530 case data := <-responseChannel:
531 switch data.Data.(OmciMessage).OmciMsg.MessageType {
532 case omci.RebootResponseType:
533 {
534 msgLayer := (*data.Data.(OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse)
535 if msgLayer == nil {
Andrea Campanella6515c582020-10-05 11:25:00 +0200536 return fmt.Errorf("omci Msg layer could not be detected for RebootResponseType")
ozgecanetsiae11479f2020-07-06 09:44:47 +0300537 }
Andrea Campanellabef4e542020-10-22 11:01:28 +0200538 msgObj, msgOk := msgLayer.(*omci.RebootResponse)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300539 if !msgOk {
Andrea Campanella6515c582020-10-05 11:25:00 +0200540 return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300541 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000542 logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300543 if msgObj.Result != me.Success {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000544 logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300545 // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
Andrea Campanellabef4e542020-10-22 11:01:28 +0200546 return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
Andrea Campanella6515c582020-10-05 11:25:00 +0200547 msgObj.Result, oo.deviceID)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300548 }
549 return nil
550 }
551 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000552 logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200553 return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300554 }
555}
556
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557//Relay the InSync message via Handler to Rw core - Status update
dbainbri4d3a0dc2020-12-02 00:33:42 +0000558func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent OnuDeviceEvent) {
559 logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000560 // decouple the handler transfer from further processing here
561 // TODO!!! check if really no synch is required within the system e.g. to ensure following steps ..
Himani Chawla26e555c2020-08-31 12:30:20 +0530562 if devEvent == MibDatabaseSync {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000563 if oo.devState < MibDatabaseSync { //devState has not been synced yet
564 oo.devState = MibDatabaseSync
dbainbri4d3a0dc2020-12-02 00:33:42 +0000565 go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566 //TODO!!! device control: next step: start MIB capability verification from here ?!!!
567 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000568 logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000569 }
Himani Chawla26e555c2020-08-31 12:30:20 +0530570 } else if devEvent == MibDownloadDone {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000571 if oo.devState < MibDownloadDone { //devState has not been synced yet
572 oo.devState = MibDownloadDone
dbainbri4d3a0dc2020-12-02 00:33:42 +0000573 go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000574 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000575 logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576 }
577 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000578 logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000579 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000580}
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000581
582func (oo *OnuDeviceEntry) restoreDataFromOnuKvStore(ctx context.Context) error {
583 if oo.onuKVStore == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000584 logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000585 return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
586 }
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000587 oo.persUniConfigMutex.Lock()
588 defer oo.persUniConfigMutex.Unlock()
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000589 oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0)}
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000590 oo.onuKVStoreMutex.RLock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000591 Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000592 oo.onuKVStoreMutex.RUnlock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000593 if err == nil {
594 if Value != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000595 logger.Debugw(ctx, "ONU-data read",
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000596 log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
597 tmpBytes, _ := kvstore.ToByte(Value.Value)
598
599 if err = json.Unmarshal(tmpBytes, &oo.sOnuPersistentData); err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000600 logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000601 return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
602 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000603 logger.Debugw(ctx, "ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000604 "device-id": oo.deviceID})
605 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000606 logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
mpagenko2418ab02020-11-12 12:58:06 +0000607 return fmt.Errorf("no-ONU-data-found")
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000608 }
609 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000610 logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000611 return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
612 }
613 return nil
614}
615
616func (oo *OnuDeviceEntry) deleteDataFromOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
617 defer wg.Done()
618
619 if oo.onuKVStore == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000620 logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000621 oo.onuKVStoreprocResult = errors.New("onu-data delete aborted: onuKVStore not set")
622 return
623 }
624 var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
625 go oo.deletePersistentData(ctx, processingStep)
626 if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
627 //timeout or error detected
dbainbri4d3a0dc2020-12-02 00:33:42 +0000628 logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000629 oo.onuKVStoreprocResult = errors.New("onu-data delete aborted: during kv-access")
630 return
631 }
632}
633
634func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
635
dbainbri4d3a0dc2020-12-02 00:33:42 +0000636 logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000637
638 oo.persUniConfigMutex.Lock()
639 defer oo.persUniConfigMutex.Unlock()
640
Holger Hildebrandte3677f12021-02-05 14:50:56 +0000641 oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector
642 oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0)} //default entry
mpagenko2418ab02020-11-12 12:58:06 +0000643
dbainbri4d3a0dc2020-12-02 00:33:42 +0000644 logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000645 oo.onuKVStoreMutex.Lock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000646 err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000647 oo.onuKVStoreMutex.Unlock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000648 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000649 logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000650 oo.chOnuKvProcessingStep <- 0 //error indication
651 return
652 }
653 oo.chOnuKvProcessingStep <- aProcessingStep //done
654}
655
656func (oo *OnuDeviceEntry) updateOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
657 defer wg.Done()
658
659 if oo.onuKVStore == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000660 logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000661 oo.onuKVStoreprocResult = errors.New("onu-data update aborted: onuKVStore not set")
662 return
663 }
664 var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
665 go oo.storeDataInOnuKvStore(ctx, processingStep)
666 if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
667 //timeout or error detected
dbainbri4d3a0dc2020-12-02 00:33:42 +0000668 logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000669 oo.onuKVStoreprocResult = errors.New("onu-data update aborted: during writing process")
670 return
671 }
672}
673
674func (oo *OnuDeviceEntry) storeDataInOnuKvStore(ctx context.Context, aProcessingStep uint8) {
675
676 //assign values which are not already present when newOnuDeviceEntry() is called
677 oo.sOnuPersistentData.PersOnuID = oo.baseDeviceHandler.pOnuIndication.OnuId
678 oo.sOnuPersistentData.PersIntfID = oo.baseDeviceHandler.pOnuIndication.IntfId
679 oo.sOnuPersistentData.PersSnr = oo.baseDeviceHandler.pOnuOmciDevice.serialNumber
680 //TODO: verify usage of these values during restart UC
Holger Hildebrandt3a644642020-12-02 09:46:18 +0000681 oo.sOnuPersistentData.PersAdminState = oo.baseDeviceHandler.pOnuIndication.AdminState
682 oo.sOnuPersistentData.PersOperState = oo.baseDeviceHandler.pOnuIndication.OperState
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000683
684 oo.persUniConfigMutex.RLock()
685 defer oo.persUniConfigMutex.RUnlock()
dbainbri4d3a0dc2020-12-02 00:33:42 +0000686 logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "sOnuPersistentData": oo.sOnuPersistentData})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000687
688 Value, err := json.Marshal(oo.sOnuPersistentData)
689 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000690 logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000691 "device-id": oo.deviceID, "err": err})
692 oo.chOnuKvProcessingStep <- 0 //error indication
693 return
694 }
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000695 oo.onuKVStoreMutex.Lock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000696 err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000697 oo.onuKVStoreMutex.Unlock()
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000698 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000699 logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000700 oo.chOnuKvProcessingStep <- 0 //error indication
701 return
702 }
703 oo.chOnuKvProcessingStep <- aProcessingStep //done
704}
705
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706func (oo *OnuDeviceEntry) updateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000707 /* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
708 as also the complete sequence is ensured to 'run to completion' before some new request is accepted
709 no specific concurrency protection to sOnuPersistentData is required here
710 */
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000711 oo.persUniConfigMutex.Lock()
712 defer oo.persUniConfigMutex.Unlock()
713
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000714 for k, v := range oo.sOnuPersistentData.PersUniConfig {
715 if v.PersUniID == aUniID {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000716 logger.Debugw(ctx, "PersUniConfig-entry already exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
Girish Gowdra041dcb32020-11-16 16:54:30 -0800717 existingPath, ok := oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
718 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000719 logger.Debugw(ctx, "tp-does-not-exist--to-be-created-afresh", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
Girish Gowdra041dcb32020-11-16 16:54:30 -0800720 }
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000721 if existingPath != aPathString {
722 if aPathString == "" {
723 //existing entry to be deleted
dbainbri4d3a0dc2020-12-02 00:33:42 +0000724 logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
Girish Gowdra041dcb32020-11-16 16:54:30 -0800725 oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000726 } else {
727 //existing entry to be modified
dbainbri4d3a0dc2020-12-02 00:33:42 +0000728 logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
Girish Gowdra041dcb32020-11-16 16:54:30 -0800729 oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000730 }
731 return true
732 }
733 //entry already exists
mpagenkofc4f56e2020-11-04 17:17:49 +0000734 if aPathString == "" {
735 //no active TechProfile
dbainbri4d3a0dc2020-12-02 00:33:42 +0000736 logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
mpagenkofc4f56e2020-11-04 17:17:49 +0000737 "device-id": oo.deviceID, "uniID": aUniID})
738 // attention 201105: this block is at the moment entered for each of subsequent GemPortDeletes and TContDelete
739 // as the path is already cleared with the first GemPort - this will probably change with the upcoming real
740 // TechProfile removal (still TODO), but anyway the reasonUpdate initiated here should not harm overall behavior
dbainbri4d3a0dc2020-12-02 00:33:42 +0000741 go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved)
mpagenkofc4f56e2020-11-04 17:17:49 +0000742 // no flow config pending on 'remove' so far
743 } else {
744 //the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
745 //was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
746 // (as here the TechProfile has not been removed with the disable-device before the new enable-device)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000747 logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
mpagenkofc4f56e2020-11-04 17:17:49 +0000748 "device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
749 //no deviceReason update (deviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
750 // (during which the flows are removed/re-assigned but the techProf is left active)
751 //and as the TechProfile is regarded as active we have to verify, if some flow configuration still waits on it
752 // (should not be the case, but should not harm or be more robust ...)
mpagenko2418ab02020-11-12 12:58:06 +0000753 // and to be sure, that for some reason the corresponding TpDelete was lost somewhere in history
754 // we also reset a possibly outstanding delete request - repeated TpConfig is regarded as valid for waiting flow config
755 if oo.baseDeviceHandler.pOnuTP != nil {
Girish Gowdra041dcb32020-11-16 16:54:30 -0800756 oo.baseDeviceHandler.pOnuTP.setProfileToDelete(aUniID, aTpID, false)
mpagenko2418ab02020-11-12 12:58:06 +0000757 }
mpagenko551a4d42020-12-08 18:09:20 +0000758 go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID, aTpID)
mpagenkofc4f56e2020-11-04 17:17:49 +0000759 }
760 return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000761 }
762 }
763 //no entry exists for uniId
764
765 if aPathString == "" {
766 //delete request in non-existing state , accept as no change
dbainbri4d3a0dc2020-12-02 00:33:42 +0000767 logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000768 return false
769 }
770 //new entry to be created
dbainbri4d3a0dc2020-12-02 00:33:42 +0000771 logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
Girish Gowdra041dcb32020-11-16 16:54:30 -0800772 perSubTpPathMap := make(map[uint8]string)
773 perSubTpPathMap[aTpID] = aPathString
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000774 oo.sOnuPersistentData.PersUniConfig =
Girish Gowdra041dcb32020-11-16 16:54:30 -0800775 append(oo.sOnuPersistentData.PersUniConfig, uniPersConfig{PersUniID: aUniID, PersTpPathMap: perSubTpPathMap, PersFlowParams: make([]uniVlanFlowParams, 0)})
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000776 return true
777}
778
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000779func (oo *OnuDeviceEntry) updateOnuUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]uniVlanFlowParams) {
780
Holger Hildebrandtdaf0f722021-02-12 11:50:30 +0000781 oo.persUniConfigMutex.Lock()
782 defer oo.persUniConfigMutex.Unlock()
783
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000784 for k, v := range oo.sOnuPersistentData.PersUniConfig {
785 if v.PersUniID == aUniID {
786 oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams = make([]uniVlanFlowParams, len(*aUniVlanFlowParams))
787 copy(oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams, *aUniVlanFlowParams)
788 return
789 }
790 }
791 //flow update was faster than tp-config - create PersUniConfig-entry
Girish Gowdra041dcb32020-11-16 16:54:30 -0800792 tmpConfig := uniPersConfig{PersUniID: aUniID, PersTpPathMap: make(map[uint8]string), PersFlowParams: make([]uniVlanFlowParams, len(*aUniVlanFlowParams))}
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000793 copy(tmpConfig.PersFlowParams, *aUniVlanFlowParams)
794 oo.sOnuPersistentData.PersUniConfig = append(oo.sOnuPersistentData.PersUniConfig, tmpConfig)
795}
796
797func (oo *OnuDeviceEntry) waitForTimeoutOrCompletion(
798 ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
799 select {
800 case <-ctx.Done():
dbainbri4d3a0dc2020-12-02 00:33:42 +0000801 logger.Warnw(ctx, "processing not completed in-time!",
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000802 log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
803 return false
804 case rxStep := <-aChOnuProcessingStep:
805 if rxStep == aProcessingStep {
806 return true
807 }
808 //all other values are not accepted - including 0 for error indication
dbainbri4d3a0dc2020-12-02 00:33:42 +0000809 logger.Warnw(ctx, "Invalid processing step received: abort!",
Holger Hildebrandt47555e72020-09-21 11:07:24 +0000810 log.Fields{"device-id": oo.deviceID,
811 "wantedStep": aProcessingStep, "haveStep": rxStep})
812 return false
813 }
814}
815
816func (oo *OnuDeviceEntry) resetKvProcessingErrorIndication() {
817 oo.onuKVStoreprocResult = nil
818}
819func (oo *OnuDeviceEntry) getKvProcessingErrorIndication() error {
820 return oo.onuKVStoreprocResult
821}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000822func (oo *OnuDeviceEntry) incrementMibDataSync(ctx context.Context) {
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000823 if oo.sOnuPersistentData.PersMibDataSyncAdpt < 255 {
824 oo.sOnuPersistentData.PersMibDataSyncAdpt++
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000825 } else {
826 // per G.984 and G.988 overflow starts over at 1 given 0 is reserved for reset
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000827 oo.sOnuPersistentData.PersMibDataSyncAdpt = 1
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000828 }
Holger Hildebrandt10d98192021-01-27 15:29:31 +0000829 logger.Debugf(ctx, "mibDataSync updated - mds: %d - device-id: %s", oo.sOnuPersistentData.PersMibDataSyncAdpt, oo.deviceID)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000830}