VOL-4057 - EntityID changes for various MEs
Change-Id: I19cf521113fc554074d18ab3058f990d1f54a365
diff --git a/internal/pkg/onuadaptercore/me_config.go b/internal/pkg/onuadaptercore/me_config.go
new file mode 100644
index 0000000..11ffe87
--- /dev/null
+++ b/internal/pkg/onuadaptercore/me_config.go
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package adaptercoreonu provides the utility for onu devices, flows and statistics
+package adaptercoreonu
+
+import (
+ "fmt"
+)
+
+const (
+ tpIDStart = 64
+ tpIDEnd = 256
+ tpRange = tpIDEnd - tpIDStart
+ maxUni = 256
+ ieeMaperServiceProfileBaseEID = uint16(0x1001)
+ macBridgePortAniBaseEID = uint16(0x1001)
+ macBridgePortUniBaseEID = uint16(0x201)
+ macBridgePortAniMcastBaseEID = uint16(0xA01)
+ galEthernetEID = uint16(1)
+ macBridgeServiceProfileEID = uint16(0x201)
+)
+
+func generateIeeMaperServiceProfileEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
+ if tpID < tpIDStart || tpID >= tpIDEnd {
+ return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
+ }
+ if uniPortMacBpNo > maxUni {
+ return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+ }
+ return (ieeMaperServiceProfileBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
+}
+
+func generateANISideMBPCDEID(uniPortMacBpNo uint16, tpID uint16) (uint16, error) {
+ if tpID < tpIDStart || tpID >= tpIDEnd {
+ return 0, fmt.Errorf("tech profile id out of range - %d", tpID)
+ }
+ if uniPortMacBpNo > maxUni {
+ return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+ }
+ return (macBridgePortAniBaseEID + uniPortMacBpNo*tpRange + tpID - tpIDStart), nil
+}
+
+func generateUNISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
+ if uniPortMacBpNo > maxUni {
+ return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+ }
+ return (macBridgePortUniBaseEID + uniPortMacBpNo), nil
+}
+
+func generateMcastANISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
+
+ if uniPortMacBpNo > maxUni {
+ return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+ }
+ return (macBridgePortAniMcastBaseEID + uniPortMacBpNo), nil
+}
diff --git a/internal/pkg/onuadaptercore/mib_download.go b/internal/pkg/onuadaptercore/mib_download.go
index 148291c..305a647 100644
--- a/internal/pkg/onuadaptercore/mib_download.go
+++ b/internal/pkg/onuadaptercore/mib_download.go
@@ -331,7 +331,7 @@
//create MBPCD
onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigData(
+ meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigDataUniSide(
log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
if err != nil {
onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/onuadaptercore/omci_ani_config.go
index a3df661..ae70353 100644
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/onuadaptercore/omci_ani_config.go
@@ -294,17 +294,28 @@
oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID)
}
+//nolint: gocyclo
+//TODO:visit here for refactoring for gocyclo
func (oFsm *uniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *AdapterFsm) {
if aPAFsm != nil && aPAFsm.pFsm != nil {
//stick to pythonAdapter numbering scheme
//index 0 in naming refers to possible usage of multiple instances (later)
- oFsm.mapperSP0ID = ieeeMapperServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) + uint16(oFsm.techProfileID)
- oFsm.macBPCD0ID = macBridgePortAniEID + uint16(oFsm.pOnuUniPort.entityID) + uint16(oFsm.techProfileID)
-
- /*
- // Find a free TCONT Instance ID and use it
- foundFreeTcontInstID := false
- */
+ var err error
+ oFsm.mapperSP0ID, err = generateIeeMaperServiceProfileEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.techProfileID))
+ if err != nil {
+ logger.Errorw(ctx, "error generating maper id", log.Fields{"device-id": oFsm.deviceID,
+ "techProfileID": oFsm.techProfileID, "error": err})
+ return
+ }
+ oFsm.macBPCD0ID, err = generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.techProfileID))
+ if err != nil {
+ logger.Errorw(ctx, "error generating mbpcd id", log.Fields{"device-id": oFsm.deviceID,
+ "techProfileID": oFsm.techProfileID, "error": err})
+ return
+ }
+ logger.Debugw(ctx, "generated ids for ani config", log.Fields{"mapperSP0ID": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
+ "macBPCD0ID": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16), "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "techProfileID": oFsm.techProfileID})
if tcontInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
// FIXME: Ideally the ME configurations on the ONU should constantly be MIB Synced back to the ONU DB
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/onuadaptercore/omci_cc.go
index 0e3b8a5..649b58f 100644
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/onuadaptercore/omci_cc.go
@@ -44,15 +44,11 @@
// ### OMCI related definitions - retrieved from Python adapter code/trace ####
-const galEthernetEID = uint16(1)
const maxGemPayloadSize = uint16(48)
const connectivityModeValue = uint8(5)
//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)
const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
@@ -1000,12 +996,17 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
+func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
tid := oo.getNextTid(highPrio)
- instID := macBridgePortAniEID + aPUniPort.entityID
- logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
- "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
+ instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
+ if idErr != nil {
+ logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
+ "Err": idErr, "device-id": oo.deviceID})
+ return nil, idErr
+ }
+ logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
+ "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
meParams := me.ParamData{
EntityID: instID,
diff --git a/internal/pkg/onuadaptercore/omci_vlan_config.go b/internal/pkg/onuadaptercore/omci_vlan_config.go
index 308d3af..7e06cae 100644
--- a/internal/pkg/onuadaptercore/omci_vlan_config.go
+++ b/internal/pkg/onuadaptercore/omci_vlan_config.go
@@ -945,10 +945,11 @@
} else {
// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
- vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + uint16(oFsm.actualUniVlanConfigRule.TpID)
+ vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
- "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
+ "in state": e.FSM.Current(), "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
// setVid is assumed to be masked already by the caller to 12 bit
oFsm.vlanFilterList[0] = uint16(oFsm.actualUniVlanConfigRule.SetVid)
oFsm.mutexFlowParams.Unlock()
@@ -1129,11 +1130,12 @@
if oFsm.numVlanFilterEntries == 0 {
// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
- vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + uint16(oFsm.actualUniVlanConfigRule.TpID)
+ vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
//no VTFD yet created
logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
- "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
+ "in state": e.FSM.Current(), "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
// 'SetVid' below is assumed to be masked already by the caller to 12 bit
oFsm.vlanFilterList[0] = uint16(oFsm.actualUniVlanConfigRule.SetVid)
@@ -1173,12 +1175,12 @@
} else {
// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
- vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID +
- uint16(oFsm.actualUniVlanConfigRule.TpID)
+ vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
- "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
+ "in state": e.FSM.Current(), "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
// setVid is assumed to be masked already by the caller to 12 bit
oFsm.vlanFilterList[oFsm.numVlanFilterEntries] =
uint16(oFsm.actualUniVlanConfigRule.SetVid)
@@ -1286,12 +1288,13 @@
} else {
vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization and 're-copy'
if oFsm.numVlanFilterEntries == 1 {
- vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + uint16(loRuleParams.TpID)
+ vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
//only one active VLAN entry (hopefully the SetVID we want to remove - should be, but not verified ..)
// so we can just delete the VTFD entry
logger.Debugw(ctx, "UniVlanConfigFsm: VTFD delete (no more vlan filters)",
- log.Fields{"current vlan list": oFsm.vlanFilterList,
- "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
+ log.Fields{"current vlan list": oFsm.vlanFilterList, "EntitytId": strconv.FormatInt(int64(vtfdID), 16),
+ "in state": e.FSM.Current(), "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
loVlanEntryClear = 1 //full VlanFilter clear request
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
oFsm.mutexPLastTxMeInstance.Lock()
@@ -1323,7 +1326,7 @@
}
}
if loVlanEntryRmPos < cVtfdTableSize {
- vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + uint16(loRuleParams.TpID)
+ vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
//valid entry was found - to be eclipsed
loVlanEntryClear = 2 //VlanFilter remove request for a specific entry
for i := uint8(0); i < oFsm.numVlanFilterEntries; i++ {
@@ -1337,7 +1340,8 @@
}
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
- "new vlan list": vtfdFilterList, "device-id": oFsm.deviceID})
+ "new vlan list": vtfdFilterList, "device-id": oFsm.deviceID,
+ "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
// FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME
@@ -2424,9 +2428,19 @@
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMSCI)
}
+ macBpCdEID, errMacBpCdEID := generateMcastANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+ if errMacBpCdEID != nil {
+ logger.Errorw(ctx, "MulticastMacBridgePortConfigData entity id generation failed, aborting AniConfig FSM!",
+ log.Fields{"device-id": oFsm.deviceID})
+ _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ return fmt.Errorf("generateMcastANISideMBPCDEID responseError %s, error %s", oFsm.deviceID, errMacBpCdEID)
+ }
+ logger.Debugw(ctx, "UniVlanConfigFsm set macBpCdEID for mcast", log.Fields{
+ "EntitytId": strconv.FormatInt(int64(macBpCdEID), 16), "macBpNo": oFsm.pOnuUniPort.macBpNo,
+ "in state": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
meParams := me.ParamData{
- EntityID: macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo),
+ EntityID: macBpCdEID,
Attributes: me.AttributeValueMap{
"BridgeIdPointer": macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo),
"PortNum": 0xf0, //fixed unique ANI side indication
@@ -2460,7 +2474,7 @@
// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
- mcastVtfdID := macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo)
+ mcastVtfdID := macBpCdEID
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD for mcast", log.Fields{
"EntitytId": strconv.FormatInt(int64(mcastVtfdID), 16), "mcastVlanID": vlanID,
@@ -2504,13 +2518,14 @@
}
func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo(ctx context.Context) error {
- instID, err := oFsm.pDeviceHandler.getUniPortMEEntityID(oFsm.pOnuUniPort.portNo)
+ instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
if err != nil {
- logger.Errorw(ctx, "error fetching uni port me instance",
- log.Fields{"device-id": oFsm.deviceID, "portNo": oFsm.pOnuUniPort.portNo})
+ logger.Errorw(ctx, "error generrating me instance id",
+ log.Fields{"device-id": oFsm.deviceID, "error": err})
return err
}
- instID += macBridgePortAniEID
+ logger.Debugw(ctx, "UniVlanConfigFsm create MulticastSubscriberConfigInfo",
+ log.Fields{"device-id": oFsm.deviceID, "EntityId": instID})
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
@@ -2553,7 +2568,9 @@
log.Fields{"device-id": oFsm.deviceID, "portNo": oFsm.pOnuUniPort.portNo})
return err
}
- instID += macBridgePortAniEID
+ instID += macBridgePortAniBaseEID
+ logger.Debugw(ctx, "UniVlanConfigFsm create MulticastOperationProfile",
+ log.Fields{"device-id": oFsm.deviceID, "EntityId": instID})
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
@@ -2602,7 +2619,9 @@
log.Fields{"device-id": oFsm.deviceID, "portNo": oFsm.pOnuUniPort.portNo})
return err
}
- instID += macBridgePortAniEID
+ instID += macBridgePortAniBaseEID
+ logger.Debugw(ctx, "UniVlanConfigFsm set MulticastOperationProfile",
+ log.Fields{"device-id": oFsm.deviceID, "EntityId": instID})
//TODO check that this is correct
// Table control
//setCtrl = 1
diff --git a/internal/pkg/onuadaptercore/onu_metrics_manager.go b/internal/pkg/onuadaptercore/onu_metrics_manager.go
index 8781f91..c9685de 100644
--- a/internal/pkg/onuadaptercore/onu_metrics_manager.go
+++ b/internal/pkg/onuadaptercore/onu_metrics_manager.go
@@ -1315,7 +1315,7 @@
for _, direction := range boolForDirection {
for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
// Attach the EthernetFramePerformanceMonitoringHistoryData ME to MacBridgePortConfigData on the UNI port
- entityID := macBridgePortAniEID + uniPort.entityID
+ entityID := macBridgePortAniBaseEID + uniPort.entityID
_ = mm.updatePmData(ctx, n, entityID, cPmAdd) // TODO: ignore error for now
inner1:
// retry L2PmCreateAttempts times to create the instance of PM