[VOL-3380] Functional area specific logging
Change-Id: I67414da013d8fc82827fcdb69d4f8a34040625d3
diff --git a/VERSION b/VERSION
index 1e4ec5e..38f77a6 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.1-dev
+2.0.1
diff --git a/cmd/openonu-adapter/main.go b/cmd/openonu-adapter/main.go
index ce5dc6f..8a7971b 100644
--- a/cmd/openonu-adapter/main.go
+++ b/cmd/openonu-adapter/main.go
@@ -46,7 +46,7 @@
ic "github.com/opencord/voltha-protos/v5/go/inter_container"
"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
- ac "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/onuadaptercore"
+ ac "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/core"
)
const (
diff --git a/internal/pkg/onuadaptercore/alarm_manager.go b/internal/pkg/almgr/alarm_manager.go
old mode 100644
new mode 100755
similarity index 73%
rename from internal/pkg/onuadaptercore/alarm_manager.go
rename to internal/pkg/almgr/alarm_manager.go
index b9d4d68..91651fe
--- a/internal/pkg/onuadaptercore/alarm_manager.go
+++ b/internal/pkg/almgr/alarm_manager.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package almgr provides the utilities for managing alarm notifications
+package almgr
import (
"context"
@@ -30,6 +30,7 @@
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
@@ -42,18 +43,19 @@
alarmBitMapSizeBytes = 28
)
+// events of alarm sync FSM
const (
- // events of alarm sync FSM
- asEvStart = "asEvStart"
- asEvStop = "asEvStop"
- asEvAudit = "asEvAudit"
- asEvSync = "asEvSync"
- asEvSuccess = "asEvSuccess"
- asEvFailure = "asEvFailure"
- asEvResync = "asEvResync"
+ AsEvStart = "AsEvStart"
+ AsEvStop = "AsEvStop"
+ AsEvAudit = "AsEvAudit"
+ AsEvSync = "AsEvSync"
+ AsEvSuccess = "AsEvSuccess"
+ AsEvFailure = "AsEvFailure"
+ AsEvResync = "AsEvResync"
)
+
+// states of alarm sync FSM
const (
- // states of alarm sync FSM
asStStarting = "asStStarting"
asStDisabled = "asStDisabled"
asStInSync = "asStInSync"
@@ -78,25 +80,6 @@
}
type alarmBitMapDB map[meAlarmKey][alarmBitMapSizeBytes]byte
-type onuAlarmManager struct {
- pDeviceHandler *deviceHandler
- eventProxy eventif.EventProxy
- stopProcessingOmciMessages chan bool
- eventChannel chan Message
- onuAlarmManagerLock sync.RWMutex
- processMessage bool
- activeAlarms alarms
- alarmBitMapDB alarmBitMapDB
- onuEventsList map[onuDevice]onuDeviceEvent
- lastAlarmSequence uint8
- alarmSyncFsm *AdapterFsm
- oltDbCopy alarmBitMapDB
- onuDBCopy alarmBitMapDB
- bufferedNotifications []*omci.AlarmNotificationMsg
- alarmUploadSeqNo uint16
- alarmUploadNoOfCmds uint16
- stopAlarmAuditTimer chan struct{}
-}
type onuDevice struct {
classID me.ClassID
@@ -109,17 +92,43 @@
EventDescription string
}
-func newAlarmManager(ctx context.Context, dh *deviceHandler) *onuAlarmManager {
- var alarmManager onuAlarmManager
- logger.Debugw(ctx, "init-alarm-manager", log.Fields{"device-id": dh.deviceID})
+// OnuAlarmManager holds alarm manager related data
+type OnuAlarmManager struct {
+ deviceID string
+ pDeviceHandler cmn.IdeviceHandler
+ pOnuDeviceEntry cmn.IonuDeviceEntry
+ eventProxy eventif.EventProxy
+ StopProcessingOmciMessages chan bool
+ eventChannel chan cmn.Message
+ onuAlarmManagerLock sync.RWMutex
+ processMessage bool
+ activeAlarms alarms
+ alarmBitMapDB alarmBitMapDB
+ onuEventsList map[onuDevice]onuDeviceEvent
+ lastAlarmSequence uint8
+ AlarmSyncFsm *cmn.AdapterFsm
+ oltDbCopy alarmBitMapDB
+ onuDBCopy alarmBitMapDB
+ bufferedNotifications []*omci.AlarmNotificationMsg
+ alarmUploadSeqNo uint16
+ alarmUploadNoOfCmds uint16
+ StopAlarmAuditTimer chan struct{}
+}
+
+// NewAlarmManager - TODO: add comment
+func NewAlarmManager(ctx context.Context, dh cmn.IdeviceHandler, onuDev cmn.IonuDeviceEntry) *OnuAlarmManager {
+ var alarmManager OnuAlarmManager
+ alarmManager.deviceID = dh.GetDeviceID()
+ logger.Debugw(ctx, "init-alarm-manager", log.Fields{"device-id": alarmManager.deviceID})
alarmManager.pDeviceHandler = dh
- alarmManager.eventProxy = dh.EventProxy // Or event proxy should be on cluster address ??
- alarmManager.eventChannel = make(chan Message)
- alarmManager.stopProcessingOmciMessages = make(chan bool)
+ alarmManager.pOnuDeviceEntry = onuDev
+ alarmManager.eventProxy = dh.GetEventProxy() // Or event proxy should be on cluster address ??
+ alarmManager.eventChannel = make(chan cmn.Message)
+ alarmManager.StopProcessingOmciMessages = make(chan bool)
alarmManager.processMessage = false
alarmManager.activeAlarms = make(map[alarmInfo]struct{})
alarmManager.alarmBitMapDB = make(map[meAlarmKey][alarmBitMapSizeBytes]byte)
- alarmManager.stopAlarmAuditTimer = make(chan struct{})
+ alarmManager.StopAlarmAuditTimer = make(chan struct{})
alarmManager.onuEventsList = map[onuDevice]onuDeviceEvent{
{classID: circuitPackClassID, alarmno: 0}: {EventName: "ONU_EQUIPMENT",
EventCategory: voltha.EventCategory_EQUIPMENT, EventSubCategory: voltha.EventSubCategory_ONU, EventDescription: "onu equipment"},
@@ -158,20 +167,20 @@
{classID: aniGClassID, alarmno: 6}: {EventName: "ONU_LASER_BIAS_CURRENT",
EventCategory: voltha.EventCategory_EQUIPMENT, EventSubCategory: voltha.EventSubCategory_ONU, EventDescription: "onu laser bias current"},
}
- alarmManager.alarmSyncFsm = NewAdapterFsm("AlarmSync", dh.deviceID, alarmManager.eventChannel)
- alarmManager.alarmSyncFsm.pFsm = fsm.NewFSM(
+ alarmManager.AlarmSyncFsm = cmn.NewAdapterFsm("AlarmSync", alarmManager.deviceID, alarmManager.eventChannel)
+ alarmManager.AlarmSyncFsm.PFsm = fsm.NewFSM(
asStDisabled,
fsm.Events{
- {Name: asEvStart, Src: []string{asStDisabled}, Dst: asStStarting},
- {Name: asEvAudit, Src: []string{asStStarting, asStInSync}, Dst: asStAuditing},
- {Name: asEvSync, Src: []string{asStStarting}, Dst: asStInSync},
- {Name: asEvSuccess, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStInSync},
- {Name: asEvFailure, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStAuditing},
- {Name: asEvResync, Src: []string{asStAuditing}, Dst: asStResynchronizing},
- {Name: asEvStop, Src: []string{asStDisabled, asStStarting, asStAuditing, asStInSync, asStIdle, asStResynchronizing}, Dst: asStDisabled},
+ {Name: AsEvStart, Src: []string{asStDisabled}, Dst: asStStarting},
+ {Name: AsEvAudit, Src: []string{asStStarting, asStInSync}, Dst: asStAuditing},
+ {Name: AsEvSync, Src: []string{asStStarting}, Dst: asStInSync},
+ {Name: AsEvSuccess, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStInSync},
+ {Name: AsEvFailure, Src: []string{asStAuditing, asStResynchronizing}, Dst: asStAuditing},
+ {Name: AsEvResync, Src: []string{asStAuditing}, Dst: asStResynchronizing},
+ {Name: AsEvStop, Src: []string{asStDisabled, asStStarting, asStAuditing, asStInSync, asStIdle, asStResynchronizing}, Dst: asStDisabled},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { alarmManager.alarmSyncFsm.logFsmStateChange(ctx, e) },
+ "enter_state": func(e *fsm.Event) { alarmManager.AlarmSyncFsm.LogFsmStateChange(ctx, e) },
"enter_" + asStStarting: func(e *fsm.Event) { alarmManager.asFsmStarting(ctx, e) },
"enter_" + asStAuditing: func(e *fsm.Event) { alarmManager.asFsmAuditing(ctx, e) },
"enter_" + asStInSync: func(e *fsm.Event) { alarmManager.asFsmInSync(ctx, e) },
@@ -181,35 +190,35 @@
return &alarmManager
}
-func (am *onuAlarmManager) asFsmStarting(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "alarm-sync-fsm-start-processing-msgs-in-state", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmStarting(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "alarm-sync-fsm-start-processing-msgs-in-state", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
go am.processAlarmSyncMessages(ctx)
// Start the first audit, if audit interval configured, else reach the sync state
- if am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+ if am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
select {
//Transition into auditing state, using a very shorter timeout delay here, hence it is the first audit
case <-time.After(defaultTimeoutDelay * time.Second):
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
- case <-am.stopAlarmAuditTimer:
- logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ case <-am.StopAlarmAuditTimer:
+ logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.deviceID})
return
}
} else {
// Transition into sync state directly.
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvSync); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvSync); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
}
}
-func (am *onuAlarmManager) asFsmAuditing(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "alarm-sync-fsm-start-auditing", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmAuditing(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "alarm-sync-fsm-start-auditing", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
// Always reset the buffered notifications and db copies before starting the audit
am.onuAlarmManagerLock.Lock()
am.bufferedNotifications = make([]*omci.AlarmNotificationMsg, 0)
@@ -217,22 +226,22 @@
am.onuDBCopy = make(map[meAlarmKey][alarmBitMapSizeBytes]byte)
am.onuAlarmManagerLock.Unlock()
failureTransition := func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
}
}
- if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarm(log.WithSpanFromContext(context.TODO(), ctx), 0,
- am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+ if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarm(log.WithSpanFromContext(context.TODO(), ctx), 0,
+ am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
// Transition to failure so that alarm sync can be restarted again
go failureTransition()
}
}
-func (am *onuAlarmManager) asFsmResynchronizing(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) asFsmResynchronizing(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
failureTransition := func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
}
}
// See if there is any onu only diff, meaning the class and entity is only in onu DB
@@ -250,7 +259,7 @@
AlarmBitmap: am.onuDBCopy[alarm],
}
if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
- logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
// Transition to failure.
go failureTransition()
return
@@ -272,7 +281,7 @@
AlarmBitmap: am.oltDbCopy[alarm],
}
if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
- logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
// Transition to failure
go failureTransition()
return
@@ -292,7 +301,7 @@
}
// We will assume that onudb is correct always in this case and process the changed bitmap.
if err := am.processAlarmData(ctx, omciAlarmMessage); err != nil {
- logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
// Transition to failure
go failureTransition()
return
@@ -302,57 +311,57 @@
}
// Send the buffered notifications if no failure.
for _, notif := range am.bufferedNotifications {
- logger.Debugw(ctx, "processing-buffered-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+ logger.Debugw(ctx, "processing-buffered-alarm-notification", log.Fields{"device-id": am.deviceID,
"notification": notif})
if err := am.processAlarmData(ctx, notif); err != nil {
- logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
go failureTransition()
}
}
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
}
-func (am *onuAlarmManager) asFsmInSync(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.pDeviceHandler.deviceID})
- if am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+func (am *OnuAlarmManager) asFsmInSync(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "alarm-sync-fsm", log.Fields{"state": e.FSM.Current(), "device-id": am.deviceID})
+ if am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
select {
- case <-time.After(am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval):
+ case <-time.After(am.pDeviceHandler.GetAlarmAuditInterval()):
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
- case <-am.stopAlarmAuditTimer:
- logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ case <-am.StopAlarmAuditTimer:
+ logger.Infow(ctx, "stopping-alarm-timer", log.Fields{"device-id": am.deviceID})
return
}
}
}
-func (am *onuAlarmManager) processAlarmSyncMessages(ctx context.Context) {
- logger.Debugw(ctx, "start-routine-to-process-omci-messages-for-alarm-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+func (am *OnuAlarmManager) processAlarmSyncMessages(ctx context.Context) {
+ logger.Debugw(ctx, "start-routine-to-process-omci-messages-for-alarm-sync", log.Fields{"device-id": am.deviceID})
for {
select {
case message, ok := <-am.eventChannel:
if !ok {
- logger.Info(ctx, "alarm-sync-omci-message-could-not-be-read-from-channel", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Info(ctx, "alarm-sync-omci-message-could-not-be-read-from-channel", log.Fields{"device-id": am.deviceID})
continue
}
- logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.deviceID})
switch message.Type {
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
am.handleOmciMessage(ctx, msg)
default:
- logger.Warn(ctx, "alarm-sync-unknown-message-type-received", log.Fields{"device-id": am.pDeviceHandler.deviceID, "message.Type": message.Type})
+ logger.Warn(ctx, "alarm-sync-unknown-message-type-received", log.Fields{"device-id": am.deviceID, "message.Type": message.Type})
}
- case <-am.stopProcessingOmciMessages:
- logger.Infow(ctx, "alarm-manager-stop-omci-alarm-message-processing-routines", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ case <-am.StopProcessingOmciMessages:
+ logger.Infow(ctx, "alarm-manager-stop-omci-alarm-message-processing-routines", log.Fields{"device-id": am.deviceID})
am.onuAlarmManagerLock.Lock()
am.processMessage = false
am.activeAlarms = nil
@@ -366,8 +375,8 @@
}
}
-func (am *onuAlarmManager) handleOmciMessage(ctx context.Context, msg OmciMessage) {
- logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+func (am *OnuAlarmManager) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
+ logger.Debugw(ctx, "alarm-sync-omci-message-received", log.Fields{"device-id": am.deviceID,
"msg-type": msg.OmciMsg.MessageType, "msg": msg})
switch msg.OmciMsg.MessageType {
case omci.GetAllAlarmsResponseType:
@@ -380,28 +389,28 @@
}
}
-func (am *onuAlarmManager) handleOmciGetAllAlarmsResponseMessage(ctx context.Context, msg OmciMessage) {
+func (am *OnuAlarmManager) handleOmciGetAllAlarmsResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetAllAlarmsResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.GetAllAlarmsResponse)
if !msgOk {
- logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.deviceID})
return
}
- logger.Debugw(ctx, "get-all-alarm-response-data", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
- if am.alarmSyncFsm.pFsm.Is(asStDisabled) {
- logger.Debugw(ctx, "alarm-sync-fsm-is-disabled-ignoring-response-message", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "get-all-alarm-response-data", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
+ if am.AlarmSyncFsm.PFsm.Is(asStDisabled) {
+ logger.Debugw(ctx, "alarm-sync-fsm-is-disabled-ignoring-response-message", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
return
}
am.onuAlarmManagerLock.Lock()
am.alarmUploadNoOfCmds = msgObj.NumberOfCommands
am.onuAlarmManagerLock.Unlock()
failureTransition := func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
}
}
am.onuAlarmManagerLock.Lock()
@@ -413,8 +422,8 @@
am.oltDbCopy[alarms] = bitmap
}
am.onuAlarmManagerLock.Unlock()
- if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarmNext(
- log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+ if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarmNext(
+ log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
// Transition to failure
go failureTransition()
}
@@ -429,40 +438,40 @@
if am.isAlarmDBDiffPresent(ctx) {
// transition to resync state
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvResync); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvResync); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
} else {
// Transition to sync state
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
}
} else {
- logger.Errorw(ctx, "invalid-number-of-commands-received", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+ logger.Errorw(ctx, "invalid-number-of-commands-received", log.Fields{"device-id": am.deviceID,
"upload-no-of-cmds": am.alarmUploadNoOfCmds, "upload-seq-no": am.alarmUploadSeqNo})
am.onuAlarmManagerLock.Unlock()
go failureTransition()
}
}
-func (am *onuAlarmManager) handleOmciGetAllAlarmNextResponseMessage(ctx context.Context, msg OmciMessage) {
+func (am *OnuAlarmManager) handleOmciGetAllAlarmNextResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetAllAlarmsNextResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected", log.Fields{"device-id": am.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.GetAllAlarmsNextResponse)
if !msgOk {
- logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned", log.Fields{"device-id": am.deviceID})
return
}
logger.Debugw(ctx, "get-all-alarms-next-response-data",
- log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+ log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
meClassID := msgObj.AlarmEntityClass
meEntityID := msgObj.AlarmEntityInstance
meAlarmBitMap := msgObj.AlarmBitMap
@@ -474,15 +483,15 @@
}] = meAlarmBitMap
am.onuAlarmManagerLock.Unlock()
failureTransition := func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvFailure); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvFailure); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-failure", log.Fields{"device-id": am.deviceID, "err": err})
}
}
am.onuAlarmManagerLock.RLock()
if am.alarmUploadSeqNo < am.alarmUploadNoOfCmds {
am.onuAlarmManagerLock.RUnlock()
- if err := am.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetAllAlarmNext(
- log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.pOpenOnuAc.omciTimeout, true); err != nil {
+ if err := am.pOnuDeviceEntry.GetDevOmciCC().SendGetAllAlarmNext(
+ log.WithSpanFromContext(context.TODO(), ctx), am.pDeviceHandler.GetOmciTimeout(), true); err != nil {
// Transition to failure
go failureTransition()
} //TODO: needs to handle timeouts
@@ -491,23 +500,24 @@
if am.isAlarmDBDiffPresent(ctx) {
// transition to resync state
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvResync); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvResync); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-resynchronizing", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
} else {
// Transition to sync state
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvSuccess); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvSuccess); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-sync", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
}
}
}
-func (am *onuAlarmManager) startOMCIAlarmMessageProcessing(ctx context.Context) {
- logger.Infow(ctx, "alarm-manager-start-omci-alarm-message-processing-routines", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+// StartOMCIAlarmMessageProcessing - TODO: add comment: add comment
+func (am *OnuAlarmManager) StartOMCIAlarmMessageProcessing(ctx context.Context) {
+ logger.Infow(ctx, "alarm-manager-start-omci-alarm-message-processing-routines", log.Fields{"device-id": am.deviceID})
am.onuAlarmManagerLock.Lock()
am.processMessage = true
if am.activeAlarms == nil {
@@ -517,45 +527,46 @@
am.onuAlarmManagerLock.Unlock()
am.flushAlarmSyncChannels(ctx) // Need to do this first as there might be stale data on the channels and the start state waits on same channels
- if am.alarmSyncFsm.pFsm.Is(asStDisabled) {
- if err := am.alarmSyncFsm.pFsm.Event(asEvStart); err != nil {
- logger.Errorw(ctx, "alarm-sync-fsm-can-not-go-to-state-starting", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if am.AlarmSyncFsm.PFsm.Is(asStDisabled) {
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvStart); err != nil {
+ logger.Errorw(ctx, "alarm-sync-fsm-can-not-go-to-state-starting", log.Fields{"device-id": am.deviceID, "err": err})
return
}
} else {
- logger.Errorw(ctx, "wrong-state-of-alarm-sync-fsm-want-disabled", log.Fields{"state": string(am.alarmSyncFsm.pFsm.Current()),
- "device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "wrong-state-of-alarm-sync-fsm-want-disabled", log.Fields{"state": string(am.AlarmSyncFsm.PFsm.Current()),
+ "device-id": am.deviceID})
return
}
- logger.Debugw(ctx, "alarm-sync-fsm-started", log.Fields{"state": string(am.alarmSyncFsm.pFsm.Current())})
+ logger.Debugw(ctx, "alarm-sync-fsm-started", log.Fields{"state": string(am.AlarmSyncFsm.PFsm.Current())})
}
-func (am *onuAlarmManager) handleOmciAlarmNotificationMessage(ctx context.Context, msg OmciMessage) {
- logger.Debugw(ctx, "omci-alarm-notification-msg", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+// HandleOmciAlarmNotificationMessage - TODO: add comment
+func (am *OnuAlarmManager) HandleOmciAlarmNotificationMessage(ctx context.Context, msg cmn.OmciMessage) {
+ logger.Debugw(ctx, "omci-alarm-notification-msg", log.Fields{"device-id": am.deviceID,
"msg-type": msg.OmciMsg.MessageType})
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeAlarmNotification)
if msgLayer == nil {
logger.Errorw(ctx, "omci-msg-layer-could-not-be-detected-for-alarm-notification",
- log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ log.Fields{"device-id": am.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.AlarmNotificationMsg)
if !msgOk {
logger.Errorw(ctx, "omci-msg-layer-could-not-be-assigned-for-alarm-notification",
- log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ log.Fields{"device-id": am.deviceID})
return
}
//Alarm Notification decoding at omci lib validates that the me class ID supports the
// alarm notifications.
- logger.Debugw(ctx, "alarm-notification-data-received", log.Fields{"device-id": am.pDeviceHandler.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "alarm-notification-data-received", log.Fields{"device-id": am.deviceID, "data-fields": msgObj})
if err := am.processAlarmData(ctx, msgObj); err != nil {
- logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-process-alarm-notification", log.Fields{"device-id": am.deviceID})
}
}
-func (am *onuAlarmManager) processAlarmData(ctx context.Context, msg *omci.AlarmNotificationMsg) error {
+func (am *OnuAlarmManager) processAlarmData(ctx context.Context, msg *omci.AlarmNotificationMsg) error {
classID := msg.EntityClass
sequenceNo := msg.AlarmSequenceNumber
meInstance := msg.EntityInstance
@@ -566,26 +577,26 @@
defer am.onuAlarmManagerLock.Unlock()
if !am.processMessage {
logger.Warnw(ctx, "ignoring-alarm-notification-received-for-me-as-channel-for-processing-is-closed",
- log.Fields{"device-id": am.pDeviceHandler.deviceID})
+ log.Fields{"device-id": am.deviceID})
return fmt.Errorf("alarm-manager-is-in-stopped-state")
}
- if _, present := am.pDeviceHandler.pOnuOmciDevice.pOnuDB.meDb[classID][meInstance]; !present {
+ if _, present := am.pOnuDeviceEntry.GetOnuDB().MeDb[classID][meInstance]; !present {
logger.Errorw(ctx, "me-class-instance-not-present", log.Fields{"class-id": classID, "instance-id": meInstance})
return fmt.Errorf("me-class-%d-instance-%d-not-present", classID, meInstance)
}
if sequenceNo > 0 {
- if am.alarmSyncFsm.pFsm.Is(asStAuditing) || am.alarmSyncFsm.pFsm.Is(asStResynchronizing) {
+ if am.AlarmSyncFsm.PFsm.Is(asStAuditing) || am.AlarmSyncFsm.PFsm.Is(asStResynchronizing) {
am.bufferedNotifications = append(am.bufferedNotifications, msg)
- logger.Debugw(ctx, "adding-notification-to-buffered-notification-list", log.Fields{"device-id": am.pDeviceHandler.deviceID,
+ logger.Debugw(ctx, "adding-notification-to-buffered-notification-list", log.Fields{"device-id": am.deviceID,
"notification": msg})
return nil
}
am.incrementAlarmSequence()
- if sequenceNo != am.lastAlarmSequence && am.pDeviceHandler.pOnuOmciDevice.alarmAuditInterval > 0 {
+ if sequenceNo != am.lastAlarmSequence && am.pDeviceHandler.GetAlarmAuditInterval() > 0 {
// signal early audit, if no match(if we are reaching here it means that audit is not going on currently)
go func() {
- if err := am.alarmSyncFsm.pFsm.Event(asEvAudit); err != nil {
- logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.pDeviceHandler.deviceID, "err": err})
+ if err := am.AlarmSyncFsm.PFsm.Event(AsEvAudit); err != nil {
+ logger.Debugw(ctx, "alarm-sync-fsm-cannot-go-to-state-auditing", log.Fields{"device-id": am.deviceID, "err": err})
}
}()
}
@@ -644,7 +655,7 @@
return nil
}
-func (am *onuAlarmManager) raiseAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
+func (am *OnuAlarmManager) raiseAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
am.activeAlarms[alarmInfo{
classID: classID,
instanceID: instanceID,
@@ -654,7 +665,7 @@
go am.sendAlarm(ctx, classID, instanceID, alarm, true)
}
-func (am *onuAlarmManager) clearAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
+func (am *OnuAlarmManager) clearAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8) {
go am.sendAlarm(ctx, classID, instanceID, alarm, false)
delete(am.activeAlarms, alarmInfo{
classID: classID,
@@ -670,17 +681,17 @@
}
}
-func (am *onuAlarmManager) getIntfIDAlarm(ctx context.Context, classID me.ClassID, instanceID uint16) *uint32 {
+func (am *OnuAlarmManager) getIntfIDAlarm(ctx context.Context, classID me.ClassID, instanceID uint16) *uint32 {
var intfID *uint32
if classID == circuitPackClassID || classID == physicalPathTerminationPointEthernetUniClassID {
- for _, uniPort := range am.pDeviceHandler.uniEntityMap {
- if uniPort.entityID == instanceID {
- intfID = &uniPort.portNo
+ for _, uniPort := range *am.pDeviceHandler.GetUniEntityMap() {
+ if uniPort.EntityID == instanceID {
+ intfID = &uniPort.PortNo
return intfID
}
}
} else if classID == aniGClassID || classID == onuGClassID {
- intfID = &am.pDeviceHandler.ponPortNumber
+ intfID = am.pDeviceHandler.GetPonPortNumber()
return intfID
} else {
logger.Warnw(ctx, "me-not-supported", log.Fields{"class-id": classID, "instance-id": instanceID})
@@ -688,13 +699,11 @@
return nil
}
-func (am *onuAlarmManager) sendAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8, raised bool) {
+func (am *OnuAlarmManager) sendAlarm(ctx context.Context, classID me.ClassID, instanceID uint16, alarm uint8, raised bool) {
context := make(map[string]string)
intfID := am.getIntfIDAlarm(ctx, classID, instanceID)
- onuID := am.pDeviceHandler.deviceID
- am.pDeviceHandler.pOnuOmciDevice.mutexPersOnuConfig.RLock()
- serialNo := am.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersSerialNumber
- am.pDeviceHandler.pOnuOmciDevice.mutexPersOnuConfig.RUnlock()
+ onuID := am.deviceID
+ serialNo := am.pOnuDeviceEntry.GetPersSerialNumber()
if intfID == nil {
logger.Warn(ctx, "intf-id-for-alarm-not-found", log.Fields{"alarm-no": alarm, "class-id": classID})
return
@@ -724,11 +733,11 @@
raisedTimestamp)
}
-func (am *onuAlarmManager) isAlarmDBDiffPresent(ctx context.Context) bool {
+func (am *OnuAlarmManager) isAlarmDBDiffPresent(ctx context.Context) bool {
return !reflect.DeepEqual(am.onuDBCopy, am.oltDbCopy)
}
-func (am *onuAlarmManager) incrementAlarmSequence() {
+func (am *OnuAlarmManager) incrementAlarmSequence() {
//alarm sequence number wraps from 255 to 1.
if am.lastAlarmSequence == 255 {
am.lastAlarmSequence = 1
@@ -737,12 +746,12 @@
}
}
-func (am *onuAlarmManager) resetAlarmSequence() {
+func (am *OnuAlarmManager) resetAlarmSequence() {
am.lastAlarmSequence = 0
}
// flushAlarmSyncChannels flushes all alarm sync channels to discard any previous response
-func (am *onuAlarmManager) flushAlarmSyncChannels(ctx context.Context) {
+func (am *OnuAlarmManager) flushAlarmSyncChannels(ctx context.Context) {
// flush alarm sync channel
select {
case <-am.eventChannel:
@@ -750,14 +759,14 @@
default:
}
select {
- case <-am.stopAlarmAuditTimer:
+ case <-am.StopAlarmAuditTimer:
logger.Debug(ctx, "flushed-alarm-audit-timer-channel")
default:
}
}
// getDeviceEventData returns the event data for a device
-func (am *onuAlarmManager) getDeviceEventData(ctx context.Context, classID me.ClassID, alarmNo uint8) (onuDeviceEvent, error) {
+func (am *OnuAlarmManager) getDeviceEventData(ctx context.Context, classID me.ClassID, alarmNo uint8) (onuDeviceEvent, error) {
if onuEventDetails, ok := am.onuEventsList[onuDevice{classID: classID, alarmno: alarmNo}]; ok {
return onuEventDetails, nil
}
@@ -765,7 +774,7 @@
}
//ResetAlarmUploadCounters resets alarm upload sequence number and number of commands
-func (am *onuAlarmManager) ResetAlarmUploadCounters() {
+func (am *OnuAlarmManager) ResetAlarmUploadCounters() {
am.onuAlarmManagerLock.Lock()
am.alarmUploadSeqNo = 0
am.alarmUploadNoOfCmds = 0
@@ -773,16 +782,21 @@
}
//IncrementAlarmUploadSeqNo increments alarm upload sequence number
-func (am *onuAlarmManager) IncrementAlarmUploadSeqNo() {
+func (am *OnuAlarmManager) IncrementAlarmUploadSeqNo() {
am.onuAlarmManagerLock.Lock()
am.alarmUploadSeqNo++
am.onuAlarmManagerLock.Unlock()
}
//GetAlarmUploadSeqNo gets alarm upload sequence number
-func (am *onuAlarmManager) GetAlarmUploadSeqNo() uint16 {
+func (am *OnuAlarmManager) GetAlarmUploadSeqNo() uint16 {
am.onuAlarmManagerLock.RLock()
value := am.alarmUploadSeqNo
am.onuAlarmManagerLock.RUnlock()
return value
}
+
+//GetAlarmMgrEventChannel gets alarm manager event channel
+func (am *OnuAlarmManager) GetAlarmMgrEventChannel() chan cmn.Message {
+ return am.eventChannel
+}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/almgr/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/almgr/common.go
index b0b10e3..541bff6
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/almgr/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package almgr provides the utilities for managing alarm notifications
+package almgr
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "almgr"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/avcfg/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/avcfg/common.go
index b0b10e3..8e02fe0
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/avcfg/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "avcfg"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/avcfg/omci_ani_config.go
old mode 100644
new mode 100755
similarity index 74%
rename from internal/pkg/onuadaptercore/omci_ani_config.go
rename to internal/pkg/avcfg/omci_ani_config.go
index a236950..6ade746
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/avcfg/omci_ani_config.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
import (
"context"
@@ -31,9 +31,12 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+
//ic "github.com/opencord/voltha-protos/v5/go/inter_container"
//"github.com/opencord/voltha-protos/v5/go/openflow_13"
//"github.com/opencord/voltha-protos/v5/go/voltha"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
)
const (
@@ -86,12 +89,14 @@
aniStRemoveDone = "aniStRemoveDone"
aniStResetting = "aniStResetting"
)
-const cAniFsmIdleState = aniStConfigDone
const (
bitTrafficSchedulerPtrSetPermitted = 0x0002 // Refer section 9.1.2 ONU-2G, table for "Quality of service (QoS) configuration flexibility" IE
)
+// CAniFsmIdleState - TODO: add comment
+const CAniFsmIdleState = aniStConfigDone
+
type ponAniGemPortAttribs struct {
gemPortID uint16
upQueueID uint16
@@ -106,22 +111,23 @@
dynamicACL string
}
-//uniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
-type uniPonAniConfigFsm struct {
- pDeviceHandler *deviceHandler
+//UniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
+type UniPonAniConfigFsm struct {
deviceID string
- pOmciCC *omciCC
- pOnuUniPort *onuUniPort
- pUniTechProf *onuUniTechProf
- pOnuDB *onuDeviceDB
+ pDeviceHandler cmn.IdeviceHandler
+ pOnuDeviceEntry cmn.IonuDeviceEntry
+ pOmciCC *cmn.OmciCC
+ pOnuUniPort *cmn.OnuUniPort
+ pUniTechProf *OnuUniTechProf
+ pOnuDB *devdb.OnuDeviceDB
techProfileID uint8
uniTpKey uniTP
- requestEvent OnuDeviceEvent
+ requestEvent cmn.OnuDeviceEvent
mutexIsAwaitingResponse sync.RWMutex
isCanceled bool
isAwaitingResponse bool
omciMIdsResponseReceived chan bool //separate channel needed for checking multiInstance OMCI message responses
- pAdaptFsm *AdapterFsm
+ PAdaptFsm *cmn.AdapterFsm
chSuccess chan<- uint8
procStep uint8
mutexChanSet sync.RWMutex
@@ -139,33 +145,34 @@
tcontSetBefore bool
}
-//newUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
-func newUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *omciCC, apUniPort *onuUniPort, apUniTechProf *onuUniTechProf,
- apOnuDB *onuDeviceDB, aTechProfileID uint8, aRequestEvent OnuDeviceEvent, aName string,
- apDeviceHandler *deviceHandler, aCommChannel chan Message) *uniPonAniConfigFsm {
- instFsm := &uniPonAniConfigFsm{
- pDeviceHandler: apDeviceHandler,
- deviceID: apDeviceHandler.deviceID,
- pOmciCC: apDevOmciCC,
- pOnuUniPort: apUniPort,
- pUniTechProf: apUniTechProf,
- pOnuDB: apOnuDB,
- techProfileID: aTechProfileID,
- requestEvent: aRequestEvent,
- chanSet: false,
- tcontSetBefore: false,
+//NewUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
+func NewUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort, apUniTechProf *OnuUniTechProf,
+ apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8, aRequestEvent cmn.OnuDeviceEvent, aName string,
+ apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, aCommChannel chan cmn.Message) *UniPonAniConfigFsm {
+ instFsm := &UniPonAniConfigFsm{
+ pDeviceHandler: apDeviceHandler,
+ pOnuDeviceEntry: apOnuDeviceEntry,
+ deviceID: apDeviceHandler.GetDeviceID(),
+ pOmciCC: apDevOmciCC,
+ pOnuUniPort: apUniPort,
+ pUniTechProf: apUniTechProf,
+ pOnuDB: apOnuDB,
+ techProfileID: aTechProfileID,
+ requestEvent: aRequestEvent,
+ chanSet: false,
+ tcontSetBefore: false,
}
- instFsm.uniTpKey = uniTP{uniID: apUniPort.uniID, tpID: aTechProfileID}
+ instFsm.uniTpKey = uniTP{uniID: apUniPort.UniID, tpID: aTechProfileID}
instFsm.waitFlowDeleteChannel = make(chan bool)
- instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
- if instFsm.pAdaptFsm == nil {
- logger.Errorw(ctx, "uniPonAniConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+ if instFsm.PAdaptFsm == nil {
+ logger.Errorw(ctx, "UniPonAniConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
+ instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
aniStDisabled,
fsm.Events{
@@ -216,7 +223,7 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+ "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
("enter_" + aniStStarting): func(e *fsm.Event) { instFsm.enterConfigStartingState(ctx, e) },
("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(ctx, e) },
("enter_" + aniStCreatingMBPCD): func(e *fsm.Event) { instFsm.enterCreatingMBPCD(ctx, e) },
@@ -238,27 +245,27 @@
("enter_" + aniStDisabled): func(e *fsm.Event) { instFsm.enterDisabledState(ctx, e) },
},
)
- if instFsm.pAdaptFsm.pFsm == nil {
- logger.Errorw(ctx, "uniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
+ if instFsm.PAdaptFsm.PFsm == nil {
+ logger.Errorw(ctx, "UniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- logger.Debugw(ctx, "uniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
return instFsm
}
//setFsmCompleteChannel sets the requested channel and channel result for transfer on success
-func (oFsm *uniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) {
+func (oFsm *UniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) {
oFsm.chSuccess = aChSuccess
oFsm.procStep = aProcStep
oFsm.setChanSet(true)
}
//CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM
-func (oFsm *uniPonAniConfigFsm) CancelProcessing(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) CancelProcessing(ctx context.Context) {
//early indication about started reset processing
- oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true)
+ oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true)
//mutex protection is required for possible concurrent access to FSM members
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isCanceled = true
@@ -282,14 +289,14 @@
}
// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
- pAdaptFsm := oFsm.pAdaptFsm
- if pAdaptFsm != nil {
+ PAdaptFsm := oFsm.PAdaptFsm
+ if PAdaptFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm.pFsm != nil {
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm.PFsm != nil {
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
}
- }(pAdaptFsm)
+ }(PAdaptFsm)
}
// possible access conflicts on internal data by next needed data clearance
@@ -298,21 +305,21 @@
// as it may result in deadlock situations (as observed at soft-reboot handling where
// TpProcMutex is already locked by some ongoing TechProfile config/removal processing
//remove all TechProf related internal data to allow for new configuration
- oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID)
+ 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 {
+func (oFsm *UniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
var err error
- oFsm.mapperSP0ID, err = generateIeeMaperServiceProfileEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.techProfileID))
+ oFsm.mapperSP0ID, err = cmn.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))
+ oFsm.macBPCD0ID, err = cmn.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})
@@ -320,17 +327,16 @@
}
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})
- pDevEntry := oFsm.pDeviceHandler.getOnuDeviceEntry(ctx, false)
- if pDevEntry == nil {
+ "macBpNo": oFsm.pOnuUniPort.MacBpNo, "techProfileID": oFsm.techProfileID})
+ if oFsm.pOnuDeviceEntry == nil {
logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": oFsm.deviceID})
return
}
- tcontInstID, tcontAlreadyExist, err := pDevEntry.allocateFreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
+ tcontInstID, tcontAlreadyExist, err := oFsm.pOnuDeviceEntry.AllocateFreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
if err != nil {
logger.Errorw(ctx, "No TCont instances found", log.Fields{"device-id": oFsm.deviceID, "err": err})
//reset the state machine to enable usage on subsequent requests
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ _ = aPAFsm.PFsm.Event(aniEvReset)
return
}
oFsm.tcont0ID = tcontInstID
@@ -352,7 +358,7 @@
//collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig)
- if queueInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 {
+ if queueInstKeys := oFsm.pOnuDB.GetSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 {
loGemPortAttribs.gemPortID = gemEntry.gemPortID
// MibDb usage: upstream PrioQueue.RelatedPort = xxxxyyyy with xxxx=TCont.Entity(incl. slot) and yyyy=prio
@@ -361,11 +367,11 @@
usQrelPortMask := uint32((((uint32)(oFsm.tcont0ID)) << 16) + uint32(gemEntry.prioQueueIndex))
// MibDb usage: downstream PrioQueue.RelatedPort = xxyyzzzz with xx=slot, yy=UniPort and zzzz=prio
- // i.e.: search PrioQueue list with yy=actual pOnuUniPort.uniID,
+ // i.e.: search PrioQueue list with yy=actual pOnuUniPort.UniID,
// from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == zzzz (expect 0..7)
// Note: As we do not maintain any slot numbering, slot number will be excluded from seatch pattern.
// Furthermore OMCI Onu port-Id is expected to start with 1 (not 0).
- dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.uniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex))
+ dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.UniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex))
usQueueFound := false
dsQueueFound := false
@@ -373,7 +379,7 @@
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, err := oFsm.pOnuDB.GetUint32Attrib(returnVal); err == nil {
if relatedPort == usQrelPortMask {
loGemPortAttribs.upQueueID = mgmtEntityID
logger.Debugw(ctx, "UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
@@ -437,22 +443,22 @@
oFsm.gemPortAttribsSlice = append(oFsm.gemPortAttribsSlice, loGemPortAttribs)
}
- if !oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
- _ = aPAFsm.pFsm.Event(aniEvStartConfig)
+ if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
+ _ = aPAFsm.PFsm.Event(aniEvStartConfig)
} else {
logger.Debugw(ctx, "reconciling - skip omci-config of ANI side ", log.Fields{"device-id": oFsm.deviceID})
- _ = aPAFsm.pFsm.Event(aniEvSkipOmciConfig)
+ _ = aPAFsm.PFsm.Event(aniEvSkipOmciConfig)
}
}
}
-func (oFsm *uniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "UniPonAniConfigFsm start", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
// in case the used channel is not yet defined (can be re-used after restarts)
if oFsm.omciMIdsResponseReceived == nil {
oFsm.omciMIdsResponseReceived = make(chan bool)
- logger.Debug(ctx, "uniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
+ logger.Debug(ctx, "UniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
} else {
// as we may 're-use' this instance of FSM and the connected channel
// make sure there is no 'lingering' request in the already existing channel:
@@ -472,7 +478,7 @@
go oFsm.processOmciAniMessages(ctx)
//let the state machine run forward from here directly
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
go oFsm.prepareAndEnterConfigState(ctx, pConfigAniStateAFsm)
@@ -480,24 +486,24 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
oFsm.requestEventOffset = 0 //0 offset for last config request activity
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.mapperSP0ID, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.mapperSP0ID, oFsm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "Dot1PMapper create failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "Dot1PMapper create failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -510,12 +516,12 @@
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16),
"TPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- bridgePtr := macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
+ bridgePtr := cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile
meParams := me.ParamData{
EntityID: oFsm.macBPCD0ID,
Attributes: me.AttributeValueMap{
@@ -526,18 +532,18 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
- logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -550,19 +556,19 @@
}
-func (oFsm *uniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::Tcont", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::Tcont", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
"AllocId": strconv.FormatInt(int64(oFsm.alloc0ID), 16),
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"tcontExist": oFsm.tcontSetBefore})
//If tcont was set before, then no need to set it again. Let state machine to proceed.
if oFsm.tcontSetBefore {
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvRxTcontsResp)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvRxTcontsResp)
}
- }(oFsm.pAdaptFsm)
+ }(oFsm.PAdaptFsm)
return
}
meParams := me.ParamData{
@@ -572,18 +578,18 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
- logger.Errorw(ctx, "TcontVar set failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -596,31 +602,31 @@
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
go oFsm.performCreatingGemNCTPs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
go oFsm.performCreatingGemIWs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
+func (oFsm *UniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
go oFsm.performSettingPQs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
"toGemIw": 1024, /* cmp above */
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
@@ -633,13 +639,13 @@
var loPrioGemPortArray [8]uint16
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.isMulticast {
- logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
}
if gemPortAttribs.pbitString == "" {
- logger.Warnw(ctx, "uniPonAniConfigFsm PrioString empty string error", log.Fields{
+ logger.Warnw(ctx, "UniPonAniConfigFsm PrioString empty string error", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
@@ -651,13 +657,13 @@
if loPrioGemPortArray[i] == 0 {
loPrioGemPortArray[i] = gemPortAttribs.gemPortID //gemPortId=EntityID and unique
} else {
- logger.Warnw(ctx, "uniPonAniConfigFsm PrioString not unique", log.Fields{
+ logger.Warnw(ctx, "UniPonAniConfigFsm PrioString not unique", log.Fields{
"device-id": oFsm.deviceID, "IgnoredGemPort": gemPortAttribs.gemPortID,
"SetGemPort": loPrioGemPortArray[i]})
}
}
} else {
- logger.Warnw(ctx, "uniPonAniConfigFsm PrioString evaluation error", log.Fields{
+ logger.Warnw(ctx, "UniPonAniConfigFsm PrioString evaluation error", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString, "position": i})
}
@@ -693,39 +699,39 @@
//TODO With multicast is possible that no upstream gem ports are not present in the tech profile,
// this reset needs to be performed only if the tech profile provides upstream gem ports but no priority is set
//let's reset the state machine in order to release all resources now
- //pConfigAniStateAFsm := oFsm.pAdaptFsm
+ //pConfigAniStateAFsm := oFsm.PAdaptFsm
//if pConfigAniStateAFsm != nil {
// // obviously calling some FSM event here directly does not work - so trying to decouple it ...
- // go func(aPAFsm *AdapterFsm) {
- // if aPAFsm != nil && aPAFsm.pFsm != nil {
- // _ = aPAFsm.pFsm.Event(aniEvReset)
+ // go func(aPAFsm *cmn.AdapterFsm) {
+ // if aPAFsm != nil && aPAFsm.PFsm != nil {
+ // _ = aPAFsm.PFsm.Event(aniEvReset)
// }
// }(pConfigAniStateAFsm)
//}
//Moving forward the FSM as if the response was received correctly.
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvRxDot1pmapSResp)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvRxDot1pmapSResp)
}
}(pConfigAniStateAFsm)
}
} else {
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetDot1PMapperVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetDot1PMapperVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
- logger.Errorw(ctx, "Dot1PMapperVar set failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "Dot1PMapperVar set failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -738,25 +744,25 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm ani config done", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+func (oFsm *UniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm ani config done", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
//store that the UNI related techProfile processing is done for the given Profile and Uni
- oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true)
- if !oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true)
+ if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
//use DeviceHandler event notification directly
- oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+ oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
//if techProfile processing is done it must be checked, if some prior/parallel flow configuration is pending
// but only in case the techProfile was configured (not deleted)
if oFsm.requestEventOffset == 0 {
- go oFsm.pDeviceHandler.verifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID)
+ go oFsm.pDeviceHandler.VerifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID)
}
} else {
logger.Debugw(ctx, "reconciling - skip AniConfigDone processing", log.Fields{"device-id": oFsm.deviceID})
}
if oFsm.isChanSet() {
// indicate processing done to the caller
- logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{
"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.chSuccess <- oFsm.procStep
oFsm.setChanSet(false) //reset the internal channel state
@@ -765,7 +771,7 @@
//the FSM is left active in this state as long as no specific reset or remove is requested from outside
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) {
// no need to protect access to oFsm.waitFlowDeleteChannel, only used in synchronized state entries
// or CancelProcessing() that uses separate isWaitingForFlowDelete to write to the channel
//flush the waitFlowDeleteChannel - possibly already/still set by some previous activity
@@ -775,22 +781,23 @@
default:
}
- if oFsm.pDeviceHandler.UniVlanConfigFsmMap[oFsm.pOnuUniPort.uniID] != nil {
+ uniVlanConfigFsm := oFsm.pDeviceHandler.GetUniVlanConfigFsm(oFsm.pOnuUniPort.UniID)
+ if uniVlanConfigFsm != nil {
// ensure mutexTPState not locked before calling some VlanConfigFsm activity (that might already be pending on it)
- if oFsm.pDeviceHandler.UniVlanConfigFsmMap[oFsm.pOnuUniPort.uniID].IsFlowRemovePending(oFsm.waitFlowDeleteChannel) {
+ if uniVlanConfigFsm.IsFlowRemovePending(oFsm.waitFlowDeleteChannel) {
logger.Debugw(ctx, "flow remove pending - wait before processing gem port delete",
- log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
// if flow remove is pending then wait for flow remove to finish first before proceeding with gem port delete
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvWaitFlowRem)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvWaitFlowRem)
}
}(pConfigAniStateAFsm)
} else {
- logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
}
return
}
@@ -803,25 +810,25 @@
// get the related GemPort entity Id from pUniTechProf, OMCI Gem* entityID is set to be equal to GemPortId!
loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
oFsm.pUniTechProf.mutexTPState.RUnlock()
- logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"GemIwTp-entity-id": loGemPortID})
oFsm.requestEventOffset = 1 //offset 1 to indicate last activity = remove
// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, loGemPortID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, loGemPortID)
if err != nil {
- logger.Errorw(ctx, "GemIWTP delete failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "GemIWTP delete failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -831,7 +838,7 @@
oFsm.mutexPLastTxMeInstance.Unlock()
}
-func (oFsm *uniPonAniConfigFsm) enterWaitingFlowRem(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterWaitingFlowRem(ctx context.Context, e *fsm.Event) {
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isWaitingForFlowDelete = true
oFsm.mutexIsAwaitingResponse.Unlock()
@@ -840,60 +847,60 @@
// case <-ctx.Done():
// logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
case <-time.After(2 * oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //give flow processing enough time to finish (but try to be less than rwCore flow timeouts)
- logger.Warnw(ctx, "uniPonAniConfigFsm WaitingFlowRem timeout", log.Fields{
- "for device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ logger.Warnw(ctx, "UniPonAniConfigFsm WaitingFlowRem timeout", log.Fields{
+ "for device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isWaitingForFlowDelete = false
oFsm.mutexIsAwaitingResponse.Unlock()
//if the flow is not removed as expected we just try to continue with GemPort removal and hope things are clearing up afterwards
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvFlowRemDone)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvFlowRemDone)
}
}(pConfigAniStateAFsm)
} else {
logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
}
return
case success := <-oFsm.waitFlowDeleteChannel:
if success {
- logger.Debugw(ctx, "uniPonAniConfigFsm flow removed info received", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm flow removed info received", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isWaitingForFlowDelete = false
oFsm.mutexIsAwaitingResponse.Unlock()
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvFlowRemDone)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvFlowRemDone)
}
}(pConfigAniStateAFsm)
} else {
logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
}
return
}
// waiting was aborted (probably on external request)
- logger.Debugw(ctx, "uniPonAniConfigFsm WaitingFlowRem aborted", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm WaitingFlowRem aborted", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID})
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isWaitingForFlowDelete = false
oFsm.mutexIsAwaitingResponse.Unlock()
//to be sure we can just generate the reset-event to ensure leaving this state towards 'reset'
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
}
@@ -901,27 +908,27 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) {
oFsm.pUniTechProf.mutexTPState.RLock()
loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
oFsm.pUniTechProf.mutexTPState.RUnlock()
- logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"GemNCTP-entity-id": loGemPortID})
// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, loGemPortID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, loGemPortID)
if err != nil {
- logger.Errorw(ctx, "GemNCTP delete failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "GemNCTP delete failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -931,32 +938,33 @@
oFsm.mutexPLastTxMeInstance.Unlock()
// Mark the gem port to be removed for Performance History monitoring
- if oFsm.pDeviceHandler.pOnuMetricsMgr != nil {
- oFsm.pDeviceHandler.pOnuMetricsMgr.RemoveGemPortForPerfMonitoring(ctx, loGemPortID)
+ OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager()
+ if OnuMetricsManager != nil {
+ OnuMetricsManager.RemoveGemPortForPerfMonitoring(ctx, loGemPortID)
}
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingTD(ctx context.Context, e *fsm.Event) {
+func (oFsm *UniPonAniConfigFsm) enterRemovingTD(ctx context.Context, e *fsm.Event) {
oFsm.pUniTechProf.mutexTPState.RLock()
loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
oFsm.pUniTechProf.mutexTPState.RUnlock()
- logger.Debugw(ctx, "uniPonAniConfigFsm - start removing Traffic Descriptor", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start removing Traffic Descriptor", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"TD-entity-id": loGemPortID})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteTD(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, loGemPortID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteTD(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, loGemPortID)
if err != nil {
logger.Errorw(ctx, "TD delete failed - proceed fsm",
log.Fields{"device-id": oFsm.deviceID, "gemPortID": loGemPortID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -966,31 +974,31 @@
oFsm.mutexPLastTxMeInstance.Unlock()
}
-func (oFsm *uniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start resetting the TCont", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start resetting the TCont", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
oFsm.requestEventOffset = 1 //offset 1 for last remove activity
// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
meParams := me.ParamData{
EntityID: oFsm.tcont0ID,
Attributes: me.AttributeValueMap{
- "AllocId": unusedTcontAllocID,
+ "AllocId": cmn.UnusedTcontAllocID,
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
- logger.Errorw(ctx, "TcontVar set failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -1001,9 +1009,9 @@
}
-func (oFsm *uniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
mapGemPortParams := oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].mapGemPortParams
unicastGemCount := 0
for _, gemEntry := range mapGemPortParams {
@@ -1012,35 +1020,35 @@
}
}
if unicastGemCount > 1 {
- logger.Debugw(ctx, "uniPonAniConfigFsm - Not the last gem in fsm. Skip the rest", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ logger.Debugw(ctx, "UniPonAniConfigFsm - Not the last gem in fsm. Skip the rest", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvRemGemDone)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvRemGemDone)
}
}(pConfigAniStateAFsm)
return
}
}
- logger.Debugw(ctx, "uniPonAniConfigFsm - Last gem in fsm. Continue with Mapper removal", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
+ logger.Debugw(ctx, "UniPonAniConfigFsm - Last gem in fsm. Continue with Mapper removal", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, oFsm.mapperSP0ID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, oFsm.mapperSP0ID)
if err != nil {
- logger.Errorw(ctx, "Dot1Mapper delete failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "Dot1Mapper delete failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -1051,23 +1059,23 @@
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, oFsm.macBPCD0ID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, oFsm.macBPCD0ID)
if err != nil {
- logger.Errorw(ctx, "MBPConfigData delete failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "MBPConfigData delete failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
return
@@ -1077,104 +1085,104 @@
oFsm.mutexPLastTxMeInstance.Unlock()
}
-func (oFsm *uniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm ani removal done", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm ani removal done", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
//use DeviceHandler event notification directly
- oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+ oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
if oFsm.isChanSet() {
// indicate processing done to the caller
- logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{
"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.chSuccess <- oFsm.procStep
oFsm.setChanSet(false) //reset the internal channel state
}
//let's reset the state machine in order to release all resources now
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvReset)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvReset)
}
}(pConfigAniStateAFsm)
}
}
-func (oFsm *uniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm resetting", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm resetting", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
if oFsm.isChanSet() {
// indicate processing error to the caller (in case there was still some open request)
- logger.Debugw(ctx, "uniPonAniConfigFsm processingError on channel", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm processingError on channel", log.Fields{
"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
//use non-blocking channel send to avoid blocking because of non-existing receiver
// (even though the channel is checked on 'set', the outside receiver channel might (theoretically) already be deleted)
select {
case oFsm.chSuccess <- 0:
default:
- logger.Debugw(ctx, "uniPonAniConfigFsm processingError not send on channel (no receiver)", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm processingError not send on channel (no receiver)", log.Fields{
"device-id": oFsm.deviceID})
}
oFsm.setChanSet(false) //reset the internal channel state
}
- pConfigAniStateAFsm := oFsm.pAdaptFsm
+ pConfigAniStateAFsm := oFsm.PAdaptFsm
if pConfigAniStateAFsm != nil {
// abort running message processing
- fsmAbortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ fsmAbortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
- pConfigAniStateAFsm.commChan <- fsmAbortMsg
+ pConfigAniStateAFsm.CommChan <- fsmAbortMsg
//try to restart the FSM to 'disabled', decouple event transfer
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvRestart)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvRestart)
}
}(pConfigAniStateAFsm)
}
}
-func (oFsm *uniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "uniPonAniConfigFsm enters disabled state", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+func (oFsm *UniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm enters disabled state", log.Fields{
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
oFsm.mutexPLastTxMeInstance.Lock()
defer oFsm.mutexPLastTxMeInstance.Unlock()
oFsm.pLastTxMeInstance = nil
}
-func (oFsm *uniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) {
- logger.Debugw(ctx, "Start uniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
+func (oFsm *UniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) {
+ logger.Debugw(ctx, "Start UniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
loop:
for {
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
- message, ok := <-oFsm.pAdaptFsm.commChan
+ message, ok := <-oFsm.PAdaptFsm.CommChan
if !ok {
logger.Info(ctx, "UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
break loop
}
logger.Debugw(ctx, "UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Infow(ctx, "UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
logger.Warnw(ctx, "UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oFsm.handleOmciAniConfigMessage(ctx, msg)
default:
logger.Warn(ctx, "UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1182,10 +1190,10 @@
}
}
- logger.Infow(ctx, "End uniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
+ logger.Infow(ctx, "End UniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse",
@@ -1211,12 +1219,12 @@
case "Ieee8021PMapperServiceProfile":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapCResp)
}
case "MacBridgePortConfigurationData":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxMbpcdResp)
}
case "GemPortNetworkCtp", "GemInterworkingTerminationPoint", "MulticastGemInterworkingTerminationPoint":
{ // let aniConfig Multi-Id processing proceed by stopping the wait function
@@ -1244,7 +1252,7 @@
return
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetFailResponseMessage(ctx context.Context, msgObj *omci.SetResponse) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetFailResponseMessage(ctx context.Context, msgObj *omci.SetResponse) {
//If TCONT fails, then we need to revert the allocated TCONT in DB.
//Because FSMs are running sequentially, we don't expect the same TCONT hit by another tech-profile FSM while this FSM is running.
oFsm.mutexPLastTxMeInstance.RLock()
@@ -1258,8 +1266,8 @@
if oFsm.requestEventOffset == 0 && !oFsm.tcontSetBefore && oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey] != nil {
logger.Debugw(ctx, "UniPonAniConfigFsm TCONT creation failed on device. Freeing alloc id", log.Fields{"device-id": oFsm.deviceID,
"alloc-id": oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID, "uni-tp": oFsm.uniTpKey})
- if pDevEntry := oFsm.pDeviceHandler.getOnuDeviceEntry(ctx, false); pDevEntry != nil {
- pDevEntry.freeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
+ if oFsm.pOnuDeviceEntry != nil {
+ oFsm.pOnuDeviceEntry.FreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID)
} else {
logger.Warnw(ctx, "Unable to get device entry! couldn't free tcont",
log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID})
@@ -1271,7 +1279,7 @@
}
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse",
@@ -1306,9 +1314,9 @@
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
if oFsm.requestEventOffset == 0 { //from TCont config request
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxTcontsResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxTcontsResp)
} else { // from T-Cont reset request
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxResetTcontResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxResetTcontResp)
}
}
case "PriorityQueue", "MulticastGemInterworkingTerminationPoint":
@@ -1319,7 +1327,7 @@
case "Ieee8021PMapperServiceProfile":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapSResp)
}
default:
{
@@ -1337,7 +1345,7 @@
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse)
if msgLayer == nil {
logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
@@ -1369,27 +1377,27 @@
case "GemInterworkingTerminationPoint":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemiwResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemiwResp)
}
case "GemPortNetworkCtp":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemntpResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemntpResp)
}
case "TrafficDescriptor":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemTdResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemTdResp)
}
case "Ieee8021PMapperServiceProfile":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRem1pMapperResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRem1pMapperResp)
}
case "MacBridgePortConfigurationData":
{ // this is the last event of the T-Cont cleanup procedure, FSM may be reset here
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemAniBPCDResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemAniBPCDResp)
}
default:
{
@@ -1407,7 +1415,7 @@
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
@@ -1429,17 +1437,17 @@
} //DeleteResponseType
default:
{
- logger.Errorw(ctx, "uniPonAniConfigFsm - Rx OMCI unhandled MsgType",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Rx OMCI unhandled MsgType",
log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID})
return
}
}
}
-func (oFsm *uniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) {
// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
"device-id": oFsm.deviceID})
@@ -1456,13 +1464,13 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
- logger.Errorw(ctx, "GemNCTPVar create failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "GemNCTPVar create failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -1474,20 +1482,21 @@
if err != nil {
logger.Errorw(ctx, "GemNWCtp create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
// Mark the gem port to be added for Performance History monitoring
- if oFsm.pDeviceHandler.pOnuMetricsMgr != nil {
- oFsm.pDeviceHandler.pOnuMetricsMgr.AddGemPortForPerfMonitoring(ctx, gemPortAttribs.gemPortID)
+ OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager()
+ if OnuMetricsManager != nil {
+ OnuMetricsManager.AddGemPortForPerfMonitoring(ctx, gemPortAttribs.gemPortID)
}
} //for all GemPorts of this T-Cont
// if Config has been done for all GemPort instances let the FSM proceed
logger.Debugw(ctx, "GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemntcpsResp)
}
-func (oFsm *uniPonAniConfigFsm) hasMulticastGem(ctx context.Context) bool {
+func (oFsm *UniPonAniConfigFsm) hasMulticastGem(ctx context.Context) bool {
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.isMulticast {
logger.Debugw(ctx, "Found multicast gem", log.Fields{"device-id": oFsm.deviceID})
@@ -1497,10 +1506,10 @@
return false
}
-func (oFsm *uniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) {
// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
- logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
"SPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"device-id": oFsm.deviceID})
@@ -1514,7 +1523,7 @@
"GemPortNetworkCtpConnectivityPointer": gemPortAttribs.multicastGemID,
"InterworkingOption": 0, // Don't Care
"ServiceProfilePointer": 0, // Don't Care
- "GalProfilePointer": galEthernetEID,
+ "GalProfilePointer": cmn.GalEthernetEID,
},
}
if oFsm.pUniTechProf.multicastConfiguredForOtherUniTps(ctx, oFsm.uniTpKey) {
@@ -1522,13 +1531,13 @@
continue
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
- logger.Errorw(ctx, "MulticastGemIWTPVar create failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "MulticastGemIWTPVar create failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
@@ -1539,7 +1548,7 @@
if err != nil {
logger.Errorw(ctx, "MulticastGemIWTP create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
ipv4MulticastTable := make([]uint8, 12)
@@ -1548,9 +1557,9 @@
//Secondary Key
binary.BigEndian.PutUint16(ipv4MulticastTable[2:], 0)
// Multicast IP range start This is the 224.0.0.1 address
- binary.BigEndian.PutUint32(ipv4MulticastTable[4:], IPToInt32(net.IPv4(224, 0, 0, 0)))
+ binary.BigEndian.PutUint32(ipv4MulticastTable[4:], cmn.IPToInt32(net.IPv4(224, 0, 0, 0)))
// MulticastIp range stop
- binary.BigEndian.PutUint32(ipv4MulticastTable[8:], IPToInt32(net.IPv4(239, 255, 255, 255)))
+ binary.BigEndian.PutUint32(ipv4MulticastTable[8:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255)))
meIPV4MCTableParams := me.ParamData{
EntityID: gemPortAttribs.multicastGemID,
@@ -1559,13 +1568,13 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meIPV4MCTableInstance, err := oFsm.pOmciCC.sendSetMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, oFsm.pAdaptFsm.commChan, meIPV4MCTableParams)
+ meIPV4MCTableInstance, err := oFsm.pOmciCC.SendSetMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, oFsm.PAdaptFsm.CommChan, meIPV4MCTableParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
- logger.Errorw(ctx, "MulticastGemIWTPVar set failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "MulticastGemIWTPVar set failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
oFsm.pLastTxMeInstance = meIPV4MCTableInstance
@@ -1579,17 +1588,17 @@
"InterworkingOption": 5, //fixed model:: G.998 .1pMapper
"ServiceProfilePointer": oFsm.mapperSP0ID,
"InterworkingTerminationPointPointer": 0, //not used with .1PMapper Mac bridge
- "GalProfilePointer": galEthernetEID,
+ "GalProfilePointer": cmn.GalEthernetEID,
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
- logger.Errorw(ctx, "GEMIWTPVar create failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "GEMIWTPVar create failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -1602,28 +1611,28 @@
if err != nil {
logger.Errorw(ctx, "GemTP create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.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(ctx, "GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemiwsResp)
}
-func (oFsm *uniPonAniConfigFsm) performSettingPQs(ctx context.Context) {
+func (oFsm *UniPonAniConfigFsm) performSettingPQs(ctx context.Context) {
//If upstream PQs were set before, then no need to set them again. Let state machine to proceed.
if oFsm.tcontSetBefore {
logger.Debugw(ctx, "No need to set PQs again.", log.Fields{
"device-id": oFsm.deviceID, "tcont": oFsm.alloc0ID,
- "uni-id": oFsm.pOnuUniPort.uniID,
+ "uni-id": oFsm.pOnuUniPort.UniID,
"techProfile-id": oFsm.techProfileID})
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
- _ = aPAFsm.pFsm.Event(aniEvRxPrioqsResp)
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
+ _ = aPAFsm.PFsm.Event(aniEvRxPrioqsResp)
}
- }(oFsm.pAdaptFsm)
+ }(oFsm.PAdaptFsm)
return
}
const cu16StrictPrioWeight uint16 = 0xFFFF
@@ -1631,7 +1640,7 @@
loQueueMap := ordered_map.NewOrderedMap()
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.isMulticast {
- logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
@@ -1647,29 +1656,29 @@
}
trafficSchedPtrSetSupported := false
- loOnu2g := oFsm.pOnuDB.GetMe(me.Onu2GClassID, onu2gMeID)
+ loOnu2g := oFsm.pOnuDB.GetMe(me.Onu2GClassID, cmn.Onu2gMeID)
if loOnu2g == nil {
logger.Errorw(ctx, "onu2g is nil, cannot read qos configuration flexibility parameter",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
returnVal := loOnu2g["QualityOfServiceQosConfigurationFlexibility"]
if returnVal != nil {
- if qosCfgFlexParam, err := oFsm.pOnuDB.getUint16Attrib(returnVal); err == nil {
+ if qosCfgFlexParam, err := oFsm.pOnuDB.GetUint16Attrib(returnVal); err == nil {
trafficSchedPtrSetSupported = qosCfgFlexParam&bitTrafficSchedulerPtrSetPermitted == bitTrafficSchedulerPtrSetPermitted
logger.Debugw(ctx, "trafficSchedPtrSetSupported set",
log.Fields{"qosCfgFlexParam": qosCfgFlexParam, "trafficSchedPtrSetSupported": trafficSchedPtrSetSupported})
} else {
logger.Errorw(ctx, "Cannot extract qos configuration flexibility parameter",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
} else {
logger.Errorw(ctx, "Cannot read qos configuration flexibility parameter",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
@@ -1724,13 +1733,13 @@
meParams.Attributes["Weight"] = uint8(kv.Value.(uint16))
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
- logger.Errorw(ctx, "PrioQueueVar set failed, aborting uniPonAniConfigFsm!",
+ logger.Errorw(ctx, "PrioQueueVar set failed, aborting UniPonAniConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -1743,7 +1752,7 @@
if err != nil {
logger.Errorw(ctx, "PrioQueue set failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset)
return
}
@@ -1756,16 +1765,16 @@
// if Config has been done for all PrioQueue instances let the FSM proceed
logger.Debugw(ctx, "PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxPrioqsResp)
}
-func (oFsm *uniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error {
+func (oFsm *UniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error {
oFsm.mutexIsAwaitingResponse.Lock()
if oFsm.isCanceled {
// FSM already canceled before entering wait
- logger.Debugw(ctx, "uniPonAniConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
oFsm.mutexIsAwaitingResponse.Unlock()
- return fmt.Errorf(cErrWaitAborted)
+ return fmt.Errorf(cmn.CErrWaitAborted)
}
oFsm.isAwaitingResponse = true
oFsm.mutexIsAwaitingResponse.Unlock()
@@ -1781,28 +1790,28 @@
return fmt.Errorf("uniPonAniConfigFsm multi entity timeout %s", oFsm.deviceID)
case success := <-oFsm.omciMIdsResponseReceived:
if success {
- logger.Debugw(ctx, "uniPonAniConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID})
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isAwaitingResponse = false
oFsm.mutexIsAwaitingResponse.Unlock()
return nil
}
// waiting was aborted (probably on external request)
- logger.Debugw(ctx, "uniPonAniConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID})
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isAwaitingResponse = false
oFsm.mutexIsAwaitingResponse.Unlock()
- return fmt.Errorf(cErrWaitAborted)
+ return fmt.Errorf(cmn.CErrWaitAborted)
}
}
-func (oFsm *uniPonAniConfigFsm) setChanSet(flagValue bool) {
+func (oFsm *UniPonAniConfigFsm) setChanSet(flagValue bool) {
oFsm.mutexChanSet.Lock()
oFsm.chanSet = flagValue
oFsm.mutexChanSet.Unlock()
}
-func (oFsm *uniPonAniConfigFsm) isChanSet() bool {
+func (oFsm *UniPonAniConfigFsm) isChanSet() bool {
oFsm.mutexChanSet.RLock()
flagValue := oFsm.chanSet
oFsm.mutexChanSet.RUnlock()
diff --git a/internal/pkg/onuadaptercore/omci_vlan_config.go b/internal/pkg/avcfg/omci_vlan_config.go
old mode 100644
new mode 100755
similarity index 84%
rename from internal/pkg/onuadaptercore/omci_vlan_config.go
rename to internal/pkg/avcfg/omci_vlan_config.go
index c6311e4..4a690f7
--- a/internal/pkg/onuadaptercore/omci_vlan_config.go
+++ b/internal/pkg/avcfg/omci_vlan_config.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
import (
"context"
@@ -35,6 +35,8 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
of "github.com/opencord/voltha-protos/v5/go/openflow_13"
)
@@ -47,11 +49,11 @@
)
const (
- // internal offsets for requestEvent according to definition in onu_device_entry::OnuDeviceEvent
+ // internal offsets for requestEvent according to definition in onu_device_entry::cmn.OnuDeviceEvent
cDeviceEventOffsetAddWithKvStore = 0 //OmciVlanFilterAddDone - OmciVlanFilterAddDone cannot use because of lint
- cDeviceEventOffsetAddNoKvStore = OmciVlanFilterAddDoneNoKvStore - OmciVlanFilterAddDone
- cDeviceEventOffsetRemoveWithKvStore = OmciVlanFilterRemDone - OmciVlanFilterAddDone
- cDeviceEventOffsetRemoveNoKvStore = OmciVlanFilterRemDoneNoKvStore - OmciVlanFilterAddDone
+ cDeviceEventOffsetAddNoKvStore = cmn.OmciVlanFilterAddDoneNoKvStore - cmn.OmciVlanFilterAddDone
+ cDeviceEventOffsetRemoveWithKvStore = cmn.OmciVlanFilterRemDone - cmn.OmciVlanFilterAddDone
+ cDeviceEventOffsetRemoveNoKvStore = cmn.OmciVlanFilterRemDoneNoKvStore - cmn.OmciVlanFilterAddDone
)
const (
@@ -88,82 +90,71 @@
cSetOutputTpidCopyDei uint32 = 4
)
+// events of config UNI port VLAN FSM
const (
- // events of config UNI port VLAN FSM
- vlanEvStart = "vlanEvStart"
- vlanEvPrepareDone = "vlanEvPrepareDone"
- vlanEvWaitTechProf = "vlanEvWaitTechProf"
- vlanEvCancelOutstandingConfig = "vlanEvCancelOutstandingConfig"
- vlanEvContinueConfig = "vlanEvContinueConfig"
- vlanEvStartConfig = "vlanEvStartConfig"
- vlanEvRxConfigVtfd = "vlanEvRxConfigVtfd"
- vlanEvRxConfigEvtocd = "vlanEvRxConfigEvtocd"
- vlanEvWaitTPIncr = "vlanEvWaitTPIncr"
- vlanEvIncrFlowConfig = "vlanEvIncrFlowConfig"
- vlanEvRenew = "vlanEvRenew"
- vlanEvRemFlowConfig = "vlanEvRemFlowConfig"
- vlanEvRemFlowDone = "vlanEvRemFlowDone"
- vlanEvFlowDataRemoved = "vlanEvFlowDataRemoved"
- //vlanEvTimeoutSimple = "vlanEvTimeoutSimple"
- //vlanEvTimeoutMids = "vlanEvTimeoutMids"
- vlanEvReset = "vlanEvReset"
- vlanEvRestart = "vlanEvRestart"
- vlanEvSkipOmciConfig = "vlanEvSkipOmciConfig"
- vlanEvSkipIncFlowConfig = "vlanEvSkipIncFlowConfig"
+ VlanEvStart = "VlanEvStart"
+ VlanEvPrepareDone = "VlanEvPrepareDone"
+ VlanEvWaitTechProf = "VlanEvWaitTechProf"
+ VlanEvCancelOutstandingConfig = "VlanEvCancelOutstandingConfig"
+ VlanEvContinueConfig = "VlanEvContinueConfig"
+ VlanEvStartConfig = "VlanEvStartConfig"
+ VlanEvRxConfigVtfd = "VlanEvRxConfigVtfd"
+ VlanEvRxConfigEvtocd = "VlanEvRxConfigEvtocd"
+ VlanEvWaitTPIncr = "VlanEvWaitTPIncr"
+ VlanEvIncrFlowConfig = "VlanEvIncrFlowConfig"
+ VlanEvRenew = "VlanEvRenew"
+ VlanEvRemFlowConfig = "VlanEvRemFlowConfig"
+ VlanEvRemFlowDone = "VlanEvRemFlowDone"
+ VlanEvFlowDataRemoved = "VlanEvFlowDataRemoved"
+ //VlanEvTimeoutSimple = "VlanEvTimeoutSimple"
+ //VlanEvTimeoutMids = "VlanEvTimeoutMids"
+ VlanEvReset = "VlanEvReset"
+ VlanEvRestart = "VlanEvRestart"
+ VlanEvSkipOmciConfig = "VlanEvSkipOmciConfig"
+ VlanEvSkipIncFlowConfig = "VlanEvSkipIncFlowConfig"
)
+// states of config UNI port VLAN FSM
const (
- // states of config UNI port VLAN FSM
- vlanStDisabled = "vlanStDisabled"
- vlanStPreparing = "vlanStPreparing"
- vlanStStarting = "vlanStStarting"
- vlanStWaitingTechProf = "vlanStWaitingTechProf"
- vlanStConfigVtfd = "vlanStConfigVtfd"
- vlanStConfigEvtocd = "vlanStConfigEvtocd"
- vlanStConfigDone = "vlanStConfigDone"
- vlanStIncrFlowWaitTP = "vlanStIncrFlowWaitTP"
- vlanStConfigIncrFlow = "vlanStConfigIncrFlow"
- vlanStRemoveFlow = "vlanStRemoveFlow"
- vlanStCleanupDone = "vlanStCleanupDone"
- vlanStResetting = "vlanStResetting"
+ VlanStDisabled = "VlanStDisabled"
+ VlanStPreparing = "VlanStPreparing"
+ VlanStStarting = "VlanStStarting"
+ VlanStWaitingTechProf = "VlanStWaitingTechProf"
+ VlanStConfigVtfd = "VlanStConfigVtfd"
+ VlanStConfigEvtocd = "VlanStConfigEvtocd"
+ VlanStConfigDone = "VlanStConfigDone"
+ VlanStIncrFlowWaitTP = "VlanStIncrFlowWaitTP"
+ VlanStConfigIncrFlow = "VlanStConfigIncrFlow"
+ VlanStRemoveFlow = "VlanStRemoveFlow"
+ VlanStCleanupDone = "VlanStCleanupDone"
+ VlanStResetting = "VlanStResetting"
)
-const cVlanFsmIdleState = vlanStConfigDone // state where no OMCI activity is done (for a longer time)
-const cVlanFsmConfiguredState = vlanStConfigDone // state that indicates that at least some valid user related VLAN configuration should exist
-type uniVlanRuleParams struct {
- TpID uint8 `json:"tp_id"`
- MatchVid uint32 `json:"match_vid"` //use uint32 types for allowing immediate bitshifting
- MatchPcp uint32 `json:"match_pcp"`
- TagsToRemove uint32 `json:"tags_to_remove"`
- SetVid uint32 `json:"set_vid"`
- SetPcp uint32 `json:"set_pcp"`
-}
-
-type uniVlanFlowParams struct {
- CookieSlice []uint64 `json:"cookie_slice"`
- VlanRuleParams uniVlanRuleParams `json:"vlan_rule_params"`
- Meter *voltha.OfpMeterConfig `json:"flow_meter"`
-}
+// CVlanFsmIdleState - TODO: add comment
+const CVlanFsmIdleState = VlanStConfigDone // state where no OMCI activity is done (for a longer time)
+// CVlanFsmConfiguredState - TODO: add comment
+const CVlanFsmConfiguredState = VlanStConfigDone // state that indicates that at least some valid user related VLAN configuration should exist
type uniRemoveVlanFlowParams struct {
isSuspendedOnAdd bool
removeChannel chan bool
cookie uint64 //just the last cookie valid for removal
- vlanRuleParams uniVlanRuleParams
+ vlanRuleParams cmn.UniVlanRuleParams
}
//UniVlanConfigFsm defines the structure for the state machine for configuration of the VLAN related setting via OMCI
// builds upon 'VLAN rules' that are derived from multiple flows
type UniVlanConfigFsm struct {
- pDeviceHandler *deviceHandler
+ pDeviceHandler cmn.IdeviceHandler
+ pOnuDeviceEntry cmn.IonuDeviceEntry
deviceID string
- pOmciCC *omciCC
- pOnuUniPort *onuUniPort
- pUniTechProf *onuUniTechProf
- pOnuDB *onuDeviceDB
- requestEvent OnuDeviceEvent
+ pOmciCC *cmn.OmciCC
+ pOnuUniPort *cmn.OnuUniPort
+ pUniTechProf *OnuUniTechProf
+ pOnuDB *devdb.OnuDeviceDB
+ requestEvent cmn.OnuDeviceEvent
omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses
- pAdaptFsm *AdapterFsm
+ PAdaptFsm *cmn.AdapterFsm
acceptIncrementalEvtoOption bool
clearPersistency bool
isCanceled bool
@@ -171,12 +162,12 @@
mutexIsAwaitingResponse sync.RWMutex
mutexFlowParams sync.RWMutex
chCookieDeleted chan bool //channel to indicate that a specific cookie (related to the active rule) was deleted
- actualUniVlanConfigRule uniVlanRuleParams
+ actualUniVlanConfigRule cmn.UniVlanRuleParams
actualUniVlanConfigMeter *voltha.OfpMeterConfig
- uniVlanFlowParamsSlice []uniVlanFlowParams
+ uniVlanFlowParamsSlice []cmn.UniVlanFlowParams
uniRemoveFlowsSlice []uniRemoveVlanFlowParams
- numUniFlows uint8 // expected number of flows should be less than 12
- configuredUniFlow uint8
+ NumUniFlows uint8 // expected number of flows should be less than 12
+ ConfiguredUniFlow uint8
numRemoveFlows uint8
numVlanFilterEntries uint8
vlanFilterList [cVtfdTableSize]uint16
@@ -196,84 +187,85 @@
//NewUniVlanConfigFsm is the 'constructor' for the state machine to config the PON ANI ports
// of ONU UNI ports via OMCI
-func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler *deviceHandler, apDevOmciCC *omciCC, apUniPort *onuUniPort,
- apUniTechProf *onuUniTechProf, apOnuDB *onuDeviceDB, aTechProfileID uint8,
- aRequestEvent OnuDeviceEvent, aName string, aCommChannel chan Message, aAcceptIncrementalEvto bool,
+func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort,
+ apUniTechProf *OnuUniTechProf, apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8,
+ aRequestEvent cmn.OnuDeviceEvent, aName string, aCommChannel chan cmn.Message, aAcceptIncrementalEvto bool,
aCookieSlice []uint64, aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToRec bool, aMeter *voltha.OfpMeterConfig) *UniVlanConfigFsm {
instFsm := &UniVlanConfigFsm{
pDeviceHandler: apDeviceHandler,
- deviceID: apDeviceHandler.deviceID,
+ pOnuDeviceEntry: apOnuDeviceEntry,
+ deviceID: apDeviceHandler.GetDeviceID(),
pOmciCC: apDevOmciCC,
pOnuUniPort: apUniPort,
pUniTechProf: apUniTechProf,
pOnuDB: apOnuDB,
requestEvent: aRequestEvent,
acceptIncrementalEvtoOption: aAcceptIncrementalEvto,
- numUniFlows: 0,
- configuredUniFlow: 0,
+ NumUniFlows: 0,
+ ConfiguredUniFlow: 0,
numRemoveFlows: 0,
clearPersistency: true,
lastFlowToReconcile: lastFlowToRec,
}
- instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
- if instFsm.pAdaptFsm == nil {
- logger.Errorw(ctx, "UniVlanConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+ if instFsm.PAdaptFsm == nil {
+ logger.Errorw(ctx, "UniVlanConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
- vlanStDisabled,
+ instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+ VlanStDisabled,
fsm.Events{
- {Name: vlanEvStart, Src: []string{vlanStDisabled}, Dst: vlanStPreparing},
- {Name: vlanEvPrepareDone, Src: []string{vlanStPreparing}, Dst: vlanStStarting},
- {Name: vlanEvWaitTechProf, Src: []string{vlanStStarting}, Dst: vlanStWaitingTechProf},
- {Name: vlanEvCancelOutstandingConfig, Src: []string{vlanStWaitingTechProf}, Dst: vlanStConfigDone},
- {Name: vlanEvContinueConfig, Src: []string{vlanStWaitingTechProf}, Dst: vlanStConfigVtfd},
- {Name: vlanEvStartConfig, Src: []string{vlanStStarting}, Dst: vlanStConfigVtfd},
- {Name: vlanEvRxConfigVtfd, Src: []string{vlanStConfigVtfd}, Dst: vlanStConfigEvtocd},
- {Name: vlanEvRxConfigEvtocd, Src: []string{vlanStConfigEvtocd, vlanStConfigIncrFlow},
- Dst: vlanStConfigDone},
- {Name: vlanEvRenew, Src: []string{vlanStConfigDone}, Dst: vlanStStarting},
- {Name: vlanEvWaitTPIncr, Src: []string{vlanStConfigDone}, Dst: vlanStIncrFlowWaitTP},
- {Name: vlanEvIncrFlowConfig, Src: []string{vlanStConfigDone, vlanStIncrFlowWaitTP},
- Dst: vlanStConfigIncrFlow},
- {Name: vlanEvRemFlowConfig, Src: []string{vlanStConfigDone}, Dst: vlanStRemoveFlow},
- {Name: vlanEvRemFlowDone, Src: []string{vlanStRemoveFlow}, Dst: vlanStCleanupDone},
- {Name: vlanEvFlowDataRemoved, Src: []string{vlanStCleanupDone}, Dst: vlanStConfigDone},
+ {Name: VlanEvStart, Src: []string{VlanStDisabled}, Dst: VlanStPreparing},
+ {Name: VlanEvPrepareDone, Src: []string{VlanStPreparing}, Dst: VlanStStarting},
+ {Name: VlanEvWaitTechProf, Src: []string{VlanStStarting}, Dst: VlanStWaitingTechProf},
+ {Name: VlanEvCancelOutstandingConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigDone},
+ {Name: VlanEvContinueConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigVtfd},
+ {Name: VlanEvStartConfig, Src: []string{VlanStStarting}, Dst: VlanStConfigVtfd},
+ {Name: VlanEvRxConfigVtfd, Src: []string{VlanStConfigVtfd}, Dst: VlanStConfigEvtocd},
+ {Name: VlanEvRxConfigEvtocd, Src: []string{VlanStConfigEvtocd, VlanStConfigIncrFlow},
+ Dst: VlanStConfigDone},
+ {Name: VlanEvRenew, Src: []string{VlanStConfigDone}, Dst: VlanStStarting},
+ {Name: VlanEvWaitTPIncr, Src: []string{VlanStConfigDone}, Dst: VlanStIncrFlowWaitTP},
+ {Name: VlanEvIncrFlowConfig, Src: []string{VlanStConfigDone, VlanStIncrFlowWaitTP},
+ Dst: VlanStConfigIncrFlow},
+ {Name: VlanEvRemFlowConfig, Src: []string{VlanStConfigDone}, Dst: VlanStRemoveFlow},
+ {Name: VlanEvRemFlowDone, Src: []string{VlanStRemoveFlow}, Dst: VlanStCleanupDone},
+ {Name: VlanEvFlowDataRemoved, Src: []string{VlanStCleanupDone}, Dst: VlanStConfigDone},
/*
- {Name: vlanEvTimeoutSimple, Src: []string{
- vlanStCreatingDot1PMapper, vlanStCreatingMBPCD, vlanStSettingTconts, vlanStSettingDot1PMapper}, Dst: vlanStStarting},
- {Name: vlanEvTimeoutMids, Src: []string{
- vlanStCreatingGemNCTPs, vlanStCreatingGemIWs, vlanStSettingPQs}, Dst: vlanStStarting},
+ {Name: VlanEvTimeoutSimple, Src: []string{
+ VlanStCreatingDot1PMapper, VlanStCreatingMBPCD, VlanStSettingTconts, VlanStSettingDot1PMapper}, Dst: VlanStStarting},
+ {Name: VlanEvTimeoutMids, Src: []string{
+ VlanStCreatingGemNCTPs, VlanStCreatingGemIWs, VlanStSettingPQs}, Dst: VlanStStarting},
*/
- // exceptional treatment for all states except vlanStResetting
- {Name: vlanEvReset, Src: []string{vlanStStarting, vlanStWaitingTechProf,
- vlanStConfigVtfd, vlanStConfigEvtocd, vlanStConfigDone, vlanStConfigIncrFlow,
- vlanStRemoveFlow, vlanStCleanupDone},
- Dst: vlanStResetting},
+ // exceptional treatment for all states except VlanStResetting
+ {Name: VlanEvReset, Src: []string{VlanStStarting, VlanStWaitingTechProf,
+ VlanStConfigVtfd, VlanStConfigEvtocd, VlanStConfigDone, VlanStConfigIncrFlow,
+ VlanStRemoveFlow, VlanStCleanupDone},
+ Dst: VlanStResetting},
// the only way to get to resource-cleared disabled state again is via "resseting"
- {Name: vlanEvRestart, Src: []string{vlanStResetting}, Dst: vlanStDisabled},
+ {Name: VlanEvRestart, Src: []string{VlanStResetting}, Dst: VlanStDisabled},
// transitions for reconcile handling according to VOL-3834
- {Name: vlanEvSkipOmciConfig, Src: []string{vlanStPreparing}, Dst: vlanStConfigDone},
- {Name: vlanEvSkipOmciConfig, Src: []string{vlanStConfigDone}, Dst: vlanStConfigIncrFlow},
- {Name: vlanEvSkipIncFlowConfig, Src: []string{vlanStConfigIncrFlow}, Dst: vlanStConfigDone},
+ {Name: VlanEvSkipOmciConfig, Src: []string{VlanStPreparing}, Dst: VlanStConfigDone},
+ {Name: VlanEvSkipOmciConfig, Src: []string{VlanStConfigDone}, Dst: VlanStConfigIncrFlow},
+ {Name: VlanEvSkipIncFlowConfig, Src: []string{VlanStConfigIncrFlow}, Dst: VlanStConfigDone},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
- "enter_" + vlanStPreparing: func(e *fsm.Event) { instFsm.enterPreparing(ctx, e) },
- "enter_" + vlanStStarting: func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) },
- "enter_" + vlanStConfigVtfd: func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) },
- "enter_" + vlanStConfigEvtocd: func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) },
- "enter_" + vlanStConfigDone: func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) },
- "enter_" + vlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) },
- "enter_" + vlanStRemoveFlow: func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) },
- "enter_" + vlanStCleanupDone: func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) },
- "enter_" + vlanStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
- "enter_" + vlanStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
+ "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+ "enter_" + VlanStPreparing: func(e *fsm.Event) { instFsm.enterPreparing(ctx, e) },
+ "enter_" + VlanStStarting: func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) },
+ "enter_" + VlanStConfigVtfd: func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) },
+ "enter_" + VlanStConfigEvtocd: func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) },
+ "enter_" + VlanStConfigDone: func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) },
+ "enter_" + VlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) },
+ "enter_" + VlanStRemoveFlow: func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) },
+ "enter_" + VlanStCleanupDone: func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) },
+ "enter_" + VlanStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
+ "enter_" + VlanStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
},
)
- if instFsm.pAdaptFsm.pFsm == nil {
+ if instFsm.PAdaptFsm.PFsm == nil {
logger.Errorw(ctx, "UniVlanConfigFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
@@ -289,7 +281,7 @@
//initUniFlowParams is a simplified form of SetUniFlowParams() used for first flow parameters configuration
func (oFsm *UniVlanConfigFsm) initUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aMeter *voltha.OfpMeterConfig) error {
- loRuleParams := uniVlanRuleParams{
+ loRuleParams := cmn.UniVlanRuleParams{
TpID: aTpID,
MatchVid: uint32(aMatchVlan),
SetVid: uint32(aSetVlan),
@@ -323,7 +315,7 @@
}
}
- loFlowParams := uniVlanFlowParams{VlanRuleParams: loRuleParams}
+ loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams}
loFlowParams.CookieSlice = make([]uint64, 0)
loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...)
if aMeter != nil {
@@ -331,23 +323,23 @@
}
//no mutex protection is required for initial access and adding the first flow is always possible
- oFsm.uniVlanFlowParamsSlice = make([]uniVlanFlowParams, 0)
+ oFsm.uniVlanFlowParamsSlice = make([]cmn.UniVlanFlowParams, 0)
oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
logger.Debugw(ctx, "first UniVlanConfigFsm flow added", log.Fields{
"Cookies": oFsm.uniVlanFlowParamsSlice[0].CookieSlice,
"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
"SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
"SetPcp": loRuleParams.SetPcp,
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid))
}
- oFsm.numUniFlows = 1
+ oFsm.NumUniFlows = 1
oFsm.uniRemoveFlowsSlice = make([]uniRemoveVlanFlowParams, 0) //initially nothing to remove
//permanently store flow config for reconcile case
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+ if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
&oFsm.uniVlanFlowParamsSlice, true); err != nil {
logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
@@ -372,11 +364,11 @@
}
// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
- pAdaptFsm := oFsm.pAdaptFsm
- if pAdaptFsm != nil {
- if fsmErr := pAdaptFsm.pFsm.Event(vlanEvReset); fsmErr != nil {
+ PAdaptFsm := oFsm.PAdaptFsm
+ if PAdaptFsm != nil {
+ if fsmErr := PAdaptFsm.PFsm.Event(VlanEvReset); fsmErr != nil {
logger.Errorw(ctx, "reset-event failed in UniVlanConfigFsm!",
- log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
+ log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
}
}
@@ -404,7 +396,7 @@
// nolint: gocyclo
func (oFsm *UniVlanConfigFsm) SetUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
- loRuleParams := uniVlanRuleParams{
+ loRuleParams := cmn.UniVlanRuleParams{
TpID: aTpID,
MatchVid: uint32(aMatchVlan),
SetVid: uint32(aSetVlan),
@@ -482,7 +474,7 @@
"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
"SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
"SetPcp": loRuleParams.SetPcp,
- "device-id": oFsm.deviceID, " uni-id": oFsm.pOnuUniPort.uniID})
+ "device-id": oFsm.deviceID, " uni-id": oFsm.pOnuUniPort.UniID})
var cookieMatch bool
for _, newCookie := range aCookieSlice { // for all cookies available in the arguments
cookieMatch = false
@@ -538,8 +530,8 @@
kvStoreWrite := false //default setting is to not write to kvStore immediately - will be done on FSM execution finally
if requestAppendRule {
oFsm.mutexFlowParams.Lock()
- if oFsm.numUniFlows < cMaxAllowedFlows {
- loFlowParams := uniVlanFlowParams{VlanRuleParams: loRuleParams}
+ if oFsm.NumUniFlows < cMaxAllowedFlows {
+ loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams}
loFlowParams.CookieSlice = make([]uint64, 0)
loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...)
if aMeter != nil {
@@ -547,28 +539,28 @@
}
oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
logger.Debugw(ctx, "UniVlanConfigFsm flow add", log.Fields{
- "Cookies": oFsm.uniVlanFlowParamsSlice[oFsm.numUniFlows].CookieSlice,
+ "Cookies": oFsm.uniVlanFlowParamsSlice[oFsm.NumUniFlows].CookieSlice,
"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
"SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
- "SetPcp": loRuleParams.SetPcp, "numberofFlows": oFsm.numUniFlows + 1,
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
+ "SetPcp": loRuleParams.SetPcp, "numberofFlows": oFsm.NumUniFlows + 1,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID})
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid))
}
- oFsm.numUniFlows++
- pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+ oFsm.NumUniFlows++
+ pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
logger.Debugw(ctx, "reconciling - skip omci-config of additional vlan rule",
- log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+ log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
//attention: take care to release the mutexFlowParams when calling the FSM directly -
// synchronous FSM 'event/state' functions may rely on this mutex
oFsm.mutexFlowParams.Unlock()
- if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
- if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvSkipOmciConfig); fsmErr != nil {
+ if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
+ if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvSkipOmciConfig); fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
- log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
+ log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
}
return nil
@@ -578,31 +570,31 @@
// but that is getting quite complicated - maybe a future optimization in case it should prove reasonable
// anyway the precondition here is that the FSM checks for rules to delete first and adds new rules afterwards
- if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
+ if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
//have to re-trigger the FSM to proceed with outstanding incremental flow configuration
- if oFsm.configuredUniFlow == 0 {
+ if oFsm.ConfiguredUniFlow == 0 {
// this is a restart with a complete new flow, we can re-use the initial flow config control
// including the check, if the related techProfile is (still) available (probably also removed in between)
//attention: take care to release the mutexFlowParams when calling the FSM directly -
// synchronous FSM 'event/state' functions may rely on this mutex
oFsm.mutexFlowParams.Unlock()
- if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvRenew); fsmErr != nil {
+ if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRenew); fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
} else {
//some further flows are to be configured
//store the actual rule that shall be worked upon in the following transient states
- if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.configuredUniFlow) {
+ if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) {
//check introduced after having observed some panic here
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm - inconsistent counter",
- log.Fields{"configuredUniFlow": oFsm.configuredUniFlow,
+ log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow,
"sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Unlock()
return fmt.Errorf("abort UniVlanConfigFsm on add due to internal counter mismatch %s", oFsm.deviceID)
}
- oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams
- oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].Meter
+ oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].VlanRuleParams
+ oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].Meter
//tpId of the next rule to be configured
tpID := oFsm.actualUniVlanConfigRule.TpID
oFsm.TpIDWaitingFor = tpID
@@ -612,18 +604,18 @@
// but it must be released already before calling getTechProfileDone() as it may already be locked
// by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
oFsm.mutexFlowParams.Unlock()
- loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, tpID)
+ loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID)
logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request (on setConfig)", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
var fsmErr error
if loTechProfDone {
// let the vlan processing continue with next rule
- fsmErr = pConfigVlanStateBaseFsm.Event(vlanEvIncrFlowConfig)
+ fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvIncrFlowConfig)
} else {
// set to waiting for Techprofile
- fsmErr = pConfigVlanStateBaseFsm.Event(vlanEvWaitTPIncr)
+ fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvWaitTPIncr)
}
if fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
@@ -637,7 +629,7 @@
}
} else {
logger.Errorw(ctx, "UniVlanConfigFsm flow limit exceeded", log.Fields{
- "device-id": oFsm.deviceID, "flow-number": oFsm.numUniFlows})
+ "device-id": oFsm.deviceID, "flow-number": oFsm.NumUniFlows})
oFsm.mutexFlowParams.Unlock()
return fmt.Errorf(" UniVlanConfigFsm flow limit exceeded %s", oFsm.deviceID)
}
@@ -645,7 +637,7 @@
// no activity within the FSM for OMCI processing, the deviceReason may be updated immediately
kvStoreWrite = true // ensure actual data write to kvStore immediately (no FSM activity)
oFsm.mutexFlowParams.RLock()
- if oFsm.numUniFlows == oFsm.configuredUniFlow {
+ if oFsm.NumUniFlows == oFsm.ConfiguredUniFlow {
//all requested rules really have been configured
// state transition notification is checked in deviceHandler
oFsm.mutexFlowParams.RUnlock()
@@ -653,15 +645,15 @@
//also the related TechProfile was already configured
logger.Debugw(ctx, "UniVlanConfigFsm rule already set - send immediate add-success event for reason update", log.Fields{
"device-id": oFsm.deviceID})
- // success indication without the need to write to kvStore (done already below with updated data from storePersUniFlowConfig())
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetAddNoKvStore))
+ // success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig())
+ go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetAddNoKvStore))
}
} else {
// avoid device reason update as the rule config connected to this flow may still be in progress
// and the device reason should only be updated on success of rule config
logger.Debugw(ctx, "UniVlanConfigFsm rule already set but configuration ongoing, suppress early add-success event for reason update",
log.Fields{"device-id": oFsm.deviceID,
- "NumberofRules": oFsm.numUniFlows, "Configured rules": oFsm.configuredUniFlow})
+ "NumberofRules": oFsm.NumUniFlows, "Configured rules": oFsm.ConfiguredUniFlow})
oFsm.mutexFlowParams.RUnlock()
}
}
@@ -669,7 +661,7 @@
if flowCookieModify { // some change was done to the flow entries
//permanently store flow config for reconcile case
oFsm.mutexFlowParams.RLock()
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+ if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
&oFsm.uniVlanFlowParamsSlice, kvStoreWrite); err != nil {
oFsm.mutexFlowParams.RUnlock()
logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
@@ -761,7 +753,7 @@
}
//returns flowModified, RuleAppendRequest
-func (oFsm *UniVlanConfigFsm) reviseFlowConstellation(ctx context.Context, aCookie uint64, aUniVlanRuleParams uniVlanRuleParams) (bool, bool) {
+func (oFsm *UniVlanConfigFsm) reviseFlowConstellation(ctx context.Context, aCookie uint64, aUniVlanRuleParams cmn.UniVlanRuleParams) (bool, bool) {
flowEntryMatch := false
oFsm.mutexFlowParams.Lock()
defer oFsm.mutexFlowParams.Unlock()
@@ -828,8 +820,8 @@
// no activity within the FSM for OMCI processing, the deviceReason may be updated immediately
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
- // success indication without the need to write to kvStore (done already below with updated data from storePersUniFlowConfig())
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
+ // success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig())
+ go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
}
logger.Debugw(ctx, "UniVlanConfigFsm flow removal - rule persists with still valid cookies", log.Fields{
"device-id": oFsm.deviceID, "cookies": oFsm.uniVlanFlowParamsSlice[flow].CookieSlice})
@@ -843,7 +835,7 @@
}
//permanently store the modified flow config for reconcile case and immediately write to KvStore
if oFsm.pDeviceHandler != nil {
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+ if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
&oFsm.uniVlanFlowParamsSlice, true); err != nil {
logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
@@ -862,7 +854,7 @@
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
// success indication without the need to write to kvStore (no change)
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
+ go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore))
}
return nil
} //unknown cookie
@@ -873,8 +865,8 @@
// removeRuleComplete initiates the complete removal of a VLAN rule (from single cookie element)
// requires mutexFlowParams to be locked at call
func (oFsm *UniVlanConfigFsm) removeRuleComplete(ctx context.Context,
- aUniFlowParams uniVlanFlowParams, aCookie uint64) bool {
- pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+ aUniFlowParams cmn.UniVlanFlowParams, aCookie uint64) bool {
+ pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
var cancelPendingConfig bool = false
var loRemoveParams uniRemoveVlanFlowParams = uniRemoveVlanFlowParams{}
logger.Debugw(ctx, "UniVlanConfigFsm flow removal - full flow removal", log.Fields{
@@ -883,7 +875,7 @@
// as the one still waiting in the FSM as toAdd but waiting for TechProfileConfig
// so we have to check if we have to abort the outstanding AddRequest and regard the current DelRequest as done
// if the Fsm is in some other transient (config) state, we will reach the DelRequest later and correctly process it then
- if pConfigVlanStateBaseFsm.Is(vlanStWaitingTechProf) {
+ if pConfigVlanStateBaseFsm.Is(VlanStWaitingTechProf) {
logger.Debugw(ctx, "UniVlanConfigFsm was waiting for TechProf config with add-request, just aborting the outstanding add",
log.Fields{"device-id": oFsm.deviceID})
cancelPendingConfig = true
@@ -907,7 +899,7 @@
logger.Debugw(ctx, "UniVlanConfigFsm flow removal requested - set TechProfile to-delete", log.Fields{
"device-id": oFsm.deviceID})
if oFsm.pUniTechProf != nil {
- oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, usedTpID, true)
+ oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true)
}
oFsm.mutexFlowParams.Lock()
}
@@ -919,12 +911,12 @@
//trigger the FSM to remove the relevant rule
if cancelPendingConfig {
//as the uniFlow parameters are already stored (for add) but no explicit removal is done anymore
- // the paramSlice has to be updated with rule-removal, which also then updates numUniFlows
+ // the paramSlice has to be updated with rule-removal, which also then updates NumUniFlows
//call from 'non-configured' state of the rules
if err := oFsm.removeFlowFromParamsSlice(ctx, aCookie, false); err != nil {
//something quite inconsistent detected, perhaps just try to recover with FSM reset
oFsm.mutexFlowParams.Unlock()
- if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvReset); fsmErr != nil {
+ if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvReset); fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
@@ -935,23 +927,23 @@
//attention: take care to release and re-take the mutexFlowParams when calling the FSM directly -
// synchronous FSM 'event/state' functions may rely on this mutex
oFsm.mutexFlowParams.Unlock()
- if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvCancelOutstandingConfig); fsmErr != nil {
+ if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvCancelOutstandingConfig); fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
oFsm.mutexFlowParams.Lock()
return true
}
- if pConfigVlanStateBaseFsm.Is(vlanStConfigDone) {
+ if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) {
logger.Debugw(ctx, "UniVlanConfigFsm rule removal request", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"tp-id": loRemoveParams.vlanRuleParams.TpID,
"set-Vlan": loRemoveParams.vlanRuleParams.SetVid})
//have to re-trigger the FSM to proceed with outstanding incremental flow configuration
//attention: take care to release and re-take the mutexFlowParams when calling the FSM directly -
// synchronous FSM 'event/state' functions may rely on this mutex
oFsm.mutexFlowParams.Unlock()
- if fsmErr := pConfigVlanStateBaseFsm.Event(vlanEvRemFlowConfig); fsmErr != nil {
+ if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRemFlowConfig); fsmErr != nil {
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!",
log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID})
}
@@ -999,17 +991,17 @@
//remove the actual element from the addVlanFlow slice
// oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = nil //automatically done by garbage collector
if len(oFsm.uniVlanFlowParamsSlice) <= 1 {
- oFsm.numUniFlows = 0 //no more flows
- oFsm.configuredUniFlow = 0 //no more flows configured
+ oFsm.NumUniFlows = 0 //no more flows
+ oFsm.ConfiguredUniFlow = 0 //no more flows configured
oFsm.uniVlanFlowParamsSlice = nil //reset the slice
//at this point it is evident that no flow anymore refers to a still possibly active Techprofile
//request that this profile gets deleted before a new flow add is allowed
logger.Debugw(ctx, "UniVlanConfigFsm flow removal from ParamsSlice - no more flows", log.Fields{
"device-id": oFsm.deviceID})
} else {
- oFsm.numUniFlows--
- if aWasConfigured && oFsm.configuredUniFlow > 0 {
- oFsm.configuredUniFlow--
+ oFsm.NumUniFlows--
+ if aWasConfigured && oFsm.ConfiguredUniFlow > 0 {
+ oFsm.ConfiguredUniFlow--
}
//cut off the requested flow by slicing out this element
oFsm.uniVlanFlowParamsSlice = append(
@@ -1027,7 +1019,7 @@
}
//if the cookie was found and removed from uniVlanFlowParamsSlice above now write the modified persistency data
// KVStore update will be done after reaching the requested FSM end state (not immediately here)
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
+ if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID,
&oFsm.uniVlanFlowParamsSlice, false); err != nil {
logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
@@ -1056,7 +1048,7 @@
oFsm.mutexFlowParams.Unlock()
if oFsm.pUniTechProf != nil {
//request that this profile gets deleted before a new flow add is allowed
- oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, usedTpID, true)
+ oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true)
}
oFsm.mutexFlowParams.Lock()
}
@@ -1072,20 +1064,20 @@
// start go routine for processing of LockState messages
go oFsm.processOmciVlanMessages(ctx)
//let the state machine run forward from here directly
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm != nil {
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
logger.Debugw(ctx, "reconciling - skip omci-config of vlan rule",
- log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+ log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvSkipOmciConfig)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvSkipOmciConfig)
}(pConfigVlanStateAFsm)
return
}
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvPrepareDone)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvPrepareDone)
}(pConfigVlanStateAFsm)
return
}
@@ -1096,7 +1088,7 @@
func (oFsm *UniVlanConfigFsm) enterConfigStarting(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "UniVlanConfigFsm start vlan configuration", log.Fields{"device-id": oFsm.deviceID})
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm != nil {
oFsm.mutexFlowParams.Lock()
//possibly the entry is not valid anymore based on intermediate delete requests
@@ -1106,8 +1098,8 @@
logger.Debugw(ctx, "UniVlanConfigFsm start: no rule entry anymore available", log.Fields{
"device-id": oFsm.deviceID})
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvReset)
}(pConfigVlanStateAFsm)
return
}
@@ -1118,27 +1110,27 @@
tpID := oFsm.actualUniVlanConfigRule.TpID
oFsm.TpIDWaitingFor = tpID
//cmp also usage in EVTOCDE create in omci_cc
- oFsm.evtocdID = macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo)
+ oFsm.evtocdID = cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo)
loSetVlan := oFsm.actualUniVlanConfigRule.SetVid
//attention: take care to release the mutexFlowParams when calling the FSM directly -
// synchronous FSM 'event/state' functions may rely on this mutex
// but it must be released already before calling getTechProfileDone() as it may already be locked
// by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
oFsm.mutexFlowParams.Unlock()
- loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID))
+ loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID))
logger.Debugw(ctx, "UniVlanConfigFsm - start with first rule", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
// Can't call FSM Event directly, decoupling it
- go func(aPAFsm *AdapterFsm, aTechProfDone bool) {
- if aPAFsm != nil && aPAFsm.pFsm != nil {
+ go func(aPAFsm *cmn.AdapterFsm, aTechProfDone bool) {
+ if aPAFsm != nil && aPAFsm.PFsm != nil {
if aTechProfDone {
// let the vlan processing begin
- _ = aPAFsm.pFsm.Event(vlanEvStartConfig)
+ _ = aPAFsm.PFsm.Event(VlanEvStartConfig)
} else {
// set to waiting for Techprofile
- _ = aPAFsm.pFsm.Event(vlanEvWaitTechProf)
+ _ = aPAFsm.PFsm.Event(VlanEvWaitTechProf)
}
}
}(pConfigVlanStateAFsm, loTechProfDone)
@@ -1160,19 +1152,19 @@
logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
// let the FSM proceed ... (from within this state all internal pointers may be expected to be correct)
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvRxConfigVtfd)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvRxConfigVtfd)
}(pConfigVlanStateAFsm)
} 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, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+ vtfdID, _ := cmn.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,
- "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+ "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()
@@ -1190,16 +1182,16 @@
logger.Debugw(ctx, "UniVlanConfigFsm sendcreate VTFD", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvReset)
}(pConfigVlanStateAFsm)
}
return
@@ -1226,37 +1218,37 @@
oFsm.mutexFlowParams.RLock()
tpID := oFsm.actualUniVlanConfigRule.TpID
vlanID := oFsm.actualUniVlanConfigRule.SetVid
- configuredUniFlows := oFsm.configuredUniFlow
+ configuredUniFlows := oFsm.ConfiguredUniFlow
// ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it)
oFsm.mutexFlowParams.RUnlock()
- for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+ for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) {
logger.Infow(ctx, "Setting multicast MEs, with first flow", log.Fields{"deviceID": oFsm.deviceID,
- "techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "configuredUniFlow": configuredUniFlows})
+ "techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "ConfiguredUniFlow": configuredUniFlows})
errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort,
vlanID)
if errCreateAllMulticastME != nil {
logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
}
}
//If this first flow contains a meter, then create TD for related gems.
if oFsm.actualUniVlanConfigMeter != nil {
logger.Debugw(ctx, "Creating Traffic Descriptor", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter})
- for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.uniID, tpID) {
+ for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) {
logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter, "gem": gemPort})
errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniVlanConfigMeter, tpID,
- oFsm.pOnuUniPort.uniID, gemPort)
+ oFsm.pOnuUniPort.UniID, gemPort)
if errCreateTrafficDescriptor != nil {
logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
}
}
}
//TODO Possibly insert new state for multicast --> possibly another jira/later time.
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd)
}
}()
}
@@ -1267,8 +1259,8 @@
logger.Infow(ctx, "UniVlanConfigFsm config done - checking on more flows", log.Fields{
"device-id": oFsm.deviceID,
- "overall-uni-rules": oFsm.numUniFlows, "configured-uni-rules": oFsm.configuredUniFlow})
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ "overall-uni-rules": oFsm.NumUniFlows, "configured-uni-rules": oFsm.ConfiguredUniFlow})
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm == nil {
oFsm.mutexFlowParams.Unlock()
logger.Errorw(ctx, "UniVlanConfigFsm abort: invalid FSM pointer", log.Fields{
@@ -1276,59 +1268,59 @@
//should never happen, else: recovery would be needed from outside the FSM
return
}
- pConfigVlanStateBaseFsm := pConfigVlanStateAFsm.pFsm
+ pConfigVlanStateBaseFsm := pConfigVlanStateAFsm.PFsm
if len(oFsm.uniRemoveFlowsSlice) > 0 {
//some further flows are to be removed, removal always starts with the first element
logger.Debugw(ctx, "UniVlanConfigFsm rule removal from ConfigDone", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"tp-id": oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.TpID,
"set-Vlan": oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.SetVid})
oFsm.mutexFlowParams.Unlock()
// Can't call FSM Event directly, decoupling it
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvRemFlowConfig)
+ _ = a_pBaseFsm.Event(VlanEvRemFlowConfig)
}(pConfigVlanStateBaseFsm)
return
}
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
- oFsm.configuredUniFlow = oFsm.numUniFlows
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
+ oFsm.ConfiguredUniFlow = oFsm.NumUniFlows
if oFsm.lastFlowToReconcile {
logger.Debugw(ctx, "reconciling - flow processing finished", log.Fields{"device-id": oFsm.deviceID})
- oFsm.pDeviceHandler.setReconcilingFlows(false)
- oFsm.pDeviceHandler.chReconcilingFlowsFinished <- true
+ oFsm.pOnuDeviceEntry.SetReconcilingFlows(false)
+ oFsm.pOnuDeviceEntry.SetChReconcilingFlowsFinished(true)
}
logger.Debugw(ctx, "reconciling - skip enterVlanConfigDone processing",
- log.Fields{"numUniFlows": oFsm.numUniFlows, "configuredUniFlow": oFsm.configuredUniFlow, "device-id": oFsm.deviceID})
+ log.Fields{"NumUniFlows": oFsm.NumUniFlows, "ConfiguredUniFlow": oFsm.ConfiguredUniFlow, "device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Unlock()
return
}
- if oFsm.numUniFlows > oFsm.configuredUniFlow {
- if oFsm.configuredUniFlow == 0 {
+ if oFsm.NumUniFlows > oFsm.ConfiguredUniFlow {
+ if oFsm.ConfiguredUniFlow == 0 {
oFsm.mutexFlowParams.Unlock()
// this is a restart with a complete new flow, we can re-use the initial flow config control
// including the check, if the related techProfile is (still) available (probably also removed in between)
// Can't call FSM Event directly, decoupling it
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvRenew)
+ _ = a_pBaseFsm.Event(VlanEvRenew)
}(pConfigVlanStateBaseFsm)
return
}
//some further flows are to be configured
//store the actual rule that shall be worked upon in the following transient states
- if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.configuredUniFlow) {
+ if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) {
//check introduced after having observed some panic in this processing
logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm in ConfigDone - inconsistent counter",
- log.Fields{"configuredUniFlow": oFsm.configuredUniFlow,
+ log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow,
"sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Unlock()
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvReset)
}(pConfigVlanStateAFsm)
return
}
- oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams
- oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].Meter
+ oFsm.actualUniVlanConfigRule = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].VlanRuleParams
+ oFsm.actualUniVlanConfigMeter = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow].Meter
//tpId of the next rule to be configured
tpID := oFsm.actualUniVlanConfigRule.TpID
oFsm.TpIDWaitingFor = tpID
@@ -1338,19 +1330,19 @@
// but it must be released already before calling getTechProfileDone() as it may already be locked
// by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207)
oFsm.mutexFlowParams.Unlock()
- loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, tpID)
+ loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID)
logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request", log.Fields{
- "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
+ "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID,
"set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone})
// Can't call FSM Event directly, decoupling it
go func(aPBaseFsm *fsm.FSM, aTechProfDone bool) {
if aTechProfDone {
// let the vlan processing continue with next rule
- _ = aPBaseFsm.Event(vlanEvIncrFlowConfig)
+ _ = aPBaseFsm.Event(VlanEvIncrFlowConfig)
} else {
// set to waiting for Techprofile
- _ = aPBaseFsm.Event(vlanEvWaitTPIncr)
+ _ = aPBaseFsm.Event(VlanEvWaitTPIncr)
}
}(pConfigVlanStateBaseFsm, loTechProfDone)
return
@@ -1363,23 +1355,23 @@
// note: 'flowPushed' event is only generated if all 'pending' rules are configured
if oFsm.pDeviceHandler != nil {
//making use of the add->remove successor enum assumption/definition
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset))
+ go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset))
}
}
func (oFsm *UniVlanConfigFsm) enterConfigIncrFlow(ctx context.Context, e *fsm.Event) {
- if oFsm.pDeviceHandler.isSkipOnuConfigReconciling() {
+ if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() {
logger.Debugw(ctx, "reconciling - skip further processing for incremental flow",
- log.Fields{"fsmState": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+ log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvSkipIncFlowConfig)
- }(oFsm.pAdaptFsm.pFsm)
+ _ = a_pBaseFsm.Event(VlanEvSkipIncFlowConfig)
+ }(oFsm.PAdaptFsm.PFsm)
return
}
oFsm.mutexFlowParams.Lock()
logger.Debugw(ctx, "UniVlanConfigFsm - start config further incremental flow", log.Fields{
- "recent flow-number": oFsm.configuredUniFlow,
+ "recent flow-number": oFsm.ConfiguredUniFlow,
"device-id": oFsm.deviceID})
oFsm.TpIDWaitingFor = 0 //reset indication to avoid misinterpretation
@@ -1395,12 +1387,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, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+ vtfdID, _ := cmn.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),
"device-id": oFsm.deviceID,
- "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+ "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)
@@ -1416,17 +1408,17 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
oFsm.mutexFlowParams.Unlock()
logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvReset)
}(pConfigVlanStateAFsm)
}
return
@@ -1441,12 +1433,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, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
+ vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniVlanConfigRule.TpID))
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"device-id": oFsm.deviceID,
- "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": oFsm.actualUniVlanConfigRule.TpID})
+ "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)
@@ -1467,14 +1459,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
oFsm.mutexFlowParams.Unlock()
logger.Errorw(ctx, "UniVlanFsm create Vlan Tagging Filter ME result error",
log.Fields{"device-id": oFsm.deviceID, "Error": err})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -1491,10 +1483,10 @@
oFsm.mutexFlowParams.Unlock()
logger.Errorw(ctx, "VTFD create/set failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
+ pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
// Can't call FSM Event directly, decoupling it
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvReset)
+ _ = a_pBaseFsm.Event(VlanEvReset)
}(pConfigVlanStateBaseFsm)
return
}
@@ -1505,41 +1497,41 @@
go func() {
oFsm.mutexFlowParams.RLock()
tpID := oFsm.actualUniVlanConfigRule.TpID
- configuredUniFlow := oFsm.configuredUniFlow
+ ConfiguredUniFlow := oFsm.ConfiguredUniFlow
// ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it)
oFsm.mutexFlowParams.RUnlock()
- errEvto := oFsm.performConfigEvtocdEntries(ctx, configuredUniFlow)
+ errEvto := oFsm.performConfigEvtocdEntries(ctx, ConfiguredUniFlow)
//This is correct passing scenario
if errEvto == nil {
//TODO Possibly insert new state for multicast --> possibly another jira/later time.
- for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+ for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) {
oFsm.mutexFlowParams.RLock()
vlanID := oFsm.actualUniVlanConfigRule.SetVid
logger.Infow(ctx, "Setting multicast MEs for additional flows", log.Fields{"deviceID": oFsm.deviceID,
"techProfile": tpID, "gemPort": gemPort,
- "vlanID": vlanID, "configuredUniFlow": configuredUniFlow})
+ "vlanID": vlanID, "ConfiguredUniFlow": ConfiguredUniFlow})
oFsm.mutexFlowParams.RUnlock()
errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort, vlanID)
if errCreateAllMulticastME != nil {
logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
}
}
//If this incremental flow contains a meter, then create TD for related gems.
if oFsm.actualUniVlanConfigMeter != nil {
- for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.uniID, tpID) {
+ for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) {
logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniVlanConfigMeter, "gem": gemPort})
errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniVlanConfigMeter, tpID,
- oFsm.pOnuUniPort.uniID, gemPort)
+ oFsm.pOnuUniPort.UniID, gemPort)
if errCreateTrafficDescriptor != nil {
logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
}
}
}
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigEvtocd)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd)
}
}()
}
@@ -1550,8 +1542,8 @@
"with last cookie": oFsm.uniRemoveFlowsSlice[0].cookie,
"device-id": oFsm.deviceID})
- pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
- loAllowSpecificOmciConfig := oFsm.pDeviceHandler.isReadyForOmciConfig()
+ pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm
+ loAllowSpecificOmciConfig := oFsm.pDeviceHandler.IsReadyForOmciConfig()
loVlanEntryClear := uint8(0)
loVlanEntryRmPos := uint8(0x80) //with indication 'invalid' in bit 7
//shallow copy is sufficient as no reference variables are used within struct
@@ -1569,30 +1561,30 @@
} else {
vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization and 're-copy'
if oFsm.numVlanFilterEntries == 1 {
- vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
+ vtfdID, _ := cmn.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, "EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"device-id": oFsm.deviceID,
- "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
+ "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()
- meInstance, err := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, vtfdID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, vtfdID)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error",
log.Fields{"device-id": oFsm.deviceID, "Error": err})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
oFsm.pLastTxMeInstance = meInstance
oFsm.mutexPLastTxMeInstance.Unlock()
} else {
logger.Debugw(ctx, "UniVlanConfigFsm delete VTFD OMCI handling skipped based on device state", log.Fields{
- "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.getDeviceReasonString()})
+ "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()})
}
} else {
//many VTFD already should exists - find and remove the one concerned by the actual remove rule
@@ -1607,7 +1599,7 @@
}
}
if loVlanEntryRmPos < cVtfdTableSize {
- vtfdID, _ := generateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo), uint16(loRuleParams.TpID))
+ vtfdID, _ := cmn.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++ {
@@ -1622,25 +1614,25 @@
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"new vlan list": vtfdFilterList, "device-id": oFsm.deviceID,
- "macBpNo": oFsm.pOnuUniPort.macBpNo, "TpID": loRuleParams.TpID})
+ "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
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, vtfdID)
+ meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, vtfdID)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error",
log.Fields{"device-id": oFsm.deviceID, "Error": err})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
oFsm.pLastTxMeInstance = meInstance
oFsm.mutexPLastTxMeInstance.Unlock()
} else {
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD OMCI handling skipped based on device state", log.Fields{
- "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.getDeviceReasonString()})
+ "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()})
}
} else {
logger.Warnw(ctx, "UniVlanConfigFsm: requested VLAN for removal not found in list - ignore and continue (no VTFD set)",
@@ -1656,7 +1648,7 @@
log.Fields{"device-id": oFsm.deviceID})
// Can't call FSM Event directly, decoupling it
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvReset)
+ _ = a_pBaseFsm.Event(VlanEvReset)
}(pConfigVlanStateBaseFsm)
return
}
@@ -1686,7 +1678,7 @@
"device-id": oFsm.deviceID})
// Can't call FSM Event directly, decoupling it
go func(a_pBaseFsm *fsm.FSM) {
- _ = a_pBaseFsm.Event(vlanEvRemFlowDone, loRuleParams.TpID)
+ _ = a_pBaseFsm.Event(VlanEvRemFlowDone, loRuleParams.TpID)
}(pConfigVlanStateBaseFsm)
}
}
@@ -1703,7 +1695,7 @@
oFsm.mutexFlowParams.Lock()
deletedCookie := oFsm.uniRemoveFlowsSlice[0].cookie
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm == nil {
logger.Errorw(ctx, "invalid Fsm pointer - unresolvable - abort",
log.Fields{"device-id": oFsm.deviceID})
@@ -1718,8 +1710,8 @@
//something quite inconsistent detected, perhaps just try to recover with FSM reset
oFsm.mutexFlowParams.Unlock()
logger.Errorw(ctx, "UniVlanConfigFsm - could not clear database - abort", log.Fields{"device-id": oFsm.deviceID})
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvReset)
}(pConfigVlanStateAFsm)
return
}
@@ -1751,8 +1743,8 @@
oFsm.requestEventOffset = uint8(cDeviceEventOffsetRemoveWithKvStore) //offset for last flow-remove activity (with kvStore request)
//return to the basic config verification state
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(vlanEvFlowDataRemoved)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(VlanEvFlowDataRemoved)
}(pConfigVlanStateAFsm)
oFsm.mutexFlowParams.Lock()
@@ -1781,22 +1773,22 @@
func (oFsm *UniVlanConfigFsm) enterResetting(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "UniVlanConfigFsm resetting", log.Fields{"device-id": oFsm.deviceID})
- pConfigVlanStateAFsm := oFsm.pAdaptFsm
+ pConfigVlanStateAFsm := oFsm.PAdaptFsm
if pConfigVlanStateAFsm != nil {
// abort running message processing
- fsmAbortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ fsmAbortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
- pConfigVlanStateAFsm.commChan <- fsmAbortMsg
+ pConfigVlanStateAFsm.CommChan <- fsmAbortMsg
//try to restart the FSM to 'disabled'
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(vlanEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(VlanEvRestart)
}
}(pConfigVlanStateAFsm)
}
@@ -1836,8 +1828,8 @@
if oFsm.clearPersistency {
//permanently remove possibly stored persistent data
if len(oFsm.uniVlanFlowParamsSlice) > 0 {
- var emptySlice = make([]uniVlanFlowParams, 0)
- _ = oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID, &emptySlice, true) //ignore errors
+ var emptySlice = make([]cmn.UniVlanFlowParams, 0)
+ _ = oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, &emptySlice, true) //ignore errors
}
} else {
logger.Debugw(ctx, "UniVlanConfigFsm persistency data not cleared", log.Fields{"device-id": oFsm.deviceID})
@@ -1857,25 +1849,25 @@
// case <-ctx.Done():
// logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
- message, ok := <-oFsm.pAdaptFsm.commChan
+ message, ok := <-oFsm.PAdaptFsm.CommChan
if !ok {
logger.Info(ctx, "UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
break loop
}
logger.Debugw(ctx, "UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Infow(ctx, "UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
logger.Warnw(ctx, "UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oFsm.handleOmciVlanConfigMessage(ctx, msg)
default:
logger.Warn(ctx, "UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1885,7 +1877,7 @@
logger.Infow(ctx, "End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "Rx OMCI UniVlanConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
@@ -1991,9 +1983,9 @@
"ExtendedVlanTaggingOperationConfigurationData", "TrafficDescriptor":
{
oFsm.mutexPLastTxMeInstance.RUnlock()
- if oFsm.pAdaptFsm.pFsm.Current() == vlanStConfigVtfd {
+ if oFsm.PAdaptFsm.PFsm.Current() == VlanStConfigVtfd {
// Only if CreateResponse is received from first flow entry - let the FSM proceed ...
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRxConfigVtfd)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigVtfd)
} else { // let the MultiEntity config proceed by stopping the wait function
oFsm.omciMIdsResponseReceived <- true
}
@@ -2074,8 +2066,8 @@
"EntitytId": strconv.FormatInt(int64(evtocdID), 16),
"i/oEthType": strconv.FormatInt(int64(cDefaultTpid), 16),
"device-id": oFsm.deviceID})
- associationType := 2 // default to uniPPTP
- if oFsm.pOnuUniPort.portType == uniVEIP {
+ associationType := 2 // default to UniPPTP
+ if oFsm.pOnuUniPort.PortType == cmn.UniVEIP {
associationType = 10
}
// Create the EVTOCD ME
@@ -2083,17 +2075,17 @@
EntityID: evtocdID,
Attributes: me.AttributeValueMap{
"AssociationType": uint8(associationType),
- "AssociatedMePointer": oFsm.pOnuUniPort.entityID,
+ "AssociatedMePointer": oFsm.pOnuUniPort.EntityID,
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateEvtocdVar(context.TODO(), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateEvtocdVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "CreateEvtocdVar create failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance create failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2106,7 +2098,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd create failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd create failed %s, error %s", oFsm.deviceID, err)
}
@@ -2120,14 +2112,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err = oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err = oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2140,7 +2132,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd set TPID failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd set TPID failed %s, error %s", oFsm.deviceID, err)
}
} //first flow element
@@ -2182,14 +2174,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2202,7 +2194,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd set transparent singletagged rule failed %s, error %s", oFsm.deviceID, err)
}
@@ -2248,14 +2240,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2268,7 +2260,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd set singletagged translation rule failed %s, error %s", oFsm.deviceID, err)
}
} else {
@@ -2310,14 +2302,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2330,7 +2322,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd set untagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
}
@@ -2373,14 +2365,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2393,7 +2385,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("evtocd set priotagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
}
@@ -2404,12 +2396,12 @@
// if Config has been done for all EVTOCD entries let the FSM proceed
logger.Debugw(ctx, "EVTOCD set loop finished", log.Fields{"device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Lock()
- oFsm.configuredUniFlow++ // one (more) flow configured
+ oFsm.ConfiguredUniFlow++ // one (more) flow configured
oFsm.mutexFlowParams.Unlock()
return nil
}
-func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams uniVlanRuleParams) {
+func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams cmn.UniVlanRuleParams) {
oFsm.mutexFlowParams.RLock()
evtocdID := oFsm.evtocdID
oFsm.mutexFlowParams.RUnlock()
@@ -2452,14 +2444,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -2472,7 +2464,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd reset singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
} else {
@@ -2507,14 +2499,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -2527,7 +2519,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd clear singletagged translation rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
} else {
@@ -2541,7 +2533,7 @@
// there is only one service vlan (oFsm.acceptIncrementalEvtoOption is false in this case).
// Interstingly this problem has not been observed in multi-tcont (or multi-service) scenario (in
// which case the oFsm.acceptIncrementalEvtoOption is set to true).
- if oFsm.configuredUniFlow == 1 && !oFsm.acceptIncrementalEvtoOption {
+ if oFsm.ConfiguredUniFlow == 1 && !oFsm.acceptIncrementalEvtoOption {
oFsm.mutexFlowParams.RUnlock()
logger.Debugw(ctx, "UniVlanConfigFsm Tx Remove::EVTOCD", log.Fields{"device-id": oFsm.deviceID})
// When there are no more EVTOCD vlan configurations on the ONU and acceptIncrementalEvtoOption
@@ -2550,14 +2542,14 @@
EntityID: evtocdID,
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "DeleteEvtocdVar delete failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -2570,14 +2562,14 @@
if err != nil {
logger.Errorw(ctx, "Evtocd delete rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
} else {
// NOTE : We should ideally never ether this section when oFsm.acceptIncrementalEvtoOption is set to false
// This is true for only ATT/DT workflow
logger.Debugw(ctx, "UniVlanConfigFsm: Remove EVTOCD set operation",
- log.Fields{"configured-flow": oFsm.configuredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption})
+ log.Fields{"configured-flow": oFsm.ConfiguredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption})
oFsm.mutexFlowParams.RUnlock()
//not transparent and not acceptIncrementalEvtoOption: untagged/priotagged->singletagged
{ // just for local var's
@@ -2619,14 +2611,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -2639,7 +2631,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd reset untagged rule to default failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
} // just for local var's
@@ -2671,14 +2663,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
//accept also nil as (error) return value for writing to LastTx
@@ -2691,7 +2683,7 @@
if err != nil {
logger.Errorw(ctx, "Evtocd delete priotagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return
}
}
@@ -2700,7 +2692,7 @@
}
// if Config has been done for all EVTOCD entries let the FSM proceed
logger.Debugw(ctx, "EVTOCD filter remove loop finished", log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRemFlowDone, aRuleParams.TpID)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRemFlowDone, aRuleParams.TpID)
}
func (oFsm *UniVlanConfigFsm) waitforOmciResponse(ctx context.Context) error {
@@ -2709,7 +2701,7 @@
// FSM already canceled before entering wait
logger.Debugw(ctx, "UniVlanConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID})
oFsm.mutexIsAwaitingResponse.Unlock()
- return fmt.Errorf(cErrWaitAborted)
+ return fmt.Errorf(cmn.CErrWaitAborted)
}
oFsm.isAwaitingResponse = true
oFsm.mutexIsAwaitingResponse.Unlock()
@@ -2736,7 +2728,7 @@
oFsm.mutexIsAwaitingResponse.Lock()
oFsm.isAwaitingResponse = false
oFsm.mutexIsAwaitingResponse.Unlock()
- return fmt.Errorf(cErrWaitAborted)
+ return fmt.Errorf(cmn.CErrWaitAborted)
}
}
@@ -2747,7 +2739,7 @@
if errCreateMOP != nil {
logger.Errorw(ctx, "MulticastOperationProfile create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMOP)
}
@@ -2755,7 +2747,7 @@
if errSettingMOP != nil {
logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errSettingMOP)
}
@@ -2763,37 +2755,37 @@
if errCreateMSCI != nil {
logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMSCI)
}
- macBpCdEID, errMacBpCdEID := generateMcastANISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+ macBpCdEID, errMacBpCdEID := cmn.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)
+ _ = 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})
+ "EntitytId": strconv.FormatInt(int64(macBpCdEID), 16), "macBpNo": oFsm.pOnuUniPort.MacBpNo,
+ "in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
meParams := me.ParamData{
EntityID: macBpCdEID,
Attributes: me.AttributeValueMap{
- "BridgeIdPointer": macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo),
+ "BridgeIdPointer": cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo),
"PortNum": 0xf0, //fixed unique ANI side indication
"TpType": 6, //MCGemIWTP
"TpPointer": multicastGemPortID,
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateMBPConfigDataVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo createError #{oFsm.deviceID}, error #{err}")
}
//accept also nil as (error) return value for writing to LastTx
@@ -2803,8 +2795,8 @@
err = oFsm.waitforOmciResponse(ctx)
if err != nil {
logger.Errorw(ctx, "CreateMBPConfigData failed, aborting AniConfig FSM!",
- log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": macBridgeServiceProfileEID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": cmn.MacBridgeServiceProfileEID})
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, err)
}
@@ -2816,7 +2808,7 @@
logger.Debugw(ctx, "UniVlanConfigFsm set VTFD for mcast", log.Fields{
"EntitytId": strconv.FormatInt(int64(mcastVtfdID), 16), "mcastVlanID": vlanID,
- "in state": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
+ "in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID})
vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization
// FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME
@@ -2833,13 +2825,13 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err = oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err = oFsm.pOmciCC.SendCreateVtfdVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "CreateVtfdVar create failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("createMcastVlanFilterData creationError %s, error %s", oFsm.deviceID, err)
}
oFsm.pLastTxMeInstance = meInstance
@@ -2848,7 +2840,7 @@
if err != nil {
logger.Errorw(ctx, "CreateMcastVlanFilterData failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "mcastVtfdID": mcastVtfdID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("createMcastVlanFilterData responseError %s, error %s", oFsm.deviceID, err)
}
@@ -2856,7 +2848,7 @@
}
func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo(ctx context.Context) error {
- instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+ instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
if err != nil {
logger.Errorw(ctx, "error generrating me instance id",
log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2874,14 +2866,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateMulticastSubConfigInfoVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateMulticastSubConfigInfoVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "CreateMulticastSubConfigInfoVar create failed, aborting UniVlanConfigFSM!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo interface creationError %s, error %s",
oFsm.deviceID, err)
}
@@ -2900,7 +2892,7 @@
}
func (oFsm *UniVlanConfigFsm) performCreatingMulticastOperationProfile(ctx context.Context) error {
- instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+ instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
if err != nil {
logger.Errorw(ctx, "error generating me instance id",
log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2925,14 +2917,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendCreateMulticastOperationProfileVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendCreateMulticastOperationProfileVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "CreateMulticastOperationProfileVar create failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("createMulticastOperationProfileVar responseError %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -2950,7 +2942,7 @@
}
func (oFsm *UniVlanConfigFsm) performSettingMulticastOperationProfile(ctx context.Context, multicastGemPortID uint16, vlanID uint32) error {
- instID, err := generateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.macBpNo))
+ instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo))
if err != nil {
logger.Errorw(ctx, "error generating me instance id",
log.Fields{"device-id": oFsm.deviceID, "error": err})
@@ -2965,7 +2957,7 @@
//test = 0
//rowKey = 0
tableCtrlStr := "0100000000000000"
- tableCtrl := AsByteSlice(tableCtrlStr)
+ tableCtrl := cmn.AsByteSlice(tableCtrlStr)
dynamicAccessCL := make([]uint8, 24)
copy(dynamicAccessCL, tableCtrl)
//Multicast GemPortId
@@ -2974,12 +2966,12 @@
// brcm_openomci_onu_handler.py
binary.BigEndian.PutUint16(dynamicAccessCL[4:], uint16(vlanID))
//Source IP all to 0
- binary.BigEndian.PutUint32(dynamicAccessCL[6:], IPToInt32(net.IPv4(0, 0, 0, 0)))
+ binary.BigEndian.PutUint32(dynamicAccessCL[6:], cmn.IPToInt32(net.IPv4(0, 0, 0, 0)))
//TODO start and end are hardcoded, get from TP
// Destination IP address start of range
- binary.BigEndian.PutUint32(dynamicAccessCL[10:], IPToInt32(net.IPv4(225, 0, 0, 0)))
+ binary.BigEndian.PutUint32(dynamicAccessCL[10:], cmn.IPToInt32(net.IPv4(225, 0, 0, 0)))
// Destination IP address end of range
- binary.BigEndian.PutUint32(dynamicAccessCL[14:], IPToInt32(net.IPv4(239, 255, 255, 255)))
+ binary.BigEndian.PutUint32(dynamicAccessCL[14:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255)))
//imputed group bandwidth
binary.BigEndian.PutUint16(dynamicAccessCL[18:], 0)
@@ -2990,14 +2982,14 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetMulticastOperationProfileVar(context.TODO(),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetMulticastOperationProfileVar(context.TODO(),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetMulticastOperationProfileVar set failed, aborting UniVlanConfigFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset)
return fmt.Errorf("setMulticastOperationProfile responseError %s, error %s", oFsm.deviceID, err)
}
//accept also nil as (error) return value for writing to LastTx
@@ -3049,8 +3041,8 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, errCreateTD := oFsm.pOmciCC.sendCreateTDVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, errCreateTD := oFsm.pOmciCC.SendCreateTDVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, oFsm.PAdaptFsm.CommChan, meParams)
if errCreateTD != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "Traffic Descriptor create failed", log.Fields{"device-id": oFsm.deviceID})
@@ -3085,8 +3077,8 @@
},
}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx),
- oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, oFsm.pAdaptFsm.commChan, meParams)
+ meInstance, err := oFsm.pOmciCC.SendSetGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx),
+ oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "GemNCTP set failed", log.Fields{"device-id": oFsm.deviceID})
diff --git a/internal/pkg/onuadaptercore/onu_uni_tp.go b/internal/pkg/avcfg/onu_uni_tp.go
old mode 100644
new mode 100755
similarity index 88%
rename from internal/pkg/onuadaptercore/onu_uni_tp.go
rename to internal/pkg/avcfg/onu_uni_tp.go
index 1e3f9af..efb69be
--- a/internal/pkg/onuadaptercore/onu_uni_tp.go
+++ b/internal/pkg/avcfg/onu_uni_tp.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package avcfg provides anig and vlan configuration functionality
+package avcfg
import (
"context"
@@ -25,6 +25,7 @@
"sync"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/tech_profile"
)
@@ -37,11 +38,13 @@
//binaryBit1 = '1'
)
-type resourceEntry int
+// ResourceEntry - TODO: add comment
+type ResourceEntry int
+// TODO: add comment
const (
- cResourceGemPort resourceEntry = 1
- cResourceTcont resourceEntry = 2
+ CResourceGemPort ResourceEntry = 1
+ CResourceTcont ResourceEntry = 2
)
type tTechProfileIndication struct {
@@ -87,15 +90,16 @@
tpID uint8
}
-//onuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU
-type onuUniTechProf struct {
- baseDeviceHandler *deviceHandler
+//OnuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU
+type OnuUniTechProf struct {
deviceID string
+ baseDeviceHandler cmn.IdeviceHandler
+ onuDevice cmn.IonuDeviceEntry
tpProcMutex sync.RWMutex
chTpConfigProcessingStep chan uint8
mapUniTpIndication map[uniTP]*tTechProfileIndication //use pointer values to ease assignments to the map
mapPonAniConfig map[uniTP]*tcontGemList //per UNI: use pointer values to ease assignments to the map
- pAniConfigFsm map[uniTP]*uniPonAniConfigFsm
+ PAniConfigFsm map[uniTP]*UniPonAniConfigFsm
procResult map[uniTP]error //error indication of processing
mutexTPState sync.RWMutex
tpProfileExists map[uniTP]bool
@@ -103,8 +107,8 @@
mapRemoveGemEntry map[uniTP]*gemPortParamStruct //per UNI: pointer to GemEntry to be removed
}
-func (onuTP *onuUniTechProf) multicastConfiguredForOtherUniTps(ctx context.Context, uniTpKey uniTP) bool {
- for _, aniFsm := range onuTP.pAniConfigFsm {
+func (onuTP *OnuUniTechProf) multicastConfiguredForOtherUniTps(ctx context.Context, uniTpKey uniTP) bool {
+ for _, aniFsm := range onuTP.PAniConfigFsm {
if aniFsm.uniTpKey.uniID == uniTpKey.uniID && aniFsm.uniTpKey.tpID == uniTpKey.tpID {
continue
}
@@ -115,13 +119,15 @@
return false
}
-//newOnuUniTechProf returns the instance of a OnuUniTechProf
+//NewOnuUniTechProf returns the instance of a OnuUniTechProf
//(one instance per ONU/deviceHandler for all possible UNI's)
-func newOnuUniTechProf(ctx context.Context, aDeviceHandler *deviceHandler) *onuUniTechProf {
- logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": aDeviceHandler.deviceID})
- var onuTP onuUniTechProf
+func NewOnuUniTechProf(ctx context.Context, aDeviceHandler cmn.IdeviceHandler, aOnuDev cmn.IonuDeviceEntry) *OnuUniTechProf {
+
+ var onuTP OnuUniTechProf
+ onuTP.deviceID = aDeviceHandler.GetDeviceID()
+ logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": onuTP.deviceID})
onuTP.baseDeviceHandler = aDeviceHandler
- onuTP.deviceID = aDeviceHandler.deviceID
+ onuTP.onuDevice = aOnuDev
onuTP.chTpConfigProcessingStep = make(chan uint8)
onuTP.mapUniTpIndication = make(map[uniTP]*tTechProfileIndication)
onuTP.mapPonAniConfig = make(map[uniTP]*tcontGemList)
@@ -133,40 +139,41 @@
return &onuTP
}
-// lockTpProcMutex locks OnuUniTechProf processing mutex
-func (onuTP *onuUniTechProf) lockTpProcMutex() {
+// LockTpProcMutex locks OnuUniTechProf processing mutex
+func (onuTP *OnuUniTechProf) LockTpProcMutex() {
onuTP.tpProcMutex.Lock()
}
-// unlockTpProcMutex unlocks OnuUniTechProf processing mutex
-func (onuTP *onuUniTechProf) unlockTpProcMutex() {
+// UnlockTpProcMutex unlocks OnuUniTechProf processing mutex
+func (onuTP *OnuUniTechProf) UnlockTpProcMutex() {
onuTP.tpProcMutex.Unlock()
}
-// resetTpProcessingErrorIndication resets the internal error indication
+// ResetTpProcessingErrorIndication resets the internal error indication
// need to be called before evaluation of any subsequent processing (given by waitForTpCompletion())
-func (onuTP *onuUniTechProf) resetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) {
+func (onuTP *OnuUniTechProf) ResetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) {
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] = nil
}
-func (onuTP *onuUniTechProf) getTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error {
+// GetTpProcessingErrorIndication - TODO: add comment
+func (onuTP *OnuUniTechProf) GetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error {
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
return onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}]
}
-// configureUniTp checks existing tp resources to configure and starts the corresponding OMCI configuation of the UNI port
+// ConfigureUniTp checks existing tp resources to configure 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 synchronization
-func (onuTP *onuUniTechProf) configureUniTp(ctx context.Context,
+func (onuTP *OnuUniTechProf) ConfigureUniTp(ctx context.Context,
aUniID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, wg *sync.WaitGroup) {
defer wg.Done() //always decrement the waitGroup on return
logger.Debugw(ctx, "configure the Uni according to TpPath", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
- tpID, err := GetTpIDFromTpPath(aPathString)
+ tpID, err := cmn.GetTpIDFromTpPath(aPathString)
uniTpKey := uniTP{uniID: aUniID, tpID: tpID}
if err != nil {
logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
@@ -174,10 +181,10 @@
}
//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
- var pCurrentUniPort *onuUniPort
- for _, uniPort := range onuTP.baseDeviceHandler.uniEntityMap {
+ var pCurrentUniPort *cmn.OnuUniPort
+ for _, uniPort := range *onuTP.baseDeviceHandler.GetUniEntityMap() {
// only if this port is validated for operState transfer
- if uniPort.uniID == aUniID {
+ if uniPort.UniID == aUniID {
pCurrentUniPort = uniPort
break //found - end search loop
}
@@ -204,7 +211,7 @@
}
var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep
- //according to updateOnuUniTpPath() logic the assumption here is, that this configuration is only called
+ //according to UpdateOnuUniTpPath() logic the assumption here is, that this configuration is only called
// in case the KVPath has changed for the given UNI,
// as T-Cont and Gem-Id's are dependent on TechProfile-Id this means, that possibly previously existing
// (ANI) configuration of this port has to be removed first
@@ -280,8 +287,8 @@
//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)
- if _, ok := onuTP.pAniConfigFsm[uniTpKey]; ok {
- _ = onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm.Event(aniEvReset)
+ if _, ok := onuTP.PAniConfigFsm[uniTpKey]; ok {
+ _ = onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm.Event(aniEvReset)
}
return
}
@@ -309,7 +316,7 @@
/* internal methods *********************/
// nolint: gocyclo
-func (onuTP *onuUniTechProf) readAniSideConfigFromTechProfile(
+func (onuTP *OnuUniTechProf) readAniSideConfigFromTechProfile(
ctx context.Context, aUniID uint8, aTpID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, aProcessingStep uint8) {
var err error
//store profile type and identifier for later usage within the OMCI identifier and possibly ME setup
@@ -525,33 +532,33 @@
onuTP.chTpConfigProcessingStep <- aProcessingStep //done
}
-func (onuTP *onuUniTechProf) setAniSideConfigFromTechProfile(
- ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *onuUniPort, aProcessingStep uint8) error {
+func (onuTP *OnuUniTechProf) setAniSideConfigFromTechProfile(
+ ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *cmn.OnuUniPort, aProcessingStep uint8) error {
//OMCI transfer of ANI data acc. to mapPonAniConfig
// also the FSM's are running in background,
// hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
- if onuTP.pAniConfigFsm == nil {
- return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
- } else if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
- return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
+ if onuTP.PAniConfigFsm == nil {
+ return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep)
+ } else if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
+ return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep)
}
//AniConfigFsm already init
return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
}
-// deleteTpResource removes Resources from the ONU's specified Uni
+// DeleteTpResource removes Resources from the ONU's specified Uni
// nolint: gocyclo
-func (onuTP *onuUniTechProf) deleteTpResource(ctx context.Context,
- aUniID uint8, aTpID uint8, aPathString string, aResource resourceEntry, aEntryID uint32,
+func (onuTP *OnuUniTechProf) DeleteTpResource(ctx context.Context,
+ aUniID uint8, aTpID uint8, aPathString string, aResource ResourceEntry, aEntryID uint32,
wg *sync.WaitGroup) {
defer wg.Done()
logger.Debugw(ctx, "will remove TP resources from ONU's UNI", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "Resource": aResource})
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
- if cResourceGemPort == aResource {
+ if CResourceGemPort == aResource {
logger.Debugw(ctx, "remove GemPort from the list of existing ones of the TP", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "GemPort": aEntryID})
@@ -589,11 +596,11 @@
*/
return
}
- if onuTP.baseDeviceHandler.isReadyForOmciConfig() {
+ if onuTP.baseDeviceHandler.IsReadyForOmciConfig() {
// check that the TpConfigRequest was done before
// -> that is implicitly done using the AniConfigFsm,
// which must be in the according state to remove something
- if onuTP.pAniConfigFsm == nil {
+ if onuTP.PAniConfigFsm == nil {
logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
/* Do not set some error indication to the outside system interface on delete (see above)
@@ -610,7 +617,7 @@
onuTP.mutexTPState.Unlock()
return
}
- if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
+ if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available for this uni/tp",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
/* Do not set some error indication to the outside system interface on delete (see above)
@@ -656,8 +663,8 @@
//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)
- if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
- _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+ if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+ _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
}
//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
return
@@ -668,19 +675,19 @@
//as a consequence a possible remove-flow does not see any dependency on the TechProfile anymore and is executed (pro forma) directly
//a later TechProfile removal would cause the device-reason to be updated to 'techProfile-delete-success' which is not the expected state
// and anyway is no real useful information at that stage
- logger.Debugw(ctx, "uniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
- "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.getDeviceReasonString()})
+ logger.Debugw(ctx, "UniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
+ "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()})
}
// remove GemPort from config DB
//ensure write protection for access to mapPonAniConfig
- logger.Debugw(ctx, "uniPonAniConfigFsm removing gem from config data and clearing ani FSM", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm removing gem from config data and clearing ani FSM", log.Fields{
"device-id": onuTP.deviceID, "gem-id": onuTP.mapRemoveGemEntry[uniTPKey].removeGemID, "uniTPKey": uniTPKey})
onuTP.mutexTPState.Lock()
delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID)
// remove the removeEntry
delete(onuTP.mapRemoveGemEntry, uniTPKey)
onuTP.mutexTPState.Unlock()
- } else { //if cResourceTcont == aResource {
+ } else { //if CResourceTcont == aResource {
logger.Debugw(ctx, "reset TCont with AllocId", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "allocId": aEntryID})
@@ -710,7 +717,7 @@
//T-Cont to be reset found
logger.Debugw(ctx, "Reset-T-Cont AllocId found - valid", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "AllocId": aEntryID})
- if onuTP.pAniConfigFsm == nil {
+ if onuTP.PAniConfigFsm == nil {
logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
/* Do not set some error indication to the outside system interface on delete (see above)
@@ -719,7 +726,7 @@
*/
return
}
- if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
+ if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok {
logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available for this uni/tp",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
//even if the FSM invocation did not work we don't indicate a problem within procResult
@@ -727,7 +734,7 @@
//if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data
return
}
- if onuTP.baseDeviceHandler.isReadyForOmciConfig() {
+ if onuTP.baseDeviceHandler.IsReadyForOmciConfig() {
// check that the TpConfigRequest was done before
// -> that is implicitly done using the AniConfigFsm,
// which must be in the according state to remove something
@@ -754,24 +761,25 @@
//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)
- if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
- _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+ if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+ _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
}
//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
return
}
} else {
//see gemPort comments
- logger.Debugw(ctx, "uniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
- "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.getDeviceReasonString()})
+ logger.Debugw(ctx, "UniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
+ "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()})
}
}
}
-func (onuTP *onuUniTechProf) isTechProfileConfigCleared(ctx context.Context, uniID uint8, tpID uint8) bool {
+// IsTechProfileConfigCleared - TODO: add comment
+func (onuTP *OnuUniTechProf) IsTechProfileConfigCleared(ctx context.Context, uniID uint8, tpID uint8) bool {
uniTPKey := uniTP{uniID: uniID, tpID: tpID}
- logger.Debugw(ctx, "isTechProfileConfigCleared", log.Fields{"device-id": onuTP.deviceID})
+ logger.Debugw(ctx, "IsTechProfileConfigCleared", log.Fields{"device-id": onuTP.deviceID})
if onuTP.mapPonAniConfig[uniTPKey] != nil {
mapGemPortParams := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams
unicastGemCount := 0
@@ -784,17 +792,17 @@
logger.Debugw(ctx, "clearing-ani-side-config", log.Fields{
"device-id": onuTP.deviceID, "uniTpKey": uniTPKey})
onuTP.clearAniSideConfig(ctx, uniID, tpID)
- if _, ok := onuTP.pAniConfigFsm[uniTPKey]; ok {
- _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
+ if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok {
+ _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset)
}
- go onuTP.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved)
+ go onuTP.baseDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OmciAniResourceRemoved)
return true
}
}
return false
}
-func (onuTP *onuUniTechProf) waitForTimeoutOrCompletion(
+func (onuTP *OnuUniTechProf) waitForTimeoutOrCompletion(
ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool {
select {
case <-ctx.Done():
@@ -814,44 +822,43 @@
}
// createAniConfigFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
-func (onuTP *onuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8,
- apCurrentUniPort *onuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) error {
+func (onuTP *OnuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8,
+ apCurrentUniPort *cmn.OnuUniPort, devEvent cmn.OnuDeviceEvent, aProcessingStep uint8) error {
logger.Debugw(ctx, "createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID})
- chAniConfigFsm := make(chan Message, 2048)
+ chAniConfigFsm := make(chan cmn.Message, 2048)
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
- pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(ctx, true)
- if pDevEntry == nil {
+ if onuTP.onuDevice == nil {
logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", onuTP.deviceID)
}
- pAniCfgFsm := newUniPonAniConfigFsm(ctx, pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP,
- pDevEntry.pOnuDB, aTpID, devEvent,
- "AniConfigFsm", onuTP.baseDeviceHandler, chAniConfigFsm)
+ pAniCfgFsm := NewUniPonAniConfigFsm(ctx, onuTP.onuDevice.GetDevOmciCC(), apCurrentUniPort, onuTP,
+ onuTP.onuDevice.GetOnuDB(), aTpID, devEvent,
+ "AniConfigFsm", onuTP.baseDeviceHandler, onuTP.onuDevice, chAniConfigFsm)
if pAniCfgFsm == nil {
logger.Errorw(ctx, "AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID})
return fmt.Errorf("could not create AniConfigFSM: %s", onuTP.deviceID)
}
- if onuTP.pAniConfigFsm == nil {
- onuTP.pAniConfigFsm = make(map[uniTP]*uniPonAniConfigFsm)
+ if onuTP.PAniConfigFsm == nil {
+ onuTP.PAniConfigFsm = make(map[uniTP]*UniPonAniConfigFsm)
}
- onuTP.pAniConfigFsm[uniTPKey] = pAniCfgFsm
+ onuTP.PAniConfigFsm[uniTPKey] = pAniCfgFsm
return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
}
// runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
-func (onuTP *onuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
+func (onuTP *OnuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
/* Uni related ANI config procedure -
***** should run via 'aniConfigDone' state and generate the argument requested event *****
*/
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
- pACStatemachine := onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm
+ pACStatemachine := onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm
if pACStatemachine != nil {
if aEvent == aniEvStart {
if !pACStatemachine.Is(aniStDisabled) {
logger.Errorw(ctx, "wrong state of AniConfigFSM to start - want: Disabled", log.Fields{
"have": pACStatemachine.Current(), "device-id": onuTP.deviceID})
- // maybe try a FSM reset and then again ... - TODO!!!
+ // maybe try a FSM reset and then again ... - TODO: add comment!!!
return fmt.Errorf("wrong state of AniConfigFSM to start: %s", onuTP.deviceID)
}
} else if !pACStatemachine.Is(aniStConfigDone) {
@@ -860,7 +867,7 @@
return fmt.Errorf("wrong state of AniConfigFSM to remove: %s", onuTP.deviceID)
}
//FSM init requirement to get informed about FSM completion! (otherwise timeout of the TechProf config)
- onuTP.pAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep)
+ onuTP.PAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep)
if err := pACStatemachine.Event(aEvent); err != nil {
logger.Errorw(ctx, "AniConfigFSM: can't trigger event", log.Fields{"err": err})
return fmt.Errorf("can't trigger event in AniConfigFSM: %s", onuTP.deviceID)
@@ -871,12 +878,12 @@
return nil
}
logger.Errorw(ctx, "AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID})
- // maybe try a FSM reset and then again ... - TODO!!!
+ // maybe try a FSM reset and then again ... - TODO: add comment!!!
return fmt.Errorf("stateMachine AniConfigFSM invalid: %s", onuTP.deviceID)
}
// clearAniSideConfig deletes internal TechProfile related data connected to the requested UniPort and TpID
-func (onuTP *onuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) {
+func (onuTP *OnuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) {
logger.Debugw(ctx, "removing TpIndication and PonAniConfig data", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID})
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
@@ -892,7 +899,7 @@
}
// setConfigDone sets the requested techProfile config state (if possible)
-func (onuTP *onuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) {
+func (onuTP *OnuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
@@ -902,7 +909,7 @@
}
// getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done
-func (onuTP *onuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool {
+func (onuTP *OnuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
@@ -920,8 +927,8 @@
return false
}
-// setProfileToDelete sets the requested techProfile toDelete state (if possible)
-func (onuTP *onuUniTechProf) setProfileToDelete(aUniID uint8, aTpID uint8, aState bool) {
+// SetProfileToDelete sets the requested techProfile toDelete state (if possible)
+func (onuTP *OnuUniTechProf) SetProfileToDelete(aUniID uint8, aTpID uint8, aState bool) {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
@@ -930,8 +937,7 @@
} //else: the state is just ignored (does not exist)
}
-// setProfileToDelete sets the requested techProfile toDelete state (if possible)
-func (onuTP *onuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
+func (onuTP *OnuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
@@ -949,7 +955,7 @@
return gemPortIds
}
-func (onuTP *onuUniTechProf) getBidirectionalGemPortIDsForTP(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
+func (onuTP *OnuUniTechProf) getBidirectionalGemPortIDsForTP(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
@@ -971,7 +977,8 @@
return gemPortIds
}
-func (onuTP *onuUniTechProf) GetAllBidirectionalGemPortIDsForOnu() []uint16 {
+// GetAllBidirectionalGemPortIDsForOnu - TODO: add comment
+func (onuTP *OnuUniTechProf) GetAllBidirectionalGemPortIDsForOnu() []uint16 {
var gemPortInstIDs []uint16
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
@@ -986,7 +993,7 @@
}
// setProfileResetting sets/resets the indication, that a reset of the TechProfileConfig/Removal is ongoing
-func (onuTP *onuUniTechProf) setProfileResetting(ctx context.Context, aUniID uint8, aTpID uint8, aState bool) {
+func (onuTP *OnuUniTechProf) setProfileResetting(ctx context.Context, aUniID uint8, aTpID uint8, aState bool) {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
@@ -994,7 +1001,7 @@
}
// getProfileResetting returns true, if the the according indication for started reset procedure is set
-func (onuTP *onuUniTechProf) getProfileResetting(aUniTpKey uniTP) bool {
+func (onuTP *OnuUniTechProf) getProfileResetting(aUniTpKey uniTP) bool {
onuTP.mutexTPState.RLock()
defer onuTP.mutexTPState.RUnlock()
if isResetting, exist := onuTP.tpProfileResetting[aUniTpKey]; exist {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/common/common.go
old mode 100644
new mode 100755
similarity index 86%
rename from internal/pkg/onuadaptercore/common.go
rename to internal/pkg/common/common.go
index b0b10e3..5019a75
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/common/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package common provides global definitions
+package common
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "common"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/common/defines.go b/internal/pkg/common/defines.go
new file mode 100755
index 0000000..2c597c1
--- /dev/null
+++ b/internal/pkg/common/defines.go
@@ -0,0 +1,329 @@
+/*
+ * Copyright 2018-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 common provides global definitions
+package common
+
+import (
+ "context"
+ "time"
+
+ gp "github.com/google/gopacket"
+ "github.com/looplab/fsm"
+ "github.com/opencord/omci-lib-go"
+ vc "github.com/opencord/voltha-protos/v5/go/common"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+// MessageType - Message Protocol Type
+type MessageType uint8
+
+const (
+ // TestMsg - Message type for non OMCI messages
+ TestMsg MessageType = iota
+ //OMCI - OMCI protocol type msg
+ OMCI
+)
+
+// String - Return the text representation of the message type based on integer
+func (m MessageType) String() string {
+ names := [...]string{
+ "TestMsg",
+ "OMCI",
+ }
+ return names[m]
+}
+
+// Message - message type and data(OMCI)
+type Message struct {
+ Type MessageType
+ Data interface{}
+}
+
+//TestMessageType - message data for various events
+type TestMessageType uint8
+
+const (
+ // LoadMibTemplateOk - message data for getting mib template successfully
+ LoadMibTemplateOk TestMessageType = iota + 1
+ // LoadMibTemplateFailed - message data for failure for getting mib template
+ LoadMibTemplateFailed
+ // TimeOutOccurred - message data for timeout
+ TimeOutOccurred
+ // AbortMessageProcessing - message data for aborting running message
+ AbortMessageProcessing
+)
+
+//TestMessage - Struct to hold the message data
+//TODO: place holder to have a second interface variant - to be replaced by real variant later on
+type TestMessage struct {
+ TestMessageVal TestMessageType
+}
+
+//OmciMessage - OMCI protocol messages for managing and monitoring ONUs
+type OmciMessage struct {
+ //OnuSN *openolt.SerialNumber
+ //OnuID uint32
+ OmciMsg *omci.OMCI
+ OmciPacket *gp.Packet
+}
+
+///////////////////////////////////////////////////////////
+
+// device reasons
+const (
+ DrUnset = 0
+ DrActivatingOnu = 1
+ DrStartingOpenomci = 2
+ DrDiscoveryMibsyncComplete = 3
+ DrInitialMibDownloaded = 4
+ DrTechProfileConfigDownloadSuccess = 5
+ DrOmciFlowsPushed = 6
+ DrOmciAdminLock = 7
+ DrOnuReenabled = 8
+ DrStoppingOpenomci = 9
+ DrRebooting = 10
+ DrOmciFlowsDeleted = 11
+ DrTechProfileConfigDeleteSuccess = 12
+ DrReconcileFailed = 13
+ DrReconcileMaxTimeout = 14
+ DrReconcileCanceled = 15
+ DrTechProfileConfigDownloadFailed = 16
+)
+
+// DeviceReasonMap holds device reason strings
+var DeviceReasonMap = map[uint8]string{
+ DrUnset: "unset",
+ DrActivatingOnu: "activating-onu",
+ DrStartingOpenomci: "starting-openomci",
+ DrDiscoveryMibsyncComplete: "discovery-mibsync-complete",
+ DrInitialMibDownloaded: "initial-mib-downloaded",
+ DrTechProfileConfigDownloadSuccess: "tech-profile-config-download-success",
+ DrTechProfileConfigDownloadFailed: "tech-profile-config-download-failed",
+ DrOmciFlowsPushed: "omci-flows-pushed",
+ DrOmciAdminLock: "omci-admin-lock",
+ DrOnuReenabled: "onu-reenabled",
+ DrStoppingOpenomci: "stopping-openomci",
+ DrRebooting: "rebooting",
+ DrOmciFlowsDeleted: "omci-flows-deleted",
+ DrTechProfileConfigDeleteSuccess: "tech-profile-config-delete-success",
+ DrReconcileFailed: "reconcile-failed",
+ DrReconcileMaxTimeout: "reconcile-max-timeout",
+ DrReconcileCanceled: "reconciling-canceled",
+}
+
+// UsedOmciConfigFsms type for FSMs dealing with OMCI messages
+type UsedOmciConfigFsms int
+
+// FSMs dealing with OMCI messages
+const (
+ CUploadFsm UsedOmciConfigFsms = iota
+ CDownloadFsm
+ CUniLockFsm
+ CUniUnLockFsm
+ CAniConfigFsm
+ CUniVlanConfigFsm
+ CL2PmFsm
+ COnuUpgradeFsm
+)
+
+// OnuDeviceEvent - TODO: add comment
+type OnuDeviceEvent int
+
+// Events of interest to Device Adapters and OpenOMCI State Machines
+const (
+ // DeviceStatusInit - default start state
+ DeviceStatusInit OnuDeviceEvent = iota
+ // MibDatabaseSync - MIB database sync (upload done)
+ MibDatabaseSync
+ // OmciCapabilitiesDone - OMCI ME and message type capabilities known
+ OmciCapabilitiesDone
+ // MibDownloadDone - // MIB download done
+ MibDownloadDone
+ // UniLockStateDone - Uni ports admin set to lock
+ UniLockStateDone
+ // UniUnlockStateDone - Uni ports admin set to unlock
+ UniUnlockStateDone
+ // UniDisableStateDone - Uni ports admin set to lock based on device disable
+ UniDisableStateDone
+ // UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
+ UniEnableStateDone
+ // PortLinkUp - Port link state change
+ PortLinkUp
+ // PortLinkDw - Port link state change
+ PortLinkDw
+ // OmciAniConfigDone - AniSide config according to TechProfile done
+ OmciAniConfigDone
+ // OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
+ OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
+ // OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
+ OmciVlanFilterAddDone
+ // OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
+ OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
+ // OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
+ OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
+ // OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
+ OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
+ // OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
+ OmciOnuSwUpgradeDone
+ // Add other events here as needed (alarms separate???)
+)
+
+///////////////////////////////////////////////////////////
+
+//definitions as per G.988 softwareImage::valid ME IDs
+const (
+ FirstSwImageMeID = 0
+ SecondSwImageMeID = 1
+)
+
+//definitions as per G.988 softwareImage::IsCommitted
+const (
+ SwIsUncommitted = 0
+ SwIsCommitted = 1
+)
+
+//definitions as per G.988 softwareImage::IsActive
+const (
+ SwIsInactive = 0
+ SwIsActive = 1
+)
+
+//definitions as per G.988 softwareImage::IsValid
+const (
+ SwIsInvalid = 0
+ SwIsValid = 1
+)
+
+// SEntrySwImageIndication - TODO: add comment
+type SEntrySwImageIndication struct {
+ Valid bool
+ EntityID uint16
+ Version string
+ IsCommitted uint8
+}
+
+// SswImageIndications - TODO: add comment
+type SswImageIndications struct {
+ ActiveEntityEntry SEntrySwImageIndication
+ InActiveEntityEntry SEntrySwImageIndication
+}
+
+///////////////////////////////////////////////////////////
+
+type activityDescr struct {
+ DatabaseClass func(context.Context) error
+ //advertiseEvents bool
+ AuditInterval time.Duration
+ //tasks map[string]func() error
+}
+
+// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
+type OmciDeviceFsms map[string]activityDescr
+
+// AdapterFsm - Adapter FSM details including channel, event and device
+type AdapterFsm struct {
+ fsmName string
+ deviceID string
+ CommChan chan Message
+ PFsm *fsm.FSM
+}
+
+//CErrWaitAborted - AdapterFsm related error string
+//error string could be checked on waitforOmciResponse() e.g. to avoid misleading error log
+// but not used that way so far (permit error log even for wanted cancellation)
+const CErrWaitAborted = "waitResponse aborted"
+
+///////////////////////////////////////////////////////////
+
+// UniPortType holds possible UNI port types
+type UniPortType uint8
+
+// UniPPTP Interface type - re-use values from G.988 (Chapter 9.3.4) TP type definition (directly used in OMCI!)
+const (
+ // UniPPTP relates to PPTP
+ UniPPTP UniPortType = 1 // relates to PPTP
+ // UniVEIP relates to VEIP
+ UniVEIP UniPortType = 11 // relates to VEIP
+ // UniPPTPPots relates to PPTP POTS
+ UniPPTPPots UniPortType = 4 // relates to IP host config data (for Voice Services)
+)
+
+//OnuUniPort structure holds information about the ONU attached Uni Ports
+type OnuUniPort struct {
+ Enabled bool
+ Name string
+ PortNo uint32
+ PortType UniPortType
+ OfpPortNo string
+ UniID uint8
+ MacBpNo uint8
+ EntityID uint16
+ AdminState vc.AdminState_Types
+ OperState vc.OperStatus_Types
+ PPort *voltha.Port
+}
+
+// OnuUniPortMap - TODO: add comment
+type OnuUniPortMap map[uint32]*OnuUniPort
+
+///////////////////////////////////////////////////////////
+
+const (
+ tpIDStart = 64
+ tpIDEnd = 256
+ tpRange = tpIDEnd - tpIDStart
+ maxUni = 256
+)
+
+// TODO
+const (
+ IeeMaperServiceProfileBaseEID = uint16(0x1001)
+ MacBridgePortAniBaseEID = uint16(0x1001)
+ MacBridgePortUniBaseEID = uint16(0x201)
+ MacBridgePortAniMcastBaseEID = uint16(0xA01)
+ GalEthernetEID = uint16(1)
+ MacBridgeServiceProfileEID = uint16(0x201)
+)
+
+// UniVlanRuleParams - TODO: add comment
+type UniVlanRuleParams struct {
+ TpID uint8 `json:"tp_id"`
+ MatchVid uint32 `json:"match_vid"` //use uint32 types for allowing immediate bitshifting
+ MatchPcp uint32 `json:"match_pcp"`
+ TagsToRemove uint32 `json:"tags_to_remove"`
+ SetVid uint32 `json:"set_vid"`
+ SetPcp uint32 `json:"set_pcp"`
+}
+
+// UniVlanFlowParams - TODO: add comment
+type UniVlanFlowParams struct {
+ CookieSlice []uint64 `json:"cookie_slice"`
+ VlanRuleParams UniVlanRuleParams `json:"vlan_rule_params"`
+ Meter *voltha.OfpMeterConfig `json:"flow_meter"`
+}
+
+///////////////////////////////////////////////////////////
+
+//definitions as per G.988
+const (
+ OnuDataMeID = 0
+ Onu2gMeID = 0
+ OnugMeID = 0
+ IPHostConfigDataMeID = 1
+ OnugSerialNumberLen = 8
+ OmciMacAddressLen = 6
+)
diff --git a/internal/pkg/common/interfaces.go b/internal/pkg/common/interfaces.go
new file mode 100755
index 0000000..a15bf35
--- /dev/null
+++ b/internal/pkg/common/interfaces.go
@@ -0,0 +1,178 @@
+/*
+ * 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 common provides global definitions
+package common
+
+import (
+ "context"
+ "time"
+
+ //"github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v7/pkg/db"
+ "github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
+ ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+ "github.com/opencord/voltha-protos/v5/go/openolt"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+// IopenONUAC interface to openONUAC
+type IopenONUAC interface {
+ GetSupportedFsms() *OmciDeviceFsms
+ LockMutexMibTemplateGenerated()
+ UnlockMutexMibTemplateGenerated()
+ GetMibTemplatesGenerated(string) (bool, bool)
+ SetMibTemplatesGenerated(string, bool)
+ RLockMutexDeviceHandlersMap()
+ RUnlockMutexDeviceHandlersMap()
+ GetDeviceHandler(string) (IdeviceHandler, bool)
+}
+
+// IdeviceHandler interface to deviceHandler
+type IdeviceHandler interface {
+ GetDeviceID() string
+ GetLogicalDeviceID() string
+ GetDevice() *voltha.Device
+ GetDeviceType() string
+ GetProxyAddressID() string
+ GetProxyAddressType() string
+ GetProxyAddress() *voltha.Device_ProxyAddress
+ GetEventProxy() eventif.EventProxy
+ GetOmciTimeout() int
+ GetAlarmAuditInterval() time.Duration
+ GetDlToOnuTimeout4M() time.Duration
+ GetUniEntityMap() *OnuUniPortMap
+ GetUniPortMask() int
+ GetPonPortNumber() *uint32
+ GetOnuIndication() *openolt.OnuIndication
+ GetUniVlanConfigFsm(uint8) IuniVlanConfigFsm
+
+ GetDeviceReasonString() string
+ SetDeviceReason(uint8)
+
+ GetCollectorIsRunning() bool
+ StartCollector(context.Context)
+ InitPmConfigs()
+ GetPmConfigs() *voltha.PmConfigs
+ GetMetricsEnabled() bool
+ GetOnuMetricsManager() IonuMetricsManager
+ GetOnuAlarmManager() IonuAlarmManager
+ GetOnuTP() IonuUniTechProf
+
+ GetAlarmManagerIsRunning(context.Context) bool
+ StartAlarmManager(context.Context)
+
+ CheckAuditStartCondition(context.Context, UsedOmciConfigFsms) bool
+
+ RemoveOnuUpgradeFsm(context.Context, *voltha.ImageState)
+ DeviceProcStatusUpdate(context.Context, OnuDeviceEvent)
+
+ SetReadyForOmciConfig(bool)
+ IsReadyForOmciConfig() bool
+
+ StorePersistentData(context.Context) error
+ StorePersUniFlowConfig(context.Context, uint8, *[]UniVlanFlowParams, bool) error
+
+ StartReconciling(context.Context, bool)
+ StopReconciling(context.Context, bool)
+ IsReconciling() bool
+ IsSkipOnuConfigReconciling() bool
+ PrepareReconcilingWithActiveAdapter(context.Context)
+ ReconcileDeviceTechProf(context.Context)
+ ReconcileDeviceFlowConfig(context.Context)
+
+ VerifyUniVlanConfigRequest(context.Context, *OnuUniPort, uint8)
+ VerifyVlanConfigRequest(context.Context, uint8, uint8)
+ AddAllUniPorts(context.Context)
+ RemoveVlanFilterFsm(context.Context, *OnuUniPort)
+
+ EnableUniPortStateUpdate(context.Context)
+ DisableUniPortStateUpdate(context.Context)
+
+ SetBackend(context.Context, string) *db.Backend
+ GetBackendPathPrefix() string
+
+ RLockMutexDeletionInProgressFlag()
+ RUnlockMutexDeletionInProgressFlag()
+ GetDeletionInProgress() bool
+
+ SendOMCIRequest(context.Context, string, *ic.OmciMessage) error
+ CreatePortInCore(context.Context, *voltha.Port) error
+}
+
+// IonuDeviceEntry interface to onuDeviceEntry
+type IonuDeviceEntry interface {
+ GetDevOmciCC() *OmciCC
+ GetOnuDB() *devdb.OnuDeviceDB
+ GetPersSerialNumber() string
+ GetPersVendorID() string
+ GetPersEquipmentID() string
+
+ GetMibUploadFsmCommChan() chan Message
+ GetMibDownloadFsmCommChan() chan Message
+
+ GetOmciRebootMsgRevChan() chan Message
+ WaitForRebootResponse(context.Context, chan Message) error
+
+ IncrementMibDataSync(context.Context)
+
+ GetActiveImageMeID(context.Context) (uint16, error)
+ LockMutexOnuSwImageIndications()
+ UnlockMutexOnuSwImageIndications()
+ GetOnuSwImageIndications() SswImageIndications
+ SetOnuSwImageIndications(SswImageIndications)
+ GetPersActiveSwVersion() string
+ SetPersActiveSwVersion(string)
+ GetActiveImageVersion(context.Context) string
+ ModifySwImageInactiveVersion(context.Context, string)
+ ModifySwImageActiveCommit(context.Context, uint8)
+
+ AllocateFreeTcont(context.Context, uint16) (uint16, bool, error)
+ FreeTcont(context.Context, uint16)
+
+ LockMutexPersOnuConfig()
+ UnlockMutexPersOnuConfig()
+
+ SetReconcilingFlows(bool)
+ SetChReconcilingFlowsFinished(bool)
+}
+
+// IonuMetricsManager interface to onuMetricsManager
+type IonuMetricsManager interface {
+ AddGemPortForPerfMonitoring(context.Context, uint16)
+ RemoveGemPortForPerfMonitoring(context.Context, uint16)
+}
+
+// IonuAlarmManager interface to onuAlarmManager
+type IonuAlarmManager interface {
+ HandleOmciAlarmNotificationMessage(context.Context, OmciMessage)
+ ResetAlarmUploadCounters()
+ GetAlarmMgrEventChannel() chan Message
+ GetAlarmUploadSeqNo() uint16
+ IncrementAlarmUploadSeqNo()
+}
+
+// IonuUniTechProf interface to onuUniTechProf
+type IonuUniTechProf interface {
+ GetAllBidirectionalGemPortIDsForOnu() []uint16
+ SetProfileToDelete(uint8, uint8, bool)
+}
+
+// IuniVlanConfigFsm interface to uniVlanConfigFsm
+type IuniVlanConfigFsm interface {
+ IsFlowRemovePending(chan<- bool) bool
+}
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/common/omci_cc.go
old mode 100644
new mode 100755
similarity index 80%
rename from internal/pkg/onuadaptercore/omci_cc.go
rename to internal/pkg/common/omci_cc.go
index be930b8..363a59f
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/common/omci_cc.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package common provides global definitions
+package common
import (
"container/list"
@@ -51,7 +51,9 @@
//const defaultTPID = uint16(0x8100)
//const broadComDefaultVID = uint16(4091)
-const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
+
+// UnusedTcontAllocID - TODO: add comment
+const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
const cOmciBaseMessageTrailerLen = 40
@@ -67,39 +69,42 @@
cOmciMessageReceiveErrorMissTrailer
)
-const cDefaultRetries = 2
+// CDefaultRetries - TODO: add comment
+const CDefaultRetries = 2
// ### OMCI related definitions - end
-//callbackPairEntry to be used for OMCI send/receive correlation
-type callbackPairEntry struct {
- cbRespChannel chan Message
- cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
- framePrint bool //true for printing
+//CallbackPairEntry to be used for OMCI send/receive correlation
+type CallbackPairEntry struct {
+ CbRespChannel chan Message
+ CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
+ FramePrint bool //true for printing
}
-//callbackPair to be used for ReceiveCallback init
-type callbackPair struct {
- cbKey uint16
- cbEntry callbackPairEntry
+//CallbackPair to be used for ReceiveCallback init
+type CallbackPair struct {
+ CbKey uint16
+ CbEntry CallbackPairEntry
}
-type omciTransferStructure struct {
+// OmciTransferStructure - TODO: add comment
+type OmciTransferStructure struct {
txFrame []byte
timeout int
retries int
highPrio bool
withFramePrint bool
- cbPair callbackPair
+ cbPair CallbackPair
chSuccess chan bool
}
-//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
-type omciCC struct {
+//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
+type OmciCC struct {
enabled bool
- pOnuDeviceEntry *OnuDeviceEntry
+ pBaseDeviceHandler IdeviceHandler
+ pOnuDeviceEntry IonuDeviceEntry
+ pOnuAlarmManager IonuAlarmManager
deviceID string
- pBaseDeviceHandler *deviceHandler
coreClient *vgrpc.Client
supportExtMsg bool
rxOmciFrameError tOmciReceiveError
@@ -112,17 +117,15 @@
tid uint16
mutexHpTid sync.Mutex
hpTid uint16
- uploadSequNo uint16
- uploadNoOfCmds uint16
+ UploadSequNo uint16
+ UploadNoOfCmds uint16
- mutexTxQueue sync.Mutex
- txQueue *list.List
- mutexRxSchedMap sync.Mutex
- rxSchedulerMap map[uint16]callbackPairEntry
- mutexMonReq sync.RWMutex
- monitoredRequests map[uint16]omciTransferStructure
- mutexPLastTxMeInstance sync.RWMutex
- pLastTxMeInstance *me.ManagedEntity
+ mutexTxQueue sync.Mutex
+ txQueue *list.List
+ mutexRxSchedMap sync.Mutex
+ rxSchedulerMap map[uint16]CallbackPairEntry
+ mutexMonReq sync.RWMutex
+ monitoredRequests map[uint16]OmciTransferStructure
}
var responsesWithMibDataSync = []omci.MessageType{
@@ -135,17 +138,18 @@
omci.CommitSoftwareResponseType,
}
-//newOmciCC constructor returns a new instance of a OmciCC
+//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, onuDeviceEntry *OnuDeviceEntry,
- deviceID string, deviceHandler *deviceHandler,
- coreClient *vgrpc.Client) *omciCC {
+func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
+ onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
+ coreClient *vgrpc.Client) *OmciCC {
logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
- var omciCC omciCC
+ var omciCC OmciCC
omciCC.enabled = false
+ omciCC.pBaseDeviceHandler = deviceHandler
+ omciCC.pOnuAlarmManager = onuAlarmManager
omciCC.pOnuDeviceEntry = onuDeviceEntry
omciCC.deviceID = deviceID
- omciCC.pBaseDeviceHandler = deviceHandler
omciCC.coreClient = coreClient
omciCC.supportExtMsg = false
omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
@@ -156,17 +160,17 @@
omciCC.rxOnuDiscards = 0
omciCC.tid = 0x1
omciCC.hpTid = 0x8000
- omciCC.uploadSequNo = 0
- omciCC.uploadNoOfCmds = 0
+ omciCC.UploadSequNo = 0
+ omciCC.UploadNoOfCmds = 0
omciCC.txQueue = list.New()
- omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
- omciCC.monitoredRequests = make(map[uint16]omciTransferStructure)
+ omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
+ omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
return &omciCC
}
-//stop stops/resets the omciCC
-func (oo *omciCC) stop(ctx context.Context) error {
+//Stop stops/resets the omciCC
+func (oo *OmciCC) Stop(ctx context.Context) error {
logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
//reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
oo.CancelRequestMonitoring(ctx)
@@ -185,8 +189,8 @@
oo.tid = 1 //reset the low prio transactionId
oo.mutexTid.Unlock()
//reset control values
- oo.uploadSequNo = 0
- oo.uploadNoOfCmds = 0
+ oo.UploadSequNo = 0
+ oo.UploadNoOfCmds = 0
oo.rxOmciFrameError = cOmciMessageReceiveNoError
//reset the stats counter - which might be topic of discussion ...
oo.txFrames = 0
@@ -199,7 +203,7 @@
}
// Rx handler for omci messages
-func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
+func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
"payload": hex.EncodeToString(omciMsg.Payload)})
switch omciMsg.MessageType {
@@ -208,7 +212,7 @@
OmciMsg: omciMsg,
OmciPacket: packet,
}
- go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
+ go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
return nil
default:
return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
@@ -258,7 +262,7 @@
*/
}
-func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
+func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
//assuming omci message content is hex coded!
// with restricted output of 16bytes would be ...rxMsg[:16]
logger.Debugw(ctx, "omci-message-received:", log.Fields{
@@ -266,9 +270,9 @@
"device-id": oo.deviceID})
}
-// Rx handler for onu messages
+// ReceiveMessage - Rx handler for onu messages
// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
-func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
+func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
//logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
// NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
@@ -342,15 +346,15 @@
//logger.Debug(ctx,"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 {
- if rxCallbackEntry.framePrint {
+ if ok && rxCallbackEntry.CbFunction != nil {
+ if rxCallbackEntry.FramePrint {
oo.printRxMessage(ctx, rxMsg)
}
//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(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
+ go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
- oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
+ oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
}
// If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
@@ -478,26 +482,26 @@
*/
// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
-func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
+func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
delete(oo.rxSchedulerMap, tid)
}
-//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
-func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
- receiveCallbackPair callbackPair) error {
+// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
+func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
+ receiveCallbackPair CallbackPair) error {
if timeout != 0 {
- logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
+ logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
oo.mutexRxSchedMap.Lock()
// it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
- oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
+ oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
oo.mutexRxSchedMap.Unlock()
} //else timeout 0 indicates that no response is expected - fire and forget
- printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
+ printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
//just use a simple list for starting - might need some more effort, especially for multi source write access
- omciTxRequest := omciTransferStructure{
+ omciTxRequest := OmciTransferStructure{
txFrame,
timeout,
retry,
@@ -508,19 +512,19 @@
}
oo.mutexMonReq.Lock()
defer oo.mutexMonReq.Unlock()
- if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
+ if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
// do not call processRequestMonitoring in background here to ensure correct sequencing
// of requested messages into txQueue (especially for non-response-supervised messages)
oo.processRequestMonitoring(ctx, omciTxRequest)
return nil
}
logger.Errorw(ctx, "A message with this tid is processed already!",
- log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
+ log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
}
//Pull next tx request and send it
-func (oo *omciCC) sendNextRequest(ctx context.Context) error {
+func (oo *OmciCC) sendNextRequest(ctx context.Context) error {
// return errors.New("sendNextRequest unimplemented")
// just try to get something transferred !!
@@ -531,7 +535,7 @@
defer oo.mutexTxQueue.Unlock()
for oo.txQueue.Len() > 0 {
queueElement := oo.txQueue.Front() // First element
- omciTxRequest := queueElement.Value.(omciTransferStructure)
+ omciTxRequest := queueElement.Value.(OmciTransferStructure)
/* compare olt device handler code:
func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
@@ -588,18 +592,18 @@
logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
"device-id": oo.deviceID,
- "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
- "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID,
- "proxyAddress": oo.pBaseDeviceHandler.device.ProxyAddress})
+ "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
+ "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
+ "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
}
omciMsg := &ic.OmciMessage{
- ParentDeviceId: oo.pBaseDeviceHandler.ProxyAddressID,
+ ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
ChildDeviceId: oo.deviceID,
Message: omciTxRequest.txFrame,
- ProxyAddress: oo.pBaseDeviceHandler.device.ProxyAddress,
+ ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
}
- sendErr := oo.pBaseDeviceHandler.sendOMCIRequest(ctx, oo.pBaseDeviceHandler.device.ProxyAddress.AdapterEndpoint, omciMsg)
+ sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
if sendErr != nil {
logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
return sendErr
@@ -609,7 +613,8 @@
return nil
}
-func (oo *omciCC) getNextTid(highPriority bool) uint16 {
+// GetNextTid - TODO: add comment
+func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
var next uint16
if highPriority {
oo.mutexHpTid.Lock()
@@ -633,7 +638,9 @@
// ###################################################################################
// # utility methods provided to work on OMCI messages
-func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
+
+// Serialize - TODO: add comment
+func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
omciLayer := &omci.OMCI{
TransactionID: tid,
MessageType: msgType,
@@ -663,7 +670,7 @@
*/
//supply a response handler for omci response messages to be transferred to the requested FSM
-func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
"transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
@@ -703,7 +710,8 @@
return nil
}
-func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
+// SendMibReset sends MibResetRequest
+func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.MibResetRequest{
@@ -711,106 +719,110 @@
EntityClass: me.OnuDataClassID,
},
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
}
- return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
}
-func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
- logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
+// SendReboot sends RebootRequest
+func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
+ logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.RebootRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuGClassID,
},
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
+ err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
if err != nil {
- logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
+ logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
return nil
}
-func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
+// SendMibUpload sends MibUploadRequest
+func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.MibUploadRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuDataClassID,
},
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- oo.uploadSequNo = 0
- oo.uploadNoOfCmds = 0
+ oo.UploadSequNo = 0
+ oo.UploadNoOfCmds = 0
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
}
- return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
}
-func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
- logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
+// SendMibUploadNext sends MibUploadNextRequest
+func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
+ logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
request := &omci.MibUploadNextRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuDataClassID,
},
- CommandSequenceNumber: oo.uploadSequNo,
+ CommandSequenceNumber: oo.UploadSequNo,
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- oo.uploadSequNo++
+ oo.UploadSequNo++
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
//frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
// if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
// compare also software upgrade download section handling
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
}
- return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
}
-func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
+// SendGetAllAlarm gets all alarm ME instances
+func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.GetAllAlarmsRequest{
MeBasePacket: omci.MeBasePacket{
@@ -818,26 +830,26 @@
},
AlarmRetrievalMode: byte(alarmRetreivalMode),
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
+ oo.pOnuAlarmManager.ResetAlarmUploadCounters()
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
- oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
}
- return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
}
-func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
- alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
- logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
+// SendGetAllAlarmNext gets next alarm ME instance
+func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
+ alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
+ logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
"alarmUploadSeqNo": alarmUploadSeqNo})
request := &omci.GetAllAlarmsNextRequest{
MeBasePacket: omci.MeBasePacket{
@@ -845,29 +857,30 @@
},
CommandSequenceNumber: alarmUploadSeqNo,
}
- tid := oo.getNextTid(highPrio)
- pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
+ tid := oo.GetNextTid(highPrio)
+ pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
+ oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
}
- return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
}
-func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
+func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
meParams := me.ParamData{
- EntityID: galEthernetEID,
+ EntityID: GalEthernetEID,
Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
}
meInstance, omciErr := me.NewGalEthernetProfile(meParams)
@@ -887,11 +900,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -905,9 +918,10 @@
return nil, omciErr.GetError()
}
+// SendSetOnu2g sets Onu2G ME instance
// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
-func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -935,11 +949,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -953,10 +967,11 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
- aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
- instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
+// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
+func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
+ instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
@@ -989,11 +1004,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1007,25 +1022,26 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
- aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
- instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
+// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
+ 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})
+ "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
- "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
- "PortNum": aPUniPort.macBpNo,
- "TpType": uint8(aPUniPort.portType),
- "TpPointer": aPUniPort.entityID,
+ "BridgeIdPointer": MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
+ "PortNum": aPUniPort.MacBpNo,
+ "TpType": uint8(aPUniPort.PortType),
+ "TpPointer": aPUniPort.EntityID,
},
}
meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
@@ -1046,11 +1062,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1064,11 +1080,12 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
- aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
+ aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
//same entityId is used as for MBSP (see there), but just arbitrary ...
- instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
+ instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
@@ -1076,14 +1093,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 aPUniPort.portType == uniVEIP {
+ if aPUniPort.PortType == UniVEIP {
assType = uint8(10) // for VEIP
}
meParams := me.ParamData{
EntityID: instID,
Attributes: me.AttributeValueMap{
"AssociationType": assType,
- "AssociatedMePointer": aPUniPort.entityID,
+ "AssociatedMePointer": aPUniPort.EntityID,
},
}
meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
@@ -1103,11 +1120,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1121,9 +1138,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
+// SendSetOnuGLS sets OnuG ME instance
+func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1148,11 +1166,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1166,9 +1184,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
+// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
+func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1193,11 +1212,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1215,7 +1234,7 @@
UniG AdminState anyway should be ignored by ONU acc. to G988
func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1240,11 +1259,11 @@
return nil
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1259,9 +1278,10 @@
}
*/
-func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
+// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
+func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1286,11 +1306,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1304,10 +1324,11 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
+// SendGetMe gets ME instance
+func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1328,11 +1349,11 @@
logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil, err
@@ -1344,10 +1365,11 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
+// SendGetMeWithAttributeMask gets ME instance with attribute mask
+func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
timeout int, highPrio bool, rxChan chan Message) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -1359,16 +1381,16 @@
AttributeMask: requestedAttributesMask,
}
- pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
+ pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
if err != nil {
logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
return err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
return err
@@ -1377,9 +1399,10 @@
return nil
}
-func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
+// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1416,11 +1439,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1434,9 +1457,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1459,11 +1483,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1477,9 +1501,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1502,11 +1527,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1520,8 +1545,9 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1544,11 +1570,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1562,9 +1588,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1587,11 +1614,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1605,9 +1632,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetTcontVar sets TCont ME instance
+func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1628,11 +1656,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1646,9 +1674,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetPrioQueueVar sets PriorityQueue ME instance
+func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1669,11 +1698,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1687,9 +1716,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1710,11 +1740,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1728,9 +1758,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
+func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1756,11 +1787,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1775,9 +1806,9 @@
}
// nolint: unused
-func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
+func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1802,11 +1833,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1820,9 +1851,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1843,11 +1875,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1861,9 +1893,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1884,11 +1917,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1902,9 +1935,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
+func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1925,11 +1959,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1943,9 +1977,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
+func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1971,11 +2006,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -1989,8 +2024,9 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+// SendCreateTDVar creates TrafficDescriptor ME instance
+func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2006,11 +2042,11 @@
logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
@@ -2023,9 +2059,9 @@
}
// nolint: unused
-func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
+func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2042,11 +2078,11 @@
logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
@@ -2059,10 +2095,10 @@
}
-// nolint: unused
-func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteTD - TODO: add comment
+func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2080,11 +2116,11 @@
logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
@@ -2097,9 +2133,10 @@
}
-func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2125,11 +2162,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -2143,9 +2180,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
+func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2171,11 +2209,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -2189,9 +2227,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
+func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2217,11 +2256,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -2235,9 +2274,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
+// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
+func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -2263,11 +2303,11 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{
+ CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
@@ -2281,9 +2321,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2303,10 +2344,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
@@ -2319,9 +2360,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
+func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2341,10 +2383,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil, err
@@ -2357,9 +2399,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
+func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2381,10 +2424,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2398,9 +2441,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
+// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
+func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2422,10 +2466,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2439,9 +2483,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
+// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
+func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2463,10 +2508,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2480,8 +2525,9 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
- tid := oo.getNextTid(highPrio)
+// SendSyncTime sends SynchronizeTimeRequest
+func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
@@ -2512,10 +2558,10 @@
return err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2525,9 +2571,10 @@
return nil
}
-func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
meParam := me.ParamData{EntityID: entityID}
@@ -2562,10 +2609,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2580,9 +2627,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
meParam := me.ParamData{EntityID: entityID}
@@ -2614,10 +2662,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2632,9 +2680,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
meParam := me.ParamData{EntityID: entityID}
@@ -2666,10 +2715,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send fec history data ME",
log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2684,9 +2733,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
+func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
meParam := me.ParamData{EntityID: entityID}
@@ -2718,10 +2768,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send gemport history data ME",
log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
@@ -2736,9 +2786,10 @@
return nil, omciErr.GetError()
}
-func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
+// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
+func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2771,10 +2822,10 @@
}
outgoingPacket := buffer.Bytes()
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2784,9 +2835,10 @@
return nil
}
-func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
+// SendDownloadSection sends DownloadSectionRequestWithResponse
+func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
@@ -2834,12 +2886,12 @@
printFrame = true
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
// the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
// (used to avoid retransmission of frames with the same TID)
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
}
- err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2849,9 +2901,10 @@
return nil
}
-func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
+//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
+func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2884,10 +2937,10 @@
}
outgoingPacket := buffer.Bytes()
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2897,9 +2950,10 @@
return nil
}
-func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
+// SendActivateSoftware sends ActivateSoftwareRequest
+func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aImageMeID uint16) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2929,10 +2983,10 @@
}
outgoingPacket := buffer.Bytes()
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2942,9 +2996,10 @@
return nil
}
-func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
+// SendCommitSoftware sends CommitSoftwareRequest
+func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aImageMeID uint16) error {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aImageMeID), 16)})
@@ -2973,10 +3028,10 @@
}
outgoingPacket := buffer.Bytes()
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -2986,8 +3041,9 @@
return nil
}
-func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
- tid := oo.getNextTid(highPrio)
+//SendSelfTestReq sends TestRequest
+func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(instdID), 16)})
@@ -3000,7 +3056,7 @@
var request *omci.OpticalLineSupervisionTestRequest
switch classID {
- case aniGClassID:
+ case me.AniGClassID:
request = &omci.OpticalLineSupervisionTestRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: classID,
@@ -3027,10 +3083,10 @@
}
outgoingPacket := buffer.Bytes()
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
"device-id": oo.deviceID})
@@ -3095,7 +3151,7 @@
return false
}
-func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
+func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
timeout := aOmciTxRequest.timeout
if timeout == 0 {
//timeout 0 indicates that no response is expected - fire and forget
@@ -3112,10 +3168,10 @@
}
}
-func (oo *omciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest omciTransferStructure, aTimeout int) {
+func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
chSuccess := make(chan bool)
aOmciTxRequest.chSuccess = chSuccess
- tid := aOmciTxRequest.cbPair.cbKey
+ tid := aOmciTxRequest.cbPair.CbKey
oo.mutexMonReq.Lock()
oo.monitoredRequests[tid] = aOmciTxRequest
oo.mutexMonReq.Unlock()
@@ -3158,7 +3214,7 @@
}
//CancelRequestMonitoring terminates monitoring of outstanding omci requests
-func (oo *omciCC) CancelRequestMonitoring(ctx context.Context) {
+func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
oo.mutexMonReq.RLock()
for k := range oo.monitoredRequests {
//implement non-blocking channel send to avoid blocking on mutexMonReq later
@@ -3174,13 +3230,14 @@
//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
//time consumed for retry processing of a particular OMCI-request
-func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
- return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
+func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
+ return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
}
-func (oo *omciCC) sendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
+// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
+func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
- tid := oo.getNextTid(highPrio)
+ tid := oo.GetNextTid(highPrio)
logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
@@ -3219,10 +3276,10 @@
return nil, err
}
- omciRxCallbackPair := callbackPair{cbKey: tid,
- cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
+ omciRxCallbackPair := CallbackPair{CbKey: tid,
+ CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
}
- err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
+ err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
if err != nil {
logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
@@ -3236,3 +3293,24 @@
log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
return nil, omciErr.GetError()
}
+
+// RLockMutexMonReq lock read access to monitoredRequests
+func (oo *OmciCC) RLockMutexMonReq() {
+ oo.mutexMonReq.RLock()
+}
+
+// RUnlockMutexMonReq unlock read access to monitoredRequests
+func (oo *OmciCC) RUnlockMutexMonReq() {
+ oo.mutexMonReq.RUnlock()
+}
+
+// GetMonitoredRequest get OmciTransferStructure for an omciTransID
+func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
+ value, exist = oo.monitoredRequests[omciTransID]
+ return value, exist
+}
+
+// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
+func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
+ oo.monitoredRequests[omciTransID].chSuccess <- chVal
+}
diff --git a/internal/pkg/common/onu_uni_port.go b/internal/pkg/common/onu_uni_port.go
new file mode 100755
index 0000000..77cce60
--- /dev/null
+++ b/internal/pkg/common/onu_uni_port.go
@@ -0,0 +1,158 @@
+/*
+ * 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 common provides global definitions
+package common
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+ "strings"
+ "time"
+
+ //"sync"
+ //"time"
+
+ //"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ vc "github.com/opencord/voltha-protos/v5/go/common"
+ of "github.com/opencord/voltha-protos/v5/go/openflow_13"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+)
+
+//NewOnuUniPort returns a new instance of a OnuUniPort
+func NewOnuUniPort(ctx context.Context, aUniID uint8, aPortNo uint32, aInstNo uint16,
+ aPortType UniPortType) *OnuUniPort {
+ logger.Infow(ctx, "init-onuUniPort", log.Fields{"uniID": aUniID,
+ "portNo": aPortNo, "InstNo": aInstNo, "type": aPortType})
+ var OnuUniPort OnuUniPort
+ OnuUniPort.Enabled = false
+ OnuUniPort.Name = "uni-" + strconv.FormatUint(uint64(aPortNo), 10)
+ OnuUniPort.PortNo = aPortNo
+ OnuUniPort.PortType = aPortType
+ // so far it seems as here ofpPortNo/Name ist the same as the original port name ...??
+ OnuUniPort.OfpPortNo = OnuUniPort.Name
+ OnuUniPort.UniID = aUniID
+ OnuUniPort.MacBpNo = aUniID + 1 //ensure >0 instanceNo
+ OnuUniPort.EntityID = aInstNo
+ OnuUniPort.AdminState = vc.AdminState_ENABLED //enabled per create
+ OnuUniPort.OperState = vc.OperStatus_UNKNOWN
+ OnuUniPort.PPort = nil // to be set on create
+ return &OnuUniPort
+}
+
+//CreateVolthaPort creates the Voltha port based on ONU UNI Port and informs the core about it
+func (oo *OnuUniPort) CreateVolthaPort(ctx context.Context, apDeviceHandler IdeviceHandler) error {
+ logger.Debugw(ctx, "creating-voltha-uni-port", log.Fields{
+ "device-id": apDeviceHandler.GetDevice().Id, "portNo": oo.PortNo})
+ //200630: per [VOL-3202] OF port info is now to be delivered within UniPort create
+ // not doing so crashes rw_core processing (at least still in 200630 version)
+ name := apDeviceHandler.GetDevice().SerialNumber + "-" + strconv.FormatUint(uint64(oo.MacBpNo), 10)
+ var macOctets [6]uint8
+ macOctets[5] = 0x08
+ macOctets[4] = uint8(*apDeviceHandler.GetPonPortNumber() >> 8)
+ macOctets[3] = uint8(*apDeviceHandler.GetPonPortNumber())
+ macOctets[2] = uint8(oo.PortNo >> 16)
+ macOctets[1] = uint8(oo.PortNo >> 8)
+ macOctets[0] = uint8(oo.PortNo)
+ hwAddr := genMacFromOctets(macOctets)
+ ofHwAddr := macAddressToUint32Array(hwAddr)
+ capacity := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+ ofUniPortState := of.OfpPortState_OFPPS_LINK_DOWN
+ /* as the VOLTHA port create is only called directly after Uni Port create
+ the OfPortOperState is always Down
+ Note: this way the OfPortOperState won't ever change (directly in adapter)
+ maybe that was already always the case, but looks a bit weird - to be kept in mind ...
+ if pUniPort.operState == vc.OperStatus_ACTIVE {
+ ofUniPortState = of.OfpPortState_OFPPS_LIVE
+ }
+ */
+ logger.Debugw(ctx, "ofPort values", log.Fields{
+ "forUniPortName": oo.Name, "forMacBase": hwAddr,
+ "name": name, "hwAddr": ofHwAddr, "OperState": ofUniPortState})
+
+ pUniPort := &voltha.Port{
+ DeviceId: apDeviceHandler.GetDevice().Id,
+ PortNo: oo.PortNo,
+ Label: oo.Name,
+ Type: voltha.Port_ETHERNET_UNI,
+ AdminState: oo.AdminState,
+ OperStatus: oo.OperState,
+ // obviously empty peer setting
+ OfpPort: &of.OfpPort{
+ Name: name,
+ HwAddr: ofHwAddr,
+ Config: 0,
+ State: uint32(ofUniPortState),
+ Curr: capacity,
+ Advertised: capacity,
+ Peer: capacity,
+ CurrSpeed: 1000,
+ MaxSpeed: 1000,
+ },
+ }
+ maxRetry := 3
+ retryCnt := 0
+ var err error
+ for retryCnt = 0; retryCnt < maxRetry; retryCnt++ {
+ if err = apDeviceHandler.CreatePortInCore(ctx, pUniPort); err != nil {
+ logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s, retrying after a delay", err)
+ // retry after a sleep
+ time.Sleep(2 * time.Second)
+ } else {
+ // success, break from retry loop
+ break
+ }
+ }
+ if retryCnt == maxRetry { // maxed out..
+ logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s", err)
+ return fmt.Errorf("device-fsm-port-create-failed-%s", err)
+ }
+ logger.Infow(ctx, "Voltha OnuUniPort-added", log.Fields{
+ "device-id": apDeviceHandler.GetDevice().Id, "PortNo": oo.PortNo})
+ oo.PPort = pUniPort
+ oo.OperState = vc.OperStatus_DISCOVERED
+
+ return nil
+}
+
+//SetOperState modifies OperState of the the UniPort
+func (oo *OnuUniPort) SetOperState(aNewOperState vc.OperStatus_Types) {
+ oo.OperState = aNewOperState
+}
+
+// uni port related utility functions (so far only used here)
+func genMacFromOctets(aOctets [6]uint8) string {
+ return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
+ aOctets[5], aOctets[4], aOctets[3],
+ aOctets[2], aOctets[1], aOctets[0])
+}
+
+//copied from OLT Adapter: unify centrally ?
+func macAddressToUint32Array(mac string) []uint32 {
+ slist := strings.Split(mac, ":")
+ result := make([]uint32, len(slist))
+ var err error
+ var tmp int64
+ for index, val := range slist {
+ if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
+ return []uint32{1, 2, 3, 4, 5, 6}
+ }
+ result[index] = uint32(tmp)
+ }
+ return result
+}
diff --git a/internal/pkg/common/utils.go b/internal/pkg/common/utils.go
new file mode 100755
index 0000000..8ea2624
--- /dev/null
+++ b/internal/pkg/common/utils.go
@@ -0,0 +1,155 @@
+/*
+ * 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 common provides global definitions
+package common
+
+import (
+ "bytes"
+ "context"
+ "encoding/binary"
+ "errors"
+ "fmt"
+ "net"
+ "regexp"
+ "strconv"
+ "strings"
+
+ "github.com/looplab/fsm"
+ me "github.com/opencord/omci-lib-go/generated"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+)
+
+// GetTpIDFromTpPath extracts TpID from the TpPath.
+// On success it returns a valid TpID and nil error.
+// On failure it returns TpID as 0 and the error.
+func GetTpIDFromTpPath(tpPath string) (uint8, error) {
+ // tpPath is of the format <technology>/<table_id>/olt-{}/pon-{}/onu-{}/uni-{}
+ // A sample tpPath is ==> XGS-PON/64/olt-{12345abcd}/pon-{0}/onu-{1}/uni-{1}
+ var tpPathFormat = regexp.MustCompile(`^[a-zA-Z\-_]+/[0-9]+/olt-{[a-z0-9\-]+}/pon-{[0-9]+}/onu-{[0-9]+}/uni-{[0-9]+}$`)
+
+ // Ensure tpPath is of the format <technology>/<table_id>/<uni_port_name>
+ if !tpPathFormat.Match([]byte(tpPath)) {
+ return 0, errors.New("tp-path-not-confirming-to-format")
+ }
+ // Extract the TP table-id field.
+ tpID, err := strconv.Atoi(strings.Split(tpPath, "/")[1])
+ // Atoi returns uint64 and need to be type-casted to uint8 as tpID is uint8 size.
+ return uint8(tpID), err
+}
+
+//IPToInt32 transforms an IP of net.Ip type to int32
+func IPToInt32(ip net.IP) uint32 {
+ if len(ip) == 16 {
+ return binary.BigEndian.Uint32(ip[12:16])
+ }
+ return binary.BigEndian.Uint32(ip)
+}
+
+//AsByteSlice transforms a string of manually set bits to a byt array
+func AsByteSlice(bitString string) []byte {
+ var out []byte
+ var str string
+
+ for i := len(bitString); i > 0; i -= 8 {
+ if i-8 < 0 {
+ str = bitString[0:i]
+ } else {
+ str = bitString[i-8 : i]
+ }
+ v, err := strconv.ParseUint(str, 2, 8)
+ if err != nil {
+ panic(err)
+ }
+ out = append([]byte{byte(v)}, out...)
+ }
+ return out
+}
+
+// TwosComplementToSignedInt16 convert 2s complement to signed int16
+func TwosComplementToSignedInt16(val uint16) int16 {
+ var uint16MsbMask uint16 = 0x8000
+ if val&uint16MsbMask == uint16MsbMask {
+ return int16(^val+1) * -1
+ }
+
+ return int16(val)
+}
+
+// TrimStringFromMeOctet trim string out of Me octet
+func TrimStringFromMeOctet(input interface{}) string {
+ ifBytes, _ := me.InterfaceToOctets(input)
+ return fmt.Sprintf("%s", bytes.Trim(ifBytes, "\x00"))
+}
+
+////////////////////////////////////////////////////////////////////////
+
+//NewAdapterFsm - FSM details including event, device and channel.
+func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm {
+ aFsm := &AdapterFsm{
+ fsmName: aName,
+ deviceID: aDeviceID,
+ CommChan: aCommChannel,
+ }
+ return aFsm
+}
+
+// LogFsmStateChange logs FSM state changes
+func (oo *AdapterFsm) LogFsmStateChange(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
+ "event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
+}
+
+////////////////////////////////////////////////////////////////////////
+
+// GenerateIeeMaperServiceProfileEID returns IeeMaperServiceProfileEntityID
+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
+}
+
+// GenerateANISideMBPCDEID returns ANISideMacBridgePortConfigurationDataEntryID
+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
+}
+
+// GenerateUNISideMBPCDEID returns UNISideMacBridgePortConfigurationDataEntityID
+func GenerateUNISideMBPCDEID(uniPortMacBpNo uint16) (uint16, error) {
+ if uniPortMacBpNo > maxUni {
+ return 0, fmt.Errorf("uni macbpno out of range - %d", uniPortMacBpNo)
+ }
+ return (MacBridgePortUniBaseEID + uniPortMacBpNo), nil
+}
+
+// GenerateMcastANISideMBPCDEID returns McastANISideMacBridgePortConfigurationDataEntityID
+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/common.go b/internal/pkg/core/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/core/common.go
index b0b10e3..c18ae16
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/core/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "core"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/core/device_handler.go
old mode 100644
new mode 100755
similarity index 71%
rename from internal/pkg/onuadaptercore/device_handler.go
rename to internal/pkg/core/device_handler.go
index 2c5a4c8..22f08f8
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
import (
"context"
@@ -26,6 +26,7 @@
"time"
"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
+ "github.com/opencord/voltha-protos/v5/go/openolt"
"github.com/opencord/voltha-protos/v5/go/tech_profile"
"github.com/gogo/protobuf/proto"
@@ -36,6 +37,14 @@
flow "github.com/opencord/voltha-lib-go/v7/pkg/flows"
vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ almgr "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/almgr"
+ avcfg "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/avcfg"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ mib "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/mib"
+ otst "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/omcitst"
+ pmmgr "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/pmmgr"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+ uniprt "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/uniprt"
vc "github.com/opencord/voltha-protos/v5/go/common"
"github.com/opencord/voltha-protos/v5/go/extension"
ic "github.com/opencord/voltha-protos/v5/go/inter_container"
@@ -88,74 +97,20 @@
cOnuActivatedEvent = "ONU_ACTIVATED"
)
-type usedOmciConfigFsms int
-
-const (
- cUploadFsm usedOmciConfigFsms = iota
- cDownloadFsm
- cUniLockFsm
- cUniUnLockFsm
- cAniConfigFsm
- cUniVlanConfigFsm
- cL2PmFsm
- cOnuUpgradeFsm
-)
-
type omciIdleCheckStruct struct {
- omciIdleCheckFunc func(*deviceHandler, context.Context, usedOmciConfigFsms, string) bool
+ omciIdleCheckFunc func(*deviceHandler, context.Context, cmn.UsedOmciConfigFsms, string) bool
omciIdleState string
}
-var fsmOmciIdleStateFuncMap = map[usedOmciConfigFsms]omciIdleCheckStruct{
- cUploadFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cMibUlFsmIdleState},
- cDownloadFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cMibDlFsmIdleState},
- cUniLockFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cUniFsmIdleState},
- cUniUnLockFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cUniFsmIdleState},
- cAniConfigFsm: {(*deviceHandler).isAniConfigFsmInOmciIdleState, cAniFsmIdleState},
- cUniVlanConfigFsm: {(*deviceHandler).isUniVlanConfigFsmInOmciIdleState, cVlanFsmIdleState},
- cL2PmFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cL2PmFsmIdleState},
- cOnuUpgradeFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, cOnuUpgradeFsmIdleState},
-}
-
-const (
- // device reasons
- drUnset = 0
- drActivatingOnu = 1
- drStartingOpenomci = 2
- drDiscoveryMibsyncComplete = 3
- drInitialMibDownloaded = 4
- drTechProfileConfigDownloadSuccess = 5
- drOmciFlowsPushed = 6
- drOmciAdminLock = 7
- drOnuReenabled = 8
- drStoppingOpenomci = 9
- drRebooting = 10
- drOmciFlowsDeleted = 11
- drTechProfileConfigDeleteSuccess = 12
- drReconcileFailed = 13
- drReconcileMaxTimeout = 14
- drReconcileCanceled = 15
- drTechProfileConfigDownloadFailed = 16
-)
-
-var deviceReasonMap = map[uint8]string{
- drUnset: "unset",
- drActivatingOnu: "activating-onu",
- drStartingOpenomci: "starting-openomci",
- drDiscoveryMibsyncComplete: "discovery-mibsync-complete",
- drInitialMibDownloaded: "initial-mib-downloaded",
- drTechProfileConfigDownloadSuccess: "tech-profile-config-download-success",
- drTechProfileConfigDownloadFailed: "tech-profile-config-download-failed",
- drOmciFlowsPushed: "omci-flows-pushed",
- drOmciAdminLock: "omci-admin-lock",
- drOnuReenabled: "onu-reenabled",
- drStoppingOpenomci: "stopping-openomci",
- drRebooting: "rebooting",
- drOmciFlowsDeleted: "omci-flows-deleted",
- drTechProfileConfigDeleteSuccess: "tech-profile-config-delete-success",
- drReconcileFailed: "reconcile-failed",
- drReconcileMaxTimeout: "reconcile-max-timeout",
- drReconcileCanceled: "reconciling-canceled",
+var fsmOmciIdleStateFuncMap = map[cmn.UsedOmciConfigFsms]omciIdleCheckStruct{
+ cmn.CUploadFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, mib.CMibUlFsmIdleState},
+ cmn.CDownloadFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, mib.CMibDlFsmIdleState},
+ cmn.CUniLockFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, uniprt.CUniFsmIdleState},
+ cmn.CUniUnLockFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, uniprt.CUniFsmIdleState},
+ cmn.CAniConfigFsm: {(*deviceHandler).isAniConfigFsmInOmciIdleState, avcfg.CAniFsmIdleState},
+ cmn.CUniVlanConfigFsm: {(*deviceHandler).isUniVlanConfigFsmInOmciIdleState, avcfg.CVlanFsmIdleState},
+ cmn.CL2PmFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, pmmgr.CL2PmFsmIdleState},
+ cmn.COnuUpgradeFsm: {(*deviceHandler).isFsmInOmciIdleStateDefault, swupg.COnuUpgradeFsmIdleState},
}
const (
@@ -166,7 +121,7 @@
//deviceHandler will interact with the ONU ? device.
type deviceHandler struct {
- deviceID string
+ DeviceID string
DeviceType string
adminState string
device *voltha.Device
@@ -186,18 +141,18 @@
pDeviceStateFsm *fsm.FSM
//pPonPort *voltha.Port
deviceEntrySet chan bool //channel for DeviceEntry set event
- pOnuOmciDevice *OnuDeviceEntry
- pOnuTP *onuUniTechProf
- pOnuMetricsMgr *onuMetricsManager
- pAlarmMgr *onuAlarmManager
- pSelfTestHdlr *selfTestControlBlock
+ pOnuOmciDevice *mib.OnuDeviceEntry
+ pOnuTP *avcfg.OnuUniTechProf
+ pOnuMetricsMgr *pmmgr.OnuMetricsManager
+ pAlarmMgr *almgr.OnuAlarmManager
+ pSelfTestHdlr *otst.SelfTestControlBlock
exitChannel chan int
lockDevice sync.RWMutex
pOnuIndication *oop.OnuIndication
deviceReason uint8
mutexDeviceReason sync.RWMutex
- pLockStateFsm *lockStateFsm
- pUnlockStateFsm *lockStateFsm
+ pLockStateFsm *uniprt.LockStateFsm
+ pUnlockStateFsm *uniprt.LockStateFsm
//flowMgr *OpenOltFlowMgr
//eventMgr *OpenOltEventMgr
@@ -213,19 +168,16 @@
mutextAlarmManagerFlag sync.RWMutex
stopAlarmManager chan bool
stopHeartbeatCheck chan bool
- uniEntityMap map[uint32]*onuUniPort
+ uniEntityMap cmn.OnuUniPortMap
mutexKvStoreContext sync.Mutex
lockVlanConfig sync.RWMutex
lockVlanAdd sync.RWMutex
- UniVlanConfigFsmMap map[uint8]*UniVlanConfigFsm
+ UniVlanConfigFsmMap map[uint8]*avcfg.UniVlanConfigFsm
lockUpgradeFsm sync.RWMutex
- pOnuUpradeFsm *OnuUpgradeFsm
+ pOnuUpradeFsm *swupg.OnuUpgradeFsm
reconciling uint8
mutexReconcilingFlag sync.RWMutex
chReconcilingFinished chan bool //channel to indicate that reconciling has been finished
- reconcilingFlows bool
- mutexReconcilingFlowsFlag sync.RWMutex
- chReconcilingFlowsFinished chan bool //channel to indicate that reconciling of flows has been finished
mutexReadyForOmciConfig sync.RWMutex
readyForOmciConfig bool
deletionInProgress bool
@@ -241,7 +193,7 @@
dh.EventProxy = ep
dh.config = adapter.config
cloned := (proto.Clone(device)).(*voltha.Device)
- dh.deviceID = cloned.Id
+ dh.DeviceID = cloned.Id
dh.DeviceType = cloned.Type
dh.adminState = "up"
dh.device = cloned
@@ -256,15 +208,13 @@
dh.stopHeartbeatCheck = make(chan bool, 2)
//dh.metrics = pmmetrics.NewPmMetrics(cloned.Id, pmmetrics.Frequency(150), pmmetrics.FrequencyOverride(false), pmmetrics.Grouped(false), pmmetrics.Metrics(pmNames))
//TODO initialize the support classes.
- dh.uniEntityMap = make(map[uint32]*onuUniPort)
+ dh.uniEntityMap = make(map[uint32]*cmn.OnuUniPort)
dh.lockVlanConfig = sync.RWMutex{}
dh.lockVlanAdd = sync.RWMutex{}
dh.lockUpgradeFsm = sync.RWMutex{}
- dh.UniVlanConfigFsmMap = make(map[uint8]*UniVlanConfigFsm)
+ dh.UniVlanConfigFsmMap = make(map[uint8]*avcfg.UniVlanConfigFsm)
dh.reconciling = cNoReconciling
dh.chReconcilingFinished = make(chan bool)
- dh.reconcilingFlows = false
- dh.chReconcilingFlowsFinished = make(chan bool)
dh.readyForOmciConfig = false
dh.deletionInProgress = false
dh.pLastUpgradeImageState = &voltha.ImageState{
@@ -307,7 +257,7 @@
// start save the device to the data model
func (dh *deviceHandler) start(ctx context.Context) {
- logger.Debugw(ctx, "starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.deviceID})
+ logger.Debugw(ctx, "starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.DeviceID})
// Add the initial device to the local model
logger.Debug(ctx, "device-handler-started")
}
@@ -337,7 +287,7 @@
if device.PmConfigs == nil {
// Now, set the initial PM configuration for that device
if err := dh.updatePMConfigInCore(ctx, dh.pmConfigs); err != nil {
- logger.Errorw(ctx, "error updating pm config to core", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "error updating pm config to core", log.Fields{"device-id": dh.DeviceID, "err": err})
}
}
} else {
@@ -351,38 +301,37 @@
//assuming omci message content is hex coded!
// with restricted output of 16(?) bytes would be ...omciMsg.Message[:16]
logger.Debugw(ctx, "inter-adapter-recv-omci", log.Fields{
- "device-id": dh.deviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
+ "device-id": dh.DeviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
*/
-
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry != nil {
if pDevEntry.PDevOmciCC != nil {
- return pDevEntry.PDevOmciCC.receiveMessage(log.WithSpanFromContext(context.TODO(), ctx), msg.Message)
+ return pDevEntry.PDevOmciCC.ReceiveMessage(log.WithSpanFromContext(context.TODO(), ctx), msg.Message)
}
logger.Debugw(ctx, "omciCC not ready to receive omci messages - incoming omci message ignored", log.Fields{"rxMsg": msg.Message})
}
- logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
func (dh *deviceHandler) handleTechProfileDownloadRequest(ctx context.Context, techProfMsg *ic.TechProfileDownloadMessage) error {
- logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
if dh.pOnuTP == nil {
//should normally not happen ...
logger.Errorw(ctx, "onuTechProf instance not set up for DLMsg request - ignoring request",
- log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("techProfile DLMsg request while onuTechProf instance not setup: %s", dh.deviceID)
+ log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("techProfile DLMsg request while onuTechProf instance not setup: %s", dh.DeviceID)
}
- if !dh.isReadyForOmciConfig() {
- logger.Errorw(ctx, "TechProf-set rejected: improper device state", log.Fields{"device-id": dh.deviceID,
- "device-state": dh.getDeviceReasonString()})
- return fmt.Errorf("improper device state %s on device %s", dh.getDeviceReasonString(), dh.deviceID)
+ if !dh.IsReadyForOmciConfig() {
+ logger.Errorw(ctx, "TechProf-set rejected: improper device state", log.Fields{"device-id": dh.DeviceID,
+ "device-state": dh.GetDeviceReasonString()})
+ return fmt.Errorf("improper device state %s on device %s", dh.GetDeviceReasonString(), dh.DeviceID)
}
//previous state test here was just this one, now extended for more states to reject the SetRequest:
// at least 'mib-downloaded' should be reached for processing of this specific ONU configuration
@@ -391,22 +340,22 @@
// we have to lock access to TechProfile processing based on different messageType calls or
// even to fast subsequent calls of the same messageType as well as OnuKVStore processing due
// to possible concurrent access by flow processing
- dh.pOnuTP.lockTpProcMutex()
- defer dh.pOnuTP.unlockTpProcMutex()
+ dh.pOnuTP.LockTpProcMutex()
+ defer dh.pOnuTP.UnlockTpProcMutex()
if techProfMsg.UniId > 255 {
return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
- techProfMsg.UniId, dh.deviceID))
+ techProfMsg.UniId, dh.DeviceID))
}
uniID := uint8(techProfMsg.UniId)
- tpID, err := GetTpIDFromTpPath(techProfMsg.TpInstancePath)
+ tpID, err := cmn.GetTpIDFromTpPath(techProfMsg.TpInstancePath)
if err != nil {
logger.Errorw(ctx, "error-parsing-tpid-from-tppath", log.Fields{"err": err, "tp-path": techProfMsg.TpInstancePath})
return err
}
logger.Debugw(ctx, "unmarshal-techprof-msg-body", log.Fields{"uniID": uniID, "tp-path": techProfMsg.TpInstancePath, "tpID": tpID})
- if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, uint8(tpID), techProfMsg.TpInstancePath); bTpModify {
+ if bTpModify := pDevEntry.UpdateOnuUniTpPath(ctx, uniID, uint8(tpID), techProfMsg.TpInstancePath); bTpModify {
switch tpInst := techProfMsg.TechTpInstance.(type) {
case *ic.TechProfileDownloadMessage_TpInstance:
@@ -423,25 +372,25 @@
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(context.Background(), deadline)
- dh.pOnuTP.resetTpProcessingErrorIndication(uniID, tpID)
+ dh.pOnuTP.ResetTpProcessingErrorIndication(uniID, tpID)
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
// attention: deadline completion check and wg.Done is to be done in both routines
- go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniID, techProfMsg.TpInstancePath, *tpInst.TpInstance, &wg)
+ go dh.pOnuTP.ConfigureUniTp(log.WithSpanFromContext(dctx, ctx), uniID, techProfMsg.TpInstancePath, *tpInst.TpInstance, &wg)
dh.waitForCompletion(ctx, cancel, &wg, "TechProfDwld") //wait for background process to finish
- if tpErr := dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID); tpErr != nil {
- logger.Errorw(ctx, "error-processing-tp", log.Fields{"device-id": dh.deviceID, "err": tpErr, "tp-path": techProfMsg.TpInstancePath})
+ if tpErr := dh.pOnuTP.GetTpProcessingErrorIndication(uniID, tpID); tpErr != nil {
+ logger.Errorw(ctx, "error-processing-tp", log.Fields{"device-id": dh.DeviceID, "err": tpErr, "tp-path": techProfMsg.TpInstancePath})
return tpErr
}
deadline = time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx2, cancel2 := context.WithDeadline(context.Background(), deadline)
- pDevEntry.resetKvProcessingErrorIndication()
+ pDevEntry.ResetKvProcessingErrorIndication()
wg.Add(1) // for the 1 go routine to finish
- go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg)
+ go pDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg)
dh.waitForCompletion(ctx, cancel2, &wg, "TechProfDwld") //wait for background process to finish
- if kvErr := pDevEntry.getKvProcessingErrorIndication(); kvErr != nil {
- logger.Errorw(ctx, "error-updating-KV", log.Fields{"device-id": dh.deviceID, "err": kvErr, "tp-path": techProfMsg.TpInstancePath})
+ if kvErr := pDevEntry.GetKvProcessingErrorIndication(); kvErr != nil {
+ logger.Errorw(ctx, "error-updating-KV", log.Fields{"device-id": dh.DeviceID, "err": kvErr, "tp-path": techProfMsg.TpInstancePath})
return kvErr
}
return nil
@@ -456,84 +405,84 @@
}
func (dh *deviceHandler) handleDeleteGemPortRequest(ctx context.Context, delGemPortMsg *ic.DeleteGemPortMessage) error {
- logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.DeviceID})
if dh.pOnuTP == nil {
//should normally not happen ...
logger.Warnw(ctx, "onuTechProf instance not set up for DelGem request - ignoring request",
- log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("techProfile DelGem request while onuTechProf instance not setup: %s", dh.deviceID)
+ log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("techProfile DelGem request while onuTechProf instance not setup: %s", dh.DeviceID)
}
//compare TECH_PROFILE_DOWNLOAD_REQUEST
- dh.pOnuTP.lockTpProcMutex()
- defer dh.pOnuTP.unlockTpProcMutex()
+ dh.pOnuTP.LockTpProcMutex()
+ defer dh.pOnuTP.UnlockTpProcMutex()
if delGemPortMsg.UniId > 255 {
return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
- delGemPortMsg.UniId, dh.deviceID))
+ delGemPortMsg.UniId, dh.DeviceID))
}
uniID := uint8(delGemPortMsg.UniId)
- tpID, err := GetTpIDFromTpPath(delGemPortMsg.TpInstancePath)
+ tpID, err := cmn.GetTpIDFromTpPath(delGemPortMsg.TpInstancePath)
if err != nil {
logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": delGemPortMsg.TpInstancePath})
return err
}
- logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID, "gem": delGemPortMsg.GemPortId})
+ logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID, "gem": delGemPortMsg.GemPortId})
//a removal of some GemPort would never remove the complete TechProfile entry (done on T-Cont)
return dh.deleteTechProfileResource(ctx, uniID, tpID, delGemPortMsg.TpInstancePath,
- cResourceGemPort, delGemPortMsg.GemPortId)
+ avcfg.CResourceGemPort, delGemPortMsg.GemPortId)
}
func (dh *deviceHandler) handleDeleteTcontRequest(ctx context.Context, delTcontMsg *ic.DeleteTcontMessage) error {
- logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
if dh.pOnuTP == nil {
//should normally not happen ...
logger.Warnw(ctx, "onuTechProf instance not set up for DelTcont request - ignoring request",
- log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("techProfile DelTcont request while onuTechProf instance not setup: %s", dh.deviceID)
+ log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("techProfile DelTcont request while onuTechProf instance not setup: %s", dh.DeviceID)
}
//compare TECH_PROFILE_DOWNLOAD_REQUEST
- dh.pOnuTP.lockTpProcMutex()
- defer dh.pOnuTP.unlockTpProcMutex()
+ dh.pOnuTP.LockTpProcMutex()
+ defer dh.pOnuTP.UnlockTpProcMutex()
if delTcontMsg.UniId > 255 {
return fmt.Errorf(fmt.Sprintf("received UniId value exceeds range: %d, device-id: %s",
- delTcontMsg.UniId, dh.deviceID))
+ delTcontMsg.UniId, dh.DeviceID))
}
uniID := uint8(delTcontMsg.UniId)
tpPath := delTcontMsg.TpInstancePath
- tpID, err := GetTpIDFromTpPath(tpPath)
+ tpID, err := cmn.GetTpIDFromTpPath(tpPath)
if err != nil {
logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": tpPath})
return err
}
- logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID, "tcont": delTcontMsg.AllocId})
+ logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID, "tcont": delTcontMsg.AllocId})
- pDevEntry.freeTcont(ctx, uint16(delTcontMsg.AllocId))
+ pDevEntry.FreeTcont(ctx, uint16(delTcontMsg.AllocId))
return dh.deleteTechProfileResource(ctx, uniID, tpID, delTcontMsg.TpInstancePath,
- cResourceTcont, delTcontMsg.AllocId)
+ avcfg.CResourceTcont, delTcontMsg.AllocId)
}
func (dh *deviceHandler) deleteTechProfileResource(ctx context.Context,
- uniID uint8, tpID uint8, pathString string, resource resourceEntry, entryID uint32) error {
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ uniID uint8, tpID uint8, pathString string, resource avcfg.ResourceEntry, entryID uint32) error {
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
var resourceName string
- if cResourceGemPort == resource {
+ if avcfg.CResourceGemPort == resource {
resourceName = "Gem"
} else {
resourceName = "Tcont"
@@ -543,36 +492,36 @@
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(context.Background(), deadline)
- dh.pOnuTP.resetTpProcessingErrorIndication(uniID, tpID)
+ dh.pOnuTP.ResetTpProcessingErrorIndication(uniID, tpID)
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go dh.pOnuTP.deleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, pathString,
+ go dh.pOnuTP.DeleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, pathString,
resource, entryID, &wg)
dh.waitForCompletion(ctx, cancel, &wg, resourceName+"Delete") //wait for background process to finish
- if err := dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID); err != nil {
- logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+ if err := dh.pOnuTP.GetTpProcessingErrorIndication(uniID, tpID); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
return err
}
- if dh.pOnuTP.isTechProfileConfigCleared(ctx, uniID, tpID) {
- logger.Debugw(ctx, "techProfile-config-cleared", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID})
- if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, tpID, ""); bTpModify {
- pDevEntry.resetKvProcessingErrorIndication()
+ if dh.pOnuTP.IsTechProfileConfigCleared(ctx, uniID, tpID) {
+ logger.Debugw(ctx, "techProfile-config-cleared", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID})
+ if bTpModify := pDevEntry.UpdateOnuUniTpPath(ctx, uniID, tpID, ""); bTpModify {
+ pDevEntry.ResetKvProcessingErrorIndication()
var wg2 sync.WaitGroup
dctx2, cancel2 := context.WithDeadline(context.Background(), deadline)
wg2.Add(1)
// Removal of the gem id mapping represents the removal of the tech profile
- logger.Infow(ctx, "remove-techProfile-indication-in-kv", log.Fields{"device-id": dh.deviceID, "uni-id": uniID, "tpID": tpID})
- go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg2)
+ logger.Infow(ctx, "remove-techProfile-indication-in-kv", log.Fields{"device-id": dh.DeviceID, "uni-id": uniID, "tpID": tpID})
+ go pDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx2, ctx), &wg2)
dh.waitForCompletion(ctx, cancel2, &wg2, "TechProfileDeleteOn"+resourceName) //wait for background process to finish
- if err := pDevEntry.getKvProcessingErrorIndication(); err != nil {
- logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+ if err := pDevEntry.GetKvProcessingErrorIndication(); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
return err
}
}
}
- logger.Debugw(ctx, "delete-tech-profile-resource-completed", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "delete-tech-profile-resource-completed", log.Fields{"device-id": dh.DeviceID,
"uni-id": uniID, "tpID": tpID, "resource-type": resourceName, "resource-id": entryID})
return nil
}
@@ -581,49 +530,49 @@
func (dh *deviceHandler) FlowUpdateIncremental(ctx context.Context,
apOfFlowChanges *of.FlowChanges,
apOfGroupChanges *of.FlowGroupChanges, apFlowMetaData *voltha.FlowMetadata) error {
- logger.Debugw(ctx, "FlowUpdateIncremental started", log.Fields{"device-id": dh.deviceID, "metadata": apFlowMetaData})
+ logger.Debugw(ctx, "FlowUpdateIncremental started", log.Fields{"device-id": dh.DeviceID, "metadata": apFlowMetaData})
var retError error = nil
//Remove flows (always remove flows first - remove old and add new with same cookie may be part of the same request)
if apOfFlowChanges.ToRemove != nil {
for _, flowItem := range apOfFlowChanges.ToRemove.Items {
if flowItem.GetCookie() == 0 {
logger.Warnw(ctx, "flow-remove no cookie: ignore and continuing on checking further flows", log.Fields{
- "device-id": dh.deviceID})
- retError = fmt.Errorf("flow-remove no cookie, device-id %s", dh.deviceID)
+ "device-id": dh.DeviceID})
+ retError = fmt.Errorf("flow-remove no cookie, device-id %s", dh.DeviceID)
continue
}
flowInPort := flow.GetInPort(flowItem)
if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
- logger.Warnw(ctx, "flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
- retError = fmt.Errorf("flow-remove inPort invalid, device-id %s", dh.deviceID)
+ logger.Warnw(ctx, "flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.DeviceID})
+ retError = fmt.Errorf("flow-remove inPort invalid, device-id %s", dh.DeviceID)
continue
- //return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
+ //return fmt.Errorf("flow inPort invalid: %s", dh.DeviceID)
} else if flowInPort == dh.ponPortNumber {
//this is some downstream flow, not regarded as error, just ignored
logger.Debugw(ctx, "flow-remove for downstream: ignore and continuing on checking further flows", log.Fields{
- "device-id": dh.deviceID, "inPort": flowInPort})
+ "device-id": dh.DeviceID, "inPort": flowInPort})
continue
} else {
// this is the relevant upstream flow
- var loUniPort *onuUniPort
+ var loUniPort *cmn.OnuUniPort
if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
loUniPort = uniPort
} else {
logger.Warnw(ctx, "flow-remove inPort not found in UniPorts: ignore and continuing on checking further flows",
- log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
+ log.Fields{"device-id": dh.DeviceID, "inPort": flowInPort})
retError = fmt.Errorf("flow-remove inPort not found in UniPorts, inPort %d, device-id %s",
- flowInPort, dh.deviceID)
+ flowInPort, dh.DeviceID)
continue
}
flowOutPort := flow.GetOutPort(flowItem)
logger.Debugw(ctx, "flow-remove port indications", log.Fields{
- "device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
- "uniPortName": loUniPort.name})
+ "device-id": dh.DeviceID, "inPort": flowInPort, "outPort": flowOutPort,
+ "uniPortName": loUniPort.Name})
err := dh.removeFlowItemFromUniPort(ctx, flowItem, loUniPort)
//try next flow after processing error
if err != nil {
logger.Warnw(ctx, "flow-remove processing error: continuing on checking further flows",
- log.Fields{"device-id": dh.deviceID, "error": err})
+ log.Fields{"device-id": dh.DeviceID, "error": err})
retError = err
continue
//return err
@@ -637,31 +586,31 @@
for _, flowItem := range apOfFlowChanges.ToAdd.Items {
if flowItem.GetCookie() == 0 {
logger.Debugw(ctx, "incremental flow-add no cookie: ignore and continuing on checking further flows", log.Fields{
- "device-id": dh.deviceID})
- retError = fmt.Errorf("flow-add no cookie, device-id %s", dh.deviceID)
+ "device-id": dh.DeviceID})
+ retError = fmt.Errorf("flow-add no cookie, device-id %s", dh.DeviceID)
continue
}
flowInPort := flow.GetInPort(flowItem)
if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
- logger.Warnw(ctx, "flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
- retError = fmt.Errorf("flow-add inPort invalid, device-id %s", dh.deviceID)
+ logger.Warnw(ctx, "flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.DeviceID})
+ retError = fmt.Errorf("flow-add inPort invalid, device-id %s", dh.DeviceID)
continue
- //return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
+ //return fmt.Errorf("flow inPort invalid: %s", dh.DeviceID)
} else if flowInPort == dh.ponPortNumber {
//this is some downstream flow
logger.Debugw(ctx, "flow-add for downstream: ignore and continuing on checking further flows", log.Fields{
- "device-id": dh.deviceID, "inPort": flowInPort})
+ "device-id": dh.DeviceID, "inPort": flowInPort})
continue
} else {
// this is the relevant upstream flow
- var loUniPort *onuUniPort
+ var loUniPort *cmn.OnuUniPort
if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
loUniPort = uniPort
} else {
logger.Warnw(ctx, "flow-add inPort not found in UniPorts: ignore and continuing on checking further flows",
- log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
+ log.Fields{"device-id": dh.DeviceID, "inPort": flowInPort})
retError = fmt.Errorf("flow-add inPort not found in UniPorts, inPort %d, device-id %s",
- flowInPort, dh.deviceID)
+ flowInPort, dh.DeviceID)
continue
//return fmt.Errorf("flow-parameter inPort %d not found in internal UniPorts", flowInPort)
}
@@ -671,21 +620,21 @@
// after the device gets active automatically (and still with its dependency to the TechProfile)
// for state checking compare also code here: processInterAdapterTechProfileDownloadReqMessage
// also abort for the other still possible flows here
- if !dh.isReadyForOmciConfig() {
- logger.Errorw(ctx, "flow-add rejected: improper device state", log.Fields{"device-id": dh.deviceID,
- "last device-reason": dh.getDeviceReasonString()})
- return fmt.Errorf("improper device state on device %s", dh.deviceID)
+ if !dh.IsReadyForOmciConfig() {
+ logger.Errorw(ctx, "flow-add rejected: improper device state", log.Fields{"device-id": dh.DeviceID,
+ "last device-reason": dh.GetDeviceReasonString()})
+ return fmt.Errorf("improper device state on device %s", dh.DeviceID)
}
flowOutPort := flow.GetOutPort(flowItem)
logger.Debugw(ctx, "flow-add port indications", log.Fields{
- "device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
- "uniPortName": loUniPort.name})
+ "device-id": dh.DeviceID, "inPort": flowInPort, "outPort": flowOutPort,
+ "uniPortName": loUniPort.Name})
err := dh.addFlowItemToUniPort(ctx, flowItem, loUniPort, apFlowMetaData)
//try next flow after processing error
if err != nil {
logger.Warnw(ctx, "flow-add processing error: continuing on checking further flows",
- log.Fields{"device-id": dh.deviceID, "error": err})
+ log.Fields{"device-id": dh.DeviceID, "error": err})
retError = err
continue
//return err
@@ -709,34 +658,34 @@
//note that disableDevice sequences in some 'ONU active' state may yield also
// "tech...delete-success" or "omci-flow-deleted" according to further received requests in the end
// - inblock state checking to prevent possibly unneeded processing (on command repitition)
- if dh.getDeviceReason() != drOmciAdminLock {
+ if dh.getDeviceReason() != cmn.DrOmciAdminLock {
//disable-device shall be just a UNi/ONU-G related admin state setting
//all other configurations/FSM's shall not be impacted and shall execute as required by the system
- if dh.isReadyForOmciConfig() {
+ if dh.IsReadyForOmciConfig() {
// disable UNI ports/ONU
// *** should generate UniDisableStateDone event - used to disable the port(s) on success
if dh.pLockStateFsm == nil {
- dh.createUniLockFsm(ctx, true, UniDisableStateDone)
+ dh.createUniLockFsm(ctx, true, cmn.UniDisableStateDone)
} else { //LockStateFSM already init
- dh.pLockStateFsm.setSuccessEvent(UniDisableStateDone)
+ dh.pLockStateFsm.SetSuccessEvent(cmn.UniDisableStateDone)
dh.runUniLockFsm(ctx, true)
}
} else {
logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_REACHABLE,
OperStatus: voltha.OperStatus_UNKNOWN,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
}
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
//TODO with VOL-3045/VOL-3046: catch and return error, valid for all occurrences in the codebase
- _ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrOmciAdminLock, true)
}
}
}
@@ -753,67 +702,67 @@
// OnuIndication-Dw (or not active at all) (- disable) - enable: here already the LockFsm may run into timeout (no OmciResponse)
// but that anyway is hopefully resolved by some OnuIndication-Up event (maybe to be tested)
// one could also argue, that a device-enable should also enable attempts for specific omci configuration
- dh.setReadyForOmciConfig(true) //needed to allow subsequent flow/techProf config (on BBSIM)
+ dh.SetReadyForOmciConfig(true) //needed to allow subsequent flow/techProf config (on BBSIM)
// enable ONU/UNI ports
- // *** should generate UniEnableStateDone event - used to disable the port(s) on success
+ // *** should generate cmn.UniEnableStateDone event - used to disable the port(s) on success
if dh.pUnlockStateFsm == nil {
- dh.createUniLockFsm(ctx, false, UniEnableStateDone)
+ dh.createUniLockFsm(ctx, false, cmn.UniEnableStateDone)
} else { //UnlockStateFSM already init
- dh.pUnlockStateFsm.setSuccessEvent(UniEnableStateDone)
+ dh.pUnlockStateFsm.SetSuccessEvent(cmn.UniEnableStateDone)
dh.runUniLockFsm(ctx, false)
}
}
func (dh *deviceHandler) reconcileDeviceOnuInd(ctx context.Context) {
- logger.Debugw(ctx, "reconciling - simulate onu indication", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - simulate onu indication", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- if err := pDevEntry.restoreDataFromOnuKvStore(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+ if err := pDevEntry.RestoreDataFromOnuKvStore(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
if err == fmt.Errorf("no-ONU-data-found") {
- logger.Debugw(ctx, "no persistent data found - abort reconciling", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "no persistent data found - abort reconciling", log.Fields{"device-id": dh.DeviceID})
} else {
- logger.Errorw(ctx, "reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.deviceID})
+ logger.Errorw(ctx, "reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.DeviceID})
}
- dh.stopReconciling(ctx, false)
+ dh.StopReconciling(ctx, false)
return
}
var onuIndication oop.OnuIndication
- pDevEntry.mutexPersOnuConfig.RLock()
- onuIndication.IntfId = pDevEntry.sOnuPersistentData.PersIntfID
- onuIndication.OnuId = pDevEntry.sOnuPersistentData.PersOnuID
- onuIndication.OperState = pDevEntry.sOnuPersistentData.PersOperState
- onuIndication.AdminState = pDevEntry.sOnuPersistentData.PersAdminState
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RLock()
+ onuIndication.IntfId = pDevEntry.SOnuPersistentData.PersIntfID
+ onuIndication.OnuId = pDevEntry.SOnuPersistentData.PersOnuID
+ onuIndication.OperState = pDevEntry.SOnuPersistentData.PersOperState
+ onuIndication.AdminState = pDevEntry.SOnuPersistentData.PersAdminState
+ pDevEntry.MutexPersOnuConfig.RUnlock()
_ = dh.createInterface(ctx, &onuIndication)
}
-func (dh *deviceHandler) reconcileDeviceTechProf(ctx context.Context) {
- logger.Debugw(ctx, "reconciling - trigger tech profile config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) ReconcileDeviceTechProf(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - trigger tech profile config", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, false)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, false)
}
return
}
- dh.pOnuTP.lockTpProcMutex()
- defer dh.pOnuTP.unlockTpProcMutex()
+ dh.pOnuTP.LockTpProcMutex()
+ defer dh.pOnuTP.UnlockTpProcMutex()
- pDevEntry.mutexPersOnuConfig.RLock()
+ pDevEntry.MutexPersOnuConfig.RLock()
persMutexLock := true
- if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ if len(pDevEntry.SOnuPersistentData.PersUniConfig) == 0 {
+ pDevEntry.MutexPersOnuConfig.RUnlock()
logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
- log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, true)
}
return
}
@@ -821,17 +770,17 @@
techProfsFound := false
techProfInstLoadFailed := false
outerLoop:
- for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
+ for _, uniData := range pDevEntry.SOnuPersistentData.PersUniConfig {
//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
if len(uniData.PersTpPathMap) == 0 {
logger.Debugw(ctx, "reconciling - no TPs stored for uniID",
- log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+ log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
continue
}
- //release mutexPersOnuConfig before TechProfile (ANIConfig) processing as otherwise the reception of
- // OMCI frames may get completely stuck due to lock request within incrementMibDataSync() at OMCI
+ //release MutexPersOnuConfig before TechProfile (ANIConfig) processing as otherwise the reception of
+ // OMCI frames may get completely stuck due to lock request within IncrementMibDataSync() at OMCI
// frame reception may also lock the complete OMCI reception processing based on mutexRxSchedMap
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RUnlock()
persMutexLock = false
techProfsFound = true // set to true if we found TP once for any UNI port
for tpID := range uniData.PersTpPathMap {
@@ -848,7 +797,7 @@
})
if err != nil || iaTechTpInst == nil {
logger.Errorw(ctx, "error fetching tp instance",
- log.Fields{"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID, "err": err})
+ log.Fields{"tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID, "err": err})
techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
break outerLoop
}
@@ -857,10 +806,10 @@
case *ic.TechProfileDownloadMessage_TpInstance: // supports only GPON, XGPON, XGS-PON
tpInst = *techTpInst.TpInstance
logger.Debugw(ctx, "received-tp-instance-successfully-after-reconcile", log.Fields{
- "tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+ "tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
default: // do not support epon or other tech
logger.Errorw(ctx, "unsupported-tech-profile", log.Fields{
- "tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+ "tp-id": tpID, "tpPath": uniData.PersTpPathMap[tpID], "uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
break outerLoop
}
@@ -870,13 +819,13 @@
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(ctx, deadline)
- dh.pOnuTP.resetTpProcessingErrorIndication(uniData.PersUniID, tpID)
+ dh.pOnuTP.ResetTpProcessingErrorIndication(uniData.PersUniID, tpID)
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniData.PersUniID, uniData.PersTpPathMap[tpID], tpInst, &wg)
+ go dh.pOnuTP.ConfigureUniTp(log.WithSpanFromContext(dctx, ctx), uniData.PersUniID, uniData.PersTpPathMap[tpID], tpInst, &wg)
dh.waitForCompletion(ctx, cancel, &wg, "TechProfReconcile") //wait for background process to finish
- if err := dh.pOnuTP.getTpProcessingErrorIndication(uniData.PersUniID, tpID); err != nil {
- logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+ if err := dh.pOnuTP.GetTpProcessingErrorIndication(uniData.PersUniID, tpID); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
techProfInstLoadFailed = true // stop loading tp instance as soon as we hit failure
break outerLoop
}
@@ -884,11 +833,11 @@
if len(uniData.PersFlowParams) != 0 {
flowsFound = true
}
- pDevEntry.mutexPersOnuConfig.RLock() //set protection again for loop test on sOnuPersistentData
+ pDevEntry.MutexPersOnuConfig.RLock() //set protection again for loop test on SOnuPersistentData
persMutexLock = true
- } // for all UNI entries from sOnuPersistentData
- if persMutexLock { // if loop was left with mutexPersOnuConfig still set
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ } // for all UNI entries from SOnuPersistentData
+ if persMutexLock { // if loop was left with MutexPersOnuConfig still set
+ pDevEntry.MutexPersOnuConfig.RUnlock()
}
//had to move techProf/flow result evaluation into separate function due to SCA complexity limit
@@ -899,89 +848,87 @@
abTechProfsFound bool, abTechProfInstLoadFailed bool, abFlowsFound bool) {
if !abTechProfsFound {
logger.Debugw(ctx, "reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
- log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, true)
}
return
}
if abTechProfInstLoadFailed {
- dh.setDeviceReason(drTechProfileConfigDownloadFailed)
- dh.stopReconciling(ctx, false)
+ dh.SetDeviceReason(cmn.DrTechProfileConfigDownloadFailed)
+ dh.StopReconciling(ctx, false)
return
- } else if dh.isSkipOnuConfigReconciling() {
- dh.setDeviceReason(drTechProfileConfigDownloadSuccess)
+ } else if dh.IsSkipOnuConfigReconciling() {
+ dh.SetDeviceReason(cmn.DrTechProfileConfigDownloadSuccess)
}
if !abFlowsFound {
logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
- log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, true)
}
}
}
-func (dh *deviceHandler) reconcileDeviceFlowConfig(ctx context.Context) {
- logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) ReconcileDeviceFlowConfig(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, false)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, false)
}
return
}
- pDevEntry.mutexPersOnuConfig.RLock()
- if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RLock()
+ if len(pDevEntry.SOnuPersistentData.PersUniConfig) == 0 {
+ pDevEntry.MutexPersOnuConfig.RUnlock()
logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
- log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, true)
}
return
}
flowsFound := false
- for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
+ for _, uniData := range pDevEntry.SOnuPersistentData.PersUniConfig {
//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
if len(uniData.PersFlowParams) == 0 {
logger.Debugw(ctx, "reconciling - no flows stored for uniID",
- log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+ log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
continue
}
if len(uniData.PersTpPathMap) == 0 {
logger.Warnw(ctx, "reconciling - flows but no TPs stored for uniID",
- log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
+ log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.DeviceID})
// It doesn't make sense to configure any flows if no TPs are available
continue
}
- //release mutexPersOnuConfig before VlanConfig processing as otherwise the reception of
- // OMCI frames may get completely stuck due to lock request within incrementMibDataSync() at OMCI
+ //release MutexPersOnuConfig before VlanConfig processing as otherwise the reception of
+ // OMCI frames may get completely stuck due to lock request within IncrementMibDataSync() at OMCI
// frame reception may also lock the complete OMCI reception processing based on mutexRxSchedMap
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RUnlock()
- var uniPort *onuUniPort
+ var uniPort *cmn.OnuUniPort
var exist bool
uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
if uniPort, exist = dh.uniEntityMap[uniNo]; !exist {
- logger.Errorw(ctx, "reconciling - onuUniPort data not found - terminate reconcilement",
- log.Fields{"uniNo": uniNo, "device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, false)
+ logger.Errorw(ctx, "reconciling - OnuUniPort data not found - terminate reconcilement",
+ log.Fields{"uniNo": uniNo, "device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, false)
}
return
}
flowsFound = true
lastFlowToReconcile := false
flowsProcessed := 0
- dh.setReconcilingFlows(true)
+ pDevEntry.SetReconcilingFlows(true)
for _, flowData := range uniData.PersFlowParams {
logger.Debugw(ctx, "reconciling - add flow with cookie slice", log.Fields{
- "device-id": dh.deviceID, "uni-id": uniData.PersUniID, "cookies": flowData.CookieSlice})
- // If this is the last flow for the device we need to announce it the waiting
- // chReconcilingFlowsFinished channel
+ "device-id": dh.DeviceID, "uni-id": uniData.PersUniID, "cookies": flowData.CookieSlice})
if flowsProcessed == len(uniData.PersFlowParams)-1 {
lastFlowToReconcile = true
}
@@ -991,55 +938,55 @@
if err := dh.UniVlanConfigFsmMap[uniData.PersUniID].SetUniFlowParams(ctx, flowData.VlanRuleParams.TpID,
flowData.CookieSlice, uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
uint8(flowData.VlanRuleParams.SetPcp), lastFlowToReconcile, flowData.Meter); err != nil {
- logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
}
} else {
if err := dh.createVlanFilterFsm(ctx, uniPort, flowData.VlanRuleParams.TpID, flowData.CookieSlice,
uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
- uint8(flowData.VlanRuleParams.SetPcp), OmciVlanFilterAddDone, lastFlowToReconcile, flowData.Meter); err != nil {
- logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
+ uint8(flowData.VlanRuleParams.SetPcp), cmn.OmciVlanFilterAddDone, lastFlowToReconcile, flowData.Meter); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.DeviceID})
}
}
dh.lockVlanConfig.Unlock()
flowsProcessed++
} //for all flows of this UNI
logger.Debugw(ctx, "reconciling - flows processed", log.Fields{
- "device-id": dh.deviceID, "uni-id": uniData.PersUniID, "flowsProcessed": flowsProcessed,
- "numUniFlows": dh.UniVlanConfigFsmMap[uniData.PersUniID].numUniFlows,
- "configuredUniFlow": dh.UniVlanConfigFsmMap[uniData.PersUniID].configuredUniFlow})
+ "device-id": dh.DeviceID, "uni-id": uniData.PersUniID, "flowsProcessed": flowsProcessed,
+ "NumUniFlows": dh.UniVlanConfigFsmMap[uniData.PersUniID].NumUniFlows,
+ "ConfiguredUniFlow": dh.UniVlanConfigFsmMap[uniData.PersUniID].ConfiguredUniFlow})
// this can't be used as global finished reconciling flag because
// assumes is getting called before the state machines for the last flow is completed,
// while this is not guaranteed.
- //dh.setReconcilingFlows(false)
- pDevEntry.mutexPersOnuConfig.RLock() //set protection again for loop test on sOnuPersistentData
- } // for all UNI entries from sOnuPersistentData
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ //dh.SetReconcilingFlows(false)
+ pDevEntry.MutexPersOnuConfig.RLock() //set protection again for loop test on SOnuPersistentData
+ } // for all UNI entries from SOnuPersistentData
+ pDevEntry.MutexPersOnuConfig.RUnlock()
if !flowsFound {
logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
- log.Fields{"device-id": dh.deviceID})
- if !dh.isSkipOnuConfigReconciling() {
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ if !dh.IsSkipOnuConfigReconciling() {
+ dh.StopReconciling(ctx, true)
}
return
}
- if dh.isSkipOnuConfigReconciling() {
- dh.setDeviceReason(drOmciFlowsPushed)
+ if dh.IsSkipOnuConfigReconciling() {
+ dh.SetDeviceReason(cmn.DrOmciFlowsPushed)
}
}
func (dh *deviceHandler) reconcileEnd(ctx context.Context) {
- logger.Debugw(ctx, "reconciling - completed!", log.Fields{"device-id": dh.deviceID})
- dh.stopReconciling(ctx, true)
+ logger.Debugw(ctx, "reconciling - completed!", log.Fields{"device-id": dh.DeviceID})
+ dh.StopReconciling(ctx, true)
}
func (dh *deviceHandler) deleteDevicePersistencyData(ctx context.Context) error {
- logger.Debugw(ctx, "delete device persistency data", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "delete device persistency data", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
//IfDevEntry does not exist here, no problem - no persistent data should have been stored
- logger.Debugw(ctx, "OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.DeviceID})
return nil
}
@@ -1048,51 +995,51 @@
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(ctx, deadline)
- pDevEntry.resetKvProcessingErrorIndication()
+ pDevEntry.ResetKvProcessingErrorIndication()
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go pDevEntry.deleteDataFromOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ go pDevEntry.DeleteDataFromOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
dh.waitForCompletion(ctx, cancel, &wg, "DeleteDevice") //wait for background process to finish
// TODO: further actions - stop metrics and FSMs, remove device ...
- return pDevEntry.getKvProcessingErrorIndication()
+ return pDevEntry.GetKvProcessingErrorIndication()
}
//func (dh *deviceHandler) rebootDevice(ctx context.Context, device *voltha.Device) error {
// before this change here return like this was used:
-// return fmt.Errorf("device-unreachable: %s, %s", dh.deviceID, device.SerialNumber)
+// return fmt.Errorf("device-unreachable: %s, %s", dh.DeviceID, device.SerialNumber)
//was and is called in background - error return does not make sense
func (dh *deviceHandler) rebootDevice(ctx context.Context, aCheckDeviceState bool, device *voltha.Device) {
- logger.Infow(ctx, "reboot-device", log.Fields{"device-id": dh.deviceID, "SerialNumber": dh.device.SerialNumber})
+ logger.Infow(ctx, "reboot-device", log.Fields{"device-id": dh.DeviceID, "SerialNumber": dh.device.SerialNumber})
if aCheckDeviceState && device.ConnectStatus != voltha.ConnectStatus_REACHABLE {
logger.Errorw(ctx, "device-unreachable", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
return
}
- if err := dh.pOnuOmciDevice.reboot(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+ if err := dh.pOnuOmciDevice.Reboot(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-rebooting-device", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-rebooting-device", log.Fields{"device-id": dh.DeviceID, "error": err})
return
}
//transfer the possibly modified logical uni port state
- dh.disableUniPortStateUpdate(ctx)
+ dh.DisableUniPortStateUpdate(ctx)
logger.Debugw(ctx, "call DeviceStateUpdate upon reboot", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_REACHABLE,
OperStatus: voltha.OperStatus_DISCOVERED,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
return
}
- if err := dh.deviceReasonUpdate(ctx, drRebooting, true); err != nil {
+ if err := dh.deviceReasonUpdate(ctx, cmn.DrRebooting, true); err != nil {
return
}
- dh.setReadyForOmciConfig(false)
+ dh.SetReadyForOmciConfig(false)
//no specific activity to synchronize any internal FSM to the 'rebooted' state is explicitly done here
// the expectation ids for a real device, that it will be synced with the expected following 'down' indication
// as BBSIM does not support this testing requires explicite disable/enable device calls in which sequence also
@@ -1102,46 +1049,50 @@
//doOnuSwUpgrade initiates the SW download transfer to the ONU and on success activates the (inactive) image
// used only for old - R2.7 style - upgrade API
func (dh *deviceHandler) doOnuSwUpgrade(ctx context.Context, apImageDsc *voltha.ImageDownload,
- apDownloadManager *adapterDownloadManager) error {
+ apDownloadManager *swupg.AdapterDownloadManager) error {
logger.Debugw(ctx, "onuSwUpgrade requested", log.Fields{
- "device-id": dh.deviceID, "image-name": (*apImageDsc).Name})
+ "device-id": dh.DeviceID, "image-name": (*apImageDsc).Name})
var err error
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("start Onu SW upgrade rejected: no valid OnuDevice for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("start Onu SW upgrade rejected: no valid OnuDevice for device-id: %s", dh.DeviceID)
}
- if dh.isReadyForOmciConfig() {
+ if dh.IsReadyForOmciConfig() {
var inactiveImageID uint16
if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err == nil {
dh.lockUpgradeFsm.Lock()
defer dh.lockUpgradeFsm.Unlock()
if dh.pOnuUpradeFsm == nil {
- err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+ err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
if err == nil {
if err = dh.pOnuUpradeFsm.SetDownloadParams(ctx, inactiveImageID, apImageDsc, apDownloadManager); err != nil {
logger.Errorw(ctx, "onu upgrade fsm could not set parameters", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
}
} else {
logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
}
} else { //OnuSw upgrade already running - restart (with possible abort of running)
- logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.DeviceID})
+ dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
+ //no effort spent anymore for the old API to automatically cancel and restart the download
+ // like done for the new API
+ logger.Debugw(ctx, "Onu SW upgrade already running - abort", log.Fields{"device-id": dh.DeviceID})
dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
//no effort spent anymore for the old API to automatically cancel and restart the download
// like done for the new API
}
} else {
logger.Errorw(ctx, "start Onu SW upgrade rejected: no inactive image", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
}
} else {
- logger.Errorw(ctx, "start Onu SW upgrade rejected: no active OMCI connection", log.Fields{"device-id": dh.deviceID})
- err = fmt.Errorf("start Onu SW upgrade rejected: no active OMCI connection for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "start Onu SW upgrade rejected: no active OMCI connection", log.Fields{"device-id": dh.DeviceID})
+ err = fmt.Errorf("start Onu SW upgrade rejected: no active OMCI connection for device-id: %s", dh.DeviceID)
}
return err
}
@@ -1149,28 +1100,28 @@
//onuSwUpgradeAfterDownload initiates the SW download transfer to the ONU with activate and commit options
// after the OnuImage has been downloaded to the adapter, called in background
func (dh *deviceHandler) onuSwUpgradeAfterDownload(ctx context.Context, apImageRequest *voltha.DeviceImageDownloadRequest,
- apDownloadManager *fileDownloadManager, aImageIdentifier string) {
+ apDownloadManager *swupg.FileDownloadManager, aImageIdentifier string) {
var err error
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
return
}
var inactiveImageID uint16
if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err == nil {
logger.Debugw(ctx, "onuSwUpgrade requested", log.Fields{
- "device-id": dh.deviceID, "image-version": apImageRequest.Image.Version, "to onu-image": inactiveImageID})
+ "device-id": dh.DeviceID, "image-version": apImageRequest.Image.Version, "to onu-image": inactiveImageID})
dh.lockUpgradeFsm.RLock()
lopOnuUpradeFsm := dh.pOnuUpradeFsm
- //lockUpgradeFsm must be release before cancellation as this may implicitly request removeOnuUpgradeFsm()
+ //lockUpgradeFsm must be release before cancellation as this may implicitly request RemoveOnuUpgradeFsm()
dh.lockUpgradeFsm.RUnlock()
if lopOnuUpradeFsm != nil {
//OnuSw upgrade already running on this device (e.g. with activate/commit not yet set)
// abort the current processing, running upgrades are always aborted by newer request
- logger.Debugw(ctx, "Onu SW upgrade already running - abort previous activity", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Onu SW upgrade already running - abort previous activity", log.Fields{"device-id": dh.DeviceID})
//flush the remove upgradeFsmChan channel
select {
case <-dh.upgradeFsmChan:
@@ -1180,33 +1131,33 @@
lopOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_REQUEST) //complete abort
select {
case <-time.After(cTimeOutRemoveUpgrade * time.Second):
- logger.Errorw(ctx, "could not remove Upgrade FSM in time, aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "could not remove Upgrade FSM in time, aborting", log.Fields{"device-id": dh.DeviceID})
//should not appear, can't proceed with new upgrade, perhaps operator can retry manually later
return
case <-dh.upgradeFsmChan:
- logger.Debugw(ctx, "recent Upgrade FSM removed, proceed with new request", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "recent Upgrade FSM removed, proceed with new request", log.Fields{"device-id": dh.DeviceID})
}
}
//here it can be assumed that no running upgrade processing exists (anymore)
//OmciOnuSwUpgradeDone could be used to create some Kafka event with information on upgrade completion,
// but none yet defined
- err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+ err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
if err == nil {
if err = dh.pOnuUpradeFsm.SetDownloadParamsAfterDownload(ctx, inactiveImageID,
apImageRequest, apDownloadManager, aImageIdentifier); err != nil {
logger.Errorw(ctx, "onu upgrade fsm could not set parameters", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
return
}
} else {
logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
}
return
}
logger.Errorw(ctx, "start Onu SW upgrade rejected: no inactive image", log.Fields{
- "device-id": dh.deviceID, "error": err})
+ "device-id": dh.DeviceID, "error": err})
}
//onuSwActivateRequest ensures activation of the requested image with commit options
@@ -1217,18 +1168,18 @@
// 1.) activation of the image for a started upgrade process (in case the running upgrade runs on the requested image)
// 2.) activation of the inactive image
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "Onu image activation rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
- return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "Onu image activation rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+ return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
}
dh.lockUpgradeFsm.RLock()
if dh.pOnuUpradeFsm != nil {
dh.lockUpgradeFsm.RUnlock()
- onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.deviceID)
+ onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.DeviceID)
if getErr != nil || onuVolthaDevice == nil {
- logger.Errorw(ctx, "Failed to fetch Onu device for image activation", log.Fields{"device-id": dh.deviceID, "err": getErr})
- return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "Failed to fetch Onu device for image activation", log.Fields{"device-id": dh.DeviceID, "err": getErr})
+ return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.DeviceID)
}
// use the OnuVendor identification from this device for the internal unique name
imageIdentifier := onuVolthaDevice.VendorId + aVersion //head on vendor ID of the ONU
@@ -1236,11 +1187,11 @@
if err = dh.pOnuUpradeFsm.SetActivationParamsRunning(ctx, imageIdentifier, aCommitRequest); err != nil {
//if some ONU upgrade is ongoing we do not accept some explicit ONU image-version related activation
logger.Errorw(ctx, "onu upgrade fsm did not accept activation while running", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("activation not accepted for this version for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("activation not accepted for this version for device-id: %s", dh.DeviceID)
}
logger.Debugw(ctx, "image activation acknowledged by onu upgrade processing", log.Fields{
- "device-id": dh.deviceID, "image-id": imageIdentifier})
+ "device-id": dh.DeviceID, "image-id": imageIdentifier})
pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
return pImageStates, nil
} //else
@@ -1251,25 +1202,25 @@
var inactiveImageID uint16
if inactiveImageID, err = pDevEntry.GetInactiveImageMeID(ctx); err != nil || inactiveImageID > 1 {
logger.Errorw(ctx, "get inactive image failed", log.Fields{
- "device-id": dh.deviceID, "err": err, "image-id": inactiveImageID})
- return nil, fmt.Errorf("no valid inactive image found for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "err": err, "image-id": inactiveImageID})
+ return nil, fmt.Errorf("no valid inactive image found for device-id: %s", dh.DeviceID)
}
- err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+ err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
if err == nil {
if err = dh.pOnuUpradeFsm.SetActivationParamsStart(ctx, aVersion,
inactiveImageID, aCommitRequest); err != nil {
logger.Errorw(ctx, "onu upgrade fsm did not accept activation to start", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("activation to start from scratch not accepted for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("activation to start from scratch not accepted for device-id: %s", dh.DeviceID)
}
logger.Debugw(ctx, "inactive image activation acknowledged by onu upgrade", log.Fields{
- "device-id": dh.deviceID, "image-version": aVersion})
+ "device-id": dh.DeviceID, "image-version": aVersion})
pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
return pImageStates, nil
} //else
logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.DeviceID)
}
//onuSwCommitRequest ensures commitment of the requested image
@@ -1280,18 +1231,18 @@
// 1.) commitment of the image for a started upgrade process (in case the running upgrade runs on the requested image)
// 2.) commitment of the active image
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "Onu image commitment rejected: no valid OnuDevice", log.Fields{"device-id": dh.deviceID})
- return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "Onu image commitment rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+ return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
}
dh.lockUpgradeFsm.RLock()
if dh.pOnuUpradeFsm != nil {
dh.lockUpgradeFsm.RUnlock()
- onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.deviceID)
+ onuVolthaDevice, getErr := dh.getDeviceFromCore(ctx, dh.DeviceID)
if getErr != nil || onuVolthaDevice == nil {
- logger.Errorw(ctx, "Failed to fetch Onu device for image commitment", log.Fields{"device-id": dh.deviceID, "err": getErr})
- return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.deviceID)
+ logger.Errorw(ctx, "Failed to fetch Onu device for image commitment", log.Fields{"device-id": dh.DeviceID, "err": getErr})
+ return nil, fmt.Errorf("could not fetch device for device-id: %s", dh.DeviceID)
}
// use the OnuVendor identification from this device for the internal unique name
imageIdentifier := onuVolthaDevice.VendorId + aVersion //head on vendor ID of the ONU
@@ -1301,11 +1252,11 @@
if err = dh.pOnuUpradeFsm.SetCommitmentParamsRunning(ctx, imageIdentifier, aVersion); err != nil {
//if some ONU upgrade is ongoing we do not accept some explicit different ONU image-version related commitment
logger.Errorw(ctx, "onu upgrade fsm did not accept commitment while running", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("commitment not accepted for this version for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("commitment not accepted for this version for device-id: %s", dh.DeviceID)
}
logger.Debugw(ctx, "image commitment acknowledged by onu upgrade processing", log.Fields{
- "device-id": dh.deviceID, "image-id": imageIdentifier})
+ "device-id": dh.DeviceID, "image-id": imageIdentifier})
pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
return pImageStates, nil
} //else
@@ -1315,24 +1266,24 @@
var activeImageID uint16
if activeImageID, err = pDevEntry.GetActiveImageMeID(ctx); err != nil || activeImageID > 1 {
logger.Errorw(ctx, "get active image failed", log.Fields{
- "device-id": dh.deviceID, "err": err, "image-id": activeImageID})
- return nil, fmt.Errorf("no valid active image found for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "err": err, "image-id": activeImageID})
+ return nil, fmt.Errorf("no valid active image found for device-id: %s", dh.DeviceID)
}
- err = dh.createOnuUpgradeFsm(ctx, pDevEntry, OmciOnuSwUpgradeDone)
+ err = dh.createOnuUpgradeFsm(ctx, pDevEntry, cmn.OmciOnuSwUpgradeDone)
if err == nil {
if err = dh.pOnuUpradeFsm.SetCommitmentParamsStart(ctx, aVersion, activeImageID); err != nil {
logger.Errorw(ctx, "onu upgrade fsm did not accept commitment to start", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("commitment to start from scratch not accepted for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("commitment to start from scratch not accepted for device-id: %s", dh.DeviceID)
}
logger.Debugw(ctx, "active image commitment acknowledged by onu upgrade", log.Fields{
- "device-id": dh.deviceID, "image-version": aVersion})
+ "device-id": dh.DeviceID, "image-version": aVersion})
pImageStates := dh.pOnuUpradeFsm.GetImageStates(ctx, "", aVersion)
return pImageStates, nil
} //else
logger.Errorw(ctx, "onu upgrade fsm could not be created", log.Fields{
- "device-id": dh.deviceID, "error": err})
- return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.deviceID)
+ "device-id": dh.DeviceID, "error": err})
+ return nil, fmt.Errorf("could not start upgradeFsm for device-id: %s", dh.DeviceID)
}
func (dh *deviceHandler) requestOnuSwUpgradeState(ctx context.Context, aImageIdentifier string,
@@ -1360,7 +1311,7 @@
func (dh *deviceHandler) cancelOnuSwUpgrade(ctx context.Context, aImageIdentifier string,
aVersion string, pDeviceImageState *voltha.DeviceImageState) {
- pDeviceImageState.DeviceId = dh.deviceID
+ pDeviceImageState.DeviceId = dh.DeviceID
pDeviceImageState.ImageState.Version = aVersion
dh.lockUpgradeFsm.RLock()
if dh.pOnuUpradeFsm != nil {
@@ -1395,23 +1346,23 @@
func (dh *deviceHandler) getOnuImages(ctx context.Context) (*voltha.OnuImages, error) {
- var onuImageStatus *OnuImageStatus
+ var onuImageStatus *swupg.OnuImageStatus
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry != nil {
- onuImageStatus = NewOnuImageStatus(pDevEntry)
- pDevEntry.mutexOnuImageStatus.Lock()
- pDevEntry.pOnuImageStatus = onuImageStatus
- pDevEntry.mutexOnuImageStatus.Unlock()
+ onuImageStatus = swupg.NewOnuImageStatus(dh, pDevEntry)
+ pDevEntry.MutexOnuImageStatus.Lock()
+ pDevEntry.POnuImageStatus = onuImageStatus
+ pDevEntry.MutexOnuImageStatus.Unlock()
} else {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return nil, fmt.Errorf("no-valid-OnuDevice-aborting")
}
- images, err := onuImageStatus.getOnuImageStatus(ctx)
- pDevEntry.mutexOnuImageStatus.Lock()
- pDevEntry.pOnuImageStatus = nil
- pDevEntry.mutexOnuImageStatus.Unlock()
+ images, err := onuImageStatus.GetOnuImageStatus(ctx)
+ pDevEntry.MutexOnuImageStatus.Lock()
+ pDevEntry.POnuImageStatus = nil
+ pDevEntry.MutexOnuImageStatus.Unlock()
return images, err
}
@@ -1422,7 +1373,7 @@
// deviceHandler StateMachine related state transition methods ##### begin #########
func (dh *deviceHandler) logStateChange(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.deviceID})
+ logger.Debugw(ctx, "Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.DeviceID})
}
// doStateInit provides the device update to the core
@@ -1435,20 +1386,20 @@
dh.device.Root = false
dh.device.Vendor = "OpenONU"
dh.device.Model = "go"
- dh.device.Reason = deviceReasonMap[drActivatingOnu]
- dh.setDeviceReason(drActivatingOnu)
+ dh.device.Reason = cmn.DeviceReasonMap[cmn.DrActivatingOnu]
+ dh.SetDeviceReason(cmn.DrActivatingOnu)
- dh.logicalDeviceID = dh.deviceID // really needed - what for ??? //TODO!!!
+ dh.logicalDeviceID = dh.DeviceID // really needed - what for ??? //TODO!!!
- if !dh.isReconciling() {
- logger.Infow(ctx, "DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.deviceID})
+ if !dh.IsReconciling() {
+ logger.Infow(ctx, "DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.DeviceID})
if err := dh.updateDeviceInCore(ctx, dh.device); err != nil {
logger.Errorw(ctx, "device-update-failed", log.Fields{"device-id": dh.device.Id, "error": err})
}
//TODO Need to Update Device Reason To CORE as part of device update userstory
} else {
logger.Debugw(ctx, "reconciling - don't notify core about DeviceUpdate",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
}
dh.parentID = dh.device.ParentId
@@ -1457,7 +1408,7 @@
// store proxy parameters for later communication - assumption: invariant, else they have to be requested dynamically!!
dh.ProxyAddressID = dh.device.ProxyAddress.GetDeviceId()
dh.ProxyAddressType = dh.device.ProxyAddress.GetDeviceType()
- logger.Debugw(ctx, "device-updated", log.Fields{"device-id": dh.deviceID, "proxyAddressID": dh.ProxyAddressID,
+ logger.Debugw(ctx, "device-updated", log.Fields{"device-id": dh.DeviceID, "proxyAddressID": dh.ProxyAddressID,
"proxyAddressType": dh.ProxyAddressType, "SNR": dh.device.SerialNumber,
"ParentId": dh.parentID, "ParentPortNo": dh.ponPortNumber})
@@ -1470,15 +1421,15 @@
oper_status=self._pon.get_port().oper_status,
)
*/
- if !dh.isReconciling() {
- logger.Debugw(ctx, "adding-pon-port", log.Fields{"device-id": dh.deviceID, "ponPortNo": dh.ponPortNumber})
+ if !dh.IsReconciling() {
+ logger.Debugw(ctx, "adding-pon-port", log.Fields{"device-id": dh.DeviceID, "ponPortNo": dh.ponPortNumber})
var ponPortNo uint32 = 1
if dh.ponPortNumber != 0 {
ponPortNo = dh.ponPortNumber
}
pPonPort := &voltha.Port{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
PortNo: ponPortNo,
Label: fmt.Sprintf("pon-%d", ponPortNo),
Type: voltha.Port_PON_ONU,
@@ -1486,13 +1437,13 @@
Peers: []*voltha.Port_PeerPort{{DeviceId: dh.parentID, // Peer device is OLT
PortNo: ponPortNo}}, // Peer port is parent's port number
}
- if err = dh.createPortInCore(ctx, pPonPort); err != nil {
+ if err = dh.CreatePortInCore(ctx, pPonPort); err != nil {
logger.Fatalf(ctx, "Device FSM: PortCreated-failed-%s", err)
e.Cancel(err)
return
}
} else {
- logger.Debugw(ctx, "reconciling - pon-port already added", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - pon-port already added", log.Fields{"device-id": dh.DeviceID})
}
logger.Debug(ctx, "doStateInit-done")
}
@@ -1513,7 +1464,7 @@
return
}
- if dh.isReconciling() {
+ if dh.IsReconciling() {
go dh.reconcileDeviceOnuInd(ctx)
// reconcilement will be continued after mib download is done
}
@@ -1557,7 +1508,7 @@
exclusive=False,
**kwargs_omci_test_action)
- self.enabled = True
+ self.Enabled = True
else:
self.logger.info('onu-already-activated')
*/
@@ -1605,7 +1556,7 @@
device := dh.device
if device == nil {
/*TODO: needs to handle error scenarios */
- logger.Errorw(ctx, "Failed to fetch handler device", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "Failed to fetch handler device", log.Fields{"device-id": dh.DeviceID})
e.Cancel(err)
return
}
@@ -1640,7 +1591,7 @@
// Update onu state as down in onu adapter
onuInd := oop.OnuIndication{}
onuInd.OperState = "down"
- er := dh.AdapterProxy.SendInterAdapterMessage(ctx, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
+ er := dh.adapterProxy.SendInterAdapterMessage(ctx, &onuInd, ic.InterAdapterMessageType_ONU_IND_REQUEST,
"openolt", onuDevice.Type, onuDevice.Id, onuDevice.ProxyAddress.DeviceId, "")
if er != nil {
logger.Errorw("Failed to send inter-adapter-message", log.Fields{"OnuInd": onuInd,
@@ -1665,22 +1616,22 @@
// ###################################################
// deviceHandler utility methods ##### begin #########
-//getOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
-func (dh *deviceHandler) getOnuDeviceEntry(ctx context.Context, aWait bool) *OnuDeviceEntry {
+//GetOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
+func (dh *deviceHandler) GetOnuDeviceEntry(ctx context.Context, aWait bool) *mib.OnuDeviceEntry {
dh.lockDevice.RLock()
pOnuDeviceEntry := dh.pOnuOmciDevice
if aWait && pOnuDeviceEntry == nil {
//keep the read sema short to allow for subsequent write
dh.lockDevice.RUnlock()
- logger.Debugw(ctx, "Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.DeviceID})
// based on concurrent processing the deviceEntry setup may not yet be finished at his point
// so it might be needed to wait here for that event with some timeout
select {
case <-time.After(60 * time.Second): //timer may be discussed ...
- logger.Errorw(ctx, "No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.DeviceID})
return nil
case <-dh.deviceEntrySet:
- logger.Debugw(ctx, "devicEntry ready now - continue", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "devicEntry ready now - continue", log.Fields{"device-id": dh.DeviceID})
// if written now, we can return the written value without sema
return dh.pOnuOmciDevice
}
@@ -1689,9 +1640,9 @@
return pOnuDeviceEntry
}
-//setOnuDeviceEntry sets the ONU device entry within the handler
-func (dh *deviceHandler) setOnuDeviceEntry(
- apDeviceEntry *OnuDeviceEntry, apOnuTp *onuUniTechProf, apOnuMetricsMgr *onuMetricsManager, apOnuAlarmMgr *onuAlarmManager, apSelfTestHdlr *selfTestControlBlock) {
+//setDeviceHandlerEntries sets the ONU device entry within the handler
+func (dh *deviceHandler) setDeviceHandlerEntries(apDeviceEntry *mib.OnuDeviceEntry, apOnuTp *avcfg.OnuUniTechProf,
+ apOnuMetricsMgr *pmmgr.OnuMetricsManager, apOnuAlarmMgr *almgr.OnuAlarmManager, apSelfTestHdlr *otst.SelfTestControlBlock) {
dh.lockDevice.Lock()
defer dh.lockDevice.Unlock()
dh.pOnuOmciDevice = apDeviceEntry
@@ -1703,26 +1654,26 @@
//addOnuDeviceEntry creates a new ONU device or returns the existing
func (dh *deviceHandler) addOnuDeviceEntry(ctx context.Context) error {
- logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.DeviceID})
- deviceEntry := dh.getOnuDeviceEntry(ctx, false)
+ deviceEntry := dh.GetOnuDeviceEntry(ctx, false)
if deviceEntry == nil {
/* costum_me_map in python code seems always to be None,
we omit that here first (declaration unclear) -> todo at Adapter specialization ...*/
/* also no 'clock' argument - usage open ...*/
/* and no alarm_db yet (oo.alarm_db) */
- deviceEntry = newOnuDeviceEntry(ctx, dh)
- onuTechProfProc := newOnuUniTechProf(ctx, dh)
- onuMetricsMgr := newonuMetricsManager(ctx, dh)
- onuAlarmManager := newAlarmManager(ctx, dh)
- selfTestHdlr := newSelfTestMsgHandlerCb(ctx, dh)
+ deviceEntry = mib.NewOnuDeviceEntry(ctx, dh.coreClient, dh, dh.pOpenOnuAc)
+ onuTechProfProc := avcfg.NewOnuUniTechProf(ctx, dh, deviceEntry)
+ onuMetricsMgr := pmmgr.NewOnuMetricsManager(ctx, dh, deviceEntry)
+ onuAlarmManager := almgr.NewAlarmManager(ctx, dh, deviceEntry)
+ selfTestHdlr := otst.NewSelfTestMsgHandlerCb(ctx, dh, deviceEntry)
//error treatment possible //TODO!!!
- dh.setOnuDeviceEntry(deviceEntry, onuTechProfProc, onuMetricsMgr, onuAlarmManager, selfTestHdlr)
+ dh.setDeviceHandlerEntries(deviceEntry, onuTechProfProc, onuMetricsMgr, onuAlarmManager, selfTestHdlr)
// fire deviceEntry ready event to spread to possibly waiting processing
dh.deviceEntrySet <- true
- logger.Debugw(ctx, "onuDeviceEntry-added", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "onuDeviceEntry-added", log.Fields{"device-id": dh.DeviceID})
} else {
- logger.Debugw(ctx, "onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.DeviceID})
}
// might be updated with some error handling !!!
return nil
@@ -1734,45 +1685,45 @@
dh.pOnuIndication = onuind // let's revise if storing the pointer is sufficient...
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
- if !dh.isReconciling() {
- if err := dh.storePersistentData(ctx); err != nil {
+ if !dh.IsReconciling() {
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
logger.Debugw(ctx, "call DeviceStateUpdate upon create interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_ACTIVATING, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_ACTIVATING, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
OperStatus: voltha.OperStatus_ACTIVATING,
ConnStatus: voltha.ConnectStatus_REACHABLE,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
}
} else {
logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVATING",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
- pDevEntry.mutexPersOnuConfig.RLock()
- if !pDevEntry.sOnuPersistentData.PersUniUnlockDone {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RLock()
+ if !pDevEntry.SOnuPersistentData.PersUniUnlockDone {
+ pDevEntry.MutexPersOnuConfig.RUnlock()
logger.Debugw(ctx, "reconciling - uni-ports were not unlocked before adapter restart - resume with a normal start-up",
- log.Fields{"device-id": dh.deviceID})
- dh.stopReconciling(ctx, true)
+ log.Fields{"device-id": dh.DeviceID})
+ dh.StopReconciling(ctx, true)
} else {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RUnlock()
}
}
// It does not look to me as if makes sense to work with the real core device here, (not the stored clone)?
// in this code the GetDevice would just make a check if the DeviceID's Device still exists in core
// in python code it looks as the started onu_omci_device might have been updated with some new instance state of the core device
- // but I would not know why, and the go code anyway does not work with the device directly anymore in the OnuDeviceEntry
+ // but I would not know why, and the go code anyway does not work with the device directly anymore in the mib.OnuDeviceEntry
// so let's just try to keep it simple ...
/*
device, err := dh.coreProxy.GetDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, dh.device.Id)
@@ -1783,18 +1734,18 @@
}
*/
- if err := pDevEntry.start(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+ if err := pDevEntry.Start(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
return err
}
- _ = dh.deviceReasonUpdate(ctx, drStartingOpenomci, !dh.isReconciling())
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrStartingOpenomci, !dh.IsReconciling())
/* this might be a good time for Omci Verify message? */
verifyExec := make(chan bool)
- omciVerify := newOmciTestRequest(log.WithSpanFromContext(context.TODO(), ctx),
+ omciVerify := otst.NewOmciTestRequest(log.WithSpanFromContext(context.TODO(), ctx),
dh.device.Id, pDevEntry.PDevOmciCC,
true, true) //exclusive and allowFailure (anyway not yet checked)
- omciVerify.performOmciTest(log.WithSpanFromContext(context.TODO(), ctx), verifyExec)
+ omciVerify.PerformOmciTest(log.WithSpanFromContext(context.TODO(), ctx), verifyExec)
/* give the handler some time here to wait for the OMCi verification result
after Timeout start and try MibUpload FSM anyway
@@ -1877,44 +1828,44 @@
*/
// PM related heartbeat??? !!!TODO....
- //self._heartbeat.enabled = True
+ //self._heartbeat.Enabled = True
/* 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 synchronization would be required - cmp. e.g TechProfile processing
*/
- //call MibUploadFSM - transition up to state ulStInSync
- pMibUlFsm := pDevEntry.pMibUploadFsm.pFsm
+ //call MibUploadFSM - transition up to state UlStInSync
+ pMibUlFsm := pDevEntry.PMibUploadFsm.PFsm
if pMibUlFsm != nil {
- if pMibUlFsm.Is(ulStDisabled) {
- if err := pMibUlFsm.Event(ulEvStart); err != nil {
- logger.Errorw(ctx, "MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
- return fmt.Errorf("can't go to state starting: %s", dh.deviceID)
+ if pMibUlFsm.Is(mib.UlStDisabled) {
+ if err := pMibUlFsm.Event(mib.UlEvStart); err != nil {
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.DeviceID, "err": err})
+ return fmt.Errorf("can't go to state starting: %s", dh.DeviceID)
}
logger.Debugw(ctx, "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 pDevEntry.isNewOnu() {
- if err := pMibUlFsm.Event(ulEvResetMib); err != nil {
- logger.Errorw(ctx, "MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.deviceID, "err": err})
- return fmt.Errorf("can't go to state resetting_mib: %s", dh.deviceID)
+ if pDevEntry.IsNewOnu() {
+ if err := pMibUlFsm.Event(mib.UlEvResetMib); err != nil {
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.DeviceID, "err": err})
+ return fmt.Errorf("can't go to state resetting_mib: %s", dh.DeviceID)
}
} else {
- if err := pMibUlFsm.Event(ulEvExamineMds); err != nil {
- logger.Errorw(ctx, "MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.deviceID, "err": err})
- return fmt.Errorf("can't go to examine_mds: %s", dh.deviceID)
+ if err := pMibUlFsm.Event(mib.UlEvExamineMds); err != nil {
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.DeviceID, "err": err})
+ return fmt.Errorf("can't go to examine_mds: %s", dh.DeviceID)
}
logger.Debugw(ctx, "state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
}
} else {
logger.Errorw(ctx, "wrong state of MibSyncFsm - want: disabled", log.Fields{"have": string(pMibUlFsm.Current()),
- "device-id": dh.deviceID})
- return fmt.Errorf("wrong state of MibSyncFsm: %s", dh.deviceID)
+ "device-id": dh.DeviceID})
+ return fmt.Errorf("wrong state of MibSyncFsm: %s", dh.DeviceID)
}
} else {
- logger.Errorw(ctx, "MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("can't execute MibSync: %s", dh.deviceID)
+ logger.Errorw(ctx, "MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("can't execute MibSync: %s", dh.DeviceID)
}
return nil
}
@@ -1922,15 +1873,15 @@
func (dh *deviceHandler) updateInterface(ctx context.Context, onuind *oop.OnuIndication) error {
//state checking to prevent unneeded processing (eg. on ONU 'unreachable' and 'down')
// (but note that the deviceReason may also have changed to e.g. TechProf*Delete_Success in between)
- if dh.getDeviceReason() != drStoppingOpenomci {
- logger.Debugw(ctx, "updateInterface-started - stopping-device", log.Fields{"device-id": dh.deviceID})
+ if dh.getDeviceReason() != cmn.DrStoppingOpenomci {
+ logger.Debugw(ctx, "updateInterface-started - stopping-device", log.Fields{"device-id": dh.DeviceID})
//stop all running FSM processing - make use of the DH-state as mirrored in the deviceReason
//here no conflict with aborted FSM's should arise as a complete OMCI initialization is assumed on ONU-Up
//but that might change with some simple MDS check on ONU-Up treatment -> attention!!!
if err := dh.resetFsms(ctx, true); err != nil {
logger.Errorw(ctx, "error-updateInterface at FSM stop",
- log.Fields{"device-id": dh.deviceID, "error": err})
+ log.Fields{"device-id": dh.DeviceID, "error": err})
// abort: system behavior is just unstable ...
return err
}
@@ -1940,12 +1891,12 @@
//deviceEntry stop without omciCC reset here, regarding the OMCI_CC still valid for this ONU
// - in contrary to disableDevice - compare with processUniDisableStateDoneEvent
//stop the device entry which resets the attached omciCC
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
- _ = pDevEntry.stop(log.WithSpanFromContext(context.TODO(), ctx), false)
+ _ = pDevEntry.Stop(log.WithSpanFromContext(context.TODO(), ctx), false)
//TODO!!! remove existing traffic profiles
/* from py code, if TP's exist, remove them - not yet implemented
@@ -1957,29 +1908,29 @@
self._tech_profile_download_done[uni_id].clear()
*/
- dh.disableUniPortStateUpdate(ctx)
+ dh.DisableUniPortStateUpdate(ctx)
- dh.setReadyForOmciConfig(false)
+ dh.SetReadyForOmciConfig(false)
- if err := dh.deviceReasonUpdate(ctx, drStoppingOpenomci, true); err != nil {
+ if err := dh.deviceReasonUpdate(ctx, cmn.DrStoppingOpenomci, true); err != nil {
// abort: system behavior is just unstable ...
return err
}
logger.Debugw(ctx, "call DeviceStateUpdate upon update interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_UNREACHABLE,
- "OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_UNREACHABLE,
OperStatus: voltha.OperStatus_DISCOVERED,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
logger.Errorw(ctx, "error-updating-device-state unreachable-discovered",
- log.Fields{"device-id": dh.deviceID, "error": err})
+ log.Fields{"device-id": dh.DeviceID, "error": err})
// abort: system behavior is just unstable ...
return err
}
} else {
- logger.Debugw(ctx, "updateInterface - device already stopped", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "updateInterface - device already stopped", log.Fields{"device-id": dh.DeviceID})
}
return nil
}
@@ -1990,48 +1941,48 @@
// as after down/up procedures all FSM's might be active/ongoing (in theory)
// and using the stop/reset event should never harm
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
if pDevEntry.PDevOmciCC != nil {
pDevEntry.PDevOmciCC.CancelRequestMonitoring(ctx)
}
- pDevEntry.mutexOnuImageStatus.RLock()
- if pDevEntry.pOnuImageStatus != nil {
- pDevEntry.pOnuImageStatus.CancelProcessing(ctx)
+ pDevEntry.MutexOnuImageStatus.RLock()
+ if pDevEntry.POnuImageStatus != nil {
+ pDevEntry.POnuImageStatus.CancelProcessing(ctx)
}
- pDevEntry.mutexOnuImageStatus.RUnlock()
+ pDevEntry.MutexOnuImageStatus.RUnlock()
if includingMibSyncFsm {
pDevEntry.CancelProcessing(ctx)
}
//MibDownload may run
- pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
+ pMibDlFsm := pDevEntry.PMibDownloadFsm.PFsm
if pMibDlFsm != nil {
- _ = pMibDlFsm.Event(dlEvReset)
+ _ = pMibDlFsm.Event(mib.DlEvReset)
}
//port lock/unlock FSM's may be active
if dh.pUnlockStateFsm != nil {
- _ = dh.pUnlockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pUnlockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
}
if dh.pLockStateFsm != nil {
- _ = dh.pLockStateFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = dh.pLockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
}
//techProfile related PonAniConfigFsm FSM may be active
if dh.pOnuTP != nil {
// should always be the case here
// FSM stop maybe encapsulated as OnuTP method - perhaps later in context of module splitting
- if dh.pOnuTP.pAniConfigFsm != nil {
- for uniTP := range dh.pOnuTP.pAniConfigFsm {
- dh.pOnuTP.pAniConfigFsm[uniTP].CancelProcessing(ctx)
+ if dh.pOnuTP.PAniConfigFsm != nil {
+ for uniTP := range dh.pOnuTP.PAniConfigFsm {
+ dh.pOnuTP.PAniConfigFsm[uniTP].CancelProcessing(ctx)
}
}
for _, uniPort := range dh.uniEntityMap {
// reset the possibly existing VlanConfigFsm
dh.lockVlanConfig.RLock()
- if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[uniPort.uniID]; exist {
+ if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[uniPort.UniID]; exist {
//VlanFilterFsm exists and was already started
dh.lockVlanConfig.RUnlock()
//reset of all Fsm is always accompanied by global persistency data removal
@@ -2044,41 +1995,41 @@
}
}
}
- if dh.getCollectorIsRunning() {
+ if dh.GetCollectorIsRunning() {
// Stop collector routine
dh.stopCollector <- true
}
- if dh.getAlarmManagerIsRunning(ctx) {
+ if dh.GetAlarmManagerIsRunning(ctx) {
dh.stopAlarmManager <- true
}
if dh.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
- dh.pSelfTestHdlr.stopSelfTestModule <- true
+ dh.pSelfTestHdlr.StopSelfTestModule <- true
}
//reset a possibly running upgrade FSM
- // (note the Upgrade FSM may stay alive e.g. in state upgradeStWaitForCommit to endure the ONU reboot)
+ // (note the Upgrade FSM may stay alive e.g. in state UpgradeStWaitForCommit to endure the ONU reboot)
dh.lockUpgradeFsm.RLock()
lopOnuUpradeFsm := dh.pOnuUpradeFsm
- //lockUpgradeFsm must be release before cancellation as this may implicitly request removeOnuUpgradeFsm()
+ //lockUpgradeFsm must be release before cancellation as this may implicitly request RemoveOnuUpgradeFsm()
dh.lockUpgradeFsm.RUnlock()
if lopOnuUpradeFsm != nil {
lopOnuUpradeFsm.CancelProcessing(ctx, false, voltha.ImageState_CANCELLED_ON_ONU_STATE) //conditional cancel
}
- logger.Infow(ctx, "resetFsms done", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "resetFsms done", log.Fields{"device-id": dh.DeviceID})
return nil
}
-func (dh *deviceHandler) processMibDatabaseSyncEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- logger.Debugw(ctx, "MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDatabaseSyncEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ logger.Debugw(ctx, "MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.DeviceID})
// store persistent data collected during MIB upload processing
- if err := dh.storePersistentData(ctx); err != nil {
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
- _ = dh.deviceReasonUpdate(ctx, drDiscoveryMibsyncComplete, !dh.isReconciling())
- dh.addAllUniPorts(ctx)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrDiscoveryMibsyncComplete, !dh.IsReconciling())
+ dh.AddAllUniPorts(ctx)
/* 200605: lock processing after initial MIBUpload removed now as the ONU should be in the lock state per default here */
/* 201117: build_dt-berlin-pod-openonugo_1T8GEM_voltha_DT_openonugo_master_test runs into error TC
@@ -2093,34 +2044,34 @@
// Init Uni Ports to Admin locked state
// *** should generate UniLockStateDone event *****
if dh.pLockStateFsm == nil {
- dh.createUniLockFsm(ctx, true, UniLockStateDone)
+ dh.createUniLockFsm(ctx, true, cmn.UniLockStateDone)
} else { //LockStateFSM already init
- dh.pLockStateFsm.setSuccessEvent(UniLockStateDone)
+ dh.pLockStateFsm.SetSuccessEvent(cmn.UniLockStateDone)
dh.runUniLockFsm(ctx, true)
}
}
-func (dh *deviceHandler) processUniLockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- logger.Infow(ctx, "UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processUniLockStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ logger.Infow(ctx, "UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.DeviceID})
/* Mib download procedure -
***** should run over 'downloaded' state and generate MibDownloadDone event *****
*/
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
+ pMibDlFsm := pDevEntry.PMibDownloadFsm.PFsm
if pMibDlFsm != nil {
- if pMibDlFsm.Is(dlStDisabled) {
- if err := pMibDlFsm.Event(dlEvStart); err != nil {
- logger.Errorw(ctx, "MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
+ if pMibDlFsm.Is(mib.DlStDisabled) {
+ if err := pMibDlFsm.Event(mib.DlEvStart); err != nil {
+ logger.Errorw(ctx, "MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.DeviceID, "err": err})
// maybe try a FSM reset and then again ... - TODO!!!
} else {
logger.Debugw(ctx, "MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
// maybe use more specific states here for the specific download steps ...
- if err := pMibDlFsm.Event(dlEvCreateGal); err != nil {
- logger.Errorw(ctx, "MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.deviceID, "err": err})
+ if err := pMibDlFsm.Event(mib.DlEvCreateGal); err != nil {
+ logger.Errorw(ctx, "MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.DeviceID, "err": err})
} else {
logger.Debugw(ctx, "state of MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
//Begin MIB data download (running autonomously)
@@ -2128,349 +2079,349 @@
}
} else {
logger.Errorw(ctx, "wrong state of MibDownloadFsm - want: disabled", log.Fields{"have": string(pMibDlFsm.Current()),
- "device-id": dh.deviceID})
+ "device-id": dh.DeviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
/***** Mib download started */
} else {
- logger.Errorw(ctx, "MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
}
}
-func (dh *deviceHandler) processMibDownloadDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- logger.Debugw(ctx, "MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDownloadDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ logger.Debugw(ctx, "MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.DeviceID})
//initiate DevStateUpdate
- if !dh.isReconciling() {
+ if !dh.IsReconciling() {
logger.Debugw(ctx, "call DeviceStateUpdate upon mib-download done", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.DeviceID})
//we allow a possible OnuSw image commit only in the normal startup, not at reconciling
// in case of adapter restart connected to an ONU upgrade I would not rely on the image quality
// maybe some 'forced' commitment can be done in this situation from system management (or upgrade restarted)
dh.checkOnOnuImageCommit(ctx)
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_REACHABLE,
OperStatus: voltha.OperStatus_ACTIVE,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
} else {
- logger.Debugw(ctx, "dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.DeviceID})
}
} else {
logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVE",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
}
- _ = dh.deviceReasonUpdate(ctx, drInitialMibDownloaded, !dh.isReconciling())
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrInitialMibDownloaded, !dh.IsReconciling())
- if !dh.getCollectorIsRunning() {
+ if !dh.GetCollectorIsRunning() {
// Start PM collector routine
- go dh.startCollector(ctx)
+ go dh.StartCollector(ctx)
}
- if !dh.getAlarmManagerIsRunning(ctx) {
- go dh.startAlarmManager(ctx)
+ if !dh.GetAlarmManagerIsRunning(ctx) {
+ go dh.StartAlarmManager(ctx)
}
// Initialize classical L2 PM Interval Counters
- if err := dh.pOnuMetricsMgr.pAdaptFsm.pFsm.Event(l2PmEventInit); err != nil {
+ if err := dh.pOnuMetricsMgr.PAdaptFsm.PFsm.Event(pmmgr.L2PmEventInit); err != nil {
// There is no way we should be landing here, but if we do then
// there is nothing much we can do about this other than log error
logger.Errorw(ctx, "error starting l2 pm fsm", log.Fields{"device-id": dh.device.Id, "err": err})
}
- dh.setReadyForOmciConfig(true)
+ dh.SetReadyForOmciConfig(true)
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pDevEntry.mutexPersOnuConfig.RLock()
- if dh.isReconciling() && pDevEntry.sOnuPersistentData.PersUniDisableDone {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RLock()
+ if dh.IsReconciling() && pDevEntry.SOnuPersistentData.PersUniDisableDone {
+ pDevEntry.MutexPersOnuConfig.RUnlock()
logger.Debugw(ctx, "reconciling - uni-ports were disabled by admin before adapter restart - keep the ports locked",
- log.Fields{"device-id": dh.deviceID})
- go dh.reconcileDeviceTechProf(ctx)
+ log.Fields{"device-id": dh.DeviceID})
+ go dh.ReconcileDeviceTechProf(ctx)
// reconcilement will be continued after ani config is done
} else {
- pDevEntry.mutexPersOnuConfig.RUnlock()
+ pDevEntry.MutexPersOnuConfig.RUnlock()
// *** should generate UniUnlockStateDone event *****
if dh.pUnlockStateFsm == nil {
- dh.createUniLockFsm(ctx, false, UniUnlockStateDone)
+ dh.createUniLockFsm(ctx, false, cmn.UniUnlockStateDone)
} else { //UnlockStateFSM already init
- dh.pUnlockStateFsm.setSuccessEvent(UniUnlockStateDone)
+ dh.pUnlockStateFsm.SetSuccessEvent(cmn.UniUnlockStateDone)
dh.runUniLockFsm(ctx, false)
}
}
}
-func (dh *deviceHandler) processUniUnlockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- dh.enableUniPortStateUpdate(ctx) //cmp python yield self.enable_ports()
+func (dh *deviceHandler) processUniUnlockStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ dh.EnableUniPortStateUpdate(ctx) //cmp python yield self.enable_ports()
- if !dh.isReconciling() {
- logger.Infow(ctx, "UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.deviceID})
+ if !dh.IsReconciling() {
+ logger.Infow(ctx, "UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.DeviceID})
raisedTs := time.Now().Unix()
- go dh.sendOnuOperStateEvent(ctx, voltha.OperStatus_ACTIVE, dh.deviceID, raisedTs) //cmp python onu_active_event
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ go dh.sendOnuOperStateEvent(ctx, voltha.OperStatus_ACTIVE, dh.DeviceID, raisedTs) //cmp python onu_active_event
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pDevEntry.mutexPersOnuConfig.Lock()
- pDevEntry.sOnuPersistentData.PersUniUnlockDone = true
- pDevEntry.mutexPersOnuConfig.Unlock()
- if err := dh.storePersistentData(ctx); err != nil {
+ pDevEntry.MutexPersOnuConfig.Lock()
+ pDevEntry.SOnuPersistentData.PersUniUnlockDone = true
+ pDevEntry.MutexPersOnuConfig.Unlock()
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
} else {
logger.Debugw(ctx, "reconciling - don't notify core that onu went to active but trigger tech profile config",
- log.Fields{"device-id": dh.deviceID})
- go dh.reconcileDeviceTechProf(ctx)
+ log.Fields{"device-id": dh.DeviceID})
+ go dh.ReconcileDeviceTechProf(ctx)
// reconcilement will be continued after ani config is done
}
}
-func (dh *deviceHandler) processUniDisableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processUniDisableStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_REACHABLE,
OperStatus: voltha.OperStatus_UNKNOWN,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
}
- logger.Debugw(ctx, "DeviceReasonUpdate upon disable", log.Fields{"reason": deviceReasonMap[drOmciAdminLock], "device-id": dh.deviceID})
+ logger.Debugw(ctx, "DeviceReasonUpdate upon disable", log.Fields{"reason": cmn.DeviceReasonMap[cmn.DrOmciAdminLock], "device-id": dh.DeviceID})
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
- _ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrOmciAdminLock, true)
//transfer the modified logical uni port state
- dh.disableUniPortStateUpdate(ctx)
+ dh.DisableUniPortStateUpdate(ctx)
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pDevEntry.mutexPersOnuConfig.Lock()
- pDevEntry.sOnuPersistentData.PersUniDisableDone = true
- pDevEntry.mutexPersOnuConfig.Unlock()
- if err := dh.storePersistentData(ctx); err != nil {
+ pDevEntry.MutexPersOnuConfig.Lock()
+ pDevEntry.SOnuPersistentData.PersUniDisableDone = true
+ pDevEntry.MutexPersOnuConfig.Unlock()
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
}
-func (dh *deviceHandler) processUniEnableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processUniEnableStateDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
logger.Debugw(ctx, "DeviceStateUpdate upon re-enable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
- "OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
+ "OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: voltha.ConnectStatus_REACHABLE,
OperStatus: voltha.OperStatus_ACTIVE,
}); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.DeviceID, "error": err})
}
logger.Debugw(ctx, "DeviceReasonUpdate upon re-enable", log.Fields{
- "reason": deviceReasonMap[drOnuReenabled], "device-id": dh.deviceID})
+ "reason": cmn.DeviceReasonMap[cmn.DrOnuReenabled], "device-id": dh.DeviceID})
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
- _ = dh.deviceReasonUpdate(ctx, drOnuReenabled, true)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrOnuReenabled, true)
//transfer the modified logical uni port state
- dh.enableUniPortStateUpdate(ctx)
+ dh.EnableUniPortStateUpdate(ctx)
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pDevEntry.mutexPersOnuConfig.Lock()
- pDevEntry.sOnuPersistentData.PersUniDisableDone = false
- pDevEntry.mutexPersOnuConfig.Unlock()
- if err := dh.storePersistentData(ctx); err != nil {
+ pDevEntry.MutexPersOnuConfig.Lock()
+ pDevEntry.SOnuPersistentData.PersUniDisableDone = false
+ pDevEntry.MutexPersOnuConfig.Unlock()
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
}
-func (dh *deviceHandler) processOmciAniConfigDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- if devEvent == OmciAniConfigDone {
- logger.Debugw(ctx, "OmciAniConfigDone event received", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processOmciAniConfigDoneEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ if devEvent == cmn.OmciAniConfigDone {
+ logger.Debugw(ctx, "OmciAniConfigDone event received", log.Fields{"device-id": dh.DeviceID})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
- if dh.getDeviceReason() != drTechProfileConfigDownloadSuccess {
+ if dh.getDeviceReason() != cmn.DrTechProfileConfigDownloadSuccess {
// which may be the case from some previous actvity even on this UNI Port (but also other UNI ports)
- _ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDownloadSuccess, !dh.isReconciling())
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrTechProfileConfigDownloadSuccess, !dh.IsReconciling())
}
- if dh.isReconciling() {
- go dh.reconcileDeviceFlowConfig(ctx)
+ if dh.IsReconciling() {
+ go dh.ReconcileDeviceFlowConfig(ctx)
}
} else { // should be the OmciAniResourceRemoved block
- logger.Debugw(ctx, "OmciAniResourceRemoved event received", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "OmciAniResourceRemoved event received", log.Fields{"device-id": dh.DeviceID})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
- if dh.getDeviceReason() != drTechProfileConfigDeleteSuccess {
+ if dh.getDeviceReason() != cmn.DrTechProfileConfigDeleteSuccess {
// which may be the case from some previous actvity even on this ONU port (but also other UNI ports)
- _ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDeleteSuccess, true)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrTechProfileConfigDeleteSuccess, true)
}
}
}
-func (dh *deviceHandler) processOmciVlanFilterDoneEvent(ctx context.Context, aDevEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processOmciVlanFilterDoneEvent(ctx context.Context, aDevEvent cmn.OnuDeviceEvent) {
logger.Debugw(ctx, "OmciVlanFilterDone event received",
- log.Fields{"device-id": dh.deviceID, "event": aDevEvent})
+ log.Fields{"device-id": dh.DeviceID, "event": aDevEvent})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
- if aDevEvent == OmciVlanFilterAddDone || aDevEvent == OmciVlanFilterAddDoneNoKvStore {
- if dh.getDeviceReason() != drOmciFlowsPushed {
+ if aDevEvent == cmn.OmciVlanFilterAddDone || aDevEvent == cmn.OmciVlanFilterAddDoneNoKvStore {
+ if dh.getDeviceReason() != cmn.DrOmciFlowsPushed {
// which may be the case from some previous actvity on another UNI Port of the ONU
// or even some previous flow add activity on the same port
- _ = dh.deviceReasonUpdate(ctx, drOmciFlowsPushed, !dh.isReconciling())
- if dh.isReconciling() {
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrOmciFlowsPushed, !dh.IsReconciling())
+ if dh.IsReconciling() {
go dh.reconcileEnd(ctx)
}
}
} else {
- if dh.getDeviceReason() != drOmciFlowsDeleted {
+ if dh.getDeviceReason() != cmn.DrOmciFlowsDeleted {
//not relevant for reconcile
- _ = dh.deviceReasonUpdate(ctx, drOmciFlowsDeleted, true)
+ _ = dh.deviceReasonUpdate(ctx, cmn.DrOmciFlowsDeleted, true)
}
}
- if aDevEvent == OmciVlanFilterAddDone || aDevEvent == OmciVlanFilterRemDone {
+ if aDevEvent == cmn.OmciVlanFilterAddDone || aDevEvent == cmn.OmciVlanFilterRemDone {
//events that request KvStore write
- if err := dh.storePersistentData(ctx); err != nil {
+ if err := dh.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
- log.Fields{"device-id": dh.deviceID, "err": err})
+ log.Fields{"device-id": dh.DeviceID, "err": err})
}
} else {
logger.Debugw(ctx, "OmciVlanFilter*Done* - write to KvStore not requested",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
}
}
-//deviceProcStatusUpdate evaluates possible processing events and initiates according next activities
-func (dh *deviceHandler) deviceProcStatusUpdate(ctx context.Context, devEvent OnuDeviceEvent) {
+//DeviceProcStatusUpdate evaluates possible processing events and initiates according next activities
+func (dh *deviceHandler) DeviceProcStatusUpdate(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
switch devEvent {
- case MibDatabaseSync:
+ case cmn.MibDatabaseSync:
{
dh.processMibDatabaseSyncEvent(ctx, devEvent)
}
- case UniLockStateDone:
+ case cmn.UniLockStateDone:
{
dh.processUniLockStateDoneEvent(ctx, devEvent)
}
- case MibDownloadDone:
+ case cmn.MibDownloadDone:
{
dh.processMibDownloadDoneEvent(ctx, devEvent)
}
- case UniUnlockStateDone:
+ case cmn.UniUnlockStateDone:
{
dh.processUniUnlockStateDoneEvent(ctx, devEvent)
}
- case UniEnableStateDone:
+ case cmn.UniEnableStateDone:
{
dh.processUniEnableStateDoneEvent(ctx, devEvent)
}
- case UniDisableStateDone:
+ case cmn.UniDisableStateDone:
{
dh.processUniDisableStateDoneEvent(ctx, devEvent)
}
- case OmciAniConfigDone, OmciAniResourceRemoved:
+ case cmn.OmciAniConfigDone, cmn.OmciAniResourceRemoved:
{
dh.processOmciAniConfigDoneEvent(ctx, devEvent)
}
- case OmciVlanFilterAddDone, OmciVlanFilterAddDoneNoKvStore, OmciVlanFilterRemDone, OmciVlanFilterRemDoneNoKvStore:
+ case cmn.OmciVlanFilterAddDone, cmn.OmciVlanFilterAddDoneNoKvStore, cmn.OmciVlanFilterRemDone, cmn.OmciVlanFilterRemDoneNoKvStore:
{
dh.processOmciVlanFilterDoneEvent(ctx, devEvent)
}
default:
{
- logger.Debugw(ctx, "unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
+ logger.Debugw(ctx, "unhandled-device-event", log.Fields{"device-id": dh.DeviceID, "event": devEvent})
}
} //switch
}
-func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType uniPortType) {
+func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType cmn.UniPortType) {
// parameters are IntfId, OnuId, uniId
uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
uint32(aUniID))
if _, present := dh.uniEntityMap[uniNo]; present {
- logger.Warnw(ctx, "onuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
+ logger.Warnw(ctx, "OnuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
} else {
//with arguments aUniID, a_portNo, aPortType
- pUniPort := newOnuUniPort(ctx, aUniID, uniNo, aUniInstNo, aPortType)
+ pUniPort := cmn.NewOnuUniPort(ctx, aUniID, uniNo, aUniInstNo, aPortType)
if pUniPort == nil {
- logger.Warnw(ctx, "onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
+ logger.Warnw(ctx, "OnuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
} else {
//store UniPort with the System-PortNumber key
dh.uniEntityMap[uniNo] = pUniPort
- if !dh.isReconciling() {
+ if !dh.IsReconciling() {
// create announce the UniPort to the core as VOLTHA Port object
- if err := pUniPort.createVolthaPort(ctx, dh); err == nil {
- logger.Infow(ctx, "onuUniPort-added", log.Fields{"for PortNo": uniNo})
+ if err := pUniPort.CreateVolthaPort(ctx, dh); err == nil {
+ logger.Infow(ctx, "OnuUniPort-added", log.Fields{"for PortNo": uniNo})
} //error logging already within UniPort method
} else {
- logger.Debugw(ctx, "reconciling - onuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - OnuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
}
}
}
}
-func (dh *deviceHandler) addAllUniPorts(ctx context.Context) {
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+func (dh *deviceHandler) AddAllUniPorts(ctx context.Context) {
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
return
}
i := uint8(0) //UNI Port limit: see MaxUnisPerOnu (by now 16) (OMCI supports max 255 p.b.)
- if pptpInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+ if pptpInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
ctx, me.PhysicalPathTerminationPointEthernetUniClassID); len(pptpInstKeys) > 0 {
for _, mgmtEntityID := range pptpInstKeys {
logger.Debugw(ctx, "Add PPTPEthUni port for MIB-stored instance:", log.Fields{
- "device-id": dh.deviceID, "PPTPEthUni EntityID": mgmtEntityID})
- dh.addUniPort(ctx, mgmtEntityID, i, uniPPTP)
+ "device-id": dh.DeviceID, "PPTPEthUni EntityID": mgmtEntityID})
+ dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniPPTP)
i++
}
} else {
- logger.Debugw(ctx, "No PPTP instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "No PPTP instances found", log.Fields{"device-id": dh.DeviceID})
}
- if veipInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+ if veipInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
ctx, me.VirtualEthernetInterfacePointClassID); len(veipInstKeys) > 0 {
for _, mgmtEntityID := range veipInstKeys {
logger.Debugw(ctx, "Add VEIP for MIB-stored instance:", log.Fields{
- "device-id": dh.deviceID, "VEIP EntityID": mgmtEntityID})
- dh.addUniPort(ctx, mgmtEntityID, i, uniVEIP)
+ "device-id": dh.DeviceID, "VEIP EntityID": mgmtEntityID})
+ dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniVEIP)
i++
}
} else {
- logger.Debugw(ctx, "No VEIP instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "No VEIP instances found", log.Fields{"device-id": dh.DeviceID})
}
- if potsInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(
+ if potsInstKeys := pDevEntry.GetOnuDB().GetSortedInstKeys(
ctx, me.PhysicalPathTerminationPointPotsUniClassID); len(potsInstKeys) > 0 {
for _, mgmtEntityID := range potsInstKeys {
logger.Debugw(ctx, "Add PPTP Pots UNI for MIB-stored instance:", log.Fields{
- "device-id": dh.deviceID, "PPTP Pots UNI EntityID": mgmtEntityID})
- dh.addUniPort(ctx, mgmtEntityID, i, uniPPTPPots)
+ "device-id": dh.DeviceID, "PPTP Pots UNI EntityID": mgmtEntityID})
+ dh.addUniPort(ctx, mgmtEntityID, i, cmn.UniPPTPPots)
i++
}
} else {
- logger.Debugw(ctx, "No PPTP Pots UNI instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "No PPTP Pots UNI instances found", log.Fields{"device-id": dh.DeviceID})
}
if i == 0 {
- logger.Warnw(ctx, "No UniG instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Warnw(ctx, "No UniG instances found", log.Fields{"device-id": dh.DeviceID})
}
}
-// enableUniPortStateUpdate enables UniPortState and update core port state accordingly
-func (dh *deviceHandler) enableUniPortStateUpdate(ctx context.Context) {
+// EnableUniPortStateUpdate enables UniPortState and update core port state accordingly
+func (dh *deviceHandler) EnableUniPortStateUpdate(ctx context.Context) {
// 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 signaled
// with following remark:
@@ -2481,52 +2432,52 @@
for uniNo, uniPort := range dh.uniEntityMap {
// only if this port is validated for operState transfer
- if (1<<uniPort.uniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.uniID) {
- logger.Infow(ctx, "onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
- uniPort.setOperState(vc.OperStatus_ACTIVE)
- if !dh.isReconciling() {
+ if (1<<uniPort.UniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.UniID) {
+ logger.Infow(ctx, "OnuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
+ uniPort.SetOperState(vc.OperStatus_ACTIVE)
+ if !dh.IsReconciling() {
//maybe also use getter functions on uniPort - perhaps later ...
- go func(port *onuUniPort) {
+ go func(port *cmn.OnuUniPort) {
if err := dh.updatePortStateInCore(ctx, &ic.PortState{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
PortType: voltha.Port_ETHERNET_UNI,
- PortNo: port.portNo,
- OperStatus: port.operState,
+ PortNo: port.PortNo,
+ OperStatus: port.OperState,
}); err != nil {
- logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.portNo, "device-id": dh.deviceID})
+ logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.PortNo, "device-id": dh.DeviceID})
}
}(uniPort)
} else {
- logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.DeviceID})
}
}
}
}
// Disable UniPortState and update core port state accordingly
-func (dh *deviceHandler) disableUniPortStateUpdate(ctx context.Context) {
- // compare enableUniPortStateUpdate() above
+func (dh *deviceHandler) DisableUniPortStateUpdate(ctx context.Context) {
+ // compare EnableUniPortStateUpdate() above
// -> use current restriction to operate only on first UNI port as inherited from actual Py code
for uniNo, uniPort := range dh.uniEntityMap {
// only if this port is validated for operState transfer
- if (1<<uniPort.uniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.uniID) {
- logger.Infow(ctx, "onuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
- uniPort.setOperState(vc.OperStatus_UNKNOWN)
- if !dh.isReconciling() {
+ if (1<<uniPort.UniID)&dh.pOpenOnuAc.config.UniPortMask == (1 << uniPort.UniID) {
+ logger.Infow(ctx, "OnuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo, "device-id": dh.DeviceID})
+ uniPort.SetOperState(vc.OperStatus_UNKNOWN)
+ if !dh.IsReconciling() {
//maybe also use getter functions on uniPort - perhaps later ...
- go func(port *onuUniPort) {
+ go func(port *cmn.OnuUniPort) {
if err := dh.updatePortStateInCore(ctx, &ic.PortState{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
PortType: voltha.Port_ETHERNET_UNI,
- PortNo: port.portNo,
- OperStatus: port.operState,
+ PortNo: port.PortNo,
+ OperStatus: port.OperState,
}); err != nil {
- logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.portNo, "device-id": dh.deviceID})
+ logger.Errorw(ctx, "port-state-update-failed", log.Fields{"error": err, "port-no": uniPort.PortNo, "device-id": dh.DeviceID})
}
}(uniPort)
} else {
- logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.DeviceID})
}
}
@@ -2555,15 +2506,15 @@
eventContext["device-id"] = aDeviceID
eventContext["registration-id"] = aDeviceID //py: string(device_id)??
eventContext["num-of-unis"] = strconv.Itoa(len(dh.uniEntityMap))
- if deviceEntry := dh.getOnuDeviceEntry(ctx, false); deviceEntry != nil {
- deviceEntry.mutexPersOnuConfig.RLock()
- eventContext["equipment-id"] = deviceEntry.sOnuPersistentData.PersEquipmentID
- deviceEntry.mutexPersOnuConfig.RUnlock()
- eventContext["software-version"] = deviceEntry.getActiveImageVersion(ctx)
- deviceEntry.mutexPersOnuConfig.RLock()
- eventContext["vendor"] = deviceEntry.sOnuPersistentData.PersVendorID
- deviceEntry.mutexPersOnuConfig.RUnlock()
- eventContext["inactive-software-version"] = deviceEntry.getInactiveImageVersion(ctx)
+ if deviceEntry := dh.GetOnuDeviceEntry(ctx, false); deviceEntry != nil {
+ deviceEntry.MutexPersOnuConfig.RLock()
+ eventContext["equipment-id"] = deviceEntry.SOnuPersistentData.PersEquipmentID
+ deviceEntry.MutexPersOnuConfig.RUnlock()
+ eventContext["software-version"] = deviceEntry.GetActiveImageVersion(ctx)
+ deviceEntry.MutexPersOnuConfig.RLock()
+ eventContext["vendor"] = deviceEntry.SOnuPersistentData.PersVendorID
+ deviceEntry.MutexPersOnuConfig.RUnlock()
+ eventContext["inactive-software-version"] = deviceEntry.GetInactiveImageVersion(ctx)
logger.Debugw(ctx, "prepare ONU_ACTIVATED event",
log.Fields{"device-id": aDeviceID, "EventContext": eventContext})
} else {
@@ -2594,24 +2545,23 @@
}
// createUniLockFsm initializes and runs the UniLock FSM to transfer the OMCI related commands for port lock/unlock
-func (dh *deviceHandler) createUniLockFsm(ctx context.Context, aAdminState bool, devEvent OnuDeviceEvent) {
- chLSFsm := make(chan Message, 2048)
+func (dh *deviceHandler) createUniLockFsm(ctx context.Context, aAdminState bool, devEvent cmn.OnuDeviceEvent) {
+ chLSFsm := make(chan cmn.Message, 2048)
var sFsmName string
if aAdminState {
- logger.Debugw(ctx, "createLockStateFSM", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "createLockStateFSM", log.Fields{"device-id": dh.DeviceID})
sFsmName = "LockStateFSM"
} else {
- logger.Debugw(ctx, "createUnlockStateFSM", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "createUnlockStateFSM", log.Fields{"device-id": dh.DeviceID})
sFsmName = "UnLockStateFSM"
}
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
return
}
- pLSFsm := newLockStateFsm(ctx, pDevEntry.PDevOmciCC, aAdminState, devEvent,
- sFsmName, dh, chLSFsm)
+ pLSFsm := uniprt.NewLockStateFsm(ctx, aAdminState, devEvent, sFsmName, dh, pDevEntry, chLSFsm)
if pLSFsm != nil {
if aAdminState {
dh.pLockStateFsm = pLSFsm
@@ -2620,7 +2570,7 @@
}
dh.runUniLockFsm(ctx, aAdminState)
} else {
- logger.Errorw(ctx, "LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.DeviceID})
}
}
@@ -2631,58 +2581,58 @@
*/
var pLSStatemachine *fsm.FSM
if aAdminState {
- pLSStatemachine = dh.pLockStateFsm.pAdaptFsm.pFsm
+ 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.Current() != uniprt.UniStDisabled) {
+ _ = dh.pUnlockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
}
} else {
- pLSStatemachine = dh.pUnlockStateFsm.pAdaptFsm.pFsm
+ 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.Current() != uniprt.UniStDisabled) {
+ _ = dh.pLockStateFsm.PAdaptFsm.PFsm.Event(uniprt.UniEvReset)
}
}
if pLSStatemachine != nil {
- if pLSStatemachine.Is(uniStDisabled) {
- if err := pLSStatemachine.Event(uniEvStart); err != nil {
+ if pLSStatemachine.Is(uniprt.UniStDisabled) {
+ if err := pLSStatemachine.Event(uniprt.UniEvStart); err != nil {
logger.Warnw(ctx, "LockStateFSM: can't start", log.Fields{"err": err})
// maybe try a FSM reset and then again ... - TODO!!!
} else {
/***** LockStateFSM started */
logger.Debugw(ctx, "LockStateFSM started", log.Fields{
- "state": pLSStatemachine.Current(), "device-id": dh.deviceID})
+ "state": pLSStatemachine.Current(), "device-id": dh.DeviceID})
}
} else {
logger.Warnw(ctx, "wrong state of LockStateFSM - want: disabled", log.Fields{
- "have": pLSStatemachine.Current(), "device-id": dh.deviceID})
+ "have": pLSStatemachine.Current(), "device-id": dh.DeviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
} else {
- logger.Errorw(ctx, "LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
}
// createOnuUpgradeFsm initializes and runs the Onu Software upgrade FSM
-func (dh *deviceHandler) createOnuUpgradeFsm(ctx context.Context, apDevEntry *OnuDeviceEntry, aDevEvent OnuDeviceEvent) error {
+func (dh *deviceHandler) createOnuUpgradeFsm(ctx context.Context, apDevEntry *mib.OnuDeviceEntry, aDevEvent cmn.OnuDeviceEvent) error {
//in here lockUpgradeFsm is already locked
- chUpgradeFsm := make(chan Message, 2048)
+ chUpgradeFsm := make(chan cmn.Message, 2048)
var sFsmName = "OnuSwUpgradeFSM"
- logger.Debugw(ctx, "create OnuSwUpgradeFSM", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "create OnuSwUpgradeFSM", log.Fields{"device-id": dh.DeviceID})
if apDevEntry.PDevOmciCC == nil {
- logger.Errorw(ctx, "no valid OnuDevice or omciCC - abort", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "no valid OnuDevice or omciCC - abort", log.Fields{"device-id": dh.DeviceID})
return fmt.Errorf(fmt.Sprintf("no valid omciCC - abort for device-id: %s", dh.device.Id))
}
- dh.pOnuUpradeFsm = NewOnuUpgradeFsm(ctx, dh, apDevEntry, apDevEntry.pOnuDB, aDevEvent,
+ dh.pOnuUpradeFsm = swupg.NewOnuUpgradeFsm(ctx, dh, apDevEntry, apDevEntry.GetOnuDB(), aDevEvent,
sFsmName, chUpgradeFsm)
if dh.pOnuUpradeFsm != nil {
- pUpgradeStatemachine := dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+ pUpgradeStatemachine := dh.pOnuUpradeFsm.PAdaptFsm.PFsm
if pUpgradeStatemachine != nil {
- if pUpgradeStatemachine.Is(upgradeStDisabled) {
- if err := pUpgradeStatemachine.Event(upgradeEvStart); err != nil {
+ if pUpgradeStatemachine.Is(swupg.UpgradeStDisabled) {
+ if err := pUpgradeStatemachine.Event(swupg.UpgradeEvStart); err != nil {
logger.Errorw(ctx, "OnuSwUpgradeFSM: can't start", log.Fields{"err": err})
// maybe try a FSM reset and then again ... - TODO!!!
return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be started for device-id: %s", dh.device.Id))
@@ -2693,29 +2643,29 @@
(*dh.pLastUpgradeImageState).Reason = voltha.ImageState_NO_ERROR
(*dh.pLastUpgradeImageState).ImageState = voltha.ImageState_IMAGE_UNKNOWN
logger.Debugw(ctx, "OnuSwUpgradeFSM started", log.Fields{
- "state": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+ "state": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
} else {
logger.Errorw(ctx, "wrong state of OnuSwUpgradeFSM to start - want: disabled", log.Fields{
- "have": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+ "have": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
// maybe try a FSM reset and then again ... - TODO!!!
return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be started for device-id: %s, wrong internal state", dh.device.Id))
}
} else {
- logger.Errorw(ctx, "OnuSwUpgradeFSM internal FSM invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "OnuSwUpgradeFSM internal FSM invalid - cannot be executed!!", log.Fields{"device-id": dh.DeviceID})
// maybe try a FSM reset and then again ... - TODO!!!
return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM internal FSM could not be created for device-id: %s", dh.device.Id))
}
} else {
- logger.Errorw(ctx, "OnuSwUpgradeFSM could not be created - abort", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "OnuSwUpgradeFSM could not be created - abort", log.Fields{"device-id": dh.DeviceID})
return fmt.Errorf(fmt.Sprintf("OnuSwUpgradeFSM could not be created - abort for device-id: %s", dh.device.Id))
}
return nil
}
-// removeOnuUpgradeFsm clears the Onu Software upgrade FSM
-func (dh *deviceHandler) removeOnuUpgradeFsm(ctx context.Context, apImageState *voltha.ImageState) {
+// RemoveOnuUpgradeFsm clears the Onu Software upgrade FSM
+func (dh *deviceHandler) RemoveOnuUpgradeFsm(ctx context.Context, apImageState *voltha.ImageState) {
logger.Debugw(ctx, "remove OnuSwUpgradeFSM StateMachine", log.Fields{
- "device-id": dh.deviceID})
+ "device-id": dh.DeviceID})
dh.lockUpgradeFsm.Lock()
dh.pOnuUpradeFsm = nil //resource clearing is left to garbage collector
dh.pLastUpgradeImageState = apImageState
@@ -2725,65 +2675,65 @@
case dh.upgradeFsmChan <- struct{}{}:
default:
logger.Debugw(ctx, "removed-UpgradeFsm signal not send on upgradeFsmChan (no receiver)", log.Fields{
- "device-id": dh.deviceID})
+ "device-id": dh.DeviceID})
}
}
// checkOnOnuImageCommit verifies if the ONU is in some upgrade state that allows for image commit and if tries to commit
func (dh *deviceHandler) checkOnOnuImageCommit(ctx context.Context) {
- pDevEntry := dh.getOnuDeviceEntry(ctx, false)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice -aborting checkOnOnuImageCommit", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting checkOnOnuImageCommit", log.Fields{"device-id": dh.DeviceID})
return
}
dh.lockUpgradeFsm.RLock()
defer dh.lockUpgradeFsm.RUnlock()
if dh.pOnuUpradeFsm != nil {
- pUpgradeStatemachine := dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+ pUpgradeStatemachine := dh.pOnuUpradeFsm.PAdaptFsm.PFsm
if pUpgradeStatemachine != nil {
// commit is only processed in case out upgrade FSM indicates the according state (for automatic commit)
// (some manual forced commit could do without)
- upgradeState := pUpgradeStatemachine.Current()
- if (upgradeState == upgradeStWaitForCommit) ||
- (upgradeState == upgradeStRequestingActivate) {
- // also include upgradeStRequestingActivate as it may be left in case the ActivateResponse just got lost
+ UpgradeState := pUpgradeStatemachine.Current()
+ if (UpgradeState == swupg.UpgradeStWaitForCommit) ||
+ (UpgradeState == swupg.UpgradeStRequestingActivate) {
+ // also include UpgradeStRequestingActivate as it may be left in case the ActivateResponse just got lost
// here no need to update the upgrade image state to activated as the state will be immediately be set to committing
- if pDevEntry.IsImageToBeCommitted(ctx, dh.pOnuUpradeFsm.inactiveImageMeID) {
+ if pDevEntry.IsImageToBeCommitted(ctx, dh.pOnuUpradeFsm.InactiveImageMeID) {
activeImageID, errImg := pDevEntry.GetActiveImageMeID(ctx)
if errImg != nil {
logger.Errorw(ctx, "OnuSwUpgradeFSM abort - could not get active image after reboot",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
return
}
- if activeImageID == dh.pOnuUpradeFsm.inactiveImageMeID {
- if (upgradeState == upgradeStRequestingActivate) && !dh.pOnuUpradeFsm.GetCommitFlag(ctx) {
+ if activeImageID == dh.pOnuUpradeFsm.InactiveImageMeID {
+ if (UpgradeState == swupg.UpgradeStRequestingActivate) && !dh.pOnuUpradeFsm.GetCommitFlag(ctx) {
// if FSM was waiting on activateResponse, new image is active, but FSM shall not commit, then:
- if err := pUpgradeStatemachine.Event(upgradeEvActivationDone); err != nil {
+ if err := pUpgradeStatemachine.Event(swupg.UpgradeEvActivationDone); err != nil {
logger.Errorw(ctx, "OnuSwUpgradeFSM: can't call activate-done event", log.Fields{"err": err})
return
}
logger.Debugw(ctx, "OnuSwUpgradeFSM activate-done after reboot", log.Fields{
- "state": upgradeState, "device-id": dh.deviceID})
+ "state": UpgradeState, "device-id": dh.DeviceID})
} else {
- //FSM in waitForCommit or (upgradeStRequestingActivate [lost ActivateResp] and commit allowed)
- if err := pUpgradeStatemachine.Event(upgradeEvCommitSw); err != nil {
+ //FSM in waitForCommit or (UpgradeStRequestingActivate [lost ActivateResp] and commit allowed)
+ if err := pUpgradeStatemachine.Event(swupg.UpgradeEvCommitSw); err != nil {
logger.Errorw(ctx, "OnuSwUpgradeFSM: can't call commit event", log.Fields{"err": err})
return
}
logger.Debugw(ctx, "OnuSwUpgradeFSM commit image requested", log.Fields{
- "state": upgradeState, "device-id": dh.deviceID})
+ "state": UpgradeState, "device-id": dh.DeviceID})
}
} else {
logger.Errorw(ctx, "OnuSwUpgradeFSM waiting to commit/on ActivateResponse, but load did not start with expected image Id",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
return
}
} else {
logger.Errorw(ctx, "OnuSwUpgradeFSM waiting to commit, but nothing to commit on ONU - abort upgrade",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
dh.pOnuUpradeFsm.CancelProcessing(ctx, true, voltha.ImageState_CANCELLED_ON_ONU_STATE) //complete abort
return
}
@@ -2791,24 +2741,24 @@
//upgrade FSM is active but not waiting for commit: maybe because commit flag is not set
// upgrade FSM is to be informed if the current active image is the one that was used in upgrade for the download
if activeImageID, err := pDevEntry.GetActiveImageMeID(ctx); err == nil {
- if dh.pOnuUpradeFsm.inactiveImageMeID == activeImageID {
+ if dh.pOnuUpradeFsm.InactiveImageMeID == activeImageID {
logger.Debugw(ctx, "OnuSwUpgradeFSM image state set to activated", log.Fields{
- "state": pUpgradeStatemachine.Current(), "device-id": dh.deviceID})
+ "state": pUpgradeStatemachine.Current(), "device-id": dh.DeviceID})
dh.pOnuUpradeFsm.SetImageStateActive(ctx)
}
}
}
}
} else {
- logger.Debugw(ctx, "no ONU image to be committed", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "no ONU image to be committed", log.Fields{"device-id": dh.DeviceID})
}
}
-//setBackend provides a DB backend for the specified path on the existing KV client
-func (dh *deviceHandler) setBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
+//SetBackend provides a DB backend for the specified path on the existing KV client
+func (dh *deviceHandler) SetBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
logger.Debugw(ctx, "SetKVStoreBackend", log.Fields{"IpTarget": dh.pOpenOnuAc.KVStoreAddress,
- "BasePathKvStore": aBasePathKvStore, "device-id": dh.deviceID})
+ "BasePathKvStore": aBasePathKvStore, "device-id": dh.DeviceID})
// kvbackend := db.NewBackend(ctx, dh.pOpenOnuAc.KVStoreType, dh.pOpenOnuAc.KVStoreAddress, dh.pOpenOnuAc.KVStoreTimeout, aBasePathKvStore)
kvbackend := &db.Backend{
Client: dh.pOpenOnuAc.kvClient,
@@ -2827,20 +2777,20 @@
switch field.Type {
case of.OxmOfbFieldTypes_OFPXMT_OFB_ETH_TYPE:
{
- logger.Debugw(ctx, "flow type EthType", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow type EthType", log.Fields{"device-id": dh.DeviceID,
"EthType": strconv.FormatInt(int64(field.GetEthType()), 16)})
}
/* TT related temporary workaround - should not be needed anymore
case of.OxmOfbFieldTypes_OFPXMT_OFB_IP_PROTO:
{
*loIPProto = field.GetIpProto()
- logger.Debugw("flow type IpProto", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw("flow type IpProto", log.Fields{"device-id": dh.DeviceID,
"IpProto": strconv.FormatInt(int64(*loIPProto), 16)})
if *loIPProto == 2 {
// some workaround for TT workflow at proto == 2 (IGMP trap) -> ignore the flow
// avoids installing invalid EVTOCD rule
logger.Debugw("flow type IpProto 2: TT workaround: ignore flow",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
return
}
}
@@ -2853,38 +2803,38 @@
loMatchVlanMask == uint16(of.OfpVlanId_OFPVID_PRESENT)) {
*loMatchVlan = *loMatchVlan & 0xFFF // not transparent: copy only ID bits
}
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"VID": strconv.FormatInt(int64(*loMatchVlan), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP:
{
*loAddPcp = uint8(field.GetVlanPcp())
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"PCP": loAddPcp})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_DST:
{
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"UDP-DST": strconv.FormatInt(int64(field.GetUdpDst()), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_SRC:
{
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"UDP-SRC": strconv.FormatInt(int64(field.GetUdpSrc()), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_DST:
{
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"IPv4-DST": field.GetIpv4Dst()})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_SRC:
{
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"IPv4-SRC": field.GetIpv4Src()})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_METADATA:
{
- logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.DeviceID,
"Metadata": field.GetTableMetadata()})
}
/*
@@ -2903,32 +2853,32 @@
/* not used:
case of.OfpActionType_OFPAT_OUTPUT:
{
- logger.Debugw("flow action type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw("flow action type", log.Fields{"device-id": dh.DeviceID,
"Output": action.GetOutput()})
}
*/
case of.OfpActionType_OFPAT_PUSH_VLAN:
{
- logger.Debugw(ctx, "flow action type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow action type", log.Fields{"device-id": dh.DeviceID,
"PushEthType": strconv.FormatInt(int64(action.GetPush().Ethertype), 16)})
}
case of.OfpActionType_OFPAT_SET_FIELD:
{
pActionSetField := action.GetSetField()
if pActionSetField.Field.OxmClass != of.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
- logger.Warnw(ctx, "flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.deviceID,
+ logger.Warnw(ctx, "flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.DeviceID,
"OxcmClass": pActionSetField.Field.OxmClass})
}
if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID {
*loSetVlan = uint16(pActionSetField.Field.GetOfbField().GetVlanVid())
- logger.Debugw(ctx, "flow Set VLAN from SetField action", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow Set VLAN from SetField action", log.Fields{"device-id": dh.DeviceID,
"SetVlan": strconv.FormatInt(int64(*loSetVlan), 16)})
} else if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP {
*loSetPcp = uint8(pActionSetField.Field.GetOfbField().GetVlanPcp())
- logger.Debugw(ctx, "flow Set PCP from SetField action", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow Set PCP from SetField action", log.Fields{"device-id": dh.DeviceID,
"SetPcp": *loSetPcp})
} else {
- logger.Warnw(ctx, "flow action SetField invalid FieldType", log.Fields{"device-id": dh.deviceID,
+ logger.Warnw(ctx, "flow action SetField invalid FieldType", log.Fields{"device-id": dh.DeviceID,
"Type": pActionSetField.Field.GetOfbField().Type})
}
}
@@ -2943,7 +2893,7 @@
}
//addFlowItemToUniPort parses the actual flow item to add it to the UniPort
-func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *onuUniPort,
+func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort,
apFlowMetaData *voltha.FlowMetadata) error {
var loSetVlan uint16 = uint16(of.OfpVlanId_OFPVID_NONE) //noValidEntry
var loMatchVlan uint16 = uint16(of.OfpVlanId_OFPVID_PRESENT) //reserved VLANID entry
@@ -2962,13 +2912,13 @@
metadata := flow.GetMetadataFromWriteMetadataAction(ctx, apFlowItem)
if metadata == 0 {
logger.Debugw(ctx, "flow-add invalid metadata - abort",
- log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("flow-add invalid metadata: %s", dh.deviceID)
+ log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("flow-add invalid metadata: %s", dh.DeviceID)
}
loTpID := uint8(flow.GetTechProfileIDFromWriteMetaData(ctx, metadata))
loCookie := apFlowItem.GetCookie()
loCookieSlice := []uint64{loCookie}
- logger.Debugw(ctx, "flow-add base indications", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow-add base indications", log.Fields{"device-id": dh.DeviceID,
"TechProf-Id": loTpID, "cookie": loCookie})
dh.getFlowOfbFields(ctx, apFlowItem, &loMatchVlan, &loAddPcp, &loIPProto)
@@ -2977,7 +2927,7 @@
// some workaround for TT workflow at proto == 2 (IGMP trap) -> ignore the flow
// avoids installing invalid EVTOCD rule
logger.Debugw("flow-add type IpProto 2: TT workaround: ignore flow",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
return nil
}
*/
@@ -2985,15 +2935,15 @@
if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan != uint16(of.OfpVlanId_OFPVID_PRESENT) {
logger.Errorw(ctx, "flow-add aborted - SetVlanId undefined, but MatchVid set", log.Fields{
- "device-id": dh.deviceID, "UniPort": apUniPort.portNo,
+ "device-id": dh.DeviceID, "UniPort": apUniPort.PortNo,
"set_vid": strconv.FormatInt(int64(loSetVlan), 16),
"match_vid": strconv.FormatInt(int64(loMatchVlan), 16)})
//TODO!!: Use DeviceId within the error response to rwCore
// likewise also in other error response cases to calling components as requested in [VOL-3458]
- return fmt.Errorf("flow-add Set/Match VlanId inconsistent: %s", dh.deviceID)
+ return fmt.Errorf("flow-add Set/Match VlanId inconsistent: %s", dh.DeviceID)
}
if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan == uint16(of.OfpVlanId_OFPVID_PRESENT) {
- logger.Debugw(ctx, "flow-add vlan-any/copy", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "flow-add vlan-any/copy", log.Fields{"device-id": dh.DeviceID})
loSetVlan = loMatchVlan //both 'transparent' (copy any)
} else {
//looks like OMCI value 4097 (copyFromOuter - for Uni double tagged) is not supported here
@@ -3001,7 +2951,7 @@
// not set to transparent
loSetVlan &= 0x0FFF //mask VID bits as prerequisite for vlanConfigFsm
}
- logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.DeviceID})
}
var meter *voltha.OfpMeterConfig
@@ -3014,11 +2964,11 @@
// (also vlan persistency data does not support multiple FSM's on the same UNI correctly!)
dh.lockVlanAdd.Lock() //prevent multiple add activities to start in parallel
dh.lockVlanConfig.RLock() //read protection on UniVlanConfigFsmMap (removeFlowItemFromUniPort)
- logger.Debugw(ctx, "flow-add got lock", log.Fields{"device-id": dh.deviceID, "tpID": loTpID, "uniID": apUniPort.uniID})
- if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
+ logger.Debugw(ctx, "flow-add got lock", log.Fields{"device-id": dh.DeviceID, "tpID": loTpID, "uniID": apUniPort.UniID})
+ if _, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
//SetUniFlowParams() may block on some rule that is suspended-to-add
// in order to allow for according flow removal lockVlanConfig may only be used with RLock here
- err := dh.UniVlanConfigFsmMap[apUniPort.uniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
+ err := dh.UniVlanConfigFsmMap[apUniPort.UniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
loMatchVlan, loSetVlan, loSetPcp, false, meter)
dh.lockVlanConfig.RUnlock()
dh.lockVlanAdd.Unlock() //re-admit new Add-flow-processing
@@ -3027,14 +2977,14 @@
dh.lockVlanConfig.RUnlock()
dh.lockVlanConfig.Lock() //createVlanFilterFsm should always be a non-blocking operation and requires r+w lock
err := dh.createVlanFilterFsm(ctx, apUniPort, loTpID, loCookieSlice,
- loMatchVlan, loSetVlan, loSetPcp, OmciVlanFilterAddDone, false, meter)
+ loMatchVlan, loSetVlan, loSetPcp, cmn.OmciVlanFilterAddDone, false, meter)
dh.lockVlanConfig.Unlock()
dh.lockVlanAdd.Unlock() //re-admit new Add-flow-processing
return err
}
//removeFlowItemFromUniPort parses the actual flow item to remove it from the UniPort
-func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *onuUniPort) error {
+func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *of.OfpFlowStats, apUniPort *cmn.OnuUniPort) error {
//optimization and assumption: the flow cookie uniquely identifies the flow and with that the internal rule
//hence only the cookie is used here to find the relevant flow and possibly remove the rule
//no extra check is done on the rule parameters
@@ -3044,18 +2994,18 @@
// from addFlow - where at reconcilement multiple cookies per flow ) can be configured in one sequence)
// - some possible 'delete-all' sequence would have to be implemented separately (where the cookies are don't care anyway)
loCookie := apFlowItem.GetCookie()
- logger.Debugw(ctx, "flow-remove base indications", log.Fields{"device-id": dh.deviceID, "cookie": loCookie})
+ logger.Debugw(ctx, "flow-remove base indications", log.Fields{"device-id": dh.DeviceID, "cookie": loCookie})
/* TT related temporary workaround - should not be needed anymore
for _, field := range flow.GetOfbFields(apFlowItem) {
if field.Type == of.OxmOfbFieldTypes_OFPXMT_OFB_IP_PROTO {
loIPProto := field.GetIpProto()
- logger.Debugw(ctx, "flow type IpProto", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow type IpProto", log.Fields{"device-id": dh.DeviceID,
"IpProto": strconv.FormatInt(int64(loIPProto), 16)})
if loIPProto == 2 {
// some workaround for TT workflow on proto == 2 (IGMP trap) -> the flow was not added, no need to remove
logger.Debugw(ctx, "flow-remove type IpProto 2: TT workaround: ignore flow",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
return nil
}
}
@@ -3065,15 +3015,15 @@
//mutex protection as the update_flow rpc maybe running concurrently for different flows, perhaps also activities
dh.lockVlanConfig.RLock()
defer dh.lockVlanConfig.RUnlock()
- logger.Debugw(ctx, "flow-remove got RLock", log.Fields{"device-id": dh.deviceID, "uniID": apUniPort.uniID})
- if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
- return dh.UniVlanConfigFsmMap[apUniPort.uniID].RemoveUniFlowParams(ctx, loCookie)
+ logger.Debugw(ctx, "flow-remove got RLock", log.Fields{"device-id": dh.DeviceID, "uniID": apUniPort.UniID})
+ if _, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
+ return dh.UniVlanConfigFsmMap[apUniPort.UniID].RemoveUniFlowParams(ctx, loCookie)
}
logger.Debugw(ctx, "flow-remove called, but no flow is configured (no VlanConfigFsm, flow already removed) ",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
//but as we regard the flow as not existing = removed we respond just ok
// and treat the reason accordingly (which in the normal removal procedure is initiated by the FSM)
- go dh.deviceProcStatusUpdate(ctx, OmciVlanFilterRemDone)
+ go dh.DeviceProcStatusUpdate(ctx, cmn.OmciVlanFilterRemDone)
return nil
}
@@ -3081,48 +3031,48 @@
// createVlanFilterFsm initializes and runs the VlanFilter FSM to transfer OMCI related VLAN config
// if this function is called from possibly concurrent processes it must be mutex-protected from the caller!
// precondition: dh.lockVlanConfig is locked by the caller!
-func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort, aTpID uint8, aCookieSlice []uint64,
- aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent OnuDeviceEvent, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
- chVlanFilterFsm := make(chan Message, 2048)
+func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *cmn.OnuUniPort, aTpID uint8, aCookieSlice []uint64,
+ aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent cmn.OnuDeviceEvent, lastFlowToReconcile bool, aMeter *voltha.OfpMeterConfig) error {
+ chVlanFilterFsm := make(chan cmn.Message, 2048)
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.DeviceID)
}
- pVlanFilterFsm := NewUniVlanConfigFsm(ctx, dh, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
- pDevEntry.pOnuDB, aTpID, aDevEvent, "UniVlanConfigFsm", chVlanFilterFsm,
+ pVlanFilterFsm := avcfg.NewUniVlanConfigFsm(ctx, dh, pDevEntry, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
+ pDevEntry.GetOnuDB(), aTpID, aDevEvent, "UniVlanConfigFsm", chVlanFilterFsm,
dh.pOpenOnuAc.AcceptIncrementalEvto, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp, lastFlowToReconcile, aMeter)
if pVlanFilterFsm != nil {
//dh.lockVlanConfig is locked (by caller) throughout the state transition to 'starting'
// to prevent unintended (ignored) events to be sent there (from parallel processing)
- dh.UniVlanConfigFsmMap[apUniPort.uniID] = pVlanFilterFsm
- pVlanFilterStatemachine := pVlanFilterFsm.pAdaptFsm.pFsm
+ dh.UniVlanConfigFsmMap[apUniPort.UniID] = pVlanFilterFsm
+ pVlanFilterStatemachine := pVlanFilterFsm.PAdaptFsm.PFsm
if pVlanFilterStatemachine != nil {
- if pVlanFilterStatemachine.Is(vlanStDisabled) {
- if err := pVlanFilterStatemachine.Event(vlanEvStart); err != nil {
+ if pVlanFilterStatemachine.Is(avcfg.VlanStDisabled) {
+ if err := pVlanFilterStatemachine.Event(avcfg.VlanEvStart); err != nil {
logger.Warnw(ctx, "UniVlanConfigFsm: can't start", log.Fields{"err": err})
- return fmt.Errorf("can't start UniVlanConfigFsm for device-id %x", dh.deviceID)
+ return fmt.Errorf("can't start UniVlanConfigFsm for device-id %x", dh.DeviceID)
}
/***** UniVlanConfigFsm started */
logger.Debugw(ctx, "UniVlanConfigFsm started", log.Fields{
- "state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
- "UniPort": apUniPort.portNo})
+ "state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+ "UniPort": apUniPort.PortNo})
} else {
logger.Warnw(ctx, "wrong state of UniVlanConfigFsm - want: disabled", log.Fields{
- "have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID})
- return fmt.Errorf("uniVlanConfigFsm not in expected disabled state for device-id %x", dh.deviceID)
+ "have": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID})
+ return fmt.Errorf("uniVlanConfigFsm not in expected disabled state for device-id %x", dh.DeviceID)
}
} else {
logger.Errorw(ctx, "UniVlanConfigFsm StateMachine invalid - cannot be executed!!", log.Fields{
- "device-id": dh.deviceID})
- return fmt.Errorf("uniVlanConfigFsm invalid for device-id %x", dh.deviceID)
+ "device-id": dh.DeviceID})
+ return fmt.Errorf("uniVlanConfigFsm invalid for device-id %x", dh.DeviceID)
}
} else {
logger.Errorw(ctx, "UniVlanConfigFsm could not be created - abort!!", log.Fields{
- "device-id": dh.deviceID, "UniPort": apUniPort.portNo})
- return fmt.Errorf("uniVlanConfigFsm could not be created for device-id %x", dh.deviceID)
+ "device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
+ return fmt.Errorf("uniVlanConfigFsm could not be created for device-id %x", dh.DeviceID)
}
return nil
}
@@ -3131,69 +3081,69 @@
// and starts verification of flow config based on that
func (dh *deviceHandler) VerifyVlanConfigRequest(ctx context.Context, aUniID uint8, aTpID uint8) {
//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
- var pCurrentUniPort *onuUniPort
+ var pCurrentUniPort *cmn.OnuUniPort
for _, uniPort := range dh.uniEntityMap {
// only if this port is validated for operState transfer
- if uniPort.uniID == uint8(aUniID) {
+ if uniPort.UniID == uint8(aUniID) {
pCurrentUniPort = uniPort
break //found - end search loop
}
}
if pCurrentUniPort == nil {
logger.Debugw(ctx, "VerifyVlanConfig aborted: requested uniID not found in PortDB",
- log.Fields{"device-id": dh.deviceID, "uni-id": aUniID})
+ log.Fields{"device-id": dh.DeviceID, "uni-id": aUniID})
return
}
- dh.verifyUniVlanConfigRequest(ctx, pCurrentUniPort, aTpID)
+ dh.VerifyUniVlanConfigRequest(ctx, pCurrentUniPort, aTpID)
}
-//verifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
-func (dh *deviceHandler) verifyUniVlanConfigRequest(ctx context.Context, apUniPort *onuUniPort, aTpID uint8) {
+//VerifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
+func (dh *deviceHandler) VerifyUniVlanConfigRequest(ctx context.Context, apUniPort *cmn.OnuUniPort, aTpID uint8) {
//TODO!! verify and start pending flow configuration
//some pending config request my exist in case the UniVlanConfig FSM was already started - with internal data -
//but execution was set to 'on hold' as first the TechProfile config had to be applied
dh.lockVlanConfig.RLock()
- if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
+ if pVlanFilterFsm, exist := dh.UniVlanConfigFsmMap[apUniPort.UniID]; exist {
dh.lockVlanConfig.RUnlock()
//VlanFilterFsm exists and was already started (assumed to wait for TechProfile execution here)
- pVlanFilterStatemachine := pVlanFilterFsm.pAdaptFsm.pFsm
+ pVlanFilterStatemachine := pVlanFilterFsm.PAdaptFsm.PFsm
if pVlanFilterStatemachine != nil {
//if this was an event of the TP processing that was waited for in the VlanFilterFsm
if pVlanFilterFsm.GetWaitingTpID() == aTpID {
- if pVlanFilterStatemachine.Is(vlanStWaitingTechProf) {
- if err := pVlanFilterStatemachine.Event(vlanEvContinueConfig); err != nil {
+ if pVlanFilterStatemachine.Is(avcfg.VlanStWaitingTechProf) {
+ if err := pVlanFilterStatemachine.Event(avcfg.VlanEvContinueConfig); err != nil {
logger.Warnw(ctx, "UniVlanConfigFsm: can't continue processing", log.Fields{"err": err,
- "device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+ "device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
} else {
/***** UniVlanConfigFsm continued */
logger.Debugw(ctx, "UniVlanConfigFsm continued", log.Fields{
- "state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
- "UniPort": apUniPort.portNo})
+ "state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+ "UniPort": apUniPort.PortNo})
}
- } else if pVlanFilterStatemachine.Is(vlanStIncrFlowWaitTP) {
- if err := pVlanFilterStatemachine.Event(vlanEvIncrFlowConfig); err != nil {
+ } else if pVlanFilterStatemachine.Is(avcfg.VlanStIncrFlowWaitTP) {
+ if err := pVlanFilterStatemachine.Event(avcfg.VlanEvIncrFlowConfig); err != nil {
logger.Warnw(ctx, "UniVlanConfigFsm: can't continue processing", log.Fields{"err": err,
- "device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+ "device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
} else {
/***** UniVlanConfigFsm continued */
logger.Debugw(ctx, "UniVlanConfigFsm continued with incremental flow", log.Fields{
- "state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
- "UniPort": apUniPort.portNo})
+ "state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+ "UniPort": apUniPort.PortNo})
}
} else {
logger.Debugw(ctx, "no state of UniVlanConfigFsm to be continued", log.Fields{
- "have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
- "UniPort": apUniPort.portNo})
+ "have": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+ "UniPort": apUniPort.PortNo})
}
} else {
logger.Debugw(ctx, "TechProfile Ready event for TpId that was not waited for in the VlanConfigFsm - continue waiting", log.Fields{
- "state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
- "UniPort": apUniPort.portNo, "techprofile-id (done)": aTpID})
+ "state": pVlanFilterStatemachine.Current(), "device-id": dh.DeviceID,
+ "UniPort": apUniPort.PortNo, "techprofile-id (done)": aTpID})
}
} else {
logger.Debugw(ctx, "UniVlanConfigFsm StateMachine does not exist, no flow processing", log.Fields{
- "device-id": dh.deviceID, "UniPort": apUniPort.portNo})
+ "device-id": dh.DeviceID, "UniPort": apUniPort.PortNo})
}
} else {
dh.lockVlanConfig.RUnlock()
@@ -3202,17 +3152,17 @@
//RemoveVlanFilterFsm deletes the stored pointer to the VlanConfigFsm
// intention is to provide this method to be called from VlanConfigFsm itself, when resources (and methods!) are cleaned up
-func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort) {
+func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *cmn.OnuUniPort) {
logger.Debugw(ctx, "remove UniVlanConfigFsm StateMachine", log.Fields{
- "device-id": dh.deviceID, "uniPort": apUniPort.portNo})
+ "device-id": dh.DeviceID, "uniPort": apUniPort.PortNo})
//save to do, even if entry dows not exist
dh.lockVlanConfig.Lock()
- delete(dh.UniVlanConfigFsmMap, apUniPort.uniID)
+ delete(dh.UniVlanConfigFsmMap, apUniPort.UniID)
dh.lockVlanConfig.Unlock()
}
//startWritingOnuDataToKvStore initiates the KVStore write of ONU persistent data
-func (dh *deviceHandler) startWritingOnuDataToKvStore(ctx context.Context, aPDevEntry *OnuDeviceEntry) error {
+func (dh *deviceHandler) startWritingOnuDataToKvStore(ctx context.Context, aPDevEntry *mib.OnuDeviceEntry) error {
dh.mutexKvStoreContext.Lock() //this write routine may (could) be called with the same context,
defer dh.mutexKvStoreContext.Unlock() //this write routine may (could) be called with the same context,
// obviously then parallel processing on the cancel must be avoided
@@ -3221,33 +3171,33 @@
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(context.Background(), deadline)
- aPDevEntry.resetKvProcessingErrorIndication()
+ aPDevEntry.ResetKvProcessingErrorIndication()
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go aPDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ go aPDevEntry.UpdateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
dh.waitForCompletion(ctx, cancel, &wg, "UpdateKvStore") //wait for background process to finish
- return aPDevEntry.getKvProcessingErrorIndication()
+ return aPDevEntry.GetKvProcessingErrorIndication()
}
-//storePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
+//StorePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
//available for potential reconcilement
-func (dh *deviceHandler) storePersUniFlowConfig(ctx context.Context, aUniID uint8,
- aUniVlanFlowParams *[]uniVlanFlowParams, aWriteToKvStore bool) error {
+func (dh *deviceHandler) StorePersUniFlowConfig(ctx context.Context, aUniID uint8,
+ aUniVlanFlowParams *[]cmn.UniVlanFlowParams, aWriteToKvStore bool) error {
- if dh.isReconciling() {
- logger.Debugw(ctx, "reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+ if dh.IsReconciling() {
+ logger.Debugw(ctx, "reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.DeviceID})
return nil
}
- logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.DeviceID})
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
- pDevEntry.updateOnuUniFlowConfig(aUniID, aUniVlanFlowParams)
+ pDevEntry.UpdateOnuUniFlowConfig(aUniID, aUniVlanFlowParams)
if aWriteToKvStore {
return dh.startWritingOnuDataToKvStore(ctx, pDevEntry)
@@ -3259,34 +3209,34 @@
defer cancel() //ensure termination of context (may be pro forma)
wg.Wait()
logger.Debugw(ctx, "WaitGroup processing completed", log.Fields{
- "device-id": dh.deviceID, "called from": aCallerIdent})
+ "device-id": dh.DeviceID, "called from": aCallerIdent})
}
func (dh *deviceHandler) deviceReasonUpdate(ctx context.Context, deviceReason uint8, notifyCore bool) error {
- dh.setDeviceReason(deviceReason)
+ dh.SetDeviceReason(deviceReason)
if notifyCore {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing at calling position
if err := dh.updateDeviceReasonInCore(ctx, &ic.DeviceReason{
- DeviceId: dh.deviceID,
- Reason: deviceReasonMap[deviceReason],
+ DeviceId: dh.DeviceID,
+ Reason: cmn.DeviceReasonMap[deviceReason],
}); err != nil {
logger.Errorf(ctx, "DeviceReasonUpdate error: %s",
- log.Fields{"device-id": dh.deviceID, "error": err}, deviceReasonMap[deviceReason])
+ log.Fields{"device-id": dh.DeviceID, "error": err}, cmn.DeviceReasonMap[deviceReason])
return err
}
- logger.Infof(ctx, "DeviceReasonUpdate success: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+ logger.Infof(ctx, "DeviceReasonUpdate success: %s - device-id: %s", cmn.DeviceReasonMap[deviceReason], dh.DeviceID)
return nil
}
- logger.Infof(ctx, "Don't notify core about DeviceReasonUpdate: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+ logger.Infof(ctx, "Don't notify core about DeviceReasonUpdate: %s - device-id: %s", cmn.DeviceReasonMap[deviceReason], dh.DeviceID)
return nil
}
-func (dh *deviceHandler) storePersistentData(ctx context.Context) error {
- pDevEntry := dh.getOnuDeviceEntry(ctx, true)
+func (dh *deviceHandler) StorePersistentData(ctx context.Context) error {
+ pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.deviceID})
- return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
+ logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
+ return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
}
return dh.startWritingOnuDataToKvStore(ctx, pDevEntry)
}
@@ -3297,7 +3247,7 @@
dh.lockDevice.RLock()
defer dh.lockDevice.RUnlock()
if uniPort, ok := dh.uniEntityMap[uniPortNo]; ok {
- return uniPort.entityID, nil
+ return uniPort.EntityID, nil
}
return 0, errors.New("error-fetching-uni-port")
}
@@ -3316,10 +3266,10 @@
// TODO: Although it is possible to revert to old config in case of partial failure, the code becomes quite complex. Needs more investigation
// Is it possible the rw-core reverts to old config on partial failure but adapter retains a partial new config?
if len(errorsList) > 0 {
- logger.Errorw(ctx, "one-or-more-pm-config-failed", log.Fields{"device-id": dh.deviceID, "pmConfig": dh.pmConfigs})
+ logger.Errorw(ctx, "one-or-more-pm-config-failed", log.Fields{"device-id": dh.DeviceID, "pmConfig": dh.pmConfigs})
return fmt.Errorf("errors-handling-one-or-more-pm-config, errors:%v", errorsList)
}
- logger.Infow(ctx, "pm-config-updated", log.Fields{"device-id": dh.deviceID, "pmConfig": dh.pmConfigs})
+ logger.Infow(ctx, "pm-config-updated", log.Fields{"device-id": dh.DeviceID, "pmConfig": dh.pmConfigs})
return nil
}
@@ -3329,7 +3279,7 @@
logger.Infow(ctx, "handling-global-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
if pmConfigs.DefaultFreq != dh.pmConfigs.DefaultFreq {
- if err = dh.pOnuMetricsMgr.updateDefaultFrequency(ctx, pmConfigs); err != nil {
+ if err = dh.pOnuMetricsMgr.UpdateDefaultFrequency(ctx, pmConfigs); err != nil {
errorsList = append(errorsList, err)
}
}
@@ -3344,17 +3294,17 @@
logger.Debugw(ctx, "handling-group-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
// Check if group metric related config is updated
for _, v := range pmConfigs.Groups {
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock()
- m, ok := dh.pOnuMetricsMgr.groupMetricMap[v.GroupName]
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock()
+ m, ok := dh.pOnuMetricsMgr.GroupMetricMap[v.GroupName]
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
- if ok && m.frequency != v.GroupFreq {
- if err = dh.pOnuMetricsMgr.updateGroupFreq(ctx, v.GroupName, pmConfigs); err != nil {
+ if ok && m.Frequency != v.GroupFreq {
+ if err = dh.pOnuMetricsMgr.UpdateGroupFreq(ctx, v.GroupName, pmConfigs); err != nil {
errorsList = append(errorsList, err)
}
}
- if ok && m.enabled != v.Enabled {
- if err = dh.pOnuMetricsMgr.updateGroupSupport(ctx, v.GroupName, pmConfigs); err != nil {
+ if ok && m.Enabled != v.Enabled {
+ if err = dh.pOnuMetricsMgr.UpdateGroupSupport(ctx, v.GroupName, pmConfigs); err != nil {
errorsList = append(errorsList, err)
}
}
@@ -3369,17 +3319,17 @@
logger.Debugw(ctx, "handling-individual-pm-config-params - start", log.Fields{"device-id": dh.device.Id})
// Check if standalone metric related config is updated
for _, v := range pmConfigs.Metrics {
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock()
- m, ok := dh.pOnuMetricsMgr.standaloneMetricMap[v.Name]
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock()
+ m, ok := dh.pOnuMetricsMgr.StandaloneMetricMap[v.Name]
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
- if ok && m.frequency != v.SampleFreq {
- if err = dh.pOnuMetricsMgr.updateMetricFreq(ctx, v.Name, pmConfigs); err != nil {
+ if ok && m.Frequency != v.SampleFreq {
+ if err = dh.pOnuMetricsMgr.UpdateMetricFreq(ctx, v.Name, pmConfigs); err != nil {
errorsList = append(errorsList, err)
}
}
- if ok && m.enabled != v.Enabled {
- if err = dh.pOnuMetricsMgr.updateMetricSupport(ctx, v.Name, pmConfigs); err != nil {
+ if ok && m.Enabled != v.Enabled {
+ if err = dh.pOnuMetricsMgr.UpdateMetricSupport(ctx, v.Name, pmConfigs); err != nil {
errorsList = append(errorsList, err)
}
}
@@ -3389,17 +3339,17 @@
}
// nolint: gocyclo
-func (dh *deviceHandler) startCollector(ctx context.Context) {
+func (dh *deviceHandler) StartCollector(ctx context.Context) {
logger.Debugf(ctx, "startingCollector")
// Start routine to process OMCI GET Responses
- go dh.pOnuMetricsMgr.processOmciMessages(ctx)
+ go dh.pOnuMetricsMgr.ProcessOmciMessages(ctx)
// Create Extended Frame PM ME
- go dh.pOnuMetricsMgr.createEthernetFrameExtendedPMME(ctx)
+ go dh.pOnuMetricsMgr.CreateEthernetFrameExtendedPMME(ctx)
// Initialize the next metric collection time.
// Normally done when the onu_metrics_manager is initialized the first time, but needed again later when ONU is
// reset like onu rebooted.
- dh.pOnuMetricsMgr.initializeMetricCollectionTime(ctx)
+ dh.pOnuMetricsMgr.InitializeMetricCollectionTime(ctx)
dh.setCollectorIsRunning(true)
for {
select {
@@ -3408,67 +3358,67 @@
logger.Debugw(ctx, "stopping-collector-for-onu", log.Fields{"device-id": dh.device.Id})
// Stop the L2 PM FSM
go func() {
- if dh.pOnuMetricsMgr.pAdaptFsm != nil && dh.pOnuMetricsMgr.pAdaptFsm.pFsm != nil {
- if err := dh.pOnuMetricsMgr.pAdaptFsm.pFsm.Event(l2PmEventStop); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": dh.deviceID, "err": err})
+ if dh.pOnuMetricsMgr.PAdaptFsm != nil && dh.pOnuMetricsMgr.PAdaptFsm.PFsm != nil {
+ if err := dh.pOnuMetricsMgr.PAdaptFsm.PFsm.Event(pmmgr.L2PmEventStop); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": dh.DeviceID, "err": err})
}
} else {
- logger.Errorw(ctx, "metrics manager fsm not initialized", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "metrics manager fsm not initialized", log.Fields{"device-id": dh.DeviceID})
}
}()
- if dh.pOnuMetricsMgr.getOmciProcessingStatus() {
- dh.pOnuMetricsMgr.stopProcessingOmciResponses <- true // Stop the OMCI GET response processing routine
+ if dh.pOnuMetricsMgr.GetOmciProcessingStatus() {
+ dh.pOnuMetricsMgr.StopProcessingOmciResponses <- true // Stop the OMCI GET response processing routine
}
- if dh.pOnuMetricsMgr.getTickGenerationStatus() {
- dh.pOnuMetricsMgr.stopTicks <- true
+ if dh.pOnuMetricsMgr.GetTickGenerationStatus() {
+ dh.pOnuMetricsMgr.StopTicks <- true
}
return
- case <-time.After(time.Duration(FrequencyGranularity) * time.Second): // Check every FrequencyGranularity to see if it is time for collecting metrics
- if !dh.pmConfigs.FreqOverride { // If FreqOverride is false, then nextGlobalMetricCollectionTime applies
- // If the current time is eqaul to or greater than the nextGlobalMetricCollectionTime, collect the group and standalone metrics
- if time.Now().Equal(dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime) || time.Now().After(dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime) {
- go dh.pOnuMetricsMgr.collectAllGroupAndStandaloneMetrics(ctx)
+ case <-time.After(time.Duration(pmmgr.FrequencyGranularity) * time.Second): // Check every FrequencyGranularity to see if it is time for collecting metrics
+ if !dh.pmConfigs.FreqOverride { // If FreqOverride is false, then NextGlobalMetricCollectionTime applies
+ // If the current time is eqaul to or greater than the NextGlobalMetricCollectionTime, collect the group and standalone metrics
+ if time.Now().Equal(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) || time.Now().After(dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime) {
+ go dh.pOnuMetricsMgr.CollectAllGroupAndStandaloneMetrics(ctx)
// Update the next metric collection time.
- dh.pOnuMetricsMgr.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(dh.pmConfigs.DefaultFreq) * time.Second)
+ dh.pOnuMetricsMgr.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(dh.pmConfigs.DefaultFreq) * time.Second)
}
} else {
if dh.pmConfigs.Grouped { // metrics are managed as a group
// parse through the group and standalone metrics to see it is time to collect their metrics
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RLock() // Rlock as we are reading groupMetricMap and standaloneMetricMap
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RLock() // Rlock as we are reading GroupMetricMap and StandaloneMetricMap
- for n, g := range dh.pOnuMetricsMgr.groupMetricMap {
- // If the group is enabled AND (current time is equal to OR after nextCollectionInterval, collect the group metric)
+ for n, g := range dh.pOnuMetricsMgr.GroupMetricMap {
+ // If the group is enabled AND (current time is equal to OR after NextCollectionInterval, collect the group metric)
// Since the L2 PM counters are collected in a separate FSM, we should avoid those counters in the check.
- if g.enabled && !g.isL2PMCounter && (time.Now().Equal(g.nextCollectionInterval) || time.Now().After(g.nextCollectionInterval)) {
- go dh.pOnuMetricsMgr.collectGroupMetric(ctx, n)
+ if g.Enabled && !g.IsL2PMCounter && (time.Now().Equal(g.NextCollectionInterval) || time.Now().After(g.NextCollectionInterval)) {
+ go dh.pOnuMetricsMgr.CollectGroupMetric(ctx, n)
}
}
- for n, m := range dh.pOnuMetricsMgr.standaloneMetricMap {
- // If the standalone is enabled AND (current time is equal to OR after nextCollectionInterval, collect the metric)
- if m.enabled && (time.Now().Equal(m.nextCollectionInterval) || time.Now().After(m.nextCollectionInterval)) {
- go dh.pOnuMetricsMgr.collectStandaloneMetric(ctx, n)
+ for n, m := range dh.pOnuMetricsMgr.StandaloneMetricMap {
+ // If the standalone is enabled AND (current time is equal to OR after NextCollectionInterval, collect the metric)
+ if m.Enabled && (time.Now().Equal(m.NextCollectionInterval) || time.Now().After(m.NextCollectionInterval)) {
+ go dh.pOnuMetricsMgr.CollectStandaloneMetric(ctx, n)
}
}
- dh.pOnuMetricsMgr.onuMetricsManagerLock.RUnlock()
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.RUnlock()
// parse through the group and update the next metric collection time
- dh.pOnuMetricsMgr.onuMetricsManagerLock.Lock() // Lock as we are writing the next metric collection time
- for _, g := range dh.pOnuMetricsMgr.groupMetricMap {
- // If group enabled, and the nextCollectionInterval is old (before or equal to current time), update the next collection time stamp
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.Lock() // Lock as we are writing the next metric collection time
+ for _, g := range dh.pOnuMetricsMgr.GroupMetricMap {
+ // If group enabled, and the NextCollectionInterval is old (before or equal to current time), update the next collection time stamp
// Since the L2 PM counters are collected and managed in a separate FSM, we should avoid those counters in the check.
- if g.enabled && !g.isL2PMCounter && (g.nextCollectionInterval.Before(time.Now()) || g.nextCollectionInterval.Equal(time.Now())) {
- g.nextCollectionInterval = time.Now().Add(time.Duration(g.frequency) * time.Second)
+ if g.Enabled && !g.IsL2PMCounter && (g.NextCollectionInterval.Before(time.Now()) || g.NextCollectionInterval.Equal(time.Now())) {
+ g.NextCollectionInterval = time.Now().Add(time.Duration(g.Frequency) * time.Second)
}
}
// parse through the standalone metrics and update the next metric collection time
- for _, m := range dh.pOnuMetricsMgr.standaloneMetricMap {
- // If standalone metrics enabled, and the nextCollectionInterval is old (before or equal to current time), update the next collection time stamp
- if m.enabled && (m.nextCollectionInterval.Before(time.Now()) || m.nextCollectionInterval.Equal(time.Now())) {
- m.nextCollectionInterval = time.Now().Add(time.Duration(m.frequency) * time.Second)
+ for _, m := range dh.pOnuMetricsMgr.StandaloneMetricMap {
+ // If standalone metrics enabled, and the NextCollectionInterval is old (before or equal to current time), update the next collection time stamp
+ if m.Enabled && (m.NextCollectionInterval.Before(time.Now()) || m.NextCollectionInterval.Equal(time.Now())) {
+ m.NextCollectionInterval = time.Now().Add(time.Duration(m.Frequency) * time.Second)
}
}
- dh.pOnuMetricsMgr.onuMetricsManagerLock.Unlock()
+ dh.pOnuMetricsMgr.OnuMetricsManagerLock.Unlock()
} /* else { // metrics are not managed as a group
// TODO: We currently do not have standalone metrics. When available, add code here to fetch the metric.
} */
@@ -3477,10 +3427,10 @@
}
}
-func (dh *deviceHandler) getUniPortStatus(ctx context.Context, uniInfo *extension.GetOnuUniInfoRequest) *extension.SingleGetValueResponse {
+func (dh *deviceHandler) GetUniPortStatus(ctx context.Context, uniInfo *extension.GetOnuUniInfoRequest) *extension.SingleGetValueResponse {
- portStatus := NewUniPortStatus(dh.pOnuOmciDevice.PDevOmciCC)
- return portStatus.getUniPortStatus(ctx, uniInfo.UniIndex)
+ portStatus := uniprt.NewUniPortStatus(dh, dh.pOnuOmciDevice.PDevOmciCC)
+ return portStatus.GetUniPortStatus(ctx, uniInfo.UniIndex)
}
func (dh *deviceHandler) getOnuOMCICounters(ctx context.Context, onuInfo *extension.GetOmciEthernetFrameExtendedPmRequest) *extension.SingleGetValueResponse {
@@ -3492,75 +3442,75 @@
},
}
}
- resp := dh.pOnuMetricsMgr.collectEthernetFrameExtendedPMCounters(ctx)
+ resp := dh.pOnuMetricsMgr.CollectEthernetFrameExtendedPMCounters(ctx)
return resp
}
-func (dh *deviceHandler) isFsmInOmciIdleState(ctx context.Context, pFsm *fsm.FSM, wantedState string) bool {
- if pFsm == nil {
+func (dh *deviceHandler) isFsmInOmciIdleState(ctx context.Context, PFsm *fsm.FSM, wantedState string) bool {
+ if PFsm == nil {
return true //FSM not active - so there is no activity on omci
}
- return pFsm.Current() == wantedState
+ return PFsm.Current() == wantedState
}
-func (dh *deviceHandler) isFsmInOmciIdleStateDefault(ctx context.Context, omciFsm usedOmciConfigFsms, wantedState string) bool {
- var pFsm *fsm.FSM
+func (dh *deviceHandler) isFsmInOmciIdleStateDefault(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, wantedState string) bool {
+ var PFsm *fsm.FSM
//note/TODO!!: might be that access to all these specific FSM; pointers need a semaphore protection as well, cmp lockUpgradeFsm
switch omciFsm {
- case cUploadFsm:
+ case cmn.CUploadFsm:
{
- pFsm = dh.pOnuOmciDevice.pMibUploadFsm.pFsm
+ PFsm = dh.pOnuOmciDevice.PMibUploadFsm.PFsm
}
- case cDownloadFsm:
+ case cmn.CDownloadFsm:
{
- pFsm = dh.pOnuOmciDevice.pMibDownloadFsm.pFsm
+ PFsm = dh.pOnuOmciDevice.PMibDownloadFsm.PFsm
}
- case cUniLockFsm:
+ case cmn.CUniLockFsm:
{
- pFsm = dh.pLockStateFsm.pAdaptFsm.pFsm
+ PFsm = dh.pLockStateFsm.PAdaptFsm.PFsm
}
- case cUniUnLockFsm:
+ case cmn.CUniUnLockFsm:
{
- pFsm = dh.pUnlockStateFsm.pAdaptFsm.pFsm
+ PFsm = dh.pUnlockStateFsm.PAdaptFsm.PFsm
}
- case cL2PmFsm:
+ case cmn.CL2PmFsm:
{
- if dh.pOnuMetricsMgr != nil && dh.pOnuMetricsMgr.pAdaptFsm != nil {
- pFsm = dh.pOnuMetricsMgr.pAdaptFsm.pFsm
+ if dh.pOnuMetricsMgr != nil && dh.pOnuMetricsMgr.PAdaptFsm != nil {
+ PFsm = dh.pOnuMetricsMgr.PAdaptFsm.PFsm
} else {
return true //FSM not active - so there is no activity on omci
}
}
- case cOnuUpgradeFsm:
+ case cmn.COnuUpgradeFsm:
{
dh.lockUpgradeFsm.RLock()
defer dh.lockUpgradeFsm.RUnlock()
- pFsm = dh.pOnuUpradeFsm.pAdaptFsm.pFsm
+ PFsm = dh.pOnuUpradeFsm.PAdaptFsm.PFsm
}
default:
{
logger.Errorw(ctx, "invalid stateMachine selected for idle check", log.Fields{
- "device-id": dh.deviceID, "selectedFsm number": omciFsm})
+ "device-id": dh.DeviceID, "selectedFsm number": omciFsm})
return false //logical error in FSM check, do not not indicate 'idle' - we can't be sure
}
}
- return dh.isFsmInOmciIdleState(ctx, pFsm, wantedState)
+ return dh.isFsmInOmciIdleState(ctx, PFsm, wantedState)
}
-func (dh *deviceHandler) isAniConfigFsmInOmciIdleState(ctx context.Context, omciFsm usedOmciConfigFsms, idleState string) bool {
- for _, v := range dh.pOnuTP.pAniConfigFsm {
- if !dh.isFsmInOmciIdleState(ctx, v.pAdaptFsm.pFsm, idleState) {
+func (dh *deviceHandler) isAniConfigFsmInOmciIdleState(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, idleState string) bool {
+ for _, v := range dh.pOnuTP.PAniConfigFsm {
+ if !dh.isFsmInOmciIdleState(ctx, v.PAdaptFsm.PFsm, idleState) {
return false
}
}
return true
}
-func (dh *deviceHandler) isUniVlanConfigFsmInOmciIdleState(ctx context.Context, omciFsm usedOmciConfigFsms, idleState string) bool {
+func (dh *deviceHandler) isUniVlanConfigFsmInOmciIdleState(ctx context.Context, omciFsm cmn.UsedOmciConfigFsms, idleState string) bool {
dh.lockVlanConfig.RLock()
defer dh.lockVlanConfig.RUnlock()
for _, v := range dh.UniVlanConfigFsmMap {
- if !dh.isFsmInOmciIdleState(ctx, v.pAdaptFsm.pFsm, idleState) {
+ if !dh.isFsmInOmciIdleState(ctx, v.PAdaptFsm.PFsm, idleState) {
return false
}
}
@@ -3571,8 +3521,8 @@
dh.lockVlanConfig.RLock()
defer dh.lockVlanConfig.RUnlock()
for _, v := range dh.UniVlanConfigFsmMap {
- if v.pAdaptFsm.pFsm != nil {
- if v.pAdaptFsm.pFsm.Is(cVlanFsmConfiguredState) {
+ if v.PAdaptFsm.PFsm != nil {
+ if v.PAdaptFsm.PFsm.Is(avcfg.CVlanFsmConfiguredState) {
return true //there is at least one VLAN FSM with some active configuration
}
}
@@ -3580,7 +3530,7 @@
return false //there is no VLAN FSM with some active configuration
}
-func (dh *deviceHandler) checkAuditStartCondition(ctx context.Context, callingFsm usedOmciConfigFsms) bool {
+func (dh *deviceHandler) CheckAuditStartCondition(ctx context.Context, callingFsm cmn.UsedOmciConfigFsms) bool {
for fsmName, fsmStruct := range fsmOmciIdleStateFuncMap {
if fsmName != callingFsm && !fsmStruct.omciIdleCheckFunc(dh, ctx, fsmName, fsmStruct.omciIdleState) {
return false
@@ -3591,15 +3541,15 @@
return dh.checkUserServiceExists(ctx)
}
-func (dh *deviceHandler) prepareReconcilingWithActiveAdapter(ctx context.Context) {
+func (dh *deviceHandler) PrepareReconcilingWithActiveAdapter(ctx context.Context) {
logger.Debugw(ctx, "prepare to reconcile the ONU with adapter using persistency data", log.Fields{"device-id": dh.device.Id})
if err := dh.resetFsms(ctx, false); err != nil {
- logger.Errorw(ctx, "reset of FSMs failed!", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "reset of FSMs failed!", log.Fields{"device-id": dh.DeviceID, "error": err})
// TODO: fatal error reset ONU, delete deviceHandler!
return
}
- dh.uniEntityMap = make(map[uint32]*onuUniPort)
- dh.startReconciling(ctx, false)
+ dh.uniEntityMap = make(map[uint32]*cmn.OnuUniPort)
+ dh.StartReconciling(ctx, false)
}
func (dh *deviceHandler) setCollectorIsRunning(flagValue bool) {
@@ -3608,7 +3558,7 @@
dh.mutexCollectorFlag.Unlock()
}
-func (dh *deviceHandler) getCollectorIsRunning() bool {
+func (dh *deviceHandler) GetCollectorIsRunning() bool {
dh.mutexCollectorFlag.RLock()
flagValue := dh.collectorIsRunning
dh.mutexCollectorFlag.RUnlock()
@@ -3621,7 +3571,7 @@
dh.mutextAlarmManagerFlag.Unlock()
}
-func (dh *deviceHandler) getAlarmManagerIsRunning(ctx context.Context) bool {
+func (dh *deviceHandler) GetAlarmManagerIsRunning(ctx context.Context) bool {
dh.mutextAlarmManagerFlag.RLock()
flagValue := dh.alarmManagerIsRunning
logger.Debugw(ctx, "alarm-manager-is-running", log.Fields{"flag": dh.alarmManagerIsRunning})
@@ -3629,95 +3579,95 @@
return flagValue
}
-func (dh *deviceHandler) startAlarmManager(ctx context.Context) {
+func (dh *deviceHandler) StartAlarmManager(ctx context.Context) {
logger.Debugf(ctx, "startingAlarmManager")
// Start routine to process OMCI GET Responses
- go dh.pAlarmMgr.startOMCIAlarmMessageProcessing(ctx)
+ go dh.pAlarmMgr.StartOMCIAlarmMessageProcessing(ctx)
dh.setAlarmManagerIsRunning(true)
if stop := <-dh.stopAlarmManager; stop {
logger.Debugw(ctx, "stopping-collector-for-onu", log.Fields{"device-id": dh.device.Id})
dh.setAlarmManagerIsRunning(false)
go func() {
- if dh.pAlarmMgr.alarmSyncFsm != nil && dh.pAlarmMgr.alarmSyncFsm.pFsm != nil {
- _ = dh.pAlarmMgr.alarmSyncFsm.pFsm.Event(asEvStop)
+ if dh.pAlarmMgr.AlarmSyncFsm != nil && dh.pAlarmMgr.AlarmSyncFsm.PFsm != nil {
+ _ = dh.pAlarmMgr.AlarmSyncFsm.PFsm.Event(almgr.AsEvStop)
}
}()
- dh.pAlarmMgr.stopProcessingOmciMessages <- true // Stop the OMCI routines if any(This will stop the fsms also)
- dh.pAlarmMgr.stopAlarmAuditTimer <- struct{}{}
+ dh.pAlarmMgr.StopProcessingOmciMessages <- true // Stop the OMCI routines if any(This will stop the fsms also)
+ dh.pAlarmMgr.StopAlarmAuditTimer <- struct{}{}
logger.Debugw(ctx, "sent-all-stop-signals-to-alarm-manager", log.Fields{"device-id": dh.device.Id})
}
}
-func (dh *deviceHandler) startReconciling(ctx context.Context, skipOnuConfig bool) {
- logger.Debugw(ctx, "start reconciling", log.Fields{"skipOnuConfig": skipOnuConfig, "device-id": dh.deviceID})
+func (dh *deviceHandler) StartReconciling(ctx context.Context, skipOnuConfig bool) {
+ logger.Debugw(ctx, "start reconciling", log.Fields{"skipOnuConfig": skipOnuConfig, "device-id": dh.DeviceID})
connectStatus := voltha.ConnectStatus_UNREACHABLE
operState := voltha.OperStatus_UNKNOWN
- if !dh.isReconciling() {
+ if !dh.IsReconciling() {
go func() {
logger.Debugw(ctx, "wait for channel signal or timeout",
- log.Fields{"timeout": dh.pOpenOnuAc.maxTimeoutReconciling, "device-id": dh.deviceID})
+ log.Fields{"timeout": dh.pOpenOnuAc.maxTimeoutReconciling, "device-id": dh.DeviceID})
select {
case success := <-dh.chReconcilingFinished:
if success {
- if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+ if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
logger.Errorw(ctx, "No valid OnuDevice - aborting Core DeviceStateUpdate",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
} else {
- if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+ if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
connectStatus = voltha.ConnectStatus_REACHABLE
- if !onuDevEntry.sOnuPersistentData.PersUniDisableDone {
- if onuDevEntry.sOnuPersistentData.PersUniUnlockDone {
+ if !onuDevEntry.SOnuPersistentData.PersUniDisableDone {
+ if onuDevEntry.SOnuPersistentData.PersUniUnlockDone {
operState = voltha.OperStatus_ACTIVE
} else {
operState = voltha.OperStatus_ACTIVATING
}
}
- } else if onuDevEntry.sOnuPersistentData.PersOperState == "down" ||
- onuDevEntry.sOnuPersistentData.PersOperState == "unknown" ||
- onuDevEntry.sOnuPersistentData.PersOperState == "" {
+ } else if onuDevEntry.SOnuPersistentData.PersOperState == "down" ||
+ onuDevEntry.SOnuPersistentData.PersOperState == "unknown" ||
+ onuDevEntry.SOnuPersistentData.PersOperState == "" {
operState = voltha.OperStatus_DISCOVERED
}
logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": operState})
}
logger.Debugw(ctx, "reconciling has been finished in time",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: connectStatus,
OperStatus: operState,
}); err != nil {
logger.Errorw(ctx, "unable to update device state to core",
- log.Fields{"device-id": dh.deviceID, "Err": err})
+ log.Fields{"device-id": dh.DeviceID, "Err": err})
}
} else {
logger.Errorw(ctx, "wait for reconciling aborted",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
- if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+ if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
logger.Errorw(ctx, "No valid OnuDevice",
- log.Fields{"device-id": dh.deviceID})
- } else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+ log.Fields{"device-id": dh.DeviceID})
+ } else if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
connectStatus = voltha.ConnectStatus_REACHABLE
}
- dh.deviceReconcileFailedUpdate(ctx, drReconcileCanceled, connectStatus)
+ dh.deviceReconcileFailedUpdate(ctx, cmn.DrReconcileCanceled, connectStatus)
}
case <-time.After(dh.pOpenOnuAc.maxTimeoutReconciling):
logger.Errorw(ctx, "timeout waiting for reconciling to be finished!",
- log.Fields{"device-id": dh.deviceID})
+ log.Fields{"device-id": dh.DeviceID})
- if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+ if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
logger.Errorw(ctx, "No valid OnuDevice",
- log.Fields{"device-id": dh.deviceID})
- } else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+ log.Fields{"device-id": dh.DeviceID})
+ } else if onuDevEntry.SOnuPersistentData.PersOperState == "up" {
connectStatus = voltha.ConnectStatus_REACHABLE
}
- dh.deviceReconcileFailedUpdate(ctx, drReconcileMaxTimeout, connectStatus)
+ dh.deviceReconcileFailedUpdate(ctx, cmn.DrReconcileMaxTimeout, connectStatus)
}
dh.mutexReconcilingFlag.Lock()
@@ -3734,28 +3684,28 @@
dh.mutexReconcilingFlag.Unlock()
}
-func (dh *deviceHandler) stopReconciling(ctx context.Context, success bool) {
- logger.Debugw(ctx, "stop reconciling", log.Fields{"device-id": dh.deviceID, "success": success})
- if dh.isReconciling() {
+func (dh *deviceHandler) StopReconciling(ctx context.Context, success bool) {
+ logger.Debugw(ctx, "stop reconciling", log.Fields{"device-id": dh.DeviceID, "success": success})
+ if dh.IsReconciling() {
dh.chReconcilingFinished <- success
} else {
- logger.Infow(ctx, "reconciling is not running", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "reconciling is not running", log.Fields{"device-id": dh.DeviceID})
}
}
-func (dh *deviceHandler) isReconciling() bool {
+func (dh *deviceHandler) IsReconciling() bool {
dh.mutexReconcilingFlag.RLock()
defer dh.mutexReconcilingFlag.RUnlock()
return dh.reconciling != cNoReconciling
}
-func (dh *deviceHandler) isSkipOnuConfigReconciling() bool {
+func (dh *deviceHandler) IsSkipOnuConfigReconciling() bool {
dh.mutexReconcilingFlag.RLock()
defer dh.mutexReconcilingFlag.RUnlock()
return dh.reconciling == cSkipOnuConfigReconciling
}
-func (dh *deviceHandler) setDeviceReason(value uint8) {
+func (dh *deviceHandler) SetDeviceReason(value uint8) {
dh.mutexDeviceReason.Lock()
dh.deviceReason = value
dh.mutexDeviceReason.Unlock()
@@ -3768,29 +3718,16 @@
return value
}
-func (dh *deviceHandler) getDeviceReasonString() string {
- return deviceReasonMap[dh.getDeviceReason()]
+func (dh *deviceHandler) GetDeviceReasonString() string {
+ return cmn.DeviceReasonMap[dh.getDeviceReason()]
}
-func (dh *deviceHandler) setReconcilingFlows(value bool) {
- dh.mutexReconcilingFlowsFlag.Lock()
- dh.reconcilingFlows = value
- dh.mutexReconcilingFlowsFlag.Unlock()
-}
-
-func (dh *deviceHandler) isReconcilingFlows() bool {
- dh.mutexReconcilingFlowsFlag.RLock()
- value := dh.reconcilingFlows
- dh.mutexReconcilingFlowsFlag.RUnlock()
- return value
-}
-
-func (dh *deviceHandler) setReadyForOmciConfig(flagValue bool) {
+func (dh *deviceHandler) SetReadyForOmciConfig(flagValue bool) {
dh.mutexReadyForOmciConfig.Lock()
dh.readyForOmciConfig = flagValue
dh.mutexReadyForOmciConfig.Unlock()
}
-func (dh *deviceHandler) isReadyForOmciConfig() bool {
+func (dh *deviceHandler) IsReadyForOmciConfig() bool {
dh.mutexReadyForOmciConfig.RLock()
flagValue := dh.readyForOmciConfig
dh.mutexReadyForOmciConfig.RUnlock()
@@ -3800,17 +3737,17 @@
func (dh *deviceHandler) deviceReconcileFailedUpdate(ctx context.Context, deviceReason uint8, connectStatus voltha.ConnectStatus_Types) {
if err := dh.deviceReasonUpdate(ctx, deviceReason, true); err != nil {
logger.Errorw(ctx, "unable to update device reason to core",
- log.Fields{"device-id": dh.deviceID, "Err": err})
+ log.Fields{"device-id": dh.DeviceID, "Err": err})
}
logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": voltha.OperStatus_RECONCILING_FAILED})
if err := dh.updateDeviceStateInCore(ctx, &ic.DeviceStateFilter{
- DeviceId: dh.deviceID,
+ DeviceId: dh.DeviceID,
ConnStatus: connectStatus,
OperStatus: voltha.OperStatus_RECONCILING_FAILED,
}); err != nil {
logger.Errorw(ctx, "unable to update device state to core",
- log.Fields{"device-id": dh.deviceID, "Err": err})
+ log.Fields{"device-id": dh.DeviceID, "Err": err})
}
}
@@ -3865,7 +3802,7 @@
return err
}
-func (dh *deviceHandler) createPortInCore(ctx context.Context, port *voltha.Port) error {
+func (dh *deviceHandler) CreatePortInCore(ctx context.Context, port *voltha.Port) error {
cClient, err := dh.coreClient.GetCoreServiceClient()
if err != nil || cClient == nil {
return err
@@ -3917,7 +3854,7 @@
return pgClient.GetTechProfileInstance(subCtx, request)
}
-func (dh *deviceHandler) sendOMCIRequest(ctx context.Context, parentEndpoint string, request *ic.OmciMessage) error {
+func (dh *deviceHandler) SendOMCIRequest(ctx context.Context, parentEndpoint string, request *ic.OmciMessage) error {
pgClient, err := dh.pOpenOnuAc.getParentAdapterServiceClient(parentEndpoint)
if err != nil || pgClient == nil {
return err
@@ -3931,3 +3868,133 @@
}
return err
}
+
+// GetDeviceID - TODO: add comment
+func (dh *deviceHandler) GetDeviceID() string {
+ return dh.DeviceID
+}
+
+// GetProxyAddressID - TODO: add comment
+func (dh *deviceHandler) GetProxyAddressID() string {
+ return dh.device.ProxyAddress.GetDeviceId()
+}
+
+// GetProxyAddressType - TODO: add comment
+func (dh *deviceHandler) GetProxyAddressType() string {
+ return dh.device.ProxyAddress.GetDeviceType()
+}
+
+// GetProxyAddress - TODO: add comment
+func (dh *deviceHandler) GetProxyAddress() *voltha.Device_ProxyAddress {
+ return dh.device.ProxyAddress
+}
+
+// GetEventProxy - TODO: add comment
+func (dh *deviceHandler) GetEventProxy() eventif.EventProxy {
+ return dh.EventProxy
+}
+
+// GetOmciTimeout - TODO: add comment
+func (dh *deviceHandler) GetOmciTimeout() int {
+ return dh.pOpenOnuAc.omciTimeout
+}
+
+// GetAlarmAuditInterval - TODO: add comment
+func (dh *deviceHandler) GetAlarmAuditInterval() time.Duration {
+ return dh.pOpenOnuAc.alarmAuditInterval
+}
+
+// GetDlToOnuTimeout4M - TODO: add comment
+func (dh *deviceHandler) GetDlToOnuTimeout4M() time.Duration {
+ return dh.pOpenOnuAc.dlToOnuTimeout4M
+}
+
+// GetUniEntityMap - TODO: add comment
+func (dh *deviceHandler) GetUniEntityMap() *cmn.OnuUniPortMap {
+ return &dh.uniEntityMap
+}
+
+// GetPonPortNumber - TODO: add comment
+func (dh *deviceHandler) GetPonPortNumber() *uint32 {
+ return &dh.ponPortNumber
+}
+
+// GetUniVlanConfigFsm - TODO: add comment
+func (dh *deviceHandler) GetUniVlanConfigFsm(uniID uint8) cmn.IuniVlanConfigFsm {
+ return dh.UniVlanConfigFsmMap[uniID]
+}
+
+// GetOnuAlarmManager - TODO: add comment
+func (dh *deviceHandler) GetOnuAlarmManager() cmn.IonuAlarmManager {
+ return dh.pAlarmMgr
+}
+
+// GetOnuMetricsManager - TODO: add comment
+func (dh *deviceHandler) GetOnuMetricsManager() cmn.IonuMetricsManager {
+ return dh.pOnuMetricsMgr
+}
+
+// GetOnuTP - TODO: add comment
+func (dh *deviceHandler) GetOnuTP() cmn.IonuUniTechProf {
+ return dh.pOnuTP
+}
+
+// GetBackendPathPrefix - TODO: add comment
+func (dh *deviceHandler) GetBackendPathPrefix() string {
+ return dh.pOpenOnuAc.cm.Backend.PathPrefix
+}
+
+// GetOnuIndication - TODO: add comment
+func (dh *deviceHandler) GetOnuIndication() *openolt.OnuIndication {
+ return dh.pOnuIndication
+}
+
+// RLockMutexDeletionInProgressFlag - TODO: add comment
+func (dh *deviceHandler) RLockMutexDeletionInProgressFlag() {
+ dh.mutexDeletionInProgressFlag.RLock()
+}
+
+// RUnlockMutexDeletionInProgressFlag - TODO: add comment
+func (dh *deviceHandler) RUnlockMutexDeletionInProgressFlag() {
+ dh.mutexDeletionInProgressFlag.RUnlock()
+}
+
+// GetDeletionInProgress - TODO: add comment
+func (dh *deviceHandler) GetDeletionInProgress() bool {
+ return dh.deletionInProgress
+}
+
+// GetPmConfigs - TODO: add comment
+func (dh *deviceHandler) GetPmConfigs() *voltha.PmConfigs {
+ return dh.pmConfigs
+}
+
+// GetDeviceType - TODO: add comment
+func (dh *deviceHandler) GetDeviceType() string {
+ return dh.DeviceType
+}
+
+// GetLogicalDeviceID - TODO: add comment
+func (dh *deviceHandler) GetLogicalDeviceID() string {
+ return dh.logicalDeviceID
+}
+
+// GetDevice - TODO: add comment
+func (dh *deviceHandler) GetDevice() *voltha.Device {
+ return dh.device
+}
+
+// GetMetricsEnabled - TODO: add comment
+func (dh *deviceHandler) GetMetricsEnabled() bool {
+ return dh.pOpenOnuAc.MetricsEnabled
+}
+
+// InitPmConfigs - TODO: add comment
+func (dh *deviceHandler) InitPmConfigs() {
+ dh.pmConfigs = &voltha.PmConfigs{}
+}
+
+// GetUniPortMask - TODO: add comment
+func (dh *deviceHandler) GetUniPortMask() int {
+ return dh.pOpenOnuAc.config.UniPortMask
+}
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/core/openonu.go
old mode 100644
new mode 100755
similarity index 92%
rename from internal/pkg/onuadaptercore/openonu.go
rename to internal/pkg/core/openonu.go
index eecd002..a7ad35c
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/core/openonu.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
import (
"context"
@@ -39,14 +39,17 @@
ic "github.com/opencord/voltha-protos/v5/go/inter_container"
"github.com/opencord/voltha-protos/v5/go/voltha"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+ uniprt "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/uniprt"
)
//OpenONUAC structure holds the ONU core information
type OpenONUAC struct {
deviceHandlers map[string]*deviceHandler
deviceHandlersCreateChan map[string]chan bool //channels for deviceHandler create events
- lockDeviceHandlersMap sync.RWMutex
+ mutexDeviceHandlersMap sync.RWMutex
coreClient *vgrpc.Client
parentAdapterClients map[string]*vgrpc.Client
lockParentAdapterClients sync.RWMutex
@@ -59,18 +62,18 @@
KVStoreType string
KVStoreTimeout time.Duration
mibTemplatesGenerated map[string]bool
- lockMibTemplateGenerated sync.RWMutex
+ mutexMibTemplateGenerated sync.RWMutex
exitChannel chan int
HeartbeatCheckInterval time.Duration
HeartbeatFailReportInterval time.Duration
AcceptIncrementalEvto bool
//GrpcTimeoutInterval time.Duration
- pSupportedFsms *OmciDeviceFsms
+ pSupportedFsms *cmn.OmciDeviceFsms
maxTimeoutInterAdapterComm time.Duration
maxTimeoutReconciling time.Duration
- pDownloadManager *adapterDownloadManager
- pFileManager *fileDownloadManager //let coexist 'old and new' DownloadManager as long as 'old' does not get obsolete
- metricsEnabled bool
+ pDownloadManager *swupg.AdapterDownloadManager
+ pFileManager *swupg.FileDownloadManager //let coexist 'old and new' DownloadManager as long as 'old' does not get obsolete
+ MetricsEnabled bool
mibAuditInterval time.Duration
omciTimeout int // in seconds
alarmAuditInterval time.Duration
@@ -86,7 +89,7 @@
openOnuAc.deviceHandlers = make(map[string]*deviceHandler)
openOnuAc.deviceHandlersCreateChan = make(map[string]chan bool)
openOnuAc.parentAdapterClients = make(map[string]*vgrpc.Client)
- openOnuAc.lockDeviceHandlersMap = sync.RWMutex{}
+ openOnuAc.mutexDeviceHandlersMap = sync.RWMutex{}
openOnuAc.config = cfg
openOnuAc.cm = cm
openOnuAc.coreClient = coreClient
@@ -97,14 +100,14 @@
openOnuAc.KVStoreType = cfg.KVStoreType
openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout
openOnuAc.mibTemplatesGenerated = make(map[string]bool)
- openOnuAc.lockMibTemplateGenerated = sync.RWMutex{}
+ openOnuAc.mutexMibTemplateGenerated = sync.RWMutex{}
openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval
openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto
openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm
openOnuAc.maxTimeoutReconciling = cfg.MaxTimeoutReconciling
//openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
- openOnuAc.metricsEnabled = cfg.MetricsEnabled
+ openOnuAc.MetricsEnabled = cfg.MetricsEnabled
openOnuAc.mibAuditInterval = cfg.MibAuditInterval
// since consumers of OMCI timeout value everywhere in code is in "int seconds", do this useful conversion
openOnuAc.omciTimeout = int(cfg.OmciTimeout.Seconds())
@@ -112,12 +115,12 @@
openOnuAc.dlToOnuTimeout4M = cfg.DownloadToOnuTimeout4MB
openOnuAc.rpcTimeout = cfg.RPCTimeout
- openOnuAc.pSupportedFsms = &OmciDeviceFsms{
+ openOnuAc.pSupportedFsms = &cmn.OmciDeviceFsms{
"mib-synchronizer": {
//mibSyncFsm, // Implements the MIB synchronization state machine
- mibDbVolatileDictImpl, // Implements volatile ME MIB database
+ DatabaseClass: mibDbVolatileDictImpl, // Implements volatile ME MIB database
//true, // Advertise events on OpenOMCI event bus
- openOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
+ AuditInterval: openOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
// map[string]func() error{
// "mib-upload": onuDeviceEntry.MibUploadTask,
// "mib-template": onuDeviceEntry.MibTemplateTask,
@@ -129,8 +132,8 @@
},
}
- openOnuAc.pDownloadManager = newAdapterDownloadManager(ctx)
- openOnuAc.pFileManager = newFileDownloadManager(ctx)
+ openOnuAc.pDownloadManager = swupg.NewAdapterDownloadManager(ctx)
+ openOnuAc.pFileManager = swupg.NewFileDownloadManager(ctx)
openOnuAc.pFileManager.SetDownloadTimeout(ctx, cfg.DownloadToAdapterTimeout)
return &openOnuAc
@@ -154,28 +157,28 @@
*/
func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *deviceHandler) {
- oo.lockDeviceHandlersMap.Lock()
- defer oo.lockDeviceHandlersMap.Unlock()
- if _, exist := oo.deviceHandlers[agent.deviceID]; !exist {
- oo.deviceHandlers[agent.deviceID] = agent
- oo.deviceHandlers[agent.deviceID].start(ctx)
- if _, exist := oo.deviceHandlersCreateChan[agent.deviceID]; exist {
- logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID})
- oo.deviceHandlersCreateChan[agent.deviceID] <- true
+ oo.mutexDeviceHandlersMap.Lock()
+ defer oo.mutexDeviceHandlersMap.Unlock()
+ if _, exist := oo.deviceHandlers[agent.DeviceID]; !exist {
+ oo.deviceHandlers[agent.DeviceID] = agent
+ oo.deviceHandlers[agent.DeviceID].start(ctx)
+ if _, exist := oo.deviceHandlersCreateChan[agent.DeviceID]; exist {
+ logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.DeviceID})
+ oo.deviceHandlersCreateChan[agent.DeviceID] <- true
}
}
}
func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *deviceHandler) {
- oo.lockDeviceHandlersMap.Lock()
- defer oo.lockDeviceHandlersMap.Unlock()
- delete(oo.deviceHandlers, agent.deviceID)
- delete(oo.deviceHandlersCreateChan, agent.deviceID)
+ oo.mutexDeviceHandlersMap.Lock()
+ defer oo.mutexDeviceHandlersMap.Unlock()
+ delete(oo.deviceHandlers, agent.DeviceID)
+ delete(oo.deviceHandlersCreateChan, agent.DeviceID)
}
//getDeviceHandler gets the ONU deviceHandler and may wait until it is created
func (oo *OpenONUAC) getDeviceHandler(ctx context.Context, deviceID string, aWait bool) *deviceHandler {
- oo.lockDeviceHandlersMap.Lock()
+ oo.mutexDeviceHandlersMap.Lock()
agent, ok := oo.deviceHandlers[deviceID]
if aWait && !ok {
logger.Infow(ctx, "Race condition: deviceHandler not present - wait for creation or timeout",
@@ -185,7 +188,7 @@
}
deviceCreateChan := oo.deviceHandlersCreateChan[deviceID]
//keep the read sema short to allow for subsequent write
- oo.lockDeviceHandlersMap.Unlock()
+ oo.mutexDeviceHandlersMap.Unlock()
// based on concurrent processing the deviceHandler creation may not yet be finished at his point
// so it might be needed to wait here for that event with some timeout
select {
@@ -194,12 +197,12 @@
return nil
case <-deviceCreateChan:
logger.Debugw(ctx, "deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
- oo.lockDeviceHandlersMap.RLock()
- defer oo.lockDeviceHandlersMap.RUnlock()
+ oo.mutexDeviceHandlersMap.RLock()
+ defer oo.mutexDeviceHandlersMap.RUnlock()
return oo.deviceHandlers[deviceID]
}
}
- oo.lockDeviceHandlersMap.Unlock()
+ oo.mutexDeviceHandlersMap.Unlock()
return agent
}
@@ -256,7 +259,7 @@
return nil, err
}
- handler.startReconciling(log.WithSpanFromContext(context.Background(), ctx), false)
+ handler.StartReconciling(log.WithSpanFromContext(context.Background(), ctx), false)
go handler.adoptOrReconcileDevice(log.WithSpanFromContext(context.Background(), ctx), handler.device)
// reconcilement will be continued after onu-device entry is added
} else {
@@ -315,23 +318,23 @@
}
// Stop PM, Alarm and Self Test event handler routines
- if handler.getCollectorIsRunning() {
+ if handler.GetCollectorIsRunning() {
handler.stopCollector <- true
logger.Debugw(ctx, "sent stop signal to metric collector routine", log.Fields{"device-id": device.Id})
}
- if handler.getAlarmManagerIsRunning(ctx) {
+ if handler.GetAlarmManagerIsRunning(ctx) {
handler.stopAlarmManager <- true
logger.Debugw(ctx, "sent stop signal to alarm manager", log.Fields{"device-id": device.Id})
}
if handler.pSelfTestHdlr.GetSelfTestHandlerIsRunning() {
- handler.pSelfTestHdlr.stopSelfTestModule <- true
+ handler.pSelfTestHdlr.StopSelfTestModule <- true
logger.Debugw(ctx, "sent stop signal to self test handler module", log.Fields{"device-id": device.Id})
}
// Clear PM data on the KV store
if handler.pOnuMetricsMgr != nil {
- if err := handler.pOnuMetricsMgr.clearAllPmData(ctx); err != nil {
+ if err := handler.pOnuMetricsMgr.ClearAllPmData(ctx); err != nil {
errorsList = append(errorsList, err)
}
}
@@ -396,11 +399,11 @@
func (oo *OpenONUAC) DownloadImage(ctx context.Context, imageInfo *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
ctx = log.WithSpanFromContext(context.Background(), ctx)
if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
- if !oo.pDownloadManager.imageExists(ctx, imageInfo.Image) {
+ if !oo.pDownloadManager.ImageExists(ctx, imageInfo.Image) {
logger.Debugw(ctx, "start image download", log.Fields{"image-description": imageInfo.Image})
// Download_image is not supposed to be blocking, anyway let's call the DownloadManager still synchronously to detect 'fast' problems
// the download itself is later done in background
- if err := oo.pDownloadManager.startDownload(ctx, imageInfo.Image); err != nil {
+ if err := oo.pDownloadManager.StartDownload(ctx, imageInfo.Image); err != nil {
return nil, err
}
return imageInfo.Image, nil
@@ -418,7 +421,7 @@
//The ImageDownload needs to be called `request`due to library reflection requirements
func (oo *OpenONUAC) ActivateImageUpdate(ctx context.Context, imageInfo *ic.ImageDownloadMessage) (*voltha.ImageDownload, error) {
if imageInfo != nil && imageInfo.Image != nil && imageInfo.Image.Name != "" {
- if oo.pDownloadManager.imageLocallyDownloaded(ctx, imageInfo.Image) {
+ if oo.pDownloadManager.ImageLocallyDownloaded(ctx, imageInfo.Image) {
if handler := oo.getDeviceHandler(ctx, imageInfo.Device.Id, false); handler != nil {
logger.Debugw(ctx, "image download on omci requested", log.Fields{
"image-description": imageInfo.Image, "device-id": imageInfo.Device.Id})
@@ -443,12 +446,12 @@
if handler := oo.getDeviceHandler(ctx, request.TargetId, false); handler != nil {
switch reqType := request.GetRequest().GetRequest().(type) {
case *extension.GetValueRequest_UniInfo:
- return handler.getUniPortStatus(ctx, reqType.UniInfo), nil
+ return handler.GetUniPortStatus(ctx, reqType.UniInfo), nil
case *extension.GetValueRequest_OnuOpticalInfo:
- commChan := make(chan Message)
+ CommChan := make(chan cmn.Message)
respChan := make(chan extension.SingleGetValueResponse)
// Initiate the self test request
- if err := handler.pSelfTestHdlr.SelfTestRequestStart(ctx, *request, commChan, respChan); err != nil {
+ if err := handler.pSelfTestHdlr.SelfTestRequestStart(ctx, *request, CommChan, respChan); err != nil {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: extension.GetValueResponse_ERROR,
@@ -462,12 +465,12 @@
case *extension.GetValueRequest_OnuInfo:
return handler.getOnuOMCICounters(ctx, reqType.OnuInfo), nil
default:
- return postUniStatusErrResponse(extension.GetValueResponse_UNSUPPORTED), nil
+ return uniprt.PostUniStatusErrResponse(extension.GetValueResponse_UNSUPPORTED), nil
}
}
logger.Errorw(ctx, "Single_get_value_request failed ", log.Fields{"request": request})
- return postUniStatusErrResponse(extension.GetValueResponse_INVALID_DEVICE_ID), nil
+ return uniprt.PostUniStatusErrResponse(extension.GetValueResponse_INVALID_DEVICE_ID), nil
}
//if update >= 4.3.0
@@ -1130,3 +1133,45 @@
func (oo *OpenONUAC) ChildDeviceLost(ctx context.Context, childDevice *voltha.Device) (*empty.Empty, error) {
return nil, errors.New("unImplemented")
}
+
+// GetSupportedFsms - TODO: add comment
+func (oo *OpenONUAC) GetSupportedFsms() *cmn.OmciDeviceFsms {
+ return oo.pSupportedFsms
+}
+
+// LockMutexMibTemplateGenerated - TODO: add comment
+func (oo *OpenONUAC) LockMutexMibTemplateGenerated() {
+ oo.mutexMibTemplateGenerated.Lock()
+}
+
+// UnlockMutexMibTemplateGenerated - TODO: add comment
+func (oo *OpenONUAC) UnlockMutexMibTemplateGenerated() {
+ oo.mutexMibTemplateGenerated.Unlock()
+}
+
+// GetMibTemplatesGenerated - TODO: add comment
+func (oo *OpenONUAC) GetMibTemplatesGenerated(mibTemplatePath string) (value bool, exist bool) {
+ value, exist = oo.mibTemplatesGenerated[mibTemplatePath]
+ return value, exist
+}
+
+// SetMibTemplatesGenerated - TODO: add comment
+func (oo *OpenONUAC) SetMibTemplatesGenerated(mibTemplatePath string, value bool) {
+ oo.mibTemplatesGenerated[mibTemplatePath] = value
+}
+
+// RLockMutexDeviceHandlersMap - TODO: add comment
+func (oo *OpenONUAC) RLockMutexDeviceHandlersMap() {
+ oo.mutexDeviceHandlersMap.RLock()
+}
+
+// RUnlockMutexDeviceHandlersMap - TODO: add comment
+func (oo *OpenONUAC) RUnlockMutexDeviceHandlersMap() {
+ oo.mutexDeviceHandlersMap.RUnlock()
+}
+
+// GetDeviceHandler - TODO: add comment
+func (oo *OpenONUAC) GetDeviceHandler(deviceID string) (value cmn.IdeviceHandler, exist bool) {
+ value, exist = oo.deviceHandlers[deviceID]
+ return value, exist
+}
diff --git a/internal/pkg/onuadaptercore/openonuimpl.go b/internal/pkg/core/openonuimpl.go
old mode 100644
new mode 100755
similarity index 96%
rename from internal/pkg/onuadaptercore/openonuimpl.go
rename to internal/pkg/core/openonuimpl.go
index efa4e96..8017d48
--- a/internal/pkg/onuadaptercore/openonuimpl.go
+++ b/internal/pkg/core/openonuimpl.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
import (
"context"
diff --git a/internal/pkg/onuadaptercore/platform.go b/internal/pkg/core/platform.go
old mode 100644
new mode 100755
similarity index 98%
rename from internal/pkg/onuadaptercore/platform.go
rename to internal/pkg/core/platform.go
index 6ad3e7b..9430e92
--- a/internal/pkg/onuadaptercore/platform.go
+++ b/internal/pkg/core/platform.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package core provides the utility for onu devices, flows and statistics
+package core
import "context"
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/devdb/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/devdb/common.go
index b0b10e3..74fdf31
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/devdb/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package devdb provides access to internal device ME DB
+package devdb
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "devdb"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/onu_device_db.go b/internal/pkg/devdb/onu_device_db.go
old mode 100644
new mode 100755
similarity index 63%
rename from internal/pkg/onuadaptercore/onu_device_db.go
rename to internal/pkg/devdb/onu_device_db.go
index 00a1945..1bee2ec
--- a/internal/pkg/onuadaptercore/onu_device_db.go
+++ b/internal/pkg/devdb/onu_device_db.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package devdb provides access to internal device ME DB
+package devdb
import (
"context"
@@ -30,76 +30,79 @@
type meDbMap map[me.ClassID]map[uint16]me.AttributeValueMap
-//onuDeviceDB structure holds information about known ME's
-type onuDeviceDB struct {
- ctx context.Context
- pOnuDeviceEntry *OnuDeviceEntry
- meDb meDbMap
- meDbLock sync.RWMutex
+//OnuDeviceDB structure holds information about known ME's
+type OnuDeviceDB struct {
+ ctx context.Context
+ deviceID string
+ MeDb meDbMap
+ meDbLock sync.RWMutex
}
-//newOnuDeviceDB returns a new instance for a specific ONU_Device_Entry
-func newOnuDeviceDB(ctx context.Context, aPOnuDeviceEntry *OnuDeviceEntry) *onuDeviceDB {
- logger.Debugw(ctx, "Init OnuDeviceDB for:", log.Fields{"device-id": aPOnuDeviceEntry.deviceID})
- var onuDeviceDB onuDeviceDB
- onuDeviceDB.ctx = ctx
- onuDeviceDB.pOnuDeviceEntry = aPOnuDeviceEntry
- onuDeviceDB.meDb = make(meDbMap)
+//NewOnuDeviceDB returns a new instance for a specific ONU_Device_Entry
+func NewOnuDeviceDB(ctx context.Context, aDeviceID string) *OnuDeviceDB {
+ logger.Debugw(ctx, "Init OnuDeviceDB for:", log.Fields{"device-id": aDeviceID})
+ var OnuDeviceDB OnuDeviceDB
+ OnuDeviceDB.ctx = ctx
+ OnuDeviceDB.deviceID = aDeviceID
+ OnuDeviceDB.MeDb = make(meDbMap)
- return &onuDeviceDB
+ return &OnuDeviceDB
}
-func (onuDeviceDB *onuDeviceDB) PutMe(ctx context.Context, meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
- onuDeviceDB.meDbLock.Lock()
- defer onuDeviceDB.meDbLock.Unlock()
+//PutMe puts an ME instance into internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) PutMe(ctx context.Context, meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
+ OnuDeviceDB.meDbLock.Lock()
+ defer OnuDeviceDB.meDbLock.Unlock()
//filter out the OnuData
if me.OnuDataClassID == meClassID {
return
}
- //logger.Debugw(ctx,"Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
- meInstMap, ok := onuDeviceDB.meDb[meClassID]
+ //logger.Debugw(ctx,"Search for key data :", log.Fields{"deviceId": OnuDeviceDB.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
+ meInstMap, ok := OnuDeviceDB.MeDb[meClassID]
if !ok {
- logger.Debugw(ctx, "meClassID not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "meClassID not found - add to db :", log.Fields{"device-id": OnuDeviceDB.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 := meInstMap[meEntityID]
if !ok {
/* verbose logging, avoid in >= debug level
- logger.Debugw(ctx,"meEntityId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx,"meEntityId not found - add to db :", log.Fields{"device-id": OnuDeviceDB.deviceID})
*/
meInstMap[meEntityID] = meAttributes
} else {
/* verbose logging, avoid in >= debug level
- logger.Debugw(ctx,"ME-Instance exists already: merge attribute data :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+ logger.Debugw(ctx,"ME-Instance exists already: merge attribute data :", log.Fields{"device-id": OnuDeviceDB.deviceID, "meAttribs": meAttribs})
*/
for k, v := range meAttributes {
meAttribs[k] = v
}
meInstMap[meEntityID] = meAttribs
/* verbose logging, avoid in >= debug level
- logger.Debugw(ctx,"ME-Instance updated :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+ logger.Debugw(ctx,"ME-Instance updated :", log.Fields{"device-id": OnuDeviceDB.deviceID, "meAttribs": meAttribs})
*/
}
}
}
-func (onuDeviceDB *onuDeviceDB) GetMe(meClassID me.ClassID, meEntityID uint16) me.AttributeValueMap {
- onuDeviceDB.meDbLock.RLock()
- defer onuDeviceDB.meDbLock.RUnlock()
- if meAttributes, present := onuDeviceDB.meDb[meClassID][meEntityID]; present {
+//GetMe returns an ME instance from internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) GetMe(meClassID me.ClassID, meEntityID uint16) me.AttributeValueMap {
+ OnuDeviceDB.meDbLock.RLock()
+ defer OnuDeviceDB.meDbLock.RUnlock()
+ if meAttributes, present := OnuDeviceDB.MeDb[meClassID][meEntityID]; present {
/* verbose logging, avoid in >= debug level
logger.Debugw(ctx,"ME found:", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttributes": meAttributes,
- "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ "device-id": OnuDeviceDB.deviceID})
*/
return meAttributes
}
return nil
}
-func (onuDeviceDB *onuDeviceDB) getUint32Attrib(meAttribute interface{}) (uint32, error) {
+//GetUint32Attrib converts JSON numbers to uint32
+func (OnuDeviceDB *OnuDeviceDB) GetUint32Attrib(meAttribute interface{}) (uint32, error) {
switch reflect.TypeOf(meAttribute).Kind() {
case reflect.Float64:
@@ -108,11 +111,12 @@
case reflect.Uint32:
return meAttribute.(uint32), nil
default:
- return uint32(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), onuDeviceDB.pOnuDeviceEntry.deviceID))
+ return uint32(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), OnuDeviceDB.deviceID))
}
}
-func (onuDeviceDB *onuDeviceDB) getUint16Attrib(meAttribute interface{}) (uint16, error) {
+//GetUint16Attrib converts JSON numbers to uint16
+func (OnuDeviceDB *OnuDeviceDB) GetUint16Attrib(meAttribute interface{}) (uint16, error) {
switch reflect.TypeOf(meAttribute).Kind() {
case reflect.Float64:
@@ -121,16 +125,17 @@
case reflect.Uint16:
return meAttribute.(uint16), nil
default:
- return uint16(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), onuDeviceDB.pOnuDeviceEntry.deviceID))
+ return uint16(0), fmt.Errorf(fmt.Sprintf("wrong-interface-type-%v-received-for-device-%s", reflect.TypeOf(meAttribute).Kind(), OnuDeviceDB.deviceID))
}
}
-func (onuDeviceDB *onuDeviceDB) getSortedInstKeys(ctx context.Context, meClassID me.ClassID) []uint16 {
+//GetSortedInstKeys returns a sorted list of all instances of an ME
+func (OnuDeviceDB *OnuDeviceDB) GetSortedInstKeys(ctx context.Context, meClassID me.ClassID) []uint16 {
var meInstKeys []uint16
- onuDeviceDB.meDbLock.RLock()
- defer onuDeviceDB.meDbLock.RUnlock()
- meInstMap := onuDeviceDB.meDb[meClassID]
+ OnuDeviceDB.meDbLock.RLock()
+ defer OnuDeviceDB.meDbLock.RUnlock()
+ meInstMap := OnuDeviceDB.MeDb[meClassID]
for k := range meInstMap {
meInstKeys = append(meInstKeys, k)
@@ -141,11 +146,12 @@
return meInstKeys
}
-func (onuDeviceDB *onuDeviceDB) logMeDb(ctx context.Context) {
- logger.Debugw(ctx, "ME instances stored for :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
- for meClassID, meInstMap := range onuDeviceDB.meDb {
+//LogMeDb logs content of internal ONU DB
+func (OnuDeviceDB *OnuDeviceDB) LogMeDb(ctx context.Context) {
+ logger.Debugw(ctx, "ME instances stored for :", log.Fields{"device-id": OnuDeviceDB.deviceID})
+ for meClassID, meInstMap := range OnuDeviceDB.MeDb {
for meEntityID, meAttribs := range meInstMap {
- logger.Debugw(ctx, "ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": OnuDeviceDB.deviceID})
}
}
}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/mib/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/mib/common.go
index b0b10e3..e9d39c3
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/mib/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mib"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/mib_download.go b/internal/pkg/mib/mib_download.go
old mode 100644
new mode 100755
similarity index 70%
rename from internal/pkg/onuadaptercore/mib_download.go
rename to internal/pkg/mib/mib_download.go
index 5d77931..9c49f9b
--- a/internal/pkg/onuadaptercore/mib_download.go
+++ b/internal/pkg/mib/mib_download.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
import (
"context"
@@ -30,6 +30,7 @@
//ic "github.com/opencord/voltha-protos/v5/go/inter_container"
//"github.com/opencord/voltha-protos/v5/go/openflow_13"
//"github.com/opencord/voltha-protos/v5/go/voltha"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
)
func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(ctx context.Context, e *fsm.Event) {
@@ -45,47 +46,48 @@
func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx), onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+ onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+ meInstance, err := onuDeviceEntry.PDevOmciCC.SendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx),
+ onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "GalEthernetProfile create failed, aborting MibDownload FSM!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+ pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
if pMibDlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(dlEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(DlEvReset)
}(pMibDlFsm)
}
return
}
- onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.pLastTxMeInstance = meInstance
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
}
func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx),
- onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+ onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+ meInstance, err := onuDeviceEntry.PDevOmciCC.SendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx),
+ onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "ONU2-G set failed, aborting MibDownload FSM!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+ pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
if pMibDlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(dlEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(DlEvReset)
}(pMibDlFsm)
}
return
}
- onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.pLastTxMeInstance = meInstance
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
}
func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(ctx context.Context, e *fsm.Event) {
@@ -96,14 +98,14 @@
func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.transferSystemEvent(ctx, MibDownloadDone)
+ onuDeviceEntry.transferSystemEvent(ctx, cmn.MibDownloadDone)
//let's reset the state machine in order to release all resources now
- pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+ pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
if pMibDlFsm != nil {
// 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)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(DlEvReset)
}
}(pMibDlFsm)
}
@@ -111,22 +113,22 @@
func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID})
- pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
+ pMibDlFsm := onuDeviceEntry.PMibDownloadFsm
if pMibDlFsm != nil {
// abort running message processing
- fsmAbortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ fsmAbortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
- pMibDlFsm.commChan <- fsmAbortMsg
+ pMibDlFsm.CommChan <- fsmAbortMsg
//try to restart the FSM to 'disabled'
// see DownloadedState: decouple event transfer
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(dlEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(DlEvRestart)
}
}(pMibDlFsm)
}
@@ -140,25 +142,25 @@
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
// break loop
// unless multiple channels are not involved, we should not use select
- message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan
+ message, ok := <-onuDeviceEntry.PMibDownloadFsm.CommChan
if !ok {
logger.Info(ctx, "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)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRestart)
break loop
}
logger.Debugw(ctx, "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 {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Debugw(ctx, "MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
break loop
}
logger.Warnw(ctx, "MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
onuDeviceEntry.handleOmciMibDownloadMessage(ctx, msg)
default:
logger.Warn(ctx, "MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
@@ -169,7 +171,7 @@
logger.Debugw(ctx, "End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
}
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadCreateResponseMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
@@ -192,46 +194,46 @@
// but as that is not straightforward to me I insert the type checkes manually here
// and feed the FSM with only 'pre-defined' events ...
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RLock()
- if onuDeviceEntry.PDevOmciCC.pLastTxMeInstance != nil {
- if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() &&
- msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() {
+ onuDeviceEntry.mutexPLastTxMeInstance.RLock()
+ if onuDeviceEntry.pLastTxMeInstance != nil {
+ if msgObj.EntityClass == onuDeviceEntry.pLastTxMeInstance.GetClassID() &&
+ msgObj.EntityInstance == onuDeviceEntry.pLastTxMeInstance.GetEntityID() {
//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
// if, then something like:
//onuDeviceEntry.pOnuDB.StoreMe(msgObj)
// 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 onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
+ switch onuDeviceEntry.pLastTxMeInstance.GetName() {
case "GalEthernetProfile":
{ // let the FSM proceed ...
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxGalResp)
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxGalResp)
}
case "MacBridgeServiceProfile",
"MacBridgePortConfigurationData",
"ExtendedVlanTaggingOperationConfigurationData":
{ // let bridge init proceed by stopping the wait function
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
onuDeviceEntry.omciMessageReceived <- true
}
default:
{
logger.Warnw(ctx, "Unsupported ME name received!",
- log.Fields{"ME name": onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ log.Fields{"ME name": onuDeviceEntry.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
}
}
} else {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
}
} else {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
logger.Errorw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": onuDeviceEntry.deviceID})
}
}
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadSetResponseMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadSetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
@@ -251,39 +253,39 @@
}
// compare comments above for CreateResponse (apply also here ...)
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RLock()
- if onuDeviceEntry.PDevOmciCC.pLastTxMeInstance != nil {
- if msgObj.EntityClass == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetClassID() &&
- msgObj.EntityInstance == onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetEntityID() {
+ onuDeviceEntry.mutexPLastTxMeInstance.RLock()
+ if onuDeviceEntry.pLastTxMeInstance != nil {
+ if msgObj.EntityClass == onuDeviceEntry.pLastTxMeInstance.GetClassID() &&
+ msgObj.EntityInstance == onuDeviceEntry.pLastTxMeInstance.GetEntityID() {
//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
// if, then something like:
//onuDeviceEntry.pOnuDB.StoreMe(msgObj)
- switch onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName() {
+ switch onuDeviceEntry.pLastTxMeInstance.GetName() {
case "Onu2G":
{ // let the FSM proceed ...
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxOnu2gResp)
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxOnu2gResp)
}
//so far that was the only MibDownlad Set Element ...
default:
{
logger.Warnw(ctx, "Unsupported ME name received!",
- log.Fields{"ME name": onuDeviceEntry.PDevOmciCC.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ log.Fields{"ME name": onuDeviceEntry.pLastTxMeInstance.GetName(), "device-id": onuDeviceEntry.deviceID})
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
}
}
} else {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
}
} else {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.RUnlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.RUnlock()
logger.Errorw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": onuDeviceEntry.deviceID})
}
}
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg OmciMessage) {
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID,
"msgType": msg.OmciMsg.MessageType})
@@ -291,7 +293,7 @@
case omci.CreateResponseType:
onuDeviceEntry.handleOmciMibDownloadCreateResponseMessage(ctx, msg)
//TODO
- // onuDeviceEntry.pMibDownloadFsm.pFsm.Event("rx_evtocd_resp")
+ // onuDeviceEntry.PMibDownloadFsm.PFsm.Event("rx_evtocd_resp")
case omci.SetResponseType:
onuDeviceEntry.handleOmciMibDownloadSetResponseMessage(ctx, msg)
default:
@@ -304,79 +306,79 @@
}
func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup(ctx context.Context) {
- for uniNo, uniPort := range onuDeviceEntry.baseDeviceHandler.uniEntityMap {
+ for uniNo, uniPort := range *onuDeviceEntry.baseDeviceHandler.GetUniEntityMap() {
logger.Debugw(ctx, "Starting IntialBridgeSetup", log.Fields{
"device-id": onuDeviceEntry.deviceID, "for PortNo": uniNo})
//create MBSP
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err := onuDeviceEntry.PDevOmciCC.sendCreateMBServiceProfile(
- log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+ onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+ meInstance, err := onuDeviceEntry.PDevOmciCC.SendCreateMBServiceProfile(
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
if err != nil {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "MBServiceProfile create failed, aborting MibDownload FSM!", log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
return
}
- onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.pLastTxMeInstance = meInstance
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
//verify response
err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
logger.Errorw(ctx, "InitialBridgeSetup failed at MBSP, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
return
}
//create MBPCD
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigDataUniSide(
- log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+ onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+ meInstance, err = onuDeviceEntry.PDevOmciCC.SendCreateMBPConfigDataUniSide(
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
if err != nil {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "MBPConfigData create failed, aborting MibDownload FSM!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
return
}
- onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.pLastTxMeInstance = meInstance
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
//verify response
err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
logger.Errorw(ctx, "InitialBridgeSetup failed at MBPCD, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
return
}
//create EVTOCD
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Lock()
- meInstance, err = onuDeviceEntry.PDevOmciCC.sendCreateEVTOConfigData(
- log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.pOpenOnuAc.omciTimeout, true)
+ onuDeviceEntry.mutexPLastTxMeInstance.Lock()
+ meInstance, err = onuDeviceEntry.PDevOmciCC.SendCreateEVTOConfigData(
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, onuDeviceEntry.baseDeviceHandler.GetOmciTimeout(), true)
if err != nil {
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "EVTOConfigData create failed, aborting MibDownload FSM!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvReset)
return
}
- onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
- onuDeviceEntry.PDevOmciCC.mutexPLastTxMeInstance.Unlock()
+ onuDeviceEntry.pLastTxMeInstance = meInstance
+ onuDeviceEntry.mutexPLastTxMeInstance.Unlock()
//verify response
err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
logger.Errorw(ctx, "InitialBridgeSetup failed at EVTOCD, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = 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(ctx, "IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
- _ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
+ _ = onuDeviceEntry.PMibDownloadFsm.PFsm.Event(DlEvRxBridgeResp)
}
func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/mib/mib_sync.go
old mode 100644
new mode 100755
similarity index 74%
rename from internal/pkg/onuadaptercore/mib_sync.go
rename to internal/pkg/mib/mib_sync.go
index 1660791..871b6de
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/mib/mib_sync.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package mib provides the utilities for managing the onu mib
+package mib
import (
"context"
@@ -34,6 +34,8 @@
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ devdb "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
)
type sLastTxMeParameter struct {
@@ -64,25 +66,25 @@
// 347 // definitions for ME "IPv6 host config data" are currently missing in omci-lib-go!
}
-var fsmMsg TestMessageType
+var fsmMsg cmn.TestMessageType
func (oo *OnuDeviceEntry) enterStartingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start processing MibSync-msgs in State": e.FSM.Current(), "device-id": oo.deviceID})
- oo.pOnuDB = newOnuDeviceDB(log.WithSpanFromContext(context.TODO(), ctx), oo)
+ oo.pOnuDB = devdb.NewOnuDeviceDB(log.WithSpanFromContext(context.TODO(), ctx), oo.deviceID)
go oo.processMibSyncMessages(ctx)
}
func (oo *OnuDeviceEntry) enterResettingMibState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibTemplate processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- if (!oo.isNewOnu() && !oo.baseDeviceHandler.isReconciling()) || //use case: re-auditing failed
- oo.baseDeviceHandler.isSkipOnuConfigReconciling() { //use case: reconciling without omci-config failed
- oo.baseDeviceHandler.prepareReconcilingWithActiveAdapter(ctx)
- oo.devState = DeviceStatusInit
+ if (!oo.IsNewOnu() && !oo.baseDeviceHandler.IsReconciling()) || //use case: re-auditing failed
+ oo.baseDeviceHandler.IsSkipOnuConfigReconciling() { //use case: reconciling without omci-config failed
+ oo.baseDeviceHandler.PrepareReconcilingWithActiveAdapter(ctx)
+ oo.devState = cmn.DeviceStatusInit
}
logger.Debugw(ctx, "MibSync FSM", log.Fields{"send mibReset in State": e.FSM.Current(), "device-id": oo.deviceID})
oo.mutexLastTxParamStruct.Lock()
- _ = oo.PDevOmciCC.sendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+ _ = oo.PDevOmciCC.SendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
//TODO: needs to handle timeouts
//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
// that the lastTxMessageType is correctly set to avoid misinterpreting other responses
@@ -95,16 +97,16 @@
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting VendorId and SerialNumber in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"VendorId": "", "SerialNumber": 0}
oo.mutexLastTxParamStruct.Lock()
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.OnuGClassID, onugMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.OnuGClassID, cmn.OnugMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "ONU-G get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -118,16 +120,16 @@
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting EquipmentId in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"EquipmentId": ""}
oo.mutexLastTxParamStruct.Lock()
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.Onu2GClassID, onu2gMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.Onu2GClassID, cmn.Onu2gMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "ONU2-G get failed, aborting MibSync FSM!", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -141,16 +143,16 @@
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of first SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
oo.mutexLastTxParamStruct.Lock()
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, firstSwImageMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, cmn.FirstSwImageMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "SoftwareImage get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -164,16 +166,16 @@
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of second SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
oo.mutexLastTxParamStruct.Lock()
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, secondSwImageMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, cmn.SecondSwImageMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "SoftwareImage get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -187,16 +189,16 @@
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting MacAddress in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"MacAddress": ""}
oo.mutexLastTxParamStruct.Lock()
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.IpHostConfigDataClassID, ipHostConfigDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.IpHostConfigDataClassID, cmn.IPHostConfigDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "IpHostConfigData get failed, aborting MibSync FSM", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -209,10 +211,10 @@
func (oo *OnuDeviceEntry) enterGettingMibTemplateState(ctx context.Context, e *fsm.Event) {
oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.activeEntityEntry.valid {
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersActiveSwVersion = oo.onuSwImageIndications.activeEntityEntry.version
- oo.mutexPersOnuConfig.Unlock()
+ if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersActiveSwVersion = oo.onuSwImageIndications.ActiveEntityEntry.Version
+ oo.MutexPersOnuConfig.Unlock()
oo.mutexOnuSwImageIndications.RUnlock()
} else {
oo.mutexOnuSwImageIndications.RUnlock()
@@ -221,35 +223,35 @@
}
if oo.getMibFromTemplate(ctx) {
logger.Debug(ctx, "MibSync FSM - valid MEs stored from template")
- oo.pOnuDB.logMeDb(ctx)
- fsmMsg = LoadMibTemplateOk
+ oo.pOnuDB.LogMeDb(ctx)
+ fsmMsg = cmn.LoadMibTemplateOk
} else {
logger.Debug(ctx, "MibSync FSM - no valid MEs stored from template - perform MIB-upload!")
- fsmMsg = LoadMibTemplateFailed
+ fsmMsg = cmn.LoadMibTemplateFailed
- oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
- if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
+ oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+ if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.GetMibTemplatesGenerated(oo.mibTemplatePath); exist {
if mibTemplateIsGenerated {
logger.Debugw(ctx,
"MibSync FSM - template was successfully generated before, but doesn't exist or isn't usable anymore - reset flag in map",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
- oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
+ oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
}
}
- oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+ oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
}
- mibSyncMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
+ mibSyncMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
TestMessageVal: fsmMsg,
},
}
- oo.pMibUploadFsm.commChan <- mibSyncMsg
+ oo.PMibUploadFsm.CommChan <- mibSyncMsg
}
func (oo *OnuDeviceEntry) enterUploadingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"send MibUpload in State": e.FSM.Current(), "device-id": oo.deviceID})
- _ = oo.PDevOmciCC.sendMibUpload(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+ _ = oo.PDevOmciCC.SendMibUpload(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
// that the lastTxMessageType is correctly set to avoid misinterpreting other responses
oo.mutexLastTxParamStruct.Lock()
@@ -259,21 +261,21 @@
func (oo *OnuDeviceEntry) enterUploadDoneState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oo.deviceID})
- oo.transferSystemEvent(ctx, MibDatabaseSync)
+ oo.transferSystemEvent(ctx, cmn.MibDatabaseSync)
go func() {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
}()
}
func (oo *OnuDeviceEntry) enterInSyncState(ctx context.Context, e *fsm.Event) {
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersMibLastDbSync = uint32(time.Now().Unix())
- oo.mutexPersOnuConfig.Unlock()
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersMibLastDbSync = uint32(time.Now().Unix())
+ oo.MutexPersOnuConfig.Unlock()
if oo.mibAuditInterval > 0 {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"trigger next Audit in State": e.FSM.Current(), "oo.mibAuditInterval": oo.mibAuditInterval, "device-id": oo.deviceID})
go func() {
time.Sleep(oo.mibAuditInterval)
- if err := oo.pMibUploadFsm.pFsm.Event(ulEvAuditMib); err != nil {
+ if err := oo.PMibUploadFsm.PFsm.Event(UlEvAuditMib); err != nil {
logger.Debugw(ctx, "MibSyncFsm: Can't go to state auditing", log.Fields{"device-id": oo.deviceID, "err": err})
}
}()
@@ -300,20 +302,20 @@
log.Fields{"Start processing on examining MDS success in State": e.FSM.Current(), "device-id": oo.deviceID})
if oo.getMibFromTemplate(ctx) {
- oo.baseDeviceHandler.startReconciling(ctx, true)
- oo.baseDeviceHandler.addAllUniPorts(ctx)
- oo.baseDeviceHandler.setDeviceReason(drInitialMibDownloaded)
- oo.baseDeviceHandler.setReadyForOmciConfig(true)
+ oo.baseDeviceHandler.StartReconciling(ctx, true)
+ oo.baseDeviceHandler.AddAllUniPorts(ctx)
+ oo.baseDeviceHandler.SetDeviceReason(cmn.DrInitialMibDownloaded)
+ oo.baseDeviceHandler.SetReadyForOmciConfig(true)
- if !oo.baseDeviceHandler.getCollectorIsRunning() {
+ if !oo.baseDeviceHandler.GetCollectorIsRunning() {
// Start PM collector routine
- go oo.baseDeviceHandler.startCollector(ctx)
+ go oo.baseDeviceHandler.StartCollector(ctx)
}
- if !oo.baseDeviceHandler.getAlarmManagerIsRunning(ctx) {
- go oo.baseDeviceHandler.startAlarmManager(ctx)
+ if !oo.baseDeviceHandler.GetAlarmManagerIsRunning(ctx) {
+ go oo.baseDeviceHandler.StartAlarmManager(ctx)
}
// no need to reconcile additional data for MibDownloadFsm, LockStateFsm, or UnlockStateFsm
- oo.baseDeviceHandler.reconcileDeviceTechProf(ctx)
+ oo.baseDeviceHandler.ReconcileDeviceTechProf(ctx)
// start go routine with select() on reconciling flow channel before
// starting flow reconciling process to prevent loss of any signal
@@ -322,66 +324,66 @@
// we get a signal that the processing of the last step to rebuild the adapter internal
// flow data is finished.
select {
- case success := <-oo.baseDeviceHandler.chReconcilingFlowsFinished:
+ case success := <-oo.chReconcilingFlowsFinished:
if success {
logger.Debugw(ctx, "reconciling flows has been finished in time",
log.Fields{"device-id": oo.deviceID})
- oo.baseDeviceHandler.stopReconciling(ctx, true)
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ oo.baseDeviceHandler.StopReconciling(ctx, true)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
} else {
logger.Debugw(ctx, "wait for reconciling flows aborted",
log.Fields{"device-id": oo.deviceID})
- oo.baseDeviceHandler.setReconcilingFlows(false)
+ oo.SetReconcilingFlows(false)
}
case <-time.After(500 * time.Millisecond):
logger.Errorw(ctx, "timeout waiting for reconciling flows to be finished!",
log.Fields{"device-id": oo.deviceID})
- oo.baseDeviceHandler.setReconcilingFlows(false)
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+ oo.SetReconcilingFlows(false)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
}
}()
- oo.baseDeviceHandler.reconcileDeviceFlowConfig(ctx)
+ oo.baseDeviceHandler.ReconcileDeviceFlowConfig(ctx)
- oo.mutexPersOnuConfig.RLock()
- if oo.sOnuPersistentData.PersUniDisableDone {
- oo.mutexPersOnuConfig.RUnlock()
- oo.baseDeviceHandler.disableUniPortStateUpdate(ctx)
- oo.baseDeviceHandler.setDeviceReason(drOmciAdminLock)
+ oo.MutexPersOnuConfig.RLock()
+ if oo.SOnuPersistentData.PersUniDisableDone {
+ oo.MutexPersOnuConfig.RUnlock()
+ oo.baseDeviceHandler.DisableUniPortStateUpdate(ctx)
+ oo.baseDeviceHandler.SetDeviceReason(cmn.DrOmciAdminLock)
} else {
- oo.mutexPersOnuConfig.RUnlock()
- oo.baseDeviceHandler.enableUniPortStateUpdate(ctx)
+ oo.MutexPersOnuConfig.RUnlock()
+ oo.baseDeviceHandler.EnableUniPortStateUpdate(ctx)
}
} else {
logger.Debugw(ctx, "MibSync FSM",
log.Fields{"Getting MIB from template not successful": e.FSM.Current(), "device-id": oo.deviceID})
go func() {
//switch to reconciling with OMCI config
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
}()
}
}
func (oo *OnuDeviceEntry) enterAuditingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibAudit processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- if oo.baseDeviceHandler.checkAuditStartCondition(ctx, cUploadFsm) {
+ if oo.baseDeviceHandler.CheckAuditStartCondition(ctx, cmn.CUploadFsm) {
oo.requestMdsValue(ctx)
} else {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Configuration is ongoing or missing - skip auditing!": e.FSM.Current(), "device-id": oo.deviceID})
go func() {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
}()
}
}
func (oo *OnuDeviceEntry) enterReAuditingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start retest MdsValue processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- if oo.baseDeviceHandler.checkAuditStartCondition(ctx, cUploadFsm) {
+ if oo.baseDeviceHandler.CheckAuditStartCondition(ctx, cmn.CUploadFsm) {
oo.requestMdsValue(ctx)
} else {
logger.Debugw(ctx, "MibSync FSM", log.Fields{"Configuration is ongoing or missing - skip re-auditing!": e.FSM.Current(), "device-id": oo.deviceID})
go func() {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
}()
}
}
@@ -398,7 +400,7 @@
// case <-ctx.Done():
// logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": onuDeviceEntry.deviceID})
// break loop
- message, ok := <-oo.pMibUploadFsm.commChan
+ message, ok := <-oo.PMibUploadFsm.CommChan
if !ok {
logger.Info(ctx, "MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": oo.deviceID})
break loop
@@ -406,11 +408,11 @@
logger.Debugw(ctx, "MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": oo.deviceID})
switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
oo.handleTestMsg(ctx, msg)
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oo.handleOmciMessage(ctx, msg)
default:
logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "message.Type": message.Type})
@@ -418,38 +420,38 @@
}
logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
// TODO: only this action?
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}
-func (oo *OnuDeviceEntry) handleTestMsg(ctx context.Context, msg TestMessage) {
+func (oo *OnuDeviceEntry) handleTestMsg(ctx context.Context, msg cmn.TestMessage) {
logger.Debugw(ctx, "MibSync Msg", log.Fields{"TestMessage received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
switch msg.TestMessageVal {
- case LoadMibTemplateFailed:
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvUploadMib)
- logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
- case LoadMibTemplateOk:
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
- logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
+ case cmn.LoadMibTemplateFailed:
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvUploadMib)
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.PMibUploadFsm.PFsm.Current())})
+ case cmn.LoadMibTemplateOk:
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.PMibUploadFsm.PFsm.Current())})
default:
logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
}
}
-func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(ctx context.Context, msg OmciMessage) {
- if oo.pMibUploadFsm.pFsm.Is(ulStResettingMib) {
+func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
+ if oo.PMibUploadFsm.PFsm.Is(UlStResettingMib) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibResetResponse)
if msgLayer != nil {
msgObj, msgOk := msgLayer.(*omci.MibResetResponse)
if msgOk {
logger.Debugw(ctx, "MibResetResponse Data", log.Fields{"data-fields": msgObj})
if msgObj.Result == me.Success {
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersMibDataSyncAdpt = 0
- oo.mutexPersOnuConfig.Unlock()
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersMibDataSyncAdpt = 0
+ oo.MutexPersOnuConfig.Unlock()
// trigger retrieval of VendorId and SerialNumber
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetVendorAndSerial)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetVendorAndSerial)
return
}
logger.Errorw(ctx, "Omci MibResetResponse Error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
@@ -467,12 +469,12 @@
if oo.lastTxParamStruct.lastTxMessageType == omci.GetRequestType && oo.lastTxParamStruct.repeatCount == 0 {
logger.Debugw(ctx, "MibSync FSM - repeat MdsGetRequest (updated SequenceNumber)", log.Fields{"device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"MibDataSync": ""}
- _, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
- me.OnuDataClassID, onuDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ _, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
+ me.OnuDataClassID, cmn.OnuDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
if err != nil {
oo.mutexLastTxParamStruct.Unlock()
logger.Errorw(ctx, "ONUData get failed, aborting MibSync", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
return
}
//TODO: needs extra handling of timeouts
@@ -486,10 +488,10 @@
return
}
logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}
-func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadResponse)
if msgLayer == nil {
logger.Errorw(ctx, "Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
@@ -502,22 +504,22 @@
}
logger.Debugw(ctx, "MibUploadResponse Data for:", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
/* to be verified / reworked !!! */
- oo.PDevOmciCC.uploadNoOfCmds = msgObj.NumberOfCommands
- if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
- _ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+ oo.PDevOmciCC.UploadNoOfCmds = msgObj.NumberOfCommands
+ if oo.PDevOmciCC.UploadSequNo < oo.PDevOmciCC.UploadNoOfCmds {
+ _ = oo.PDevOmciCC.SendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
// that the lastTxMessageType is correctly set to avoid misinterpreting other responses
oo.mutexLastTxParamStruct.Lock()
oo.lastTxParamStruct.lastTxMessageType = omci.MibUploadNextRequestType
oo.mutexLastTxParamStruct.Unlock()
} else {
- logger.Errorw(ctx, "Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "uploadNoOfCmds": oo.PDevOmciCC.uploadNoOfCmds})
+ logger.Errorw(ctx, "Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "UploadNoOfCmds": oo.PDevOmciCC.UploadNoOfCmds})
//TODO right action?
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvTimeout)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvTimeout)
}
}
-func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(ctx context.Context, msg cmn.OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadNextResponse)
if msgLayer == nil {
@@ -541,25 +543,25 @@
meAttributes := msgObj.ReportedME.GetAttributeValueMap()
oo.pOnuDB.PutMe(ctx, meClassID, meEntityID, meAttributes)
}
- if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
- _ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+ if oo.PDevOmciCC.UploadSequNo < oo.PDevOmciCC.UploadNoOfCmds {
+ _ = oo.PDevOmciCC.SendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
//even though lastTxParameters are currently not used for checking the ResetResponse message we have to ensure
// that the lastTxMessageType is correctly set to avoid misinterpreting other responses
oo.mutexLastTxParamStruct.Lock()
oo.lastTxParamStruct.lastTxMessageType = omci.MibUploadNextRequestType
oo.mutexLastTxParamStruct.Unlock()
} else {
- oo.pOnuDB.logMeDb(ctx)
+ oo.pOnuDB.LogMeDb(ctx)
err := oo.createAndPersistMibTemplate(ctx)
if err != nil {
logger.Errorw(ctx, "MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": oo.deviceID})
}
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
}
}
-func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
var err error = nil
oo.mutexLastTxParamStruct.RLock()
@@ -570,7 +572,7 @@
// then we may force the ONU to react on the MIB reset with a new message that uses an increased Sequence number
if oo.lastTxParamStruct.lastTxMessageType == omci.MibResetRequestType && oo.lastTxParamStruct.repeatCount == 0 {
logger.Debugw(ctx, "MibSync FSM - repeat mibReset (updated SequenceNumber)", log.Fields{"device-id": oo.deviceID})
- _ = oo.PDevOmciCC.sendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.pOpenOnuAc.omciTimeout, true)
+ _ = oo.PDevOmciCC.SendMibReset(log.WithSpanFromContext(context.TODO(), ctx), oo.baseDeviceHandler.GetOmciTimeout(), true)
//TODO: needs extra handling of timeouts
oo.lastTxParamStruct.repeatCount = 1
oo.mutexLastTxParamStruct.RUnlock()
@@ -585,13 +587,13 @@
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
if msgLayer == nil {
logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.GetResponse)
if !msgOk {
logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
}
logger.Debugw(ctx, "MibSync FSM - GetResponse Data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
@@ -605,36 +607,36 @@
switch meInstance {
case "OnuG":
oo.mutexLastTxParamStruct.RUnlock()
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersVendorID = TrimStringFromMeOctet(meAttributes["VendorId"])
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersVendorID = cmn.TrimStringFromMeOctet(meAttributes["VendorId"])
snBytes, _ := me.InterfaceToOctets(meAttributes["SerialNumber"])
- if onugSerialNumberLen == len(snBytes) {
+ if cmn.OnugSerialNumberLen == len(snBytes) {
snVendorPart := fmt.Sprintf("%s", snBytes[:4])
snNumberPart := hex.EncodeToString(snBytes[4:])
- oo.sOnuPersistentData.PersSerialNumber = snVendorPart + snNumberPart
+ oo.SOnuPersistentData.PersSerialNumber = snVendorPart + snNumberPart
logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"device-id": oo.deviceID,
- "onuDeviceEntry.vendorID": oo.sOnuPersistentData.PersVendorID, "onuDeviceEntry.serialNumber": oo.sOnuPersistentData.PersSerialNumber})
+ "onuDeviceEntry.vendorID": oo.SOnuPersistentData.PersVendorID, "onuDeviceEntry.serialNumber": oo.SOnuPersistentData.PersSerialNumber})
} else {
logger.Infow(ctx, "MibSync FSM - SerialNumber has wrong length - fill serialNumber with zeros", log.Fields{"device-id": oo.deviceID, "length": len(snBytes)})
- oo.sOnuPersistentData.PersSerialNumber = cEmptySerialNumberString
+ oo.SOnuPersistentData.PersSerialNumber = cEmptySerialNumberString
}
- oo.mutexPersOnuConfig.Unlock()
+ oo.MutexPersOnuConfig.Unlock()
// trigger retrieval of EquipmentId
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetEquipmentID)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetEquipmentID)
return nil
case "Onu2G":
oo.mutexLastTxParamStruct.RUnlock()
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersEquipmentID = TrimStringFromMeOctet(meAttributes["EquipmentId"])
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersEquipmentID = cmn.TrimStringFromMeOctet(meAttributes["EquipmentId"])
logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"device-id": oo.deviceID,
- "onuDeviceEntry.equipmentID": oo.sOnuPersistentData.PersEquipmentID})
- oo.mutexPersOnuConfig.Unlock()
+ "onuDeviceEntry.equipmentID": oo.SOnuPersistentData.PersEquipmentID})
+ oo.MutexPersOnuConfig.Unlock()
// trigger retrieval of 1st SW-image info
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetFirstSwVersion)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetFirstSwVersion)
return nil
case "SoftwareImage":
oo.mutexLastTxParamStruct.RUnlock()
- if entityID > secondSwImageMeID {
+ if entityID > cmn.SecondSwImageMeID {
logger.Errorw(ctx, "mibSync FSM - Failed to GetResponse Data for SoftwareImage with expected EntityId",
log.Fields{"device-id": oo.deviceID, "entity-ID": entityID})
return fmt.Errorf("mibSync FSM - SwResponse Data with unexpected EntityId: %s %x",
@@ -646,18 +648,18 @@
case "IpHostConfigData":
oo.mutexLastTxParamStruct.RUnlock()
macBytes, _ := me.InterfaceToOctets(meAttributes["MacAddress"])
- oo.mutexPersOnuConfig.Lock()
- if omciMacAddressLen == len(macBytes) {
- oo.sOnuPersistentData.PersMacAddress = hex.EncodeToString(macBytes[:])
+ oo.MutexPersOnuConfig.Lock()
+ if cmn.OmciMacAddressLen == len(macBytes) {
+ oo.SOnuPersistentData.PersMacAddress = hex.EncodeToString(macBytes[:])
logger.Debugw(ctx, "MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"device-id": oo.deviceID,
- "macAddress": oo.sOnuPersistentData.PersMacAddress})
+ "macAddress": oo.SOnuPersistentData.PersMacAddress})
} else {
logger.Infow(ctx, "MibSync FSM - MacAddress wrong length - fill macAddress with zeros", log.Fields{"device-id": oo.deviceID, "length": len(macBytes)})
- oo.sOnuPersistentData.PersMacAddress = cEmptyMacAddrString
+ oo.SOnuPersistentData.PersMacAddress = cEmptyMacAddrString
}
- oo.mutexPersOnuConfig.Unlock()
+ oo.MutexPersOnuConfig.Unlock()
// trigger retrieval of mib template
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMibTemplate)
return nil
case "OnuData":
oo.mutexLastTxParamStruct.RUnlock()
@@ -680,86 +682,86 @@
}
}
logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
return err
}
func (oo *OnuDeviceEntry) handleSwImageIndications(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap) {
imageIsCommitted := meAttributes["IsCommitted"].(uint8)
imageIsActive := meAttributes["IsActive"].(uint8)
- imageVersion := TrimStringFromMeOctet(meAttributes["Version"])
- oo.mutexPersOnuConfig.RLock()
+ imageVersion := cmn.TrimStringFromMeOctet(meAttributes["Version"])
+ oo.MutexPersOnuConfig.RLock()
logger.Infow(ctx, "MibSync FSM - GetResponse Data for SoftwareImage",
log.Fields{"device-id": oo.deviceID, "entityID": entityID,
- "version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted, "SNR": oo.sOnuPersistentData.PersSerialNumber})
- oo.mutexPersOnuConfig.RUnlock()
- if firstSwImageMeID == entityID {
+ "version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted, "SNR": oo.SOnuPersistentData.PersSerialNumber})
+ oo.MutexPersOnuConfig.RUnlock()
+ if cmn.FirstSwImageMeID == entityID {
//always accept the state of the first image (2nd image info should not yet be available)
oo.mutexOnuSwImageIndications.Lock()
- if imageIsActive == swIsActive {
- oo.onuSwImageIndications.activeEntityEntry.entityID = entityID
- oo.onuSwImageIndications.activeEntityEntry.valid = true
- oo.onuSwImageIndications.activeEntityEntry.version = imageVersion
- oo.onuSwImageIndications.activeEntityEntry.isCommitted = imageIsCommitted
+ if imageIsActive == cmn.SwIsActive {
+ oo.onuSwImageIndications.ActiveEntityEntry.EntityID = entityID
+ oo.onuSwImageIndications.ActiveEntityEntry.Valid = true
+ oo.onuSwImageIndications.ActiveEntityEntry.Version = imageVersion
+ oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = imageIsCommitted
//as the SW version indication may stem from some ONU Down/up event
//the complementary image state is to be invalidated
// (state of the second image is always expected afterwards or just invalid)
- oo.onuSwImageIndications.inactiveEntityEntry.valid = false
+ oo.onuSwImageIndications.InActiveEntityEntry.Valid = false
} else {
- oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
- oo.onuSwImageIndications.inactiveEntityEntry.valid = true
- oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
- oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+ oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+ oo.onuSwImageIndications.InActiveEntityEntry.Valid = true
+ oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+ oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
//as the SW version indication may stem form some ONU Down/up event
//the complementary image state is to be invalidated
// (state of the second image is always expected afterwards or just invalid)
- oo.onuSwImageIndications.activeEntityEntry.valid = false
+ oo.onuSwImageIndications.ActiveEntityEntry.Valid = false
}
oo.mutexOnuSwImageIndications.Unlock()
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetSecondSwVersion)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetSecondSwVersion)
return
- } else if secondSwImageMeID == entityID {
+ } else if cmn.SecondSwImageMeID == entityID {
//2nd image info might conflict with first image info, in which case we priorize first image info!
oo.mutexOnuSwImageIndications.Lock()
- if imageIsActive == swIsActive { //2nd image reported to be active
- if oo.onuSwImageIndications.activeEntityEntry.valid {
+ if imageIsActive == cmn.SwIsActive { //2nd image reported to be active
+ if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
//conflict exists - state of first image is left active
logger.Warnw(ctx, "mibSync FSM - both ONU images are reported as active - assuming 2nd to be inactive",
log.Fields{"device-id": oo.deviceID})
- oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
- oo.onuSwImageIndications.inactiveEntityEntry.valid = true ////to indicate that at least something has been reported
- oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
- oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+ oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+ oo.onuSwImageIndications.InActiveEntityEntry.Valid = true ////to indicate that at least something has been reported
+ oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+ oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
} else { //first image inactive, this one active
- oo.onuSwImageIndications.activeEntityEntry.entityID = entityID
- oo.onuSwImageIndications.activeEntityEntry.valid = true
- oo.onuSwImageIndications.activeEntityEntry.version = imageVersion
- oo.onuSwImageIndications.activeEntityEntry.isCommitted = imageIsCommitted
+ oo.onuSwImageIndications.ActiveEntityEntry.EntityID = entityID
+ oo.onuSwImageIndications.ActiveEntityEntry.Valid = true
+ oo.onuSwImageIndications.ActiveEntityEntry.Version = imageVersion
+ oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = imageIsCommitted
}
} else { //2nd image reported to be inactive
- if oo.onuSwImageIndications.inactiveEntityEntry.valid {
+ if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
//conflict exists - both images inactive - regard it as ONU failure and assume first image to be active
logger.Warnw(ctx, "mibSync FSM - both ONU images are reported as inactive, defining first to be active",
log.Fields{"device-id": oo.deviceID})
- oo.onuSwImageIndications.activeEntityEntry.entityID = firstSwImageMeID
- oo.onuSwImageIndications.activeEntityEntry.valid = true //to indicate that at least something has been reported
+ oo.onuSwImageIndications.ActiveEntityEntry.EntityID = cmn.FirstSwImageMeID
+ oo.onuSwImageIndications.ActiveEntityEntry.Valid = true //to indicate that at least something has been reported
//copy active commit/version from the previously stored inactive position
- oo.onuSwImageIndications.activeEntityEntry.version = oo.onuSwImageIndications.inactiveEntityEntry.version
- oo.onuSwImageIndications.activeEntityEntry.isCommitted = oo.onuSwImageIndications.inactiveEntityEntry.isCommitted
+ oo.onuSwImageIndications.ActiveEntityEntry.Version = oo.onuSwImageIndications.InActiveEntityEntry.Version
+ oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted
}
//in any case we indicate (and possibly overwrite) the second image indications as inactive
- oo.onuSwImageIndications.inactiveEntityEntry.entityID = entityID
- oo.onuSwImageIndications.inactiveEntityEntry.valid = true
- oo.onuSwImageIndications.inactiveEntityEntry.version = imageVersion
- oo.onuSwImageIndications.inactiveEntityEntry.isCommitted = imageIsCommitted
+ oo.onuSwImageIndications.InActiveEntityEntry.EntityID = entityID
+ oo.onuSwImageIndications.InActiveEntityEntry.Valid = true
+ oo.onuSwImageIndications.InActiveEntityEntry.Version = imageVersion
+ oo.onuSwImageIndications.InActiveEntityEntry.IsCommitted = imageIsCommitted
}
oo.mutexOnuSwImageIndications.Unlock()
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMacAddress)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMacAddress)
return
}
}
-func (oo *OnuDeviceEntry) handleOmciMessage(ctx context.Context, msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "MibSync Msg", log.Fields{"OmciMessage received for device-id": oo.deviceID,
"msgType": msg.OmciMsg.MessageType, "msg": msg})
//further analysis could be done here based on msg.OmciMsg.Payload, e.g. verification of error code ...
@@ -798,11 +800,11 @@
oo.mutexLastTxParamStruct.RUnlock()
logger.Debugw(ctx, "MibSync FSM - erroneous result for IpHostConfigData received - ONU doesn't support ME - fill macAddress with zeros",
log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
- oo.mutexPersOnuConfig.Lock()
- oo.sOnuPersistentData.PersMacAddress = cEmptyMacAddrString
- oo.mutexPersOnuConfig.Unlock()
+ oo.MutexPersOnuConfig.Lock()
+ oo.SOnuPersistentData.PersMacAddress = cEmptyMacAddrString
+ oo.MutexPersOnuConfig.Unlock()
// trigger retrieval of mib template
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvGetMibTemplate)
return nil
default:
oo.mutexLastTxParamStruct.RUnlock()
@@ -823,10 +825,11 @@
return err
}
-func (oo *OnuDeviceEntry) isNewOnu() bool {
- oo.mutexPersOnuConfig.RLock()
- defer oo.mutexPersOnuConfig.RUnlock()
- return oo.sOnuPersistentData.PersMibLastDbSync == 0
+// IsNewOnu - TODO: add comment
+func (oo *OnuDeviceEntry) IsNewOnu() bool {
+ oo.MutexPersOnuConfig.RLock()
+ defer oo.MutexPersOnuConfig.RUnlock()
+ return oo.SOnuPersistentData.PersMibLastDbSync == 0
}
func isSupportedClassID(meClassID me.ClassID) bool {
@@ -850,12 +853,12 @@
logger.Debugw(ctx, "MibSync - MibTemplate - path name", log.Fields{"path": oo.mibTemplatePath,
"device-id": oo.deviceID})
- oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
- if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
+ oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+ if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.GetMibTemplatesGenerated(oo.mibTemplatePath); exist {
if mibTemplateIsGenerated {
logger.Debugw(ctx, "MibSync - MibTemplate - another thread has already started to generate it - skip",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
- oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+ oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
return nil
}
logger.Debugw(ctx, "MibSync - MibTemplate - previous generation attempt seems to be failed - try again",
@@ -864,15 +867,15 @@
logger.Debugw(ctx, "MibSync - MibTemplate - first ONU-instance of this kind - start generation",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
}
- oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = true
- oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+ oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, true)
+ oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
currentTime := time.Now()
templateMap := make(map[string]interface{})
templateMap["TemplateName"] = oo.mibTemplatePath
templateMap["TemplateCreated"] = currentTime.Format("2006-01-02 15:04:05.000000")
- firstLevelMap := oo.pOnuDB.meDb
+ firstLevelMap := oo.pOnuDB.MeDb
for firstLevelKey, firstLevelValue := range firstLevelMap {
logger.Debugw(ctx, "MibSync - MibTemplate - firstLevelKey", log.Fields{"firstLevelKey": firstLevelKey})
classID := strconv.Itoa(int(firstLevelKey))
@@ -902,17 +905,17 @@
mibTemplate, err := json.Marshal(&templateMap)
if err != nil {
logger.Errorw(ctx, "MibSync - MibTemplate - Failed to marshal mibTemplate", log.Fields{"error": err, "device-id": oo.deviceID})
- oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
- oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
- oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+ oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+ oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
+ oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
return err
}
err = oo.mibTemplateKVStore.Put(log.WithSpanFromContext(context.TODO(), ctx), oo.mibTemplatePath, string(mibTemplate))
if err != nil {
logger.Errorw(ctx, "MibSync - MibTemplate - Failed to store template in etcd", log.Fields{"error": err, "device-id": oo.deviceID})
- oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
- oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
- oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+ oo.pOpenOnuAc.LockMutexMibTemplateGenerated()
+ oo.pOpenOnuAc.SetMibTemplatesGenerated(oo.mibTemplatePath, false)
+ oo.pOpenOnuAc.UnlockMutexMibTemplateGenerated()
return err
}
logger.Debugw(ctx, "MibSync - MibTemplate - Stored the template to etcd", log.Fields{"device-id": oo.deviceID})
@@ -922,16 +925,16 @@
func (oo *OnuDeviceEntry) requestMdsValue(ctx context.Context) {
logger.Debugw(ctx, "Request MDS value", log.Fields{"device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"MibDataSync": ""}
- meInstance, err := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
- me.OnuDataClassID, onuDataMeID, requestedAttributes, oo.pOpenOnuAc.omciTimeout, true, oo.pMibUploadFsm.commChan)
+ meInstance, err := oo.PDevOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx),
+ me.OnuDataClassID, cmn.OnuDataMeID, requestedAttributes, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.PMibUploadFsm.CommChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
if err != nil {
logger.Errorw(ctx, "ONUData get failed, aborting MibSync FSM!", log.Fields{"device-id": oo.deviceID})
- pMibUlFsm := oo.pMibUploadFsm
+ pMibUlFsm := oo.PMibUploadFsm
if pMibUlFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvStop)
}(pMibUlFsm)
}
return
@@ -944,47 +947,47 @@
}
func (oo *OnuDeviceEntry) checkMdsValue(ctx context.Context, mibDataSyncOnu uint8) {
- oo.mutexPersOnuConfig.RLock()
+ oo.MutexPersOnuConfig.RLock()
logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu-Data - MibDataSync", log.Fields{"device-id": oo.deviceID,
- "mibDataSyncOnu": mibDataSyncOnu, "PersMibDataSyncAdpt": oo.sOnuPersistentData.PersMibDataSyncAdpt})
+ "mibDataSyncOnu": mibDataSyncOnu, "PersMibDataSyncAdpt": oo.SOnuPersistentData.PersMibDataSyncAdpt})
- mdsValuesAreEqual := oo.sOnuPersistentData.PersMibDataSyncAdpt == mibDataSyncOnu
- oo.mutexPersOnuConfig.RUnlock()
- if oo.pMibUploadFsm.pFsm.Is(ulStAuditing) {
+ mdsValuesAreEqual := oo.SOnuPersistentData.PersMibDataSyncAdpt == mibDataSyncOnu
+ oo.MutexPersOnuConfig.RUnlock()
+ if oo.PMibUploadFsm.PFsm.Is(UlStAuditing) {
if mdsValuesAreEqual {
logger.Debugw(ctx, "MibSync FSM - mib audit - MDS check ok", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
} else {
logger.Warnw(ctx, "MibSync FSM - mib audit - MDS check failed for the first time!", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
}
- } else if oo.pMibUploadFsm.pFsm.Is(ulStReAuditing) {
+ } else if oo.PMibUploadFsm.PFsm.Is(UlStReAuditing) {
if mdsValuesAreEqual {
logger.Debugw(ctx, "MibSync FSM - mib reaudit - MDS check ok", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
} else {
logger.Errorw(ctx, "MibSync FSM - mib audit - MDS check failed for the second time!", log.Fields{"device-id": oo.deviceID})
//TODO: send new event notification "MDS counter mismatch" to the core
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
}
- } else if oo.pMibUploadFsm.pFsm.Is(ulStExaminingMds) {
+ } else if oo.PMibUploadFsm.PFsm.Is(UlStExaminingMds) {
if mdsValuesAreEqual && mibDataSyncOnu != 0 {
logger.Debugw(ctx, "MibSync FSM - MDS examination ok", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
} else {
logger.Debugw(ctx, "MibSync FSM - MDS examination failed - new provisioning", log.Fields{"device-id": oo.deviceID})
- _ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
+ _ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
}
} else {
- logger.Warnw(ctx, "wrong state for MDS evaluation!", log.Fields{"state": oo.pMibUploadFsm.pFsm.Current(), "device-id": oo.deviceID})
+ logger.Warnw(ctx, "wrong state for MDS evaluation!", log.Fields{"state": oo.PMibUploadFsm.PFsm.Current(), "device-id": oo.deviceID})
}
}
//GetActiveImageMeID returns the Omci MeId of the active ONU image together with error code for validity
func (oo *OnuDeviceEntry) GetActiveImageMeID(ctx context.Context) (uint16, error) {
oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.activeEntityEntry.valid {
- value := oo.onuSwImageIndications.activeEntityEntry.entityID
+ if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+ value := oo.onuSwImageIndications.ActiveEntityEntry.EntityID
oo.mutexOnuSwImageIndications.RUnlock()
return value, nil
}
@@ -995,8 +998,8 @@
//GetInactiveImageMeID returns the Omci MeId of the inactive ONU image together with error code for validity
func (oo *OnuDeviceEntry) GetInactiveImageMeID(ctx context.Context) (uint16, error) {
oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.inactiveEntityEntry.valid {
- value := oo.onuSwImageIndications.inactiveEntityEntry.entityID
+ if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
+ value := oo.onuSwImageIndications.InActiveEntityEntry.EntityID
oo.mutexOnuSwImageIndications.RUnlock()
return value, nil
}
@@ -1007,9 +1010,9 @@
//IsImageToBeCommitted returns true if the active image is still uncommitted
func (oo *OnuDeviceEntry) IsImageToBeCommitted(ctx context.Context, aImageID uint16) bool {
oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.activeEntityEntry.valid {
- if oo.onuSwImageIndications.activeEntityEntry.entityID == aImageID {
- if oo.onuSwImageIndications.activeEntityEntry.isCommitted == swIsUncommitted {
+ if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+ if oo.onuSwImageIndications.ActiveEntityEntry.EntityID == aImageID {
+ if oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted == cmn.SwIsUncommitted {
oo.mutexOnuSwImageIndications.RUnlock()
return true
}
@@ -1032,10 +1035,10 @@
// swap out tokens with specific data
mibTmpString, _ := kvstore.ToString(Value.Value)
- oo.mutexPersOnuConfig.RLock()
- mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", oo.sOnuPersistentData.PersSerialNumber, -1)
- mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", oo.sOnuPersistentData.PersMacAddress, -1)
- oo.mutexPersOnuConfig.RUnlock()
+ oo.MutexPersOnuConfig.RLock()
+ mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", oo.SOnuPersistentData.PersSerialNumber, -1)
+ mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", oo.SOnuPersistentData.PersMacAddress, -1)
+ oo.MutexPersOnuConfig.RUnlock()
mibTmpBytes := []byte(mibTmpString)
logger.Debugf(ctx, "MibSync FSM - Mib template tokens swapped out: %s", mibTmpBytes)
@@ -1085,16 +1088,16 @@
//CancelProcessing terminates potentially running reconciling processes and stops the FSM
func (oo *OnuDeviceEntry) CancelProcessing(ctx context.Context) {
- if oo.baseDeviceHandler.isReconcilingFlows() {
- oo.baseDeviceHandler.chReconcilingFlowsFinished <- false
+ if oo.IsReconcilingFlows() {
+ oo.chReconcilingFlowsFinished <- false
}
- if oo.baseDeviceHandler.isReconciling() {
- oo.baseDeviceHandler.stopReconciling(ctx, false)
+ if oo.baseDeviceHandler.IsReconciling() {
+ oo.baseDeviceHandler.StopReconciling(ctx, false)
}
//the MibSync FSM might be active all the ONU-active time,
// hence it must be stopped unconditionally
- pMibUlFsm := oo.pMibUploadFsm.pFsm
+ pMibUlFsm := oo.PMibUploadFsm.PFsm
if pMibUlFsm != nil {
- _ = pMibUlFsm.Event(ulEvStop)
+ _ = pMibUlFsm.Event(UlEvStop)
}
}
diff --git a/internal/pkg/mib/onu_device_entry.go b/internal/pkg/mib/onu_device_entry.go
new file mode 100755
index 0000000..ebf8de8
--- /dev/null
+++ b/internal/pkg/mib/onu_device_entry.go
@@ -0,0 +1,992 @@
+/*
+ * 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 mib provides the utilities for managing the onu mib
+package mib
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "sync"
+ "time"
+
+ "github.com/looplab/fsm"
+ "github.com/opencord/omci-lib-go"
+ me "github.com/opencord/omci-lib-go/generated"
+ "github.com/opencord/voltha-lib-go/v7/pkg/db"
+ "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
+ vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ devdb "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/swupg"
+)
+
+// events of MibUpload FSM
+const (
+ UlEvStart = "UlEvStart"
+ UlEvResetMib = "UlEvResetMib"
+ UlEvGetVendorAndSerial = "UlEvGetVendorAndSerial"
+ UlEvGetEquipmentID = "UlEvGetEquipmentId"
+ UlEvGetFirstSwVersion = "UlEvGetFirstSwVersion"
+ UlEvGetSecondSwVersion = "UlEvGetSecondSwVersion"
+ UlEvGetMacAddress = "UlEvGetMacAddress"
+ UlEvGetMibTemplate = "UlEvGetMibTemplate"
+ UlEvUploadMib = "UlEvUploadMib"
+ UlEvExamineMds = "UlEvExamineMds"
+ UlEvSuccess = "UlEvSuccess"
+ UlEvMismatch = "UlEvMismatch"
+ UlEvAuditMib = "UlEvAuditMib"
+ UlEvForceResync = "UlEvForceResync"
+ UlEvDiffsFound = "UlEvDiffsFound"
+ UlEvTimeout = "UlEvTimeout"
+ UlEvStop = "UlEvStop"
+)
+
+// states of MibUpload FSM
+const (
+ UlStDisabled = "UlStDisabled"
+ UlStStarting = "UlStStarting"
+ UlStResettingMib = "UlStResettingMib"
+ UlStGettingVendorAndSerial = "UlStGettingVendorAndSerial"
+ UlStGettingEquipmentID = "UlStGettingEquipmentID"
+ UlStGettingFirstSwVersion = "UlStGettingFirstSwVersion"
+ UlStGettingSecondSwVersion = "UlStGettingSecondSwVersion"
+ UlStGettingMacAddress = "UlStGettingMacAddress"
+ UlStGettingMibTemplate = "UlStGettingMibTemplate"
+ UlStUploading = "UlStUploading"
+ UlStUploadDone = "UlStUploadDone"
+ UlStInSync = "UlStInSync"
+ UlStExaminingMds = "UlStExaminingMds"
+ UlStResynchronizing = "UlStResynchronizing"
+ UlStExaminingMdsSuccess = "UlStExaminingMdsSuccess"
+ UlStAuditing = "UlStAuditing"
+ UlStReAuditing = "UlStReAuditing"
+ UlStOutOfSync = "UlStOutOfSync"
+)
+
+// CMibUlFsmIdleState - TODO: add comment
+const CMibUlFsmIdleState = UlStInSync
+
+// events of MibDownload FSM
+const (
+ DlEvStart = "DlEvStart"
+ DlEvCreateGal = "DlEvCreateGal"
+ DlEvRxGalResp = "DlEvRxGalResp"
+ DlEvRxOnu2gResp = "DlEvRxOnu2gResp"
+ DlEvRxBridgeResp = "DlEvRxBridgeResp"
+ DlEvTimeoutSimple = "DlEvTimeoutSimple"
+ DlEvTimeoutBridge = "DlEvTimeoutBridge"
+ DlEvReset = "DlEvReset"
+ DlEvRestart = "DlEvRestart"
+)
+
+// states of MibDownload FSM
+const (
+ DlStDisabled = "DlStDisabled"
+ DlStStarting = "DlStStarting"
+ DlStCreatingGal = "DlStCreatingGal"
+ DlStSettingOnu2g = "DlStSettingOnu2g"
+ DlStBridgeInit = "DlStBridgeInit"
+ DlStDownloaded = "DlStDownloaded"
+ DlStResetting = "DlStResetting"
+)
+
+// CMibDlFsmIdleState - TODO: add comment
+const CMibDlFsmIdleState = DlStDisabled
+
+const (
+ // NOTE that this hardcoded to service/voltha as the MIB template is shared across stacks
+ cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates"
+ cSuffixMibTemplateKvStore = "%s/%s/%s"
+ cBasePathOnuKVStore = "%s/openonu"
+)
+
+const cEmptyMacAddrString = "000000000000"
+const cEmptySerialNumberString = "0000000000000000"
+
+type uniPersConfig struct {
+ PersUniID uint8 `json:"uni_id"`
+ PersTpPathMap map[uint8]string `json:"PersTpPathMap"` // tp-id to tp-path map
+ PersFlowParams []cmn.UniVlanFlowParams `json:"flow_params"` //as defined in omci_ani_config.go
+}
+
+type onuPersistentData struct {
+ PersOnuID uint32 `json:"onu_id"`
+ PersIntfID uint32 `json:"intf_id"`
+ PersSerialNumber string `json:"serial_number"`
+ PersMacAddress string `json:"mac_address"`
+ PersVendorID string `json:"vendor_id"`
+ PersEquipmentID string `json:"equipment_id"`
+ PersActiveSwVersion string `json:"active_sw_version"`
+ PersAdminState string `json:"admin_state"`
+ PersOperState string `json:"oper_state"`
+ PersUniUnlockDone bool `json:"uni_unlock_done"`
+ PersUniDisableDone bool `json:"uni_disable_done"`
+ PersMibAuditInterval time.Duration `json:"mib_audit_interval"`
+ PersMibLastDbSync uint32 `json:"mib_last_db_sync"`
+ PersMibDataSyncAdpt uint8 `json:"mib_data_sync_adpt"`
+ PersUniConfig []uniPersConfig `json:"uni_config"`
+ PersAlarmAuditInterval time.Duration `json:"alarm_audit_interval"`
+ PersTcontMap map[uint16]uint16 `json:"tcont_map"` //alloc-id to me-instance-id map
+}
+
+// OnuDeviceEntry - ONU device info and FSM events.
+type OnuDeviceEntry struct {
+ deviceID string
+ baseDeviceHandler cmn.IdeviceHandler
+ pOpenOnuAc cmn.IopenONUAC
+ pOnuTP cmn.IonuUniTechProf
+ coreClient *vgrpc.Client
+ PDevOmciCC *cmn.OmciCC
+ pOnuDB *devdb.OnuDeviceDB
+ mibTemplateKVStore *db.Backend
+ MutexPersOnuConfig sync.RWMutex
+ SOnuPersistentData onuPersistentData
+ reconcilingFlows bool
+ mutexReconcilingFlowsFlag sync.RWMutex
+ chReconcilingFlowsFinished chan bool //channel to indicate that reconciling of flows has been finished
+ mibTemplatePath string
+ mutexOnuKVStore sync.RWMutex
+ onuKVStore *db.Backend
+ onuKVStorePath string
+ mutexOnuKVStoreProcResult sync.RWMutex
+ onuKVStoreProcResult error //error indication of processing
+ chOnuKvProcessingStep chan uint8
+ mutexOnuSwImageIndications sync.RWMutex
+ onuSwImageIndications cmn.SswImageIndications
+ MutexOnuImageStatus sync.RWMutex
+ POnuImageStatus *swupg.OnuImageStatus
+ //lockDeviceEntries sync.RWMutex
+ mibDbClass func(context.Context) error
+ supportedFsms cmn.OmciDeviceFsms
+ devState cmn.OnuDeviceEvent
+ // Audit and MDS
+ mibAuditInterval time.Duration
+ alarmAuditInterval time.Duration
+ // TODO: periodical mib resync will be implemented with story VOL-3792
+ //mibNextDbResync uint32
+
+ // for mibUpload
+ PMibUploadFsm *cmn.AdapterFsm //could be handled dynamically and more general as pcmn.AdapterFsm - perhaps later
+ mutexLastTxParamStruct sync.RWMutex
+ lastTxParamStruct sLastTxMeParameter
+ // for mibDownload
+ PMibDownloadFsm *cmn.AdapterFsm //could be handled dynamically and more general as pcmn.AdapterFsm - perhaps later
+ //remark: general usage of pAdapterFsm would require generalization of CommChan usage and internal event setting
+ // within the FSM event procedures
+ mutexPLastTxMeInstance sync.RWMutex
+ pLastTxMeInstance *me.ManagedEntity
+ omciMessageReceived chan bool //seperate channel needed by DownloadFsm
+ omciRebootMessageReceivedChannel chan cmn.Message // channel needed by reboot request
+
+ mutexTcontMap sync.RWMutex
+}
+
+//NewOnuDeviceEntry returns a new instance of a OnuDeviceEntry
+//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
+func NewOnuDeviceEntry(ctx context.Context, cc *vgrpc.Client, dh cmn.IdeviceHandler,
+ openonu cmn.IopenONUAC) *OnuDeviceEntry {
+ var onuDeviceEntry OnuDeviceEntry
+ onuDeviceEntry.deviceID = dh.GetDeviceID()
+ logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ onuDeviceEntry.baseDeviceHandler = dh
+ onuDeviceEntry.pOpenOnuAc = openonu
+ onuDeviceEntry.coreClient = cc
+ onuDeviceEntry.devState = cmn.DeviceStatusInit
+ onuDeviceEntry.SOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
+ onuDeviceEntry.SOnuPersistentData.PersTcontMap = make(map[uint16]uint16)
+ onuDeviceEntry.chReconcilingFlowsFinished = make(chan bool)
+ onuDeviceEntry.reconcilingFlows = false
+ onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
+ onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan cmn.Message, 2048)
+ //openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
+ //OMCI related databases are on a per-agent basis. State machines and tasks
+ //are per ONU Vendor
+ //
+ // MIB Synchronization Database - possible overloading from arguments
+ supportedFsms := onuDeviceEntry.pOpenOnuAc.GetSupportedFsms()
+ if supportedFsms != nil {
+ onuDeviceEntry.supportedFsms = *supportedFsms
+ } else {
+ // This branch is currently not used and is for potential future usage of alternative MIB Sync FSMs only!
+ //var mibSyncFsm = NewMibSynchronizer()
+ // use some internal defaults, if not defined from outside
+ onuDeviceEntry.supportedFsms = cmn.OmciDeviceFsms{
+ "mib-synchronizer": {
+ //mibSyncFsm, // Implements the MIB synchronization state machine
+ DatabaseClass: onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
+ //true, // Advertise events on OpenOMCI event bus
+ AuditInterval: dh.GetAlarmAuditInterval(), // Time to wait between MIB audits. 0 to disable audits.
+ // map[string]func() error{
+ // "mib-upload": onuDeviceEntry.MibUploadTask,
+ // "mib-template": onuDeviceEntry.MibTemplateTask,
+ // "get-mds": onuDeviceEntry.GetMdsTask,
+ // "mib-audit": onuDeviceEntry.GetMdsTask,
+ // "mib-resync": onuDeviceEntry.MibResyncTask,
+ // "mib-reconcile": onuDeviceEntry.MibReconcileTask,
+ // },
+ },
+ }
+ }
+ onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].DatabaseClass
+ logger.Debug(ctx, "access2mibDbClass")
+ go onuDeviceEntry.mibDbClass(ctx)
+ if !dh.IsReconciling() {
+ onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].AuditInterval
+ onuDeviceEntry.SOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
+ onuDeviceEntry.alarmAuditInterval = dh.GetAlarmAuditInterval()
+ onuDeviceEntry.SOnuPersistentData.PersAlarmAuditInterval = onuDeviceEntry.alarmAuditInterval
+ } else {
+ logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ // TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
+ // vendor- or deviceID-specific configurations via voltctl-commands
+ onuDeviceEntry.mibAuditInterval = onuDeviceEntry.SOnuPersistentData.PersMibAuditInterval
+ onuDeviceEntry.alarmAuditInterval = onuDeviceEntry.SOnuPersistentData.PersAlarmAuditInterval
+ }
+ logger.Debugw(ctx, "MibAuditInterval and AlarmAuditInterval is set to", log.Fields{"mib-audit-interval": onuDeviceEntry.mibAuditInterval,
+ "alarm-audit-interval": onuDeviceEntry.alarmAuditInterval})
+ // TODO: periodical mib resync will be implemented with story VOL-3792
+ //onuDeviceEntry.mibNextDbResync = 0
+
+ // Omci related Mib upload sync state machine
+ mibUploadChan := make(chan cmn.Message, 2048)
+ onuDeviceEntry.PMibUploadFsm = cmn.NewAdapterFsm("MibUpload", onuDeviceEntry.deviceID, mibUploadChan)
+ onuDeviceEntry.PMibUploadFsm.PFsm = fsm.NewFSM(
+ UlStDisabled,
+ fsm.Events{
+
+ {Name: UlEvStart, Src: []string{UlStDisabled}, Dst: UlStStarting},
+
+ {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: UlEvGetSecondSwVersion, Src: []string{UlStGettingFirstSwVersion}, Dst: UlStGettingSecondSwVersion},
+ {Name: UlEvGetMacAddress, Src: []string{UlStGettingSecondSwVersion}, Dst: UlStGettingMacAddress},
+ {Name: UlEvGetMibTemplate, Src: []string{UlStGettingMacAddress}, Dst: UlStGettingMibTemplate},
+
+ {Name: UlEvUploadMib, Src: []string{UlStGettingMibTemplate}, Dst: UlStUploading},
+ {Name: UlEvExamineMds, Src: []string{UlStStarting}, Dst: UlStExaminingMds},
+
+ {Name: UlEvSuccess, Src: []string{UlStGettingMibTemplate}, Dst: UlStUploadDone},
+ {Name: UlEvSuccess, Src: []string{UlStUploading}, Dst: UlStUploadDone},
+
+ {Name: UlEvSuccess, Src: []string{UlStUploadDone}, Dst: UlStInSync},
+ //{Name: UlEvSuccess, Src: []string{UlStExaminingMds}, Dst: UlStInSync},
+ {Name: UlEvSuccess, Src: []string{UlStExaminingMds}, Dst: UlStExaminingMdsSuccess},
+ // TODO: As long as mib-resynchronizing is not implemented, failed MDS-examination triggers
+ // mib-reset and new provisioning at this point
+ //{Name: UlEvMismatch, Src: []string{UlStExaminingMds}, Dst: UlStResynchronizing},
+ {Name: UlEvMismatch, Src: []string{UlStExaminingMds}, Dst: UlStResettingMib},
+
+ {Name: UlEvSuccess, Src: []string{UlStExaminingMdsSuccess}, Dst: UlStInSync},
+ {Name: UlEvMismatch, Src: []string{UlStExaminingMdsSuccess}, Dst: UlStResettingMib},
+
+ {Name: UlEvAuditMib, Src: []string{UlStInSync}, Dst: UlStAuditing},
+
+ {Name: UlEvSuccess, Src: []string{UlStOutOfSync}, Dst: UlStInSync},
+ {Name: UlEvAuditMib, Src: []string{UlStOutOfSync}, Dst: UlStAuditing},
+
+ {Name: UlEvSuccess, Src: []string{UlStAuditing}, Dst: UlStInSync},
+ {Name: UlEvMismatch, Src: []string{UlStAuditing}, Dst: UlStReAuditing},
+ {Name: UlEvForceResync, Src: []string{UlStAuditing}, Dst: UlStResynchronizing},
+
+ {Name: UlEvSuccess, Src: []string{UlStReAuditing}, Dst: UlStInSync},
+ {Name: UlEvMismatch, Src: []string{UlStReAuditing}, Dst: UlStResettingMib},
+
+ {Name: UlEvSuccess, Src: []string{UlStResynchronizing}, Dst: UlStInSync},
+ {Name: UlEvDiffsFound, Src: []string{UlStResynchronizing}, Dst: UlStOutOfSync},
+
+ {Name: UlEvTimeout, Src: []string{UlStResettingMib, UlStGettingVendorAndSerial, UlStGettingEquipmentID, UlStGettingFirstSwVersion,
+ UlStGettingSecondSwVersion, UlStGettingMacAddress, UlStGettingMibTemplate, UlStUploading, UlStResynchronizing, UlStExaminingMds,
+ UlStUploadDone, UlStInSync, UlStOutOfSync, UlStAuditing, UlStReAuditing}, Dst: UlStStarting},
+
+ {Name: UlEvStop, Src: []string{UlStStarting, UlStResettingMib, UlStGettingVendorAndSerial, UlStGettingEquipmentID, UlStGettingFirstSwVersion,
+ UlStGettingSecondSwVersion, UlStGettingMacAddress, UlStGettingMibTemplate, UlStUploading, UlStResynchronizing, UlStExaminingMds,
+ UlStUploadDone, UlStInSync, UlStOutOfSync, UlStAuditing, UlStReAuditing}, Dst: UlStDisabled},
+ },
+
+ fsm.Callbacks{
+ "enter_state": func(e *fsm.Event) { onuDeviceEntry.PMibUploadFsm.LogFsmStateChange(ctx, e) },
+ "enter_" + UlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
+ "enter_" + UlStResettingMib: func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
+ "enter_" + UlStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
+ "enter_" + UlStGettingEquipmentID: func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
+ "enter_" + UlStGettingFirstSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
+ "enter_" + UlStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
+ "enter_" + UlStGettingMacAddress: func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
+ "enter_" + UlStGettingMibTemplate: func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplateState(ctx, e) },
+ "enter_" + UlStUploading: func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
+ "enter_" + UlStUploadDone: func(e *fsm.Event) { onuDeviceEntry.enterUploadDoneState(ctx, e) },
+ "enter_" + UlStExaminingMds: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
+ "enter_" + UlStResynchronizing: func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
+ "enter_" + UlStExaminingMdsSuccess: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsSuccessState(ctx, e) },
+ "enter_" + UlStAuditing: func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
+ "enter_" + UlStReAuditing: func(e *fsm.Event) { onuDeviceEntry.enterReAuditingState(ctx, e) },
+ "enter_" + UlStOutOfSync: func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
+ "enter_" + UlStInSync: func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
+ },
+ )
+ // Omci related Mib download state machine
+ mibDownloadChan := make(chan cmn.Message, 2048)
+ onuDeviceEntry.PMibDownloadFsm = cmn.NewAdapterFsm("MibDownload", onuDeviceEntry.deviceID, mibDownloadChan)
+ onuDeviceEntry.PMibDownloadFsm.PFsm = fsm.NewFSM(
+ DlStDisabled,
+ fsm.Events{
+
+ {Name: DlEvStart, Src: []string{DlStDisabled}, Dst: DlStStarting},
+
+ {Name: DlEvCreateGal, Src: []string{DlStStarting}, Dst: DlStCreatingGal},
+ {Name: DlEvRxGalResp, Src: []string{DlStCreatingGal}, Dst: DlStSettingOnu2g},
+ {Name: DlEvRxOnu2gResp, Src: []string{DlStSettingOnu2g}, Dst: DlStBridgeInit},
+ // the bridge state is used for multi ME config for alle UNI related ports
+ // maybe such could be reflected in the state machine as well (port number parametrized)
+ // but that looks not straightforward here - so we keep it simple here for the beginning(?)
+ {Name: DlEvRxBridgeResp, Src: []string{DlStBridgeInit}, Dst: DlStDownloaded},
+
+ {Name: DlEvTimeoutSimple, Src: []string{DlStCreatingGal, DlStSettingOnu2g}, Dst: DlStStarting},
+ {Name: DlEvTimeoutBridge, Src: []string{DlStBridgeInit}, Dst: DlStStarting},
+
+ {Name: DlEvReset, Src: []string{DlStStarting, DlStCreatingGal, DlStSettingOnu2g,
+ DlStBridgeInit, DlStDownloaded}, Dst: DlStResetting},
+ // exceptional treatment for all states except DlStResetting
+ {Name: DlEvRestart, Src: []string{DlStStarting, DlStCreatingGal, DlStSettingOnu2g,
+ DlStBridgeInit, DlStDownloaded, DlStResetting}, Dst: DlStDisabled},
+ },
+
+ fsm.Callbacks{
+ "enter_state": func(e *fsm.Event) { onuDeviceEntry.PMibDownloadFsm.LogFsmStateChange(ctx, e) },
+ "enter_" + DlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
+ "enter_" + DlStCreatingGal: func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
+ "enter_" + DlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
+ "enter_" + DlStBridgeInit: func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
+ "enter_" + DlStDownloaded: func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
+ "enter_" + DlStResetting: func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
+ },
+ )
+ if onuDeviceEntry.PMibDownloadFsm == nil || onuDeviceEntry.PMibDownloadFsm.PFsm == nil {
+ logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ // TODO some specific error treatment - or waiting for crash ?
+ }
+
+ onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.SetBackend(ctx, cBasePathMibTemplateKvStore)
+ if onuDeviceEntry.mibTemplateKVStore == nil {
+ logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
+ log.Fields{"device-id": onuDeviceEntry.deviceID, "service": cBasePathMibTemplateKvStore})
+ }
+
+ onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
+ baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.GetBackendPathPrefix())
+ onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.SetBackend(ctx, baseKvStorePath)
+ if onuDeviceEntry.onuKVStore == nil {
+ logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
+ log.Fields{"device-id": onuDeviceEntry.deviceID, "service": baseKvStorePath})
+ }
+
+ // Alarm Synchronization Database
+
+ //self._alarm_db = None
+ //self._alarm_database_cls = support_classes['alarm-synchronizer']['database']
+ return &onuDeviceEntry
+}
+
+//Start starts (logs) the omci agent
+func (oo *OnuDeviceEntry) Start(ctx context.Context) error {
+ logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
+ if oo.PDevOmciCC == nil {
+ oo.PDevOmciCC = cmn.NewOmciCC(ctx, oo.deviceID, oo.baseDeviceHandler, oo, oo.baseDeviceHandler.GetOnuAlarmManager(), oo.coreClient)
+ if oo.PDevOmciCC == nil {
+ logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
+ return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
+ }
+ }
+ return nil
+}
+
+//Stop stops/resets the omciCC
+func (oo *OnuDeviceEntry) Stop(ctx context.Context, abResetOmciCC bool) error {
+ logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
+ if abResetOmciCC && (oo.PDevOmciCC != nil) {
+ _ = oo.PDevOmciCC.Stop(ctx)
+ }
+ //to allow for all event notifications again when re-using the device and omciCC
+ oo.devState = cmn.DeviceStatusInit
+ return nil
+}
+
+// Reboot - TODO: add comment
+func (oo *OnuDeviceEntry) Reboot(ctx context.Context) error {
+ logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
+ if oo.PDevOmciCC != nil {
+ if err := oo.PDevOmciCC.SendReboot(ctx, oo.baseDeviceHandler.GetOmciTimeout(), true, oo.omciRebootMessageReceivedChannel); err != nil {
+ logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
+ return err
+ }
+ }
+ return nil
+}
+
+// WaitForRebootResponse - TODO: add comment
+func (oo *OnuDeviceEntry) WaitForRebootResponse(ctx context.Context, responseChannel chan cmn.Message) error {
+ select {
+ case <-time.After(oo.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
+ logger.Warnw(ctx, "reboot timeout", log.Fields{"for device-id": oo.deviceID})
+ return fmt.Errorf("rebootTimeout")
+ case data := <-responseChannel:
+ switch data.Data.(cmn.OmciMessage).OmciMsg.MessageType {
+ case omci.RebootResponseType:
+ {
+ msgLayer := (*data.Data.(cmn.OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse)
+ if msgLayer == nil {
+ return fmt.Errorf("omci Msg layer could not be detected for RebootResponseType")
+ }
+ msgObj, msgOk := msgLayer.(*omci.RebootResponse)
+ if !msgOk {
+ return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
+ }
+ logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
+ if msgObj.Result != me.Success {
+ logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
+ // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
+ return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
+ msgObj.Result, oo.deviceID)
+ }
+ return nil
+ }
+ }
+ logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
+ return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
+ }
+}
+
+//Relay the InSync message via Handler to Rw core - Status update
+func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent cmn.OnuDeviceEvent) {
+ logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
+ // 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 ..
+ if devEvent == cmn.MibDatabaseSync {
+ if oo.devState < cmn.MibDatabaseSync { //devState has not been synced yet
+ oo.devState = cmn.MibDatabaseSync
+ go oo.baseDeviceHandler.DeviceProcStatusUpdate(ctx, devEvent)
+ //TODO!!! device control: next step: start MIB capability verification from here ?!!!
+ } else {
+ logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
+ }
+ } else if devEvent == cmn.MibDownloadDone {
+ if oo.devState < cmn.MibDownloadDone { //devState has not been synced yet
+ oo.devState = cmn.MibDownloadDone
+ go oo.baseDeviceHandler.DeviceProcStatusUpdate(ctx, devEvent)
+ } else {
+ logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
+ }
+ } else {
+ logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
+ }
+}
+
+// RestoreDataFromOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) RestoreDataFromOnuKvStore(ctx context.Context) error {
+ if oo.onuKVStore == nil {
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
+ }
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+ oo.SOnuPersistentData =
+ onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
+ oo.mutexOnuKVStore.RLock()
+ Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
+ oo.mutexOnuKVStore.RUnlock()
+ if err == nil {
+ if Value != nil {
+ logger.Debugw(ctx, "ONU-data read",
+ log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
+ tmpBytes, _ := kvstore.ToByte(Value.Value)
+
+ if err = json.Unmarshal(tmpBytes, &oo.SOnuPersistentData); err != nil {
+ logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
+ return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
+ }
+ logger.Debugw(ctx, "ONU-data", log.Fields{"SOnuPersistentData": oo.SOnuPersistentData,
+ "device-id": oo.deviceID})
+ } else {
+ logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
+ return fmt.Errorf("no-ONU-data-found")
+ }
+ } else {
+ logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
+ return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
+ }
+ return nil
+}
+
+// DeleteDataFromOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) DeleteDataFromOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
+ defer wg.Done()
+
+ if oo.onuKVStore == nil {
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: onuKVStore not set"))
+ return
+ }
+ var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
+ go oo.deletePersistentData(ctx, processingStep)
+ if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
+ //timeout or error detected
+ logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
+ oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: during kv-access"))
+ return
+ }
+}
+
+func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
+
+ logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
+
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+
+ oo.SOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector default entry
+ oo.SOnuPersistentData =
+ onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
+ logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
+ oo.mutexOnuKVStore.Lock()
+ err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
+ oo.mutexOnuKVStore.Unlock()
+ if err != nil {
+ logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+ oo.chOnuKvProcessingStep <- 0 //error indication
+ return
+ }
+ oo.chOnuKvProcessingStep <- aProcessingStep //done
+}
+
+// UpdateOnuKvStore - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
+ defer wg.Done()
+
+ if oo.onuKVStore == nil {
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: onuKVStore not set"))
+ return
+ }
+ var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
+ go oo.storeDataInOnuKvStore(ctx, processingStep)
+ if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
+ //timeout or error detected
+ logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
+ oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: during writing process"))
+ return
+ }
+}
+
+func (oo *OnuDeviceEntry) storeDataInOnuKvStore(ctx context.Context, aProcessingStep uint8) {
+
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+ //assign values which are not already present when NewOnuDeviceEntry() is called
+ onuIndication := oo.baseDeviceHandler.GetOnuIndication()
+ oo.SOnuPersistentData.PersOnuID = onuIndication.OnuId
+ oo.SOnuPersistentData.PersIntfID = onuIndication.IntfId
+ //TODO: verify usage of these values during restart UC
+ oo.SOnuPersistentData.PersAdminState = onuIndication.AdminState
+ oo.SOnuPersistentData.PersOperState = onuIndication.OperState
+
+ logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "SOnuPersistentData": oo.SOnuPersistentData})
+
+ Value, err := json.Marshal(oo.SOnuPersistentData)
+ if err != nil {
+ logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"SOnuPersistentData": oo.SOnuPersistentData,
+ "device-id": oo.deviceID, "err": err})
+ oo.chOnuKvProcessingStep <- 0 //error indication
+ return
+ }
+ oo.pOpenOnuAc.RLockMutexDeviceHandlersMap()
+ if _, exist := oo.pOpenOnuAc.GetDeviceHandler(oo.deviceID); !exist {
+ logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
+ oo.chOnuKvProcessingStep <- aProcessingStep
+ oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+ return
+ }
+ oo.baseDeviceHandler.RLockMutexDeletionInProgressFlag()
+ if oo.baseDeviceHandler.GetDeletionInProgress() {
+ logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
+ oo.chOnuKvProcessingStep <- aProcessingStep
+ oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+ oo.baseDeviceHandler.RUnlockMutexDeletionInProgressFlag()
+ return
+ }
+ oo.pOpenOnuAc.RUnlockMutexDeviceHandlersMap()
+ oo.baseDeviceHandler.RUnlockMutexDeletionInProgressFlag()
+
+ oo.mutexOnuKVStore.Lock()
+ err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
+ oo.mutexOnuKVStore.Unlock()
+ if err != nil {
+ logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+ oo.chOnuKvProcessingStep <- 0 //error indication
+ return
+ }
+ oo.chOnuKvProcessingStep <- aProcessingStep //done
+}
+
+// UpdateOnuUniTpPath - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
+ /* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
+ as also the complete sequence is ensured to 'run to completion' before some new request is accepted
+ no specific concurrency protection to SOnuPersistentData is required here
+ */
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+
+ for k, v := range oo.SOnuPersistentData.PersUniConfig {
+ if v.PersUniID == aUniID {
+ existingPath, ok := oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
+ logger.Debugw(ctx, "PersUniConfig-entry exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID,
+ "tpID": aTpID, "path": aPathString, "existingPath": existingPath, "ok": ok})
+ if !ok {
+ logger.Debugw(ctx, "tp-does-not-exist", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
+ }
+ if existingPath != aPathString {
+ if aPathString == "" {
+ //existing entry to be deleted
+ logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
+ } else {
+ //existing entry to be modified
+ logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ oo.SOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
+ }
+ return true
+ }
+ //entry already exists
+ if aPathString == "" {
+ //no active TechProfile
+ logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
+ "device-id": oo.deviceID, "uniID": aUniID})
+ } else {
+ //the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
+ //was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
+ // (as here the TechProfile has not been removed with the disable-device before the new enable-device)
+ logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
+ "device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ //no deviceReason update (DeviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
+ // (during which the flows are removed/re-assigned but the techProf is left active)
+ //and as the TechProfile is regarded as active we have to verify, if some flow configuration still waits on it
+ // (should not be the case, but should not harm or be more robust ...)
+ // and to be sure, that for some reason the corresponding TpDelete was lost somewhere in history
+ // we also reset a possibly outstanding delete request - repeated TpConfig is regarded as valid for waiting flow config
+ if oo.pOnuTP != nil {
+ oo.pOnuTP.SetProfileToDelete(aUniID, aTpID, false)
+ }
+ go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID, aTpID)
+ }
+ return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
+ }
+ }
+ //no entry exists for uniId
+
+ if aPathString == "" {
+ //delete request in non-existing state , accept as no change
+ logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
+ return false
+ }
+ //new entry to be created
+ logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ perSubTpPathMap := make(map[uint8]string)
+ perSubTpPathMap[aTpID] = aPathString
+ oo.SOnuPersistentData.PersUniConfig =
+ append(oo.SOnuPersistentData.PersUniConfig, uniPersConfig{PersUniID: aUniID, PersTpPathMap: perSubTpPathMap, PersFlowParams: make([]cmn.UniVlanFlowParams, 0)})
+ return true
+}
+
+// UpdateOnuUniFlowConfig - TODO: add comment
+func (oo *OnuDeviceEntry) UpdateOnuUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]cmn.UniVlanFlowParams) {
+
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+
+ for k, v := range oo.SOnuPersistentData.PersUniConfig {
+ if v.PersUniID == aUniID {
+ oo.SOnuPersistentData.PersUniConfig[k].PersFlowParams = make([]cmn.UniVlanFlowParams, len(*aUniVlanFlowParams))
+ copy(oo.SOnuPersistentData.PersUniConfig[k].PersFlowParams, *aUniVlanFlowParams)
+ return
+ }
+ }
+ //flow update was faster than tp-config - create PersUniConfig-entry
+ //TODO!!: following activity to 'add' some new uni entry might not be quite correct if this function is called to clear the data
+ // (e.g after flow removal from RemoveUniFlowParams()).
+ // This has the effect of misleading indication that there is still some active UNI entry, even though there might be only some nil flow entry
+ // The effect of this flaw is that at TechProfile removal there is an additional attempt to remove the entry even though no techProfile exists anymore
+ // The code is not changed here because of the current release lane, changes might have unexpected secondary effects, perhaps later with more elaborate tests
+ tmpConfig := uniPersConfig{PersUniID: aUniID, PersTpPathMap: make(map[uint8]string), PersFlowParams: make([]cmn.UniVlanFlowParams, len(*aUniVlanFlowParams))}
+ copy(tmpConfig.PersFlowParams, *aUniVlanFlowParams)
+ oo.SOnuPersistentData.PersUniConfig = append(oo.SOnuPersistentData.PersUniConfig, tmpConfig)
+}
+
+func (oo *OnuDeviceEntry) waitForTimeoutOrCompletion(
+ ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
+ select {
+ case <-ctx.Done():
+ logger.Warnw(ctx, "processing not completed in-time!",
+ log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
+ return false
+ case rxStep := <-aChOnuProcessingStep:
+ if rxStep == aProcessingStep {
+ return true
+ }
+ //all other values are not accepted - including 0 for error indication
+ logger.Warnw(ctx, "Invalid processing step received: abort!",
+ log.Fields{"device-id": oo.deviceID,
+ "wantedStep": aProcessingStep, "haveStep": rxStep})
+ return false
+ }
+}
+
+// ResetKvProcessingErrorIndication - TODO: add comment
+func (oo *OnuDeviceEntry) ResetKvProcessingErrorIndication() {
+ oo.mutexOnuKVStoreProcResult.Lock()
+ oo.onuKVStoreProcResult = nil
+ oo.mutexOnuKVStoreProcResult.Unlock()
+}
+
+// GetKvProcessingErrorIndication - TODO: add comment
+func (oo *OnuDeviceEntry) GetKvProcessingErrorIndication() error {
+ oo.mutexOnuKVStoreProcResult.RLock()
+ value := oo.onuKVStoreProcResult
+ oo.mutexOnuKVStoreProcResult.RUnlock()
+ return value
+}
+
+func (oo *OnuDeviceEntry) setKvProcessingErrorIndication(value error) {
+ oo.mutexOnuKVStoreProcResult.Lock()
+ oo.onuKVStoreProcResult = value
+ oo.mutexOnuKVStoreProcResult.Unlock()
+}
+
+// IncrementMibDataSync - TODO: add comment
+func (oo *OnuDeviceEntry) IncrementMibDataSync(ctx context.Context) {
+ oo.MutexPersOnuConfig.Lock()
+ defer oo.MutexPersOnuConfig.Unlock()
+ if oo.SOnuPersistentData.PersMibDataSyncAdpt < 255 {
+ oo.SOnuPersistentData.PersMibDataSyncAdpt++
+ } else {
+ // per G.984 and G.988 overflow starts over at 1 given 0 is reserved for reset
+ oo.SOnuPersistentData.PersMibDataSyncAdpt = 1
+ }
+ logger.Debugf(ctx, "mibDataSync updated - mds: %d - device-id: %s", oo.SOnuPersistentData.PersMibDataSyncAdpt, oo.deviceID)
+}
+
+// ModifySwImageInactiveVersion - updates the inactive SW image version stored
+func (oo *OnuDeviceEntry) ModifySwImageInactiveVersion(ctx context.Context, aImageVersion string) {
+ oo.mutexOnuSwImageIndications.Lock()
+ defer oo.mutexOnuSwImageIndications.Unlock()
+ logger.Debugw(ctx, "software-image set inactive version", log.Fields{
+ "device-id": oo.deviceID, "version": aImageVersion})
+ oo.onuSwImageIndications.InActiveEntityEntry.Version = aImageVersion
+ //inactive SW version is not part of persistency data (yet) - no need to update that
+}
+
+// ModifySwImageActiveCommit - updates the active SW commit flag stored
+func (oo *OnuDeviceEntry) ModifySwImageActiveCommit(ctx context.Context, aCommitted uint8) {
+ oo.mutexOnuSwImageIndications.Lock()
+ defer oo.mutexOnuSwImageIndications.Unlock()
+ logger.Debugw(ctx, "software-image set active entity commit flag", log.Fields{
+ "device-id": oo.deviceID, "committed": aCommitted})
+ oo.onuSwImageIndications.ActiveEntityEntry.IsCommitted = aCommitted
+ //commit flag is not part of persistency data (yet) - no need to update that
+}
+
+// GetActiveImageVersion - returns the active SW image version stored
+func (oo *OnuDeviceEntry) GetActiveImageVersion(ctx context.Context) string {
+ oo.mutexOnuSwImageIndications.RLock()
+ if oo.onuSwImageIndications.ActiveEntityEntry.Valid {
+ value := oo.onuSwImageIndications.ActiveEntityEntry.Version
+ oo.mutexOnuSwImageIndications.RUnlock()
+ return value
+ }
+ oo.mutexOnuSwImageIndications.RUnlock()
+ logger.Debugw(ctx, "Active Image is not valid", log.Fields{"device-id": oo.deviceID})
+ return ""
+}
+
+// GetInactiveImageVersion - TODO: add comment
+func (oo *OnuDeviceEntry) GetInactiveImageVersion(ctx context.Context) string {
+ oo.mutexOnuSwImageIndications.RLock()
+ if oo.onuSwImageIndications.InActiveEntityEntry.Valid {
+ value := oo.onuSwImageIndications.InActiveEntityEntry.Version
+ oo.mutexOnuSwImageIndications.RUnlock()
+ return value
+ }
+ oo.mutexOnuSwImageIndications.RUnlock()
+ logger.Debugw(ctx, "Inactive Image is not valid", log.Fields{"device-id": oo.deviceID})
+ return ""
+}
+
+func (oo *OnuDeviceEntry) buildMibTemplatePath() string {
+ oo.MutexPersOnuConfig.RLock()
+ defer oo.MutexPersOnuConfig.RUnlock()
+ return fmt.Sprintf(cSuffixMibTemplateKvStore, oo.SOnuPersistentData.PersVendorID, oo.SOnuPersistentData.PersEquipmentID, oo.SOnuPersistentData.PersActiveSwVersion)
+}
+
+// AllocateFreeTcont - TODO: add comment
+func (oo *OnuDeviceEntry) AllocateFreeTcont(ctx context.Context, allocID uint16) (uint16, bool, error) {
+ logger.Debugw(ctx, "allocate-free-tcont", log.Fields{"device-id": oo.deviceID, "allocID": allocID,
+ "allocated-instances": oo.SOnuPersistentData.PersTcontMap})
+
+ oo.mutexTcontMap.Lock()
+ defer oo.mutexTcontMap.Unlock()
+ if entityID, ok := oo.SOnuPersistentData.PersTcontMap[allocID]; ok {
+ //tcont already allocated before, return the used instance-id
+ return entityID, true, nil
+ }
+ //First allocation of tcont. Find a free instance
+ if tcontInstKeys := oo.pOnuDB.GetSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
+ logger.Debugw(ctx, "allocate-free-tcont-db-keys", log.Fields{"device-id": oo.deviceID, "keys": tcontInstKeys})
+ for _, instID := range tcontInstKeys {
+ instExist := false
+ //If this instance exist in map, it means it is not empty. It is allocated before
+ for _, v := range oo.SOnuPersistentData.PersTcontMap {
+ if v == instID {
+ instExist = true
+ break
+ }
+ }
+ if !instExist {
+ oo.SOnuPersistentData.PersTcontMap[allocID] = instID
+ return instID, false, nil
+ }
+ }
+ }
+ return 0, false, fmt.Errorf(fmt.Sprintf("no-free-tcont-left-for-device-%s", oo.deviceID))
+
+}
+
+// FreeTcont - TODO: add comment
+func (oo *OnuDeviceEntry) FreeTcont(ctx context.Context, allocID uint16) {
+ logger.Debugw(ctx, "free-tcont", log.Fields{"device-id": oo.deviceID, "alloc": allocID})
+ oo.mutexTcontMap.Lock()
+ defer oo.mutexTcontMap.Unlock()
+ delete(oo.SOnuPersistentData.PersTcontMap, allocID)
+}
+
+// GetDevOmciCC - TODO: add comment
+func (oo *OnuDeviceEntry) GetDevOmciCC() *cmn.OmciCC {
+ return oo.PDevOmciCC
+}
+
+// GetOnuDB - TODO: add comment
+func (oo *OnuDeviceEntry) GetOnuDB() *devdb.OnuDeviceDB {
+ return oo.pOnuDB
+}
+
+// GetPersSerialNumber - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersSerialNumber() string {
+ value := oo.SOnuPersistentData.PersSerialNumber
+ return value
+}
+
+// GetPersVendorID - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersVendorID() string {
+ value := oo.SOnuPersistentData.PersVendorID
+ return value
+}
+
+// GetPersEquipmentID - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersEquipmentID() string {
+ value := oo.SOnuPersistentData.PersEquipmentID
+ return value
+}
+
+// GetMibUploadFsmCommChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetMibUploadFsmCommChan() chan cmn.Message {
+ return oo.PMibUploadFsm.CommChan
+}
+
+// GetMibDownloadFsmCommChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetMibDownloadFsmCommChan() chan cmn.Message {
+ return oo.PMibDownloadFsm.CommChan
+}
+
+// GetOmciRebootMsgRevChan - TODO: add comment
+func (oo *OnuDeviceEntry) GetOmciRebootMsgRevChan() chan cmn.Message {
+ return oo.omciRebootMessageReceivedChannel
+}
+
+// LockMutexOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) LockMutexOnuSwImageIndications() {
+ oo.mutexOnuSwImageIndications.Lock()
+}
+
+// UnlockMutexOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) UnlockMutexOnuSwImageIndications() {
+ oo.mutexOnuSwImageIndications.Unlock()
+}
+
+// GetOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) GetOnuSwImageIndications() cmn.SswImageIndications {
+ return oo.onuSwImageIndications
+}
+
+// SetOnuSwImageIndications - TODO: add comment
+func (oo *OnuDeviceEntry) SetOnuSwImageIndications(value cmn.SswImageIndications) {
+ oo.onuSwImageIndications = value
+}
+
+// LockMutexPersOnuConfig - TODO: add comment
+func (oo *OnuDeviceEntry) LockMutexPersOnuConfig() {
+ oo.MutexPersOnuConfig.Lock()
+}
+
+// UnlockMutexPersOnuConfig - TODO: add comment
+func (oo *OnuDeviceEntry) UnlockMutexPersOnuConfig() {
+ oo.MutexPersOnuConfig.Unlock()
+}
+
+// GetPersActiveSwVersion - TODO: add comment
+func (oo *OnuDeviceEntry) GetPersActiveSwVersion() string {
+ return oo.SOnuPersistentData.PersActiveSwVersion
+}
+
+// SetPersActiveSwVersion - TODO: add comment
+func (oo *OnuDeviceEntry) SetPersActiveSwVersion(value string) {
+ oo.SOnuPersistentData.PersActiveSwVersion = value
+}
+
+// SetReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) SetReconcilingFlows(value bool) {
+ oo.mutexReconcilingFlowsFlag.Lock()
+ oo.reconcilingFlows = value
+ oo.mutexReconcilingFlowsFlag.Unlock()
+}
+
+// SetChReconcilingFlowsFinished - TODO: add comment
+func (oo *OnuDeviceEntry) SetChReconcilingFlowsFinished(value bool) {
+ oo.chReconcilingFlowsFinished <- value
+}
+
+// IsReconcilingFlows - TODO: add comment
+func (oo *OnuDeviceEntry) IsReconcilingFlows() bool {
+ oo.mutexReconcilingFlowsFlag.RLock()
+ value := oo.reconcilingFlows
+ oo.mutexReconcilingFlowsFlag.RUnlock()
+ return value
+}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/omcitst/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/omcitst/common.go
index b0b10e3..7ec4687
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/omcitst/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "omcitst"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/omci_self_test_handler.go b/internal/pkg/omcitst/omci_self_test_handler.go
old mode 100644
new mode 100755
similarity index 78%
rename from internal/pkg/onuadaptercore/omci_self_test_handler.go
rename to internal/pkg/omcitst/omci_self_test_handler.go
index 13b6ec3..5809228
--- a/internal/pkg/onuadaptercore/omci_self_test_handler.go
+++ b/internal/pkg/omcitst/omci_self_test_handler.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
import (
"context"
@@ -26,7 +26,9 @@
"github.com/looplab/fsm"
"github.com/opencord/omci-lib-go"
"github.com/opencord/omci-lib-go/generated"
+ me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/extension"
)
@@ -52,60 +54,67 @@
// We initiate an fsmCb per Self Test Request
type fsmCb struct {
- fsm *AdapterFsm
+ fsm *cmn.AdapterFsm
reqMsg extension.SingleGetValueRequest
respChan chan extension.SingleGetValueResponse
stopOmciChan chan bool
}
-type selfTestControlBlock struct {
- pDeviceHandler *deviceHandler
+// SelfTestControlBlock - TODO: add comment
+type SelfTestControlBlock struct {
deviceID string
+ pDeviceHandler cmn.IdeviceHandler
+ pDevEntry cmn.IonuDeviceEntry
selfTestFsmMap map[generated.ClassID]*fsmCb // The fsmCb is indexed by ME Class ID of the Test Action procedure
selfTestFsmLock sync.RWMutex
selfTestHandlerLock sync.RWMutex
selfTestHandlerActive bool
- stopSelfTestModule chan bool
+ StopSelfTestModule chan bool
}
-// newSelfTestMsgHandlerCb creates the selfTestControlBlock
+// NewSelfTestMsgHandlerCb creates the SelfTestControlBlock
// Self Test Handler module supports sending SelfTestRequest and handling of SelfTestResponse/SelfTestResults
// An ephemeral Self Test FSM is initiated for every Self Test request and multiple Self Tests on different
// MEs (that support it) can be handled in parallel.
// At the time of creating this module, only ANI-G self-test is supported.
-func newSelfTestMsgHandlerCb(ctx context.Context, dh *deviceHandler) *selfTestControlBlock {
- selfTestCb := selfTestControlBlock{pDeviceHandler: dh}
+func NewSelfTestMsgHandlerCb(ctx context.Context, dh cmn.IdeviceHandler, devEntry cmn.IonuDeviceEntry) *SelfTestControlBlock {
+ selfTestCb := SelfTestControlBlock{
+ deviceID: dh.GetDeviceID(),
+ pDeviceHandler: dh,
+ pDevEntry: devEntry,
+ }
selfTestCb.selfTestFsmMap = make(map[generated.ClassID]*fsmCb)
- selfTestCb.deviceID = selfTestCb.pDeviceHandler.deviceID
- selfTestCb.stopSelfTestModule = make(chan bool)
+ selfTestCb.StopSelfTestModule = make(chan bool)
go selfTestCb.waitForStopSelfTestModuleSignal(ctx)
return &selfTestCb
}
-func (selfTestCb *selfTestControlBlock) initiateNewSelfTestFsm(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, classID generated.ClassID, respChan chan extension.SingleGetValueResponse) error {
- aFsm := NewAdapterFsm("selfTestFsm", selfTestCb.deviceID, commChan)
+func (selfTestCb *SelfTestControlBlock) initiateNewSelfTestFsm(ctx context.Context, reqMsg extension.SingleGetValueRequest,
+ CommChan chan cmn.Message, classID generated.ClassID, respChan chan extension.SingleGetValueResponse) error {
+ aFsm := cmn.NewAdapterFsm("selfTestFsm", selfTestCb.deviceID, CommChan)
if aFsm == nil {
- logger.Errorw(ctx, "selfTestFsm AdapterFsm could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "selfTestFsm cmn.AdapterFsm could not be instantiated!!", log.Fields{
"device-id": selfTestCb.deviceID})
return fmt.Errorf("nil-adapter-fsm")
}
// Self Test FSM related state machine
- aFsm.pFsm = fsm.NewFSM(
+ aFsm.PFsm = fsm.NewFSM(
selfTestStNull,
fsm.Events{
{Name: selfTestEventTestRequest, Src: []string{selfTestStNull}, Dst: selfTestStHandleSelfTestReq},
{Name: selfTestEventTestResponseSuccess, Src: []string{selfTestStHandleSelfTestReq}, Dst: selfTestStHandleSelfTestResp},
{Name: selfTestEventTestResultSuccess, Src: []string{selfTestStHandleSelfTestResp}, Dst: selfTestStNull},
- {Name: selfTestEventAbort, Src: []string{selfTestStHandleSelfTestReq, selfTestStHandleSelfTestReq, selfTestStHandleTestResult, selfTestStNull}, Dst: selfTestStNull},
+ {Name: selfTestEventAbort, Src: []string{selfTestStHandleSelfTestReq, selfTestStHandleSelfTestReq, selfTestStHandleTestResult,
+ selfTestStNull}, Dst: selfTestStNull},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { aFsm.logFsmStateChange(ctx, e) },
+ "enter_state": func(e *fsm.Event) { aFsm.LogFsmStateChange(ctx, e) },
"enter_" + selfTestStHandleSelfTestReq: func(e *fsm.Event) { selfTestCb.selfTestFsmHandleSelfTestRequest(ctx, e) },
"enter_" + selfTestStHandleSelfTestResp: func(e *fsm.Event) { selfTestCb.selfTestFsmHandleSelfTestResponse(ctx, e) },
},
@@ -122,7 +131,7 @@
///// FSM Handlers
-func (selfTestCb *selfTestControlBlock) selfTestFsmHandleSelfTestRequest(ctx context.Context, e *fsm.Event) {
+func (selfTestCb *SelfTestControlBlock) selfTestFsmHandleSelfTestRequest(ctx context.Context, e *fsm.Event) {
classID := e.Args[0].(generated.ClassID)
selfTestCb.selfTestFsmLock.RLock()
pFsmCb, ok := selfTestCb.selfTestFsmMap[classID]
@@ -131,10 +140,12 @@
// This case is impossible. Would be curious to see if this happens
logger.Fatalw(ctx, "class-id-not-found", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
}
- instKeys := selfTestCb.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, classID)
+ instKeys := selfTestCb.pDevEntry.GetOnuDB().GetSortedInstKeys(ctx, classID)
- // TODO: Choosing the first index from the instance keys. For ANI-G, this is fine as there is only one ANI-G instance. How do we handle and report self test for multiple instances?
- if err := selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendSelfTestReq(ctx, classID, instKeys[0], selfTestCb.pDeviceHandler.pOpenOnuAc.omciTimeout, false, pFsmCb.fsm.commChan); err != nil {
+ // TODO: Choosing the first index from the instance keys. For ANI-G, this is fine as there is only one ANI-G instance.
+ // How do we handle and report self test for multiple instances?
+ if err := selfTestCb.pDevEntry.GetDevOmciCC().SendSelfTestReq(ctx, classID, instKeys[0], selfTestCb.pDeviceHandler.GetOmciTimeout(),
+ false, pFsmCb.fsm.CommChan); err != nil {
logger.Errorw(ctx, "error sending self test request", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
selfTestCb.submitFailureGetValueResponse(ctx, pFsmCb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
@@ -144,7 +155,7 @@
go selfTestCb.handleOmciResponse(ctx, classID)
}
-func (selfTestCb *selfTestControlBlock) selfTestFsmHandleSelfTestResponse(ctx context.Context, e *fsm.Event) {
+func (selfTestCb *SelfTestControlBlock) selfTestFsmHandleSelfTestResponse(ctx context.Context, e *fsm.Event) {
classID := e.Args[0].(generated.ClassID)
// Pass the test result processing to another routine
go selfTestCb.handleOmciResponse(ctx, classID)
@@ -153,27 +164,28 @@
///// Utility functions
-func (selfTestCb *selfTestControlBlock) getMeClassID(ctx context.Context, reqMsg extension.SingleGetValueRequest) (generated.ClassID, error) {
+func (selfTestCb *SelfTestControlBlock) getMeClassID(ctx context.Context, reqMsg extension.SingleGetValueRequest) (generated.ClassID, error) {
switch reqMsg.GetRequest().GetRequest().(type) {
case *extension.GetValueRequest_OnuOpticalInfo:
- return aniGClassID, nil
+ return me.AniGClassID, nil
default:
logger.Warnw(ctx, "unsupported me class id for self test", log.Fields{"device-id": selfTestCb.deviceID})
return 0, fmt.Errorf("unsupported me class id for self test %v", selfTestCb.deviceID)
}
}
-func (selfTestCb *selfTestControlBlock) triggerFsmEvent(pSelfTestFsm *AdapterFsm, event string, args ...generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) triggerFsmEvent(pSelfTestFsm *cmn.AdapterFsm, event string, args ...generated.ClassID) {
go func() {
if len(args) > 0 {
- _ = pSelfTestFsm.pFsm.Event(event, args[0])
+ _ = pSelfTestFsm.PFsm.Event(event, args[0])
} else {
- _ = pSelfTestFsm.pFsm.Event(event)
+ _ = pSelfTestFsm.PFsm.Event(event)
}
}()
}
-func (selfTestCb *selfTestControlBlock) submitFailureGetValueResponse(ctx context.Context, respChan chan extension.SingleGetValueResponse, errorCode extension.GetValueResponse_ErrorReason, statusCode extension.GetValueResponse_Status) {
+func (selfTestCb *SelfTestControlBlock) submitFailureGetValueResponse(ctx context.Context, respChan chan extension.SingleGetValueResponse,
+ errorCode extension.GetValueResponse_ErrorReason, statusCode extension.GetValueResponse_Status) {
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: statusCode,
@@ -185,7 +197,7 @@
logger.Infow(ctx, "OMCI test response failure - pushing failure response complete", log.Fields{"device-id": selfTestCb.deviceID})
}
-func (selfTestCb *selfTestControlBlock) handleOmciMessage(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": selfTestCb.deviceID, "msgType": msg.OmciMsg.MessageType, "msg": msg})
switch msg.OmciMsg.MessageType {
case omci.TestResponseType:
@@ -199,11 +211,11 @@
}
}
-func (selfTestCb *selfTestControlBlock) handleOmciTestResponse(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciTestResponse(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeTestResponse)
if msgLayer == nil {
logger.Errorw(ctx, "omci Msg layer nil self test response", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
- selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+ selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
return
@@ -211,7 +223,7 @@
msgObj, msgOk := msgLayer.(*omci.TestResponse)
if !msgOk {
logger.Errorw(ctx, "omci Msg layer could not be detected for self test response", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
- selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+ selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_INTERNAL_ERROR, extension.GetValueResponse_ERROR)
return
@@ -224,12 +236,12 @@
}
logger.Infow(ctx, "OMCI test response failure", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
- selfTestCb.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.ReleaseTid(ctx, msg.OmciMsg.TransactionID)
+ selfTestCb.pDevEntry.GetDevOmciCC().ReleaseTid(ctx, msg.OmciMsg.TransactionID)
selfTestCb.triggerFsmEvent(cb.fsm, selfTestEventAbort)
selfTestCb.submitFailureGetValueResponse(ctx, cb.respChan, extension.GetValueResponse_UNSUPPORTED, extension.GetValueResponse_ERROR)
}
-func (selfTestCb *selfTestControlBlock) handleOmciTestResult(ctx context.Context, msg OmciMessage, cb *fsmCb, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciTestResult(ctx context.Context, msg cmn.OmciMessage, cb *fsmCb, classID generated.ClassID) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeTestResult)
if msgLayer == nil {
logger.Errorw(ctx, "omci Msg layer nil self test result", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
@@ -240,7 +252,7 @@
var msgObj *omci.OpticalLineSupervisionTestResult
var msgOk bool
switch classID {
- case aniGClassID:
+ case me.AniGClassID:
msgObj, msgOk = msgLayer.(*omci.OpticalLineSupervisionTestResult)
default:
// We should not really land here
@@ -267,18 +279,18 @@
Response: &extension.GetValueResponse_OnuOpticalInfo{
OnuOpticalInfo: &extension.GetOnuPonOpticalInfoResponse{
// OMCI representation is Volts, 2s compliment, 20mV resolution
- PowerFeedVoltage: float32(TwosComplementToSignedInt16(msgObj.PowerFeedVoltage)) * 0.02,
+ PowerFeedVoltage: float32(cmn.TwosComplementToSignedInt16(msgObj.PowerFeedVoltage)) * 0.02,
// OMCI representation is Decibel-microwatts, 2s compliment, 0.002dB resolution.
// Subtract 30 to convert the unit from dBu to dBm (as expected by proto interface)
- ReceivedOpticalPower: float32(TwosComplementToSignedInt16(msgObj.ReceivedOpticalPower))*0.002 - 30,
+ ReceivedOpticalPower: float32(cmn.TwosComplementToSignedInt16(msgObj.ReceivedOpticalPower))*0.002 - 30,
// OMCI representation is Decibel-microwatts, 2s compliment, 0.002dB resolution
// Subtract 30 to convert the unit from dBu to dBm (as expected by proto interface)
- MeanOpticalLaunchPower: float32(TwosComplementToSignedInt16(msgObj.MeanOpticalLaunch))*0.002 - 30,
+ MeanOpticalLaunchPower: float32(cmn.TwosComplementToSignedInt16(msgObj.MeanOpticalLaunch))*0.002 - 30,
// OMCI representation is unsigned int, 2uA resolution
// units of gRPC interface is mA.
LaserBiasCurrent: float32(msgObj.LaserBiasCurrent) * 0.000002 * 1000, // multiply by 1000 to get units in mA
// OMCI representation is 2s complement, 1/256 degree Celsius resolution
- Temperature: float32(TwosComplementToSignedInt16(msgObj.Temperature)) / 256.0,
+ Temperature: float32(cmn.TwosComplementToSignedInt16(msgObj.Temperature)) / 256.0,
},
},
},
@@ -297,7 +309,7 @@
logger.Infow(ctx, "OMCI test result success - pushing results complete", log.Fields{"device-id": selfTestCb.deviceID, "classID": classID})
}
-func (selfTestCb *selfTestControlBlock) handleOmciResponse(ctx context.Context, classID generated.ClassID) {
+func (selfTestCb *SelfTestControlBlock) handleOmciResponse(ctx context.Context, classID generated.ClassID) {
selfTestCb.selfTestFsmLock.RLock()
pFsmCb, ok := selfTestCb.selfTestFsmMap[classID]
selfTestCb.selfTestFsmLock.RUnlock()
@@ -310,7 +322,7 @@
logger.Infow(ctx, "omci processing stopped", log.Fields{"device-id": selfTestCb.deviceID, "class-id": classID})
selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
selfTestCb.submitFailureGetValueResponse(ctx, pFsmCb.respChan, extension.GetValueResponse_REASON_UNDEFINED, extension.GetValueResponse_ERROR)
- case message, ok := <-pFsmCb.fsm.commChan:
+ case message, ok := <-pFsmCb.fsm.CommChan:
if !ok {
logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": selfTestCb.deviceID})
selfTestCb.triggerFsmEvent(pFsmCb.fsm, selfTestEventAbort)
@@ -319,8 +331,8 @@
logger.Debugw(ctx, "Received message on self test result channel", log.Fields{"device-id": selfTestCb.deviceID})
switch message.Type {
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
selfTestCb.handleOmciMessage(ctx, msg, pFsmCb, classID)
default:
logger.Errorw(ctx, "Unknown message type received", log.Fields{"device-id": selfTestCb.deviceID, "message.Type": message.Type})
@@ -334,7 +346,7 @@
}
// selfTestRequestComplete removes the fsmCb from the local cache if found
-func (selfTestCb *selfTestControlBlock) selfTestRequestComplete(ctx context.Context, reqMsg extension.SingleGetValueRequest) {
+func (selfTestCb *SelfTestControlBlock) selfTestRequestComplete(ctx context.Context, reqMsg extension.SingleGetValueRequest) {
meClassID, err := selfTestCb.getMeClassID(ctx, reqMsg)
if err != nil {
return
@@ -344,9 +356,9 @@
delete(selfTestCb.selfTestFsmMap, meClassID)
}
-func (selfTestCb *selfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
+func (selfTestCb *SelfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
selfTestCb.SetSelfTestHandlerIsRunning(true)
- <-selfTestCb.stopSelfTestModule // block on stop signal
+ <-selfTestCb.StopSelfTestModule // block on stop signal
selfTestCb.SetSelfTestHandlerIsRunning(false)
logger.Infow(ctx, "received stop signal - clean up start", log.Fields{"device-id": selfTestCb.deviceID})
@@ -367,23 +379,24 @@
//// Exported functions
-// SetSelfTestHandlerActive sets the value to selfTestCb.selfTestHandlerActive
-func (selfTestCb *selfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
+// SetSelfTestHandlerIsRunning sets the value to selfTestCb.selfTestHandlerActive
+func (selfTestCb *SelfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
selfTestCb.selfTestHandlerLock.Lock()
defer selfTestCb.selfTestHandlerLock.Unlock()
selfTestCb.selfTestHandlerActive = active
}
-// GetSelfTestHandlerActive gets selfTestCb.selfTestHandlerActive
-func (selfTestCb *selfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
+// GetSelfTestHandlerIsRunning gets selfTestCb.selfTestHandlerActive
+func (selfTestCb *SelfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
selfTestCb.selfTestHandlerLock.RLock()
defer selfTestCb.selfTestHandlerLock.RUnlock()
return selfTestCb.selfTestHandlerActive
}
-// selfTestRequest initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
+// SelfTestRequestStart initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
// If the return from selfTestRequest is NOT nil, the caller shall not wait for async response.
-func (selfTestCb *selfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, respChan chan extension.SingleGetValueResponse) error {
+func (selfTestCb *SelfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest,
+ CommChan chan cmn.Message, respChan chan extension.SingleGetValueResponse) error {
meClassID, err := selfTestCb.getMeClassID(ctx, reqMsg)
if err != nil {
return err
@@ -395,5 +408,5 @@
logger.Infow(ctx, "self test request initiated", log.Fields{"device-id": selfTestCb.deviceID, "meClassID": meClassID})
// indicates only if the FSM was initiated correctly. Response is asynchronous on respChan.
// If the return from here is NOT nil, the caller shall not wait for async response.
- return selfTestCb.initiateNewSelfTestFsm(ctx, reqMsg, commChan, meClassID, respChan)
+ return selfTestCb.initiateNewSelfTestFsm(ctx, reqMsg, CommChan, meClassID, respChan)
}
diff --git a/internal/pkg/onuadaptercore/omci_test_request.go b/internal/pkg/omcitst/omci_test_request.go
old mode 100644
new mode 100755
similarity index 66%
rename from internal/pkg/onuadaptercore/omci_test_request.go
rename to internal/pkg/omcitst/omci_test_request.go
index 235f21d..33db828
--- a/internal/pkg/onuadaptercore/omci_test_request.go
+++ b/internal/pkg/omcitst/omci_test_request.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package omcitst provides the omci test functionality
+package omcitst
import (
"context"
@@ -24,14 +24,15 @@
gp "github.com/google/gopacket"
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
)
-//omciTestRequest structure holds the information for the OMCI test
-type omciTestRequest struct {
+//OmciTestRequest structure holds the information for the OMCI test
+type OmciTestRequest struct {
deviceID string
- pDevOmciCC *omciCC
+ pDevOmciCC *cmn.OmciCC
started bool
result bool
exclusiveCc bool
@@ -40,41 +41,45 @@
verifyDone chan<- bool
}
-//newOmciTestRequest returns a new instance of OmciTestRequest
-func newOmciTestRequest(ctx context.Context,
- deviceID string, omciCc *omciCC,
- exclusive bool, allowFailure bool) *omciTestRequest {
- logger.Debug(ctx, "omciTestRequest-init")
- var omciTestRequest omciTestRequest
- omciTestRequest.deviceID = deviceID
- omciTestRequest.pDevOmciCC = omciCc
- omciTestRequest.started = false
- omciTestRequest.result = false
- omciTestRequest.exclusiveCc = exclusive
- omciTestRequest.allowFailure = allowFailure
+//NewOmciTestRequest returns a new instance of OmciTestRequest
+func NewOmciTestRequest(ctx context.Context,
+ deviceID string, omciCc *cmn.OmciCC,
+ exclusive bool, allowFailure bool) *OmciTestRequest {
+ logger.Debug(ctx, "OmciTestRequest-init")
+ var OmciTestRequest OmciTestRequest
+ OmciTestRequest.deviceID = deviceID
+ OmciTestRequest.pDevOmciCC = omciCc
+ OmciTestRequest.started = false
+ OmciTestRequest.result = false
+ OmciTestRequest.exclusiveCc = exclusive
+ OmciTestRequest.allowFailure = allowFailure
- return &omciTestRequest
+ return &OmciTestRequest
}
-//
-func (oo *omciTestRequest) performOmciTest(ctx context.Context, execChannel chan<- bool) {
- logger.Debug(ctx, "omciTestRequest-start-test")
+// PerformOmciTest - TODO: add comment
+func (oo *OmciTestRequest) PerformOmciTest(ctx context.Context, execChannel chan<- bool) {
+ logger.Debug(ctx, "OmciTestRequest-start-test")
if oo.pDevOmciCC != nil {
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)
+ tid := oo.pDevOmciCC.GetNextTid(false)
onu2gBaseGet, _ := oo.createOnu2gBaseGet(ctx, tid)
- omciRxCallbackPair := callbackPair{
- cbKey: tid,
- cbEntry: callbackPairEntry{nil, oo.receiveOmciVerifyResponse, true},
+ omciRxCallbackPair := cmn.CallbackPair{
+ CbKey: tid,
+ CbEntry: cmn.CallbackPairEntry{
+ CbRespChannel: nil,
+ CbFunction: oo.ReceiveOmciVerifyResponse,
+ FramePrint: true,
+ },
}
logger.Debugw(ctx, "performOmciTest-start sending frame", log.Fields{"for device-id": oo.deviceID})
// send with default timeout and normal prio
// Note: No reference to fetch the OMCI timeout value from configuration, so hardcode it to 10s
- go oo.pDevOmciCC.send(ctx, onu2gBaseGet, 10, cDefaultRetries, false, omciRxCallbackPair)
+ go oo.pDevOmciCC.Send(ctx, onu2gBaseGet, 10, cmn.CDefaultRetries, false, omciRxCallbackPair)
} else {
logger.Errorw(ctx, "performOmciTest: Device does not exist", log.Fields{"for device-id": oo.deviceID})
@@ -84,7 +89,7 @@
// these are OMCI related functions, could/should be collected in a separate file? TODO!!!
// for a simple start just included in here
//basic approach copied from bbsim, cmp /devices/onu.go and /internal/common/omci/mibpackets.go
-func (oo *omciTestRequest) createOnu2gBaseGet(ctx context.Context, tid uint16) ([]byte, error) {
+func (oo *OmciTestRequest) createOnu2gBaseGet(ctx context.Context, tid uint16) ([]byte, error) {
request := &omci.GetRequest{
MeBasePacket: omci.MeBasePacket{
@@ -95,7 +100,7 @@
}
oo.txSeqNo = tid
- pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
+ pkt, err := cmn.Serialize(ctx, omci.GetRequestType, request, tid)
if err != nil {
//omciLogger.WithFields(log.Fields{ ...
logger.Errorw(ctx, "Cannot serialize Onu2-G GetRequest", log.Fields{"device-id": oo.deviceID, "Err": err})
@@ -106,8 +111,8 @@
return pkt, nil
}
-//supply a response handler - in this testobject the message is evaluated directly, no response channel used
-func (oo *omciTestRequest) receiveOmciVerifyResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+//ReceiveOmciVerifyResponse supply a response handler - in this testobject the message is evaluated directly, no response channel used
+func (oo *OmciTestRequest) ReceiveOmciVerifyResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan cmn.Message) error {
logger.Debugw(ctx, "verify-omci-message-response received:", log.Fields{"omciMsgType": omciMsg.MessageType,
"transCorrId": omciMsg.TransactionID, "DeviceIdent": omciMsg.DeviceIdentifier})
@@ -131,14 +136,14 @@
//TODO!!! further tests on the payload should be done here ...
- oo.pDevOmciCC.mutexMonReq.RLock()
- if _, exist := oo.pDevOmciCC.monitoredRequests[omciMsg.TransactionID]; exist {
- oo.pDevOmciCC.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
+ oo.pDevOmciCC.RLockMutexMonReq()
+ if _, exist := oo.pDevOmciCC.GetMonitoredRequest(omciMsg.TransactionID); exist {
+ oo.pDevOmciCC.SetChMonitoredRequest(omciMsg.TransactionID, true)
} else {
logger.Infow(ctx, "reqMon: map entry does not exist!",
log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
}
- oo.pDevOmciCC.mutexMonReq.RUnlock()
+ oo.pDevOmciCC.RUnlockMutexMonReq()
oo.result = true
oo.verifyDone <- true
diff --git a/internal/pkg/onuadaptercore/me_config.go b/internal/pkg/onuadaptercore/me_config.go
deleted file mode 100644
index 11ffe87..0000000
--- a/internal/pkg/onuadaptercore/me_config.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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/messageTypes.go b/internal/pkg/onuadaptercore/messageTypes.go
deleted file mode 100644
index 2f5bac6..0000000
--- a/internal/pkg/onuadaptercore/messageTypes.go
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2018-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 (
- gp "github.com/google/gopacket"
- "github.com/opencord/omci-lib-go"
-)
-
-// MessageType - Message Protocol Type
-type MessageType uint8
-
-const (
- // TestMsg - Message type for non OMCI messages
- TestMsg MessageType = iota
- //OMCI - OMCI protocol type msg
- OMCI
-)
-
-// String - Return the text representation of the message type based on integer
-func (m MessageType) String() string {
- names := [...]string{
- "TestMsg",
- "OMCI",
- }
- return names[m]
-}
-
-// Message - message type and data(OMCI)
-type Message struct {
- Type MessageType
- Data interface{}
-}
-
-//TestMessageType - message data for various events
-type TestMessageType uint8
-
-const (
- // LoadMibTemplateOk - message data for getting mib template successfully
- LoadMibTemplateOk TestMessageType = iota + 1
- // LoadMibTemplateFailed - message data for failure for getting mib template
- LoadMibTemplateFailed
- // TimeOutOccurred - message data for timeout
- TimeOutOccurred
- // AbortMessageProcessing - message data for aborting running message
- AbortMessageProcessing
-)
-
-//TestMessage - Struct to hold the message data
-//TODO: place holder to have a second interface variant - to be replaced by real variant later on
-type TestMessage struct {
- TestMessageVal TestMessageType
-}
-
-//OmciMessage - OMCI protocol messages for managing and monitoring ONUs
-type OmciMessage struct {
- //OnuSN *openolt.SerialNumber
- //OnuID uint32
- OmciMsg *omci.OMCI
- OmciPacket *gp.Packet
-}
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
deleted file mode 100644
index bfb1ab5..0000000
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- * 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 (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "sync"
- "time"
-
- "github.com/looplab/fsm"
- "github.com/opencord/omci-lib-go"
- me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v7/pkg/db"
- "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
- vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
-
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
-)
-
-const (
- // events of MibUpload FSM
- ulEvStart = "ulEvStart"
- ulEvResetMib = "ulEvResetMib"
- ulEvGetVendorAndSerial = "ulEvGetVendorAndSerial"
- ulEvGetEquipmentID = "ulEvGetEquipmentId"
- ulEvGetFirstSwVersion = "ulEvGetFirstSwVersion"
- ulEvGetSecondSwVersion = "ulEvGetSecondSwVersion"
- ulEvGetMacAddress = "ulEvGetMacAddress"
- ulEvGetMibTemplate = "ulEvGetMibTemplate"
- ulEvUploadMib = "ulEvUploadMib"
- ulEvExamineMds = "ulEvExamineMds"
- ulEvSuccess = "ulEvSuccess"
- ulEvMismatch = "ulEvMismatch"
- ulEvAuditMib = "ulEvAuditMib"
- ulEvForceResync = "ulEvForceResync"
- ulEvDiffsFound = "ulEvDiffsFound"
- ulEvTimeout = "ulEvTimeout"
- ulEvStop = "ulEvStop"
-)
-const (
- // states of MibUpload FSM
- ulStDisabled = "ulStDisabled"
- ulStStarting = "ulStStarting"
- ulStResettingMib = "ulStResettingMib"
- ulStGettingVendorAndSerial = "ulStGettingVendorAndSerial"
- ulStGettingEquipmentID = "ulStGettingEquipmentID"
- ulStGettingFirstSwVersion = "ulStGettingFirstSwVersion"
- ulStGettingSecondSwVersion = "ulStGettingSecondSwVersion"
- ulStGettingMacAddress = "ulStGettingMacAddress"
- ulStGettingMibTemplate = "ulStGettingMibTemplate"
- ulStUploading = "ulStUploading"
- ulStUploadDone = "ulStUploadDone"
- ulStInSync = "ulStInSync"
- ulStExaminingMds = "ulStExaminingMds"
- ulStResynchronizing = "ulStResynchronizing"
- ulStExaminingMdsSuccess = "ulStExaminingMdsSuccess"
- ulStAuditing = "ulStAuditing"
- ulStReAuditing = "ulStReAuditing"
- ulStOutOfSync = "ulStOutOfSync"
-)
-const cMibUlFsmIdleState = ulStInSync
-
-const (
- // events of MibDownload FSM
- dlEvStart = "dlEvStart"
- dlEvCreateGal = "dlEvCreateGal"
- dlEvRxGalResp = "dlEvRxGalResp"
- dlEvRxOnu2gResp = "dlEvRxOnu2gResp"
- dlEvRxBridgeResp = "dlEvRxBridgeResp"
- dlEvTimeoutSimple = "dlEvTimeoutSimple"
- dlEvTimeoutBridge = "dlEvTimeoutBridge"
- dlEvReset = "dlEvReset"
- dlEvRestart = "dlEvRestart"
-)
-const (
- // states of MibDownload FSM
- dlStDisabled = "dlStDisabled"
- dlStStarting = "dlStStarting"
- dlStCreatingGal = "dlStCreatingGal"
- dlStSettingOnu2g = "dlStSettingOnu2g"
- dlStBridgeInit = "dlStBridgeInit"
- dlStDownloaded = "dlStDownloaded"
- dlStResetting = "dlStResetting"
-)
-const cMibDlFsmIdleState = dlStDisabled
-
-const (
- // NOTE that this hardcoded to service/voltha as the MIB template is shared across stacks
- cBasePathMibTemplateKvStore = "service/voltha/omci_mibs/go_templates"
- cSuffixMibTemplateKvStore = "%s/%s/%s"
- cBasePathOnuKVStore = "%s/openonu"
-)
-
-// OnuDeviceEvent - event of interest to Device Adapters and OpenOMCI State Machines
-type OnuDeviceEvent int
-
-const (
- // Events of interest to Device Adapters and OpenOMCI State Machines
-
- // DeviceStatusInit - default start state
- DeviceStatusInit OnuDeviceEvent = iota
- // MibDatabaseSync - MIB database sync (upload done)
- MibDatabaseSync
- // OmciCapabilitiesDone - OMCI ME and message type capabilities known
- OmciCapabilitiesDone
- // MibDownloadDone - // MIB download done
- MibDownloadDone
- // UniLockStateDone - Uni ports admin set to lock
- UniLockStateDone
- // UniUnlockStateDone - Uni ports admin set to unlock
- UniUnlockStateDone
- // UniDisableStateDone - Uni ports admin set to lock based on device disable
- UniDisableStateDone
- // UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
- UniEnableStateDone
- // PortLinkUp - Port link state change
- PortLinkUp
- // PortLinkDw - Port link state change
- PortLinkDw
- // OmciAniConfigDone - AniSide config according to TechProfile done
- OmciAniConfigDone
- // OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
- OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
- // OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
- OmciVlanFilterAddDone
- // OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
- OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
- // OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
- OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
- // OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
- OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
- // OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
- OmciOnuSwUpgradeDone
- // Add other events here as needed (alarms separate???)
-)
-
-//AdapterFsm related error string
-//error string could be checked on waitforOmciResponse() e.g. to avoid misleading error log
-// but not used that way so far (permit error log even for wanted cancellation)
-const cErrWaitAborted = "waitResponse aborted"
-
-type activityDescr struct {
- databaseClass func(context.Context) error
- //advertiseEvents bool
- auditInterval time.Duration
- //tasks map[string]func() error
-}
-
-// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
-type OmciDeviceFsms map[string]activityDescr
-
-// AdapterFsm - Adapter FSM details including channel, event and device
-type AdapterFsm struct {
- fsmName string
- deviceID string
- commChan chan Message
- pFsm *fsm.FSM
-}
-
-//NewAdapterFsm - FSM details including event, device and channel.
-func NewAdapterFsm(aName string, aDeviceID string, aCommChannel chan Message) *AdapterFsm {
- aFsm := &AdapterFsm{
- fsmName: aName,
- deviceID: aDeviceID,
- commChan: aCommChannel,
- }
- return aFsm
-}
-
-//Start starts (logs) the omci agent
-func (oo *AdapterFsm) logFsmStateChange(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
- "event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
-}
-
-//OntDeviceEntry structure holds information about the attached FSM'as and their communication
-
-const (
- firstSwImageMeID = 0
- secondSwImageMeID = 1
-)
-const ( //definitions as per G.988 softwareImage::IsCommitted
- swIsUncommitted = 0
- swIsCommitted = 1
-)
-const ( //definitions as per G.988 softwareImage::IsActive
- swIsInactive = 0
- swIsActive = 1
-)
-const ( //definitions as per G.988 softwareImage::IsValid
- //swIsInvalid = 0 not yet used
- swIsValid = 1
-)
-const onuDataMeID = 0
-const onugMeID = 0
-const onu2gMeID = 0
-const ipHostConfigDataMeID = 1
-const onugSerialNumberLen = 8
-const omciMacAddressLen = 6
-
-const cEmptyMacAddrString = "000000000000"
-const cEmptySerialNumberString = "0000000000000000"
-
-type sEntrySwImageIndication struct {
- valid bool
- entityID uint16
- version string
- isCommitted uint8
-}
-type sSwImageIndications struct {
- activeEntityEntry sEntrySwImageIndication
- inactiveEntityEntry sEntrySwImageIndication
-}
-
-type uniPersConfig struct {
- PersUniID uint8 `json:"uni_id"`
- PersTpPathMap map[uint8]string `json:"PersTpPathMap"` // tp-id to tp-path map
- PersFlowParams []uniVlanFlowParams `json:"flow_params"` //as defined in omci_ani_config.go
-}
-
-type onuPersistentData struct {
- PersOnuID uint32 `json:"onu_id"`
- PersIntfID uint32 `json:"intf_id"`
- PersSerialNumber string `json:"serial_number"`
- PersMacAddress string `json:"mac_address"`
- PersVendorID string `json:"vendor_id"`
- PersEquipmentID string `json:"equipment_id"`
- PersActiveSwVersion string `json:"active_sw_version"`
- PersAdminState string `json:"admin_state"`
- PersOperState string `json:"oper_state"`
- PersUniUnlockDone bool `json:"uni_unlock_done"`
- PersUniDisableDone bool `json:"uni_disable_done"`
- PersMibAuditInterval time.Duration `json:"mib_audit_interval"`
- PersMibLastDbSync uint32 `json:"mib_last_db_sync"`
- PersMibDataSyncAdpt uint8 `json:"mib_data_sync_adpt"`
- PersUniConfig []uniPersConfig `json:"uni_config"`
- PersAlarmAuditInterval time.Duration `json:"alarm_audit_interval"`
- PersTcontMap map[uint16]uint16 `json:"tcont_map"` //alloc-id to me-instance-id map
-}
-
-// OnuDeviceEntry - ONU device info and FSM events.
-type OnuDeviceEntry struct {
- deviceID string
- baseDeviceHandler *deviceHandler
- pOpenOnuAc *OpenONUAC
- coreClient *vgrpc.Client
- PDevOmciCC *omciCC
- pOnuDB *onuDeviceDB
- mibTemplateKVStore *db.Backend
- mutexPersOnuConfig sync.RWMutex
- sOnuPersistentData onuPersistentData
- mibTemplatePath string
- mutexOnuKVStore sync.RWMutex
- onuKVStore *db.Backend
- onuKVStorePath string
- mutexOnuKVStoreProcResult sync.RWMutex
- onuKVStoreProcResult error //error indication of processing
- chOnuKvProcessingStep chan uint8
- mutexOnuSwImageIndications sync.RWMutex
- onuSwImageIndications sSwImageIndications
- mutexOnuImageStatus sync.RWMutex
- pOnuImageStatus *OnuImageStatus
- //lockDeviceEntries sync.RWMutex
- mibDbClass func(context.Context) error
- supportedFsms OmciDeviceFsms
- devState OnuDeviceEvent
- // Audit and MDS
- mibAuditInterval time.Duration
- alarmAuditInterval time.Duration
- // TODO: periodical mib resync will be implemented with story VOL-3792
- //mibNextDbResync uint32
-
- // for mibUpload
- pMibUploadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
- mutexLastTxParamStruct sync.RWMutex
- lastTxParamStruct sLastTxMeParameter
- // for mibDownload
- pMibDownloadFsm *AdapterFsm //could be handled dynamically and more general as pAdapterFsm - perhaps later
- //remark: general usage of pAdapterFsm would require generalization of commChan usage and internal event setting
- // within the FSM event procedures
- omciMessageReceived chan bool //seperate channel needed by DownloadFsm
- omciRebootMessageReceivedChannel chan Message // channel needed by Reboot request
-
- mutexTcontMap sync.RWMutex
-}
-
-//newOnuDeviceEntry returns a new instance of a OnuDeviceEntry
-//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newOnuDeviceEntry(ctx context.Context, dh *deviceHandler) *OnuDeviceEntry {
- logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": dh.deviceID})
- var onuDeviceEntry OnuDeviceEntry
- onuDeviceEntry.deviceID = dh.deviceID
- onuDeviceEntry.baseDeviceHandler = dh
- onuDeviceEntry.pOpenOnuAc = dh.pOpenOnuAc
- onuDeviceEntry.coreClient = dh.coreClient
- onuDeviceEntry.devState = DeviceStatusInit
- onuDeviceEntry.sOnuPersistentData.PersUniConfig = make([]uniPersConfig, 0)
- onuDeviceEntry.sOnuPersistentData.PersTcontMap = make(map[uint16]uint16)
- onuDeviceEntry.chOnuKvProcessingStep = make(chan uint8)
- onuDeviceEntry.omciRebootMessageReceivedChannel = make(chan Message, 2048)
- //openomciagent.lockDeviceHandlersMap = sync.RWMutex{}
- //OMCI related databases are on a per-agent basis. State machines and tasks
- //are per ONU Vendor
- //
- // MIB Synchronization Database - possible overloading from arguments
- if dh.pOpenOnuAc.pSupportedFsms != nil {
- onuDeviceEntry.supportedFsms = *dh.pOpenOnuAc.pSupportedFsms
- } else {
- // This branch is currently not used and is for potential future usage of alternative MIB Sync FSMs only!
- //var mibSyncFsm = NewMibSynchronizer()
- // use some internal defaults, if not defined from outside
- onuDeviceEntry.supportedFsms = OmciDeviceFsms{
- "mib-synchronizer": {
- //mibSyncFsm, // Implements the MIB synchronization state machine
- onuDeviceEntry.mibDbVolatileDict, // Implements volatile ME MIB database
- //true, // Advertise events on OpenOMCI event bus
- dh.pOpenOnuAc.mibAuditInterval, // Time to wait between MIB audits. 0 to disable audits.
- // map[string]func() error{
- // "mib-upload": onuDeviceEntry.MibUploadTask,
- // "mib-template": onuDeviceEntry.MibTemplateTask,
- // "get-mds": onuDeviceEntry.GetMdsTask,
- // "mib-audit": onuDeviceEntry.GetMdsTask,
- // "mib-resync": onuDeviceEntry.MibResyncTask,
- // "mib-reconcile": onuDeviceEntry.MibReconcileTask,
- // },
- },
- }
- }
- onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].databaseClass
- logger.Debug(ctx, "access2mibDbClass")
- go onuDeviceEntry.mibDbClass(ctx)
- if !dh.isReconciling() {
- onuDeviceEntry.mibAuditInterval = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditInterval
- onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval = onuDeviceEntry.mibAuditInterval
- onuDeviceEntry.alarmAuditInterval = dh.pOpenOnuAc.alarmAuditInterval
- onuDeviceEntry.sOnuPersistentData.PersAlarmAuditInterval = onuDeviceEntry.alarmAuditInterval
- } else {
- logger.Debugw(ctx, "reconciling - take audit interval from persistent data", log.Fields{"device-id": dh.deviceID})
- // TODO: This is a preparation for VOL-VOL-3811 to preserve config history in case of
- // vendor- or deviceID-specific configurations via voltctl-commands
- onuDeviceEntry.mibAuditInterval = onuDeviceEntry.sOnuPersistentData.PersMibAuditInterval
- onuDeviceEntry.alarmAuditInterval = onuDeviceEntry.sOnuPersistentData.PersAlarmAuditInterval
- }
- logger.Debugw(ctx, "MibAuditInterval and AlarmAuditInterval is set to", log.Fields{"mib-audit-interval": onuDeviceEntry.mibAuditInterval,
- "alarm-audit-interval": onuDeviceEntry.alarmAuditInterval})
- // TODO: periodical mib resync will be implemented with story VOL-3792
- //onuDeviceEntry.mibNextDbResync = 0
-
- // Omci related Mib upload sync state machine
- mibUploadChan := make(chan Message, 2048)
- onuDeviceEntry.pMibUploadFsm = NewAdapterFsm("MibUpload", dh.deviceID, mibUploadChan)
- onuDeviceEntry.pMibUploadFsm.pFsm = fsm.NewFSM(
- ulStDisabled,
- fsm.Events{
-
- {Name: ulEvStart, Src: []string{ulStDisabled}, Dst: ulStStarting},
-
- {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: ulEvGetSecondSwVersion, Src: []string{ulStGettingFirstSwVersion}, Dst: ulStGettingSecondSwVersion},
- {Name: ulEvGetMacAddress, Src: []string{ulStGettingSecondSwVersion}, Dst: ulStGettingMacAddress},
- {Name: ulEvGetMibTemplate, Src: []string{ulStGettingMacAddress}, Dst: ulStGettingMibTemplate},
-
- {Name: ulEvUploadMib, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploading},
- {Name: ulEvExamineMds, Src: []string{ulStStarting}, Dst: ulStExaminingMds},
-
- {Name: ulEvSuccess, Src: []string{ulStGettingMibTemplate}, Dst: ulStUploadDone},
- {Name: ulEvSuccess, Src: []string{ulStUploading}, Dst: ulStUploadDone},
-
- {Name: ulEvSuccess, Src: []string{ulStUploadDone}, Dst: ulStInSync},
- //{Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStInSync},
- {Name: ulEvSuccess, Src: []string{ulStExaminingMds}, Dst: ulStExaminingMdsSuccess},
- // TODO: As long as mib-resynchronizing is not implemented, failed MDS-examination triggers
- // mib-reset and new provisioning at this point
- //{Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResynchronizing},
- {Name: ulEvMismatch, Src: []string{ulStExaminingMds}, Dst: ulStResettingMib},
-
- {Name: ulEvSuccess, Src: []string{ulStExaminingMdsSuccess}, Dst: ulStInSync},
- {Name: ulEvMismatch, Src: []string{ulStExaminingMdsSuccess}, Dst: ulStResettingMib},
-
- {Name: ulEvAuditMib, Src: []string{ulStInSync}, Dst: ulStAuditing},
-
- {Name: ulEvSuccess, Src: []string{ulStOutOfSync}, Dst: ulStInSync},
- {Name: ulEvAuditMib, Src: []string{ulStOutOfSync}, Dst: ulStAuditing},
-
- {Name: ulEvSuccess, Src: []string{ulStAuditing}, Dst: ulStInSync},
- {Name: ulEvMismatch, Src: []string{ulStAuditing}, Dst: ulStReAuditing},
- {Name: ulEvForceResync, Src: []string{ulStAuditing}, Dst: ulStResynchronizing},
-
- {Name: ulEvSuccess, Src: []string{ulStReAuditing}, Dst: ulStInSync},
- {Name: ulEvMismatch, Src: []string{ulStReAuditing}, Dst: ulStResettingMib},
-
- {Name: ulEvSuccess, Src: []string{ulStResynchronizing}, Dst: ulStInSync},
- {Name: ulEvDiffsFound, Src: []string{ulStResynchronizing}, Dst: ulStOutOfSync},
-
- {Name: ulEvTimeout, Src: []string{ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
- ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
- ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStStarting},
-
- {Name: ulEvStop, Src: []string{ulStStarting, ulStResettingMib, ulStGettingVendorAndSerial, ulStGettingEquipmentID, ulStGettingFirstSwVersion,
- ulStGettingSecondSwVersion, ulStGettingMacAddress, ulStGettingMibTemplate, ulStUploading, ulStResynchronizing, ulStExaminingMds,
- ulStUploadDone, ulStInSync, ulStOutOfSync, ulStAuditing, ulStReAuditing}, Dst: ulStDisabled},
- },
-
- fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(ctx, e) },
- "enter_" + ulStStarting: func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
- "enter_" + ulStResettingMib: func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
- "enter_" + ulStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
- "enter_" + ulStGettingEquipmentID: func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
- "enter_" + ulStGettingFirstSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
- "enter_" + ulStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
- "enter_" + ulStGettingMacAddress: func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
- "enter_" + ulStGettingMibTemplate: func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplateState(ctx, e) },
- "enter_" + ulStUploading: func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
- "enter_" + ulStUploadDone: func(e *fsm.Event) { onuDeviceEntry.enterUploadDoneState(ctx, e) },
- "enter_" + ulStExaminingMds: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
- "enter_" + ulStResynchronizing: func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
- "enter_" + ulStExaminingMdsSuccess: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsSuccessState(ctx, e) },
- "enter_" + ulStAuditing: func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
- "enter_" + ulStReAuditing: func(e *fsm.Event) { onuDeviceEntry.enterReAuditingState(ctx, e) },
- "enter_" + ulStOutOfSync: func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
- "enter_" + ulStInSync: func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
- },
- )
- // Omci related Mib download state machine
- mibDownloadChan := make(chan Message, 2048)
- onuDeviceEntry.pMibDownloadFsm = NewAdapterFsm("MibDownload", dh.deviceID, mibDownloadChan)
- onuDeviceEntry.pMibDownloadFsm.pFsm = fsm.NewFSM(
- dlStDisabled,
- fsm.Events{
-
- {Name: dlEvStart, Src: []string{dlStDisabled}, Dst: dlStStarting},
-
- {Name: dlEvCreateGal, Src: []string{dlStStarting}, Dst: dlStCreatingGal},
- {Name: dlEvRxGalResp, Src: []string{dlStCreatingGal}, Dst: dlStSettingOnu2g},
- {Name: dlEvRxOnu2gResp, Src: []string{dlStSettingOnu2g}, Dst: dlStBridgeInit},
- // the bridge state is used for multi ME config for alle UNI related ports
- // maybe such could be reflected in the state machine as well (port number parametrized)
- // but that looks not straightforward here - so we keep it simple here for the beginning(?)
- {Name: dlEvRxBridgeResp, Src: []string{dlStBridgeInit}, Dst: dlStDownloaded},
-
- {Name: dlEvTimeoutSimple, Src: []string{dlStCreatingGal, dlStSettingOnu2g}, Dst: dlStStarting},
- {Name: dlEvTimeoutBridge, Src: []string{dlStBridgeInit}, Dst: dlStStarting},
-
- {Name: dlEvReset, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
- dlStBridgeInit, dlStDownloaded}, Dst: dlStResetting},
- // exceptional treatment for all states except dlStResetting
- {Name: dlEvRestart, Src: []string{dlStStarting, dlStCreatingGal, dlStSettingOnu2g,
- dlStBridgeInit, dlStDownloaded, dlStResetting}, Dst: dlStDisabled},
- },
-
- fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(ctx, e) },
- "enter_" + dlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
- "enter_" + dlStCreatingGal: func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
- "enter_" + dlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
- "enter_" + dlStBridgeInit: func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
- "enter_" + dlStDownloaded: func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
- "enter_" + dlStResetting: func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
- },
- )
- if onuDeviceEntry.pMibDownloadFsm == nil || onuDeviceEntry.pMibDownloadFsm.pFsm == nil {
- logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": dh.deviceID})
- // TODO some specific error treatment - or waiting for crash ?
- }
-
- onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, cBasePathMibTemplateKvStore)
- if onuDeviceEntry.mibTemplateKVStore == nil {
- logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
- log.Fields{"device-id": dh.deviceID, "service": cBasePathMibTemplateKvStore})
- }
-
- onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
- baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.pOpenOnuAc.cm.Backend.PathPrefix)
- onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, baseKvStorePath)
- if onuDeviceEntry.onuKVStore == nil {
- logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
- log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
- }
-
- // Alarm Synchronization Database
-
- //self._alarm_db = None
- //self._alarm_database_cls = support_classes['alarm-synchronizer']['database']
- return &onuDeviceEntry
-}
-
-//start starts (logs) the omci agent
-func (oo *OnuDeviceEntry) start(ctx context.Context) error {
- logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
- if oo.PDevOmciCC == nil {
- oo.PDevOmciCC = newOmciCC(ctx, oo, oo.deviceID, oo.baseDeviceHandler, oo.coreClient)
- if oo.PDevOmciCC == nil {
- logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
- return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
- }
- }
- return nil
-}
-
-//stop stops/resets the omciCC
-func (oo *OnuDeviceEntry) stop(ctx context.Context, abResetOmciCC bool) error {
- logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
- if abResetOmciCC && (oo.PDevOmciCC != nil) {
- _ = oo.PDevOmciCC.stop(ctx)
- }
- //to allow for all event notifications again when re-using the device and omciCC
- oo.devState = DeviceStatusInit
- return nil
-}
-
-func (oo *OnuDeviceEntry) reboot(ctx context.Context) error {
- logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
- if oo.PDevOmciCC != nil {
- if err := oo.PDevOmciCC.sendReboot(ctx, oo.pOpenOnuAc.omciTimeout, true, oo.omciRebootMessageReceivedChannel); err != nil {
- logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
- return err
- }
- }
- return nil
-}
-
-func (oo *OnuDeviceEntry) waitForRebootResponse(ctx context.Context, responseChannel chan Message) error {
- select {
- case <-time.After(oo.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw(ctx, "Reboot timeout", log.Fields{"for device-id": oo.deviceID})
- return fmt.Errorf("rebootTimeout")
- case data := <-responseChannel:
- switch data.Data.(OmciMessage).OmciMsg.MessageType {
- case omci.RebootResponseType:
- {
- msgLayer := (*data.Data.(OmciMessage).OmciPacket).Layer(omci.LayerTypeRebootResponse)
- if msgLayer == nil {
- return fmt.Errorf("omci Msg layer could not be detected for RebootResponseType")
- }
- msgObj, msgOk := msgLayer.(*omci.RebootResponse)
- if !msgOk {
- return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
- }
- logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
- if msgObj.Result != me.Success {
- logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
- // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
- return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
- msgObj.Result, oo.deviceID)
- }
- return nil
- }
- }
- logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
- return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
- }
-}
-
-//Relay the InSync message via Handler to Rw core - Status update
-func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent OnuDeviceEvent) {
- logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
- // 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 ..
- if devEvent == MibDatabaseSync {
- if oo.devState < MibDatabaseSync { //devState has not been synced yet
- oo.devState = MibDatabaseSync
- go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
- //TODO!!! device control: next step: start MIB capability verification from here ?!!!
- } else {
- logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
- }
- } else if devEvent == MibDownloadDone {
- if oo.devState < MibDownloadDone { //devState has not been synced yet
- oo.devState = MibDownloadDone
- go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
- } else {
- logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
- }
- } else {
- logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
- }
-}
-
-func (oo *OnuDeviceEntry) restoreDataFromOnuKvStore(ctx context.Context) error {
- if oo.onuKVStore == nil {
- logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
- return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
- }
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
- oo.sOnuPersistentData =
- onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
- oo.mutexOnuKVStore.RLock()
- Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
- oo.mutexOnuKVStore.RUnlock()
- if err == nil {
- if Value != nil {
- logger.Debugw(ctx, "ONU-data read",
- log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
- tmpBytes, _ := kvstore.ToByte(Value.Value)
-
- if err = json.Unmarshal(tmpBytes, &oo.sOnuPersistentData); err != nil {
- logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
- return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
- }
- logger.Debugw(ctx, "ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
- "device-id": oo.deviceID})
- } else {
- logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
- return fmt.Errorf("no-ONU-data-found")
- }
- } else {
- logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
- return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
- }
- return nil
-}
-
-func (oo *OnuDeviceEntry) deleteDataFromOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
- defer wg.Done()
-
- if oo.onuKVStore == nil {
- logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
- oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: onuKVStore not set"))
- return
- }
- var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
- go oo.deletePersistentData(ctx, processingStep)
- if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
- //timeout or error detected
- logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
- oo.setKvProcessingErrorIndication(errors.New("onu-data delete aborted: during kv-access"))
- return
- }
-}
-
-func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
-
- logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
-
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
-
- oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector default entry
- oo.sOnuPersistentData =
- onuPersistentData{0, 0, "", "", "", "", "", "", "", false, false, oo.mibAuditInterval, 0, 0, make([]uniPersConfig, 0), oo.alarmAuditInterval, make(map[uint16]uint16)}
- logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
- oo.mutexOnuKVStore.Lock()
- err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
- oo.mutexOnuKVStore.Unlock()
- if err != nil {
- logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
- oo.chOnuKvProcessingStep <- 0 //error indication
- return
- }
- oo.chOnuKvProcessingStep <- aProcessingStep //done
-}
-
-func (oo *OnuDeviceEntry) updateOnuKvStore(ctx context.Context, wg *sync.WaitGroup) {
- defer wg.Done()
-
- if oo.onuKVStore == nil {
- logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
- oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: onuKVStore not set"))
- return
- }
- var processingStep uint8 = 1 // used to synchronize the different processing steps with chOnuKvProcessingStep
- go oo.storeDataInOnuKvStore(ctx, processingStep)
- if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
- //timeout or error detected
- logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
- oo.setKvProcessingErrorIndication(errors.New("onu-data update aborted: during writing process"))
- return
- }
-}
-
-func (oo *OnuDeviceEntry) storeDataInOnuKvStore(ctx context.Context, aProcessingStep uint8) {
-
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
- //assign values which are not already present when newOnuDeviceEntry() is called
- oo.sOnuPersistentData.PersOnuID = oo.baseDeviceHandler.pOnuIndication.OnuId
- oo.sOnuPersistentData.PersIntfID = oo.baseDeviceHandler.pOnuIndication.IntfId
- //TODO: verify usage of these values during restart UC
- oo.sOnuPersistentData.PersAdminState = oo.baseDeviceHandler.pOnuIndication.AdminState
- oo.sOnuPersistentData.PersOperState = oo.baseDeviceHandler.pOnuIndication.OperState
-
- logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "sOnuPersistentData": oo.sOnuPersistentData})
-
- Value, err := json.Marshal(oo.sOnuPersistentData)
- if err != nil {
- logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
- "device-id": oo.deviceID, "err": err})
- oo.chOnuKvProcessingStep <- 0 //error indication
- return
- }
- oo.pOpenOnuAc.lockDeviceHandlersMap.RLock()
- if _, exist := oo.pOpenOnuAc.deviceHandlers[oo.deviceID]; !exist {
- logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
- oo.chOnuKvProcessingStep <- aProcessingStep
- oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
- return
- }
- oo.baseDeviceHandler.mutexDeletionInProgressFlag.RLock()
- if oo.baseDeviceHandler.deletionInProgress {
- logger.Debugw(ctx, "delete_device in progress - skip write request", log.Fields{"device-id": oo.deviceID})
- oo.chOnuKvProcessingStep <- aProcessingStep
- oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
- oo.baseDeviceHandler.mutexDeletionInProgressFlag.RUnlock()
- return
- }
- oo.pOpenOnuAc.lockDeviceHandlersMap.RUnlock()
- oo.baseDeviceHandler.mutexDeletionInProgressFlag.RUnlock()
-
- oo.mutexOnuKVStore.Lock()
- err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
- oo.mutexOnuKVStore.Unlock()
- if err != nil {
- logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
- oo.chOnuKvProcessingStep <- 0 //error indication
- return
- }
- oo.chOnuKvProcessingStep <- aProcessingStep //done
-}
-
-func (oo *OnuDeviceEntry) updateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
- /* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
- as also the complete sequence is ensured to 'run to completion' before some new request is accepted
- no specific concurrency protection to sOnuPersistentData is required here
- */
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
-
- for k, v := range oo.sOnuPersistentData.PersUniConfig {
- if v.PersUniID == aUniID {
- existingPath, ok := oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
- logger.Debugw(ctx, "PersUniConfig-entry exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID,
- "tpID": aTpID, "path": aPathString, "existingPath": existingPath, "ok": ok})
- if !ok {
- logger.Debugw(ctx, "tp-does-not-exist", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
- }
- if existingPath != aPathString {
- if aPathString == "" {
- //existing entry to be deleted
- logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
- oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
- } else {
- //existing entry to be modified
- logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
- oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
- }
- return true
- }
- //entry already exists
- if aPathString == "" {
- //no active TechProfile
- logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
- "device-id": oo.deviceID, "uniID": aUniID})
- } else {
- //the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
- //was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
- // (as here the TechProfile has not been removed with the disable-device before the new enable-device)
- logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
- "device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
- //no deviceReason update (deviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
- // (during which the flows are removed/re-assigned but the techProf is left active)
- //and as the TechProfile is regarded as active we have to verify, if some flow configuration still waits on it
- // (should not be the case, but should not harm or be more robust ...)
- // and to be sure, that for some reason the corresponding TpDelete was lost somewhere in history
- // we also reset a possibly outstanding delete request - repeated TpConfig is regarded as valid for waiting flow config
- if oo.baseDeviceHandler.pOnuTP != nil {
- oo.baseDeviceHandler.pOnuTP.setProfileToDelete(aUniID, aTpID, false)
- }
- go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID, aTpID)
- }
- return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
- }
- }
- //no entry exists for uniId
-
- if aPathString == "" {
- //delete request in non-existing state , accept as no change
- logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
- return false
- }
- //new entry to be created
- logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
- perSubTpPathMap := make(map[uint8]string)
- perSubTpPathMap[aTpID] = aPathString
- oo.sOnuPersistentData.PersUniConfig =
- append(oo.sOnuPersistentData.PersUniConfig, uniPersConfig{PersUniID: aUniID, PersTpPathMap: perSubTpPathMap, PersFlowParams: make([]uniVlanFlowParams, 0)})
- return true
-}
-
-func (oo *OnuDeviceEntry) updateOnuUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]uniVlanFlowParams) {
-
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
-
- for k, v := range oo.sOnuPersistentData.PersUniConfig {
- if v.PersUniID == aUniID {
- oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams = make([]uniVlanFlowParams, len(*aUniVlanFlowParams))
- copy(oo.sOnuPersistentData.PersUniConfig[k].PersFlowParams, *aUniVlanFlowParams)
- return
- }
- }
- //flow update was faster than tp-config - create PersUniConfig-entry
- //TODO!!: following activity to 'add' some new uni entry might not be quite correct if this function is called to clear the data
- // (e.g after flow removal from RemoveUniFlowParams()).
- // This has the effect of misleading indication that there is still some active UNI entry, even though there might be only some nil flow entry
- // The effect of this flaw is that at TechProfile removal there is an additional attempt to remove the entry even though no techProfile exists anymore
- // The code is not changed here because of the current release lane, changes might have unexpected secondary effects, perhaps later with more elaborate tests
- tmpConfig := uniPersConfig{PersUniID: aUniID, PersTpPathMap: make(map[uint8]string), PersFlowParams: make([]uniVlanFlowParams, len(*aUniVlanFlowParams))}
- copy(tmpConfig.PersFlowParams, *aUniVlanFlowParams)
- oo.sOnuPersistentData.PersUniConfig = append(oo.sOnuPersistentData.PersUniConfig, tmpConfig)
-}
-
-func (oo *OnuDeviceEntry) waitForTimeoutOrCompletion(
- ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
- select {
- case <-ctx.Done():
- logger.Warnw(ctx, "processing not completed in-time!",
- log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
- return false
- case rxStep := <-aChOnuProcessingStep:
- if rxStep == aProcessingStep {
- return true
- }
- //all other values are not accepted - including 0 for error indication
- logger.Warnw(ctx, "Invalid processing step received: abort!",
- log.Fields{"device-id": oo.deviceID,
- "wantedStep": aProcessingStep, "haveStep": rxStep})
- return false
- }
-}
-
-func (oo *OnuDeviceEntry) resetKvProcessingErrorIndication() {
- oo.mutexOnuKVStoreProcResult.Lock()
- oo.onuKVStoreProcResult = nil
- oo.mutexOnuKVStoreProcResult.Unlock()
-}
-
-func (oo *OnuDeviceEntry) getKvProcessingErrorIndication() error {
- oo.mutexOnuKVStoreProcResult.RLock()
- value := oo.onuKVStoreProcResult
- oo.mutexOnuKVStoreProcResult.RUnlock()
- return value
-}
-
-func (oo *OnuDeviceEntry) setKvProcessingErrorIndication(value error) {
- oo.mutexOnuKVStoreProcResult.Lock()
- oo.onuKVStoreProcResult = value
- oo.mutexOnuKVStoreProcResult.Unlock()
-}
-
-func (oo *OnuDeviceEntry) incrementMibDataSync(ctx context.Context) {
- oo.mutexPersOnuConfig.Lock()
- defer oo.mutexPersOnuConfig.Unlock()
- if oo.sOnuPersistentData.PersMibDataSyncAdpt < 255 {
- oo.sOnuPersistentData.PersMibDataSyncAdpt++
- } else {
- // per G.984 and G.988 overflow starts over at 1 given 0 is reserved for reset
- oo.sOnuPersistentData.PersMibDataSyncAdpt = 1
- }
- logger.Debugf(ctx, "mibDataSync updated - mds: %d - device-id: %s", oo.sOnuPersistentData.PersMibDataSyncAdpt, oo.deviceID)
-}
-
-func (oo *OnuDeviceEntry) modifySwImageInactiveVersion(ctx context.Context, aImageVersion string) {
- oo.mutexOnuSwImageIndications.Lock()
- defer oo.mutexOnuSwImageIndications.Unlock()
- logger.Debugw(ctx, "software-image set inactive version", log.Fields{
- "device-id": oo.deviceID, "version": aImageVersion})
- oo.onuSwImageIndications.inactiveEntityEntry.version = aImageVersion
- //inactive SW version is not part of persistency data (yet) - no need to update that
-}
-
-func (oo *OnuDeviceEntry) modifySwImageActiveCommit(ctx context.Context, aCommitted uint8) {
- oo.mutexOnuSwImageIndications.Lock()
- defer oo.mutexOnuSwImageIndications.Unlock()
- logger.Debugw(ctx, "software-image set active entity commit flag", log.Fields{
- "device-id": oo.deviceID, "committed": aCommitted})
- oo.onuSwImageIndications.activeEntityEntry.isCommitted = aCommitted
- //commit flag is not part of persistency data (yet) - no need to update that
-}
-
-func (oo *OnuDeviceEntry) getActiveImageVersion(ctx context.Context) string {
- oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.activeEntityEntry.valid {
- value := oo.onuSwImageIndications.activeEntityEntry.version
- oo.mutexOnuSwImageIndications.RUnlock()
- return value
- }
- oo.mutexOnuSwImageIndications.RUnlock()
- logger.Debugw(ctx, "Active Image is not valid", log.Fields{"device-id": oo.deviceID})
- return ""
-}
-
-func (oo *OnuDeviceEntry) getInactiveImageVersion(ctx context.Context) string {
- oo.mutexOnuSwImageIndications.RLock()
- if oo.onuSwImageIndications.inactiveEntityEntry.valid {
- value := oo.onuSwImageIndications.inactiveEntityEntry.version
- oo.mutexOnuSwImageIndications.RUnlock()
- return value
- }
- oo.mutexOnuSwImageIndications.RUnlock()
- logger.Debugw(ctx, "Inactive Image is not valid", log.Fields{"device-id": oo.deviceID})
- return ""
-}
-
-func (oo *OnuDeviceEntry) buildMibTemplatePath() string {
- oo.mutexPersOnuConfig.RLock()
- defer oo.mutexPersOnuConfig.RUnlock()
- return fmt.Sprintf(cSuffixMibTemplateKvStore, oo.sOnuPersistentData.PersVendorID, oo.sOnuPersistentData.PersEquipmentID, oo.sOnuPersistentData.PersActiveSwVersion)
-}
-
-func (oo *OnuDeviceEntry) allocateFreeTcont(ctx context.Context, allocID uint16) (uint16, bool, error) {
- logger.Debugw(ctx, "allocate-free-tcont", log.Fields{"device-id": oo.deviceID, "allocID": allocID,
- "allocated-instances": oo.sOnuPersistentData.PersTcontMap})
-
- oo.mutexTcontMap.Lock()
- defer oo.mutexTcontMap.Unlock()
- if entityID, ok := oo.sOnuPersistentData.PersTcontMap[allocID]; ok {
- //tcont already allocated before, return the used instance-id
- return entityID, true, nil
- }
- //First allocation of tcont. Find a free instance
- if tcontInstKeys := oo.pOnuDB.getSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
- logger.Debugw(ctx, "allocate-free-tcont-db-keys", log.Fields{"device-id": oo.deviceID, "keys": tcontInstKeys})
- for _, instID := range tcontInstKeys {
- instExist := false
- //If this instance exist in map, it means it is not empty. It is allocated before
- for _, v := range oo.sOnuPersistentData.PersTcontMap {
- if v == instID {
- instExist = true
- break
- }
- }
- if !instExist {
- oo.sOnuPersistentData.PersTcontMap[allocID] = instID
- return instID, false, nil
- }
- }
- }
- return 0, false, fmt.Errorf(fmt.Sprintf("no-free-tcont-left-for-device-%s", oo.deviceID))
-
-}
-
-func (oo *OnuDeviceEntry) freeTcont(ctx context.Context, allocID uint16) {
- logger.Debugw(ctx, "free-tcont", log.Fields{"device-id": oo.deviceID, "alloc": allocID})
- oo.mutexTcontMap.Lock()
- defer oo.mutexTcontMap.Unlock()
- delete(oo.sOnuPersistentData.PersTcontMap, allocID)
-}
diff --git a/internal/pkg/onuadaptercore/onu_uni_port.go b/internal/pkg/onuadaptercore/onu_uni_port.go
deleted file mode 100644
index f4b255f..0000000
--- a/internal/pkg/onuadaptercore/onu_uni_port.go
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * 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 (
- "context"
- "fmt"
- "strconv"
- "strings"
- "time"
-
- //"sync"
- //"time"
-
- //"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
- vc "github.com/opencord/voltha-protos/v5/go/common"
- of "github.com/opencord/voltha-protos/v5/go/openflow_13"
- "github.com/opencord/voltha-protos/v5/go/voltha"
-)
-
-type uniPortType uint8
-
-// UniPPTP Interface type - re-use values from G.988 (Chapter 9.3.4)TP type definition (directly used in OMCI!)
-const (
- // uniPPTP relates to PPTP
- uniPPTP uniPortType = 1 // relates to PPTP
- // uniVEIP relates to VEIP
- uniVEIP uniPortType = 11 // relates to VEIP
- // uniPPTPPots relates to PPTP POTS
- uniPPTPPots uniPortType = 4 // relates to IP host config data (for Voice Services)
-)
-
-//onuUniPort structure holds information about the ONU attached Uni Ports
-type onuUniPort struct {
- enabled bool
- name string
- portNo uint32
- portType uniPortType
- ofpPortNo string
- uniID uint8
- macBpNo uint8
- entityID uint16
- adminState vc.AdminState_Types
- operState vc.OperStatus_Types
- pPort *voltha.Port
-}
-
-//newOnuUniPort returns a new instance of a OnuUniPort
-func newOnuUniPort(ctx context.Context, aUniID uint8, aPortNo uint32, aInstNo uint16,
- aPortType uniPortType) *onuUniPort {
- logger.Infow(ctx, "init-onuUniPort", log.Fields{"uniID": aUniID,
- "portNo": aPortNo, "InstNo": aInstNo, "type": aPortType})
- var onuUniPort onuUniPort
- onuUniPort.enabled = false
- onuUniPort.name = "uni-" + strconv.FormatUint(uint64(aPortNo), 10)
- onuUniPort.portNo = aPortNo
- onuUniPort.portType = aPortType
- // so far it seems as here ofpPortNo/Name ist the same as the original port name ...??
- onuUniPort.ofpPortNo = onuUniPort.name
- onuUniPort.uniID = aUniID
- onuUniPort.macBpNo = aUniID + 1 //ensure >0 instanceNo
- onuUniPort.entityID = aInstNo
- onuUniPort.adminState = vc.AdminState_ENABLED //enabled per create
- onuUniPort.operState = vc.OperStatus_UNKNOWN
- onuUniPort.pPort = nil // to be set on create
- return &onuUniPort
-}
-
-//createVolthaPort creates the Voltha port based on ONU UNI Port and informs the core about it
-func (oo *onuUniPort) createVolthaPort(ctx context.Context, apDeviceHandler *deviceHandler) error {
- logger.Debugw(ctx, "creating-voltha-uni-port", log.Fields{
- "device-id": apDeviceHandler.device.Id, "portNo": oo.portNo})
- //200630: per [VOL-3202] OF port info is now to be delivered within UniPort create
- // not doing so crashes rw_core processing (at least still in 200630 version)
- name := apDeviceHandler.device.SerialNumber + "-" + strconv.FormatUint(uint64(oo.macBpNo), 10)
- var macOctets [6]uint8
- macOctets[5] = 0x08
- //ponPortNumber was copied from device.ParentPortNo
- macOctets[4] = uint8(apDeviceHandler.ponPortNumber >> 8)
- macOctets[3] = uint8(apDeviceHandler.ponPortNumber)
- macOctets[2] = uint8(oo.portNo >> 16)
- macOctets[1] = uint8(oo.portNo >> 8)
- macOctets[0] = uint8(oo.portNo)
- hwAddr := genMacFromOctets(macOctets)
- ofHwAddr := macAddressToUint32Array(hwAddr)
- capacity := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
- ofUniPortState := of.OfpPortState_OFPPS_LINK_DOWN
- /* as the VOLTHA port create is only called directly after Uni Port create
- the OfPortOperState is always Down
- Note: this way the OfPortOperState won't ever change (directly in adapter)
- maybe that was already always the case, but looks a bit weird - to be kept in mind ...
- if pUniPort.operState == vc.OperStatus_ACTIVE {
- ofUniPortState = of.OfpPortState_OFPPS_LIVE
- }
- */
- logger.Debugw(ctx, "ofPort values", log.Fields{
- "forUniPortName": oo.name, "forMacBase": hwAddr,
- "name": name, "hwAddr": ofHwAddr, "OperState": ofUniPortState})
-
- pUniPort := &voltha.Port{
- DeviceId: apDeviceHandler.deviceID,
- PortNo: oo.portNo,
- Label: oo.name,
- Type: voltha.Port_ETHERNET_UNI,
- AdminState: oo.adminState,
- OperStatus: oo.operState,
- // obviously empty peer setting
- OfpPort: &of.OfpPort{
- Name: name,
- HwAddr: ofHwAddr,
- Config: 0,
- State: uint32(ofUniPortState),
- Curr: capacity,
- Advertised: capacity,
- Peer: capacity,
- CurrSpeed: 1000,
- MaxSpeed: 1000,
- },
- }
- maxRetry := 3
- retryCnt := 0
- var err error
- for retryCnt = 0; retryCnt < maxRetry; retryCnt++ {
- if err = apDeviceHandler.createPortInCore(ctx, pUniPort); err != nil {
- logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s, retrying after a delay", err)
- // retry after a sleep
- time.Sleep(2 * time.Second)
- } else {
- // success, break from retry loop
- break
- }
- }
- if retryCnt == maxRetry { // maxed out..
- logger.Errorf(ctx, "Device FSM: PortCreated-failed-%s", err)
- return fmt.Errorf("device-fsm-port-create-failed-%s", err)
- }
- logger.Infow(ctx, "Voltha onuUniPort-added", log.Fields{
- "device-id": apDeviceHandler.device.Id, "PortNo": oo.portNo})
- oo.pPort = pUniPort
- oo.operState = vc.OperStatus_DISCOVERED
-
- return nil
-}
-
-//setOperState modifies OperState of the the UniPort
-func (oo *onuUniPort) setOperState(aNewOperState vc.OperStatus_Types) {
- oo.operState = aNewOperState
-}
-
-// uni port related utility functions (so far only used here)
-func genMacFromOctets(aOctets [6]uint8) string {
- return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
- aOctets[5], aOctets[4], aOctets[3],
- aOctets[2], aOctets[1], aOctets[0])
-}
-
-//copied from OLT Adapter: unify centrally ?
-func macAddressToUint32Array(mac string) []uint32 {
- slist := strings.Split(mac, ":")
- result := make([]uint32, len(slist))
- var err error
- var tmp int64
- for index, val := range slist {
- if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
- return []uint32{1, 2, 3, 4, 5, 6}
- }
- result[index] = uint32(tmp)
- }
- return result
-}
diff --git a/internal/pkg/onuadaptercore/openonu_utils.go b/internal/pkg/onuadaptercore/openonu_utils.go
deleted file mode 100644
index 51e5e81..0000000
--- a/internal/pkg/onuadaptercore/openonu_utils.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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 (
- "bytes"
- "encoding/binary"
- "errors"
- "fmt"
- "net"
- "regexp"
- "strconv"
- "strings"
-
- me "github.com/opencord/omci-lib-go/generated"
-)
-
-// GetTpIDFromTpPath extracts TpID from the TpPath.
-// On success it returns a valid TpID and nil error.
-// On failure it returns TpID as 0 and the error.
-func GetTpIDFromTpPath(tpPath string) (uint8, error) {
- // tpPath is of the format <technology>/<table_id>/olt-{}/pon-{}/onu-{}/uni-{}
- // A sample tpPath is ==> XGS-PON/64/olt-{12345abcd}/pon-{0}/onu-{1}/uni-{1}
- var tpPathFormat = regexp.MustCompile(`^[a-zA-Z\-_]+/[0-9]+/olt-{[a-z0-9\-]+}/pon-{[0-9]+}/onu-{[0-9]+}/uni-{[0-9]+}$`)
-
- // Ensure tpPath is of the format <technology>/<table_id>/<uni_port_name>
- if !tpPathFormat.Match([]byte(tpPath)) {
- return 0, errors.New("tp-path-not-confirming-to-format")
- }
- // Extract the TP table-id field.
- tpID, err := strconv.Atoi(strings.Split(tpPath, "/")[1])
- // Atoi returns uint64 and need to be type-casted to uint8 as tpID is uint8 size.
- return uint8(tpID), err
-}
-
-//IPToInt32 transforms an IP of net.Ip type to int32
-func IPToInt32(ip net.IP) uint32 {
- if len(ip) == 16 {
- return binary.BigEndian.Uint32(ip[12:16])
- }
- return binary.BigEndian.Uint32(ip)
-}
-
-//AsByteSlice transforms a string of manually set bits to a byt array
-func AsByteSlice(bitString string) []byte {
- var out []byte
- var str string
-
- for i := len(bitString); i > 0; i -= 8 {
- if i-8 < 0 {
- str = bitString[0:i]
- } else {
- str = bitString[i-8 : i]
- }
- v, err := strconv.ParseUint(str, 2, 8)
- if err != nil {
- panic(err)
- }
- out = append([]byte{byte(v)}, out...)
- }
- return out
-}
-
-// TwosComplementToSignedInt16 convert 2s complement to signed int16
-func TwosComplementToSignedInt16(val uint16) int16 {
- var uint16MsbMask uint16 = 0x8000
- if val&uint16MsbMask == uint16MsbMask {
- return int16(^val+1) * -1
- }
-
- return int16(val)
-}
-
-// TrimStringFromMeOctet trim string out of Me octet
-func TrimStringFromMeOctet(input interface{}) string {
- ifBytes, _ := me.InterfaceToOctets(input)
- return fmt.Sprintf("%s", bytes.Trim(ifBytes, "\x00"))
-}
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/pmmgr/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/pmmgr/common.go
index b0b10e3..5e49dda
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/pmmgr/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package pmmgr provides the utilities to manage onu metrics
+package pmmgr
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "pmmgr"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/onu_metrics_manager.go b/internal/pkg/pmmgr/onu_metrics_manager.go
old mode 100644
new mode 100755
similarity index 72%
rename from internal/pkg/onuadaptercore/onu_metrics_manager.go
rename to internal/pkg/pmmgr/onu_metrics_manager.go
index c2a2ffb..d3eaf0b
--- a/internal/pkg/onuadaptercore/onu_metrics_manager.go
+++ b/internal/pkg/pmmgr/onu_metrics_manager.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package pmmgr provides the utilities to manage onu metrics
+package pmmgr
import (
"context"
@@ -31,32 +31,35 @@
"github.com/opencord/voltha-lib-go/v7/pkg/db"
"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/extension"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
+// events of L2 PM FSM
const (
- // events of L2 PM FSM
- l2PmEventInit = "l2PmEventInit"
- l2PmEventTick = "l2PmEventTick"
- l2PmEventSuccess = "l2PmEventSuccess"
- l2PmEventFailure = "l2PmEventFailure"
- l2PmEventAddMe = "l2PmEventAddMe"
- l2PmEventDeleteMe = "l2PmEventDeleteMe"
- l2PmEventStop = "l2PmEventStop"
-)
-const (
- // states of L2 PM FSM
- l2PmStNull = "l2PmStNull"
- l2PmStStarting = "l2PmStStarting"
- l2PmStSyncTime = "l2PmStSyncTime"
- l2PmStIdle = "l2PmStIdle"
- l2PmStCreatePmMe = "l2PmStCreatePm"
- l2PmStDeletePmMe = "l2PmStDeletePmMe"
- l2PmStCollectData = "l2PmStCollectData"
+ L2PmEventInit = "L2PmEventInit"
+ L2PmEventTick = "L2PmEventTick"
+ L2PmEventSuccess = "L2PmEventSuccess"
+ L2PmEventFailure = "L2PmEventFailure"
+ L2PmEventAddMe = "L2PmEventAddMe"
+ L2PmEventDeleteMe = "L2PmEventDeleteMe"
+ L2PmEventStop = "L2PmEventStop"
)
-const cL2PmFsmIdleState = l2PmStIdle
+// states of L2 PM FSM
+const (
+ L2PmStNull = "L2PmStNull"
+ L2PmStStarting = "L2PmStStarting"
+ L2PmStSyncTime = "L2PmStSyncTime"
+ L2PmStIdle = "L2PmStIdle"
+ L2PmStCreatePmMe = "L2PmStCreatePm"
+ L2PmStDeletePmMe = "L2PmStDeletePmMe"
+ L2PmStCollectData = "L2PmStCollectData"
+)
+
+// CL2PmFsmIdleState - TODO: add comment
+const CL2PmFsmIdleState = L2PmStIdle
// general constants used for overall Metric Collection management
const (
@@ -275,25 +278,28 @@
type groupMetric struct {
groupName string
- enabled bool
- frequency uint32 // valid only if FrequencyOverride is enabled.
+ Enabled bool
+ Frequency uint32 // valid only if FrequencyOverride is enabled.
metricMap map[string]voltha.PmConfig_PmType
- nextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
- isL2PMCounter bool // true for only L2 PM counters
+ NextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
+ IsL2PMCounter bool // true for only L2 PM counters
collectAttempts uint32 // number of attempts to collect L2 PM data
pmMEData *pmMEData
}
type standaloneMetric struct {
metricName string
- enabled bool
- frequency uint32 // valid only if FrequencyOverride is enabled.
- nextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
+ Enabled bool
+ Frequency uint32 // valid only if FrequencyOverride is enabled.
+ NextCollectionInterval time.Time // valid only if FrequencyOverride is enabled.
}
-type onuMetricsManager struct {
- pDeviceHandler *deviceHandler
- pAdaptFsm *AdapterFsm
+// OnuMetricsManager - TODO: add comment
+type OnuMetricsManager struct {
+ deviceID string
+ pDeviceHandler cmn.IdeviceHandler
+ pOnuDeviceEntry cmn.IonuDeviceEntry
+ PAdaptFsm *cmn.AdapterFsm
opticalMetricsChan chan me.AttributeValueMap
uniStatusMetricsChan chan me.AttributeValueMap
@@ -307,18 +313,18 @@
l2PmToDelete []string // list of L2 PMs to delete
l2PmToAdd []string // list of L2 PM to add
- groupMetricMap map[string]*groupMetric
- standaloneMetricMap map[string]*standaloneMetric
+ GroupMetricMap map[string]*groupMetric
+ StandaloneMetricMap map[string]*standaloneMetric
- stopProcessingOmciResponses chan bool
+ StopProcessingOmciResponses chan bool
omciProcessingActive bool
- stopTicks chan bool
+ StopTicks chan bool
tickGenerationActive bool
- nextGlobalMetricCollectionTime time.Time // valid only if pmConfig.FreqOverride is set to false.
+ NextGlobalMetricCollectionTime time.Time // valid only if pmConfig.FreqOverride is set to false.
- onuMetricsManagerLock sync.RWMutex
+ OnuMetricsManagerLock sync.RWMutex
pmKvStore *db.Backend
@@ -330,20 +336,22 @@
isDeviceReadyToCollectExtendedPmStats bool
}
-// newonuMetricsManager returns a new instance of the newonuMetricsManager
+// NewOnuMetricsManager returns a new instance of the NewOnuMetricsManager
// The metrics manager module is responsible for configuration and management of individual and group metrics.
// Currently all the metrics are managed as a group which fall into two categories - L2 PM and "all others"
// The L2 PM counters have a fixed 15min interval for PM collection while all other group counters have
// the collection interval configurable.
// The global PM config is part of the voltha.Device struct and is backed up on KV store (by rw-core).
// This module also implements resiliency for L2 PM ME instances that are active/pending-delete/pending-add.
-func newonuMetricsManager(ctx context.Context, dh *deviceHandler) *onuMetricsManager {
+func NewOnuMetricsManager(ctx context.Context, dh cmn.IdeviceHandler, onuDev cmn.IonuDeviceEntry) *OnuMetricsManager {
- var metricsManager onuMetricsManager
- logger.Debugw(ctx, "init-onuMetricsManager", log.Fields{"device-id": dh.deviceID})
+ var metricsManager OnuMetricsManager
+ metricsManager.deviceID = dh.GetDeviceID()
+ logger.Debugw(ctx, "init-OnuMetricsManager", log.Fields{"device-id": metricsManager.deviceID})
metricsManager.pDeviceHandler = dh
+ metricsManager.pOnuDeviceEntry = onuDev
- commMetricsChan := make(chan Message)
+ commMetricsChan := make(chan cmn.Message)
metricsManager.opticalMetricsChan = make(chan me.AttributeValueMap)
metricsManager.uniStatusMetricsChan = make(chan me.AttributeValueMap)
metricsManager.l2PmChan = make(chan me.AttributeValueMap)
@@ -353,16 +361,16 @@
metricsManager.l2PmCreateOrDeleteResponseChan = make(chan bool)
metricsManager.extendedPMCreateOrDeleteResponseChan = make(chan me.Results)
- metricsManager.stopProcessingOmciResponses = make(chan bool)
- metricsManager.stopTicks = make(chan bool)
+ metricsManager.StopProcessingOmciResponses = make(chan bool)
+ metricsManager.StopTicks = make(chan bool)
- metricsManager.groupMetricMap = make(map[string]*groupMetric)
- metricsManager.standaloneMetricMap = make(map[string]*standaloneMetric)
+ metricsManager.GroupMetricMap = make(map[string]*groupMetric)
+ metricsManager.StandaloneMetricMap = make(map[string]*standaloneMetric)
metricsManager.ethernetFrameExtendedPmUpStreamMEByEntityID = make(map[uint16]*me.ManagedEntity)
metricsManager.ethernetFrameExtendedPmDownStreamMEByEntityID = make(map[uint16]*me.ManagedEntity)
- if dh.pmConfigs == nil { // dh.pmConfigs is NOT nil if adapter comes back from a restart. We should NOT go back to defaults in this case
+ if dh.GetPmConfigs() == nil { // dh.GetPmConfigs() is NOT nil if adapter comes back from a restart. We should NOT go back to defaults in this case
metricsManager.initializeAllGroupMetrics()
}
@@ -373,13 +381,13 @@
}
// initialize the next metric collection intervals.
- metricsManager.initializeMetricCollectionTime(ctx)
+ metricsManager.InitializeMetricCollectionTime(ctx)
- baseKvStorePath := fmt.Sprintf(cPmKvStorePrefix, dh.pOpenOnuAc.cm.Backend.PathPrefix, dh.deviceID)
- metricsManager.pmKvStore = dh.setBackend(ctx, baseKvStorePath)
+ baseKvStorePath := fmt.Sprintf(cPmKvStorePrefix, dh.GetBackendPathPrefix(), metricsManager.deviceID)
+ metricsManager.pmKvStore = dh.SetBackend(ctx, baseKvStorePath)
if metricsManager.pmKvStore == nil {
logger.Errorw(ctx, "Can't initialize pmKvStore - no backend connection to PM module",
- log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
+ log.Fields{"device-id": metricsManager.deviceID, "service": baseKvStorePath})
return nil
}
// restore data from KV store
@@ -390,55 +398,58 @@
// the actual PM config and what is present on the device).
}
- baseExtPmKvStorePath := fmt.Sprintf(cExtPmKvStorePrefix, dh.pOpenOnuAc.cm.Backend.PathPrefix)
- metricsManager.extPmKvStore = dh.setBackend(ctx, baseExtPmKvStorePath)
+ baseExtPmKvStorePath := fmt.Sprintf(cExtPmKvStorePrefix, dh.GetBackendPathPrefix())
+ metricsManager.extPmKvStore = dh.SetBackend(ctx, baseExtPmKvStorePath)
if metricsManager.extPmKvStore == nil {
logger.Errorw(ctx, "Can't initialize extPmKvStore - no backend connection to PM module",
- log.Fields{"device-id": dh.deviceID, "service": baseExtPmKvStorePath})
+ log.Fields{"device-id": metricsManager.deviceID, "service": baseExtPmKvStorePath})
return nil
}
- logger.Info(ctx, "init-onuMetricsManager completed", log.Fields{"device-id": dh.deviceID})
+ logger.Info(ctx, "init-OnuMetricsManager completed", log.Fields{"device-id": metricsManager.deviceID})
return &metricsManager
}
-func (mm *onuMetricsManager) initializeMetricCollectionTime(ctx context.Context) {
- if mm.pDeviceHandler.pmConfigs.FreqOverride {
- // If mm.pDeviceHandler.pmConfigs.FreqOverride is set to true, then group/standalone metric specific interval applies
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- for _, v := range mm.groupMetricMap {
- if v.enabled && !v.isL2PMCounter { // L2 PM counter collection is managed in a L2PmFsm
- v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+// InitializeMetricCollectionTime - TODO: add comment
+func (mm *OnuMetricsManager) InitializeMetricCollectionTime(ctx context.Context) {
+ if mm.pDeviceHandler.GetPmConfigs().FreqOverride {
+ // If mm.pDeviceHandler.GetPmConfigs().FreqOverride is set to true, then group/standalone metric specific interval applies
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ for _, v := range mm.GroupMetricMap {
+ if v.Enabled && !v.IsL2PMCounter { // L2 PM counter collection is managed in a L2PmFsm
+ v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
}
}
- for _, v := range mm.standaloneMetricMap {
- if v.enabled {
- v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+ for _, v := range mm.StandaloneMetricMap {
+ if v.Enabled {
+ v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
}
}
} else {
- // If mm.pDeviceHandler.pmConfigs.FreqOverride is set to false, then overall metric specific interval applies
- mm.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.pmConfigs.DefaultFreq) * time.Second)
+ // If mm.pDeviceHandler.GetPmConfigs().FreqOverride is set to false, then overall metric specific interval applies
+ mm.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.GetPmConfigs().DefaultFreq) * time.Second)
}
- logger.Infow(ctx, "initialized standalone group/metric collection time", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Infow(ctx, "initialized standalone group/metric collection time", log.Fields{"device-id": mm.deviceID})
}
-func (mm *onuMetricsManager) updateDefaultFrequency(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
+// UpdateDefaultFrequency - TODO: add comment
+func (mm *OnuMetricsManager) UpdateDefaultFrequency(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
// Verify that the configured DefaultFrequency is > 0 and is a multiple of FrequencyGranularity
if pmConfigs.DefaultFreq == 0 || (pmConfigs.DefaultFreq > 0 && pmConfigs.DefaultFreq%FrequencyGranularity != 0) {
logger.Errorf(ctx, "frequency-%u-should-be-a-multiple-of-%u", pmConfigs.DefaultFreq, FrequencyGranularity)
return fmt.Errorf("frequency-%d-should-be-a-multiple-of-%d", pmConfigs.DefaultFreq, FrequencyGranularity)
}
- mm.pDeviceHandler.pmConfigs.DefaultFreq = pmConfigs.DefaultFreq
- // re-set the nextGlobalMetricCollectionTime based on the new DefaultFreq
- mm.nextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.pmConfigs.DefaultFreq) * time.Second)
- logger.Debugw(ctx, "frequency-updated--new-frequency", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "frequency": mm.pDeviceHandler.pmConfigs.DefaultFreq})
+ mm.pDeviceHandler.GetPmConfigs().DefaultFreq = pmConfigs.DefaultFreq
+ // re-set the NextGlobalMetricCollectionTime based on the new DefaultFreq
+ mm.NextGlobalMetricCollectionTime = time.Now().Add(time.Duration(mm.pDeviceHandler.GetPmConfigs().DefaultFreq) * time.Second)
+ logger.Debugw(ctx, "frequency-updated--new-frequency", log.Fields{"device-id": mm.deviceID, "frequency": mm.pDeviceHandler.GetPmConfigs().DefaultFreq})
return nil
}
-func (mm *onuMetricsManager) updateGroupFreq(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateGroupFreq - TODO: add comment
+func (mm *OnuMetricsManager) UpdateGroupFreq(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
var newGroupFreq uint32
found := false
groupSliceIdx := 0
@@ -457,33 +468,34 @@
}
// if not found update group freq and next collection interval for the group
if !found {
- logger.Errorw(ctx, "group name not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+ logger.Errorw(ctx, "group name not found", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
return fmt.Errorf("group-name-not-found-%v", aGroupName)
}
updated := false
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- for k, v := range mm.groupMetricMap {
- if k == aGroupName && !v.isL2PMCounter { // We cannot allow the L2 PM counter frequency to be updated. It is 15min fixed by OMCI spec
- v.frequency = newGroupFreq
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ for k, v := range mm.GroupMetricMap {
+ if k == aGroupName && !v.IsL2PMCounter { // We cannot allow the L2 PM counter frequency to be updated. It is 15min fixed by OMCI spec
+ v.Frequency = newGroupFreq
// update internal pm config
- mm.pDeviceHandler.pmConfigs.Groups[groupSliceIdx].GroupFreq = newGroupFreq
+ mm.pDeviceHandler.GetPmConfigs().Groups[groupSliceIdx].GroupFreq = newGroupFreq
// Also updated the next group metric collection time from now
- v.nextCollectionInterval = time.Now().Add(time.Duration(newGroupFreq) * time.Second)
+ v.NextCollectionInterval = time.Now().Add(time.Duration(newGroupFreq) * time.Second)
updated = true
- logger.Infow(ctx, "group frequency updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
+ logger.Infow(ctx, "group frequency updated", log.Fields{"device-id": mm.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
break
}
}
if !updated {
- logger.Errorw(ctx, "group frequency not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
+ logger.Errorw(ctx, "group frequency not updated", log.Fields{"device-id": mm.deviceID, "newGroupFreq": newGroupFreq, "groupName": aGroupName})
return fmt.Errorf("internal-error-during-group-freq-update--groupname-%s-freq-%d", aGroupName, newGroupFreq)
}
return nil
}
-func (mm *onuMetricsManager) updateMetricFreq(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateMetricFreq - TODO: add comment
+func (mm *OnuMetricsManager) UpdateMetricFreq(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
var newMetricFreq uint32
found := false
metricSliceIdx := 0
@@ -501,33 +513,34 @@
}
}
if !found {
- logger.Errorw(ctx, "metric name not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+ logger.Errorw(ctx, "metric name not found", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
return fmt.Errorf("metric-name-not-found-%v", aMetricName)
}
updated := false
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- for k, v := range mm.groupMetricMap {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ for k, v := range mm.GroupMetricMap {
if k == aMetricName {
- v.frequency = newMetricFreq
+ v.Frequency = newMetricFreq
// update internal pm config
- mm.pDeviceHandler.pmConfigs.Metrics[metricSliceIdx].SampleFreq = newMetricFreq
+ mm.pDeviceHandler.GetPmConfigs().Metrics[metricSliceIdx].SampleFreq = newMetricFreq
// Also updated the next standalone metric collection time from now
- v.nextCollectionInterval = time.Now().Add(time.Duration(newMetricFreq) * time.Second)
+ v.NextCollectionInterval = time.Now().Add(time.Duration(newMetricFreq) * time.Second)
updated = true
- logger.Infow(ctx, "metric frequency updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
+ logger.Infow(ctx, "metric frequency updated", log.Fields{"device-id": mm.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
break
}
}
if !updated {
- logger.Errorw(ctx, "metric frequency not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
+ logger.Errorw(ctx, "metric frequency not updated", log.Fields{"device-id": mm.deviceID, "newMetricFreq": newMetricFreq, "aMetricName": aMetricName})
return fmt.Errorf("internal-error-during-standalone-metric-update--matricnane-%s-freq-%d", aMetricName, newMetricFreq)
}
return nil
}
-func (mm *onuMetricsManager) updateGroupSupport(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateGroupSupport - TODO: add comment
+func (mm *OnuMetricsManager) UpdateGroupSupport(ctx context.Context, aGroupName string, pmConfigs *voltha.PmConfigs) error {
groupSliceIdx := 0
var group *voltha.PmGroupConfig
@@ -537,19 +550,19 @@
}
}
if group == nil {
- logger.Errorw(ctx, "group metric not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+ logger.Errorw(ctx, "group metric not found", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
return fmt.Errorf("group-not-found--groupName-%s", aGroupName)
}
updated := false
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- for k, v := range mm.groupMetricMap {
- if k == aGroupName && v.enabled != group.Enabled {
- mm.pDeviceHandler.pmConfigs.Groups[groupSliceIdx].Enabled = group.Enabled
- v.enabled = group.Enabled
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ for k, v := range mm.GroupMetricMap {
+ if k == aGroupName && v.Enabled != group.Enabled {
+ mm.pDeviceHandler.GetPmConfigs().Groups[groupSliceIdx].Enabled = group.Enabled
+ v.Enabled = group.Enabled
if group.Enabled {
- if v.isL2PMCounter {
+ if v.IsL2PMCounter {
// If it is a L2 PM counter we need to mark the PM to be added
mm.l2PmToAdd = mm.appendIfMissingString(mm.l2PmToAdd, v.groupName)
// If the group support flag toggles too soon, we need to delete the group name from l2PmToDelete slice
@@ -561,11 +574,11 @@
if v.groupName == GemPortHistoryName {
mm.updateGemPortNTPInstanceToAddForPerfMonitoring(ctx)
}
- } else if mm.pDeviceHandler.pmConfigs.FreqOverride { // otherwise just update the next collection interval
- v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+ } else if mm.pDeviceHandler.GetPmConfigs().FreqOverride { // otherwise just update the next collection interval
+ v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
}
} else { // group counter is disabled
- if v.isL2PMCounter {
+ if v.IsL2PMCounter {
// If it is a L2 PM counter we need to mark the PM to be deleted
mm.l2PmToDelete = mm.appendIfMissingString(mm.l2PmToDelete, v.groupName)
// If the group support flag toggles too soon, we need to delete the group name from l2PmToAdd slice
@@ -580,24 +593,25 @@
}
}
updated = true
- if v.isL2PMCounter {
+ if v.IsL2PMCounter {
logger.Infow(ctx, "l2 pm group metric support updated",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName, "enabled": group.Enabled, "l2PmToAdd": mm.l2PmToAdd, "l2PmToDelete": mm.l2PmToDelete})
+ log.Fields{"device-id": mm.deviceID, "groupName": aGroupName, "enabled": group.Enabled, "l2PmToAdd": mm.l2PmToAdd, "l2PmToDelete": mm.l2PmToDelete})
} else {
- logger.Infow(ctx, "group metric support updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName, "enabled": group.Enabled})
+ logger.Infow(ctx, "group metric support updated", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName, "enabled": group.Enabled})
}
break
}
}
if !updated {
- logger.Errorw(ctx, "group metric support not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": aGroupName})
+ logger.Errorw(ctx, "group metric support not updated", log.Fields{"device-id": mm.deviceID, "groupName": aGroupName})
return fmt.Errorf("internal-error-during-group-support-update--groupName-%s", aGroupName)
}
return nil
}
-func (mm *onuMetricsManager) updateMetricSupport(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
+// UpdateMetricSupport - TODO: add comment
+func (mm *OnuMetricsManager) UpdateMetricSupport(ctx context.Context, aMetricName string, pmConfigs *voltha.PmConfigs) error {
metricSliceIdx := 0
var metric *voltha.PmConfig
@@ -608,48 +622,49 @@
}
if metric == nil {
- logger.Errorw(ctx, "standalone metric not found", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+ logger.Errorw(ctx, "standalone metric not found", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
return fmt.Errorf("metric-not-found--metricname-%s", aMetricName)
}
updated := false
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- for k, v := range mm.standaloneMetricMap {
- if k == aMetricName && v.enabled != metric.Enabled {
- mm.pDeviceHandler.pmConfigs.Metrics[metricSliceIdx].Enabled = metric.Enabled
- v.enabled = metric.Enabled
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ for k, v := range mm.StandaloneMetricMap {
+ if k == aMetricName && v.Enabled != metric.Enabled {
+ mm.pDeviceHandler.GetPmConfigs().Metrics[metricSliceIdx].Enabled = metric.Enabled
+ v.Enabled = metric.Enabled
// If the standalone metric is now enabled and frequency override is enabled, set the next metric collection time
- if metric.Enabled && mm.pDeviceHandler.pmConfigs.FreqOverride {
- v.nextCollectionInterval = time.Now().Add(time.Duration(v.frequency) * time.Second)
+ if metric.Enabled && mm.pDeviceHandler.GetPmConfigs().FreqOverride {
+ v.NextCollectionInterval = time.Now().Add(time.Duration(v.Frequency) * time.Second)
}
updated = true
- logger.Infow(ctx, "standalone metric support updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName, "enabled": metric.Enabled})
+ logger.Infow(ctx, "standalone metric support updated", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName, "enabled": metric.Enabled})
break
}
}
if !updated {
- logger.Errorw(ctx, "standalone metric support not updated", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": aMetricName})
+ logger.Errorw(ctx, "standalone metric support not updated", log.Fields{"device-id": mm.deviceID, "metricName": aMetricName})
return fmt.Errorf("internal-error-during-standalone-support-update--metricname-%s", aMetricName)
}
return nil
}
-func (mm *onuMetricsManager) collectAllGroupAndStandaloneMetrics(ctx context.Context) {
- if mm.pDeviceHandler.pmConfigs.Grouped { // metrics are managed as a group.
+// CollectAllGroupAndStandaloneMetrics - TODO: add comment
+func (mm *OnuMetricsManager) CollectAllGroupAndStandaloneMetrics(ctx context.Context) {
+ if mm.pDeviceHandler.GetPmConfigs().Grouped { // metrics are managed as a group.
go mm.collectAllGroupMetrics(ctx)
} else {
go mm.collectAllStandaloneMetrics(ctx)
}
}
-func (mm *onuMetricsManager) collectAllGroupMetrics(ctx context.Context) {
+func (mm *OnuMetricsManager) collectAllGroupMetrics(ctx context.Context) {
go func() {
logger.Debug(ctx, "startCollector before collecting optical metrics")
metricInfo, err := mm.collectOpticalMetrics(ctx)
if err != nil {
logger.Errorw(ctx, "collectOpticalMetrics failed",
- log.Fields{"device-id": mm.pAdaptFsm.deviceID, "Error": err})
+ log.Fields{"device-id": mm.deviceID, "Error": err})
return
}
if metricInfo != nil {
@@ -662,7 +677,7 @@
metricInfo, err := mm.collectUniStatusMetrics(ctx)
if err != nil {
logger.Errorw(ctx, "collectOpticalMetrics failed",
- log.Fields{"device-id": mm.pAdaptFsm.deviceID, "Error": err})
+ log.Fields{"device-id": mm.deviceID, "Error": err})
return
}
if metricInfo != nil {
@@ -673,11 +688,12 @@
// Add more here
}
-func (mm *onuMetricsManager) collectAllStandaloneMetrics(ctx context.Context) {
+func (mm *OnuMetricsManager) collectAllStandaloneMetrics(ctx context.Context) {
// None exists as of now, add when available here
}
-func (mm *onuMetricsManager) collectGroupMetric(ctx context.Context, groupName string) {
+// CollectGroupMetric - TODO: add comment
+func (mm *OnuMetricsManager) CollectGroupMetric(ctx context.Context, groupName string) {
switch groupName {
case OpticalPowerGroupMetricName:
go func() {
@@ -692,67 +708,68 @@
}
}()
default:
- logger.Errorw(ctx, "unhandled group metric name", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName})
+ logger.Errorw(ctx, "unhandled group metric name", log.Fields{"device-id": mm.deviceID, "groupName": groupName})
}
}
-func (mm *onuMetricsManager) collectStandaloneMetric(ctx context.Context, metricName string) {
+// CollectStandaloneMetric - TODO: add comment
+func (mm *OnuMetricsManager) CollectStandaloneMetric(ctx context.Context, metricName string) {
switch metricName {
// None exist as of now, add when available
default:
- logger.Errorw(ctx, "unhandled standalone metric name", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": metricName})
+ logger.Errorw(ctx, "unhandled standalone metric name", log.Fields{"device-id": mm.deviceID, "metricName": metricName})
}
}
// collectOpticalMetrics collects groups metrics related to optical power from ani-g ME.
-func (mm *onuMetricsManager) collectOpticalMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
- logger.Debugw(ctx, "collectOpticalMetrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) collectOpticalMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
+ logger.Debugw(ctx, "collectOpticalMetrics", log.Fields{"device-id": mm.deviceID})
- mm.onuMetricsManagerLock.RLock()
- if !mm.groupMetricMap[OpticalPowerGroupMetricName].enabled {
- mm.onuMetricsManagerLock.RUnlock()
- logger.Debugw(ctx, "optical power group metric is not enabled", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ mm.OnuMetricsManagerLock.RLock()
+ if !mm.GroupMetricMap[OpticalPowerGroupMetricName].Enabled {
+ mm.OnuMetricsManagerLock.RUnlock()
+ logger.Debugw(ctx, "optical power group metric is not enabled", log.Fields{"device-id": mm.deviceID})
return nil, nil
}
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
var metricInfoSlice []*voltha.MetricInformation
metricsContext := make(map[string]string)
- metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
- metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
- metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+ metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetProxyAddress().OnuId)
+ metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetProxyAddress().ChannelId)
+ metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
raisedTs := time.Now().Unix()
mmd := voltha.MetricMetaData{
Title: OpticalPowerGroupMetricName,
Ts: float64(raisedTs),
Context: metricsContext,
- DeviceId: mm.pDeviceHandler.deviceID,
- LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
- SerialNo: mm.pDeviceHandler.device.SerialNumber,
+ DeviceId: mm.deviceID,
+ LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+ SerialNo: mm.pDeviceHandler.GetDevice().SerialNumber,
}
// get the ANI-G instance IDs
- anigInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.AniGClassID)
+ anigInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.AniGClassID)
loop:
for _, anigInstID := range anigInstKeys {
var meAttributes me.AttributeValueMap
opticalMetrics := make(map[string]float32)
// Get the ANI-G instance optical power attributes
requestedAttributes := me.AttributeValueMap{"OpticalSignalLevel": 0, "TransmitOpticalLevel": 0}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.AniGClassID, anigInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.AniGClassID, anigInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return nil, err
}
if meInstance != nil {
select {
case meAttributes = <-mm.opticalMetricsChan:
- logger.Debugw(ctx, "received optical metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
- logger.Errorw(ctx, "timeout waiting for omci-get response for optical metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "received optical metrics", log.Fields{"device-id": mm.deviceID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+ logger.Errorw(ctx, "timeout waiting for omci-get response for optical metrics", log.Fields{"device-id": mm.deviceID})
// The metrics will be empty in this case
break loop
}
@@ -765,11 +782,11 @@
}
case "transmit_power_dBm":
if val, ok := meAttributes["TransmitOpticalLevel"]; ok && val != nil {
- opticalMetrics[k] = float32(math.Round((float64(TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
+ opticalMetrics[k] = float32(math.Round((float64(cmn.TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
}
case "receive_power_dBm":
if val, ok := meAttributes["OpticalSignalLevel"]; ok && val != nil {
- opticalMetrics[k] = float32(math.Round((float64(TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
+ opticalMetrics[k] = float32(math.Round((float64(cmn.TwosComplementToSignedInt16(val.(uint16)))/500.0)*10) / 10) // convert to dBm rounded of to single decimal place
}
default:
// do nothing
@@ -787,34 +804,34 @@
// collectUniStatusMetrics collects UNI status group metric from various MEs (uni-g, pptp and veip).
// nolint: gocyclo
-func (mm *onuMetricsManager) collectUniStatusMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
- logger.Debugw(ctx, "collectUniStatusMetrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- mm.onuMetricsManagerLock.RLock()
- if !mm.groupMetricMap[UniStatusGroupMetricName].enabled {
- mm.onuMetricsManagerLock.RUnlock()
- logger.Debugw(ctx, "uni status group metric is not enabled", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) collectUniStatusMetrics(ctx context.Context) ([]*voltha.MetricInformation, error) {
+ logger.Debugw(ctx, "collectUniStatusMetrics", log.Fields{"device-id": mm.deviceID})
+ mm.OnuMetricsManagerLock.RLock()
+ if !mm.GroupMetricMap[UniStatusGroupMetricName].Enabled {
+ mm.OnuMetricsManagerLock.RUnlock()
+ logger.Debugw(ctx, "uni status group metric is not enabled", log.Fields{"device-id": mm.deviceID})
return nil, nil
}
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
var metricInfoSlice []*voltha.MetricInformation
metricsContext := make(map[string]string)
- metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
- metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
- metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+ metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.OnuId)
+ metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.ChannelId)
+ metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
raisedTs := time.Now().Unix()
mmd := voltha.MetricMetaData{
Title: UniStatusGroupMetricName,
Ts: float64(raisedTs),
Context: metricsContext,
- DeviceId: mm.pDeviceHandler.deviceID,
- LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
- SerialNo: mm.pDeviceHandler.device.SerialNumber,
+ DeviceId: mm.deviceID,
+ LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+ SerialNo: mm.pDeviceHandler.GetDevice().SerialNumber,
}
// get the UNI-G instance IDs
- unigInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.UniGClassID)
+ unigInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.UniGClassID)
loop1:
for _, unigInstID := range unigInstKeys {
// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -823,19 +840,19 @@
var meAttributes me.AttributeValueMap
// Get the UNI-G instance optical power attributes
requestedAttributes := me.AttributeValueMap{"AdministrativeState": 0}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.UniGClassID, unigInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.UniGClassID, unigInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "UNI-G failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ logger.Errorw(ctx, "UNI-G failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return nil, err
}
if meInstance != nil {
// Wait for metrics or timeout
select {
case meAttributes = <-mm.uniStatusMetricsChan:
- logger.Debugw(ctx, "received uni-g metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
- logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "received uni-g metrics", log.Fields{"device-id": mm.deviceID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+ logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
// The metrics could be empty in this case
break loop1
}
@@ -854,9 +871,9 @@
entityID := val.(uint16)
unigMetrics["entity_id"] = float32(entityID)
// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
- for _, uni := range mm.pDeviceHandler.uniEntityMap {
- if uni.entityID == entityID {
- unigMetrics["uni_port_no"] = float32(uni.portNo)
+ for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+ if uni.EntityID == entityID {
+ unigMetrics["uni_port_no"] = float32(uni.PortNo)
break
}
}
@@ -870,7 +887,7 @@
}
// get the PPTP instance IDs
- pptpInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.PhysicalPathTerminationPointEthernetUniClassID)
+ pptpInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.PhysicalPathTerminationPointEthernetUniClassID)
loop2:
for _, pptpInstID := range pptpInstKeys {
// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -879,19 +896,19 @@
pptpMetrics := make(map[string]float32)
requestedAttributes := me.AttributeValueMap{"ConfigurationInd": 0, "OperationalState": 0, "AdministrativeState": 0}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, pptpInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, pptpInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return nil, err
}
if meInstance != nil {
// Wait for metrics or timeout
select {
case meAttributes = <-mm.uniStatusMetricsChan:
- logger.Debugw(ctx, "received pptp metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
- logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "received pptp metrics", log.Fields{"device-id": mm.deviceID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+ logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
// The metrics could be empty in this case
break loop2
}
@@ -920,9 +937,9 @@
entityID := val.(uint16)
pptpMetrics["entity_id"] = float32(entityID)
// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
- for _, uni := range mm.pDeviceHandler.uniEntityMap {
- if uni.entityID == entityID {
- pptpMetrics["uni_port_no"] = float32(uni.portNo)
+ for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+ if uni.EntityID == entityID {
+ pptpMetrics["uni_port_no"] = float32(uni.PortNo)
break
}
}
@@ -935,7 +952,7 @@
}
// get the VEIP instance IDs
- veipInstKeys := mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.VirtualEthernetInterfacePointClassID)
+ veipInstKeys := mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.VirtualEthernetInterfacePointClassID)
loop3:
for _, veipInstID := range veipInstKeys {
// TODO: Include additional information in the voltha.MetricMetaData - like portno, uni-id, instance-id
@@ -944,19 +961,19 @@
veipMetrics := make(map[string]float32)
requestedAttributes := me.AttributeValueMap{"OperationalState": 0, "AdministrativeState": 0}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, me.VirtualEthernetInterfacePointClassID, veipInstID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, me.VirtualEthernetInterfacePointClassID, veipInstID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return nil, err
}
if meInstance != nil {
// Wait for metrics or timeout
select {
case meAttributes = <-mm.uniStatusMetricsChan:
- logger.Debugw(ctx, "received veip metrics", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
- logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "received veip metrics", log.Fields{"device-id": mm.deviceID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+ logger.Errorw(ctx, "timeout waiting for omci-get response for uni status", log.Fields{"device-id": mm.deviceID})
// The metrics could be empty in this case
break loop3
}
@@ -982,9 +999,9 @@
entityID := val.(uint16)
veipMetrics["entity_id"] = float32(entityID)
// TODO: Rlock needed for reading uniEntityMap? May not be needed given uniEntityMap is populated setup at initial ONU bring up
- for _, uni := range mm.pDeviceHandler.uniEntityMap {
- if uni.entityID == entityID {
- veipMetrics["uni_port_no"] = float32(uni.portNo)
+ for _, uni := range *mm.pDeviceHandler.GetUniEntityMap() {
+ if uni.EntityID == entityID {
+ veipMetrics["uni_port_no"] = float32(uni.PortNo)
break
}
}
@@ -1000,53 +1017,54 @@
}
// publishMetrics publishes the metrics on kafka
-func (mm *onuMetricsManager) publishMetrics(ctx context.Context, metricInfo []*voltha.MetricInformation) {
+func (mm *OnuMetricsManager) publishMetrics(ctx context.Context, metricInfo []*voltha.MetricInformation) {
var ke voltha.KpiEvent2
ts := time.Now().Unix()
ke.SliceData = metricInfo
ke.Type = voltha.KpiEventType_slice
ke.Ts = float64(ts)
- if err := mm.pDeviceHandler.EventProxy.SendKpiEvent(ctx, "STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, ts); err != nil {
+ if err := mm.pDeviceHandler.GetEventProxy().SendKpiEvent(ctx, "STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, voltha.EventSubCategory_ONU, ts); err != nil {
logger.Errorw(ctx, "failed-to-send-pon-stats", log.Fields{"err": err})
}
}
-func (mm *onuMetricsManager) processOmciMessages(ctx context.Context) {
- logger.Infow(ctx, "Start routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+// ProcessOmciMessages - TODO: add comment
+func (mm *OnuMetricsManager) ProcessOmciMessages(ctx context.Context) {
+ logger.Infow(ctx, "Start routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.deviceID})
// Flush metric collection channels to be safe.
- // It is possible that there is stale data on this channel if the processOmciMessages routine
+ // It is possible that there is stale data on this channel if the ProcessOmciMessages routine
// is stopped right after issuing a OMCI-GET request and started again.
- // The processOmciMessages routine will get stopped if startCollector routine (in device_handler.go)
+ // The ProcessOmciMessages routine will get stopped if startCollector routine (in device_handler.go)
// is stopped - as a result of ONU going down.
mm.flushMetricCollectionChannels(ctx)
mm.updateOmciProcessingStatus(true)
for {
select {
- case <-mm.stopProcessingOmciResponses: // stop this routine
- logger.Infow(ctx, "Stop routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ case <-mm.StopProcessingOmciResponses: // stop this routine
+ logger.Infow(ctx, "Stop routine to process OMCI-GET messages for device-id", log.Fields{"device-id": mm.deviceID})
mm.updateOmciProcessingStatus(false)
return
- case message, ok := <-mm.pAdaptFsm.commChan:
+ case message, ok := <-mm.PAdaptFsm.CommChan:
if !ok {
- logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "Message couldn't be read from channel", log.Fields{"device-id": mm.deviceID})
continue
}
- logger.Debugw(ctx, "Received message on ONU metrics channel", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "Received message on ONU metrics channel", log.Fields{"device-id": mm.deviceID})
switch message.Type {
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
mm.handleOmciMessage(ctx, msg)
default:
- logger.Warn(ctx, "Unknown message type received", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "message.Type": message.Type})
+ logger.Warn(ctx, "Unknown message type received", log.Fields{"device-id": mm.deviceID, "message.Type": message.Type})
}
}
}
}
-func (mm *onuMetricsManager) handleOmciMessage(ctx context.Context, msg OmciMessage) {
- logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+func (mm *OnuMetricsManager) handleOmciMessage(ctx context.Context, msg cmn.OmciMessage) {
+ logger.Debugw(ctx, "omci Msg", log.Fields{"device-id": mm.deviceID,
"msgType": msg.OmciMsg.MessageType, "msg": msg})
switch msg.OmciMsg.MessageType {
case omci.GetResponseType:
@@ -1066,18 +1084,18 @@
}
}
-func (mm *onuMetricsManager) handleOmciGetResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciGetResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling stopped: %s", mm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.GetResponse)
if !msgOk {
- logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling stopped: %s", mm.deviceID)
}
- logger.Debugw(ctx, "OMCI GetResponse Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj, "result": msgObj.Result})
+ logger.Debugw(ctx, "OMCI GetResponse Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj, "result": msgObj.Result})
if msgObj.Result == me.Success {
meAttributes := msgObj.Attributes
switch msgObj.EntityClass {
@@ -1106,7 +1124,7 @@
return nil
default:
logger.Errorw(ctx, "unhandled omci get response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
} else {
meAttributes := msgObj.Attributes
@@ -1119,24 +1137,24 @@
return nil
default:
logger.Errorw(ctx, "unhandled omci get response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
}
return fmt.Errorf("unhandled-omci-get-response-message")
}
-func (mm *onuMetricsManager) handleOmciGetCurrentDataResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciGetCurrentDataResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetCurrentDataResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be detected for GetCurrentDataResponse - handling stopped: %s", mm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.GetCurrentDataResponse)
if !msgOk {
- logger.Errorw(ctx, "omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be assigned for GetCurrentDataResponse - handling stopped: %s", mm.deviceID)
}
- logger.Debugw(ctx, "OMCI GetCurrentDataResponse Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj, "result": msgObj.Result})
+ logger.Debugw(ctx, "OMCI GetCurrentDataResponse Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj, "result": msgObj.Result})
if msgObj.Result == me.Success {
meAttributes := msgObj.Attributes
switch msgObj.EntityClass {
@@ -1146,7 +1164,7 @@
return nil
default:
logger.Errorw(ctx, "unhandled omci get current data response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
} else {
meAttributes := msgObj.Attributes
@@ -1159,33 +1177,33 @@
return nil
default:
logger.Errorw(ctx, "unhandled omci get current data response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
}
return fmt.Errorf("unhandled-omci-get-current-data-response-message")
}
-func (mm *onuMetricsManager) handleOmciSynchronizeTimeResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciSynchronizeTimeResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSynchronizeTimeResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci Msg layer could not be detected for synchronize time response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be detected for synchronize time response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be detected for synchronize time response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be detected for synchronize time response - handling stopped: %s", mm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.SynchronizeTimeResponse)
if !msgOk {
- logger.Errorw(ctx, "omci Msg layer could not be assigned for synchronize time response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be assigned for synchronize time response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for synchronize time response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be assigned for synchronize time response - handling stopped: %s", mm.deviceID)
}
- logger.Debugw(ctx, "OMCI synchronize time response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "OMCI synchronize time response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
if msgObj.Result == me.Success {
switch msgObj.EntityClass {
case me.OnuGClassID:
- logger.Infow(ctx, "omci synchronize time success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Infow(ctx, "omci synchronize time success", log.Fields{"device-id": mm.deviceID})
mm.syncTimeResponseChan <- true
return nil
default:
logger.Errorw(ctx, "unhandled omci message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
}
mm.syncTimeResponseChan <- false
@@ -1194,10 +1212,10 @@
}
// flushMetricCollectionChannels flushes all metric collection channels for any stale OMCI responses
-func (mm *onuMetricsManager) flushMetricCollectionChannels(ctx context.Context) {
+func (mm *OnuMetricsManager) flushMetricCollectionChannels(ctx context.Context) {
// flush commMetricsChan
select {
- case <-mm.pAdaptFsm.commChan:
+ case <-mm.PAdaptFsm.CommChan:
logger.Debug(ctx, "flushed common metrics channel")
default:
}
@@ -1230,10 +1248,10 @@
default:
}
- // flush stopTicks
+ // flush StopTicks
select {
- case <-mm.stopTicks:
- logger.Debug(ctx, "flushed stopTicks channel")
+ case <-mm.StopTicks:
+ logger.Debug(ctx, "flushed StopTicks channel")
default:
}
@@ -1241,17 +1259,17 @@
// ** L2 PM FSM Handlers start **
-func (mm *onuMetricsManager) l2PMFsmStarting(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmStarting(ctx context.Context, e *fsm.Event) {
// Loop through all the group metrics
// If it is a L2 PM Interval metric and it is enabled, then if it is not in the
// list of active L2 PM list then mark it for creation
// It it is a L2 PM Interval metric and it is disabled, then if it is in the
// list of active L2 PM list then mark it for deletion
- mm.onuMetricsManagerLock.Lock()
- for n, g := range mm.groupMetricMap {
- if g.isL2PMCounter { // it is a l2 pm counter
- if g.enabled { // metric enabled.
+ mm.OnuMetricsManagerLock.Lock()
+ for n, g := range mm.GroupMetricMap {
+ if g.IsL2PMCounter { // it is a l2 pm counter
+ if g.Enabled { // metric enabled.
found := false
inner1:
for _, v := range mm.activeL2Pms {
@@ -1278,25 +1296,25 @@
}
}
}
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
logger.Debugw(ctx, "pms to add and delete",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": mm.l2PmToAdd, "pms-to-delete": mm.l2PmToDelete})
+ log.Fields{"device-id": mm.deviceID, "pms-to-add": mm.l2PmToAdd, "pms-to-delete": mm.l2PmToDelete})
go func() {
// push a tick event to move to next state
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventTick); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventTick); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
-func (mm *onuMetricsManager) l2PMFsmSyncTime(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmSyncTime(ctx context.Context, e *fsm.Event) {
// Sync time with the ONU to establish 15min boundary for PM collection.
if err := mm.syncTime(ctx); err != nil {
go func() {
time.Sleep(SyncTimeRetryInterval * time.Second) // retry to sync time after this timeout
// This will result in FSM attempting to sync time again
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventFailure); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventFailure); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
@@ -1304,71 +1322,71 @@
go mm.generateTicks(ctx)
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
-func (mm *onuMetricsManager) l2PMFsmNull(ctx context.Context, e *fsm.Event) {
+func (mm *OnuMetricsManager) l2PMFsmNull(ctx context.Context, e *fsm.Event) {
// We need to reset the local data so that the L2 PM MEs are re-provisioned once the ONU is back up based on the latest PM CONFIG
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
mm.activeL2Pms = nil
mm.l2PmToAdd = nil
mm.l2PmToDelete = nil
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
// If the FSM was stopped, then clear PM data from KV store
// The FSM is stopped when ONU goes down. It is time to clear its data from store
- if e.Event == l2PmEventStop {
+ if e.Event == L2PmEventStop {
_ = mm.clearPmGroupData(ctx) // ignore error
}
}
-func (mm *onuMetricsManager) l2PMFsmIdle(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "Enter state idle", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) l2PMFsmIdle(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "Enter state idle", log.Fields{"device-id": mm.deviceID})
- mm.onuMetricsManagerLock.RLock()
+ mm.OnuMetricsManagerLock.RLock()
numOfPmToDelete := len(mm.l2PmToDelete)
numOfPmToAdd := len(mm.l2PmToAdd)
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
if numOfPmToDelete > 0 {
- logger.Debugw(ctx, "state idle - pms to delete", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": numOfPmToDelete})
+ logger.Debugw(ctx, "state idle - pms to delete", log.Fields{"device-id": mm.deviceID, "pms-to-delete": numOfPmToDelete})
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventDeleteMe); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventDeleteMe); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
} else if numOfPmToAdd > 0 {
- logger.Debugw(ctx, "state idle - pms to add", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": numOfPmToAdd})
+ logger.Debugw(ctx, "state idle - pms to add", log.Fields{"device-id": mm.deviceID, "pms-to-add": numOfPmToAdd})
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventAddMe); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventAddMe); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
}
-func (mm *onuMetricsManager) l2PmFsmCollectData(ctx context.Context, e *fsm.Event) {
- logger.Debugw(ctx, "state collect data", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) l2PmFsmCollectData(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "state collect data", log.Fields{"device-id": mm.deviceID})
// Copy the activeL2Pms for which we want to collect the metrics since activeL2Pms can change dynamically
- mm.onuMetricsManagerLock.RLock()
+ mm.OnuMetricsManagerLock.RLock()
copyOfActiveL2Pms := make([]string, len(mm.activeL2Pms))
_ = copy(copyOfActiveL2Pms, mm.activeL2Pms)
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
for _, n := range copyOfActiveL2Pms {
var metricInfoSlice []*voltha.MetricInformation
- // mm.groupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
- mm.onuMetricsManagerLock.RLock()
- copyOfEntityIDs := make([]uint16, len(mm.groupMetricMap[n].pmMEData.InstancesActive))
- _ = copy(copyOfEntityIDs, mm.groupMetricMap[n].pmMEData.InstancesActive)
- mm.onuMetricsManagerLock.RUnlock()
+ // mm.GroupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
+ mm.OnuMetricsManagerLock.RLock()
+ copyOfEntityIDs := make([]uint16, len(mm.GroupMetricMap[n].pmMEData.InstancesActive))
+ _ = copy(copyOfEntityIDs, mm.GroupMetricMap[n].pmMEData.InstancesActive)
+ mm.OnuMetricsManagerLock.RUnlock()
switch n {
case EthernetBridgeHistoryName:
- logger.Debugw(ctx, "state collect data - collecting data for EthernetFramePerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "state collect data - collecting data for EthernetFramePerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.deviceID})
for _, entityID := range copyOfEntityIDs {
if metricInfo := mm.collectEthernetFramePerformanceMonitoringHistoryData(ctx, true, entityID); metricInfo != nil { // upstream
metricInfoSlice = append(metricInfoSlice, metricInfo)
@@ -1378,7 +1396,7 @@
}
}
case EthernetUniHistoryName:
- logger.Debugw(ctx, "state collect data - collecting data for EthernetPerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "state collect data - collecting data for EthernetPerformanceMonitoringHistoryData ME", log.Fields{"device-id": mm.deviceID})
for _, entityID := range copyOfEntityIDs {
if metricInfo := mm.collectEthernetUniHistoryData(ctx, entityID); metricInfo != nil { // upstream
metricInfoSlice = append(metricInfoSlice, metricInfo)
@@ -1399,7 +1417,7 @@
}
default:
- logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+ logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
}
mm.handleMetricsPublish(ctx, n, metricInfoSlice)
}
@@ -1407,21 +1425,21 @@
// Those PMs that we failed to collect data will be attempted to collect again in the next PM collection cycle (assuming
// we have not exceed max attempts to collect the PM data)
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
// nolint: gocyclo
-func (mm *onuMetricsManager) l2PmFsmCreatePM(ctx context.Context, e *fsm.Event) error {
+func (mm *OnuMetricsManager) l2PmFsmCreatePM(ctx context.Context, e *fsm.Event) error {
// Copy the l2PmToAdd for which we want to collect the metrics since l2PmToAdd can change dynamically
- mm.onuMetricsManagerLock.RLock()
+ mm.OnuMetricsManagerLock.RLock()
copyOfL2PmToAdd := make([]string, len(mm.l2PmToAdd))
_ = copy(copyOfL2PmToAdd, mm.l2PmToAdd)
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
- logger.Debugw(ctx, "state create pm - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": copyOfL2PmToAdd})
+ logger.Debugw(ctx, "state create pm - start", log.Fields{"device-id": mm.deviceID, "pms-to-add": copyOfL2PmToAdd})
for _, n := range copyOfL2PmToAdd {
resp := false
atLeastOneSuccess := false // flag indicates if at least one ME instance of the PM was successfully created.
@@ -1430,26 +1448,26 @@
case EthernetBridgeHistoryName:
// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
for _, direction := range []bool{true, false} {
- for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
+ for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
// Attach the EthernetFramePerformanceMonitoringHistoryData ME to MacBridgePortConfigData on the UNI port
- entityID := macBridgePortAniBaseEID + uniPort.entityID
+ entityID := cmn.MacBridgePortAniBaseEID + uniPort.EntityID
_ = mm.updatePmData(ctx, n, entityID, cPmAdd) // TODO: ignore error for now
inner1:
// retry L2PmCreateAttempts times to create the instance of PM
for cnt = 0; cnt < L2PmCreateAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, true, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, true, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "EthernetPerformanceMonitoringHistoryME create or delete failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- pPMFsm := mm.pAdaptFsm
+ log.Fields{"device-id": mm.deviceID})
+ pPMFsm := mm.PAdaptFsm
if pPMFsm != nil {
- go func(p_pmFsm *AdapterFsm) {
- _ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+ go func(p_pmFsm *cmn.AdapterFsm) {
+ _ = p_pmFsm.PFsm.Event(L2PmEventFailure)
}(pPMFsm)
}
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetPerformanceMonitoringHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
if resp = mm.waitForResponseOrTimeout(ctx, true, entityID, "EthernetFramePerformanceMonitoringHistoryData"); resp {
atLeastOneSuccess = true
@@ -1463,22 +1481,22 @@
}
}
case EthernetUniHistoryName:
- for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
- if uniPort.portType == uniPPTP { // This metric is only applicable for PPTP Uni Type
+ for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
+ if uniPort.PortType == cmn.UniPPTP { // This metric is only applicable for PPTP Uni Type
// Attach the EthernetPerformanceMonitoringHistoryData ME to PPTP port instance
- entityID := uniPort.entityID
+ entityID := uniPort.EntityID
_ = mm.updatePmData(ctx, n, entityID, cPmAdd) // TODO: ignore error for now
inner2:
// retry L2PmCreateAttempts times to create the instance of PM
for cnt = 0; cnt < L2PmCreateAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetUniHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetUniHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteEthernetUNIHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetUniHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
if resp = mm.waitForResponseOrTimeout(ctx, true, entityID, "EthernetPerformanceMonitoringHistoryData"); resp {
atLeastOneSuccess = true
@@ -1492,16 +1510,16 @@
}
}
case FecHistoryName:
- for _, anigInstID := range mm.pDeviceHandler.pOnuOmciDevice.pOnuDB.getSortedInstKeys(ctx, me.AniGClassID) {
+ for _, anigInstID := range mm.pOnuDeviceEntry.GetOnuDB().GetSortedInstKeys(ctx, me.AniGClassID) {
// Attach the FecPerformanceMonitoringHistoryData ME to the ANI-G ME instance
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteFecHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, anigInstID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteFecHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, anigInstID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteFecHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteFecHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
_ = mm.updatePmData(ctx, n, anigInstID, cPmAdd) // TODO: ignore error for now
inner3:
@@ -1519,30 +1537,30 @@
}
case GemPortHistoryName:
- mm.onuMetricsManagerLock.RLock()
- copyOfGemPortInstIDsToAdd := make([]uint16, len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd))
- _ = copy(copyOfGemPortInstIDsToAdd, mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd)
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RLock()
+ copyOfGemPortInstIDsToAdd := make([]uint16, len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd))
+ _ = copy(copyOfGemPortInstIDsToAdd, mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd)
+ mm.OnuMetricsManagerLock.RUnlock()
if len(copyOfGemPortInstIDsToAdd) == 0 {
// If there are no gemport history MEs to be created, just skip further processing
// Otherwise down below (after 'switch' case handling) we assume the ME creation failed because resp and atLeastOneSuccess flag are false.
// Normally there are no GemPortHistory MEs to create at start up. They come in only after provisioning service on the ONU.
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
continue
}
for _, v := range copyOfGemPortInstIDsToAdd {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteGemPortHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, true, mm.pAdaptFsm.commChan, v)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteGemPortHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, true, mm.PAdaptFsm.CommChan, v)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteGemPortHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteGemPortHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
_ = mm.updatePmData(ctx, n, v, cPmAdd) // TODO: ignore error for now
inner4:
@@ -1560,77 +1578,77 @@
}
default:
- logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+ logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
}
// On success of at least one instance of the PM for a given ME, update the local list maintained for active PMs and PMs to add
if atLeastOneSuccess {
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
mm.activeL2Pms = mm.appendIfMissingString(mm.activeL2Pms, n)
// gem ports can be added dynamically for perf monitoring. We want to clear the GemPortHistoryName from mm.l2PmToAdd
// only if no more new gem port instances created.
- if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd) == 0) {
+ if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd) == 0) {
mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
}
logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
} else {
// If we are here then no instance of the PM of the given ME were created successfully, so locally disable the PM
// and also remove it from l2PmToAdd slice so that we do not try to create the PM ME anymore
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
logger.Debugw(ctx, "exceeded-max-add-retry-attempts--disabling-group", log.Fields{"groupName": n})
- mm.groupMetricMap[n].enabled = false
+ mm.GroupMetricMap[n].Enabled = false
mm.l2PmToAdd = mm.removeIfFoundString(mm.l2PmToAdd, n)
logger.Warnw(ctx, "state create pm - failed to create pm",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n,
+ log.Fields{"device-id": mm.deviceID, "metricName": n,
"active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
}
}
- mm.onuMetricsManagerLock.RLock()
- logger.Debugw(ctx, "state create pm - done", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RLock()
+ logger.Debugw(ctx, "state create pm - done", log.Fields{"device-id": mm.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-add": mm.l2PmToAdd})
+ mm.OnuMetricsManagerLock.RUnlock()
// Does not matter we send success or failure here.
// Those PMs that we failed to create will be attempted to create again in the next PM creation cycle (assuming
// we have not exceed max attempts to create the PM ME)
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
return nil
}
// nolint: gocyclo
-func (mm *onuMetricsManager) l2PmFsmDeletePM(ctx context.Context, e *fsm.Event) error {
+func (mm *OnuMetricsManager) l2PmFsmDeletePM(ctx context.Context, e *fsm.Event) error {
// Copy the l2PmToDelete for which we want to collect the metrics since l2PmToDelete can change dynamically
- mm.onuMetricsManagerLock.RLock()
+ mm.OnuMetricsManagerLock.RLock()
copyOfL2PmToDelete := make([]string, len(mm.l2PmToDelete))
_ = copy(copyOfL2PmToDelete, mm.l2PmToDelete)
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RUnlock()
- logger.Debugw(ctx, "state delete pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": copyOfL2PmToDelete})
+ logger.Debugw(ctx, "state delete pm", log.Fields{"device-id": mm.deviceID, "pms-to-delete": copyOfL2PmToDelete})
for _, n := range copyOfL2PmToDelete {
resp := false
cnt := 0
atLeastOneDeleteFailure := false
- // mm.groupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
- mm.onuMetricsManagerLock.RLock()
- copyOfEntityIDs := make([]uint16, len(mm.groupMetricMap[n].pmMEData.InstancesActive))
- _ = copy(copyOfEntityIDs, mm.groupMetricMap[n].pmMEData.InstancesActive)
- mm.onuMetricsManagerLock.RUnlock()
+ // mm.GroupMetricMap[n].pmMEData.InstancesActive could dynamically change, so make a copy
+ mm.OnuMetricsManagerLock.RLock()
+ copyOfEntityIDs := make([]uint16, len(mm.GroupMetricMap[n].pmMEData.InstancesActive))
+ _ = copy(copyOfEntityIDs, mm.GroupMetricMap[n].pmMEData.InstancesActive)
+ mm.OnuMetricsManagerLock.RUnlock()
if len(copyOfEntityIDs) == 0 {
// if there are no enityIDs to remove for the PM ME just clear the PM name entry from cache and continue
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
continue
}
- logger.Debugw(ctx, "entities to delete", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n, "entityIDs": copyOfEntityIDs})
+ logger.Debugw(ctx, "entities to delete", log.Fields{"device-id": mm.deviceID, "metricName": n, "entityIDs": copyOfEntityIDs})
switch n {
case EthernetBridgeHistoryName:
// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
@@ -1639,19 +1657,19 @@
inner1:
// retry L2PmDeleteAttempts times to delete the instance of PM
for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, false, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, false, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteEthernetPerformanceMonitoringHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- pPMFsm := mm.pAdaptFsm
+ log.Fields{"device-id": mm.deviceID})
+ pPMFsm := mm.PAdaptFsm
if pPMFsm != nil {
- go func(p_pmFsm *AdapterFsm) {
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ go func(p_pmFsm *cmn.AdapterFsm) {
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
}(pPMFsm)
}
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetPerformanceMonitoringHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
_ = mm.updatePmData(ctx, n, entityID, cPmRemove) // TODO: ignore error for now
if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "EthernetFramePerformanceMonitoringHistoryData"); !resp {
@@ -1671,20 +1689,20 @@
inner2:
// retry L2PmDeleteAttempts times to delete the instance of PM
for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetUniHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetUniHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteEthernetUniHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- pmFsm := mm.pAdaptFsm
+ log.Fields{"device-id": mm.deviceID})
+ pmFsm := mm.PAdaptFsm
if pmFsm != nil {
- go func(p_pmFsm *AdapterFsm) {
- _ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+ go func(p_pmFsm *cmn.AdapterFsm) {
+ _ = p_pmFsm.PFsm.Event(L2PmEventFailure)
}(pmFsm)
return err
}
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteEthernetUniHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "EthernetPerformanceMonitoringHistoryData"); !resp {
atLeastOneDeleteFailure = true
@@ -1702,14 +1720,14 @@
inner3:
// retry L2PmDeleteAttempts times to delete the instance of PM
for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteFecHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteFecHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteFecHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteFecHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
if resp := mm.waitForResponseOrTimeout(ctx, false, entityID, "FecPerformanceMonitoringHistoryData"); !resp {
atLeastOneDeleteFailure = true
@@ -1727,14 +1745,14 @@
inner4:
// retry L2PmDeleteAttempts times to delete the instance of PM
for cnt = 0; cnt < L2PmDeleteAttempts; cnt++ {
- _, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteGemPortHistoryME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, false, mm.pAdaptFsm.commChan, entityID)
+ _, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteGemPortHistoryME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, false, mm.PAdaptFsm.CommChan, entityID)
if err != nil {
logger.Errorw(ctx, "CreateOrDeleteGemPortHistoryME failed, failure PM FSM!",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
+ log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
return fmt.Errorf(fmt.Sprintf("CreateOrDeleteGemPortHistoryMe-failed-%s-%s",
- mm.pDeviceHandler.deviceID, err))
+ mm.deviceID, err))
}
if resp = mm.waitForResponseOrTimeout(ctx, false, entityID, "GemPortNetworkCtpPerformanceMonitoringHistoryData"); !resp {
atLeastOneDeleteFailure = true
@@ -1748,39 +1766,39 @@
}
}
default:
- logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "name": n})
+ logger.Errorw(ctx, "unsupported l2 pm", log.Fields{"device-id": mm.deviceID, "name": n})
}
// If we could not completely clean up the PM ME then just give up.
if atLeastOneDeleteFailure {
logger.Warnw(ctx, "state delete pm - failed to delete at least one instance of the PM ME",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": n,
+ log.Fields{"device-id": mm.deviceID, "metricName": n,
"active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
logger.Debugw(ctx, "exceeded-max-delete-retry-attempts--disabling-group", log.Fields{"groupName": n})
mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
- mm.groupMetricMap[n].enabled = false
- mm.onuMetricsManagerLock.Unlock()
+ mm.GroupMetricMap[n].Enabled = false
+ mm.OnuMetricsManagerLock.Unlock()
} else { // success case
- mm.onuMetricsManagerLock.Lock()
+ mm.OnuMetricsManagerLock.Lock()
mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, n)
// gem ports can be deleted dynamically from perf monitoring. We want to clear the GemPortHistoryName from mm.l2PmToDelete
// only if no more new gem port instances removed.
- if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete) == 0) {
+ if n != GemPortHistoryName || (n == GemPortHistoryName && len(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete) == 0) {
mm.l2PmToDelete = mm.removeIfFoundString(mm.l2PmToDelete, n)
}
logger.Debugw(ctx, "success-resp", log.Fields{"pm-name": n, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
- mm.onuMetricsManagerLock.Unlock()
+ mm.OnuMetricsManagerLock.Unlock()
}
}
- mm.onuMetricsManagerLock.RLock()
- logger.Debugw(ctx, "state delete pm - done", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
- mm.onuMetricsManagerLock.RUnlock()
+ mm.OnuMetricsManagerLock.RLock()
+ logger.Debugw(ctx, "state delete pm - done", log.Fields{"device-id": mm.deviceID, "active-l2-pms": mm.activeL2Pms, "pms-to-delete": mm.l2PmToDelete})
+ mm.OnuMetricsManagerLock.RUnlock()
// Does not matter we send success or failure here.
// Those PMs that we failed to delete will be attempted to create again in the next PM collection cycle
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventSuccess); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventSuccess); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
return nil
@@ -1789,41 +1807,41 @@
// ** L2 PM FSM Handlers end **
// syncTime synchronizes time with the ONU to establish a 15 min boundary for PM collection and reporting.
-func (mm *onuMetricsManager) syncTime(ctx context.Context) error {
- if err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendSyncTime(ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); err != nil {
- logger.Errorw(ctx, "cannot send sync time request", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) syncTime(ctx context.Context) error {
+ if err := mm.pOnuDeviceEntry.GetDevOmciCC().SendSyncTime(ctx, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan); err != nil {
+ logger.Errorw(ctx, "cannot send sync time request", log.Fields{"device-id": mm.deviceID})
return err
}
select {
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
- logger.Errorw(ctx, "timed out waiting for sync time response from onu", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("timed-out-waiting-for-sync-time-response-%v", mm.pDeviceHandler.deviceID)
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
+ logger.Errorw(ctx, "timed out waiting for sync time response from onu", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("timed-out-waiting-for-sync-time-response-%v", mm.deviceID)
case syncTimeRes := <-mm.syncTimeResponseChan:
if !syncTimeRes {
- return fmt.Errorf("failed-to-sync-time-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("failed-to-sync-time-%v", mm.deviceID)
}
- logger.Infow(ctx, "sync time success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Infow(ctx, "sync time success", log.Fields{"device-id": mm.deviceID})
return nil
}
}
-func (mm *onuMetricsManager) collectEthernetFramePerformanceMonitoringHistoryData(ctx context.Context, upstream bool, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectEthernetFramePerformanceMonitoringHistoryData(ctx context.Context, upstream bool, entityID uint16) *voltha.MetricInformation {
var mEnt *me.ManagedEntity
var omciErr me.OmciErrors
var classID me.ClassID
var meAttributes me.AttributeValueMap
- logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+ logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
meParam := me.ParamData{EntityID: entityID}
if upstream {
if mEnt, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
- logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+ logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
return nil
}
classID = me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID
} else {
if mEnt, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
- logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+ logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
return nil
}
classID = me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID
@@ -1849,19 +1867,19 @@
metricInfo := mm.populateOnuMetricInfo(EthernetBridgeHistoryName, ethPMHistData)
logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData successful",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream, "metricInfo": metricInfo})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream, "metricInfo": metricInfo})
return &metricInfo
}
-func (mm *onuMetricsManager) collectEthernetUniHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectEthernetUniHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
var mEnt *me.ManagedEntity
var omciErr me.OmciErrors
var classID me.ClassID
var meAttributes me.AttributeValueMap
- logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Debugw(ctx, "collecting data for EthernetFramePerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
meParam := me.ParamData{EntityID: entityID}
if mEnt, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
- logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
return nil
}
classID = me.EthernetPerformanceMonitoringHistoryDataClassID
@@ -1879,19 +1897,19 @@
metricInfo := mm.populateOnuMetricInfo(EthernetUniHistoryName, ethUniHistData)
logger.Debugw(ctx, "collecting data for EthernetPerformanceMonitoringHistoryData successful",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
return &metricInfo
}
-func (mm *onuMetricsManager) collectFecHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectFecHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
var mEnt *me.ManagedEntity
var omciErr me.OmciErrors
var classID me.ClassID
var meAttributes me.AttributeValueMap
- logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
meParam := me.ParamData{EntityID: entityID}
if mEnt, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
- logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
return nil
}
classID = me.FecPerformanceMonitoringHistoryDataClassID
@@ -1909,19 +1927,19 @@
metricInfo := mm.populateOnuMetricInfo(FecHistoryName, fecHistData)
logger.Debugw(ctx, "collecting data for FecPerformanceMonitoringHistoryData successful",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
return &metricInfo
}
-func (mm *onuMetricsManager) collectGemHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
+func (mm *OnuMetricsManager) collectGemHistoryData(ctx context.Context, entityID uint16) *voltha.MetricInformation {
var mEnt *me.ManagedEntity
var omciErr me.OmciErrors
var classID me.ClassID
var meAttributes me.AttributeValueMap
- logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
meParam := me.ParamData{EntityID: entityID}
if mEnt, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam); omciErr == nil || mEnt == nil || omciErr.GetError() != nil {
- logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ logger.Errorw(ctx, "error creating me", log.Fields{"device-id": mm.deviceID, "entityID": entityID})
return nil
}
classID = me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID
@@ -1939,12 +1957,12 @@
metricInfo := mm.populateOnuMetricInfo(GemPortHistoryName, gemHistData)
logger.Debugw(ctx, "collecting data for GemPortNetworkCtpPerformanceMonitoringHistoryData successful",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "metricInfo": metricInfo})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "metricInfo": metricInfo})
return &metricInfo
}
// nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetBridgeHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetBridgeHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, ethPMHistData map[string]float32, intervalEndTime *int) error {
upstream := false
if classID == me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID {
@@ -1952,32 +1970,32 @@
}
// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
requestedAttributes["IntervalEndTime"] = 0
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetME failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- pmFsm := mm.pAdaptFsm
+ logger.Errorw(ctx, "GetME failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ pmFsm := mm.PAdaptFsm
if pmFsm != nil {
- go func(p_pmFsm *AdapterFsm) {
- _ = p_pmFsm.pFsm.Event(l2PmEventFailure)
+ go func(p_pmFsm *cmn.AdapterFsm) {
+ _ = p_pmFsm.PFsm.Event(L2PmEventFailure)
}(pmFsm)
return err
}
- return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+ return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
}
if meInstance != nil {
select {
case meAttributes = <-mm.l2PmChan:
logger.Debugw(ctx, "received ethernet pm history data metrics",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout waiting for omci-get response for ethernet pm history data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
+ log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
// The metrics will be empty in this case
- return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-bridge-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-bridge-history-%v", mm.deviceID)
}
// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
- return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-bridge-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-bridge-history-%v", mm.deviceID)
}
}
for k := range EthernetBridgeHistory {
@@ -2054,32 +2072,32 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetUniHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetUniHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, ethPMUniHistData map[string]float32, intervalEndTime *int) error {
// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
requestedAttributes["IntervalEndTime"] = 0
}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
- return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+ logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+ return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
}
if meInstance != nil {
select {
case meAttributes = <-mm.l2PmChan:
logger.Debugw(ctx, "received ethernet uni history data metrics",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout waiting for omci-get response for ethernet uni history data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
// The metrics will be empty in this case
- return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-uni-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("timeout-during-l2-pm-collection-for-ethernet-uni-history-%v", mm.deviceID)
}
// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
- return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-uni-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-ethernet-uni-history-%v", mm.deviceID)
}
}
for k := range EthernetUniHistory {
@@ -2156,32 +2174,32 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) populateFecHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateFecHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, fecHistData map[string]float32, intervalEndTime *int) error {
// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
requestedAttributes["IntervalEndTime"] = 0
}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
- return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+ logger.Errorw(ctx, "GetMe failed, failure PM FSM!", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+ return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
}
if meInstance != nil {
select {
case meAttributes = <-mm.l2PmChan:
logger.Debugw(ctx, "received fec history data metrics",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout waiting for omci-get response for fec history data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
// The metrics will be empty in this case
- return fmt.Errorf("timeout-during-l2-pm-collection-for-fec-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("timeout-during-l2-pm-collection-for-fec-history-%v", mm.deviceID)
}
// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
- return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-fec-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-fec-history-%v", mm.deviceID)
}
}
for k := range FecHistory {
@@ -2222,32 +2240,32 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) populateGemPortMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateGemPortMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, gemPortHistData map[string]float32, intervalEndTime *int) error {
// Insert "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
requestedAttributes["IntervalEndTime"] = 0
}
- meInstance, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ meInstance, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "GetMe failed", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
- _ = mm.pAdaptFsm.pFsm.Event(l2PmEventFailure)
- return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.pDeviceHandler.deviceID, err))
+ logger.Errorw(ctx, "GetMe failed", log.Fields{"device-id": mm.deviceID})
+ _ = mm.PAdaptFsm.PFsm.Event(L2PmEventFailure)
+ return fmt.Errorf(fmt.Sprintf("GetME-failed-%s-%s", mm.deviceID, err))
}
if meInstance != nil {
select {
case meAttributes = <-mm.l2PmChan:
logger.Debugw(ctx, "received gem port history data metrics",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout waiting for omci-get response for gem port history data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID})
// The metrics will be empty in this case
- return fmt.Errorf("timeout-during-l2-pm-collection-for-gemport-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("timeout-during-l2-pm-collection-for-gemport-history-%v", mm.deviceID)
}
// verify that interval end time has not changed during metric collection. If it changed, we abort the procedure
if valid := mm.updateAndValidateIntervalEndTime(ctx, entityID, meAttributes, intervalEndTime); !valid {
- return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-gemport-history-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("interval-end-time-changed-during-metric-collection-for-gemport-history-%v", mm.deviceID)
}
}
for k := range GemPortHistory {
@@ -2287,18 +2305,18 @@
return nil
}
-func (mm *onuMetricsManager) handleOmciCreateResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci Msg layer could not be detected for create response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be detected for create response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.CreateResponse)
if !msgOk {
- logger.Errorw(ctx, "omci Msg layer could not be assigned for create response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for create response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.deviceID)
}
- logger.Debugw(ctx, "OMCI create response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "OMCI create response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
switch msgObj.EntityClass {
case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
@@ -2309,7 +2327,7 @@
if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists {
mm.l2PmCreateOrDeleteResponseChan <- true
} else {
- logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
mm.l2PmCreateOrDeleteResponseChan <- false
}
return nil
@@ -2319,23 +2337,23 @@
return nil
default:
logger.Errorw(ctx, "unhandled omci create response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
- return fmt.Errorf("unhandled-omci-create-response-message-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("unhandled-omci-create-response-message-%v", mm.deviceID)
}
-func (mm *onuMetricsManager) handleOmciDeleteResponseMessage(ctx context.Context, msg OmciMessage) error {
+func (mm *OnuMetricsManager) handleOmciDeleteResponseMessage(ctx context.Context, msg cmn.OmciMessage) error {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse)
if msgLayer == nil {
- logger.Errorw(ctx, "omci Msg layer could not be detected for delete response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be detected for delete response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be detected for create response - handling stopped: %s", mm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.DeleteResponse)
if !msgOk {
- logger.Errorw(ctx, "omci Msg layer could not be assigned for delete response - handling stopped", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for delete response - handling stopped", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf("omci Msg layer could not be assigned for delete response - handling stopped: %s", mm.deviceID)
}
- logger.Debugw(ctx, "OMCI delete response Data", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "OMCI delete response Data", log.Fields{"device-id": mm.deviceID, "data-fields": msgObj})
switch msgObj.EntityClass {
case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
@@ -2346,54 +2364,54 @@
if msgObj.Result == me.Success || msgObj.Result == me.UnknownInstance {
mm.l2PmCreateOrDeleteResponseChan <- true
} else {
- logger.Warnw(ctx, "failed to delete me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ logger.Warnw(ctx, "failed to delete me", log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
mm.l2PmCreateOrDeleteResponseChan <- false
}
return nil
default:
logger.Errorw(ctx, "unhandled omci delete response message",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "class-id": msgObj.EntityClass})
+ log.Fields{"device-id": mm.deviceID, "class-id": msgObj.EntityClass})
}
- return fmt.Errorf("unhandled-omci-delete-response-message-%v", mm.pDeviceHandler.deviceID)
+ return fmt.Errorf("unhandled-omci-delete-response-message-%v", mm.deviceID)
}
-func (mm *onuMetricsManager) generateTicks(ctx context.Context) {
+func (mm *OnuMetricsManager) generateTicks(ctx context.Context) {
mm.updateTickGenerationStatus(true)
for {
select {
case <-time.After(L2PmCollectionInterval * time.Second):
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventTick); err != nil {
- logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventTick); err != nil {
+ logger.Errorw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
- case <-mm.stopTicks:
- logger.Infow(ctx, "stopping ticks", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ case <-mm.StopTicks:
+ logger.Infow(ctx, "stopping ticks", log.Fields{"device-id": mm.deviceID})
mm.updateTickGenerationStatus(false)
return
}
}
}
-func (mm *onuMetricsManager) handleMetricsPublish(ctx context.Context, metricName string, metricInfoSlice []*voltha.MetricInformation) {
+func (mm *OnuMetricsManager) handleMetricsPublish(ctx context.Context, metricName string, metricInfoSlice []*voltha.MetricInformation) {
// Publish metrics if it is valid
if metricInfoSlice != nil {
mm.publishMetrics(ctx, metricInfoSlice)
} else {
// If collectAttempts exceeds L2PmCollectAttempts then remove it from activeL2Pms
// slice so that we do not collect data from that PM ME anymore
- mm.onuMetricsManagerLock.Lock()
- mm.groupMetricMap[metricName].collectAttempts++
- if mm.groupMetricMap[metricName].collectAttempts > L2PmCollectAttempts {
+ mm.OnuMetricsManagerLock.Lock()
+ mm.GroupMetricMap[metricName].collectAttempts++
+ if mm.GroupMetricMap[metricName].collectAttempts > L2PmCollectAttempts {
mm.activeL2Pms = mm.removeIfFoundString(mm.activeL2Pms, metricName)
}
logger.Warnw(ctx, "state collect data - no metrics collected",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "metricName": metricName, "collectAttempts": mm.groupMetricMap[metricName].collectAttempts})
- mm.onuMetricsManagerLock.Unlock()
+ log.Fields{"device-id": mm.deviceID, "metricName": metricName, "collectAttempts": mm.GroupMetricMap[metricName].collectAttempts})
+ mm.OnuMetricsManagerLock.Unlock()
}
}
-func (mm *onuMetricsManager) populateGroupSpecificMetrics(ctx context.Context, mEnt *me.ManagedEntity, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateGroupSpecificMetrics(ctx context.Context, mEnt *me.ManagedEntity, classID me.ClassID, entityID uint16,
meAttributes me.AttributeValueMap, data map[string]float32, intervalEndTime *int) error {
var grpFunc groupMetricPopulateFunc
switch classID {
@@ -2425,7 +2443,7 @@
// Let's collect the attributes via get now and collect remaining in the next iteration
if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
logger.Errorw(ctx, "error during metric collection",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
return err
}
requestedAttributes = make(me.AttributeValueMap) // reset map
@@ -2436,26 +2454,26 @@
// Collect the omci get attributes for the last bunch of attributes.
if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
logger.Errorw(ctx, "error during metric collection",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
return err
}
return nil
}
-func (mm *onuMetricsManager) populateOnuMetricInfo(title string, data map[string]float32) voltha.MetricInformation {
+func (mm *OnuMetricsManager) populateOnuMetricInfo(title string, data map[string]float32) voltha.MetricInformation {
metricsContext := make(map[string]string)
- metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.OnuId)
- metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.device.ProxyAddress.ChannelId)
- metricsContext["devicetype"] = mm.pDeviceHandler.DeviceType
+ metricsContext["onuID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.OnuId)
+ metricsContext["intfID"] = fmt.Sprintf("%d", mm.pDeviceHandler.GetDevice().ProxyAddress.ChannelId)
+ metricsContext["devicetype"] = mm.pDeviceHandler.GetDeviceType()
raisedTs := time.Now().Unix()
mmd := voltha.MetricMetaData{
Title: title,
Ts: float64(raisedTs),
Context: metricsContext,
- DeviceId: mm.pDeviceHandler.deviceID,
- LogicalDeviceId: mm.pDeviceHandler.logicalDeviceID,
- SerialNo: mm.pDeviceHandler.device.SerialNumber,
+ DeviceId: mm.deviceID,
+ LogicalDeviceId: mm.pDeviceHandler.GetLogicalDeviceID(),
+ SerialNo: mm.pDeviceHandler.GetDevice().SerialNumber,
}
// create slice of metrics given that there could be more than one VEIP instance
@@ -2463,7 +2481,7 @@
return metricInfo
}
-func (mm *onuMetricsManager) updateAndValidateIntervalEndTime(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap, intervalEndTime *int) bool {
+func (mm *OnuMetricsManager) updateAndValidateIntervalEndTime(ctx context.Context, entityID uint16, meAttributes me.AttributeValueMap, intervalEndTime *int) bool {
valid := false
if *intervalEndTime == -1 { // first time
// Update the interval end time
@@ -2478,7 +2496,7 @@
}
if currIntervalEndTime != *intervalEndTime { // interval end time changed during metric collection
logger.Errorw(ctx, "interval end time changed during metrics collection for ethernet pm history data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID,
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID,
"currIntervalEndTime": *intervalEndTime, "newIntervalEndTime": currIntervalEndTime})
} else {
valid = true
@@ -2487,81 +2505,81 @@
return valid
}
-func (mm *onuMetricsManager) waitForResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassName string) bool {
+func (mm *OnuMetricsManager) waitForResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassName string) bool {
logger.Debugw(ctx, "waitForResponseOrTimeout", log.Fields{"create": create, "instID": instID, "meClassName": meClassName})
select {
case resp := <-mm.l2PmCreateOrDeleteResponseChan:
logger.Debugw(ctx, "received l2 pm me response",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "create": create, "meClassName": meClassName, "instID": instID})
+ log.Fields{"device-id": mm.deviceID, "resp": resp, "create": create, "meClassName": meClassName, "instID": instID})
return resp
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout waiting for l2 pm me response",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": false, "create": create, "meClassName": meClassName, "instID": instID})
+ log.Fields{"device-id": mm.deviceID, "resp": false, "create": create, "meClassName": meClassName, "instID": instID})
}
return false
}
-func (mm *onuMetricsManager) initializeGroupMetric(grpMtrcs map[string]voltha.PmConfig_PmType, grpName string, grpEnabled bool, grpFreq uint32) {
+func (mm *OnuMetricsManager) initializeGroupMetric(grpMtrcs map[string]voltha.PmConfig_PmType, grpName string, grpEnabled bool, grpFreq uint32) {
var pmConfigSlice []*voltha.PmConfig
for k, v := range grpMtrcs {
pmConfigSlice = append(pmConfigSlice,
&voltha.PmConfig{
Name: k,
Type: v,
- Enabled: grpEnabled && mm.pDeviceHandler.pOpenOnuAc.metricsEnabled,
+ Enabled: grpEnabled && mm.pDeviceHandler.GetMetricsEnabled(),
SampleFreq: grpFreq})
}
groupMetric := voltha.PmGroupConfig{
GroupName: grpName,
- Enabled: grpEnabled && mm.pDeviceHandler.pOpenOnuAc.metricsEnabled,
+ Enabled: grpEnabled && mm.pDeviceHandler.GetMetricsEnabled(),
GroupFreq: grpFreq,
Metrics: pmConfigSlice,
}
- mm.pDeviceHandler.pmConfigs.Groups = append(mm.pDeviceHandler.pmConfigs.Groups, &groupMetric)
+ mm.pDeviceHandler.GetPmConfigs().Groups = append(mm.pDeviceHandler.GetPmConfigs().Groups, &groupMetric)
}
-func (mm *onuMetricsManager) initializeL2PmFsm(ctx context.Context, aCommChannel chan Message) error {
- mm.pAdaptFsm = NewAdapterFsm("L2PmFSM", mm.pDeviceHandler.deviceID, aCommChannel)
- if mm.pAdaptFsm == nil {
- logger.Errorw(ctx, "L2PMFsm AdapterFsm could not be instantiated!!", log.Fields{
- "device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) initializeL2PmFsm(ctx context.Context, aCommChannel chan cmn.Message) error {
+ mm.PAdaptFsm = cmn.NewAdapterFsm("L2PmFSM", mm.deviceID, aCommChannel)
+ if mm.PAdaptFsm == nil {
+ logger.Errorw(ctx, "L2PMFsm cmn.AdapterFsm could not be instantiated!!", log.Fields{
+ "device-id": mm.deviceID})
return fmt.Errorf("nil-adapter-fsm")
}
// L2 PM FSM related state machine
- mm.pAdaptFsm.pFsm = fsm.NewFSM(
- l2PmStNull,
+ mm.PAdaptFsm.PFsm = fsm.NewFSM(
+ L2PmStNull,
fsm.Events{
- {Name: l2PmEventInit, Src: []string{l2PmStNull}, Dst: l2PmStStarting},
- {Name: l2PmEventTick, Src: []string{l2PmStStarting}, Dst: l2PmStSyncTime},
- {Name: l2PmEventTick, Src: []string{l2PmStIdle, l2PmStCreatePmMe, l2PmStDeletePmMe}, Dst: l2PmStCollectData},
- {Name: l2PmEventSuccess, Src: []string{l2PmStSyncTime, l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStIdle},
- {Name: l2PmEventFailure, Src: []string{l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStIdle},
- {Name: l2PmEventFailure, Src: []string{l2PmStSyncTime}, Dst: l2PmStSyncTime},
- {Name: l2PmEventAddMe, Src: []string{l2PmStIdle}, Dst: l2PmStCreatePmMe},
- {Name: l2PmEventDeleteMe, Src: []string{l2PmStIdle}, Dst: l2PmStDeletePmMe},
- {Name: l2PmEventStop, Src: []string{l2PmStNull, l2PmStStarting, l2PmStSyncTime, l2PmStIdle, l2PmStCreatePmMe, l2PmStDeletePmMe, l2PmStCollectData}, Dst: l2PmStNull},
+ {Name: L2PmEventInit, Src: []string{L2PmStNull}, Dst: L2PmStStarting},
+ {Name: L2PmEventTick, Src: []string{L2PmStStarting}, Dst: L2PmStSyncTime},
+ {Name: L2PmEventTick, Src: []string{L2PmStIdle, L2PmStCreatePmMe, L2PmStDeletePmMe}, Dst: L2PmStCollectData},
+ {Name: L2PmEventSuccess, Src: []string{L2PmStSyncTime, L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStIdle},
+ {Name: L2PmEventFailure, Src: []string{L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStIdle},
+ {Name: L2PmEventFailure, Src: []string{L2PmStSyncTime}, Dst: L2PmStSyncTime},
+ {Name: L2PmEventAddMe, Src: []string{L2PmStIdle}, Dst: L2PmStCreatePmMe},
+ {Name: L2PmEventDeleteMe, Src: []string{L2PmStIdle}, Dst: L2PmStDeletePmMe},
+ {Name: L2PmEventStop, Src: []string{L2PmStNull, L2PmStStarting, L2PmStSyncTime, L2PmStIdle, L2PmStCreatePmMe, L2PmStDeletePmMe, L2PmStCollectData}, Dst: L2PmStNull},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { mm.pAdaptFsm.logFsmStateChange(ctx, e) },
- "enter_" + l2PmStNull: func(e *fsm.Event) { mm.l2PMFsmNull(ctx, e) },
- "enter_" + l2PmStIdle: func(e *fsm.Event) { mm.l2PMFsmIdle(ctx, e) },
- "enter_" + l2PmStStarting: func(e *fsm.Event) { mm.l2PMFsmStarting(ctx, e) },
- "enter_" + l2PmStSyncTime: func(e *fsm.Event) { mm.l2PMFsmSyncTime(ctx, e) },
- "enter_" + l2PmStCollectData: func(e *fsm.Event) { mm.l2PmFsmCollectData(ctx, e) },
- "enter_" + l2PmStCreatePmMe: func(e *fsm.Event) { _ = mm.l2PmFsmCreatePM(ctx, e) },
- "enter_" + l2PmStDeletePmMe: func(e *fsm.Event) { _ = mm.l2PmFsmDeletePM(ctx, e) },
+ "enter_state": func(e *fsm.Event) { mm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+ "enter_" + L2PmStNull: func(e *fsm.Event) { mm.l2PMFsmNull(ctx, e) },
+ "enter_" + L2PmStIdle: func(e *fsm.Event) { mm.l2PMFsmIdle(ctx, e) },
+ "enter_" + L2PmStStarting: func(e *fsm.Event) { mm.l2PMFsmStarting(ctx, e) },
+ "enter_" + L2PmStSyncTime: func(e *fsm.Event) { mm.l2PMFsmSyncTime(ctx, e) },
+ "enter_" + L2PmStCollectData: func(e *fsm.Event) { mm.l2PmFsmCollectData(ctx, e) },
+ "enter_" + L2PmStCreatePmMe: func(e *fsm.Event) { _ = mm.l2PmFsmCreatePM(ctx, e) },
+ "enter_" + L2PmStDeletePmMe: func(e *fsm.Event) { _ = mm.l2PmFsmDeletePM(ctx, e) },
},
)
return nil
}
-func (mm *onuMetricsManager) initializeAllGroupMetrics() {
- mm.pDeviceHandler.pmConfigs = &voltha.PmConfigs{}
- mm.pDeviceHandler.pmConfigs.Id = mm.pDeviceHandler.deviceID
- mm.pDeviceHandler.pmConfigs.DefaultFreq = DefaultMetricCollectionFrequency
- mm.pDeviceHandler.pmConfigs.Grouped = GroupMetricEnabled
- mm.pDeviceHandler.pmConfigs.FreqOverride = DefaultFrequencyOverrideEnabled
+func (mm *OnuMetricsManager) initializeAllGroupMetrics() {
+ mm.pDeviceHandler.InitPmConfigs()
+ mm.pDeviceHandler.GetPmConfigs().Id = mm.deviceID
+ mm.pDeviceHandler.GetPmConfigs().DefaultFreq = DefaultMetricCollectionFrequency
+ mm.pDeviceHandler.GetPmConfigs().Grouped = GroupMetricEnabled
+ mm.pDeviceHandler.GetPmConfigs().FreqOverride = DefaultFrequencyOverrideEnabled
// Populate group metrics.
// Lets populate irrespective of GroupMetricEnabled is true or not.
@@ -2592,42 +2610,42 @@
// Add standalone metric (if present) after this (will be added to dh.pmConfigs.Metrics)
}
-func (mm *onuMetricsManager) populateLocalGroupMetricData(ctx context.Context) {
+func (mm *OnuMetricsManager) populateLocalGroupMetricData(ctx context.Context) {
// Populate local group metric structures
- for _, g := range mm.pDeviceHandler.pmConfigs.Groups {
- mm.groupMetricMap[g.GroupName] = &groupMetric{
+ for _, g := range mm.pDeviceHandler.GetPmConfigs().Groups {
+ mm.GroupMetricMap[g.GroupName] = &groupMetric{
groupName: g.GroupName,
- enabled: g.Enabled,
- frequency: g.GroupFreq,
+ Enabled: g.Enabled,
+ Frequency: g.GroupFreq,
}
switch g.GroupName {
case OpticalPowerGroupMetricName:
- mm.groupMetricMap[g.GroupName].metricMap = OpticalPowerGroupMetrics
+ mm.GroupMetricMap[g.GroupName].metricMap = OpticalPowerGroupMetrics
case UniStatusGroupMetricName:
- mm.groupMetricMap[g.GroupName].metricMap = UniStatusGroupMetrics
+ mm.GroupMetricMap[g.GroupName].metricMap = UniStatusGroupMetrics
case EthernetBridgeHistoryName:
- mm.groupMetricMap[g.GroupName].metricMap = EthernetBridgeHistory
- mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+ mm.GroupMetricMap[g.GroupName].metricMap = EthernetBridgeHistory
+ mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
case EthernetUniHistoryName:
- mm.groupMetricMap[g.GroupName].metricMap = EthernetUniHistory
- mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+ mm.GroupMetricMap[g.GroupName].metricMap = EthernetUniHistory
+ mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
case FecHistoryName:
- mm.groupMetricMap[g.GroupName].metricMap = FecHistory
- mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+ mm.GroupMetricMap[g.GroupName].metricMap = FecHistory
+ mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
case GemPortHistoryName:
- mm.groupMetricMap[g.GroupName].metricMap = GemPortHistory
- mm.groupMetricMap[g.GroupName].isL2PMCounter = true
+ mm.GroupMetricMap[g.GroupName].metricMap = GemPortHistory
+ mm.GroupMetricMap[g.GroupName].IsL2PMCounter = true
default:
logger.Errorw(ctx, "unhandled-group-name", log.Fields{"groupName": g.GroupName})
}
}
// Populate local standalone metric structures
- for _, m := range mm.pDeviceHandler.pmConfigs.Metrics {
- mm.standaloneMetricMap[m.Name] = &standaloneMetric{
+ for _, m := range mm.pDeviceHandler.GetPmConfigs().Metrics {
+ mm.StandaloneMetricMap[m.Name] = &standaloneMetric{
metricName: m.Name,
- enabled: m.Enabled,
- frequency: m.SampleFreq,
+ Enabled: m.Enabled,
+ Frequency: m.SampleFreq,
}
switch m.Name {
// None exist as of now. Add when available.
@@ -2637,14 +2655,15 @@
}
}
-func (mm *onuMetricsManager) AddGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- logger.Debugw(ctx, "add gemport for perf monitoring - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "gemPortID": gemPortNTPInstID})
+// AddGemPortForPerfMonitoring - TODO: add comment
+func (mm *OnuMetricsManager) AddGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ logger.Debugw(ctx, "add gemport for perf monitoring - start", log.Fields{"device-id": mm.deviceID, "gemPortID": gemPortNTPInstID})
// mark the instance for addition
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToDelete slice
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
mm.l2PmToAdd = mm.appendIfMissingString(mm.l2PmToAdd, GemPortHistoryName)
// We do not need to remove from l2PmToDelete slice as we could have Add and Delete of
@@ -2653,23 +2672,24 @@
// gemPortNCTPPerfHistInstToAdd slice
logger.Debugw(ctx, "add gemport for perf monitoring - end",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-add": mm.l2PmToAdd,
- "instances-to-add": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd})
+ log.Fields{"device-id": mm.deviceID, "pms-to-add": mm.l2PmToAdd,
+ "instances-to-add": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd})
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventAddMe); err != nil {
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventAddMe); err != nil {
// log at warn level as the gem port for monitoring is going to be added eventually
- logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
-func (mm *onuMetricsManager) RemoveGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- logger.Debugw(ctx, "remove gemport for perf monitoring - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "gemPortID": gemPortNTPInstID})
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
+// RemoveGemPortForPerfMonitoring - TODO: add comment
+func (mm *OnuMetricsManager) RemoveGemPortForPerfMonitoring(ctx context.Context, gemPortNTPInstID uint16) {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ logger.Debugw(ctx, "remove gemport for perf monitoring - start", log.Fields{"device-id": mm.deviceID, "gemPortID": gemPortNTPInstID})
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, gemPortNTPInstID)
// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToAdd slice
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, gemPortNTPInstID)
mm.l2PmToDelete = mm.appendIfMissingString(mm.l2PmToDelete, GemPortHistoryName)
// We do not need to remove from l2PmToAdd slice as we could have Add and Delete of
@@ -2678,116 +2698,116 @@
// gemPortNCTPPerfHistInstToAdd slice
logger.Debugw(ctx, "remove gemport from perf monitoring - end",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pms-to-delete": mm.l2PmToDelete,
- "instances-to-delete": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+ log.Fields{"device-id": mm.deviceID, "pms-to-delete": mm.l2PmToDelete,
+ "instances-to-delete": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
go func() {
- if err := mm.pAdaptFsm.pFsm.Event(l2PmEventDeleteMe); err != nil {
+ if err := mm.PAdaptFsm.PFsm.Event(L2PmEventDeleteMe); err != nil {
// log at warn level as the gem port for monitoring is going to be removed eventually
- logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "err": err})
+ logger.Warnw(ctx, "error calling event", log.Fields{"device-id": mm.deviceID, "err": err})
}
}()
}
-func (mm *onuMetricsManager) updateGemPortNTPInstanceToAddForPerfMonitoring(ctx context.Context) {
- if mm.pDeviceHandler.pOnuTP != nil {
- gemPortInstIDs := mm.pDeviceHandler.pOnuTP.GetAllBidirectionalGemPortIDsForOnu()
+func (mm *OnuMetricsManager) updateGemPortNTPInstanceToAddForPerfMonitoring(ctx context.Context) {
+ if mm.pDeviceHandler.GetOnuTP() != nil {
+ gemPortInstIDs := mm.pDeviceHandler.GetOnuTP().GetAllBidirectionalGemPortIDsForOnu()
// NOTE: It is expected that caller of this function has acquired the required mutex for synchronization purposes
for _, v := range gemPortInstIDs {
// mark the instance for addition
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToDelete slice
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
}
logger.Debugw(ctx, "updateGemPortNTPInstanceToAddForPerfMonitoring",
- log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "gemToAdd": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+ log.Fields{"deviceID": mm.deviceID, "gemToAdd": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
}
}
-func (mm *onuMetricsManager) updateGemPortNTPInstanceToDeleteForPerfMonitoring(ctx context.Context) {
- if mm.pDeviceHandler.pOnuTP != nil {
- gemPortInstIDs := mm.pDeviceHandler.pOnuTP.GetAllBidirectionalGemPortIDsForOnu()
+func (mm *OnuMetricsManager) updateGemPortNTPInstanceToDeleteForPerfMonitoring(ctx context.Context) {
+ if mm.pDeviceHandler.GetOnuTP() != nil {
+ gemPortInstIDs := mm.pDeviceHandler.GetOnuTP().GetAllBidirectionalGemPortIDsForOnu()
// NOTE: It is expected that caller of this function has acquired the required mutex for synchronization purposes
for _, v := range gemPortInstIDs {
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete = mm.appendIfMissingUnt16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete, v)
// If the instance presence toggles too soon, we need to remove it from gemPortNCTPPerfHistInstToAdd slice
- mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
+ mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd = mm.removeIfFoundUint16(mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, v)
}
}
logger.Debugw(ctx, "updateGemPortNTPInstanceToDeleteForPerfMonitoring",
- log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "gemToAdd": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.groupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
+ log.Fields{"deviceID": mm.deviceID, "gemToAdd": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToAdd, "gemToDel": mm.GroupMetricMap[GemPortHistoryName].pmMEData.InstancesToDelete})
}
// restorePmData restores any PM data available on the KV store to local cache
-func (mm *onuMetricsManager) restorePmData(ctx context.Context) error {
- logger.Debugw(ctx, "restorePmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) restorePmData(ctx context.Context) error {
+ logger.Debugw(ctx, "restorePmData - start", log.Fields{"device-id": mm.deviceID})
if mm.pmKvStore == nil {
- logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+ logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
}
var errorsList []error
- for groupName, group := range mm.groupMetricMap {
+ for groupName, group := range mm.GroupMetricMap {
group.pmMEData = &pmMEData{}
Value, err := mm.pmKvStore.Get(ctx, groupName)
if err == nil {
if Value != nil {
logger.Debugw(ctx, "PM data read",
- log.Fields{"Key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+ log.Fields{"Key": Value.Key, "device-id": mm.deviceID})
tmpBytes, _ := kvstore.ToByte(Value.Value)
if err = json.Unmarshal(tmpBytes, &group.pmMEData); err != nil {
- logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
- errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-PM-data-%s-for-group-%s", mm.pDeviceHandler.deviceID, groupName)))
+ logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.deviceID})
+ errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-PM-data-%s-for-group-%s", mm.deviceID, groupName)))
continue
}
- logger.Debugw(ctx, "restorePmData - success", log.Fields{"pmData": group.pmMEData, "groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "restorePmData - success", log.Fields{"pmData": group.pmMEData, "groupName": groupName, "device-id": mm.deviceID})
} else {
- logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.deviceID})
continue
}
} else {
- logger.Errorw(ctx, "restorePmData - fail", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "err": err})
- errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s-for-group-%s", mm.pDeviceHandler.deviceID, groupName)))
+ logger.Errorw(ctx, "restorePmData - fail", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "err": err})
+ errorsList = append(errorsList, fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s-for-group-%s", mm.deviceID, groupName)))
continue
}
}
if len(errorsList) > 0 {
return fmt.Errorf("errors-restoring-pm-data-for-one-or-more-groups--errors:%v", errorsList)
}
- logger.Debugw(ctx, "restorePmData - complete success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "restorePmData - complete success", log.Fields{"device-id": mm.deviceID})
return nil
}
// getPmData gets pmMEData from cache. Since we have write through cache implementation for pmMEData,
// the data must be available in cache.
// Note, it is expected that caller of this function manages the required synchronization (like using locks etc.).
-func (mm *onuMetricsManager) getPmData(ctx context.Context, groupName string) (*pmMEData, error) {
- if grp, ok := mm.groupMetricMap[groupName]; ok {
+func (mm *OnuMetricsManager) getPmData(ctx context.Context, groupName string) (*pmMEData, error) {
+ if grp, ok := mm.GroupMetricMap[groupName]; ok {
return grp.pmMEData, nil
}
// Data not in cache, try to fetch from kv store.
data := &pmMEData{}
if mm.pmKvStore == nil {
- logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return data, fmt.Errorf("pmKvStore not set. device-id - %s", mm.pDeviceHandler.deviceID)
+ logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+ return data, fmt.Errorf("pmKvStore not set. device-id - %s", mm.deviceID)
}
Value, err := mm.pmKvStore.Get(ctx, groupName)
if err == nil {
if Value != nil {
logger.Debugw(ctx, "PM data read",
- log.Fields{"Key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+ log.Fields{"Key": Value.Key, "device-id": mm.deviceID})
tmpBytes, _ := kvstore.ToByte(Value.Value)
if err = json.Unmarshal(tmpBytes, data); err != nil {
- logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable to unmarshal PM data", log.Fields{"error": err, "device-id": mm.deviceID})
return data, err
}
- logger.Debugw(ctx, "PM data", log.Fields{"pmData": data, "groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "PM data", log.Fields{"pmData": data, "groupName": groupName, "device-id": mm.deviceID})
} else {
- logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "no PM data found", log.Fields{"groupName": groupName, "device-id": mm.deviceID})
return data, err
}
} else {
- logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": mm.deviceID})
return data, err
}
@@ -2795,14 +2815,14 @@
}
// updatePmData update pmMEData to store. It is write through cache, i.e., write to cache first and then update store
-func (mm *onuMetricsManager) updatePmData(ctx context.Context, groupName string, meInstanceID uint16, pmAction string) error {
- logger.Debugw(ctx, "updatePmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "entityID": meInstanceID, "pmAction": pmAction})
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
+func (mm *OnuMetricsManager) updatePmData(ctx context.Context, groupName string, meInstanceID uint16, pmAction string) error {
+ logger.Debugw(ctx, "updatePmData - start", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "entityID": meInstanceID, "pmAction": pmAction})
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
if mm.pmKvStore == nil {
- logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+ logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
}
pmMEData, err := mm.getPmData(ctx, groupName)
@@ -2828,11 +2848,11 @@
pmMEData.InstancesToAdd = mm.removeIfFoundUint16(pmMEData.InstancesToAdd, meInstanceID)
pmMEData.InstancesActive = mm.removeIfFoundUint16(pmMEData.InstancesActive, meInstanceID)
default:
- logger.Errorw(ctx, "unknown pm action", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "pmAction": pmAction, "groupName": groupName})
- return fmt.Errorf(fmt.Sprintf("unknown-pm-action-deviceid-%s-groupName-%s-pmaction-%s", mm.pDeviceHandler.deviceID, groupName, pmAction))
+ logger.Errorw(ctx, "unknown pm action", log.Fields{"device-id": mm.deviceID, "pmAction": pmAction, "groupName": groupName})
+ return fmt.Errorf(fmt.Sprintf("unknown-pm-action-deviceid-%s-groupName-%s-pmaction-%s", mm.deviceID, groupName, pmAction))
}
// write through cache
- mm.groupMetricMap[groupName].pmMEData = pmMEData
+ mm.GroupMetricMap[groupName].pmMEData = pmMEData
Value, err := json.Marshal(*pmMEData)
if err != nil {
@@ -2844,83 +2864,86 @@
logger.Errorw(ctx, "unable to put PM data to kv store", log.Fields{"groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction, "err": err})
return err
}
- logger.Debugw(ctx, "updatePmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction})
+ logger.Debugw(ctx, "updatePmData - success", log.Fields{"device-id": mm.deviceID, "groupName": groupName, "pmData": *pmMEData, "pmAction": pmAction})
return nil
}
// clearPmGroupData cleans PM Group data from store
-func (mm *onuMetricsManager) clearPmGroupData(ctx context.Context) error {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- logger.Debugw(ctx, "clearPmGroupData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+func (mm *OnuMetricsManager) clearPmGroupData(ctx context.Context) error {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ logger.Debugw(ctx, "clearPmGroupData - start", log.Fields{"device-id": mm.deviceID})
if mm.pmKvStore == nil {
- logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+ logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
}
- for n := range mm.groupMetricMap {
+ for n := range mm.GroupMetricMap {
if err := mm.pmKvStore.Delete(ctx, n); err != nil {
- logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "groupName": n, "err": err})
+ logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.deviceID, "groupName": n, "err": err})
// do not abort this procedure. continue to delete next group.
} else {
- logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": n})
+ logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.deviceID, "groupName": n})
}
}
return nil
}
-// clearAllPmData clears all PM data associated with the device from KV store
-func (mm *onuMetricsManager) clearAllPmData(ctx context.Context) error {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
- logger.Debugw(ctx, "clearAllPmData - start", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+// ClearAllPmData clears all PM data associated with the device from KV store
+func (mm *OnuMetricsManager) ClearAllPmData(ctx context.Context) error {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
+ logger.Debugw(ctx, "ClearAllPmData - start", log.Fields{"device-id": mm.deviceID})
if mm.pmKvStore == nil {
- logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
- return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
+ logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.deviceID})
+ return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.deviceID))
}
var value error
- for n := range mm.groupMetricMap {
+ for n := range mm.GroupMetricMap {
if err := mm.pmKvStore.Delete(ctx, n); err != nil {
- logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "groupName": n, "err": err})
+ logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.deviceID, "groupName": n, "err": err})
value = err
// do not abort this procedure - continue to delete next group.
} else {
- logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": n})
+ logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.deviceID, "groupName": n})
}
}
if value == nil {
- logger.Debugw(ctx, "clearAllPmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "ClearAllPmData - success", log.Fields{"device-id": mm.deviceID})
}
return value
}
-func (mm *onuMetricsManager) updateOmciProcessingStatus(status bool) {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
+func (mm *OnuMetricsManager) updateOmciProcessingStatus(status bool) {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
mm.omciProcessingActive = status
}
-func (mm *onuMetricsManager) updateTickGenerationStatus(status bool) {
- mm.onuMetricsManagerLock.Lock()
- defer mm.onuMetricsManagerLock.Unlock()
+// updateTickGenerationStatus - TODO: add comment
+func (mm *OnuMetricsManager) updateTickGenerationStatus(status bool) {
+ mm.OnuMetricsManagerLock.Lock()
+ defer mm.OnuMetricsManagerLock.Unlock()
mm.tickGenerationActive = status
}
-func (mm *onuMetricsManager) getOmciProcessingStatus() bool {
- mm.onuMetricsManagerLock.RLock()
- defer mm.onuMetricsManagerLock.RUnlock()
+// GetOmciProcessingStatus - TODO: add comment
+func (mm *OnuMetricsManager) GetOmciProcessingStatus() bool {
+ mm.OnuMetricsManagerLock.RLock()
+ defer mm.OnuMetricsManagerLock.RUnlock()
return mm.omciProcessingActive
}
-func (mm *onuMetricsManager) getTickGenerationStatus() bool {
- mm.onuMetricsManagerLock.RLock()
- defer mm.onuMetricsManagerLock.RUnlock()
+// GetTickGenerationStatus - TODO: add comment
+func (mm *OnuMetricsManager) GetTickGenerationStatus() bool {
+ mm.OnuMetricsManagerLock.RLock()
+ defer mm.OnuMetricsManagerLock.RUnlock()
return mm.tickGenerationActive
}
-func (mm *onuMetricsManager) appendIfMissingString(slice []string, n string) []string {
+func (mm *OnuMetricsManager) appendIfMissingString(slice []string, n string) []string {
for _, ele := range slice {
if ele == n {
return slice
@@ -2929,7 +2952,7 @@
return append(slice, n)
}
-func (mm *onuMetricsManager) removeIfFoundString(slice []string, n string) []string {
+func (mm *OnuMetricsManager) removeIfFoundString(slice []string, n string) []string {
for i, ele := range slice {
if ele == n {
return append(slice[:i], slice[i+1:]...)
@@ -2938,7 +2961,7 @@
return slice
}
-func (mm *onuMetricsManager) appendIfMissingUnt16(slice []uint16, n uint16) []uint16 {
+func (mm *OnuMetricsManager) appendIfMissingUnt16(slice []uint16, n uint16) []uint16 {
for _, ele := range slice {
if ele == n {
return slice
@@ -2947,7 +2970,7 @@
return append(slice, n)
}
-func (mm *onuMetricsManager) removeIfFoundUint16(slice []uint16, n uint16) []uint16 {
+func (mm *OnuMetricsManager) removeIfFoundUint16(slice []uint16, n uint16) []uint16 {
for i, ele := range slice {
if ele == n {
return append(slice[:i], slice[i+1:]...)
@@ -2956,41 +2979,41 @@
return slice
}
-func (mm *onuMetricsManager) getEthernetFrameExtendedMETypeFromKvStore(ctx context.Context) (bool, error) {
+func (mm *OnuMetricsManager) getEthernetFrameExtendedMETypeFromKvStore(ctx context.Context) (bool, error) {
// Check if the data is already available in KV store, if yes, do not send the request for get me.
var data me.ClassID
- key := fmt.Sprintf("%s/%s/%s", mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersVendorID,
- mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersEquipmentID,
- mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersActiveSwVersion)
+ key := fmt.Sprintf("%s/%s/%s", mm.pOnuDeviceEntry.GetPersVendorID(),
+ mm.pOnuDeviceEntry.GetPersEquipmentID(),
+ mm.pOnuDeviceEntry.GetPersActiveSwVersion())
Value, err := mm.extPmKvStore.Get(ctx, key)
if err == nil {
if Value != nil {
logger.Debugw(ctx, "me-type-read",
- log.Fields{"key": Value.Key, "device-id": mm.pDeviceHandler.deviceID})
+ log.Fields{"key": Value.Key, "device-id": mm.deviceID})
tmpBytes, _ := kvstore.ToByte(Value.Value)
if err = json.Unmarshal(tmpBytes, &data); err != nil {
- logger.Errorw(ctx, "unable-to-unmarshal-data", log.Fields{"error": err, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-unmarshal-data", log.Fields{"error": err, "device-id": mm.deviceID})
return false, err
}
- logger.Debugw(ctx, "me-ext-pm-class-data", log.Fields{"class-id": data, "device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "me-ext-pm-class-data", log.Fields{"class-id": data, "device-id": mm.deviceID})
// We have found the data from db, no need to get through omci get message.
mm.supportedEthernetFrameExtendedPMClass = data
return true, nil
}
- logger.Debugw(ctx, "no-me-ext-pm-class-data-found", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Debugw(ctx, "no-me-ext-pm-class-data-found", log.Fields{"device-id": mm.deviceID})
return false, nil
}
- logger.Errorw(ctx, "unable-to-read-from-kv-store", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ logger.Errorw(ctx, "unable-to-read-from-kv-store", log.Fields{"device-id": mm.deviceID})
return false, err
}
-func (mm *onuMetricsManager) waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassID me.ClassID, upstream bool) (bool, error) {
+func (mm *OnuMetricsManager) waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx context.Context, create bool, instID uint16, meClassID me.ClassID, upstream bool) (bool, error) {
logger.Debugw(ctx, "wait-for-ethernet-frame-create-or-delete-response-or-timeout", log.Fields{"create": create, "instID": instID, "meClassID": meClassID})
select {
case resp := <-mm.extendedPMCreateOrDeleteResponseChan:
logger.Debugw(ctx, "received-extended-pm-me-response",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
+ log.Fields{"device-id": mm.deviceID, "resp": resp, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
// If the result is me.InstanceExists it means the entity was already created. It is ok handled that as success
if resp == me.Success || resp == me.InstanceExists {
return true, nil
@@ -2998,40 +3021,40 @@
resp == me.ProcessingError || resp == me.NotSupported || resp == me.AttributeFailure {
return false, fmt.Errorf("not-supported-me--resp-code-%v", resp)
} else {
- logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": resp, "class-id": meClassID, "instID": instID, "upstream": upstream})
+ logger.Warnw(ctx, "failed to create me", log.Fields{"device-id": mm.deviceID, "resp": resp, "class-id": meClassID, "instID": instID, "upstream": upstream})
return true, fmt.Errorf("error-while-creating-me--resp-code-%v", resp)
}
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout-waiting-for-ext-pm-me-response",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "resp": false, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
+ log.Fields{"device-id": mm.deviceID, "resp": false, "create": create, "meClassID": meClassID, "instID": instID, "upstream": upstream})
}
return false, fmt.Errorf("timeout-while-waiting-for-response")
}
-func (mm *onuMetricsManager) tryCreateExtPmMe(ctx context.Context, meType me.ClassID) (bool, error) {
+func (mm *OnuMetricsManager) tryCreateExtPmMe(ctx context.Context, meType me.ClassID) (bool, error) {
cnt := 0
// Create ME twice, one for each direction. Boolean true is used to indicate upstream and false for downstream.
for _, direction := range []bool{true, false} {
- for _, uniPort := range mm.pDeviceHandler.uniEntityMap {
+ for _, uniPort := range *mm.pDeviceHandler.GetUniEntityMap() {
var entityID uint16
if direction {
- entityID = uniPort.entityID + 0x100
+ entityID = uniPort.EntityID + 0x100
} else {
- entityID = uniPort.entityID
+ entityID = uniPort.EntityID
}
// parent entity id will be same for both direction
- controlBlock := mm.getControlBlockForExtendedPMDirection(ctx, direction, uniPort.entityID)
+ controlBlock := mm.getControlBlockForExtendedPMDirection(ctx, direction, uniPort.EntityID)
inner1:
// retry ExtendedPmCreateAttempts times to create the instance of PM
for cnt = 0; cnt < ExtendedPmCreateAttempts; cnt++ {
- meEnt, err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendCreateOrDeleteEthernetFrameExtendedPMME(
- ctx, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, direction, true,
- mm.pAdaptFsm.commChan, entityID, meType, controlBlock)
+ meEnt, err := mm.pOnuDeviceEntry.GetDevOmciCC().SendCreateOrDeleteEthernetFrameExtendedPMME(
+ ctx, mm.pDeviceHandler.GetOmciTimeout(), true, direction, true,
+ mm.PAdaptFsm.CommChan, entityID, meType, controlBlock)
if err != nil {
logger.Errorw(ctx, "EthernetFrameExtendedPMME-create-or-delete-failed",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+ log.Fields{"device-id": mm.deviceID})
return false, err
}
if supported, err := mm.waitForEthernetFrameCreateOrDeleteResponseOrTimeout(ctx, true, entityID, meType, direction); err == nil && supported {
@@ -3058,10 +3081,10 @@
return true, nil
}
-func (mm *onuMetricsManager) putExtPmMeKvStore(ctx context.Context) {
- key := fmt.Sprintf("%s/%s/%s", mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersVendorID,
- mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersEquipmentID,
- mm.pDeviceHandler.pOnuOmciDevice.sOnuPersistentData.PersActiveSwVersion)
+func (mm *OnuMetricsManager) putExtPmMeKvStore(ctx context.Context) {
+ key := fmt.Sprintf("%s/%s/%s", mm.pOnuDeviceEntry.GetPersVendorID(),
+ mm.pOnuDeviceEntry.GetPersEquipmentID(),
+ mm.pOnuDeviceEntry.GetPersActiveSwVersion())
// check if we get the supported type me for ethernet frame extended pm class id
if mm.supportedEthernetFrameExtendedPMClass == 0 {
logger.Error(ctx, "unable-to-get-any-supported-extended-pm-me-class")
@@ -3075,12 +3098,14 @@
}
}
-func (mm *onuMetricsManager) setAllExtPmMeCreatedFlag() {
+func (mm *OnuMetricsManager) setAllExtPmMeCreatedFlag() {
mm.onuEthernetFrameExtendedPmLock.Lock()
mm.isDeviceReadyToCollectExtendedPmStats = true
mm.onuEthernetFrameExtendedPmLock.Unlock()
}
-func (mm *onuMetricsManager) createEthernetFrameExtendedPMME(ctx context.Context) {
+
+// CreateEthernetFrameExtendedPMME - TODO: add comment
+func (mm *OnuMetricsManager) CreateEthernetFrameExtendedPMME(ctx context.Context) {
//get the type of extended frame pm me supported by onu first
exist, err := mm.getEthernetFrameExtendedMETypeFromKvStore(ctx)
if err != nil {
@@ -3090,7 +3115,7 @@
if exist {
// we have the me type, go ahead with the me type supported.
if _, err := mm.tryCreateExtPmMe(ctx, mm.supportedEthernetFrameExtendedPMClass); err != nil {
- logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+ logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.deviceID,
"meClassID": mm.supportedEthernetFrameExtendedPMClass})
return
}
@@ -3102,11 +3127,11 @@
supported64Bit, err := mm.tryCreateExtPmMe(ctx, me.EthernetFrameExtendedPm64BitClassID)
if err != nil && !supported64Bit {
logger.Errorw(ctx, "unable-to-create-me-type-as-it-is-not-supported",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "meClassID": me.EthernetFrameExtendedPm64BitClassID,
+ log.Fields{"device-id": mm.deviceID, "meClassID": me.EthernetFrameExtendedPm64BitClassID,
"supported": supported64Bit})
// Then Try with 32 bit type
if supported32Bit, err := mm.tryCreateExtPmMe(ctx, me.EthernetFrameExtendedPmClassID); err != nil {
- logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.pDeviceHandler.deviceID,
+ logger.Errorw(ctx, "unable-to-create-me-type", log.Fields{"device-id": mm.deviceID,
"meClassID": me.EthernetFrameExtendedPmClassID, "supported": supported32Bit})
} else if supported32Bit {
mm.supportedEthernetFrameExtendedPMClass = me.EthernetFrameExtendedPmClassID
@@ -3120,7 +3145,8 @@
}
}
-func (mm *onuMetricsManager) collectEthernetFrameExtendedPMCounters(ctx context.Context) *extension.SingleGetValueResponse {
+// CollectEthernetFrameExtendedPMCounters - TODO: add comment
+func (mm *OnuMetricsManager) CollectEthernetFrameExtendedPMCounters(ctx context.Context) *extension.SingleGetValueResponse {
errFunc := func(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
@@ -3188,9 +3214,9 @@
return &singleValResp
}
-func (mm *onuMetricsManager) collectEthernetFrameExtendedPMData(ctx context.Context, meEnt *me.ManagedEntity, entityID uint16, upstream bool, receivedMask *uint16) (map[string]uint64, extension.GetValueResponse_ErrorReason) {
+func (mm *OnuMetricsManager) collectEthernetFrameExtendedPMData(ctx context.Context, meEnt *me.ManagedEntity, entityID uint16, upstream bool, receivedMask *uint16) (map[string]uint64, extension.GetValueResponse_ErrorReason) {
var classID me.ClassID
- logger.Debugw(ctx, "collecting-data-for-ethernet-frame-extended-pm", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "upstream": upstream})
+ logger.Debugw(ctx, "collecting-data-for-ethernet-frame-extended-pm", log.Fields{"device-id": mm.deviceID, "entityID": entityID, "upstream": upstream})
classID = mm.supportedEthernetFrameExtendedPMClass
attributeMaskList := maskToEthernetFrameExtendedPM64Bit
@@ -3202,7 +3228,7 @@
for mask := range attributeMaskList {
if errResp, err := mm.populateEthernetFrameExtendedPMMetrics(ctx, classID, entityID, mask, ethPMData, upstream, &sumReceivedMask); err != nil {
logger.Errorw(ctx, "error-during-metric-collection",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+ log.Fields{"device-id": mm.deviceID, "entityID": entityID, "err": err})
return nil, errResp
}
if (mask == 0x3F00 || mask == 0x3800) && sumReceivedMask == 0 {
@@ -3217,22 +3243,22 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) populateEthernetFrameExtendedPMMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
+func (mm *OnuMetricsManager) populateEthernetFrameExtendedPMMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
requestedAttributesMask uint16, ethFrameExtPMData map[string]uint64, upstream bool, sumReceivedMask *uint16) (extension.GetValueResponse_ErrorReason, error) {
var meAttributes me.AttributeValueMap
logger.Debugw(ctx, "requesting-attributes", log.Fields{"attributes-mask": requestedAttributesMask, "entityID": entityID, "classID": classID})
- err := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMeWithAttributeMask(ctx, classID, entityID, requestedAttributesMask, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan)
+ err := mm.pOnuDeviceEntry.GetDevOmciCC().SendGetMeWithAttributeMask(ctx, classID, entityID, requestedAttributesMask, mm.pDeviceHandler.GetOmciTimeout(), true, mm.PAdaptFsm.CommChan)
if err != nil {
- logger.Errorw(ctx, "get-me-failed", log.Fields{"device-id": mm.pAdaptFsm.deviceID})
+ logger.Errorw(ctx, "get-me-failed", log.Fields{"device-id": mm.deviceID})
return extension.GetValueResponse_INTERNAL_ERROR, err
}
select {
case meAttributes = <-mm.extendedPmMeChan:
logger.Debugw(ctx, "received-extended-pm-data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
- case <-time.After(mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
+ case <-time.After(mm.pOnuDeviceEntry.GetDevOmciCC().GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "timeout-waiting-for-omci-get-response-for-received-extended-pm-data",
- log.Fields{"device-id": mm.pDeviceHandler.deviceID, "upstream": upstream, "entityID": entityID})
+ log.Fields{"device-id": mm.deviceID, "upstream": upstream, "entityID": entityID})
return extension.GetValueResponse_TIMEOUT, fmt.Errorf("timeout-waiting-for-omci-get-response-for-received-extended-pm-data")
}
if mm.supportedEthernetFrameExtendedPMClass == me.EthernetFrameExtendedPmClassID {
@@ -3248,7 +3274,7 @@
return extension.GetValueResponse_REASON_UNDEFINED, nil
}
-func (mm *onuMetricsManager) fillAllErrorCountersEthernetFrameExtendedPM(ethFrameExtPMData map[string]uint64) {
+func (mm *OnuMetricsManager) fillAllErrorCountersEthernetFrameExtendedPM(ethFrameExtPMData map[string]uint64) {
sourceMap := maskToEthernetFrameExtendedPM64Bit
errorCounterValue := UnsupportedCounterValue64bit
if mm.supportedEthernetFrameExtendedPMClass == me.EthernetFrameExtendedPmClassID {
@@ -3265,7 +3291,7 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) getEthFrameExtPMDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
+func (mm *OnuMetricsManager) getEthFrameExtPMDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
receivedMask := uint16(0)
switch requestedAttributesMask {
case 0x3F00:
@@ -3400,7 +3426,7 @@
}
// nolint: gocyclo
-func (mm *onuMetricsManager) getEthFrameExtPM64BitDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
+func (mm *OnuMetricsManager) getEthFrameExtPM64BitDataFromResponse(ctx context.Context, ethFrameExtPMData map[string]uint64, meAttributes me.AttributeValueMap, requestedAttributesMask uint16) uint16 {
receivedMask := uint16(0)
switch requestedAttributesMask {
case 0x3800:
@@ -3544,7 +3570,7 @@
return receivedMask
}
-func (mm *onuMetricsManager) aggregateEthernetFrameExtendedPM(pmDataIn map[string]uint64, pmData extension.OmciEthernetFrameExtendedPm, aggregate bool) extension.OmciEthernetFrameExtendedPm {
+func (mm *OnuMetricsManager) aggregateEthernetFrameExtendedPM(pmDataIn map[string]uint64, pmData extension.OmciEthernetFrameExtendedPm, aggregate bool) extension.OmciEthernetFrameExtendedPm {
mm.onuEthernetFrameExtendedPmLock.Lock()
defer mm.onuEthernetFrameExtendedPmLock.Unlock()
errorCounterValue := UnsupportedCounterValue64bit
@@ -3642,7 +3668,7 @@
return pmDataOut
}
-func (mm *onuMetricsManager) getControlBlockForExtendedPMDirection(ctx context.Context, upstream bool, entityID uint16) []uint16 {
+func (mm *OnuMetricsManager) getControlBlockForExtendedPMDirection(ctx context.Context, upstream bool, entityID uint16) []uint16 {
controlBlock := make([]uint16, 8)
// Control Block First two bytes are for threshold data 1/2 id - does not matter here
controlBlock[0] = 0
diff --git a/internal/pkg/onuadaptercore/adapter_download_manager.go b/internal/pkg/swupg/adapter_download_manager.go
old mode 100644
new mode 100755
similarity index 89%
rename from internal/pkg/onuadaptercore/adapter_download_manager.go
rename to internal/pkg/swupg/adapter_download_manager.go
index 6328f72..64f5324
--- a/internal/pkg/onuadaptercore/adapter_download_manager.go
+++ b/internal/pkg/swupg/adapter_download_manager.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
import (
"bufio"
@@ -43,23 +43,23 @@
// ### downloadToAdapter - end ####
-//adapterDownloadManager structure holds information needed for downloading to and storing images within the adapter
-type adapterDownloadManager struct {
+//AdapterDownloadManager structure holds information needed for downloading to and storing images within the adapter
+type AdapterDownloadManager struct {
mutexDownloadImageDsc sync.RWMutex
downloadImageDscSlice []*voltha.ImageDownload
}
-//newAdapterDownloadManager constructor returns a new instance of a adapterDownloadManager
+//NewAdapterDownloadManager constructor returns a new instance of a AdapterDownloadManager
//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newAdapterDownloadManager(ctx context.Context) *adapterDownloadManager {
- logger.Debug(ctx, "init-adapterDownloadManager")
- var localDnldMgr adapterDownloadManager
+func NewAdapterDownloadManager(ctx context.Context) *AdapterDownloadManager {
+ logger.Debug(ctx, "init-AdapterDownloadManager")
+ var localDnldMgr AdapterDownloadManager
localDnldMgr.downloadImageDscSlice = make([]*voltha.ImageDownload, 0)
return &localDnldMgr
}
-//imageExists returns true if the requested image already exists within the adapter
-func (dm *adapterDownloadManager) imageExists(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
+//ImageExists returns true if the requested image already exists within the adapter
+func (dm *AdapterDownloadManager) ImageExists(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
logger.Debugw(ctx, "checking on existence of the image", log.Fields{"image-name": (*apImageDsc).Name})
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
@@ -74,8 +74,8 @@
return false
}
-//imageLocallyDownloaded returns true if the requested image already exists within the adapter
-func (dm *adapterDownloadManager) imageLocallyDownloaded(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
+//ImageLocallyDownloaded returns true if the requested image already exists within the adapter
+func (dm *AdapterDownloadManager) ImageLocallyDownloaded(ctx context.Context, apImageDsc *voltha.ImageDownload) bool {
logger.Debugw(ctx, "checking if image is fully downloaded", log.Fields{"image-name": (*apImageDsc).Name})
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
@@ -96,8 +96,8 @@
return false
}
-//startDownload returns true if the download of the requested image could be started
-func (dm *adapterDownloadManager) startDownload(ctx context.Context, apImageDsc *voltha.ImageDownload) error {
+//StartDownload returns true if the download of the requested image could be started
+func (dm *AdapterDownloadManager) StartDownload(ctx context.Context, apImageDsc *voltha.ImageDownload) error {
if apImageDsc.LocalDir != "" {
logger.Infow(ctx, "image download-to-adapter requested", log.Fields{
"image-path": apImageDsc.LocalDir, "image-name": apImageDsc.Name})
@@ -120,7 +120,7 @@
}
//downloadFile downloads the specified file from the given http location
-func (dm *adapterDownloadManager) downloadFile(ctx context.Context, aURLName string, aFilePath string, aFileName string) error {
+func (dm *AdapterDownloadManager) downloadFile(ctx context.Context, aURLName string, aFilePath string, aFileName string) error {
// Get the data
logger.Infow(ctx, "downloading from http", log.Fields{"url": aURLName, "localPath": aFilePath})
// http command is already part of the aURLName argument
@@ -173,7 +173,7 @@
return nil
}
-func (dm *adapterDownloadManager) requestDownload(ctx context.Context, urlBase *url.URL, aFilePath, aFileName string) {
+func (dm *AdapterDownloadManager) requestDownload(ctx context.Context, urlBase *url.URL, aFilePath, aFileName string) {
req, err2 := http.NewRequest("GET", urlBase.String(), nil)
if err2 != nil {
logger.Errorw(ctx, "could not generate http request", log.Fields{"url": urlBase.String(), "error": err2})
@@ -238,7 +238,7 @@
}
//getImageBufferLen returns the length of the specified file in bytes (file size)
-func (dm *adapterDownloadManager) getImageBufferLen(ctx context.Context, aFileName string,
+func (dm *AdapterDownloadManager) getImageBufferLen(ctx context.Context, aFileName string,
aLocalPath string) (int64, error) {
//maybe we can also use FileSize from dm.downloadImageDscSlice - future option?
@@ -262,7 +262,7 @@
}
//getDownloadImageBuffer returns the content of the requested file as byte slice
-func (dm *adapterDownloadManager) getDownloadImageBuffer(ctx context.Context, aFileName string,
+func (dm *AdapterDownloadManager) getDownloadImageBuffer(ctx context.Context, aFileName string,
aLocalPath string) ([]byte, error) {
file, err := os.Open(filepath.Clean(aLocalPath + "/" + aFileName))
if err != nil {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/swupg/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/swupg/common.go
index b0b10e3..b933bef
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/swupg/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "swupg"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/file_download_manager.go b/internal/pkg/swupg/file_download_manager.go
old mode 100644
new mode 100755
similarity index 92%
rename from internal/pkg/onuadaptercore/file_download_manager.go
rename to internal/pkg/swupg/file_download_manager.go
index 5c3226e..900ba5a
--- a/internal/pkg/onuadaptercore/file_download_manager.go
+++ b/internal/pkg/swupg/file_download_manager.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
import (
"bufio"
@@ -57,19 +57,19 @@
type requesterChannelMap map[chan<- bool]struct{} //using an empty structure map for easier (unique) element appending
-//fileDownloadManager structure holds information needed for downloading to and storing images within the adapter
-type fileDownloadManager struct {
+//FileDownloadManager structure holds information needed for downloading to and storing images within the adapter
+type FileDownloadManager struct {
mutexDownloadImageDsc sync.RWMutex
downloadImageDscSlice []downloadImageParams
dnldImgReadyWaiting map[string]requesterChannelMap
dlToAdapterTimeout time.Duration
}
-//newFileDownloadManager constructor returns a new instance of a fileDownloadManager
+//NewFileDownloadManager constructor returns a new instance of a FileDownloadManager
//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
-func newFileDownloadManager(ctx context.Context) *fileDownloadManager {
- logger.Debug(ctx, "init-fileDownloadManager")
- var localDnldMgr fileDownloadManager
+func NewFileDownloadManager(ctx context.Context) *FileDownloadManager {
+ logger.Debug(ctx, "init-FileDownloadManager")
+ var localDnldMgr FileDownloadManager
localDnldMgr.downloadImageDscSlice = make([]downloadImageParams, 0)
localDnldMgr.dnldImgReadyWaiting = make(map[string]requesterChannelMap)
localDnldMgr.dlToAdapterTimeout = 10 * time.Second //default timeout, should be overwritten immediately after start
@@ -77,7 +77,7 @@
}
//SetDownloadTimeout configures the timeout used to supervice the download of the image to the adapter (assumed in seconds)
-func (dm *fileDownloadManager) SetDownloadTimeout(ctx context.Context, aDlTimeout time.Duration) {
+func (dm *FileDownloadManager) SetDownloadTimeout(ctx context.Context, aDlTimeout time.Duration) {
dm.mutexDownloadImageDsc.Lock()
defer dm.mutexDownloadImageDsc.Unlock()
logger.Debugw(ctx, "setting download timeout", log.Fields{"timeout": aDlTimeout})
@@ -85,14 +85,14 @@
}
//GetDownloadTimeout delivers the timeout used to supervice the download of the image to the adapter (assumed in seconds)
-func (dm *fileDownloadManager) GetDownloadTimeout(ctx context.Context) time.Duration {
+func (dm *FileDownloadManager) GetDownloadTimeout(ctx context.Context) time.Duration {
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
return dm.dlToAdapterTimeout
}
//ImageExists returns true if the requested image already exists within the adapter
-func (dm *fileDownloadManager) ImageExists(ctx context.Context, aImageName string) bool {
+func (dm *FileDownloadManager) ImageExists(ctx context.Context, aImageName string) bool {
logger.Debugw(ctx, "checking on existence of the image", log.Fields{"image-name": aImageName})
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
@@ -108,7 +108,7 @@
}
//StartDownload returns true if the download of the requested image could be started for the given file name and URL
-func (dm *fileDownloadManager) StartDownload(ctx context.Context, aImageName string, aURLCommand string) error {
+func (dm *FileDownloadManager) StartDownload(ctx context.Context, aImageName string, aURLCommand string) error {
logger.Infow(ctx, "image download-to-adapter requested", log.Fields{
"image-name": aImageName, "url-command": aURLCommand})
loDownloadImageParams := downloadImageParams{
@@ -126,7 +126,7 @@
}
//GetImageBufferLen returns the length of the specified file in bytes (file size) - as detected after download
-func (dm *fileDownloadManager) GetImageBufferLen(ctx context.Context, aFileName string) (int64, error) {
+func (dm *FileDownloadManager) GetImageBufferLen(ctx context.Context, aFileName string) (int64, error) {
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
for _, dnldImgDsc := range dm.downloadImageDscSlice {
@@ -139,7 +139,7 @@
}
//GetDownloadImageBuffer returns the content of the requested file as byte slice
-func (dm *fileDownloadManager) GetDownloadImageBuffer(ctx context.Context, aFileName string) ([]byte, error) {
+func (dm *FileDownloadManager) GetDownloadImageBuffer(ctx context.Context, aFileName string) ([]byte, error) {
file, err := os.Open(filepath.Clean(cDefaultLocalDir + "/" + aFileName))
if err != nil {
return nil, err
@@ -166,7 +166,7 @@
}
//RequestDownloadReady receives a channel that has to be used to inform the requester in case the concerned file is downloaded
-func (dm *fileDownloadManager) RequestDownloadReady(ctx context.Context, aFileName string, aWaitChannel chan<- bool) {
+func (dm *FileDownloadManager) RequestDownloadReady(ctx context.Context, aFileName string, aWaitChannel chan<- bool) {
//mutexDownloadImageDsc must already be locked here to avoid an update of the dnldImgReadyWaiting map
// just after returning false on imageLocallyDownloaded() (not found) and immediate handling of the
// download success (within updateFileState())
@@ -201,7 +201,7 @@
}
//RemoveReadyRequest removes the specified channel from the requester(channel) map for the given file name
-func (dm *fileDownloadManager) RemoveReadyRequest(ctx context.Context, aFileName string, aWaitChannel chan bool) {
+func (dm *FileDownloadManager) RemoveReadyRequest(ctx context.Context, aFileName string, aWaitChannel chan bool) {
dm.mutexDownloadImageDsc.Lock()
defer dm.mutexDownloadImageDsc.Unlock()
for imageName, channelMap := range dm.dnldImgReadyWaiting {
@@ -223,7 +223,7 @@
//imageLocallyDownloaded returns true if the requested image already exists within the adapter
// requires mutexDownloadImageDsc to be locked (at least RLocked)
-func (dm *fileDownloadManager) imageLocallyDownloaded(ctx context.Context, aImageName string) bool {
+func (dm *FileDownloadManager) imageLocallyDownloaded(ctx context.Context, aImageName string) bool {
logger.Debugw(ctx, "checking if image is fully downloaded to adapter", log.Fields{"image-name": aImageName})
for _, dnldImgDsc := range dm.downloadImageDscSlice {
if dnldImgDsc.downloadImageName == aImageName {
@@ -242,7 +242,7 @@
}
//updateDownloadCancel sets context cancel function to be used in case the download is to be aborted
-func (dm *fileDownloadManager) updateDownloadCancel(ctx context.Context,
+func (dm *FileDownloadManager) updateDownloadCancel(ctx context.Context,
aImageName string, aCancelFn context.CancelFunc) {
dm.mutexDownloadImageDsc.Lock()
defer dm.mutexDownloadImageDsc.Unlock()
@@ -259,7 +259,7 @@
}
//updateFileState sets the new active (downloaded) file state and informs possibly waiting requesters on this change
-func (dm *fileDownloadManager) updateFileState(ctx context.Context, aImageName string, aFileSize int64) {
+func (dm *FileDownloadManager) updateFileState(ctx context.Context, aImageName string, aFileSize int64) {
dm.mutexDownloadImageDsc.Lock()
defer dm.mutexDownloadImageDsc.Unlock()
for imgKey, dnldImgDsc := range dm.downloadImageDscSlice {
@@ -287,7 +287,7 @@
}
//downloadFile downloads the specified file from the given http location
-func (dm *fileDownloadManager) downloadFile(ctx context.Context, aURLCommand string, aFilePath string, aFileName string) error {
+func (dm *FileDownloadManager) downloadFile(ctx context.Context, aURLCommand string, aFilePath string, aFileName string) error {
// Get the data
logger.Infow(ctx, "downloading with URL", log.Fields{"url": aURLCommand, "localPath": aFilePath})
// verifying the complete URL by parsing it to its URL elements
@@ -402,7 +402,7 @@
}
//removeImage deletes the given image according to the Image name from filesystem and downloadImageDscSlice
-func (dm *fileDownloadManager) removeImage(ctx context.Context, aImageName string, aDelFs bool) {
+func (dm *FileDownloadManager) removeImage(ctx context.Context, aImageName string, aDelFs bool) {
logger.Debugw(ctx, "remove the image from Adapter", log.Fields{"image-name": aImageName})
dm.mutexDownloadImageDsc.RLock()
defer dm.mutexDownloadImageDsc.RUnlock()
@@ -431,7 +431,7 @@
}
//CancelDownload stops the download and clears all entires concerning this aimageName
-func (dm *fileDownloadManager) CancelDownload(ctx context.Context, aImageName string) {
+func (dm *FileDownloadManager) CancelDownload(ctx context.Context, aImageName string) {
// for the moment that would only support to wait for the download end and remove the image then
// further reactions while still downloading can be considered with some effort, but does it make sense (synchronous load here!)
dm.mutexDownloadImageDsc.RLock()
diff --git a/internal/pkg/onuadaptercore/omci_onu_upgrade.go b/internal/pkg/swupg/omci_onu_upgrade.go
old mode 100644
new mode 100755
similarity index 79%
rename from internal/pkg/onuadaptercore/omci_onu_upgrade.go
rename to internal/pkg/swupg/omci_onu_upgrade.go
index 8e8a82e..dbcb141
--- a/internal/pkg/onuadaptercore/omci_onu_upgrade.go
+++ b/internal/pkg/swupg/omci_onu_upgrade.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
import (
"context"
@@ -30,6 +30,8 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
+ "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
@@ -47,71 +49,71 @@
//cOmciDownloadCompleteTimeout = 5400 //in s for the complete timeout (may be better scale to image size/ noOfWindows)
)
+// events of config PON ANI port FSM
const (
- // events of config PON ANI port FSM
- upgradeEvStart = "upgradeEvStart"
- upgradeEvDisable = "upgradeEvDisable"
- upgradeEvAdapterDownload = "upgradeEvAdapterDownload"
- upgradeEvPrepareSwDownload = "upgradeEvPrepareSwDownload"
- upgradeEvRxStartSwDownload = "upgradeEvRxStartSwDownload"
- upgradeEvWaitWindowAck = "upgradeEvWaitWindowAck"
- upgradeEvContinueNextWindow = "upgradeEvContinueNextWindow"
- upgradeEvEndSwDownload = "upgradeEvEndSwDownload"
- upgradeEvWaitEndDownload = "upgradeEvWaitEndDownload"
- upgradeEvContinueFinalize = "upgradeEvContinueFinalize"
- upgradeEvCheckImageName = "upgradeEvCheckImageName"
- upgradeEvWaitForActivate = "upgradeEvWaitForActivate"
- upgradeEvRequestActivate = "upgradeEvRequestActivate"
- upgradeEvActivationDone = "upgradeEvActivationDone"
- upgradeEvWaitForCommit = "upgradeEvWaitForCommit"
- upgradeEvCommitSw = "upgradeEvCommitSw"
- upgradeEvCheckCommitted = "upgradeEvCheckCommitted"
+ UpgradeEvStart = "UpgradeEvStart"
+ UpgradeEvDisable = "UpgradeEvDisable"
+ UpgradeEvAdapterDownload = "UpgradeEvAdapterDownload"
+ UpgradeEvPrepareSwDownload = "UpgradeEvPrepareSwDownload"
+ UpgradeEvRxStartSwDownload = "UpgradeEvRxStartSwDownload"
+ UpgradeEvWaitWindowAck = "UpgradeEvWaitWindowAck"
+ UpgradeEvContinueNextWindow = "UpgradeEvContinueNextWindow"
+ UpgradeEvEndSwDownload = "UpgradeEvEndSwDownload"
+ UpgradeEvWaitEndDownload = "UpgradeEvWaitEndDownload"
+ UpgradeEvContinueFinalize = "UpgradeEvContinueFinalize"
+ UpgradeEvCheckImageName = "UpgradeEvCheckImageName"
+ UpgradeEvWaitForActivate = "UpgradeEvWaitForActivate"
+ UpgradeEvRequestActivate = "UpgradeEvRequestActivate"
+ UpgradeEvActivationDone = "UpgradeEvActivationDone"
+ UpgradeEvWaitForCommit = "UpgradeEvWaitForCommit"
+ UpgradeEvCommitSw = "UpgradeEvCommitSw"
+ UpgradeEvCheckCommitted = "UpgradeEvCheckCommitted"
- //upgradeEvTimeoutSimple = "upgradeEvTimeoutSimple"
- //upgradeEvTimeoutMids = "upgradeEvTimeoutMids"
- upgradeEvReset = "upgradeEvReset"
- upgradeEvAbort = "upgradeEvAbort"
- upgradeEvRestart = "upgradeEvRestart"
- upgradeEvAbortSwDownload = "upgradeEvAbortSwDownload"
+ //UpgradeEvTimeoutSimple = "UpgradeEvTimeoutSimple"
+ //UpgradeEvTimeoutMids = "UpgradeEvTimeoutMids"
+ UpgradeEvReset = "UpgradeEvReset"
+ UpgradeEvAbort = "UpgradeEvAbort"
+ UpgradeEvRestart = "UpgradeEvRestart"
+ UpgradeEvAbortSwDownload = "UpgradeEvAbortSwDownload"
)
+// states of config PON ANI port FSM
const (
- // states of config PON ANI port FSM
- upgradeStDisabled = "upgradeStDisabled"
- upgradeStStarting = "upgradeStStarting"
- upgradeStWaitingAdapterDL = "upgradeStWaitingAdapterDL"
- upgradeStPreparingDL = "upgradeStPreparingDL"
- upgradeStDLSection = "upgradeStDLSection"
- upgradeStVerifyWindow = "upgradeStVerifyWindow"
- upgradeStFinalizeDL = "upgradeStFinalizeDL"
- upgradeStWaitEndDL = "upgradeStWaitEndDL"
- upgradeStCheckImageName = "upgradeStCheckImageName"
- upgradeStWaitForActivate = "upgradeStWaitForActivate"
- upgradeStRequestingActivate = "upgradeStRequestingActivate"
- upgradeStActivated = "upgradeStActivated"
- upgradeStWaitForCommit = "upgradeStWaitForCommit"
- upgradeStCommitSw = "upgradeStCommitSw"
- upgradeStCheckCommitted = "upgradeStCheckCommitted"
- upgradeStResetting = "upgradeStResetting"
- upgradeStRestarting = "upgradeStRestarting"
- upgradeStAbortingDL = "upgradeStAbortingDL"
+ UpgradeStDisabled = "UpgradeStDisabled"
+ UpgradeStStarting = "UpgradeStStarting"
+ UpgradeStWaitingAdapterDL = "UpgradeStWaitingAdapterDL"
+ UpgradeStPreparingDL = "UpgradeStPreparingDL"
+ UpgradeStDLSection = "UpgradeStDLSection"
+ UpgradeStVerifyWindow = "UpgradeStVerifyWindow"
+ UpgradeStFinalizeDL = "UpgradeStFinalizeDL"
+ UpgradeStWaitEndDL = "UpgradeStWaitEndDL"
+ UpgradeStCheckImageName = "UpgradeStCheckImageName"
+ UpgradeStWaitForActivate = "UpgradeStWaitForActivate"
+ UpgradeStRequestingActivate = "UpgradeStRequestingActivate"
+ UpgradeStActivated = "UpgradeStActivated"
+ UpgradeStWaitForCommit = "UpgradeStWaitForCommit"
+ UpgradeStCommitSw = "UpgradeStCommitSw"
+ UpgradeStCheckCommitted = "UpgradeStCheckCommitted"
+ UpgradeStResetting = "UpgradeStResetting"
+ UpgradeStRestarting = "UpgradeStRestarting"
+ UpgradeStAbortingDL = "UpgradeStAbortingDL"
)
-//required definition for IdleState detection for activities on OMCI
-const cOnuUpgradeFsmIdleState = upgradeStWaitForCommit
+//COnuUpgradeFsmIdleState - required definition for IdleState detection for activities on OMCI
+const COnuUpgradeFsmIdleState = UpgradeStWaitForCommit
//OnuUpgradeFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
type OnuUpgradeFsm struct {
- pDeviceHandler *deviceHandler
- pDownloadManager *adapterDownloadManager
- pFileManager *fileDownloadManager //used from R2.8 with new API version
+ pDeviceHandler cmn.IdeviceHandler
+ pDownloadManager *AdapterDownloadManager
+ pFileManager *FileDownloadManager //used from R2.8 with new API version
deviceID string
- pDevEntry *OnuDeviceEntry
- pOmciCC *omciCC
- pOnuDB *onuDeviceDB
- requestEvent OnuDeviceEvent
+ pDevEntry cmn.IonuDeviceEntry
+ pOmciCC *cmn.OmciCC
+ pOnuDB *devdb.OnuDeviceDB
+ requestEvent cmn.OnuDeviceEvent
//omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses
- pAdaptFsm *AdapterFsm
+ PAdaptFsm *cmn.AdapterFsm
pImageDsc *voltha.ImageDownload
imageBuffer []byte
origImageLength uint32 //as also limited by OMCI
@@ -124,7 +126,7 @@
nextDownloadSectionsWindow uint8 //number of next section to download within current window
noOfWindows uint32 //uint32 range for windows should be sufficient for very long images
nextDownloadWindow uint32 //number of next window to download
- inactiveImageMeID uint16 //ME-ID of the inactive image
+ InactiveImageMeID uint16 //ME-ID of the inactive image
downloadToOnuTimeout4MB time.Duration //timeout for downloading the image to the ONU for a 4MB image slice
omciSectionInterleaveDelay time.Duration //DownloadSectionInterleave delay in milliseconds
delayEndSwDl bool //flag to provide a delay between last section and EndSwDl
@@ -154,19 +156,19 @@
//NewOnuUpgradeFsm is the 'constructor' for the state machine to config the PON ANI ports
// of ONU UNI ports via OMCI
-func NewOnuUpgradeFsm(ctx context.Context, apDeviceHandler *deviceHandler,
- apDevEntry *OnuDeviceEntry, apOnuDB *onuDeviceDB,
- aRequestEvent OnuDeviceEvent, aName string, aCommChannel chan Message) *OnuUpgradeFsm {
+func NewOnuUpgradeFsm(ctx context.Context, apDeviceHandler cmn.IdeviceHandler,
+ apDevEntry cmn.IonuDeviceEntry, apOnuDB *devdb.OnuDeviceDB,
+ aRequestEvent cmn.OnuDeviceEvent, aName string, aCommChannel chan cmn.Message) *OnuUpgradeFsm {
instFsm := &OnuUpgradeFsm{
pDeviceHandler: apDeviceHandler,
- deviceID: apDeviceHandler.deviceID,
+ deviceID: apDeviceHandler.GetDeviceID(),
pDevEntry: apDevEntry,
- pOmciCC: apDevEntry.PDevOmciCC,
+ pOmciCC: apDevEntry.GetDevOmciCC(),
pOnuDB: apOnuDB,
requestEvent: aRequestEvent,
omciDownloadWindowSizeLimit: cOmciDownloadWindowSizeLimit,
omciSectionInterleaveDelay: cOmciSectionInterleaveMilliseconds,
- downloadToOnuTimeout4MB: apDeviceHandler.pOpenOnuAc.dlToOnuTimeout4M,
+ downloadToOnuTimeout4MB: apDeviceHandler.GetDlToOnuTimeout4M(),
waitCountEndSwDl: cWaitCountEndSwDl,
waitDelayEndSwDl: cWaitDelayEndSwDlSeconds,
volthaDownloadState: voltha.ImageState_DOWNLOAD_STARTED, //if FSM created we can assume that the download (to adapter) really started
@@ -179,81 +181,81 @@
instFsm.chOnuDlReady = make(chan bool)
instFsm.chReceiveAbortEndSwDlResponse = make(chan bool)
- instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
- if instFsm.pAdaptFsm == nil {
+ instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+ if instFsm.PAdaptFsm == nil {
logger.Errorw(ctx, "OnuUpgradeFsm's AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
- upgradeStDisabled,
+ instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+ UpgradeStDisabled,
fsm.Events{
- {Name: upgradeEvStart, Src: []string{upgradeStDisabled}, Dst: upgradeStStarting},
- {Name: upgradeEvAdapterDownload, Src: []string{upgradeStStarting}, Dst: upgradeStWaitingAdapterDL},
- {Name: upgradeEvPrepareSwDownload, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL}, Dst: upgradeStPreparingDL},
- {Name: upgradeEvRxStartSwDownload, Src: []string{upgradeStPreparingDL}, Dst: upgradeStDLSection},
- {Name: upgradeEvWaitWindowAck, Src: []string{upgradeStDLSection}, Dst: upgradeStVerifyWindow},
- {Name: upgradeEvContinueNextWindow, Src: []string{upgradeStVerifyWindow}, Dst: upgradeStDLSection},
- {Name: upgradeEvEndSwDownload, Src: []string{upgradeStVerifyWindow}, Dst: upgradeStFinalizeDL},
- {Name: upgradeEvWaitEndDownload, Src: []string{upgradeStFinalizeDL}, Dst: upgradeStWaitEndDL},
- {Name: upgradeEvContinueFinalize, Src: []string{upgradeStWaitEndDL}, Dst: upgradeStFinalizeDL},
- //upgradeStCheckImageName only used with useAPIVersion43
- {Name: upgradeEvCheckImageName, Src: []string{upgradeStWaitEndDL}, Dst: upgradeStCheckImageName},
- //upgradeEvWaitForActivate state transitions depend on useAPIVersion43
- {Name: upgradeEvWaitForActivate, Src: []string{upgradeStWaitEndDL, upgradeStCheckImageName}, Dst: upgradeStWaitForActivate},
- //upgradeEvRequestActivate state transitions depend on useAPIVersion43
- {Name: upgradeEvRequestActivate, Src: []string{upgradeStStarting, upgradeStWaitEndDL, upgradeStCheckImageName,
- upgradeStWaitForActivate}, Dst: upgradeStRequestingActivate}, //allows also for direct activation (without download) [TODO!!!]
- {Name: upgradeEvActivationDone, Src: []string{upgradeStRequestingActivate}, Dst: upgradeStActivated},
- {Name: upgradeEvWaitForCommit, Src: []string{upgradeStRequestingActivate}, Dst: upgradeStWaitForCommit},
- {Name: upgradeEvCommitSw, Src: []string{upgradeStStarting, upgradeStRequestingActivate, upgradeStWaitForCommit,
- upgradeStActivated}, Dst: upgradeStCommitSw}, //allows also for direct commitment (without download) [TODO!!!]
- {Name: upgradeEvCheckCommitted, Src: []string{upgradeStCommitSw}, Dst: upgradeStCheckCommitted},
+ {Name: UpgradeEvStart, Src: []string{UpgradeStDisabled}, Dst: UpgradeStStarting},
+ {Name: UpgradeEvAdapterDownload, Src: []string{UpgradeStStarting}, Dst: UpgradeStWaitingAdapterDL},
+ {Name: UpgradeEvPrepareSwDownload, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL}, Dst: UpgradeStPreparingDL},
+ {Name: UpgradeEvRxStartSwDownload, Src: []string{UpgradeStPreparingDL}, Dst: UpgradeStDLSection},
+ {Name: UpgradeEvWaitWindowAck, Src: []string{UpgradeStDLSection}, Dst: UpgradeStVerifyWindow},
+ {Name: UpgradeEvContinueNextWindow, Src: []string{UpgradeStVerifyWindow}, Dst: UpgradeStDLSection},
+ {Name: UpgradeEvEndSwDownload, Src: []string{UpgradeStVerifyWindow}, Dst: UpgradeStFinalizeDL},
+ {Name: UpgradeEvWaitEndDownload, Src: []string{UpgradeStFinalizeDL}, Dst: UpgradeStWaitEndDL},
+ {Name: UpgradeEvContinueFinalize, Src: []string{UpgradeStWaitEndDL}, Dst: UpgradeStFinalizeDL},
+ //UpgradeStCheckImageName only used with useAPIVersion43
+ {Name: UpgradeEvCheckImageName, Src: []string{UpgradeStWaitEndDL}, Dst: UpgradeStCheckImageName},
+ //UpgradeEvWaitForActivate state transitions depend on useAPIVersion43
+ {Name: UpgradeEvWaitForActivate, Src: []string{UpgradeStWaitEndDL, UpgradeStCheckImageName}, Dst: UpgradeStWaitForActivate},
+ //UpgradeEvRequestActivate state transitions depend on useAPIVersion43
+ {Name: UpgradeEvRequestActivate, Src: []string{UpgradeStStarting, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+ UpgradeStWaitForActivate}, Dst: UpgradeStRequestingActivate}, //allows also for direct activation (without download) [TODO!!!]
+ {Name: UpgradeEvActivationDone, Src: []string{UpgradeStRequestingActivate}, Dst: UpgradeStActivated},
+ {Name: UpgradeEvWaitForCommit, Src: []string{UpgradeStRequestingActivate}, Dst: UpgradeStWaitForCommit},
+ {Name: UpgradeEvCommitSw, Src: []string{UpgradeStStarting, UpgradeStRequestingActivate, UpgradeStWaitForCommit,
+ UpgradeStActivated}, Dst: UpgradeStCommitSw}, //allows also for direct commitment (without download) [TODO!!!]
+ {Name: UpgradeEvCheckCommitted, Src: []string{UpgradeStCommitSw}, Dst: UpgradeStCheckCommitted},
/*
- {Name: upgradeEvTimeoutSimple, Src: []string{
- upgradeStCreatingDot1PMapper, upgradeStCreatingMBPCD, upgradeStSettingTconts, upgradeStSettingDot1PMapper}, Dst: upgradeStStarting},
- {Name: upgradeEvTimeoutMids, Src: []string{
- upgradeStCreatingGemNCTPs, upgradeStCreatingGemIWs, upgradeStSettingPQs}, Dst: upgradeStStarting},
+ {Name: UpgradeEvTimeoutSimple, Src: []string{
+ UpgradeStCreatingDot1PMapper, UpgradeStCreatingMBPCD, UpgradeStSettingTconts, UpgradeStSettingDot1PMapper}, Dst: UpgradeStStarting},
+ {Name: UpgradeEvTimeoutMids, Src: []string{
+ UpgradeStCreatingGemNCTPs, UpgradeStCreatingGemIWs, UpgradeStSettingPQs}, Dst: UpgradeStStarting},
*/
// exceptional treatments
- //on upgradeEvReset: upgradeStRequestingActivate, upgradeStWaitForCommit and upgradeStActivated are not reset
+ //on UpgradeEvReset: UpgradeStRequestingActivate, UpgradeStWaitForCommit and UpgradeStActivated are not reset
// (to let the FSM survive the expected OnuDown indication)
- {Name: upgradeEvReset, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL, upgradeStPreparingDL, upgradeStDLSection,
- upgradeStVerifyWindow, upgradeStDLSection, upgradeStFinalizeDL, upgradeStWaitEndDL, upgradeStCheckImageName,
- upgradeStWaitForActivate,
- upgradeStCommitSw, upgradeStCheckCommitted},
- Dst: upgradeStResetting},
- {Name: upgradeEvAbort, Src: []string{upgradeStStarting, upgradeStWaitingAdapterDL, upgradeStPreparingDL, upgradeStDLSection,
- upgradeStVerifyWindow, upgradeStDLSection, upgradeStFinalizeDL, upgradeStWaitEndDL, upgradeStCheckImageName,
- upgradeStWaitForActivate,
- upgradeStRequestingActivate, upgradeStActivated, upgradeStWaitForCommit,
- upgradeStCommitSw, upgradeStCheckCommitted},
- Dst: upgradeStResetting},
- {Name: upgradeEvAbortSwDownload, Src: []string{upgradeStResetting}, Dst: upgradeStAbortingDL},
- {Name: upgradeEvRestart, Src: []string{upgradeStResetting, upgradeStAbortingDL}, Dst: upgradeStRestarting},
- {Name: upgradeEvDisable, Src: []string{upgradeStRestarting}, Dst: upgradeStDisabled},
+ {Name: UpgradeEvReset, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL, UpgradeStPreparingDL, UpgradeStDLSection,
+ UpgradeStVerifyWindow, UpgradeStDLSection, UpgradeStFinalizeDL, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+ UpgradeStWaitForActivate,
+ UpgradeStCommitSw, UpgradeStCheckCommitted},
+ Dst: UpgradeStResetting},
+ {Name: UpgradeEvAbort, Src: []string{UpgradeStStarting, UpgradeStWaitingAdapterDL, UpgradeStPreparingDL, UpgradeStDLSection,
+ UpgradeStVerifyWindow, UpgradeStDLSection, UpgradeStFinalizeDL, UpgradeStWaitEndDL, UpgradeStCheckImageName,
+ UpgradeStWaitForActivate,
+ UpgradeStRequestingActivate, UpgradeStActivated, UpgradeStWaitForCommit,
+ UpgradeStCommitSw, UpgradeStCheckCommitted},
+ Dst: UpgradeStResetting},
+ {Name: UpgradeEvAbortSwDownload, Src: []string{UpgradeStResetting}, Dst: UpgradeStAbortingDL},
+ {Name: UpgradeEvRestart, Src: []string{UpgradeStResetting, UpgradeStAbortingDL}, Dst: UpgradeStRestarting},
+ {Name: UpgradeEvDisable, Src: []string{UpgradeStRestarting}, Dst: UpgradeStDisabled},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
- "enter_" + upgradeStStarting: func(e *fsm.Event) { instFsm.enterStarting(ctx, e) },
- "enter_" + upgradeStWaitingAdapterDL: func(e *fsm.Event) { instFsm.enterWaitingAdapterDL(ctx, e) },
- "enter_" + upgradeStPreparingDL: func(e *fsm.Event) { instFsm.enterPreparingDL(ctx, e) },
- "enter_" + upgradeStDLSection: func(e *fsm.Event) { instFsm.enterDownloadSection(ctx, e) },
- "enter_" + upgradeStVerifyWindow: func(e *fsm.Event) { instFsm.enterVerifyWindow(ctx, e) },
- "enter_" + upgradeStFinalizeDL: func(e *fsm.Event) { instFsm.enterFinalizeDL(ctx, e) },
- "enter_" + upgradeStWaitEndDL: func(e *fsm.Event) { instFsm.enterWaitEndDL(ctx, e) },
- "enter_" + upgradeStCheckImageName: func(e *fsm.Event) { instFsm.enterCheckImageName(ctx, e) },
- "enter_" + upgradeStRequestingActivate: func(e *fsm.Event) { instFsm.enterActivateSw(ctx, e) },
- "enter_" + upgradeStCommitSw: func(e *fsm.Event) { instFsm.enterCommitSw(ctx, e) },
- "enter_" + upgradeStCheckCommitted: func(e *fsm.Event) { instFsm.enterCheckCommitted(ctx, e) },
- "enter_" + upgradeStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
- "enter_" + upgradeStAbortingDL: func(e *fsm.Event) { instFsm.enterAbortingDL(ctx, e) },
- "enter_" + upgradeStRestarting: func(e *fsm.Event) { instFsm.enterRestarting(ctx, e) },
- "enter_" + upgradeStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
+ "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+ "enter_" + UpgradeStStarting: func(e *fsm.Event) { instFsm.enterStarting(ctx, e) },
+ "enter_" + UpgradeStWaitingAdapterDL: func(e *fsm.Event) { instFsm.enterWaitingAdapterDL(ctx, e) },
+ "enter_" + UpgradeStPreparingDL: func(e *fsm.Event) { instFsm.enterPreparingDL(ctx, e) },
+ "enter_" + UpgradeStDLSection: func(e *fsm.Event) { instFsm.enterDownloadSection(ctx, e) },
+ "enter_" + UpgradeStVerifyWindow: func(e *fsm.Event) { instFsm.enterVerifyWindow(ctx, e) },
+ "enter_" + UpgradeStFinalizeDL: func(e *fsm.Event) { instFsm.enterFinalizeDL(ctx, e) },
+ "enter_" + UpgradeStWaitEndDL: func(e *fsm.Event) { instFsm.enterWaitEndDL(ctx, e) },
+ "enter_" + UpgradeStCheckImageName: func(e *fsm.Event) { instFsm.enterCheckImageName(ctx, e) },
+ "enter_" + UpgradeStRequestingActivate: func(e *fsm.Event) { instFsm.enterActivateSw(ctx, e) },
+ "enter_" + UpgradeStCommitSw: func(e *fsm.Event) { instFsm.enterCommitSw(ctx, e) },
+ "enter_" + UpgradeStCheckCommitted: func(e *fsm.Event) { instFsm.enterCheckCommitted(ctx, e) },
+ "enter_" + UpgradeStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
+ "enter_" + UpgradeStAbortingDL: func(e *fsm.Event) { instFsm.enterAbortingDL(ctx, e) },
+ "enter_" + UpgradeStRestarting: func(e *fsm.Event) { instFsm.enterRestarting(ctx, e) },
+ "enter_" + UpgradeStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
},
)
- if instFsm.pAdaptFsm.pFsm == nil {
+ if instFsm.PAdaptFsm.PFsm == nil {
logger.Errorw(ctx, "OnuUpgradeFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
@@ -266,13 +268,13 @@
//SetDownloadParams configures the needed parameters for a specific download to the ONU
// called from 'old' API Activate_image_update()
func (oFsm *OnuUpgradeFsm) SetDownloadParams(ctx context.Context, aInactiveImageID uint16,
- apImageDsc *voltha.ImageDownload, apDownloadManager *adapterDownloadManager) error {
- pBaseFsm := oFsm.pAdaptFsm.pFsm
- if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+ apImageDsc *voltha.ImageDownload, apDownloadManager *AdapterDownloadManager) error {
+ pBaseFsm := oFsm.PAdaptFsm.PFsm
+ if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
oFsm.mutexUpgradeParams.Lock()
logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting", log.Fields{
"device-id": oFsm.deviceID, "image-description": apImageDsc})
- oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+ oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
oFsm.pImageDsc = apImageDsc
oFsm.pDownloadManager = apDownloadManager
oFsm.activateImage = true
@@ -281,7 +283,7 @@
go func(aPBaseFsm *fsm.FSM) {
// let the upgrade FSM proceed to PreparingDL
- _ = aPBaseFsm.Event(upgradeEvPrepareSwDownload)
+ _ = aPBaseFsm.Event(UpgradeEvPrepareSwDownload)
}(pBaseFsm)
return nil
}
@@ -294,18 +296,18 @@
// updated API interface with R2.8: start download to ONU if the image is downloaded to the adapter
// called from 'new' API Download_onu_image
func (oFsm *OnuUpgradeFsm) SetDownloadParamsAfterDownload(ctx context.Context, aInactiveImageID uint16,
- apImageRequest *voltha.DeviceImageDownloadRequest, apDownloadManager *fileDownloadManager,
+ apImageRequest *voltha.DeviceImageDownloadRequest, apDownloadManager *FileDownloadManager,
aImageIdentifier string) error {
oFsm.mutexUpgradeParams.Lock()
var pBaseFsm *fsm.FSM = nil
- if oFsm.pAdaptFsm != nil {
- pBaseFsm = oFsm.pAdaptFsm.pFsm
+ if oFsm.PAdaptFsm != nil {
+ pBaseFsm = oFsm.PAdaptFsm.PFsm
}
- if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+ if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting", log.Fields{
"device-id": oFsm.deviceID, "image-description": apImageRequest})
oFsm.useAPIVersion43 = true
- oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+ oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
oFsm.pFileManager = apDownloadManager
oFsm.imageIdentifier = aImageIdentifier
oFsm.imageVersion = apImageRequest.Image.Version
@@ -314,7 +316,7 @@
//TODO: currently straightforward options activate and commit are expected to be set and (unconditionally) done
// for separate handling of these options the FSM must accordingly branch from the concerned states - later
oFsm.mutexUpgradeParams.Unlock()
- _ = pBaseFsm.Event(upgradeEvAdapterDownload) //no need to call the FSM event in background here
+ _ = pBaseFsm.Event(UpgradeEvAdapterDownload) //no need to call the FSM event in background here
return nil
}
oFsm.mutexUpgradeParams.Unlock()
@@ -342,15 +344,15 @@
oFsm.activateImage = true
oFsm.commitImage = aCommit
var pBaseFsm *fsm.FSM = nil
- if oFsm.pAdaptFsm != nil {
- pBaseFsm = oFsm.pAdaptFsm.pFsm
+ if oFsm.PAdaptFsm != nil {
+ pBaseFsm = oFsm.PAdaptFsm.PFsm
}
if pBaseFsm != nil {
- if pBaseFsm.Is(upgradeStWaitForActivate) {
+ if pBaseFsm.Is(UpgradeStWaitForActivate) {
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
oFsm.mutexUpgradeParams.Unlock()
logger.Debugw(ctx, "OnuUpgradeFsm finish waiting for activate", log.Fields{"device-id": oFsm.deviceID})
- _ = pBaseFsm.Event(upgradeEvRequestActivate) //no need to call the FSM event in background here
+ _ = pBaseFsm.Event(UpgradeEvRequestActivate) //no need to call the FSM event in background here
} else {
oFsm.mutexUpgradeParams.Unlock()
logger.Debugw(ctx, "OnuUpgradeFsm not (yet?) waiting for activate", log.Fields{
@@ -368,14 +370,14 @@
func (oFsm *OnuUpgradeFsm) SetActivationParamsStart(ctx context.Context, aImageVersion string, aInactiveImageID uint16, aCommit bool) error {
oFsm.mutexUpgradeParams.Lock()
var pBaseFsm *fsm.FSM = nil
- if oFsm.pAdaptFsm != nil {
- pBaseFsm = oFsm.pAdaptFsm.pFsm
+ if oFsm.PAdaptFsm != nil {
+ pBaseFsm = oFsm.PAdaptFsm.PFsm
}
- if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+ if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting to start with activation", log.Fields{
"device-id": oFsm.deviceID, "image-version": aImageVersion})
oFsm.useAPIVersion43 = true
- oFsm.inactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
+ oFsm.InactiveImageMeID = aInactiveImageID //upgrade state machines run on configured inactive ImageId
oFsm.imageVersion = aImageVersion
oFsm.activateImage = true
oFsm.commitImage = aCommit
@@ -384,7 +386,7 @@
oFsm.volthaImageState = voltha.ImageState_IMAGE_INACTIVE //as simply applied for inactive image
oFsm.mutexUpgradeParams.Unlock()
//directly request the FSM to activate the image
- _ = pBaseFsm.Event(upgradeEvRequestActivate) //no need to call the FSM event in background here
+ _ = pBaseFsm.Event(UpgradeEvRequestActivate) //no need to call the FSM event in background here
return nil
}
oFsm.mutexUpgradeParams.Unlock()
@@ -414,14 +416,14 @@
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
oFsm.mutexUpgradeParams.Unlock()
var pBaseFsm *fsm.FSM = nil
- if oFsm.pAdaptFsm != nil {
- pBaseFsm = oFsm.pAdaptFsm.pFsm
+ if oFsm.PAdaptFsm != nil {
+ pBaseFsm = oFsm.PAdaptFsm.PFsm
}
if pBaseFsm != nil {
//let the FSM decide if it is ready to process the event
logger.Debugw(ctx, "OnuUpgradeFsm requesting commit",
log.Fields{"device-id": oFsm.deviceID, "current FsmState": pBaseFsm.Current()})
- _ = pBaseFsm.Event(upgradeEvCommitSw) //no need to call the FSM event in background here
+ _ = pBaseFsm.Event(UpgradeEvCommitSw) //no need to call the FSM event in background here
return nil
}
//should never occur
@@ -435,21 +437,21 @@
func (oFsm *OnuUpgradeFsm) SetCommitmentParamsStart(ctx context.Context, aImageVersion string, aActiveImageID uint16) error {
oFsm.mutexUpgradeParams.Lock()
var pBaseFsm *fsm.FSM = nil
- if oFsm.pAdaptFsm != nil {
- pBaseFsm = oFsm.pAdaptFsm.pFsm
+ if oFsm.PAdaptFsm != nil {
+ pBaseFsm = oFsm.PAdaptFsm.PFsm
}
- if pBaseFsm != nil && pBaseFsm.Is(upgradeStStarting) {
+ if pBaseFsm != nil && pBaseFsm.Is(UpgradeStStarting) {
logger.Debugw(ctx, "OnuUpgradeFsm Parameter setting to start with commitment", log.Fields{
"device-id": oFsm.deviceID, "image-version": aImageVersion})
oFsm.useAPIVersion43 = true
- oFsm.inactiveImageMeID = aActiveImageID //upgrade state machines inactive ImageId is the new active ImageId
+ oFsm.InactiveImageMeID = aActiveImageID //upgrade state machines inactive ImageId is the new active ImageId
oFsm.imageVersion = aImageVersion
oFsm.commitImage = true
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_STARTED //better choice would be 'UpgradeState=Started'
oFsm.volthaImageState = voltha.ImageState_IMAGE_ACTIVE //as simply applied for active image
oFsm.mutexUpgradeParams.Unlock()
//directly request the FSM to commit the image
- _ = pBaseFsm.Event(upgradeEvCommitSw) //no need to call the FSM event in background here
+ _ = pBaseFsm.Event(UpgradeEvCommitSw) //no need to call the FSM event in background here
return nil
}
oFsm.mutexUpgradeParams.Unlock()
@@ -533,12 +535,12 @@
// in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM
// specific here: See definition of state changes: some states are excluded from reset for possible later commit
- pAdaptFsm := oFsm.pAdaptFsm
- if pAdaptFsm != nil {
+ PAdaptFsm := oFsm.PAdaptFsm
+ if PAdaptFsm != nil {
// calling FSM events in background to avoid blocking of the caller
- go func(aPAFsm *AdapterFsm) {
- if aPAFsm.pFsm != nil {
- if aPAFsm.pFsm.Is(upgradeStWaitEndDL) {
+ go func(aPAFsm *cmn.AdapterFsm) {
+ if aPAFsm.PFsm != nil {
+ if aPAFsm.PFsm.Is(UpgradeStWaitEndDL) {
oFsm.chReceiveExpectedResponse <- false //which aborts the FSM in WaitEndDL state
}
// in case of state-conditional request the
@@ -555,11 +557,11 @@
}
oFsm.volthaDownloadReason = aReason
oFsm.mutexUpgradeParams.Unlock()
- err = aPAFsm.pFsm.Event(upgradeEvAbort) //as unconditional default FSM cancellation
+ err = aPAFsm.PFsm.Event(UpgradeEvAbort) //as unconditional default FSM cancellation
} else {
//at conditional request the image states are set when reaching the reset state
oFsm.conditionalCancelRequested = true
- err = aPAFsm.pFsm.Event(upgradeEvReset) //as state-conditional default FSM cleanup
+ err = aPAFsm.PFsm.Event(UpgradeEvReset) //as state-conditional default FSM cleanup
}
if err != nil {
//error return is expected in case of conditional request and no state transition
@@ -567,7 +569,7 @@
"device-id": oFsm.deviceID, "error": err})
}
} //else the FSM seems already to be in some released state
- }(pAdaptFsm)
+ }(PAdaptFsm)
}
}
@@ -610,10 +612,10 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm abort: problems getting image buffer length", log.Fields{
"device-id": oFsm.deviceID, "error": err, "length": fileLen})
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
@@ -632,10 +634,10 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm abort: can't get image buffer", log.Fields{
"device-id": oFsm.deviceID, "error": err})
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
@@ -650,7 +652,7 @@
oFsm.origImageLength = uint32(fileLen)
oFsm.imageLength = uint32(len(oFsm.imageBuffer))
logger.Infow(ctx, "OnuUpgradeFsm starts with StartSwDl values", log.Fields{
- "MeId": oFsm.inactiveImageMeID, "windowSizeLimit": oFsm.omciDownloadWindowSizeLimit,
+ "MeId": oFsm.InactiveImageMeID, "windowSizeLimit": oFsm.omciDownloadWindowSizeLimit,
"ImageSize": oFsm.imageLength, "original file size": fileLen})
//"NumberOfCircuitPacks": oFsm.numberCircuitPacks, "CircuitPacks MeId": 0}) //parallel circuit packs download not supported
@@ -664,8 +666,8 @@
}
go oFsm.waitOnDownloadToOnuReady(ctx, oFsm.chOnuDlReady) // start supervision of the complete download-to-ONU procedure
- err = oFsm.pOmciCC.sendStartSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, oFsm.omciDownloadWindowSizeLimit, oFsm.origImageLength)
+ err = oFsm.pOmciCC.SendStartSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, oFsm.omciDownloadWindowSizeLimit, oFsm.origImageLength)
if err != nil {
logger.Errorw(ctx, "StartSwDl abort: can't send section", log.Fields{
"device-id": oFsm.deviceID, "error": err})
@@ -683,11 +685,11 @@
var bufferStartOffset uint32
var bufferEndOffset uint32
var downloadSection []byte
- framePrint := false //default no printing of downloadSection frames
+ FramePrint := false //default no printing of downloadSection frames
oFsm.mutexUpgradeParams.Lock()
if oFsm.nextDownloadSectionsAbsolute == 0 {
//debug print of first section frame
- framePrint = true
+ FramePrint = true
oFsm.volthaImageState = voltha.ImageState_IMAGE_DOWNLOADING
}
@@ -703,10 +705,10 @@
oFsm.volthaDownloadReason = oFsm.abortRequested
oFsm.mutexAbortRequest.RUnlock()
oFsm.mutexUpgradeParams.Unlock()
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
@@ -726,10 +728,10 @@
oFsm.volthaDownloadReason = voltha.ImageState_UNKNOWN_ERROR //something like 'LOCAL_FILE_ERROR' would be better (proto)
oFsm.mutexUpgradeParams.Unlock()
//logical error -- reset the FSM
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
@@ -741,14 +743,14 @@
}
if oFsm.nextDownloadSectionsAbsolute+1 >= oFsm.noOfSections {
windowAckRequest = 1
- framePrint = true //debug print of last frame
+ FramePrint = true //debug print of last frame
oFsm.omciDownloadWindowSizeLast = oFsm.nextDownloadSectionsWindow
logger.Infow(ctx, "DlSection expect Response for last window (section)", log.Fields{
"device-id": oFsm.deviceID, "DlSectionNoAbsolute": oFsm.nextDownloadSectionsAbsolute})
}
oFsm.mutexUpgradeParams.Unlock() //unlock here to give other functions some chance to process during/after the send request
- err := oFsm.pOmciCC.sendDownloadSection(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, windowAckRequest, oFsm.nextDownloadSectionsWindow, downloadSection, framePrint)
+ err := oFsm.pOmciCC.SendDownloadSection(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, windowAckRequest, oFsm.nextDownloadSectionsWindow, downloadSection, FramePrint)
if err != nil {
logger.Errorw(ctx, "DlSection abort: can't send section", log.Fields{
"device-id": oFsm.deviceID, "section absolute": oFsm.nextDownloadSectionsAbsolute, "error": err})
@@ -758,15 +760,15 @@
oFsm.mutexUpgradeParams.Lock()
oFsm.nextDownloadSectionsAbsolute++ //always increase the absolute section counter after having sent one
if windowAckRequest == 1 {
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
oFsm.mutexUpgradeParams.Unlock()
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvWaitWindowAck) //state transition to upgradeStVerifyWindow
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvWaitWindowAck) //state transition to UpgradeStVerifyWindow
}(pBaseFsm)
return
}
- framePrint = false //for the next Section frame (if wanted, can be enabled in logic before sendXXX())
+ FramePrint = false //for the next Section frame (if wanted, can be enabled in logic before sendXXX())
oFsm.nextDownloadSectionsWindow++ //increase the window related section counter only if not in the last section
if oFsm.omciSectionInterleaveDelay > 0 {
//ensure a defined intersection-time-gap to leave space for further processing, other ONU's ...
@@ -796,7 +798,7 @@
oFsm.mutexUpgradeParams.RUnlock()
}
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
if pBaseFsm == nil {
logger.Errorw(ctx, "EndSwDl abort: BaseFsm invalid", log.Fields{"device-id": oFsm.deviceID})
oFsm.mutexUpgradeParams.Lock()
@@ -804,13 +806,13 @@
oFsm.volthaDownloadReason = voltha.ImageState_UNKNOWN_ERROR
oFsm.mutexUpgradeParams.Unlock()
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
- err := oFsm.pOmciCC.sendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, oFsm.origImageLength, oFsm.imageCRC)
+ err := oFsm.pOmciCC.SendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, oFsm.origImageLength, oFsm.imageCRC)
oFsm.isEndSwDlOpen = false // also to be reset in case of OMCI error, as further send attempts would not make sense
if err != nil {
@@ -821,8 +823,8 @@
}
// go waiting for the EndSwDLResponse and check, if the ONU is ready for activation
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvWaitEndDownload)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvWaitEndDownload)
}(pBaseFsm)
}
@@ -832,7 +834,7 @@
if oFsm.waitCountEndSwDl == 0 {
logger.Errorw(ctx, "WaitEndDl abort: max limit of EndSwDL reached", log.Fields{
"device-id": oFsm.deviceID})
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
if pBaseFsm == nil {
logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
"device-id": oFsm.deviceID})
@@ -842,8 +844,8 @@
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_FAILED
oFsm.volthaDownloadReason = voltha.ImageState_IMAGE_REFUSED_BY_ONU //something like 'END_DOWNLOAD_TIMEOUT' would be better (proto)
oFsm.mutexUpgradeParams.Unlock()
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
return
}
@@ -851,7 +853,7 @@
oFsm.waitCountEndSwDl--
select {
case <-time.After(oFsm.waitDelayEndSwDl * time.Second):
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
if pBaseFsm == nil {
logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
"device-id": oFsm.deviceID})
@@ -862,13 +864,13 @@
oFsm.mutexUpgradeParams.Lock()
oFsm.delayEndSwDl = false //no more extra delay for the request
oFsm.mutexUpgradeParams.Unlock()
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvContinueFinalize)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvContinueFinalize)
}(pBaseFsm)
return
case success := <-oFsm.chReceiveExpectedResponse:
logger.Debugw(ctx, "WaitEndDl stop wait timer", log.Fields{"device-id": oFsm.deviceID})
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
if pBaseFsm == nil {
logger.Errorw(ctx, "WaitEndDl abort: BaseFsm invalid", log.Fields{
"device-id": oFsm.deviceID})
@@ -879,19 +881,19 @@
//answer received with ready indication
//useAPIVersion43 may not conflict in concurrency in this state function
if oFsm.useAPIVersion43 { // newer API usage requires verification of downloaded image version
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvCheckImageName)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvCheckImageName)
}(pBaseFsm)
} else { // elder API usage does not support image version check -immediately consider download as successful
if oFsm.activateImage {
//immediate activation requested
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvRequestActivate)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvRequestActivate)
}(pBaseFsm)
} else {
//have to wait on explicit activation request
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvWaitForActivate)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvWaitForActivate)
}(pBaseFsm)
}
}
@@ -905,11 +907,11 @@
func (oFsm *OnuUpgradeFsm) enterCheckImageName(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm checking downloaded image name", log.Fields{
- "device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+ "device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
- meInstance, err := oFsm.pOmciCC.sendGetMe(log.WithSpanFromContext(context.Background(), ctx),
- me.SoftwareImageClassID, oFsm.inactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- false, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendGetMe(log.WithSpanFromContext(context.Background(), ctx),
+ me.SoftwareImageClassID, oFsm.InactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.GetOmciTimeout(),
+ false, oFsm.PAdaptFsm.CommChan)
if err != nil {
logger.Errorw(ctx, "OnuUpgradeFsm get Software Image ME result error",
log.Fields{"device-id": oFsm.deviceID, "Error": err})
@@ -921,10 +923,10 @@
func (oFsm *OnuUpgradeFsm) enterActivateSw(ctx context.Context, e *fsm.Event) {
logger.Infow(ctx, "OnuUpgradeFsm activate SW", log.Fields{
- "device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+ "device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
- err := oFsm.pOmciCC.sendActivateSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID)
+ err := oFsm.pOmciCC.SendActivateSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID)
if err != nil {
logger.Errorw(ctx, "ActivateSw abort: can't send activate frame", log.Fields{
"device-id": oFsm.deviceID, "error": err})
@@ -938,20 +940,20 @@
func (oFsm *OnuUpgradeFsm) enterCommitSw(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm start commit SW", log.Fields{
- "device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+ "device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
//any abort request (also conditional) is still regarded as valid as the commit indication might not be possible to verify
// (which is a bit problematic as the ONU might already be in committed state,
// in this case (committing failed) always 'onuimage list' should be used to verify the real state (if ONU is reachable))
if activeImageID, err := oFsm.pDevEntry.GetActiveImageMeID(ctx); err == nil {
oFsm.mutexUpgradeParams.Lock()
- if activeImageID == oFsm.inactiveImageMeID {
- inactiveImageID := oFsm.inactiveImageMeID
+ if activeImageID == oFsm.InactiveImageMeID {
+ inactiveImageID := oFsm.InactiveImageMeID
logger.Infow(ctx, "OnuUpgradeFsm commit SW", log.Fields{
"device-id": oFsm.deviceID, "me-id": inactiveImageID}) //more efficient activeImageID with above check
oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMITTING
oFsm.mutexUpgradeParams.Unlock()
- err := oFsm.pOmciCC.sendCommitSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, inactiveImageID) //more efficient activeImageID with above check
+ err := oFsm.pOmciCC.SendCommitSoftware(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, inactiveImageID) //more efficient activeImageID with above check
if err != nil {
logger.Errorw(ctx, "CommitSw abort: can't send commit sw frame", log.Fields{
"device-id": oFsm.deviceID, "error": err})
@@ -962,7 +964,7 @@
}
oFsm.mutexUpgradeParams.Unlock()
logger.Errorw(ctx, "OnuUpgradeFsm active ImageId <> IdToCommit", log.Fields{
- "device-id": oFsm.deviceID, "active ID": activeImageID, "to commit ID": oFsm.inactiveImageMeID})
+ "device-id": oFsm.deviceID, "active ID": activeImageID, "to commit ID": oFsm.InactiveImageMeID})
} else {
logger.Errorw(ctx, "OnuUpgradeFsm can't commit, no valid active image", log.Fields{
"device-id": oFsm.deviceID})
@@ -974,19 +976,19 @@
oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMIT_ABORTED
oFsm.mutexUpgradeParams.Unlock()
//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- _ = a_pAFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvAbort)
}(pBaseFsm)
}
func (oFsm *OnuUpgradeFsm) enterCheckCommitted(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm checking committed SW", log.Fields{
- "device-id": oFsm.deviceID, "me-id": oFsm.inactiveImageMeID})
+ "device-id": oFsm.deviceID, "me-id": oFsm.InactiveImageMeID})
requestedAttributes := me.AttributeValueMap{"IsCommitted": 0, "IsActive": 0, "Version": ""}
- meInstance, err := oFsm.pOmciCC.sendGetMe(log.WithSpanFromContext(context.Background(), ctx),
- me.SoftwareImageClassID, oFsm.inactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendGetMe(log.WithSpanFromContext(context.Background(), ctx),
+ me.SoftwareImageClassID, oFsm.InactiveImageMeID, requestedAttributes, oFsm.pDeviceHandler.GetOmciTimeout(), false, oFsm.PAdaptFsm.CommChan)
if err != nil {
logger.Errorw(ctx, "OnuUpgradeFsm get Software Image ME result error",
log.Fields{"device-id": oFsm.deviceID, "Error": err})
@@ -1014,43 +1016,43 @@
case oFsm.chOnuDlReady <- false:
default:
}
- pConfigupgradeStateAFsm := oFsm.pAdaptFsm
- if pConfigupgradeStateAFsm != nil {
+ pConfigUpgradeStateAFsm := oFsm.PAdaptFsm
+ if pConfigUpgradeStateAFsm != nil {
var nextEvent string
if oFsm.isEndSwDlOpen {
- nextEvent = upgradeEvAbortSwDownload
+ nextEvent = UpgradeEvAbortSwDownload
} else {
- nextEvent = upgradeEvRestart
+ nextEvent = UpgradeEvRestart
}
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(nextEvent)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(nextEvent)
}
- }(pConfigupgradeStateAFsm)
+ }(pConfigUpgradeStateAFsm)
}
}
func (oFsm *OnuUpgradeFsm) enterAbortingDL(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm aborting download to ONU", log.Fields{"device-id": oFsm.deviceID})
- pBaseFsm := oFsm.pAdaptFsm
+ pBaseFsm := oFsm.PAdaptFsm
if pBaseFsm == nil {
logger.Errorw(ctx, "OnuUpgradeFsm aborting download: BaseFsm invalid", log.Fields{"device-id": oFsm.deviceID})
return
}
// abort the download operation by sending an end software download message with invalid CRC and image size
- err := oFsm.pOmciCC.sendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, false,
- oFsm.pAdaptFsm.commChan, oFsm.inactiveImageMeID, 0, 0xFFFFFFFF)
+ err := oFsm.pOmciCC.SendEndSoftwareDownload(log.WithSpanFromContext(context.Background(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), false,
+ oFsm.PAdaptFsm.CommChan, oFsm.InactiveImageMeID, 0, 0xFFFFFFFF)
oFsm.isEndSwDlOpen = false // also to be reset in case of OMCI error, as further send attempts would not make sense
if err != nil {
logger.Errorw(ctx, "OnuUpgradeFsm aborting download: can't send EndSwDl request", log.Fields{"device-id": oFsm.deviceID})
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
}
}(pBaseFsm)
return
@@ -1058,17 +1060,17 @@
select {
case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Warnw(ctx, "OnuUpgradeFsm aborting download: timeout - no response received", log.Fields{"device-id": oFsm.deviceID})
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
}
}(pBaseFsm)
return
case <-oFsm.chReceiveAbortEndSwDlResponse:
logger.Debug(ctx, "OnuUpgradeFsm aborting download: response received")
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(upgradeEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvRestart)
}
}(pBaseFsm)
return
@@ -1077,24 +1079,24 @@
func (oFsm *OnuUpgradeFsm) enterRestarting(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "OnuUpgradeFsm restarting", log.Fields{"device-id": oFsm.deviceID})
- pConfigupgradeStateAFsm := oFsm.pAdaptFsm
- if pConfigupgradeStateAFsm != nil {
+ pConfigUpgradeStateAFsm := oFsm.PAdaptFsm
+ if pConfigUpgradeStateAFsm != nil {
// abort running message processing
- fsmAbortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ fsmAbortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
- pConfigupgradeStateAFsm.commChan <- fsmAbortMsg
+ pConfigUpgradeStateAFsm.CommChan <- fsmAbortMsg
//try to restart the FSM to 'disabled'
// Can't call FSM Event directly, decoupling it
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(upgradeEvDisable)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UpgradeEvDisable)
}
- }(pConfigupgradeStateAFsm)
+ }(pConfigUpgradeStateAFsm)
}
}
@@ -1109,7 +1111,7 @@
Reason: oFsm.volthaDownloadReason,
ImageState: oFsm.volthaImageState,
}
- go oFsm.pDeviceHandler.removeOnuUpgradeFsm(ctx, pLastUpgradeImageState)
+ go oFsm.pDeviceHandler.RemoveOnuUpgradeFsm(ctx, pLastUpgradeImageState)
}
}
@@ -1120,7 +1122,7 @@
// case <-ctx.Done():
// logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
- message, ok := <-oFsm.pAdaptFsm.commChan
+ message, ok := <-oFsm.PAdaptFsm.CommChan
if !ok {
logger.Info(ctx, "OnuUpgradeFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
@@ -1130,15 +1132,15 @@
logger.Debugw(ctx, "OnuUpgradeFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Infow(ctx, "OnuUpgradeFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
logger.Warnw(ctx, "OnuUpgradeFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oFsm.handleOmciOnuUpgradeMessage(ctx, msg)
default:
logger.Warn(ctx, "OnuUpgradeFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -1149,7 +1151,7 @@
}
//nolint: gocyclo
-func (oFsm *OnuUpgradeFsm) handleOmciOnuUpgradeMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *OnuUpgradeFsm) handleOmciOnuUpgradeMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "Rx OMCI OnuUpgradeFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
@@ -1180,7 +1182,7 @@
}
oFsm.mutexUpgradeParams.Lock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID {
logger.Debugw(ctx, "Expected StartSwDlResponse received", log.Fields{"device-id": oFsm.deviceID})
if msgObj.WindowSize != oFsm.omciDownloadWindowSizeLimit {
// also response WindowSize = 0 is a valid number for used Window size 1
@@ -1200,7 +1202,7 @@
oFsm.nextDownloadWindow = 0
oFsm.mutexUpgradeParams.Unlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvRxStartSwDownload)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvRxStartSwDownload)
return
}
oFsm.mutexUpgradeParams.Unlock()
@@ -1234,7 +1236,7 @@
return
}
oFsm.mutexUpgradeParams.Lock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID {
sectionNumber := msgObj.SectionNumber
logger.Infow(ctx, "DlSectionResponse received", log.Fields{
"window section-number": sectionNumber, "window": oFsm.nextDownloadWindow, "device-id": oFsm.deviceID})
@@ -1257,7 +1259,7 @@
binary.LittleEndian.PutUint32(byteSlice, uint32(imageCRC))
oFsm.imageCRC = binary.BigEndian.Uint32(byteSlice)
oFsm.mutexUpgradeParams.Unlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvEndSwDownload)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvEndSwDownload)
return
}
if sectionNumber != oFsm.omciDownloadWindowSizeLimit {
@@ -1270,7 +1272,7 @@
}
oFsm.nextDownloadSectionsWindow = 0
oFsm.mutexUpgradeParams.Unlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvContinueNextWindow)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvContinueNextWindow)
return
}
oFsm.mutexUpgradeParams.Unlock()
@@ -1281,11 +1283,11 @@
} //DownloadSectionResponseType
case omci.EndSoftwareDownloadResponseType:
{
- if oFsm.pAdaptFsm.pFsm.Is(upgradeStAbortingDL) {
+ if oFsm.PAdaptFsm.PFsm.Is(UpgradeStAbortingDL) {
// calling FSM events in background to avoid blocking of the caller
- go func(aPAFsm *AdapterFsm) {
+ go func(aPAFsm *cmn.AdapterFsm) {
oFsm.chReceiveAbortEndSwDlResponse <- true
- }(oFsm.pAdaptFsm)
+ }(oFsm.PAdaptFsm)
return
}
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeEndSoftwareDownloadResponse)
@@ -1317,7 +1319,7 @@
return
}
oFsm.mutexUpgradeParams.Lock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID {
//EndSwDownloadSuccess is used to indicate 'DOWNLOAD_SUCCEEDED'
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_SUCCEEDED
if !oFsm.useAPIVersion43 {
@@ -1373,15 +1375,15 @@
return
}
oFsm.mutexUpgradeParams.Lock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID {
// the image is regarded as active really only after ONU reboot and according indication (ONU down/up procedure)
oFsm.mutexUpgradeParams.Unlock()
logger.Infow(ctx, "Expected ActivateSwResponse received",
log.Fields{"device-id": oFsm.deviceID, "commit": oFsm.commitImage})
if oFsm.commitImage {
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvWaitForCommit)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvWaitForCommit)
} else {
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvActivationDone) // let the FSM wait for external commit request
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvActivationDone) // let the FSM wait for external commit request
}
return
}
@@ -1414,11 +1416,11 @@
return
}
oFsm.mutexUpgradeParams.RLock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID {
oFsm.mutexUpgradeParams.RUnlock()
logger.Debugw(ctx, "OnuUpgradeFsm Expected SwImage CommitResponse received", log.Fields{"device-id": oFsm.deviceID})
//verifying committed image
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvCheckCommitted)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvCheckCommitted)
return
}
oFsm.mutexUpgradeParams.RUnlock()
@@ -1462,16 +1464,16 @@
meAttributes := msgObj.Attributes
imageIsCommitted := meAttributes["IsCommitted"].(uint8)
imageIsActive := meAttributes["IsActive"].(uint8)
- imageVersion := TrimStringFromMeOctet(meAttributes["Version"])
+ imageVersion := cmn.TrimStringFromMeOctet(meAttributes["Version"])
logger.Debugw(ctx, "OnuUpgradeFsm - GetResponse Data for SoftwareImage",
log.Fields{"device-id": oFsm.deviceID, "entityID": msgObj.EntityInstance,
"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted})
- if oFsm.pAdaptFsm.pFsm.Current() == upgradeStCheckImageName {
+ if oFsm.PAdaptFsm.PFsm.Current() == UpgradeStCheckImageName {
//image name check after EndSwDownload, this state (and block) can only be taken if APIVersion43 is used
oFsm.mutexUpgradeParams.Lock()
- if msgObj.EntityInstance == oFsm.inactiveImageMeID && imageIsActive == swIsInactive &&
- imageIsCommitted == swIsUncommitted {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID && imageIsActive == cmn.SwIsInactive &&
+ imageIsCommitted == cmn.SwIsUncommitted {
if imageVersion != oFsm.imageVersion {
//new stored inactive version indicated on OMCI from ONU is not the expected version
logger.Errorw(ctx, "OnuUpgradeFsm SwImage GetResponse version indication not matching requested upgrade",
@@ -1490,20 +1492,20 @@
}
// TODO!!!: error treatment?
//TODO!!!: possibly send event information for aborted upgrade (aborted by wrong version)?
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
return
}
//with APIVersion43 this is the point to consider the newly loaded image as valid (and inactive)
oFsm.volthaImageState = voltha.ImageState_IMAGE_INACTIVE
//store the new inactive version to onuSwImageIndications (to keep them in sync)
- oFsm.pDevEntry.modifySwImageInactiveVersion(ctx, oFsm.imageVersion)
+ oFsm.pDevEntry.ModifySwImageInactiveVersion(ctx, oFsm.imageVersion)
//proceed within upgrade FSM
if oFsm.activateImage {
//immediate activation requested
oFsm.mutexUpgradeParams.Unlock()
logger.Debugw(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU, continue with activation",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvRequestActivate)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvRequestActivate)
} else {
//have to wait on explicit activation request
// but a previously requested download activity (without activation) was successful here
@@ -1511,7 +1513,7 @@
oFsm.mutexUpgradeParams.Unlock()
logger.Infow(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU, wait for activate request",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvWaitForActivate)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvWaitForActivate)
}
//use non-blocking channel (to be independent from receiver state)
select {
@@ -1530,14 +1532,14 @@
log.Fields{"device-id": oFsm.deviceID, "ResponseMeId": msgObj.EntityInstance})
// TODO!!!: error treatment?
//TODO!!!: possibly send event information for aborted upgrade (aborted by ONU state indication)?
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
return
}
- //assumed only relevant state here is upgradeStCheckCommitted
+ //assumed only relevant state here is UpgradeStCheckCommitted
oFsm.mutexUpgradeParams.Lock()
oFsm.conditionalCancelRequested = false //getting here any set (conditional) cancelRequest is not relevant anymore
- if msgObj.EntityInstance == oFsm.inactiveImageMeID && imageIsActive == swIsActive {
+ if msgObj.EntityInstance == oFsm.InactiveImageMeID && imageIsActive == cmn.SwIsActive {
//a check on the delivered image version is not done, the ONU delivered version might be different from what might have been
// indicated in the download image version string (version must be part of the image content itself)
// so checking that might be quite unreliable
@@ -1555,23 +1557,23 @@
oFsm.volthaDownloadReason = voltha.ImageState_CANCELLED_ON_ONU_STATE //something like 'UNEXPECTED_VERSION' would be better - proto def
oFsm.volthaImageState = voltha.ImageState_IMAGE_UNKNOWN //expected image not known
oFsm.mutexUpgradeParams.Unlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
return
}
logger.Debugw(ctx, "OnuUpgradeFsm - expected ONU image version indicated by the ONU",
log.Fields{"device-id": oFsm.deviceID})
}
- if imageIsCommitted == swIsCommitted {
+ if imageIsCommitted == cmn.SwIsCommitted {
oFsm.volthaDownloadState = voltha.ImageState_DOWNLOAD_SUCCEEDED
oFsm.volthaImageState = voltha.ImageState_IMAGE_COMMITTED
//store the new commit flag to onuSwImageIndications (to keep them in sync)
- oFsm.pDevEntry.modifySwImageActiveCommit(ctx, imageIsCommitted)
+ oFsm.pDevEntry.ModifySwImageActiveCommit(ctx, imageIsCommitted)
logger.Infow(ctx, "requested SW image committed, releasing OnuUpgrade", log.Fields{"device-id": oFsm.deviceID})
//deviceProcStatusUpdate not used anymore,
- // replaced by transferring the last (more) upgrade state information within removeOnuUpgradeFsm
+ // replaced by transferring the last (more) upgrade state information within RemoveOnuUpgradeFsm
oFsm.mutexUpgradeParams.Unlock()
//releasing the upgrade FSM on success
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
return
}
//if not committed, abort upgrade as failed. There is no implementation here that would trigger this test again
@@ -1584,7 +1586,7 @@
log.Fields{"device-id": oFsm.deviceID, "ResponseMeId": msgObj.EntityInstance})
// TODO!!!: error treatment?
//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
- _ = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
return
} //GetResponseType
default:
@@ -1609,17 +1611,17 @@
}
oFsm.mutexUpgradeParams.Unlock()
//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
- if oFsm.pAdaptFsm != nil {
+ if oFsm.PAdaptFsm != nil {
var err error
if aAsync { //asynchronous call requested to ensure state transition
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm.pFsm != nil {
- err = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm.PFsm != nil {
+ err = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
}
- }(oFsm.pAdaptFsm)
+ }(oFsm.PAdaptFsm)
} else {
- if oFsm.pAdaptFsm.pFsm != nil {
- err = oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ if oFsm.PAdaptFsm.PFsm != nil {
+ err = oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
}
}
if err != nil {
@@ -1658,8 +1660,8 @@
oFsm.volthaImageState = voltha.ImageState_IMAGE_UNKNOWN //something like 'IMAGE_DOWNLOAD_ABORTED' would be better (proto)
oFsm.mutexUpgradeParams.Unlock()
//TODO!!!: possibly send event information for aborted upgrade (aborted by omci processing)??
- if oFsm.pAdaptFsm != nil && oFsm.pAdaptFsm.pFsm != nil {
- err := oFsm.pAdaptFsm.pFsm.Event(upgradeEvAbort)
+ if oFsm.PAdaptFsm != nil && oFsm.PAdaptFsm.PFsm != nil {
+ err := oFsm.PAdaptFsm.PFsm.Event(UpgradeEvAbort)
if err != nil {
logger.Warnw(ctx, "onu upgrade fsm could not abort on omci error", log.Fields{
"device-id": oFsm.deviceID, "error": err})
@@ -1674,9 +1676,9 @@
oFsm.isWaitingForAdapterDlResponse = false
oFsm.mutexIsAwaitingAdapterDlResponse.Unlock()
//let the upgrade process proceed
- pUpgradeFsm := oFsm.pAdaptFsm
+ pUpgradeFsm := oFsm.PAdaptFsm
if pUpgradeFsm != nil {
- _ = pUpgradeFsm.pFsm.Event(upgradeEvPrepareSwDownload)
+ _ = pUpgradeFsm.PFsm.Event(UpgradeEvPrepareSwDownload)
} else {
logger.Errorw(ctx, "pUpgradeFsm is nil", log.Fields{"device-id": oFsm.deviceID})
}
diff --git a/internal/pkg/onuadaptercore/onu_image_status.go b/internal/pkg/swupg/onu_image_status.go
similarity index 74%
rename from internal/pkg/onuadaptercore/onu_image_status.go
rename to internal/pkg/swupg/onu_image_status.go
index d226134..4e1215f 100755
--- a/internal/pkg/onuadaptercore/onu_image_status.go
+++ b/internal/pkg/swupg/onu_image_status.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package swupg provides the utilities for onu sw upgrade
+package swupg
import (
"context"
@@ -27,17 +27,20 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
//OnuImageStatus implements methods to get status info of onu images
type OnuImageStatus struct {
- pDevEntry *OnuDeviceEntry
deviceID string
+ pDeviceHandler cmn.IdeviceHandler
+ pDevEntry cmn.IonuDeviceEntry
+ pOmciCC *cmn.OmciCC
requestedAttributes me.AttributeValueMap
mutexWaitingForResp sync.RWMutex
waitingForResp bool
- respChannel chan Message
+ respChannel chan cmn.Message
mutexPLastTxMeInstance sync.RWMutex
pLastTxMeInstance *me.ManagedEntity
}
@@ -53,30 +56,33 @@
const cResponse = "response: "
//NewOnuImageStatus creates a new instance of OnuImageStatus
-func NewOnuImageStatus(pDevEntry *OnuDeviceEntry) *OnuImageStatus {
+func NewOnuImageStatus(apDeviceHandler cmn.IdeviceHandler, apDevEntry cmn.IonuDeviceEntry) *OnuImageStatus {
return &OnuImageStatus{
- pDevEntry: pDevEntry,
- deviceID: pDevEntry.deviceID,
+ deviceID: apDeviceHandler.GetDeviceID(),
+ pDeviceHandler: apDeviceHandler,
+ pDevEntry: apDevEntry,
+ pOmciCC: apDevEntry.GetDevOmciCC(),
requestedAttributes: make(me.AttributeValueMap),
waitingForResp: false,
- respChannel: make(chan Message),
+ respChannel: make(chan cmn.Message),
}
}
-func (oo *OnuImageStatus) getOnuImageStatus(ctx context.Context) (*voltha.OnuImages, error) {
+// GetOnuImageStatus - TODO: add comment
+func (oo *OnuImageStatus) GetOnuImageStatus(ctx context.Context) (*voltha.OnuImages, error) {
- if !oo.pDevEntry.baseDeviceHandler.isReadyForOmciConfig() {
+ if !oo.pDeviceHandler.IsReadyForOmciConfig() {
logger.Errorw(ctx, "command rejected - improper device state", log.Fields{"device-id": oo.deviceID})
return nil, fmt.Errorf("command-rejected-improper-device-state")
}
- if oo.pDevEntry.PDevOmciCC == nil {
+ if oo.pOmciCC == nil {
logger.Errorw(ctx, "omciCC not ready to receive omci messages", log.Fields{"device-id": oo.deviceID})
return nil, fmt.Errorf("omciCC-not-ready-to-receive-omci-messages")
}
var images voltha.OnuImages
- for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
- logger.Debugw(ctx, "getOnuImageStatus for image id", log.Fields{"image-id": i, "device-id": oo.deviceID})
+ for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
+ logger.Debugw(ctx, "GetOnuImageStatus for image id", log.Fields{"image-id": i, "device-id": oo.deviceID})
var image voltha.OnuImage
@@ -110,8 +116,8 @@
func (oo *OnuImageStatus) requestOnuImageAttributes(ctx context.Context, imageID uint16, image *voltha.OnuImage) error {
oo.mutexPLastTxMeInstance.Lock()
- meInstance, err := oo.pDevEntry.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID,
- imageID, oo.requestedAttributes, oo.pDevEntry.pOpenOnuAc.omciTimeout, true, oo.respChannel)
+ meInstance, err := oo.pOmciCC.SendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID,
+ imageID, oo.requestedAttributes, oo.pDeviceHandler.GetOmciTimeout(), true, oo.respChannel)
if err != nil {
oo.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "can't send omci request to get data for image id", log.Fields{"image-id": imageID, "device-id": oo.deviceID})
@@ -135,7 +141,7 @@
logger.Errorw(ctx, "waitForGetOnuImageStatus context done", log.Fields{"device-id": oo.deviceID})
oo.setWaitingForResp(false)
return fmt.Errorf("wait-for-image-status-context-done")
- case <-time.After(oo.pDevEntry.PDevOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
+ case <-time.After(oo.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second):
logger.Errorw(ctx, "waitForGetOnuImageStatus timeout", log.Fields{"device-id": oo.deviceID})
oo.setWaitingForResp(false)
return fmt.Errorf("wait-for-image-status-timeout")
@@ -146,13 +152,13 @@
return fmt.Errorf("wait-for-image-status-response-error")
}
switch message.Type {
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oo.setWaitingForResp(false)
return oo.processGetOnuImageStatusResp(ctx, msg, image)
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Info(ctx, "waitForGetOnuImageStatus abort msg received", log.Fields{"device-id": oo.deviceID})
oo.setWaitingForResp(false)
return fmt.Errorf("wait-for-image-status-abort-msg-received")
@@ -169,7 +175,7 @@
}
-func (oo *OnuImageStatus) processGetOnuImageStatusResp(ctx context.Context, msg OmciMessage, image *voltha.OnuImage) error {
+func (oo *OnuImageStatus) processGetOnuImageStatusResp(ctx context.Context, msg cmn.OmciMessage, image *voltha.OnuImage) error {
if msg.OmciMsg.MessageType != omci.GetResponseType {
logger.Errorw(ctx, "processGetOnuImageStatusResp wrong response type received", log.Fields{"respType": msg.OmciMsg.MessageType, "device-id": oo.deviceID})
return fmt.Errorf("process-image-status-response-error")
@@ -219,30 +225,30 @@
// mandatory attributes
case cImgIsCommitted:
- if meAttributes[cImgIsCommitted].(uint8) == swIsCommitted {
+ if meAttributes[cImgIsCommitted].(uint8) == cmn.SwIsCommitted {
image.IsCommited = true
} else {
image.IsCommited = false
}
case cImgIsActive:
- if meAttributes[cImgIsActive].(uint8) == swIsActive {
+ if meAttributes[cImgIsActive].(uint8) == cmn.SwIsActive {
image.IsActive = true
} else {
image.IsActive = false
}
case cImgIsValid:
- if meAttributes[cImgIsValid].(uint8) == swIsValid {
+ if meAttributes[cImgIsValid].(uint8) == cmn.SwIsValid {
image.IsValid = true
} else {
image.IsValid = false
}
case cImgVersion:
- image.Version = TrimStringFromMeOctet(meAttributes[cImgVersion])
+ image.Version = cmn.TrimStringFromMeOctet(meAttributes[cImgVersion])
// optional attributes
case cImgProductCode:
if msgObj.Result == me.Success {
- image.ProductCode = TrimStringFromMeOctet(meAttributes[cImgProductCode])
+ image.ProductCode = cmn.TrimStringFromMeOctet(meAttributes[cImgProductCode])
} else {
sResult := msgObj.Result.String()
logger.Infow(ctx, "processAttributesReceived - ProductCode",
@@ -266,63 +272,66 @@
func (oo *OnuImageStatus) updateOnuSwImageIndications(ctx context.Context, images *voltha.OnuImages) {
- oo.pDevEntry.mutexOnuSwImageIndications.Lock()
+ oo.pDevEntry.LockMutexOnuSwImageIndications()
+ onuSwImageIndications := oo.pDevEntry.GetOnuSwImageIndications()
validActiveImageFound := false
- for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
+ for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
if images.Items[i].IsActive && images.Items[i].IsValid {
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.entityID = uint16(i)
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.valid = images.Items[i].IsValid
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.version = images.Items[i].Version
+ onuSwImageIndications.ActiveEntityEntry.EntityID = uint16(i)
+ onuSwImageIndications.ActiveEntityEntry.Valid = images.Items[i].IsValid
+ onuSwImageIndications.ActiveEntityEntry.Version = images.Items[i].Version
if images.Items[i].IsCommited {
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.isCommitted = swIsCommitted
+ onuSwImageIndications.ActiveEntityEntry.IsCommitted = cmn.SwIsCommitted
} else {
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.isCommitted = swIsUncommitted
+ onuSwImageIndications.ActiveEntityEntry.IsCommitted = cmn.SwIsUncommitted
}
validActiveImageFound = true
break
}
}
if !validActiveImageFound {
- oo.pDevEntry.onuSwImageIndications.activeEntityEntry.valid = false
+ onuSwImageIndications.ActiveEntityEntry.Valid = false
}
validInactiveImageFound := false
- for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
+ for i := cmn.FirstSwImageMeID; i <= cmn.SecondSwImageMeID; i++ {
if !images.Items[i].IsActive && images.Items[i].IsValid {
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.entityID = uint16(i)
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.valid = images.Items[i].IsValid
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.version = images.Items[i].Version
+ onuSwImageIndications.InActiveEntityEntry.EntityID = uint16(i)
+ onuSwImageIndications.InActiveEntityEntry.Valid = images.Items[i].IsValid
+ onuSwImageIndications.InActiveEntityEntry.Version = images.Items[i].Version
if images.Items[i].IsCommited {
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.isCommitted = swIsCommitted
+ onuSwImageIndications.InActiveEntityEntry.IsCommitted = cmn.SwIsCommitted
} else {
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.isCommitted = swIsUncommitted
+ onuSwImageIndications.InActiveEntityEntry.IsCommitted = cmn.SwIsUncommitted
}
validInactiveImageFound = true
break
}
}
if !validInactiveImageFound {
- oo.pDevEntry.onuSwImageIndications.inactiveEntityEntry.valid = false
+ onuSwImageIndications.InActiveEntityEntry.Valid = false
}
- oo.pDevEntry.mutexOnuSwImageIndications.Unlock()
+ oo.pDevEntry.SetOnuSwImageIndications(onuSwImageIndications)
+ oo.pDevEntry.UnlockMutexOnuSwImageIndications()
}
func (oo *OnuImageStatus) updateOnuSwImagePersistentData(ctx context.Context) {
- activeImageVersion := oo.pDevEntry.getActiveImageVersion(ctx)
- oo.pDevEntry.mutexPersOnuConfig.Lock()
- if oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion != activeImageVersion {
+ activeImageVersion := oo.pDevEntry.GetActiveImageVersion(ctx)
+ oo.pDevEntry.LockMutexPersOnuConfig()
+ persActiveSwVersion := oo.pDevEntry.GetPersActiveSwVersion()
+ if persActiveSwVersion != activeImageVersion {
logger.Infow(ctx, "Active SW version has been changed at ONU - update persistent data",
- log.Fields{"old version": oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion,
+ log.Fields{"old version": persActiveSwVersion,
"new version": activeImageVersion, "device-id": oo.deviceID})
- oo.pDevEntry.sOnuPersistentData.PersActiveSwVersion = activeImageVersion
- oo.pDevEntry.mutexPersOnuConfig.Unlock()
- if err := oo.pDevEntry.baseDeviceHandler.storePersistentData(ctx); err != nil {
+ oo.pDevEntry.SetPersActiveSwVersion(activeImageVersion)
+ oo.pDevEntry.UnlockMutexPersOnuConfig()
+ if err := oo.pDeviceHandler.StorePersistentData(ctx); err != nil {
logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
log.Fields{"device-id": oo.deviceID, "err": err})
}
return
}
- oo.pDevEntry.mutexPersOnuConfig.Unlock()
+ oo.pDevEntry.UnlockMutexPersOnuConfig()
}
func (oo *OnuImageStatus) setWaitingForResp(value bool) {
@@ -341,10 +350,10 @@
//CancelProcessing ensures that interrupted processing is canceled while waiting for a response
func (oo *OnuImageStatus) CancelProcessing(ctx context.Context) {
if oo.isWaitingForResp() {
- abortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ abortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
oo.respChannel <- abortMsg
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/uniprt/common.go
old mode 100644
new mode 100755
similarity index 86%
copy from internal/pkg/onuadaptercore/common.go
copy to internal/pkg/uniprt/common.go
index b0b10e3..3dcfe83
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/uniprt/common.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "uniprt"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/uniprt/uniportadmin.go
old mode 100644
new mode 100755
similarity index 63%
rename from internal/pkg/onuadaptercore/uniportadmin.go
rename to internal/pkg/uniprt/uniportadmin.go
index 2ceea25..a9de1dd
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/uniprt/uniportadmin.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
import (
"context"
@@ -28,128 +28,134 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
)
-//lockStateFsm defines the structure for the state machine to lock/unlock the ONU UNI ports via OMCI
-type lockStateFsm struct {
- pDeviceHandler *deviceHandler
+//LockStateFsm defines the structure for the state machine to lock/unlock the ONU UNI ports via OMCI
+type LockStateFsm struct {
deviceID string
- pOmciCC *omciCC
+ pDeviceHandler cmn.IdeviceHandler
+ pOnuDeviceEntry cmn.IonuDeviceEntry
+ pOmciCC *cmn.OmciCC
mutexAdminState sync.RWMutex
adminState bool
- requestEvent OnuDeviceEvent
+ requestEvent cmn.OnuDeviceEvent
omciLockResponseReceived chan bool //seperate channel needed for checking UNI port OMCi message responses
- pAdaptFsm *AdapterFsm
+ PAdaptFsm *cmn.AdapterFsm
mutexPLastTxMeInstance sync.RWMutex
pLastTxMeInstance *me.ManagedEntity
}
+// events of lock/unlock UNI port FSM
const (
- // events of lock/unlock UNI port FSM
- uniEvStart = "uniEvStart"
- uniEvStartAdmin = "uniEvStartAdmin"
- uniEvRxUnisResp = "uniEvRxUnisResp"
- uniEvRxOnugResp = "uniEvRxOnugResp"
- uniEvTimeoutSimple = "uniEvTimeoutSimple"
- uniEvTimeoutUnis = "uniEvTimeoutUnis"
- uniEvReset = "uniEvReset"
- uniEvRestart = "uniEvRestart"
+ UniEvStart = "UniEvStart"
+ UniEvStartAdmin = "UniEvStartAdmin"
+ UniEvRxUnisResp = "UniEvRxUnisResp"
+ UniEvRxOnugResp = "UniEvRxOnugResp"
+ UniEvTimeoutSimple = "UniEvTimeoutSimple"
+ UniEvTimeoutUnis = "UniEvTimeoutUnis"
+ UniEvReset = "UniEvReset"
+ UniEvRestart = "UniEvRestart"
)
-const (
- // states of lock/unlock UNI port FSM
- uniStDisabled = "uniStDisabled"
- uniStStarting = "uniStStarting"
- uniStSettingUnis = "uniStSettingUnis"
- uniStSettingOnuG = "uniStSettingOnuG"
- uniStAdminDone = "uniStAdminDone"
- uniStResetting = "uniStResetting"
-)
-const cUniFsmIdleState = uniStDisabled
-//newLockStateFsm is the 'constructor' for the state machine to lock/unlock the ONU UNI ports via OMCI
-func newLockStateFsm(ctx context.Context, apDevOmciCC *omciCC, aAdminState bool, aRequestEvent OnuDeviceEvent,
- aName string, apDeviceHandler *deviceHandler, aCommChannel chan Message) *lockStateFsm {
- instFsm := &lockStateFsm{
- pDeviceHandler: apDeviceHandler,
- deviceID: apDeviceHandler.deviceID,
- pOmciCC: apDevOmciCC,
- adminState: aAdminState,
- requestEvent: aRequestEvent,
+// states of lock/unlock UNI port FSM
+const (
+ UniStDisabled = "UniStDisabled"
+ UniStStarting = "UniStStarting"
+ UniStSettingUnis = "UniStSettingUnis"
+ UniStSettingOnuG = "UniStSettingOnuG"
+ UniStAdminDone = "UniStAdminDone"
+ UniStResetting = "UniStResetting"
+)
+
+// CUniFsmIdleState - TODO: add comment
+const CUniFsmIdleState = UniStDisabled
+
+//NewLockStateFsm is the 'constructor' for the state machine to lock/unlock the ONU UNI ports via OMCI
+func NewLockStateFsm(ctx context.Context, aAdminState bool, aRequestEvent cmn.OnuDeviceEvent,
+ aName string, apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, aCommChannel chan cmn.Message) *LockStateFsm {
+ instFsm := &LockStateFsm{
+ deviceID: apDeviceHandler.GetDeviceID(),
+ pDeviceHandler: apDeviceHandler,
+ pOnuDeviceEntry: apOnuDeviceEntry,
+ pOmciCC: apOnuDeviceEntry.GetDevOmciCC(),
+ adminState: aAdminState,
+ requestEvent: aRequestEvent,
}
- instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
- if instFsm.pAdaptFsm == nil {
- logger.Errorw(ctx, "LockStateFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
+ if instFsm.PAdaptFsm == nil {
+ logger.Errorw(ctx, "LockStateFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
if aAdminState { //port locking requested
- instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
- uniStDisabled,
+ instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+ UniStDisabled,
fsm.Events{
- {Name: uniEvStart, Src: []string{uniStDisabled}, Dst: uniStStarting},
+ {Name: UniEvStart, Src: []string{UniStDisabled}, Dst: UniStStarting},
- {Name: uniEvStartAdmin, Src: []string{uniStStarting}, Dst: uniStSettingUnis},
+ {Name: UniEvStartAdmin, Src: []string{UniStStarting}, Dst: UniStSettingUnis},
// the settingUnis state is used for multi ME config for all UNI related ports
// maybe such could be reflected in the state machine as well (port number parametrized)
// but that looks not straightforward here - so we keep it simple here for the beginning(?)
- {Name: uniEvRxUnisResp, Src: []string{uniStSettingUnis}, Dst: uniStSettingOnuG},
- {Name: uniEvRxOnugResp, Src: []string{uniStSettingOnuG}, Dst: uniStAdminDone},
+ {Name: UniEvRxUnisResp, Src: []string{UniStSettingUnis}, Dst: UniStSettingOnuG},
+ {Name: UniEvRxOnugResp, Src: []string{UniStSettingOnuG}, Dst: UniStAdminDone},
- {Name: uniEvTimeoutSimple, Src: []string{uniStSettingOnuG}, Dst: uniStStarting},
- {Name: uniEvTimeoutUnis, Src: []string{uniStSettingUnis}, Dst: uniStStarting},
+ {Name: UniEvTimeoutSimple, Src: []string{UniStSettingOnuG}, Dst: UniStStarting},
+ {Name: UniEvTimeoutUnis, Src: []string{UniStSettingUnis}, Dst: UniStStarting},
- {Name: uniEvReset, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
- uniStAdminDone}, Dst: uniStResetting},
- // exceptional treatment for all states except uniStResetting
- {Name: uniEvRestart, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
- uniStAdminDone, uniStResetting}, Dst: uniStDisabled},
+ {Name: UniEvReset, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+ UniStAdminDone}, Dst: UniStResetting},
+ // exceptional treatment for all states except UniStResetting
+ {Name: UniEvRestart, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+ UniStAdminDone, UniStResetting}, Dst: UniStDisabled},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
- ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
- ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
- ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
- ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
- ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
+ "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+ ("enter_" + UniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+ ("enter_" + UniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+ ("enter_" + UniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+ ("enter_" + UniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+ ("enter_" + UniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
},
)
} else { //port unlocking requested
- instFsm.pAdaptFsm.pFsm = fsm.NewFSM(
- uniStDisabled,
+ instFsm.PAdaptFsm.PFsm = fsm.NewFSM(
+ UniStDisabled,
fsm.Events{
- {Name: uniEvStart, Src: []string{uniStDisabled}, Dst: uniStStarting},
+ {Name: UniEvStart, Src: []string{UniStDisabled}, Dst: UniStStarting},
- {Name: uniEvStartAdmin, Src: []string{uniStStarting}, Dst: uniStSettingOnuG},
- {Name: uniEvRxOnugResp, Src: []string{uniStSettingOnuG}, Dst: uniStSettingUnis},
+ {Name: UniEvStartAdmin, Src: []string{UniStStarting}, Dst: UniStSettingOnuG},
+ {Name: UniEvRxOnugResp, Src: []string{UniStSettingOnuG}, Dst: UniStSettingUnis},
// the settingUnis state is used for multi ME config for all UNI related ports
// maybe such could be reflected in the state machine as well (port number parametrized)
// but that looks not straightforward here - so we keep it simple here for the beginning(?)
- {Name: uniEvRxUnisResp, Src: []string{uniStSettingUnis}, Dst: uniStAdminDone},
+ {Name: UniEvRxUnisResp, Src: []string{UniStSettingUnis}, Dst: UniStAdminDone},
- {Name: uniEvTimeoutSimple, Src: []string{uniStSettingOnuG}, Dst: uniStStarting},
- {Name: uniEvTimeoutUnis, Src: []string{uniStSettingUnis}, Dst: uniStStarting},
+ {Name: UniEvTimeoutSimple, Src: []string{UniStSettingOnuG}, Dst: UniStStarting},
+ {Name: UniEvTimeoutUnis, Src: []string{UniStSettingUnis}, Dst: UniStStarting},
- {Name: uniEvReset, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
- uniStAdminDone}, Dst: uniStResetting},
- // exceptional treatment for all states except uniStResetting
- {Name: uniEvRestart, Src: []string{uniStStarting, uniStSettingOnuG, uniStSettingUnis,
- uniStAdminDone, uniStResetting}, Dst: uniStDisabled},
+ {Name: UniEvReset, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+ UniStAdminDone}, Dst: UniStResetting},
+ // exceptional treatment for all states except UniStResetting
+ {Name: UniEvRestart, Src: []string{UniStStarting, UniStSettingOnuG, UniStSettingUnis,
+ UniStAdminDone, UniStResetting}, Dst: UniStDisabled},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
- ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
- ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
- ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
- ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
- ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
+ "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) },
+ ("enter_" + UniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+ ("enter_" + UniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+ ("enter_" + UniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+ ("enter_" + UniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+ ("enter_" + UniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
},
)
}
- if instFsm.pAdaptFsm.pFsm == nil {
+ if instFsm.PAdaptFsm.PFsm == nil {
logger.Errorw(ctx, "LockStateFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
@@ -159,13 +165,13 @@
return instFsm
}
-//setSuccessEvent modifies the requested event notified on success
+//SetSuccessEvent modifies the requested event notified on success
//assumption is that this is only called in the disabled (idle) state of the FSM, hence no sem protection required
-func (oFsm *lockStateFsm) setSuccessEvent(aEvent OnuDeviceEvent) {
+func (oFsm *LockStateFsm) SetSuccessEvent(aEvent cmn.OnuDeviceEvent) {
oFsm.requestEvent = aEvent
}
-func (oFsm *lockStateFsm) enterAdminStartingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterAdminStartingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "LockStateFSM start", log.Fields{"in state": e.FSM.Current(),
"device-id": oFsm.deviceID})
// in case the used channel is not yet defined (can be re-used after restarts)
@@ -179,26 +185,26 @@
for len(oFsm.omciLockResponseReceived) > 0 {
<-oFsm.omciLockResponseReceived
}
- for len(oFsm.pAdaptFsm.commChan) > 0 {
- <-oFsm.pAdaptFsm.commChan
+ for len(oFsm.PAdaptFsm.CommChan) > 0 {
+ <-oFsm.PAdaptFsm.CommChan
}
}
// start go routine for processing of LockState messages
go oFsm.processOmciLockMessages(ctx)
//let the state machine run forward from here directly
- pLockStateAFsm := oFsm.pAdaptFsm
+ pLockStateAFsm := oFsm.PAdaptFsm
if pLockStateAFsm != nil {
// 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)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UniEvStartAdmin)
}
}(pLockStateAFsm)
}
}
-func (oFsm *lockStateFsm) enterSettingOnuGState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterSettingOnuGState(ctx context.Context, e *fsm.Event) {
var omciAdminState uint8 = 1 //default locked
oFsm.mutexAdminState.RLock()
if !oFsm.adminState {
@@ -209,16 +215,16 @@
"omciAdmin": omciAdminState, "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetOnuGLS(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout, true,
- requestedAttributes, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendSetOnuGLS(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true,
+ requestedAttributes, oFsm.PAdaptFsm.CommChan)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "OnuGLS set failed, aborting LockStateFSM", log.Fields{"device-id": oFsm.deviceID})
- pLockStateAFsm := oFsm.pAdaptFsm
+ pLockStateAFsm := oFsm.PAdaptFsm
if pLockStateAFsm != nil {
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(uniEvReset)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UniEvReset)
}
}(pLockStateAFsm)
}
@@ -232,13 +238,13 @@
logger.Errorw(ctx, "could not send OMCI message from LockStateFsm", log.Fields{
"device-id": oFsm.deviceID})
//some more sophisticated approach is possible, e.g. repeating once, by now let's reset the state machine in order to release all resources now
- pLockStateAFsm := oFsm.pAdaptFsm
+ pLockStateAFsm := oFsm.PAdaptFsm
if pLockStateAFsm != nil {
// 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)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UniEvReset)
}
}(pLockStateAFsm)
}
@@ -247,7 +253,7 @@
oFsm.mutexPLastTxMeInstance.Unlock()
}
-func (oFsm *lockStateFsm) enterSettingUnisState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterSettingUnisState(ctx context.Context, e *fsm.Event) {
oFsm.mutexAdminState.RLock()
logger.Debugw(ctx, "LockStateFSM - starting UniTP adminState loop", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID, "LockState": oFsm.adminState})
@@ -255,41 +261,41 @@
go oFsm.performUniPortAdminSet(ctx)
}
-func (oFsm *lockStateFsm) enterAdminDoneState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterAdminDoneState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "LockStateFSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oFsm.deviceID})
//use DeviceHandler event notification directly, no need/support to update DeviceEntryState for lock/unlock
- oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, oFsm.requestEvent)
+ oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, oFsm.requestEvent)
//let's reset the state machine in order to release all resources now
- pLockStateAFsm := oFsm.pAdaptFsm
+ pLockStateAFsm := oFsm.PAdaptFsm
if pLockStateAFsm != nil {
// 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)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UniEvReset)
}
}(pLockStateAFsm)
}
}
-func (oFsm *lockStateFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+func (oFsm *LockStateFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
logger.Debugw(ctx, "LockStateFSM resetting", log.Fields{"device-id": oFsm.deviceID})
- pLockStateAFsm := oFsm.pAdaptFsm
+ pLockStateAFsm := oFsm.PAdaptFsm
if pLockStateAFsm != nil {
// abort running message processing
- fsmAbortMsg := Message{
- Type: TestMsg,
- Data: TestMessage{
- TestMessageVal: AbortMessageProcessing,
+ fsmAbortMsg := cmn.Message{
+ Type: cmn.TestMsg,
+ Data: cmn.TestMessage{
+ TestMessageVal: cmn.AbortMessageProcessing,
},
}
- pLockStateAFsm.commChan <- fsmAbortMsg
+ pLockStateAFsm.CommChan <- fsmAbortMsg
//try to restart the FSM to 'disabled'
// see DownloadedState: decouple event transfer
- go func(a_pAFsm *AdapterFsm) {
- if a_pAFsm != nil && a_pAFsm.pFsm != nil {
- _ = a_pAFsm.pFsm.Event(uniEvRestart)
+ go func(a_pAFsm *cmn.AdapterFsm) {
+ if a_pAFsm != nil && a_pAFsm.PFsm != nil {
+ _ = a_pAFsm.PFsm.Event(UniEvRestart)
}
}(pLockStateAFsm)
oFsm.mutexPLastTxMeInstance.Lock()
@@ -298,32 +304,32 @@
}
}
-func (oFsm *lockStateFsm) processOmciLockMessages(ctx context.Context) {
+func (oFsm *LockStateFsm) processOmciLockMessages(ctx context.Context) {
logger.Debugw(ctx, "Start LockStateFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
loop:
for {
// case <-ctx.Done():
// logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
- message, ok := <-oFsm.pAdaptFsm.commChan
+ message, ok := <-oFsm.PAdaptFsm.CommChan
if !ok {
logger.Info(ctx, "LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRestart)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvRestart)
break loop
}
logger.Debugw(ctx, "LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
- case TestMsg:
- msg, _ := message.Data.(TestMessage)
- if msg.TestMessageVal == AbortMessageProcessing {
+ case cmn.TestMsg:
+ msg, _ := message.Data.(cmn.TestMessage)
+ if msg.TestMessageVal == cmn.AbortMessageProcessing {
logger.Debugw(ctx, "LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
logger.Warnw(ctx, "LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
- case OMCI:
- msg, _ := message.Data.(OmciMessage)
+ case cmn.OMCI:
+ msg, _ := message.Data.(cmn.OmciMessage)
oFsm.handleOmciLockStateMessage(ctx, msg)
default:
logger.Warn(ctx, "LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
@@ -333,7 +339,7 @@
logger.Debugw(ctx, "End LockStateFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *lockStateFsm) handleOmciLockStateMessage(ctx context.Context, msg OmciMessage) {
+func (oFsm *LockStateFsm) handleOmciLockStateMessage(ctx context.Context, msg cmn.OmciMessage) {
logger.Debugw(ctx, "Rx OMCI LockStateFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
@@ -371,7 +377,7 @@
case "OnuG":
{ // let the FSM proceed ...
oFsm.mutexPLastTxMeInstance.RUnlock()
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvRxOnugResp)
}
case "PhysicalPathTerminationPointEthernetUni", "VirtualEthernetInterfacePoint":
{ // let the PPTP init proceed by stopping the wait function
@@ -401,7 +407,7 @@
}
}
-func (oFsm *lockStateFsm) performUniPortAdminSet(ctx context.Context) {
+func (oFsm *LockStateFsm) performUniPortAdminSet(ctx context.Context) {
var omciAdminState uint8 = 1 //default locked
oFsm.mutexAdminState.RLock()
if !oFsm.adminState {
@@ -411,40 +417,40 @@
//set PPTPEthUni or VEIP AdminState
requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
- for uniNo, uniPort := range oFsm.pOmciCC.pBaseDeviceHandler.uniEntityMap {
+ for uniNo, uniPort := range *oFsm.pDeviceHandler.GetUniEntityMap() {
// only unlock the UniPort in case it is defined for usage (R2.6 limit only one port),
- // compare also limitation for logical voltha port in dh.enableUniPortStateUpdate()
+ // compare also limitation for logical voltha port in dh.EnableUniPortStateUpdate()
- if (omciAdminState == 1) || (1<<uniPort.uniID)&oFsm.pDeviceHandler.pOpenOnuAc.config.UniPortMask == (1<<uniPort.uniID) {
+ if (omciAdminState == 1) || (1<<uniPort.UniID)&oFsm.pDeviceHandler.GetUniPortMask() == (1<<uniPort.UniID) {
var meInstance *me.ManagedEntity
- if uniPort.portType == uniPPTP {
+ if uniPort.PortType == cmn.UniPPTP {
logger.Debugw(ctx, "Setting PPTP admin state", log.Fields{
"device-id": oFsm.deviceID, "for PortNo": uniNo, "state (0-unlock)": omciAdminState})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetPptpEthUniLS(log.WithSpanFromContext(context.TODO(), ctx),
- uniPort.entityID, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, requestedAttributes, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendSetPptpEthUniLS(log.WithSpanFromContext(context.TODO(), ctx),
+ uniPort.EntityID, oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, requestedAttributes, oFsm.PAdaptFsm.CommChan)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetPptpEthUniLS set failed, aborting LockStateFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
return
}
oFsm.pLastTxMeInstance = meInstance
oFsm.mutexPLastTxMeInstance.Unlock()
- } else if uniPort.portType == uniVEIP {
+ } else if uniPort.PortType == cmn.UniVEIP {
logger.Debugw(ctx, "Setting VEIP admin state", log.Fields{
"device-id": oFsm.deviceID, "for PortNo": uniNo, "state (0-unlock)": omciAdminState})
oFsm.mutexPLastTxMeInstance.Lock()
- meInstance, err := oFsm.pOmciCC.sendSetVeipLS(log.WithSpanFromContext(context.TODO(), ctx),
- uniPort.entityID, oFsm.pDeviceHandler.pOpenOnuAc.omciTimeout,
- true, requestedAttributes, oFsm.pAdaptFsm.commChan)
+ meInstance, err := oFsm.pOmciCC.SendSetVeipLS(log.WithSpanFromContext(context.TODO(), ctx),
+ uniPort.EntityID, oFsm.pDeviceHandler.GetOmciTimeout(),
+ true, requestedAttributes, oFsm.PAdaptFsm.CommChan)
if err != nil {
oFsm.mutexPLastTxMeInstance.Unlock()
logger.Errorw(ctx, "SetVeipLS set failed, aborting LockStateFsm!",
log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
return
}
oFsm.pLastTxMeInstance = meInstance
@@ -460,7 +466,7 @@
logger.Errorw(ctx, "could not send PortAdmin OMCI message from LockStateFsm", log.Fields{
"device-id": oFsm.deviceID, "Port": uniNo})
//some more sophisticated approach is possible, e.g. repeating once, by now let's reset the state machine in order to release all resources now
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
return
}
oFsm.mutexPLastTxMeInstance.RUnlock()
@@ -470,7 +476,7 @@
if err != nil {
logger.Errorw(ctx, "UniTP Admin State set failed, aborting LockState set!",
log.Fields{"device-id": oFsm.deviceID, "Port": uniNo})
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvReset)
return
}
}
@@ -478,16 +484,16 @@
// 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(ctx, "UniTP adminState loop finished", log.Fields{"device-id": oFsm.deviceID})
- _ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxUnisResp)
+ _ = oFsm.PAdaptFsm.PFsm.Event(UniEvRxUnisResp)
}
-func (oFsm *lockStateFsm) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
+func (oFsm *LockStateFsm) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Infow(ctx,"LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw(ctx, "LockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "lockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("lockStateFsm uni-set timeout for device-id %s", oFsm.deviceID)
case success := <-oFsm.omciLockResponseReceived:
if success {
@@ -495,7 +501,7 @@
return nil
}
// should not happen so far
- logger.Warnw(ctx, "LockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "lockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("lockStateFsm uni-set responseError for device-id %s", oFsm.deviceID)
}
}
diff --git a/internal/pkg/onuadaptercore/uniportstatus.go b/internal/pkg/uniprt/uniportstatus.go
old mode 100644
new mode 100755
similarity index 71%
rename from internal/pkg/onuadaptercore/uniportstatus.go
rename to internal/pkg/uniprt/uniportstatus.go
index f7cfe4b..8f8dedd
--- a/internal/pkg/onuadaptercore/uniportstatus.go
+++ b/internal/pkg/uniprt/uniportstatus.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercoreonu provides the utility for onu devices, flows and statistics
-package adaptercoreonu
+//Package uniprt provides the utilities for uni port configuration
+package uniprt
import (
"context"
@@ -24,6 +24,7 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
"github.com/opencord/voltha-lib-go/v7/pkg/log"
+ cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
"github.com/opencord/voltha-protos/v5/go/extension"
)
@@ -36,89 +37,92 @@
//UniPortStatus implements methods to get uni port status info
type UniPortStatus struct {
- omciRespChn chan Message
- pOmiCC *omciCC
+ pDeviceHandler cmn.IdeviceHandler
+ pOmiCC *cmn.OmciCC
+ omciRespChn chan cmn.Message
pLastTxMeInstance *me.ManagedEntity
}
//NewUniPortStatus creates a new instance of UniPortStatus
-func NewUniPortStatus(pOmicc *omciCC) *UniPortStatus {
+func NewUniPortStatus(apDeviceHandler cmn.IdeviceHandler, apOmicc *cmn.OmciCC) *UniPortStatus {
return &UniPortStatus{
- omciRespChn: make(chan Message),
- pOmiCC: pOmicc,
+ pDeviceHandler: apDeviceHandler,
+ pOmiCC: apOmicc,
+ omciRespChn: make(chan cmn.Message),
}
}
-func (portStatus *UniPortStatus) getUniPortStatus(ctx context.Context, uniIdx uint32) *extension.SingleGetValueResponse {
- for _, uniPort := range portStatus.pOmiCC.pBaseDeviceHandler.uniEntityMap {
+// GetUniPortStatus - TODO: add comment
+func (portStatus *UniPortStatus) GetUniPortStatus(ctx context.Context, uniIdx uint32) *extension.SingleGetValueResponse {
+ for _, uniPort := range *portStatus.pDeviceHandler.GetUniEntityMap() {
- if uniPort.uniID == uint8(uniIdx) && uniPort.portType == uniPPTP {
+ if uniPort.UniID == uint8(uniIdx) && uniPort.PortType == cmn.UniPPTP {
requestedAttributes := me.AttributeValueMap{adminState: 0, operationalState: 0, configInd: 0}
// Note: No reference to fetch the OMCI timeout configuration value, so hard code it to 10s
- meInstance, err := portStatus.pOmiCC.sendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, uniPort.entityID, requestedAttributes, 10, true, portStatus.omciRespChn)
+ meInstance, err := portStatus.pOmiCC.SendGetMe(ctx, me.PhysicalPathTerminationPointEthernetUniClassID, uniPort.EntityID, requestedAttributes, 10, true, portStatus.omciRespChn)
if err != nil {
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
if meInstance != nil {
portStatus.pLastTxMeInstance = meInstance
//verify response
- return portStatus.waitforgetUniPortStatus(ctx, meInstance)
+ return portStatus.waitforGetUniPortStatus(ctx, meInstance)
}
}
}
- logger.Errorw(ctx, "getUniPortStatus uniIdx is not valid", log.Fields{"uniIdx": uniIdx})
- return postUniStatusErrResponse(extension.GetValueResponse_INVALID_PORT_TYPE)
+ logger.Errorw(ctx, "GetUniPortStatus uniIdx is not valid", log.Fields{"uniIdx": uniIdx})
+ return PostUniStatusErrResponse(extension.GetValueResponse_INVALID_PORT_TYPE)
}
-func (portStatus *UniPortStatus) waitforgetUniPortStatus(ctx context.Context, apMeInstance *me.ManagedEntity) *extension.SingleGetValueResponse {
+func (portStatus *UniPortStatus) waitforGetUniPortStatus(ctx context.Context, apMeInstance *me.ManagedEntity) *extension.SingleGetValueResponse {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
case <-ctx.Done():
- logger.Errorf(ctx, "waitforgetUniPortStatus Context done")
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ logger.Errorf(ctx, "waitforGetUniPortStatus Context done")
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
case <-time.After(uniStatusTimeout * time.Second):
- logger.Errorf(ctx, "waitforgetUniPortStatus timeout")
- return postUniStatusErrResponse(extension.GetValueResponse_TIMEOUT)
+ logger.Errorf(ctx, "waitforGetUniPortStatus timeout")
+ return PostUniStatusErrResponse(extension.GetValueResponse_TIMEOUT)
case omciMsg := <-portStatus.omciRespChn:
- if omciMsg.Type != OMCI {
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ if omciMsg.Type != cmn.OMCI {
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
- msg, _ := omciMsg.Data.(OmciMessage)
+ msg, _ := omciMsg.Data.(cmn.OmciMessage)
return portStatus.processGetUnitStatusResp(ctx, msg)
}
}
-func (portStatus *UniPortStatus) processGetUnitStatusResp(ctx context.Context, msg OmciMessage) *extension.SingleGetValueResponse {
+func (portStatus *UniPortStatus) processGetUnitStatusResp(ctx context.Context, msg cmn.OmciMessage) *extension.SingleGetValueResponse {
logger.Debugw(ctx, "processGetUniStatusResp:", log.Fields{"msg.Omci.MessageType": msg.OmciMsg.MessageType,
"msg.OmciMsg.TransactionID": msg.OmciMsg.TransactionID, "DeviceIdentfier": msg.OmciMsg.DeviceIdentifier})
if msg.OmciMsg.MessageType != omci.GetResponseType {
logger.Debugw(ctx, "processGetUniStatusResp error", log.Fields{"incorrect RespType": msg.OmciMsg.MessageType,
"expected": omci.GetResponseType})
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
if msgLayer == nil {
logger.Errorf(ctx, "processGetUniStatusResp omci Msg layer not found - ")
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
msgObj, msgOk := msgLayer.(*omci.GetResponse)
if !msgOk {
logger.Errorf(ctx, "processGetUniStatusResp omci msgObj layer could not be found ")
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
if msgObj.Result != me.Success {
- return postUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
+ return PostUniStatusErrResponse(extension.GetValueResponse_INTERNAL_ERROR)
}
meAttributes := msgObj.Attributes
@@ -160,7 +164,8 @@
return &singleValResp
}
-func postUniStatusErrResponse(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+// PostUniStatusErrResponse - TODO: add comment
+func PostUniStatusErrResponse(reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: extension.GetValueResponse_ERROR,