VOL-3434 Added SCA Fixes
Change-Id: I39dd692119774c4436b32e939d8342ae01ef4dc6
diff --git a/cmd/openonu-adapter/main.go b/cmd/openonu-adapter/main.go
index b472c2e..0b91e79 100644
--- a/cmd/openonu-adapter/main.go
+++ b/cmd/openonu-adapter/main.go
@@ -45,7 +45,7 @@
)
type adapter struct {
- defaultAppName string
+ //defaultAppName string
instanceID string
config *config.AdapterFlags
iAdapter adapters.IAdapter // from Voltha interface adapters
@@ -422,9 +422,8 @@
content, err := ioutil.ReadFile("VERSION")
if err == nil {
return (string(content))
- } else {
- logger.Error("'VERSION'-file not readable")
}
+ logger.Error("'VERSION'-file not readable")
}
return version.VersionInfo.Version
}
@@ -508,17 +507,17 @@
realMain() //fatal on httpListen(0,6060) ...
- defer log.CleanUp()
-
+ defer func() {
+ _ = log.CleanUp()
+ }()
// Print version / build information and exit
if cf.DisplayVersionOnly {
printVersion(defaultAppName)
return
- } else {
- logger.Infow("config", log.Fields{"StartName": defaultAppName})
- logger.Infow("config", log.Fields{"BuildVersion": version.VersionInfo.String(" ")})
- logger.Infow("config", log.Fields{"Arguments": os.Args[1:]})
}
+ logger.Infow("config", log.Fields{"StartName": defaultAppName})
+ logger.Infow("config", log.Fields{"BuildVersion": version.VersionInfo.String(" ")})
+ logger.Infow("config", log.Fields{"Arguments": os.Args[1:]})
// Print banner if specified
if cf.Banner {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/onuadaptercore/common.go
index ed55bbd..f4d7e06 100644
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/onuadaptercore/common.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core Common Logger initialization
+//Package adaptercoreonu provides the utility for onu devices, flows and statistics
package adaptercoreonu
import (
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 395b369..91b794c 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -70,17 +70,17 @@
//Event category and subcategory definitions - same as defiend for OLT in eventmgr.go - should be done more centrally
const (
- pon = voltha.EventSubCategory_PON
- olt = voltha.EventSubCategory_OLT
- ont = voltha.EventSubCategory_ONT
- onu = voltha.EventSubCategory_ONU
- nni = voltha.EventSubCategory_NNI
- service = voltha.EventCategory_SERVICE
- security = voltha.EventCategory_SECURITY
- equipment = voltha.EventCategory_EQUIPMENT
- processing = voltha.EventCategory_PROCESSING
- environment = voltha.EventCategory_ENVIRONMENT
- communication = voltha.EventCategory_COMMUNICATION
+ pon = voltha.EventSubCategory_PON
+ //olt = voltha.EventSubCategory_OLT
+ //ont = voltha.EventSubCategory_ONT
+ //onu = voltha.EventSubCategory_ONU
+ //nni = voltha.EventSubCategory_NNI
+ //service = voltha.EventCategory_SERVICE
+ //security = voltha.EventCategory_SECURITY
+ equipment = voltha.EventCategory_EQUIPMENT
+ //processing = voltha.EventCategory_PROCESSING
+ //environment = voltha.EventCategory_ENVIRONMENT
+ //communication = voltha.EventCategory_COMMUNICATION
)
const (
@@ -99,7 +99,7 @@
logicalDeviceID string
ProxyAddressID string
ProxyAddressType string
- parentId string
+ parentID string
ponPortNumber uint32
coreProxy adapterif.CoreProxy
@@ -108,7 +108,7 @@
pOpenOnuAc *OpenONUAC
pDeviceStateFsm *fsm.FSM
- pPonPort *voltha.Port
+ //pPonPort *voltha.Port
deviceEntrySet chan bool //channel for DeviceEntry set event
pOnuOmciDevice *OnuDeviceEntry
pOnuTP *OnuUniTechProf
@@ -184,18 +184,20 @@
return &dh
}
-// start save the device to the data model
+// Start save the device to the data model
func (dh *DeviceHandler) Start(ctx context.Context) {
logger.Debugw("starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.deviceID})
// Add the initial device to the local model
logger.Debug("device-handler-started")
}
+/*
// stop stops the device dh. Not much to do for now
func (dh *DeviceHandler) stop(ctx context.Context) {
logger.Debug("stopping-device-handler")
dh.exitChannel <- 1
}
+*/
// ##########################################################################################
// DeviceHandler methods that implement the adapters interface requests ##### begin #########
@@ -248,34 +250,33 @@
pDevEntry := dh.GetOnuDeviceEntry(true)
if pDevEntry != nil {
return pDevEntry.PDevOmciCC.ReceiveMessage(context.TODO(), omciMsg.Message)
- } else {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return errors.New("No valid OnuDevice")
}
+ logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ return errors.New("no valid OnuDevice")
}
case ic.InterAdapterMessageType_ONU_IND_REQUEST:
{
msgBody := msg.GetBody()
- onu_indication := &oop.OnuIndication{}
- if err := ptypes.UnmarshalAny(msgBody, onu_indication); err != nil {
+ onuIndication := &oop.OnuIndication{}
+ if err := ptypes.UnmarshalAny(msgBody, onuIndication); err != nil {
logger.Warnw("cannot-unmarshal-onu-indication-msg-body", log.Fields{
"device-id": dh.deviceID, "error": err})
return err
}
- onu_operstate := onu_indication.GetOperState()
- logger.Debugw("inter-adapter-recv-onu-ind", log.Fields{"OnuId": onu_indication.GetOnuId(),
- "AdminState": onu_indication.GetAdminState(), "OperState": onu_operstate,
- "SNR": onu_indication.GetSerialNumber()})
+ onuOperstate := onuIndication.GetOperState()
+ logger.Debugw("inter-adapter-recv-onu-ind", log.Fields{"OnuId": onuIndication.GetOnuId(),
+ "AdminState": onuIndication.GetAdminState(), "OperState": onuOperstate,
+ "SNR": onuIndication.GetSerialNumber()})
//interface related functions might be error checked ....
- if onu_operstate == "up" {
- dh.create_interface(onu_indication)
- } else if (onu_operstate == "down") || (onu_operstate == "unreachable") {
- dh.updateInterface(onu_indication)
+ if onuOperstate == "up" {
+ _ = dh.createInterface(onuIndication)
+ } else if (onuOperstate == "down") || (onuOperstate == "unreachable") {
+ _ = dh.updateInterface(onuIndication)
} else {
- logger.Errorw("unknown-onu-indication operState", log.Fields{"OnuId": onu_indication.GetOnuId()})
- return errors.New("InvalidOperState")
+ logger.Errorw("unknown-onu-indication operState", log.Fields{"OnuId": onuIndication.GetOnuId()})
+ return errors.New("invalidOperState")
}
}
case ic.InterAdapterMessageType_TECH_PROFILE_DOWNLOAD_REQUEST:
@@ -284,7 +285,7 @@
//should normally not happen ...
logger.Warnw("onuTechProf instance not set up for DLMsg request - ignoring request",
log.Fields{"device-id": dh.deviceID})
- return errors.New("TechProfile DLMsg request while onuTechProf instance not setup")
+ return errors.New("techProfile DLMsg request while onuTechProf instance not setup")
}
if (dh.deviceReason == "stopping-openomci") || (dh.deviceReason == "omci-admin-lock") {
// I've seen cases for this request, where the device was already stopped
@@ -304,7 +305,7 @@
// even to fast subsequent calls of the same messageType
dh.pOnuTP.lockTpProcMutex()
// lock hangs as long as below decoupled or other related TechProfile processing is active
- if bTpModify := dh.pOnuTP.updateOnuUniTpPath(techProfMsg.UniId, techProfMsg.Path); bTpModify == true {
+ if bTpModify := dh.pOnuTP.updateOnuUniTpPath(techProfMsg.UniId, techProfMsg.Path); bTpModify {
// if there has been some change for some uni TechProfilePath
//in order to allow concurrent calls to other dh instances we do not wait for execution here
//but doing so we can not indicate problems to the caller (who does what with that then?)
@@ -338,7 +339,7 @@
//should normally not happen ...
logger.Warnw("onuTechProf instance not set up for DelGem request - ignoring request",
log.Fields{"device-id": dh.deviceID})
- return errors.New("TechProfile DelGem request while onuTechProf instance not setup")
+ return errors.New("techProfile DelGem request while onuTechProf instance not setup")
}
msgBody := msg.GetBody()
@@ -371,7 +372,7 @@
//should normally not happen ...
logger.Warnw("onuTechProf instance not set up for DelTcont request - ignoring request",
log.Fields{"device-id": dh.deviceID})
- return errors.New("TechProfile DelTcont request while onuTechProf instance not setup")
+ return errors.New("techProfile DelTcont request while onuTechProf instance not setup")
}
msgBody := msg.GetBody()
@@ -384,7 +385,7 @@
//compare TECH_PROFILE_DOWNLOAD_REQUEST
dh.pOnuTP.lockTpProcMutex()
- if bTpModify := dh.pOnuTP.updateOnuUniTpPath(delTcontMsg.UniId, ""); bTpModify == true {
+ if bTpModify := dh.pOnuTP.updateOnuUniTpPath(delTcontMsg.UniId, ""); bTpModify {
// deadline context to ensure completion of background routines waited for
deadline := time.Now().Add(10 * time.Second) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(context.Background(), deadline)
@@ -538,12 +539,12 @@
dh.reconciling = false
return
}
- var onu_indication oop.OnuIndication
- onu_indication.IntfId = dh.pOnuTP.sOnuPersistentData.PersIntfID
- onu_indication.OnuId = dh.pOnuTP.sOnuPersistentData.PersOnuID
- onu_indication.OperState = dh.pOnuTP.sOnuPersistentData.PersOperState
- onu_indication.AdminState = dh.pOnuTP.sOnuPersistentData.PersAdminState
- dh.create_interface(&onu_indication)
+ var onuIndication oop.OnuIndication
+ onuIndication.IntfId = dh.pOnuTP.sOnuPersistentData.PersIntfID
+ onuIndication.OnuId = dh.pOnuTP.sOnuPersistentData.PersOnuID
+ onuIndication.OperState = dh.pOnuTP.sOnuPersistentData.PersOperState
+ onuIndication.AdminState = dh.pOnuTP.sOnuPersistentData.PersAdminState
+ _ = dh.createInterface(&onuIndication)
}
func (dh *DeviceHandler) ReconcileDeviceTechProf() {
@@ -569,7 +570,7 @@
// attention: deadline completion check and wg.Done is to be done in both routines
go dh.pOnuTP.configureUniTp(dctx, uint8(uniData.PersUniId), uniData.PersTpPath, &wg)
//the wait.. function is responsible for tpProcMutex.Unlock()
- dh.pOnuTP.waitForTpCompletion(cancel, &wg) //wait for background process to finish and collect their result
+ _ = dh.pOnuTP.waitForTpCompletion(cancel, &wg) //wait for background process to finish and collect their result
return
}
dh.pOnuTP.unlockTpProcMutex()
@@ -592,7 +593,11 @@
logger.Errorw("device-unreachable", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
return errors.New("device-unreachable")
}
- dh.pOnuOmciDevice.Reboot(context.TODO())
+ if err := dh.pOnuOmciDevice.Reboot(context.TODO()); err != nil {
+ //TODO with VOL-3045/VOL-3046: return the error and stop further processing
+ logger.Errorw("error-rebooting-device", log.Fields{"device-id": dh.deviceID, "error": err})
+ return err
+ }
if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID, voltha.ConnectStatus_UNREACHABLE,
voltha.OperStatus_DISCOVERED); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
@@ -634,13 +639,13 @@
dh.logicalDeviceID = dh.deviceID // really needed - what for ??? //TODO!!!
if !dh.reconciling {
- dh.coreProxy.DeviceUpdate(context.TODO(), dh.device)
+ _ = dh.coreProxy.DeviceUpdate(context.TODO(), dh.device)
} else {
logger.Debugw("reconciling - don't notify core about DeviceUpdate",
log.Fields{"device-id": dh.deviceID})
}
- dh.parentId = dh.device.ParentId
+ dh.parentID = dh.device.ParentId
dh.ponPortNumber = dh.device.ParentPortNo
// store proxy parameters for later communication - assumption: invariant, else they have to be requested dynamically!!
@@ -648,7 +653,7 @@
dh.ProxyAddressType = dh.device.ProxyAddress.GetDeviceType()
logger.Debugw("device-updated", log.Fields{"device-id": dh.deviceID, "proxyAddressID": dh.ProxyAddressID,
"proxyAddressType": dh.ProxyAddressType, "SNR": dh.device.SerialNumber,
- "ParentId": dh.parentId, "ParentPortNo": dh.ponPortNumber})
+ "ParentId": dh.parentID, "ParentPortNo": dh.ponPortNumber})
/*
self._pon = PonPort.create(self, self._pon_port_number)
@@ -671,7 +676,7 @@
Label: fmt.Sprintf("pon-%d", ponPortNo),
Type: voltha.Port_PON_ONU,
OperStatus: voltha.OperStatus_ACTIVE,
- Peers: []*voltha.Port_PeerPort{{DeviceId: dh.parentId, // Peer device is OLT
+ Peers: []*voltha.Port_PeerPort{{DeviceId: dh.parentID, // Peer device is OLT
PortNo: ponPortNo}}, // Peer port is parent's port number
}
if err = dh.coreProxy.PortCreated(context.TODO(), dh.deviceID, pPonPort); err != nil {
@@ -758,22 +763,18 @@
func (dh *DeviceHandler) doStateConnected(e *fsm.Event) {
logger.Debug("doStateConnected-started")
- var err error
- err = errors.New("Device FSM: function not implemented yet!")
+ err := errors.New("device FSM: function not implemented yet")
e.Cancel(err)
logger.Debug("doStateConnected-done")
- return
}
// doStateUp handle the onu up indication and update to voltha core
func (dh *DeviceHandler) doStateUp(e *fsm.Event) {
logger.Debug("doStateUp-started")
- var err error
- err = errors.New("Device FSM: function not implemented yet!")
+ err := errors.New("device FSM: function not implemented yet")
e.Cancel(err)
logger.Debug("doStateUp-done")
- return
/*
// Synchronous call to update device state - this method is run in its own go routine
@@ -844,10 +845,9 @@
logger.Debugw("do-state-down-end", log.Fields{"deviceID": device.Id})
return nil
*/
- err = errors.New("Device FSM: function not implemented yet!")
+ err = errors.New("device FSM: function not implemented yet")
e.Cancel(err)
logger.Debug("doStateDown-done")
- return
}
// DeviceHandler StateMachine related state transition methods ##### end #########
@@ -882,12 +882,11 @@
//SetOnuDeviceEntry sets the ONU device entry within the handler
func (dh *DeviceHandler) SetOnuDeviceEntry(
- apDeviceEntry *OnuDeviceEntry, apOnuTp *OnuUniTechProf) error {
+ apDeviceEntry *OnuDeviceEntry, apOnuTp *OnuUniTechProf) {
dh.lockDevice.Lock()
defer dh.lockDevice.Unlock()
dh.pOnuOmciDevice = apDeviceEntry
dh.pOnuTP = apOnuTp
- return nil
}
//AddOnuDeviceEntry creates a new ONU device or returns the existing
@@ -918,7 +917,7 @@
}
// doStateInit provides the device update to the core
-func (dh *DeviceHandler) create_interface(onuind *oop.OnuIndication) error {
+func (dh *DeviceHandler) createInterface(onuind *oop.OnuIndication) error {
logger.Debugw("create_interface-started", log.Fields{"OnuId": onuind.GetOnuId(),
"OnuIntfId": onuind.GetIntfId(), "OnuSerialNumber": onuind.GetSerialNumber()})
@@ -950,10 +949,12 @@
pDevEntry := dh.GetOnuDeviceEntry(true)
if pDevEntry != nil {
- pDevEntry.Start(context.TODO())
+ if err := pDevEntry.Start(context.TODO()); err != nil {
+ return err
+ }
} else {
logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return errors.New("No valid OnuDevice")
+ return errors.New("no valid OnuDevice")
}
if !dh.reconciling {
if err := dh.coreProxy.DeviceReasonUpdate(context.TODO(), dh.deviceID, "starting-openomci"); err != nil {
@@ -968,10 +969,10 @@
/* this might be a good time for Omci Verify message? */
verifyExec := make(chan bool)
- omci_verify := NewOmciTestRequest(context.TODO(),
+ omciVerify := NewOmciTestRequest(context.TODO(),
dh.device.Id, pDevEntry.PDevOmciCC,
true, true) //eclusive and allowFailure (anyway not yet checked)
- omci_verify.PerformOmciTest(context.TODO(), verifyExec)
+ omciVerify.PerformOmciTest(context.TODO(), verifyExec)
/* give the handler some time here to wait for the OMCi verification result
after Timeout start and try MibUpload FSM anyway
@@ -1059,7 +1060,7 @@
/* Note: Even though FSM calls look 'synchronous' here, FSM is running in background with the effect that possible errors
* within the MibUpload are not notified in the OnuIndication response, this might be acceptable here,
* as further OltAdapter processing may rely on the deviceReason event 'MibUploadDone' as a result of the FSM processing
- * otherwise some processing synchronisation would be required - cmp. e.g TechProfile processing
+ * otherwise some processing synchronization would be required - cmp. e.g TechProfile processing
*/
//call MibUploadFSM - transition up to state ulStInSync
pMibUlFsm := pDevEntry.pMibUploadFsm.pFsm
@@ -1067,25 +1068,27 @@
if pMibUlFsm.Is(ulStDisabled) {
if err := pMibUlFsm.Event(ulEvStart); err != nil {
logger.Errorw("MibSyncFsm: Can't go to state starting", log.Fields{"err": err})
- return errors.New("Can't go to state starting")
- } else {
- logger.Debugw("MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
- //Determine ONU status and start/re-start MIB Synchronization tasks
- //Determine if this ONU has ever synchronized
- if true { //TODO: insert valid check
- if err := pMibUlFsm.Event(ulEvResetMib); err != nil {
- logger.Errorw("MibSyncFsm: Can't go to state resetting_mib", log.Fields{"err": err})
- return errors.New("Can't go to state resetting_mib")
- }
- } else {
- pMibUlFsm.Event(ulEvExamineMds)
- logger.Debugw("state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
- //Examine the MIB Data Sync
- // callbacks to be handled:
- // Event(ulEvSuccess)
- // Event(ulEvTimeout)
- // Event(ulEvMismatch)
+ return errors.New("can't go to state starting")
+ }
+ logger.Debugw("MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
+ //Determine ONU status and start/re-start MIB Synchronization tasks
+ //Determine if this ONU has ever synchronized
+ if true { //TODO: insert valid check
+ if err := pMibUlFsm.Event(ulEvResetMib); err != nil {
+ logger.Errorw("MibSyncFsm: Can't go to state resetting_mib", log.Fields{"err": err})
+ return errors.New("can't go to state resetting_mib")
}
+ } else {
+ if err := pMibUlFsm.Event(ulEvExamineMds); err != nil {
+ logger.Errorw("MibSyncFsm: Can't go to state examine_mds", log.Fields{"err": err})
+ return errors.New("can't go to examine_mds")
+ }
+ logger.Debugw("state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
+ //Examine the MIB Data Sync
+ // callbacks to be handled:
+ // Event(ulEvSuccess)
+ // Event(ulEvTimeout)
+ // Event(ulEvMismatch)
}
} else {
logger.Errorw("wrong state of MibSyncFsm - want: disabled", log.Fields{"have": string(pMibUlFsm.Current())})
@@ -1106,7 +1109,7 @@
pDevEntry := dh.GetOnuDeviceEntry(false)
if pDevEntry == nil {
logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return errors.New("No valid OnuDevice")
+ return errors.New("no valid OnuDevice")
}
switch dh.deviceReason {
@@ -1114,29 +1117,29 @@
{ //MIBSync FSM may run
pMibUlFsm := pDevEntry.pMibUploadFsm.pFsm
if pMibUlFsm != nil {
- pMibUlFsm.Event(ulEvStop) //TODO!! verify if MibSyncFsm stop-processing is sufficient (to allow it again afterwards)
+ _ = pMibUlFsm.Event(ulEvStop) //TODO!! verify if MibSyncFsm stop-processing is sufficient (to allow it again afterwards)
}
}
case "discovery-mibsync-complete":
{ //MibDownload may run
pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
if pMibDlFsm != nil {
- pMibDlFsm.Event(dlEvReset)
+ _ = pMibDlFsm.Event(dlEvReset)
}
}
default:
{
//port lock/unlock FSM's may be active
if dh.pUnlockStateFsm != nil {
- dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
}
if dh.pLockStateFsm != nil {
- dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
}
//techProfile related PonAniConfigFsm FSM may be active
// maybe encapsulated as OnuTP method - perhaps later in context of module splitting
if dh.pOnuTP.pAniConfigFsm != nil {
- dh.pOnuTP.pAniConfigFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = dh.pOnuTP.pAniConfigFsm.pAdaptFsm.pFsm.Event(aniEvReset)
}
for _, uniPort := range dh.uniEntityMap {
//reset the TechProfileConfig Done state for all (active) UNI's
@@ -1146,7 +1149,7 @@
//VlanFilterFsm exists and was already started
pVlanFilterStatemachine := pVlanFilterFsm.pAdaptFsm.pFsm
if pVlanFilterStatemachine != nil {
- pVlanFilterStatemachine.Event(vlanEvReset)
+ _ = pVlanFilterStatemachine.Event(vlanEvReset)
}
}
}
@@ -1154,12 +1157,12 @@
//TODO!!! care about PM/Alarm processing once started
}
//TODO: from here the deviceHandler FSM itself may be stuck in some of the initial states
- // (mainly the still seperate 'Event states')
+ // (mainly the still separate 'Event states')
// so it is questionable, how this is resolved after some possible re-enable
// assumption there is obviously, that the system may continue with some 'after "mib-download-done" state'
//stop/remove(?) the device entry
- pDevEntry.Stop(context.TODO()) //maybe some more sophisticated context treatment should be used here?
+ _ = pDevEntry.Stop(context.TODO()) //maybe some more sophisticated context treatment should be used here?
//TODO!!! remove existing traffic profiles
/* from py code, if TP's exist, remove them - not yet implemented
@@ -1197,8 +1200,8 @@
}
//DeviceProcStatusUpdate evaluates possible processing events and initiates according next activities
-func (dh *DeviceHandler) DeviceProcStatusUpdate(dev_Event OnuDeviceEvent) {
- switch dev_Event {
+func (dh *DeviceHandler) DeviceProcStatusUpdate(devEvent OnuDeviceEvent) {
+ switch devEvent {
case MibDatabaseSync:
{
logger.Debugw("MibInSync event received", log.Fields{"device-id": dh.deviceID})
@@ -1221,20 +1224,20 @@
i := uint8(0) //UNI Port limit: see MaxUnisPerOnu (by now 16) (OMCI supports max 255 p.b.)
pDevEntry := dh.GetOnuDeviceEntry(false)
if unigInstKeys := pDevEntry.pOnuDB.GetSortedInstKeys(me.UniGClassID); len(unigInstKeys) > 0 {
- for _, mgmtEntityId := range unigInstKeys {
+ for _, mgmtEntityID := range unigInstKeys {
logger.Debugw("Add UNI port for stored UniG instance:", log.Fields{
- "device-id": dh.deviceID, "UnigMe EntityID": mgmtEntityId})
- dh.addUniPort(mgmtEntityId, i, UniPPTP)
+ "device-id": dh.deviceID, "UnigMe EntityID": mgmtEntityID})
+ dh.addUniPort(mgmtEntityID, i, UniPPTP)
i++
}
} else {
logger.Debugw("No UniG instances found", log.Fields{"device-id": dh.deviceID})
}
if veipInstKeys := pDevEntry.pOnuDB.GetSortedInstKeys(me.VirtualEthernetInterfacePointClassID); len(veipInstKeys) > 0 {
- for _, mgmtEntityId := range veipInstKeys {
+ for _, mgmtEntityID := range veipInstKeys {
logger.Debugw("Add VEIP acc. to stored VEIP instance:", log.Fields{
- "device-id": dh.deviceID, "VEIP EntityID": mgmtEntityId})
- dh.addUniPort(mgmtEntityId, i, UniVEIP)
+ "device-id": dh.deviceID, "VEIP EntityID": mgmtEntityID})
+ dh.addUniPort(mgmtEntityID, i, UniVEIP)
i++
}
} else {
@@ -1390,22 +1393,22 @@
}
default:
{
- logger.Warnw("unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": dev_Event})
+ logger.Warnw("unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
}
} //switch
}
-func (dh *DeviceHandler) addUniPort(a_uniInstNo uint16, a_uniId uint8, a_portType UniPortType) {
+func (dh *DeviceHandler) addUniPort(aUniInstNo uint16, aUniID uint8, aPortType UniPortType) {
// parameters are IntfId, OnuId, uniId
uniNo := MkUniPortNum(dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
- uint32(a_uniId))
+ uint32(aUniID))
if _, present := dh.uniEntityMap[uniNo]; present {
- logger.Warnw("onuUniPort-add: Port already exists", log.Fields{"for InstanceId": a_uniInstNo})
+ logger.Warnw("onuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
} else {
- //with arguments a_uniId, a_portNo, a_portType
- pUniPort := NewOnuUniPort(a_uniId, uniNo, a_uniInstNo, a_portType)
+ //with arguments aUniID, a_portNo, aPortType
+ pUniPort := NewOnuUniPort(aUniID, uniNo, aUniInstNo, aPortType)
if pUniPort == nil {
- logger.Warnw("onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": a_uniInstNo})
+ logger.Warnw("onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
} else {
//store UniPort with the System-PortNumber key
dh.uniEntityMap[uniNo] = pUniPort
@@ -1424,7 +1427,7 @@
// enableUniPortStateUpdate enables UniPortState and update core port state accordingly
func (dh *DeviceHandler) enableUniPortStateUpdate() {
// py code was updated 2003xx to activate the real ONU UNI ports per OMCI (VEIP or PPTP)
- // but towards core only the first port active state is signalled
+ // but towards core only the first port active state is signaled
// with following remark:
// # TODO: for now only support the first UNI given no requirement for multiple uni yet. Also needed to reduce flow
// # load on the core
@@ -1463,15 +1466,15 @@
// ONU_Active/Inactive announcement on system KAFKA bus
// tried to re-use procedure of oltUpDownIndication from openolt_eventmgr.go with used values from Py code
-func (dh *DeviceHandler) sendOnuOperStateEvent(a_OperState vc.OperStatus_Types, a_deviceID string, raisedTs int64) {
+func (dh *DeviceHandler) sendOnuOperStateEvent(aOperState vc.OperStatus_Types, aDeviceID string, raisedTs int64) {
var de voltha.DeviceEvent
eventContext := make(map[string]string)
//Populating event context
// assume giving ParentId in GetDevice twice really gives the ParentDevice (there is no GetParentDevice()...)
- parentDevice, err := dh.coreProxy.GetDevice(context.TODO(), dh.parentId, dh.parentId)
+ parentDevice, err := dh.coreProxy.GetDevice(context.TODO(), dh.parentID, dh.parentID)
if err != nil || parentDevice == nil {
logger.Errorw("Failed to fetch parent device for OnuEvent",
- log.Fields{"parentId": dh.parentId, "err": err})
+ log.Fields{"parentID": dh.parentID, "err": err})
}
oltSerialNumber := parentDevice.SerialNumber
@@ -1479,15 +1482,15 @@
eventContext["onu-id"] = strconv.FormatUint(uint64(dh.pOnuIndication.OnuId), 10)
eventContext["serial-number"] = dh.device.SerialNumber
eventContext["olt_serial_number"] = oltSerialNumber
- eventContext["device_id"] = a_deviceID
- eventContext["registration_id"] = a_deviceID //py: string(device_id)??
+ eventContext["device_id"] = aDeviceID
+ eventContext["registration_id"] = aDeviceID //py: string(device_id)??
logger.Debugw("prepare ONU_ACTIVATED event",
- log.Fields{"DeviceId": a_deviceID, "EventContext": eventContext})
+ log.Fields{"DeviceId": aDeviceID, "EventContext": eventContext})
/* Populating device event body */
de.Context = eventContext
- de.ResourceId = a_deviceID
- if a_OperState == voltha.OperStatus_ACTIVE {
+ de.ResourceId = aDeviceID
+ if aOperState == voltha.OperStatus_ACTIVE {
de.DeviceEventName = fmt.Sprintf("%s_%s", cOnuActivatedEvent, "RAISE_EVENT")
de.Description = fmt.Sprintf("%s Event - %s - %s",
cEventObjectType, cOnuActivatedEvent, "Raised")
@@ -1499,17 +1502,17 @@
/* Send event to KAFKA */
if err := dh.EventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil {
logger.Warnw("could not send ONU_ACTIVATED event",
- log.Fields{"device-id": a_deviceID, "error": err})
+ log.Fields{"device-id": aDeviceID, "error": err})
}
logger.Debugw("ONU_ACTIVATED event sent to KAFKA",
- log.Fields{"device-id": a_deviceID, "with-EventName": de.DeviceEventName})
+ log.Fields{"device-id": aDeviceID, "with-EventName": de.DeviceEventName})
}
-// createUniLockFsm initialises and runs the UniLock FSM to transfer the OMCI related commands for port lock/unlock
+// createUniLockFsm initializes and runs the UniLock FSM to transfer the OMCI related commands for port lock/unlock
func (dh *DeviceHandler) createUniLockFsm(aAdminState bool, devEvent OnuDeviceEvent) {
chLSFsm := make(chan Message, 2048)
var sFsmName string
- if aAdminState == true {
+ if aAdminState {
logger.Infow("createLockStateFSM", log.Fields{"device-id": dh.deviceID})
sFsmName = "LockStateFSM"
} else {
@@ -1525,7 +1528,7 @@
pLSFsm := NewLockStateFsm(pDevEntry.PDevOmciCC, aAdminState, devEvent,
sFsmName, dh.deviceID, chLSFsm)
if pLSFsm != nil {
- if aAdminState == true {
+ if aAdminState {
dh.pLockStateFsm = pLSFsm
} else {
dh.pUnlockStateFsm = pLSFsm
@@ -1542,19 +1545,19 @@
***** should run via 'adminDone' state and generate the argument requested event *****
*/
var pLSStatemachine *fsm.FSM
- if aAdminState == true {
+ if aAdminState {
pLSStatemachine = dh.pLockStateFsm.pAdaptFsm.pFsm
//make sure the opposite FSM is not running and if so, terminate it as not relevant anymore
if (dh.pUnlockStateFsm != nil) &&
(dh.pUnlockStateFsm.pAdaptFsm.pFsm.Current() != uniStDisabled) {
- dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
}
} else {
pLSStatemachine = dh.pUnlockStateFsm.pAdaptFsm.pFsm
//make sure the opposite FSM is not running and if so, terminate it as not relevant anymore
if (dh.pLockStateFsm != nil) &&
(dh.pLockStateFsm.pAdaptFsm.pFsm.Current() != uniStDisabled) {
- dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
}
}
if pLSStatemachine != nil {
diff --git a/internal/pkg/onuadaptercore/messageTypes.go b/internal/pkg/onuadaptercore/messageTypes.go
index a5d5aff..69b69d5 100644
--- a/internal/pkg/onuadaptercore/messageTypes.go
+++ b/internal/pkg/onuadaptercore/messageTypes.go
@@ -45,8 +45,7 @@
type TestMessageType uint8
const (
- noOperation TestMessageType = iota
- LoadMibTemplateOk
+ LoadMibTemplateOk TestMessageType = iota + 1
LoadMibTemplateFailed
TimeOutOccurred
AbortMessageProcessing
diff --git a/internal/pkg/onuadaptercore/mib_download.go b/internal/pkg/onuadaptercore/mib_download.go
index 58c5c9a..a2e485e 100644
--- a/internal/pkg/onuadaptercore/mib_download.go
+++ b/internal/pkg/onuadaptercore/mib_download.go
@@ -74,7 +74,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(dlEvReset)
+ _ = a_pAFsm.pFsm.Event(dlEvReset)
}
}(pMibDlFsm)
}
@@ -97,7 +97,7 @@
// see DownloadedState: decouple event transfer
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(dlEvRestart)
+ _ = a_pAFsm.pFsm.Event(dlEvRestart)
}
}(pMibDlFsm)
}
@@ -107,35 +107,35 @@
logger.Debugw("Start MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
loop:
for {
- select {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
// break loop
- case message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan:
- if !ok {
- logger.Info("MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
- // but then we have to ensure a restart of the FSM as well - as exceptional procedure
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart)
+ // unless multiple channels are not involved, we should not use select
+ message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan
+ if !ok {
+ logger.Info("MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
+ // but then we have to ensure a restart of the FSM as well - as exceptional procedure
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart)
+ break loop
+ }
+ logger.Debugw("MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
+
+ switch message.Type {
+ case TestMsg:
+ msg, _ := message.Data.(TestMessage)
+ if msg.TestMessageVal == AbortMessageProcessing {
+ logger.Infow("MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
break loop
}
- logger.Debugw("MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
-
- switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
- break loop
- }
- logger.Warnw("MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
- onuDeviceEntry.handleOmciMibDownloadMessage(msg)
- default:
- logger.Warn("MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
- "message.Type": message.Type})
- }
+ logger.Warnw("MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
+ case OMCI:
+ msg, _ := message.Data.(OmciMessage)
+ onuDeviceEntry.handleOmciMibDownloadMessage(msg)
+ default:
+ logger.Warn("MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
+ "message.Type": message.Type})
}
+
}
logger.Infow("End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
}
@@ -179,7 +179,7 @@
switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
case "GalEthernetProfile":
{ // let the FSM proceed ...
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp)
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp)
}
case "MacBridgeServiceProfile",
"MacBridgePortConfigurationData",
@@ -221,7 +221,7 @@
switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
case "Onu2G":
{ // let the FSM proceed ...
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp)
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp)
}
//so far that was the only MibDownlad Set Element ...
}
@@ -248,7 +248,7 @@
err := onuDeviceEntry.waitforOmciResponse(meInstance)
if err != nil {
logger.Error("InitialBridgeSetup failed at MBSP, aborting MIB Download!")
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
}
@@ -260,7 +260,7 @@
err = onuDeviceEntry.waitforOmciResponse(meInstance)
if err != nil {
logger.Error("InitialBridgeSetup failed at MBPCD, aborting MIB Download!")
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
}
@@ -272,32 +272,31 @@
err = onuDeviceEntry.waitforOmciResponse(meInstance)
if err != nil {
logger.Error("InitialBridgeSetup failed at EVTOCD, aborting MIB Download!")
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
}
}
// if Config has been done for all UNI related instances let the FSM proceed
// while we did not check here, if there is some port at all - !?
logger.Infow("IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
- return
+ _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
}
func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(apMeInstance *me.ManagedEntity) error {
select {
- // maybe be also some outside cancel (but no context modelled for the moment ...)
+ // maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Info("MibDownload-bridge-init message reception canceled", log.Fields{"for device-id": onuDeviceEntry.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
logger.Warnw("MibDownload-bridge-init timeout", log.Fields{"for device-id": onuDeviceEntry.deviceID})
- return errors.New("MibDownloadBridgeInit timeout")
+ return errors.New("mibDownloadBridgeInit timeout")
case success := <-onuDeviceEntry.omciMessageReceived:
- if success == true {
+ if success {
logger.Debug("MibDownload-bridge-init response received")
return nil
}
// should not happen so far
logger.Warnw("MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID})
- return errors.New("MibDownloadBridgeInit responseError")
+ return errors.New("mibDownloadBridgeInit responseError")
}
}
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index e68338c..45aa197 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -74,7 +74,7 @@
logger.Debugw("MibSync FSM", log.Fields{"Start MibTemplate processing in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
logger.Debugw("MibSync FSM", log.Fields{"send mibReset in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.sendMibReset(context.TODO(), ConstDefaultOmciTimeout, true)
+ _ = onuDeviceEntry.PDevOmciCC.sendMibReset(context.TODO(), ConstDefaultOmciTimeout, true)
//TODO: needs to handle timeouts
}
@@ -82,16 +82,16 @@
func (onuDeviceEntry *OnuDeviceEntry) enterGettingVendorAndSerialState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"Start getting VendorId and SerialNumber in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
requestedAttributes := me.AttributeValueMap{"VendorId": "", "SerialNumber": 0}
- meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.OnuGClassID, OnugMeId, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.OnuGClassID, OnugMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (onuDeviceEntry *OnuDeviceEntry) enterGettingEquipmentIdState(e *fsm.Event) {
+func (onuDeviceEntry *OnuDeviceEntry) enterGettingEquipmentIDState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"Start getting EquipmentId in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
requestedAttributes := me.AttributeValueMap{"EquipmentId": ""}
- meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.Onu2GClassID, Onu2gMeId, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.Onu2GClassID, Onu2gMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
@@ -100,7 +100,7 @@
func (onuDeviceEntry *OnuDeviceEntry) enterGettingFirstSwVersionState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"Start getting IsActive and Version of first SW-image in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
requestedAttributes := me.AttributeValueMap{"IsActive": 0, "Version": ""}
- meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, FirstSwImageMeId, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, FirstSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
@@ -109,7 +109,7 @@
func (onuDeviceEntry *OnuDeviceEntry) enterGettingSecondSwVersionState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"Start getting IsActive and Version of second SW-image in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
requestedAttributes := me.AttributeValueMap{"IsActive": 0, "Version": ""}
- meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, SecondSwImageMeId, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, SecondSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
@@ -118,7 +118,7 @@
func (onuDeviceEntry *OnuDeviceEntry) enterGettingMacAddressState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"Start getting MacAddress in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
requestedAttributes := me.AttributeValueMap{"MacAddress": ""}
- meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.IpHostConfigDataClassID, IpHostConfigDataMeId, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := onuDeviceEntry.PDevOmciCC.sendGetMe(context.TODO(), me.IpHostConfigDataClassID, IPHostConfigDataMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
@@ -126,7 +126,7 @@
func (onuDeviceEntry *OnuDeviceEntry) enterGettingMibTemplate(e *fsm.Event) {
- for i := FirstSwImageMeId; i <= SecondSwImageMeId; i++ {
+ for i := FirstSwImageMeID; i <= SecondSwImageMeID; i++ {
if onuDeviceEntry.swImages[i].isActive > 0 {
onuDeviceEntry.activeSwVersion = onuDeviceEntry.swImages[i].version
}
@@ -154,23 +154,23 @@
for fistLevelKey, firstLevelValue := range fistLevelMap {
logger.Debugw("MibSync FSM - fistLevelKey", log.Fields{"fistLevelKey": fistLevelKey})
if uint16ValidNumber, err := strconv.ParseUint(fistLevelKey, 10, 16); err == nil {
- meClassId := me.ClassID(uint16ValidNumber)
+ meClassID := me.ClassID(uint16ValidNumber)
logger.Debugw("MibSync FSM - fistLevelKey is a number in uint16-range", log.Fields{"uint16ValidNumber": uint16ValidNumber})
- if IsSupportedClassId(meClassId) {
- logger.Debugw("MibSync FSM - fistLevelKey is a supported classId", log.Fields{"meClassId": meClassId})
+ if IsSupportedClassId(meClassID) {
+ logger.Debugw("MibSync FSM - fistLevelKey is a supported classId", log.Fields{"meClassID": meClassID})
secondLevelMap := firstLevelValue.(map[string]interface{})
for secondLevelKey, secondLevelValue := range secondLevelMap {
logger.Debugw("MibSync FSM - secondLevelKey", log.Fields{"secondLevelKey": secondLevelKey})
if uint16ValidNumber, err := strconv.ParseUint(secondLevelKey, 10, 16); err == nil {
- meEntityId := uint16(uint16ValidNumber)
- logger.Debugw("MibSync FSM - secondLevelKey is a number and a valid EntityId", log.Fields{"meEntityId": meEntityId})
+ meEntityID := uint16(uint16ValidNumber)
+ logger.Debugw("MibSync FSM - secondLevelKey is a number and a valid EntityId", log.Fields{"meEntityID": meEntityID})
thirdLevelMap := secondLevelValue.(map[string]interface{})
for thirdLevelKey, thirdLevelValue := range thirdLevelMap {
- if thirdLevelKey == "Attributes" {
- logger.Debugw("MibSync FSM - thirdLevelKey refers to Attributes", log.Fields{"thirdLevelKey": thirdLevelKey})
+ if thirdLevelKey == "attributes" {
+ logger.Debugw("MibSync FSM - thirdLevelKey refers to attributes", log.Fields{"thirdLevelKey": thirdLevelKey})
attributesMap := thirdLevelValue.(map[string]interface{})
logger.Debugw("MibSync FSM - attributesMap", log.Fields{"attributesMap": attributesMap})
- onuDeviceEntry.pOnuDB.PutMe(meClassId, meEntityId, attributesMap)
+ onuDeviceEntry.pOnuDB.PutMe(meClassID, meEntityID, attributesMap)
meStoredFromTemplate = true
}
}
@@ -206,7 +206,7 @@
func (onuDeviceEntry *OnuDeviceEntry) enterUploadingState(e *fsm.Event) {
logger.Debugw("MibSync FSM", log.Fields{"send MibUpload in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.sendMibUpload(context.TODO(), ConstDefaultOmciTimeout, true)
+ _ = onuDeviceEntry.PDevOmciCC.sendMibUpload(context.TODO(), ConstDefaultOmciTimeout, true)
}
func (onuDeviceEntry *OnuDeviceEntry) enterInSyncState(e *fsm.Event) {
@@ -238,32 +238,30 @@
logger.Debugw("MibSync Msg", log.Fields{"Start routine to process OMCI-messages for device-id": onuDeviceEntry.deviceID})
loop:
for {
- select {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
// break loop
- case message, ok := <-onuDeviceEntry.pMibUploadFsm.commChan:
- if !ok {
- logger.Info("MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
- break loop
- }
- logger.Debugw("MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": onuDeviceEntry.deviceID})
+ message, ok := <-onuDeviceEntry.pMibUploadFsm.commChan
+ if !ok {
+ logger.Info("MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
+ break loop
+ }
+ logger.Debugw("MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": onuDeviceEntry.deviceID})
- switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- onuDeviceEntry.handleTestMsg(msg)
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
- onuDeviceEntry.handleOmciMessage(msg)
- default:
- logger.Warn("MibSync Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID, "message.Type": message.Type})
- }
+ switch message.Type {
+ case TestMsg:
+ msg, _ := message.Data.(TestMessage)
+ onuDeviceEntry.handleTestMsg(msg)
+ case OMCI:
+ msg, _ := message.Data.(OmciMessage)
+ onuDeviceEntry.handleOmciMessage(msg)
+ default:
+ logger.Warn("MibSync Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID, "message.Type": message.Type})
}
}
logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": onuDeviceEntry.deviceID})
// TODO: only this action?
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
}
func (onuDeviceEntry *OnuDeviceEntry) handleTestMsg(msg TestMessage) {
@@ -272,16 +270,182 @@
switch msg.TestMessageVal {
case LoadMibTemplateFailed:
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvUploadMib)
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvUploadMib)
logger.Debugw("MibSync Msg", log.Fields{"state": string(onuDeviceEntry.pMibUploadFsm.pFsm.Current())})
case LoadMibTemplateOk:
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvSuccess)
logger.Debugw("MibSync Msg", log.Fields{"state": string(onuDeviceEntry.pMibUploadFsm.pFsm.Current())})
default:
logger.Warn("MibSync Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
}
}
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibResetResponseMessage(msg OmciMessage) {
+ if onuDeviceEntry.pMibUploadFsm.pFsm.Is(ulStResettingMib) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibResetResponse)
+ if msgLayer != nil {
+ msgObj, msgOk := msgLayer.(*omci.MibResetResponse)
+ if msgOk {
+ logger.Debugw("MibResetResponse Data", log.Fields{"data-fields": msgObj})
+ if msgObj.Result == me.Success {
+ // trigger retrieval of VendorId and SerialNumber
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetVendorAndSerial)
+ return
+ }
+ logger.Errorw("Omci MibResetResponse Error", log.Fields{"Error": msgObj.Result})
+ } else {
+ logger.Error("Omci Msg layer could not be assigned")
+ }
+ } else {
+ logger.Error("Omci Msg layer could not be detected")
+ }
+ } else {
+ logger.Errorw("Omci MibResetResponse received", log.Fields{"in state ": onuDeviceEntry.pMibUploadFsm.pFsm.Current})
+ }
+ logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": onuDeviceEntry.deviceID})
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
+
+}
+
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibUploadResponseMessage(msg OmciMessage) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadResponse)
+ if msgLayer == nil {
+ logger.Error("Omci Msg layer could not be detected")
+ return
+ }
+ msgObj, msgOk := msgLayer.(*omci.MibUploadResponse)
+ if !msgOk {
+ logger.Error("Omci Msg layer could not be assigned")
+ return
+ }
+ logger.Debugw("MibUploadResponse Data for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
+ /* to be verified / reworked !!! */
+ onuDeviceEntry.PDevOmciCC.uploadNoOfCmds = msgObj.NumberOfCommands
+ if onuDeviceEntry.PDevOmciCC.uploadSequNo < onuDeviceEntry.PDevOmciCC.uploadNoOfCmds {
+ _ = onuDeviceEntry.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
+ } else {
+ logger.Error("Invalid number of commands received for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "uploadNoOfCmds": onuDeviceEntry.PDevOmciCC.uploadNoOfCmds})
+ //TODO right action?
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvTimeout)
+ }
+}
+
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(msg OmciMessage) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadNextResponse)
+ if msgLayer == nil {
+ logger.Error("Omci Msg layer could not be detected")
+ return
+ }
+ msgObj, msgOk := msgLayer.(*omci.MibUploadNextResponse)
+ if !msgOk {
+ logger.Error("Omci Msg layer could not be assigned")
+ return
+ }
+ if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
+ logger.Debugw("MibUploadNextResponse Data for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
+ }
+ meClassID := msgObj.ReportedME.GetClassID()
+ meEntityID := msgObj.ReportedME.GetEntityID()
+ meAttributes := msgObj.ReportedME.GetAttributeValueMap()
+
+ onuDeviceEntry.pOnuDB.PutMe(meClassID, meEntityID, meAttributes)
+
+ if onuDeviceEntry.PDevOmciCC.uploadSequNo < onuDeviceEntry.PDevOmciCC.uploadNoOfCmds {
+ _ = onuDeviceEntry.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
+ } else {
+ onuDeviceEntry.pOnuDB.LogMeDb()
+ err := onuDeviceEntry.CreateAndPersistMibTemplate()
+ if err != nil {
+ logger.Errorw("MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": onuDeviceEntry.deviceID})
+ }
+
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ }
+}
+
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciGetResponseMessage(msg OmciMessage) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
+ if msgLayer != nil {
+ msgObj, msgOk := msgLayer.(*omci.GetResponse)
+ if msgOk {
+ logger.Debugw("MibSync FSM - GetResponse Data", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
+ if msgObj.Result == me.Success {
+ entityID := onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID()
+ if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() && msgObj.EntityInstance == entityID {
+ meAttributes := msgObj.Attributes
+ meInstance := onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName()
+ if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
+ logger.Debugf("MibSync FSM - GetResponse Data for %s", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj}, meInstance)
+ }
+ switch meInstance {
+ case "OnuG":
+ onuDeviceEntry.vendorID = fmt.Sprintf("%s", meAttributes["VendorId"])
+ snBytes, _ := me.InterfaceToOctets(meAttributes["SerialNumber"])
+ if OnugSerialNumberLen == len(snBytes) {
+ snVendorPart := fmt.Sprintf("%s", snBytes[:4])
+ snNumberPart := hex.EncodeToString(snBytes[4:])
+ onuDeviceEntry.serialNumber = snVendorPart + snNumberPart
+ logger.Debugw("MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"deviceId": onuDeviceEntry.deviceID,
+ "onuDeviceEntry.vendorID": onuDeviceEntry.vendorID, "onuDeviceEntry.serialNumber": onuDeviceEntry.serialNumber})
+ } else {
+ logger.Errorw("MibSync FSM - SerialNumber has wrong length", log.Fields{"deviceId": onuDeviceEntry.deviceID, "length": len(snBytes)})
+ }
+ // trigger retrieval of EquipmentId
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetEquipmentID)
+ return
+ case "Onu2G":
+ onuDeviceEntry.equipmentID = fmt.Sprintf("%s", meAttributes["EquipmentId"])
+ logger.Debugw("MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"deviceId": onuDeviceEntry.deviceID,
+ "onuDeviceEntry.equipmentID": onuDeviceEntry.equipmentID})
+ // trigger retrieval of 1st SW-image info
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetFirstSwVersion)
+ return
+ case "SoftwareImage":
+ if entityID <= SecondSwImageMeID {
+ onuDeviceEntry.swImages[entityID].version = fmt.Sprintf("%s", meAttributes["Version"])
+ onuDeviceEntry.swImages[entityID].isActive = meAttributes["IsActive"].(uint8)
+ logger.Debugw("MibSync FSM - GetResponse Data for SoftwareImage - Version/IsActive",
+ log.Fields{"deviceId": onuDeviceEntry.deviceID, "entityID": entityID,
+ "version": onuDeviceEntry.swImages[entityID].version, "isActive": onuDeviceEntry.swImages[entityID].isActive})
+ } else {
+ //TODO: error handling
+ logger.Errorw("MibSync FSM - Failed to GetResponse Data for SoftwareImage", log.Fields{"deviceId": onuDeviceEntry.deviceID})
+
+ }
+ if FirstSwImageMeID == entityID {
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetSecondSwVersion)
+ return
+ } else if SecondSwImageMeID == entityID {
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetMacAddress)
+ return
+ }
+ case "IpHostConfigData":
+ macBytes, _ := me.InterfaceToOctets(meAttributes["MacAddress"])
+ if OmciMacAddressLen == len(macBytes) {
+ onuDeviceEntry.macAddress = hex.EncodeToString(macBytes[:])
+ logger.Debugw("MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"deviceId": onuDeviceEntry.deviceID,
+ "onuDeviceEntry.macAddress": onuDeviceEntry.macAddress})
+ } else {
+ logger.Errorw("MibSync FSM - MacAddress wrong length", log.Fields{"deviceId": onuDeviceEntry.deviceID, "length": len(macBytes)})
+ }
+ // trigger retrieval of mib template
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
+ return
+ }
+ }
+ } else {
+ logger.Errorw("Omci GetResponse Error", log.Fields{"Error": msgObj.Result})
+ }
+ } else {
+ logger.Error("Omci Msg layer could not be assigned for GetResponse")
+ }
+ } else {
+ logger.Error("Omci Msg layer could not be detected for GetResponse")
+ }
+ logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": onuDeviceEntry.deviceID})
+ _ = onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
+}
+
func (onuDeviceEntry *OnuDeviceEntry) handleOmciMessage(msg OmciMessage) {
if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
logger.Debugw("MibSync Msg", log.Fields{"OmciMessage received for device-id": onuDeviceEntry.deviceID,
@@ -290,177 +454,23 @@
//further analysis could be done here based on msg.OmciMsg.Payload, e.g. verification of error code ...
switch msg.OmciMsg.MessageType {
case omci.MibResetResponseType:
- if onuDeviceEntry.pMibUploadFsm.pFsm.Is(ulStResettingMib) {
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibResetResponse)
- if msgLayer != nil {
- msgObj, msgOk := msgLayer.(*omci.MibResetResponse)
- if msgOk {
- logger.Debugw("MibResetResponse Data", log.Fields{"data-fields": msgObj})
- if msgObj.Result == me.Success {
- // trigger retrieval of VendorId and SerialNumber
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetVendorAndSerial)
- return
- } else {
- logger.Errorw("Omci MibResetResponse Error", log.Fields{"Error": msgObj.Result})
- }
- } else {
- logger.Error("Omci Msg layer could not be assigned")
- }
- } else {
- logger.Error("Omci Msg layer could not be detected")
- }
- } else {
- logger.Errorw("Omci MibResetResponse received", log.Fields{"in state ": onuDeviceEntry.pMibUploadFsm.pFsm.Current})
- }
- logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
+ onuDeviceEntry.handleOmciMibResetResponseMessage(msg)
case omci.MibUploadResponseType:
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadResponse)
- if msgLayer == nil {
- logger.Error("Omci Msg layer could not be detected")
- return
- }
- msgObj, msgOk := msgLayer.(*omci.MibUploadResponse)
- if !msgOk {
- logger.Error("Omci Msg layer could not be assigned")
- return
- }
- logger.Debugw("MibUploadResponse Data for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- /* to be verified / reworked !!! */
- onuDeviceEntry.PDevOmciCC.uploadNoOfCmds = msgObj.NumberOfCommands
- if onuDeviceEntry.PDevOmciCC.uploadSequNo < onuDeviceEntry.PDevOmciCC.uploadNoOfCmds {
- onuDeviceEntry.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
- } else {
- logger.Error("Invalid number of commands received for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "uploadNoOfCmds": onuDeviceEntry.PDevOmciCC.uploadNoOfCmds})
- //TODO right action?
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvTimeout)
- }
+ onuDeviceEntry.handleOmciMibUploadResponseMessage(msg)
+
case omci.MibUploadNextResponseType:
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadNextResponse)
- if msgLayer == nil {
- logger.Error("Omci Msg layer could not be detected")
- return
- }
- msgObj, msgOk := msgLayer.(*omci.MibUploadNextResponse)
- if !msgOk {
- logger.Error("Omci Msg layer could not be assigned")
- return
- }
- if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
- logger.Debugw("MibUploadNextResponse Data for:", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- }
- meClassId := msgObj.ReportedME.GetClassID()
- meEntityId := msgObj.ReportedME.GetEntityID()
- meAttributes := msgObj.ReportedME.GetAttributeValueMap()
+ onuDeviceEntry.handleOmciMibUploadNextResponseMessage(msg)
- onuDeviceEntry.pOnuDB.PutMe(meClassId, meEntityId, meAttributes)
-
- if onuDeviceEntry.PDevOmciCC.uploadSequNo < onuDeviceEntry.PDevOmciCC.uploadNoOfCmds {
- onuDeviceEntry.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
- } else {
- onuDeviceEntry.pOnuDB.LogMeDb()
- err := onuDeviceEntry.CreateAndPersistMibTemplate()
- if err != nil {
- logger.Errorw("MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": onuDeviceEntry.deviceID})
- }
-
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvSuccess)
- }
case omci.GetResponseType:
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
- if msgLayer != nil {
- msgObj, msgOk := msgLayer.(*omci.GetResponse)
- if msgOk {
- logger.Debugw("MibSync FSM - GetResponse Data", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- if msgObj.Result == me.Success {
- entityId := onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID()
- if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() && msgObj.EntityInstance == entityId {
- meAttributes := msgObj.Attributes
- switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
- case "OnuG":
- if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
- logger.Debugw("MibSync FSM - GetResponse Data for Onu-G", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- }
- onuDeviceEntry.vendorID = fmt.Sprintf("%s", meAttributes["VendorId"])
- snBytes, _ := me.InterfaceToOctets(meAttributes["SerialNumber"])
- if OnugSerialNumberLen == len(snBytes) {
- snVendorPart := fmt.Sprintf("%s", snBytes[:4])
- snNumberPart := hex.EncodeToString(snBytes[4:])
- onuDeviceEntry.serialNumber = snVendorPart + snNumberPart
- logger.Debugw("MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"deviceId": onuDeviceEntry.deviceID,
- "onuDeviceEntry.vendorID": onuDeviceEntry.vendorID, "onuDeviceEntry.serialNumber": onuDeviceEntry.serialNumber})
- } else {
- logger.Errorw("MibSync FSM - SerialNumber has wrong length", log.Fields{"deviceId": onuDeviceEntry.deviceID, "length": len(snBytes)})
- }
- // trigger retrieval of EquipmentId
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetEquipmentId)
- return
- case "Onu2G":
- if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
- logger.Debugw("MibSync FSM - GetResponse Data for Onu2-G", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- }
- onuDeviceEntry.equipmentID = fmt.Sprintf("%s", meAttributes["EquipmentId"])
- logger.Debugw("MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"deviceId": onuDeviceEntry.deviceID,
- "onuDeviceEntry.equipmentID": onuDeviceEntry.equipmentID})
- // trigger retrieval of 1st SW-image info
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetFirstSwVersion)
- return
- case "SoftwareImage":
- if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
- logger.Debugw("MibSync FSM - GetResponse Data for SoftwareImage", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- }
- if entityId <= SecondSwImageMeId {
- onuDeviceEntry.swImages[entityId].version = fmt.Sprintf("%s", meAttributes["Version"])
- onuDeviceEntry.swImages[entityId].isActive = meAttributes["IsActive"].(uint8)
- logger.Debugw("MibSync FSM - GetResponse Data for SoftwareImage - Version/IsActive",
- log.Fields{"deviceId": onuDeviceEntry.deviceID, "entityId": entityId,
- "version": onuDeviceEntry.swImages[entityId].version, "isActive": onuDeviceEntry.swImages[entityId].isActive})
- } else {
- //TODO: error handling
- }
- if FirstSwImageMeId == entityId {
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetSecondSwVersion)
- return
- } else if SecondSwImageMeId == entityId {
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetMacAddress)
- return
- }
- case "IpHostConfigData":
- ///
- if onuDeviceEntry.mibDebugLevel == "VERBOSE" {
- logger.Debugw("MibSync FSM - GetResponse Data for IpHostConfigData", log.Fields{"deviceId": onuDeviceEntry.deviceID, "data-fields": msgObj})
- }
- macBytes, _ := me.InterfaceToOctets(meAttributes["MacAddress"])
- if OmciMacAddressLen == len(macBytes) {
- onuDeviceEntry.macAddress = hex.EncodeToString(macBytes[:])
- logger.Debugw("MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"deviceId": onuDeviceEntry.deviceID,
- "onuDeviceEntry.macAddress": onuDeviceEntry.macAddress})
- } else {
- logger.Errorw("MibSync FSM - MacAddress wrong length", log.Fields{"deviceId": onuDeviceEntry.deviceID, "length": len(macBytes)})
- }
- // trigger retrieval of mib template
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
- return
- }
- }
- } else {
- logger.Errorw("Omci GetResponse Error", log.Fields{"Error": msgObj.Result})
- }
- } else {
- logger.Error("Omci Msg layer could not be assigned for GetResponse")
- }
- } else {
- logger.Error("Omci Msg layer could not be detected for GetResponse")
- }
- logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.pMibUploadFsm.pFsm.Event(ulEvStop)
+ onuDeviceEntry.handleOmciGetResponseMessage(msg)
+
}
}
-func IsSupportedClassId(meClassId me.ClassID) bool {
+func IsSupportedClassId(meClassID me.ClassID) bool {
for _, v := range supportedClassIds {
- if v == meClassId {
+ if v == meClassID {
return true
}
}
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/onuadaptercore/omci_ani_config.go
index b152818..1d5e5d4 100644
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/onuadaptercore/omci_ani_config.go
@@ -20,6 +20,7 @@
import (
"context"
"errors"
+ "fmt"
"strconv"
"time"
@@ -82,7 +83,7 @@
pOnuDB *OnuDeviceDB
techProfileID uint16
requestEvent OnuDeviceEvent
- omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses
+ omciMIdsResponseReceived chan bool //separate channel needed for checking multiInstance OMCI message responses
pAdaptFsm *AdapterFsm
aniConfigCompleted bool
chSuccess chan<- uint8
@@ -212,7 +213,7 @@
oFsm.mapperSP0ID = ieeeMapperServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) + oFsm.techProfileID
oFsm.macBPCD0ID = macBridgePortAniEID + uint16(oFsm.pOnuUniPort.entityId) + oFsm.techProfileID
- // For the time beeing: if there are multiple T-Conts on the ONU the first one from the entityID-ordered list is used
+ // For the time being: if there are multiple T-Conts on the ONU the first one from the entityID-ordered list is used
// TODO!: if more T-Conts have to be supported (tcontXID!), then use the first instances of the entity-ordered list
// or use the py code approach, which might be a bit more complicated, but also more secure, as it
// ensures that the selected T-Cont also has queues (which I would assume per definition from ONU, but who knows ...)
@@ -230,7 +231,7 @@
loGemPortAttribs := ponAniGemPortAttribs{}
//for all TechProfile set GemIndices
for _, gemEntry := range (*(oFsm.pUniTechProf.mapPonAniConfig[oFsm.pOnuUniPort.uniId]))[0].mapGemPortParams {
- //collect all GemConfigData in a seperate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig)
+ //collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig)
if queueInstKeys := oFsm.pOnuDB.GetSortedInstKeys(me.PriorityQueueClassID); len(queueInstKeys) > 0 {
@@ -249,18 +250,18 @@
usQueueFound := false
dsQueueFound := false
- for _, mgmtEntityId := range queueInstKeys {
- if meAttributes := oFsm.pOnuDB.GetMe(me.PriorityQueueClassID, mgmtEntityId); meAttributes != nil {
+ for _, mgmtEntityID := range queueInstKeys {
+ if meAttributes := oFsm.pOnuDB.GetMe(me.PriorityQueueClassID, mgmtEntityID); meAttributes != nil {
returnVal := meAttributes["RelatedPort"]
if returnVal != nil {
if relatedPort, err := oFsm.pOnuDB.GetUint32Attrib(returnVal); err == nil {
if relatedPort == usQrelPortMask {
- loGemPortAttribs.upQueueID = mgmtEntityId
+ loGemPortAttribs.upQueueID = mgmtEntityID
logger.Debugw("UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
"upQueueID": strconv.FormatInt(int64(loGemPortAttribs.upQueueID), 16), "device-id": oFsm.pAdaptFsm.deviceID})
usQueueFound = true
- } else if (relatedPort&0xFFFFFF) == dsQrelPortMask && mgmtEntityId < 0x8000 {
- loGemPortAttribs.downQueueID = mgmtEntityId
+ } else if (relatedPort&0xFFFFFF) == dsQrelPortMask && mgmtEntityID < 0x8000 {
+ loGemPortAttribs.downQueueID = mgmtEntityID
logger.Debugw("DownQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
"downQueueID": strconv.FormatInt(int64(loGemPortAttribs.downQueueID), 16), "device-id": oFsm.pAdaptFsm.deviceID})
dsQueueFound = true
@@ -276,7 +277,7 @@
}
} else {
logger.Warnw("No attributes available in DB:", log.Fields{"meClassID": me.PriorityQueueClassID,
- "mgmtEntityId": mgmtEntityId, "device-id": oFsm.pAdaptFsm.deviceID})
+ "mgmtEntityID": mgmtEntityID, "device-id": oFsm.pAdaptFsm.deviceID})
}
}
} else {
@@ -297,7 +298,7 @@
oFsm.gemPortAttribsSlice = append(oFsm.gemPortAttribsSlice, loGemPortAttribs)
}
- a_pAFsm.pFsm.Event(aniEvStartConfig)
+ _ = a_pAFsm.pFsm.Event(aniEvStartConfig)
}
}(pConfigAniStateAFsm)
}
@@ -383,7 +384,7 @@
meParams := me.ParamData{
EntityID: oFsm.mapperSP0ID,
- Attributes: make(me.AttributeValueMap, 0),
+ Attributes: make(me.AttributeValueMap),
}
//assign the GemPorts according to the configured Prio
@@ -410,55 +411,18 @@
}
}
var foundIwPtr bool = false
- if loPrioGemPortArray[0] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio0": strconv.FormatInt(int64(loPrioGemPortArray[0]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority0"] = loPrioGemPortArray[0]
+ for index, value := range loPrioGemPortArray {
+ if value != 0 {
+ foundIwPtr = true
+ meAttribute := fmt.Sprintf("InterworkTpPointerForPBitPriority%d", index)
+ logger.Debugf("UniPonAniConfigFsm Set::1pMapper", log.Fields{
+ "IwPtr for Prio%d": strconv.FormatInt(int64(value), 16), "device-id": oFsm.pAdaptFsm.deviceID}, index)
+ meParams.Attributes[meAttribute] = value
+
+ }
}
- if loPrioGemPortArray[1] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio1": strconv.FormatInt(int64(loPrioGemPortArray[1]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority1"] = loPrioGemPortArray[1]
- }
- if loPrioGemPortArray[2] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio2": strconv.FormatInt(int64(loPrioGemPortArray[2]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority2"] = loPrioGemPortArray[2]
- }
- if loPrioGemPortArray[3] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio3": strconv.FormatInt(int64(loPrioGemPortArray[3]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority3"] = loPrioGemPortArray[3]
- }
- if loPrioGemPortArray[4] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio4": strconv.FormatInt(int64(loPrioGemPortArray[4]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority4"] = loPrioGemPortArray[4]
- }
- if loPrioGemPortArray[5] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio5": strconv.FormatInt(int64(loPrioGemPortArray[5]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority5"] = loPrioGemPortArray[5]
- }
- if loPrioGemPortArray[6] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio6": strconv.FormatInt(int64(loPrioGemPortArray[6]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority6"] = loPrioGemPortArray[6]
- }
- if loPrioGemPortArray[7] != 0 {
- foundIwPtr = true
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
- "IwPtr for Prio7": strconv.FormatInt(int64(loPrioGemPortArray[7]), 16), "device-id": oFsm.pAdaptFsm.deviceID})
- meParams.Attributes["InterworkTpPointerForPBitPriority7"] = loPrioGemPortArray[7]
- }
- if foundIwPtr == false {
+
+ if !foundIwPtr {
logger.Errorw("UniPonAniConfigFsm no GemIwPtr found for .1pMapper - abort", log.Fields{
"device-id": oFsm.pAdaptFsm.deviceID})
//let's reset the state machine in order to release all resources now
@@ -467,7 +431,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(aniEvReset)
+ _ = a_pAFsm.pFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
}
@@ -490,7 +454,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(aniEvReset)
+ _ = a_pAFsm.pFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
}
@@ -513,7 +477,7 @@
//try to restart the FSM to 'disabled', decouple event transfer
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(aniEvRestart)
+ _ = a_pAFsm.pFsm.Event(aniEvRestart)
}
}(pConfigAniStateAFsm)
}
@@ -548,37 +512,114 @@
logger.Debugw("Start UniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
loop:
for {
- select {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.pAdaptFsm.deviceID})
// break loop
- case message, ok := <-oFsm.pAdaptFsm.commChan:
- if !ok {
- logger.Info("UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- // but then we have to ensure a restart of the FSM as well - as exceptional procedure
- oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ message, ok := <-oFsm.pAdaptFsm.commChan
+ if !ok {
+ logger.Info("UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+ // but then we have to ensure a restart of the FSM as well - as exceptional procedure
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ break loop
+ }
+ logger.Debugw("UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+
+ switch message.Type {
+ case TestMsg:
+ msg, _ := message.Data.(TestMessage)
+ if msg.TestMessageVal == AbortMessageProcessing {
+ logger.Infow("UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
break loop
}
- logger.Debugw("UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+ logger.Warnw("UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ case OMCI:
+ msg, _ := message.Data.(OmciMessage)
+ oFsm.handleOmciAniConfigMessage(msg)
+ default:
+ logger.Warn("UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
+ "message.Type": message.Type})
+ }
- switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
- break loop
- }
- logger.Warnw("UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciAniConfigMessage(msg)
- default:
- logger.Warn("UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
- "message.Type": message.Type})
+ }
+ logger.Infow("End UniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+}
+
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(msg OmciMessage) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
+ if msgLayer == nil {
+ logger.Error("Omci Msg layer could not be detected for CreateResponse")
+ return
+ }
+ msgObj, msgOk := msgLayer.(*omci.CreateResponse)
+ if !msgOk {
+ logger.Error("Omci Msg layer could not be assigned for CreateResponse")
+ return
+ }
+ logger.Debugw("CreateResponse Data", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "data-fields": msgObj})
+ if msgObj.Result != me.Success {
+ logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
+ // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
+ return
+ }
+ if msgObj.EntityClass == oFsm.pOmciCC.pLastTxMeInstance.GetClassID() &&
+ msgObj.EntityInstance == oFsm.pOmciCC.pLastTxMeInstance.GetEntityID() {
+ // maybe we can use just the same eventName for different state transitions like "forward"
+ // - might be checked, but so far I go for sure and have to inspect the concrete state events ...
+ switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
+ case "Ieee8021PMapperServiceProfile":
+ { // let the FSM proceed ...
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
+ }
+ case "MacBridgePortConfigurationData":
+ { // let the FSM proceed ...
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
+ }
+ case "GemPortNetworkCtp", "GemInterworkingTerminationPoint":
+ { // let aniConfig Multi-Id processing proceed by stopping the wait function
+ oFsm.omciMIdsResponseReceived <- true
}
}
}
- logger.Infow("End UniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+}
+
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(msg OmciMessage) {
+ msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
+ if msgLayer == nil {
+ logger.Error("UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse")
+ return
+ }
+ msgObj, msgOk := msgLayer.(*omci.SetResponse)
+ if !msgOk {
+ logger.Error("UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse")
+ return
+ }
+ logger.Debugw("UniPonAniConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "data-fields": msgObj})
+ if msgObj.Result != me.Success {
+ logger.Errorw("UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
+ // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
+ return
+ }
+ if msgObj.EntityClass == oFsm.pOmciCC.pLastTxMeInstance.GetClassID() &&
+ msgObj.EntityInstance == oFsm.pOmciCC.pLastTxMeInstance.GetEntityID() {
+ //store the created ME into DB //TODO??? obviously the Python code does not store the config ...
+ // if, then something like:
+ //oFsm.pOnuDB.StoreMe(msgObj)
+
+ switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
+ case "TCont":
+ { // let the FSM proceed ...
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxTcontsResp)
+ }
+ case "PriorityQueue":
+ { // let the PrioQueue init proceed by stopping the wait function
+ oFsm.omciMIdsResponseReceived <- true
+ }
+ case "Ieee8021PMapperServiceProfile":
+ { // let the FSM proceed ...
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp)
+ }
+ }
+ }
}
func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigMessage(msg OmciMessage) {
@@ -588,81 +629,13 @@
switch msg.OmciMsg.MessageType {
case omci.CreateResponseType:
{
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
- if msgLayer == nil {
- logger.Error("Omci Msg layer could not be detected for CreateResponse")
- return
- }
- msgObj, msgOk := msgLayer.(*omci.CreateResponse)
- if !msgOk {
- logger.Error("Omci Msg layer could not be assigned for CreateResponse")
- return
- }
- logger.Debugw("CreateResponse Data", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "data-fields": msgObj})
- if msgObj.Result != me.Success {
- logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
- // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
- return
- }
- if msgObj.EntityClass == oFsm.pOmciCC.pLastTxMeInstance.GetClassID() &&
- msgObj.EntityInstance == oFsm.pOmciCC.pLastTxMeInstance.GetEntityID() {
- // maybe we can use just the same eventName for different state transitions like "forward"
- // - might be checked, but so far I go for sure and have to inspect the concrete state events ...
- switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
- case "Ieee8021PMapperServiceProfile":
- { // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
- }
- case "MacBridgePortConfigurationData":
- { // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
- }
- case "GemPortNetworkCtp", "GemInterworkingTerminationPoint":
- { // let aniConfig Multi-Id processing proceed by stopping the wait function
- oFsm.omciMIdsResponseReceived <- true
- }
- }
- }
+ oFsm.handleOmciAniConfigCreateResponseMessage(msg)
+
} //CreateResponseType
case omci.SetResponseType:
{
- msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
- if msgLayer == nil {
- logger.Error("UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse")
- return
- }
- msgObj, msgOk := msgLayer.(*omci.SetResponse)
- if !msgOk {
- logger.Error("UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse")
- return
- }
- logger.Debugw("UniPonAniConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "data-fields": msgObj})
- if msgObj.Result != me.Success {
- logger.Errorw("UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
- // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
- return
- }
- if msgObj.EntityClass == oFsm.pOmciCC.pLastTxMeInstance.GetClassID() &&
- msgObj.EntityInstance == oFsm.pOmciCC.pLastTxMeInstance.GetEntityID() {
- //store the created ME into DB //TODO??? obviously the Python code does not store the config ...
- // if, then something like:
- //oFsm.pOnuDB.StoreMe(msgObj)
+ oFsm.handleOmciAniConfigSetResponseMessage(msg)
- switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
- case "TCont":
- { // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxTcontsResp)
- }
- case "PriorityQueue":
- { // let the PrioQueue init proceed by stopping the wait function
- oFsm.omciMIdsResponseReceived <- true
- }
- case "Ieee8021PMapperServiceProfile":
- { // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp)
- }
- }
- }
} //SetResponseType
default:
{
@@ -702,15 +675,14 @@
if err != nil {
logger.Errorw("GemNWCtp create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "GemIndex": gemIndex})
- oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
}
} //for all GemPorts of this T-Cont
// if Config has been done for all GemPort instances let the FSM proceed
logger.Debugw("GemNWCtp create loop finished", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp)
- return
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp)
}
func (oFsm *UniPonAniConfigFsm) performCreatingGemIWs() {
@@ -741,15 +713,14 @@
if err != nil {
logger.Errorw("GemIwTp create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "GemIndex": gemIndex})
- oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
}
} //for all GemPort's of this T-Cont
// if Config has been done for all GemPort instances let the FSM proceed
logger.Debugw("GemIwTp create loop finished", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp)
- return
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp)
}
func (oFsm *UniPonAniConfigFsm) performSettingPQs() {
@@ -758,7 +729,7 @@
loQueueMap := ordered_map.NewOrderedMap()
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.qosPolicy == "WRR" {
- if _, ok := loQueueMap.Get(gemPortAttribs.upQueueID); ok == false {
+ if _, ok := loQueueMap.Get(gemPortAttribs.upQueueID); !ok {
//key does not yet exist
loQueueMap.Set(gemPortAttribs.upQueueID, uint16(gemPortAttribs.weight))
}
@@ -782,7 +753,7 @@
queueIndex := (kv.Key).(uint16)
meParams := me.ParamData{
EntityID: queueIndex,
- Attributes: make(me.AttributeValueMap, 0),
+ Attributes: make(me.AttributeValueMap),
}
if (kv.Value).(uint16) == cu16StrictPrioWeight {
//StrictPrio indication
@@ -810,7 +781,7 @@
if err != nil {
logger.Errorw("PrioQueue set failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)})
- oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
}
@@ -823,25 +794,24 @@
// if Config has been done for all PrioQueue instances let the FSM proceed
logger.Debugw("PrioQueue set loop finished", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp)
- return
+ _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp)
}
func (oFsm *UniPonAniConfigFsm) waitforOmciResponse() error {
select {
- // maybe be also some outside cancel (but no context modelled for the moment ...)
+ // maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
logger.Warnw("UniPonAniConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
- return errors.New("UniPonAniConfigFsm multi entity timeout")
+ return errors.New("uniPonAniConfigFsm multi entity timeout")
case success := <-oFsm.omciMIdsResponseReceived:
- if success == true {
+ if success {
logger.Debug("UniPonAniConfigFsm multi entity response received")
return nil
}
// should not happen so far
logger.Warnw("UniPonAniConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
- return errors.New("UniPonAniConfigFsm multi entity responseError")
+ return errors.New("uniPonAniConfigFsm multi entity responseError")
}
}
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/onuadaptercore/omci_cc.go
index 23fd506..1f70bd2 100644
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/onuadaptercore/omci_cc.go
@@ -49,8 +49,9 @@
const galEthernetEID = uint16(1)
const maxGemPayloadSize = uint16(48)
const connectivityModeValue = uint8(5)
-const defaultTPID = uint16(0x8100)
-const broadComDefaultVID = uint16(4091)
+
+//const defaultTPID = uint16(0x8100)
+//const broadComDefaultVID = uint16(4091)
const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
const ieeeMapperServiceProfileEID = uint16(0x8001)
const macBridgePortAniEID = uint16(0x2102)
@@ -108,17 +109,17 @@
//NewOmciCC constructor returns a new instance of a OmciCC
//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func NewOmciCC(ctx context.Context, onu_device_entry *OnuDeviceEntry,
- device_id string, device_handler *DeviceHandler,
- core_proxy adapterif.CoreProxy, adapter_proxy adapterif.AdapterProxy) *OmciCC {
- logger.Infow("init-omciCC", log.Fields{"device-id": device_id})
+func NewOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
+ deviceID string, deviceHandler *DeviceHandler,
+ coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *OmciCC {
+ logger.Infow("init-omciCC", log.Fields{"device-id": deviceID})
var omciCC OmciCC
omciCC.enabled = false
- omciCC.pOnuDeviceEntry = onu_device_entry
- omciCC.deviceID = device_id
- omciCC.pBaseDeviceHandler = device_handler
- omciCC.coreProxy = core_proxy
- omciCC.adapterProxy = adapter_proxy
+ omciCC.pOnuDeviceEntry = onuDeviceEntry
+ omciCC.deviceID = deviceID
+ omciCC.pBaseDeviceHandler = deviceHandler
+ omciCC.coreProxy = coreProxy
+ omciCC.adapterProxy = adapterProxy
omciCC.supportExtMsg = false
omciCC.txFrames = 0
omciCC.txOnuFrames = 0
@@ -183,7 +184,7 @@
}
}
*/
- return errors.New("ReceiveOnuMessage unimplemented")
+ return errors.New("receiveOnuMessage unimplemented")
}
// Rx handler for onu messages
@@ -201,8 +202,8 @@
logger.Debug("cc-corrected-omci-message: trailer len inserted")
}
} else {
- logger.Errorw("received omci-message to small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
- return errors.New("RxOmciMessage to small for BaseFormat")
+ logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
+ return errors.New("rxOmciMessage too small for BaseFormat")
}
packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
@@ -227,27 +228,26 @@
logger.Debug("RxMsg is no Omci Response Message")
if omciMsg.TransactionID == 0 {
return oo.ReceiveOnuMessage(ctx, omciMsg)
- } else {
- logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages",
- log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload)})
- return errors.New("Autonomous Omci Message with TranSCorrId != 0 not acccepted")
}
+ logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages",
+ log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload)})
+ return errors.New("autonomous Omci Message with TranSCorrId != 0 not acccepted")
+
+ }
+ //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester")
+ oo.mutexRxSchedMap.Lock()
+ rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
+ if ok && rxCallbackEntry.cbFunction != nil {
+ //disadvantage of decoupling: error verification made difficult, but anyway the question is
+ // how to react on erroneous frame reception, maybe can simply be ignored
+ go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel)
+ // having posted the response the request is regarded as 'done'
+ delete(oo.rxSchedulerMap, omciMsg.TransactionID)
+ oo.mutexRxSchedMap.Unlock()
} else {
- //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester")
- oo.mutexRxSchedMap.Lock()
- rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
- if ok && rxCallbackEntry.cbFunction != nil {
- //disadvantage of decoupling: error verification made difficult, but anyway the question is
- // how to react on erroneous frame reception, maybe can simply be ignored
- go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel)
- // having posted the response the request is regarded as 'done'
- delete(oo.rxSchedulerMap, omciMsg.TransactionID)
- oo.mutexRxSchedMap.Unlock()
- } else {
- oo.mutexRxSchedMap.Unlock()
- logger.Error("omci-message-response for not registered transCorrId")
- return errors.New("could not find registered response handler tor transCorrId")
- }
+ oo.mutexRxSchedMap.Unlock()
+ logger.Error("omci-message-response for not registered transCorrId")
+ return errors.New("could not find registered response handler tor transCorrId")
}
return nil
@@ -355,7 +355,7 @@
}
func (oo *OmciCC) PublishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
- return errors.New("PublishRxResponseFrame unimplemented")
+ return errors.New("publishRxResponseFrame unimplemented")
/*
def _publish_rx_frame(self, tx_frame, rx_frame):
*/
@@ -486,7 +486,7 @@
if highPriority {
oo.mutexTid.Lock()
next = oo.hpTid
- oo.hpTid += 1
+ oo.hpTid++
if oo.hpTid < 0x8000 {
oo.hpTid = 0x8000
}
@@ -494,7 +494,7 @@
} else {
oo.mutexHpTid.Lock()
next = oo.tid
- oo.tid += 1
+ oo.tid++
if oo.tid >= 0x8000 {
oo.tid = 1
}
@@ -513,12 +513,12 @@
return serializeOmciLayer(omciLayer, request)
}
-func serializeOmciLayer(a_omciLayer *omci.OMCI, a_request gopacket.SerializableLayer) ([]byte, error) {
+func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
var options gopacket.SerializeOptions
options.FixLengths = true
buffer := gopacket.NewSerializeBuffer()
- err := gopacket.SerializeLayers(buffer, options, a_omciLayer, a_request)
+ err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
if err != nil {
logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
return nil, err
@@ -526,11 +526,13 @@
return buffer.Bytes(), nil
}
+/*
func hexEncode(omciPkt []byte) ([]byte, error) {
dst := make([]byte, hex.EncodedLen(len(omciPkt)))
hex.Encode(dst, omciPkt)
return dst, nil
}
+*/
//supply a response handler for omci response messages to be transferred to the requested FSM
func (oo *OmciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
@@ -541,7 +543,7 @@
if oo.pOnuDeviceEntry == nil {
logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
"device-id": oo.deviceID})
- return errors.New("DeviceEntryPointer is nil")
+ return errors.New("deviceEntryPointer is nil")
}
// no further test on SeqNo is done here, assignment from rxScheduler is trusted
@@ -609,7 +611,7 @@
err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel)
if err != nil {
logger.Error("aborting ONU Reboot!")
- oo.pOnuDeviceEntry.pMibDownloadFsm.pFsm.Event("reset")
+ _ = oo.pOnuDeviceEntry.pMibDownloadFsm.pFsm.Event("reset")
return err
}
return nil
@@ -756,9 +758,9 @@
}
func (oo *OmciCC) sendCreateMBServiceProfile(ctx context.Context,
- a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.GetNextTid(highPrio)
- instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo)
+ instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
@@ -812,19 +814,19 @@
}
func (oo *OmciCC) sendCreateMBPConfigData(ctx context.Context,
- a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.GetNextTid(highPrio)
- instID := macBridgePortAniEID + a_pUniPort.entityId
+ instID := macBridgePortAniEID + aPUniPort.entityId
logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
- "BridgeIdPointer": macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo),
- "PortNum": a_pUniPort.macBpNo,
- "TpType": uint8(a_pUniPort.portType),
- "TpPointer": a_pUniPort.entityId,
+ "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
+ "PortNum": aPUniPort.macBpNo,
+ "TpType": uint8(aPUniPort.portType),
+ "TpPointer": aPUniPort.entityId,
},
}
meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
@@ -864,10 +866,10 @@
}
func (oo *OmciCC) sendCreateEVTOConfigData(ctx context.Context,
- a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.GetNextTid(highPrio)
//same entityId is used as for MBSP (see there), but just arbitrary ...
- instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo)
+ instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
@@ -875,14 +877,14 @@
// (setting TPID values for the create would probably anyway be ignored by the omci lib)
// but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
assType := uint8(2) // default AssociationType is PPTPEthUni
- if a_pUniPort.portType == UniVEIP {
+ if aPUniPort.portType == UniVEIP {
assType = uint8(10) // for VEIP
}
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
"AssociationType": assType,
- "AssociatedMePointer": a_pUniPort.entityId,
+ "AssociatedMePointer": aPUniPort.entityId,
},
}
meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
@@ -1068,15 +1070,15 @@
}
meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
if omciErr.GetError() == nil {
- meClassIdName := meInstance.GetName()
+ meClassIDName := meInstance.GetName()
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
pkt, err := serializeOmciLayer(omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
omciRxCallbackPair := CallbackPair{
@@ -1085,10 +1087,10 @@
}
err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debugw("send get-request-msg done", log.Fields{"meClassIdName": meClassIdName, "device-id": oo.deviceID})
+ logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
return meInstance
}
logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
diff --git a/internal/pkg/onuadaptercore/omci_test_request.go b/internal/pkg/onuadaptercore/omci_test_request.go
index a1600fd..859dd9c 100644
--- a/internal/pkg/onuadaptercore/omci_test_request.go
+++ b/internal/pkg/onuadaptercore/omci_test_request.go
@@ -41,7 +41,7 @@
pDevOmciCC *OmciCC
started bool
result bool
- exclusive_cc bool
+ exclusiveCc bool
allowFailure bool
txSeqNo uint16
verifyDone chan<- bool
@@ -49,26 +49,26 @@
//NewOmciTestRequest returns a new instance of OmciTestRequest
func NewOmciTestRequest(ctx context.Context,
- device_id string, omci_cc *OmciCC,
- exclusive bool, allow_failure bool) *OmciTestRequest {
+ deviceID string, omciCc *OmciCC,
+ exclusive bool, allowFailure bool) *OmciTestRequest {
logger.Debug("omciTestRequest-init")
var omciTestRequest OmciTestRequest
- omciTestRequest.deviceID = device_id
- omciTestRequest.pDevOmciCC = omci_cc
+ omciTestRequest.deviceID = deviceID
+ omciTestRequest.pDevOmciCC = omciCc
omciTestRequest.started = false
omciTestRequest.result = false
- omciTestRequest.exclusive_cc = exclusive
- omciTestRequest.allowFailure = allow_failure
+ omciTestRequest.exclusiveCc = exclusive
+ omciTestRequest.allowFailure = allowFailure
return &omciTestRequest
}
//
-func (oo *OmciTestRequest) PerformOmciTest(ctx context.Context, exec_Channel chan<- bool) {
+func (oo *OmciTestRequest) PerformOmciTest(ctx context.Context, execChannel chan<- bool) {
logger.Debug("omciTestRequest-start-test")
if oo.pDevOmciCC != nil {
- oo.verifyDone = exec_Channel
+ oo.verifyDone = execChannel
// test functionality is limited to ONU-2G get request for the moment
// without yet checking the received response automatically here (might be improved ??)
tid := oo.pDevOmciCC.GetNextTid(false)
@@ -124,7 +124,7 @@
logger.Debugw("verify-omci-message-response error", log.Fields{"incorrect TransCorrId": omciMsg.TransactionID,
"expected": oo.txSeqNo})
oo.verifyDone <- false
- return errors.New("Unexpected TransCorrId")
+ return errors.New("unexpected TransCorrId")
}
if omciMsg.MessageType == omci.GetResponseType {
logger.Debugw("verify-omci-message-response", log.Fields{"correct RespType": omciMsg.MessageType})
@@ -132,7 +132,7 @@
logger.Debugw("verify-omci-message-response error", log.Fields{"incorrect RespType": omciMsg.MessageType,
"expected": omci.GetResponseType})
oo.verifyDone <- false
- return errors.New("Unexpected MessageType")
+ return errors.New("unexpected MessageType")
}
//TODO!!! further tests on the payload should be done here ...
diff --git a/internal/pkg/onuadaptercore/omci_vlan_config.go b/internal/pkg/onuadaptercore/omci_vlan_config.go
index f60cd93..1a08b40 100644
--- a/internal/pkg/onuadaptercore/omci_vlan_config.go
+++ b/internal/pkg/onuadaptercore/omci_vlan_config.go
@@ -65,7 +65,7 @@
cDoNotFilterEtherType uint32 = 0
cDoNotAddPrio uint32 = 15
cCopyPrioFromInner uint32 = 8
- cDontCarePrio uint32 = 0
+ //cDontCarePrio uint32 = 0
cDontCareVid uint32 = 0
cDontCareTpid uint32 = 0
cSetOutputTpidCopyDei uint32 = 4
@@ -79,13 +79,13 @@
vlanEvStartConfig = "vlanEvStartConfig"
vlanEvRxConfigVtfd = "vlanEvRxConfigVtfd"
vlanEvRxConfigEvtocd = "vlanEvRxConfigEvtocd"
- vlanEvCleanupConfig = "vlanEvCleanupConfig"
- vlanEvRxCleanVtfd = "vlanEvRxCleanVtfd"
- vlanEvRxCleanEvtocd = "vlanEvRxCleanEvtocd"
- vlanEvTimeoutSimple = "vlanEvTimeoutSimple"
- vlanEvTimeoutMids = "vlanEvTimeoutMids"
- vlanEvReset = "vlanEvReset"
- vlanEvRestart = "vlanEvRestart"
+ //vlanEvCleanupConfig = "vlanEvCleanupConfig"
+ //vlanEvRxCleanVtfd = "vlanEvRxCleanVtfd"
+ //vlanEvRxCleanEvtocd = "vlanEvRxCleanEvtocd"
+ //vlanEvTimeoutSimple = "vlanEvTimeoutSimple"
+ //vlanEvTimeoutMids = "vlanEvTimeoutMids"
+ vlanEvReset = "vlanEvReset"
+ vlanEvRestart = "vlanEvRestart"
)
const (
// states of config PON ANI port FSM
@@ -237,10 +237,10 @@
if oFsm.pUniTechProf.getTechProfileDone(oFsm.pOnuUniPort.uniId, oFsm.techProfileID) {
// let the vlan processing begin
- a_pAFsm.pFsm.Event(vlanEvStartConfig)
+ _ = a_pAFsm.pFsm.Event(vlanEvStartConfig)
} else {
// set to waiting for Techprofile
- a_pAFsm.pFsm.Event(vlanEvWaitTechProf)
+ _ = a_pAFsm.pFsm.Event(vlanEvWaitTechProf)
}
}
}(pConfigVlanStateAFsm)
@@ -256,7 +256,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
pConfigVlanStateAFsm := oFsm.pAdaptFsm
go func(a_pAFsm *AdapterFsm) {
- a_pAFsm.pFsm.Event(vlanEvRxConfigVtfd)
+ _ = a_pAFsm.pFsm.Event(vlanEvRxConfigVtfd)
}(pConfigVlanStateAFsm)
} else {
logger.Debugw("UniVlanConfigFsm create VTFD", log.Fields{
@@ -320,7 +320,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(vlanEvReset)
+ _ = a_pAFsm.pFsm.Event(vlanEvReset)
}
}(pConfigVlanStateAFsm)
}
@@ -343,7 +343,7 @@
//try to restart the FSM to 'disabled', decouple event transfer
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(vlanEvRestart)
+ _ = a_pAFsm.pFsm.Event(vlanEvRestart)
}
}(pConfigVlanStateAFsm)
}
@@ -361,34 +361,32 @@
logger.Debugw("Start UniVlanConfigFsm Msg processing", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
loop:
for {
- select {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.pAdaptFsm.deviceID})
// break loop
- case message, ok := <-oFsm.pAdaptFsm.commChan:
- if !ok {
- logger.Info("UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- // but then we have to ensure a restart of the FSM as well - as exceptional procedure
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ message, ok := <-oFsm.pAdaptFsm.commChan
+ if !ok {
+ logger.Info("UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+ // but then we have to ensure a restart of the FSM as well - as exceptional procedure
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ break loop
+ }
+ logger.Debugw("UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+
+ switch message.Type {
+ case TestMsg:
+ msg, _ := message.Data.(TestMessage)
+ if msg.TestMessageVal == AbortMessageProcessing {
+ logger.Infow("UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
break loop
}
- logger.Debugw("UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
-
- switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
- break loop
- }
- logger.Warnw("UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciVlanConfigMessage(msg)
- default:
- logger.Warn("UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
- "message.Type": message.Type})
- }
+ logger.Warnw("UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ case OMCI:
+ msg, _ := message.Data.(OmciMessage)
+ oFsm.handleOmciVlanConfigMessage(msg)
+ default:
+ logger.Warn("UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
+ "message.Type": message.Type})
}
}
logger.Infow("End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
@@ -424,7 +422,7 @@
switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
case "VlanTaggingFilterData":
{ // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigVtfd)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigVtfd)
}
}
}
@@ -492,7 +490,7 @@
if err != nil {
logger.Errorw("Evtocd set TPID failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
}
} //for local var
@@ -542,7 +540,7 @@
if err != nil {
logger.Errorw("Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
}
} else {
@@ -592,7 +590,7 @@
if err != nil {
logger.Errorw("Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
}
} else {
@@ -643,7 +641,7 @@
if err != nil {
logger.Errorw("Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
}
} //just for local var's
@@ -693,7 +691,7 @@
if err != nil {
logger.Errorw("Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
}
} //just for local var's
@@ -702,8 +700,7 @@
// if Config has been done for all GemPort instances let the FSM proceed
logger.Debugw("EVTOCD set loop finished", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
- return
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
}
func (oFsm *UniVlanConfigFsm) waitforOmciResponse() error {
@@ -715,7 +712,7 @@
logger.Warnw("UniVlanConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
return errors.New("UniVlanConfigFsm multi entity timeout")
case success := <-oFsm.omciMIdsResponseReceived:
- if success == true {
+ if success {
logger.Debug("UniVlanConfigFsm multi entity response received")
return nil
}
diff --git a/internal/pkg/onuadaptercore/onu_device_db.go b/internal/pkg/onuadaptercore/onu_device_db.go
index 4b80a94..def0dc3 100644
--- a/internal/pkg/onuadaptercore/onu_device_db.go
+++ b/internal/pkg/onuadaptercore/onu_device_db.go
@@ -37,37 +37,37 @@
}
//OnuDeviceDB returns a new instance for a specific ONU_Device_Entry
-func NewOnuDeviceDB(ctx context.Context, a_pOnuDeviceEntry *OnuDeviceEntry) *OnuDeviceDB {
- logger.Debugw("Init OnuDeviceDB for:", log.Fields{"device-id": a_pOnuDeviceEntry.deviceID})
+func NewOnuDeviceDB(ctx context.Context, aPOnuDeviceEntry *OnuDeviceEntry) *OnuDeviceDB {
+ logger.Debugw("Init OnuDeviceDB for:", log.Fields{"device-id": aPOnuDeviceEntry.deviceID})
var onuDeviceDB OnuDeviceDB
onuDeviceDB.ctx = ctx
- onuDeviceDB.pOnuDeviceEntry = a_pOnuDeviceEntry
+ onuDeviceDB.pOnuDeviceEntry = aPOnuDeviceEntry
onuDeviceDB.meDb = make(MeDbMap)
return &onuDeviceDB
}
-func (onuDeviceDB *OnuDeviceDB) PutMe(meClassId me.ClassID, meEntityId uint16, meAttributes me.AttributeValueMap) {
+func (onuDeviceDB *OnuDeviceDB) PutMe(meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
//filter out the OnuData
- if me.OnuDataClassID == meClassId {
+ if me.OnuDataClassID == meClassID {
return
}
- //logger.Debugw("Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassId": meClassId, "meEntityId": meEntityId})
- meInstMap, ok := onuDeviceDB.meDb[meClassId]
+ //logger.Debugw("Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
+ meInstMap, ok := onuDeviceDB.meDb[meClassID]
if !ok {
- logger.Debugw("meClassId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw("meClassID not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
meInstMap = make(map[uint16]me.AttributeValueMap)
- onuDeviceDB.meDb[meClassId] = meInstMap
- onuDeviceDB.meDb[meClassId][meEntityId] = meAttributes
+ onuDeviceDB.meDb[meClassID] = meInstMap
+ onuDeviceDB.meDb[meClassID][meEntityID] = meAttributes
} else {
- meAttribs, ok := onuDeviceDB.meDb[meClassId][meEntityId]
+ meAttribs, ok := meInstMap[meEntityID]
if !ok {
/* verbose logging, avoid in >= debug level
logger.Debugw("meEntityId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
*/
- onuDeviceDB.meDb[meClassId][meEntityId] = meAttributes
+ meInstMap[meEntityID] = meAttributes
} else {
/* verbose logging, avoid in >= debug level
logger.Debugw("ME-Instance exists already: merge attribute data :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
@@ -75,7 +75,7 @@
for k, v := range meAttributes {
meAttribs[k] = v
}
- onuDeviceDB.meDb[meClassId][meEntityId] = meAttribs
+ meInstMap[meEntityID] = meAttribs
/* verbose logging, avoid in >= debug level
logger.Debugw("ME-Instance updated :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
*/
@@ -83,17 +83,16 @@
}
}
-func (onuDeviceDB *OnuDeviceDB) GetMe(meClassId me.ClassID, meEntityId uint16) me.AttributeValueMap {
+func (onuDeviceDB *OnuDeviceDB) GetMe(meClassID me.ClassID, meEntityID uint16) me.AttributeValueMap {
- if meAttributes, present := onuDeviceDB.meDb[meClassId][meEntityId]; present {
+ if meAttributes, present := onuDeviceDB.meDb[meClassID][meEntityID]; present {
/* verbose logging, avoid in >= debug level
- logger.Debugw("ME found:", log.Fields{"meClassId": meClassId, "meEntityId": meEntityId, "meAttributes": meAttributes,
+ logger.Debugw("ME found:", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttributes": meAttributes,
"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
*/
return meAttributes
- } else {
- return nil
}
+ return nil
}
func (onuDeviceDB *OnuDeviceDB) GetUint32Attrib(meAttribute interface{}) (uint32, error) {
@@ -126,9 +125,9 @@
func (onuDeviceDB *OnuDeviceDB) LogMeDb() {
logger.Debugw("ME instances stored for :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
- for meClassId, meInstMap := range onuDeviceDB.meDb {
- for meEntityId, meAttribs := range meInstMap {
- logger.Debugw("ME instance: ", log.Fields{"meClassId": meClassId, "meEntityId": meEntityId, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ for meClassID, meInstMap := range onuDeviceDB.meDb {
+ for meEntityID, meAttribs := range meInstMap {
+ logger.Debugw("ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
}
}
}
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
index 154e513..dfb056b 100644
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ b/internal/pkg/onuadaptercore/onu_device_entry.go
@@ -44,7 +44,7 @@
ulEvStart = "ulEvStart"
ulEvResetMib = "ulEvResetMib"
ulEvGetVendorAndSerial = "ulEvGetVendorAndSerial"
- ulEvGetEquipmentId = "ulEvGetEquipmentId"
+ ulEvGetEquipmentID = "ulEvGetEquipmentId"
ulEvGetFirstSwVersion = "ulEvGetFirstSwVersion"
ulEvGetSecondSwVersion = "ulEvGetSecondSwVersion"
ulEvGetMacAddress = "ulEvGetMacAddress"
@@ -65,7 +65,7 @@
ulStStarting = "ulStStarting"
ulStResettingMib = "ulStResettingMib"
ulStGettingVendorAndSerial = "ulStGettingVendorAndSerial"
- ulStGettingEquipmentId = "ulStGettingEquipmentId"
+ ulStGettingEquipmentID = "ulStGettingEquipmentID"
ulStGettingFirstSwVersion = "ulStGettingFirstSwVersion"
ulStGettingSecondSwVersion = "ulStGettingSecondSwVersion"
ulStGettingMacAddress = "ulStGettingMacAddress"
@@ -125,9 +125,9 @@
)
type activityDescr struct {
- databaseClass func() error
- advertiseEvents bool
- auditDelay uint16
+ databaseClass func() error
+ //advertiseEvents bool
+ auditDelay uint16
//tasks map[string]func() error
}
type OmciDeviceFsms map[string]activityDescr
@@ -157,12 +157,12 @@
//OntDeviceEntry structure holds information about the attached FSM'as and their communication
const (
- FirstSwImageMeId = 0
- SecondSwImageMeId = 1
+ FirstSwImageMeID = 0
+ SecondSwImageMeID = 1
)
-const OnugMeId = 0
-const Onu2gMeId = 0
-const IpHostConfigDataMeId = 1
+const OnugMeID = 0
+const Onu2gMeID = 0
+const IPHostConfigDataMeID = 1
const OnugSerialNumberLen = 8
const OmciMacAddressLen = 6
@@ -183,7 +183,7 @@
vendorID string
serialNumber string
equipmentID string
- swImages [SecondSwImageMeId + 1]SwImages
+ swImages [SecondSwImageMeID + 1]SwImages
activeSwVersion string
macAddress string
//lockDeviceEntries sync.RWMutex
@@ -232,8 +232,8 @@
"mib-synchronizer": {
//mibSyncFsm, // Implements the MIB synchronization state machine
onuDeviceEntry.MibDbVolatileDict, // Implements volatile ME MIB database
- true, // Advertise events on OpenOMCI event bus
- 60, // Time to wait between MIB audits. 0 to disable audits.
+ //true, // Advertise events on OpenOMCI event bus
+ 60, // Time to wait between MIB audits. 0 to disable audits.
// map[string]func() error{
// "mib-upload": onuDeviceEntry.MibUploadTask,
// "mib-template": onuDeviceEntry.MibTemplateTask,
@@ -263,8 +263,8 @@
{Name: ulEvResetMib, Src: []string{ulStStarting}, Dst: ulStResettingMib},
{Name: ulEvGetVendorAndSerial, Src: []string{ulStResettingMib}, Dst: ulStGettingVendorAndSerial},
- {Name: ulEvGetEquipmentId, Src: []string{ulStGettingVendorAndSerial}, Dst: ulStGettingEquipmentId},
- {Name: ulEvGetFirstSwVersion, Src: []string{ulStGettingEquipmentId}, Dst: ulStGettingFirstSwVersion},
+ {Name: ulEvGetEquipmentID, Src: []string{ulStGettingVendorAndSerial}, Dst: ulStGettingEquipmentID},
+ {Name: ulEvGetFirstSwVersion, Src: []string{ulStGettingEquipmentID}, Dst: ulStGettingFirstSwVersion},
{Name: ulEvGetSecondSwVersion, Src: []string{ulStGettingFirstSwVersion}, Dst: ulStGettingSecondSwVersion},
{Name: ulEvGetMacAddress, Src: []string{ulStGettingSecondSwVersion}, Dst: ulStGettingMacAddress},
{Name: ulEvGetMibTemplate, Src: []string{ulStGettingMacAddress}, Dst: ulStGettingMibTemplate},
@@ -290,11 +290,11 @@
{Name: ulEvSuccess, Src: []string{ulStResynchronizing}, Dst: ulStInSync},
{Name: ulEvDiffsFound, Src: []string{ulStResynchronizing}, Dst: ulStOutOfSync},
- {Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentId, ulStGettingFirstSwVersion,
+ {Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
ulStInSync, ulStOutOfSync, ulStAuditing}, Dst: ulStStarting},
- {Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentId, ulStGettingFirstSwVersion,
+ {Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
ulStInSync, ulStOutOfSync, ulStAuditing}, Dst: ulStDisabled},
},
@@ -304,7 +304,7 @@
("enter_" + ulStStarting): func(e *fsm.Event) { onuDeviceEntry.enterStartingState(e) },
("enter_" + ulStResettingMib): func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(e) },
("enter_" + ulStGettingVendorAndSerial): func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(e) },
- ("enter_" + ulStGettingEquipmentId): func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIdState(e) },
+ ("enter_" + ulStGettingEquipmentID): func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(e) },
("enter_" + ulStGettingFirstSwVersion): func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(e) },
("enter_" + ulStGettingSecondSwVersion): func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(e) },
("enter_" + ulStGettingMacAddress): func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(e) },
@@ -438,7 +438,7 @@
}
//Relay the InSync message via Handler to Rw core - Status update
-func (oo *OnuDeviceEntry) transferSystemEvent(dev_Event OnuDeviceEvent) error {
+func (oo *OnuDeviceEntry) transferSystemEvent(dev_Event OnuDeviceEvent) {
logger.Debugw("relaying system-event", log.Fields{"Event": dev_Event})
// decouple the handler transfer from further processing here
// TODO!!! check if really no synch is required within the system e.g. to ensure following steps ..
@@ -460,5 +460,4 @@
} else {
logger.Warnw("device-event not yet handled", log.Fields{"state": dev_Event})
}
- return nil
}
diff --git a/internal/pkg/onuadaptercore/onu_uni_tp.go b/internal/pkg/onuadaptercore/onu_uni_tp.go
index a5a8ba4..1a80441 100644
--- a/internal/pkg/onuadaptercore/onu_uni_tp.go
+++ b/internal/pkg/onuadaptercore/onu_uni_tp.go
@@ -26,7 +26,6 @@
"strings"
"sync"
- "github.com/looplab/fsm"
"github.com/opencord/voltha-lib-go/v3/pkg/db"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
@@ -77,15 +76,15 @@
schedPolicy uint8
}
type gemPortParamStruct struct {
- ponOmciCC bool
+ //ponOmciCC bool
gemPortID uint16
direction uint8
gemPortEncState uint8
prioQueueIndex uint8
pbitString string
discardPolicy string
- //could also be a queue specific paramter, not used that way here
- maxQueueSize uint16
+ //could also be a queue specific parameter, not used that way here
+ //maxQueueSize uint16
queueSchedPolicy string
queueWeight uint8
}
@@ -218,7 +217,7 @@
// configureUniTp checks existing tp resources to delete and starts the corresponding OMCI configuation of the UNI port
// all possibly blocking processing must be run in background to allow for deadline supervision!
// but take care on sequential background processing when needed (logical dependencies)
-// use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronisation
+// use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronization
func (onuTP *OnuUniTechProf) configureUniTp(ctx context.Context,
aUniID uint8, aPathString string, wg *sync.WaitGroup) {
defer wg.Done() //always decrement the waitGroup on return
@@ -286,10 +285,10 @@
logger.Debugw("tech-profile related configuration aborted on set",
log.Fields{"device-id": onuTP.deviceID, "UniId": aUniID})
onuTP.procResult = errors.New("TechProfile config aborted: Omci AniSideConfig failed")
- //this issue here means that the AniConfigFsm has not finished succesfully
+ //this issue here means that the AniConfigFsm has not finished successfully
//which requires to reset it to allow for new usage, e.g. also on a different UNI
//(without that it would be reset on device down indication latest)
- onuTP.pAniConfigFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = onuTP.pAniConfigFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
}
} else {
@@ -539,7 +538,7 @@
//note: the code is currently restricted to one TCcont per Onu (index [0])
//get the relevant values from the profile and store to mapPonAniConfig
(*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.allocID = uint16(tpInst.UsScheduler.AllocID)
- //maybe tCont scheduling not (yet) needed - just to basicaly have it for future
+ //maybe tCont scheduling not (yet) needed - just to basically have it for future
// (would only be relevant in case of ONU-2G QOS configuration flexibility)
if tpInst.UsScheduler.QSchedPolicy == "StrictPrio" {
(*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.schedPolicy = 1 //for the moment fixed value acc. G.988 //TODO: defines!
@@ -593,7 +592,7 @@
(*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].queueWeight =
uint8(content.Weight)
}
- if loGemPortRead == false {
+ if !loGemPortRead {
logger.Errorw("PonAniConfig reject - no GemPort could be read from TechProfile",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID})
//remove PonAniConfig as done so far, delete map should be safe, even if not existing
@@ -601,7 +600,7 @@
onuTP.chTpConfigProcessingStep <- 0 //error indication
return
}
- //TODO!! MC (downstream) GemPorts can be set using DownstreamGemPortAttributeList seperately
+ //TODO!! MC (downstream) GemPorts can be set using DownstreamGemPortAttributeList separately
//logger does not simply output the given structures, just give some example debug values
logger.Debugw("PonAniConfig read from TechProfile", log.Fields{
@@ -649,7 +648,7 @@
}
}
-// createUniLockFsm initialises and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
+// createUniLockFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
func (onuTP *OnuUniTechProf) createAniConfigFsm(aUniID uint8,
apCurrentUniPort *OnuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) {
logger.Debugw("createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID})
@@ -675,8 +674,7 @@
/* Uni related ANI config procedure -
***** should run via 'aniConfigDone' state and generate the argument requested event *****
*/
- var pACStatemachine *fsm.FSM
- pACStatemachine = onuTP.pAniConfigFsm.pAdaptFsm.pFsm
+ pACStatemachine := onuTP.pAniConfigFsm.pAdaptFsm.pFsm
if pACStatemachine != nil {
if pACStatemachine.Is(aniStDisabled) {
//FSM init requirement to get informed abou FSM completion! (otherwise timeout of the TechProf config)
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index c9d4b37..28d124d 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -86,8 +86,8 @@
"mib-synchronizer": {
//mibSyncFsm, // Implements the MIB synchronization state machine
MibDbVolatileDictImpl, // Implements volatile ME MIB database
- true, // Advertise events on OpenOMCI event bus
- cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits.
+ //true, // Advertise events on OpenOMCI event bus
+ cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits.
// map[string]func() error{
// "mib-upload": onuDeviceEntry.MibUploadTask,
// "mib-template": onuDeviceEntry.MibTemplateTask,
@@ -126,11 +126,13 @@
}
}
+/*
func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *DeviceHandler) {
oo.lockDeviceHandlersMap.Lock()
defer oo.lockDeviceHandlersMap.Unlock()
delete(oo.deviceHandlers, agent.deviceID)
}
+*/
func (oo *OpenONUAC) getDeviceHandler(deviceID string) *DeviceHandler {
oo.lockDeviceHandlersMap.Lock()
diff --git a/internal/pkg/onuadaptercore/platform.go b/internal/pkg/onuadaptercore/platform.go
index 2aef6e1..7e6469c 100644
--- a/internal/pkg/onuadaptercore/platform.go
+++ b/internal/pkg/onuadaptercore/platform.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+//Package adaptercoreonu provides the utility for onu devices, flows and statistics
package adaptercoreonu
//Attention: this file is more or less a coopy of file olt_platform.go from the voltha-openolt-adapter
@@ -98,8 +98,11 @@
bitsForONUID = 8
// Number of bits for PON ID
bitsForPONID = 8
- // Number of bits to differentiate between UNI and NNI Logical Port
- bitsForUNINNIDiff = 1
+ /*
+ // Number of bits to differentiate between UNI and NNI Logical Port
+ bitsForUNINNIDiff = 1
+ */
+
//MaxOnusPerPon is Max number of ONUs on any PON port
MaxOnusPerPon = (1 << bitsForONUID)
//MaxPonsPerOlt is Max number of PON ports on any OLT
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/onuadaptercore/uniportadmin.go
index 8ff64ce..874bf86 100644
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/onuadaptercore/uniportadmin.go
@@ -76,7 +76,7 @@
"device-id": aDeviceID})
return nil
}
- if aAdminState == true { //port locking requested
+ if aAdminState { //port locking requested
instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
uniStDisabled,
fsm.Events{
@@ -183,7 +183,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(uniEvStartAdmin)
+ _ = a_pAFsm.pFsm.Event(uniEvStartAdmin)
}
}(pLockStateAFsm)
}
@@ -191,7 +191,7 @@
func (oFsm *LockStateFsm) enterSettingOnuGState(e *fsm.Event) {
var omciAdminState uint8 = 1 //default locked
- if oFsm.adminState == false {
+ if !oFsm.adminState {
omciAdminState = 0
}
logger.Debugw("LockStateFSM Tx Set::ONU-G:admin", log.Fields{
@@ -222,7 +222,7 @@
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(uniEvReset)
+ _ = a_pAFsm.pFsm.Event(uniEvReset)
}
}(pLockStateAFsm)
}
@@ -245,7 +245,7 @@
// see DownloadedState: decouple event transfer
go func(a_pAFsm *AdapterFsm) {
if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- a_pAFsm.pFsm.Event(uniEvRestart)
+ _ = a_pAFsm.pFsm.Event(uniEvRestart)
}
}(pLockStateAFsm)
}
@@ -255,34 +255,32 @@
logger.Debugw("Start LockStateFsm Msg processing", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
loop:
for {
- select {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.pAdaptFsm.deviceID})
// break loop
- case message, ok := <-oFsm.pAdaptFsm.commChan:
- if !ok {
- logger.Info("LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- // but then we have to ensure a restart of the FSM as well - as exceptional procedure
- oFsm.pAdaptFsm.pFsm.Event(uniEvRestart)
+ message, ok := <-oFsm.pAdaptFsm.commChan
+ if !ok {
+ logger.Info("LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+ // but then we have to ensure a restart of the FSM as well - as exceptional procedure
+ _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRestart)
+ break loop
+ }
+ logger.Debugw("LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
+
+ switch message.Type {
+ case TestMsg:
+ msg, _ := message.Data.(TestMessage)
+ if msg.TestMessageVal == AbortMessageProcessing {
+ logger.Infow("LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
break loop
}
- logger.Debugw("LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
-
- switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
- break loop
- }
- logger.Warnw("LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciLockStateMessage(msg)
- default:
- logger.Warn("LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
- "message.Type": message.Type})
- }
+ logger.Warnw("LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ case OMCI:
+ msg, _ := message.Data.(OmciMessage)
+ oFsm.handleOmciLockStateMessage(msg)
+ default:
+ logger.Warn("LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID,
+ "message.Type": message.Type})
}
}
logger.Infow("End LockStateFsm Msg processing", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
@@ -319,7 +317,7 @@
switch oFsm.pOmciCC.pLastTxMeInstance.GetName() {
case "OnuG":
{ // let the FSM proceed ...
- oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
+ _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
}
case "UniG", "VEIP":
{ // let the PPTP init proceed by stopping the wait function
@@ -335,7 +333,7 @@
func (oFsm *LockStateFsm) performUniPortAdminSet() {
var omciAdminState uint8 = 1 //default locked
- if oFsm.adminState == false {
+ if !oFsm.adminState {
omciAdminState = 0
}
//set UNI-G or VEIP AdminState
@@ -365,27 +363,26 @@
if err != nil {
logger.Errorw("PPTP Admin State set failed, aborting LockState set!",
log.Fields{"device-id": oFsm.pAdaptFsm.deviceID, "Port": uniNo})
- oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
return
}
} //for all UNI ports
// if Config has been done for all UNI related instances let the FSM proceed
// while we did not check here, if there is some port at all - !?
logger.Infow("PPTP config loop finished", log.Fields{"device-id": oFsm.pAdaptFsm.deviceID})
- oFsm.pAdaptFsm.pFsm.Event(uniEvRxUnisResp)
- return
+ _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxUnisResp)
}
func (oFsm *LockStateFsm) waitforOmciResponse(apMeInstance *me.ManagedEntity) error {
select {
- // maybe be also some outside cancel (but no context modelled for the moment ...)
+ // maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
logger.Warnw("LockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.pAdaptFsm.deviceID})
return errors.New("LockStateFsm uni-set timeout")
case success := <-oFsm.omciLockResponseReceived:
- if success == true {
+ if success {
logger.Debug("LockStateFSM uni-set response received")
return nil
}
diff --git a/pkg/mocks/common.go b/pkg/mocks/common.go
index 3b2df29..546f2fe 100644
--- a/pkg/mocks/common.go
+++ b/pkg/mocks/common.go
@@ -21,12 +21,10 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-var logger log.Logger
-
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
+ _, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
if err != nil {
panic(err)
}