[VOL-5374] Update go version to 1.23
- Upgraded Go version for compatibility with recent toolchain
- Synced with latest dependency requirements
Change-Id: Ib526d29ec9e5d5e08e51354b741541038dcedb35
Signed-off-by: Akash Kankanala <akash.kankanala@radisys.com>
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index f6c3fa5..ca4e481 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -79,47 +79,40 @@
// DeviceHandler will interact with the OLT device.
type DeviceHandler struct {
- cm *config.ConfigManager
- device *voltha.Device
- cfg *conf.AdapterFlags
- coreClient *vgrpc.Client
- childAdapterClients map[string]*vgrpc.Client
- lockChildAdapterClients sync.RWMutex
- EventProxy eventif.EventProxy
- openOLT *OpenOLT
- exitChannel chan struct{}
- lockDevice sync.RWMutex
- Client oop.OpenoltClient
- transitionMap *TransitionMap
- clientCon *grpc.ClientConn
- flowMgr []*OpenOltFlowMgr
- groupMgr *OpenOltGroupMgr
- eventMgr *OpenOltEventMgr
- resourceMgr []*rsrcMgr.OpenOltResourceMgr
- kvStore *db.Backend // backend kv store connection handle
+ EventProxy eventif.EventProxy
+ Client oop.OpenoltClient
+ cm *config.ConfigManager
+ device *voltha.Device
+ cfg *conf.AdapterFlags
+ coreClient *vgrpc.Client
+ childAdapterClients map[string]*vgrpc.Client
+ openOLT *OpenOLT
+ exitChannel chan struct{}
+ transitionMap *TransitionMap
+ clientCon *grpc.ClientConn
+ groupMgr *OpenOltGroupMgr
+ eventMgr *OpenOltEventMgr
+ kvStore *db.Backend // backend kv store connection handle
deviceInfo *oop.DeviceInfo
+ portStats *OpenOltStatisticsMgr
+ metrics *pmmetrics.PmMetrics
+ stopCollector chan bool
+ stopHeartbeatCheck chan bool
+ stopIndications chan bool
+ perPonOnuIndicationChannel map[uint32]onuIndicationChannels
+
// discOnus (map[onuSn]bool) contains a list of ONUs that have been discovered, indexed by ONU SerialNumber.
// if the value is true that means the OnuDiscovery indication
// is currently being processed and thus we can ignore concurrent requests
// if it's false it means the processing has completed and we shouldn't be receiving a new indication
// if we do it means something went wrong and we need to retry
- discOnus sync.Map
- onus sync.Map
- portStats *OpenOltStatisticsMgr
- metrics *pmmetrics.PmMetrics
- stopCollector chan bool
- isCollectorActive bool
- stopHeartbeatCheck chan bool
- isHeartbeatCheckActive bool
- activePorts sync.Map
- stopIndications chan bool
- isReadIndicationRoutineActive bool
-
- totalPonPorts uint32
- perPonOnuIndicationChannel map[uint32]onuIndicationChannels
- perPonOnuIndicationChannelLock sync.Mutex
+ discOnus sync.Map
+ onus sync.Map
+ activePorts sync.Map
+ flowMgr []*OpenOltFlowMgr
+ resourceMgr []*rsrcMgr.OpenOltResourceMgr
// Slice of channels. Each channel in slice, index by (mcast-group-id modulo MaxNumOfGroupHandlerChannels)
// A go routine per index, waits on a unique channel for incoming mcast flow or group (add/modify/remove).
@@ -127,11 +120,20 @@
stopMcastHandlerRoutine []chan bool
mcastHandlerRoutineActive []bool
+ lockChildAdapterClients sync.RWMutex
+ lockDevice sync.RWMutex
+ perPonOnuIndicationChannelLock sync.Mutex
+
+ totalPonPorts uint32
+ heartbeatSignature uint32
+ isCollectorActive bool
+ isHeartbeatCheckActive bool
+ isReadIndicationRoutineActive bool
+
adapterPreviouslyConnected bool
agentPreviouslyConnected bool
isDeviceDeletionInProgress bool
- heartbeatSignature uint32
prevOperStatus common.OperStatus_Types
}
@@ -140,12 +142,12 @@
deviceID string
deviceType string
serialNumber string
+ proxyDeviceID string
+ adapterEndpoint string
onuID uint32
intfID uint32
- proxyDeviceID string
losRaised bool
rdiRaised bool
- adapterEndpoint string
}
type onuIndicationMsg struct {
@@ -164,10 +166,10 @@
// and process them serially. The mcast flow/group are assigned these routines based on formula (group-id modulo MaxNumOfGroupHandlerChannels)
type McastFlowOrGroupControlBlock struct {
ctx context.Context // Flow/group handler context
- flowOrGroupAction string // one of McastFlowOrGroupAdd, McastFlowOrGroupModify or McastFlowOrGroupDelete
flow *of.OfpFlowStats // Flow message (can be nil or valid flow)
group *of.OfpGroupEntry // Group message (can be nil or valid group)
errChan *chan error // channel to report the mcast Flow/group handling error
+ flowOrGroupAction string // one of McastFlowOrGroupAdd, McastFlowOrGroupModify or McastFlowOrGroupDelete
}
var pmNames = []string{
@@ -235,7 +237,7 @@
dh.mcastHandlerRoutineActive[i] = true
go dh.mcastFlowOrGroupChannelHandlerRoutine(i, dh.incomingMcastFlowOrGroup[i], dh.stopMcastHandlerRoutine[i])
}
- //TODO initialize the support classes.
+ // TODO initialize the support classes.
return &dh
}
@@ -378,7 +380,6 @@
// GetportLabel returns the label for the NNI and the PON port based on port number and port type
func GetportLabel(portNum uint32, portType voltha.Port_PortType) (string, error) {
-
switch portType {
case voltha.Port_ETHERNET_NNI:
return fmt.Sprintf("nni-%d", portNum), nil
@@ -391,8 +392,8 @@
func makeOfpPort(macAddress string, speedMbps uint32) *of.OfpPort {
if speedMbps == 0 {
- //In case it was not set in the indication
- //and no other value was provided
+ // In case it was not set in the indication
+ // and no other value was provided
speedMbps = defaultPortSpeedMbps
}
@@ -423,8 +424,8 @@
Curr: capacity,
Advertised: capacity,
Peer: capacity,
- CurrSpeed: speedMbps * 1000, //kbps
- MaxSpeed: speedMbps * 1000, //kbps
+ CurrSpeed: speedMbps * 1000, // kbps
+ MaxSpeed: speedMbps * 1000, // kbps
}
return port
@@ -434,7 +435,7 @@
var operStatus common.OperStatus_Types
if state == "up" {
operStatus = voltha.OperStatus_ACTIVE
- //populating the intfStatus map
+ // populating the intfStatus map
dh.activePorts.Store(intfID, true)
} else {
operStatus = voltha.OperStatus_DISCOVERED
@@ -656,7 +657,7 @@
return nil
}
-// nolint: gocyclo
+// nolint: gocyclo,govet
func (dh *DeviceHandler) handleIndication(ctx context.Context, indication *oop.Indication) {
raisedTs := time.Now().Unix()
switch indication.Data.(type) {
@@ -708,7 +709,7 @@
onuDiscInd := indication.GetOnuDiscInd()
logger.Infow(ctx, "received-onu-discovery-indication", log.Fields{"OnuDiscInd": onuDiscInd, "device-id": dh.device.Id})
- //put message to channel and return immediately
+ // put message to channel and return immediately
dh.putOnuIndicationToChannel(ctx, indication, onuDiscInd.GetIntfId())
case *oop.Indication_OnuInd:
span, ctx := log.CreateChildSpan(ctx, "onu-indication", log.Fields{"device-id": dh.device.Id})
@@ -716,7 +717,7 @@
onuInd := indication.GetOnuInd()
logger.Infow(ctx, "received-onu-indication", log.Fields{"OnuInd": onuInd, "device-id": dh.device.Id})
- //put message to channel and return immediately
+ // put message to channel and return immediately
dh.putOnuIndicationToChannel(ctx, indication, onuInd.GetIntfId())
case *oop.Indication_OmciInd:
span, ctx := log.CreateChildSpan(ctx, "omci-indication", log.Fields{"device-id": dh.device.Id})
@@ -808,8 +809,8 @@
}
return alarmInd
}
-func generatePonLosAlarmIndication(intfID uint32, losStatus string) *oop.AlarmIndication {
+func generatePonLosAlarmIndication(intfID uint32, losStatus string) *oop.AlarmIndication {
ponlosAlarmInd := &oop.LosIndication{
IntfId: intfID,
Status: losStatus,
@@ -821,6 +822,7 @@
}
return alarmInd
}
+
func (dh *DeviceHandler) updateIntfOperStateAndRaiseIndication(ctx context.Context, operState string, intfID uint32) {
go func() {
if err := dh.addPort(ctx, intfID, voltha.Port_PON_OLT, operState, defaultPortSpeedMbps); err != nil {
@@ -833,16 +835,12 @@
}
func (dh *DeviceHandler) reconcileOnus(ctx context.Context) error {
-
onuDevicesFromCore, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
-
logger.Error(ctx, "unable to fetch child device", log.Fields{"eeror": err})
-
return err
}
for _, onuDeviceFromCore := range onuDevicesFromCore.Items {
-
onuOperStatusFromCore := onuDeviceFromCore.OperStatus
onuConnectStatusFromCore := onuDeviceFromCore.ConnectStatus
intfID := plt.PortNoToIntfID(onuDeviceFromCore.ParentPortNo, voltha.Port_PON_OLT)
@@ -851,7 +849,6 @@
onuDeviceFromOlt, err := dh.getOnuInfo(ctx, intfID, &onuID)
if err != nil {
logger.Error(ctx, "unable to get onu object from olt agent", log.Fields{"eeror": err})
-
} else {
onuOperStatusFromOlt := onuDeviceFromOlt.GetState()
onuLosFromOlt := onuDeviceFromOlt.GetLosi()
@@ -861,18 +858,15 @@
dh.putOnuIndicationToChannel(ctx, OnuIndication, intfID)
case onuLosFromOlt.String() == "ON" && onuConnectStatusFromCore.String() == "REACHABLE":
- OnuIndication := generateOnuIndication(intfID, onuID, "down", "down") //check bal cli login notepad
+ OnuIndication := generateOnuIndication(intfID, onuID, "down", "down") // check bal cli login notepad
alarmInd := generateOnuAlarmIndication(intfID, onuID, "on")
raisedTs := time.Now().Unix()
go dh.eventMgr.ProcessEvents(ctx, alarmInd, dh.device.Id, raisedTs)
dh.putOnuIndicationToChannel(ctx, OnuIndication, intfID)
}
-
}
-
}
-
return nil
}
@@ -883,9 +877,7 @@
})
if err != nil {
logger.Error(ctx, "unable to fetch ports from core", log.Fields{"eeror": err})
-
return err
-
}
for _, portFromCore := range portsFromCore.Items {
portNum := portFromCore.GetPortNo()
@@ -907,7 +899,6 @@
ponLosindication := generatePonLosAlarmIndication(intfID, "on")
raisedTs := time.Now().Unix()
go dh.eventMgr.ProcessEvents(ctx, ponLosindication, dh.device.Id, raisedTs)
-
}
switch {
case portStateFromOlt.String() == "ACTIVE_WORKING" && portOperStatusFromCore.String() != "ACTIVE":
@@ -934,13 +925,9 @@
"portOperStatusFromCore": portOperStatusFromCore.String(),
"device-id": dh.device.Id,
"port": portNum})
-
}
-
}
-
}
-
return nil
}
@@ -978,17 +965,15 @@
dh.stopIndications <- true
}
dh.lockDevice.RUnlock()
- if err := dh.cleanupDeviceResources(ctx); err != nil {
+ if err = dh.cleanupDeviceResources(ctx); err != nil {
logger.Error(ctx, "unable to clean up device resources", log.Fields{"error": err})
return fmt.Errorf("cleanup device resources failed: %w", err)
}
- if err := dh.initializeDeviceHandlerModules(ctx); err != nil {
+ if err = dh.initializeDeviceHandlerModules(ctx); err != nil {
return olterrors.NewErrAdapter("device-handler-initialization-failed", log.Fields{"device-id": dh.device.Id}, err).LogAt(log.ErrorLevel)
}
go startHeartbeatCheck(ctx, dh)
-
//dh.lockDevice.RUnlock()
-
} else if device.OperStatus == voltha.OperStatus_RECONCILING {
// Log the device's operational status if it's RECONCILING
logger.Info(ctx, "Device is being reconciled", log.Fields{
@@ -1036,7 +1021,7 @@
return olterrors.NewErrAdapter("device-state-update-failed", log.Fields{"device-id": dh.device.Id}, err)
}
- //Clear olt communication failure event
+ // Clear olt communication failure event
dh.device.ConnectStatus = voltha.ConnectStatus_REACHABLE
dh.device.OperStatus = voltha.OperStatus_ACTIVE
raisedTs := time.Now().Unix()
@@ -1057,7 +1042,7 @@
cloned := proto.Clone(device).(*voltha.Device)
- //Update the device oper state and connection status
+ // Update the device oper state and connection status
cloned.OperStatus = voltha.OperStatus_UNKNOWN
dh.lockDevice.Lock()
dh.device = cloned
@@ -1071,7 +1056,7 @@
return olterrors.NewErrAdapter("state-update-failed", log.Fields{"device-id": device.Id}, err)
}
- //get the child device for the parent device
+ // get the child device for the parent device
onuDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
return olterrors.NewErrAdapter("child-device-fetch-failed", log.Fields{"device-id": dh.device.Id}, err)
@@ -1097,7 +1082,7 @@
"onu-indicator": onuInd,
"device-type": onuDevice.Type,
"device-id": onuDevice.Id}, err).LogAt(log.ErrorLevel)
- //Do not return here and continue to process other ONUs
+ // Do not return here and continue to process other ONUs
} else {
logger.Debugw(ctx, "sending inter adapter down ind to onu success", log.Fields{"olt-device-id": device.Id, "onu-device-id": onuDevice.Id})
}
@@ -1280,7 +1265,7 @@
for i = 0; i < dh.totalPonPorts+1; i++ {
// Instantiate flow manager
if dh.flowMgr[i] = NewFlowManager(ctx, dh, dh.resourceMgr[i], dh.groupMgr, i); dh.flowMgr[i] == nil {
- //Continue to check the rest of the ports
+ // Continue to check the rest of the ports
logger.Errorw(ctx, "error-initializing-flow-manager-for-intf", log.Fields{"intfID": i, "device-id": dh.device.Id})
} else {
dh.resourceMgr[i].TechprofileRef = dh.flowMgr[i].techprofile
@@ -1294,12 +1279,12 @@
dh.portStats = NewOpenOltStatsMgr(ctx, dh)
return nil
-
}
func (dh *DeviceHandler) populateDeviceInfo(ctx context.Context) (*oop.DeviceInfo, error) {
var err error
var deviceInfo *oop.DeviceInfo
+ var genmac string
deviceInfo, err = dh.Client.GetDeviceInfo(log.WithSpanFromContext(context.Background(), ctx), new(oop.Empty))
@@ -1321,7 +1306,7 @@
if deviceInfo.DeviceId == "" {
logger.Warnw(ctx, "no-device-id-provided-using-host", log.Fields{"hostport": dh.device.GetHostAndPort()})
host := strings.Split(dh.device.GetHostAndPort(), ":")[0]
- genmac, err := generateMacFromHost(ctx, host)
+ genmac, err = generateMacFromHost(ctx, host)
if err != nil {
return nil, olterrors.NewErrAdapter("failed-to-generate-mac-host", log.Fields{"host": host}, err)
}
@@ -1442,7 +1427,6 @@
return nil, olterrors.NewErrNotFound("no-flow-manager-found", log.Fields{"intf-id": ifID, "parent-device-id": request.ParentDeviceId, "child-device-id": request.DeviceId}, nil).Log()
}
return dh.flowMgr[ifID].getTechProfileDownloadMessage(ctx, request.TpInstancePath, request.OnuId, request.DeviceId)
-
}
func (dh *DeviceHandler) omciIndication(ctx context.Context, omciInd *oop.OmciIndication) error {
@@ -1461,7 +1445,6 @@
onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
if onuInCache, ok := dh.onus.Load(onuKey); !ok {
-
logger.Debugw(ctx, "omci-indication-for-a-device-not-in-cache.", log.Fields{"intf-id": omciInd.IntfId, "onu-id": omciInd.OnuId, "device-id": dh.device.Id})
ponPort := plt.IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
@@ -1479,10 +1462,10 @@
deviceID = onuDevice.Id
proxyDeviceID = onuDevice.ProxyAddress.DeviceId
childAdapterEndpoint = onuDevice.AdapterEndpoint
- //if not exist in cache, then add to cache.
+ // if not exist in cache, then add to cache.
dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID, false, onuDevice.AdapterEndpoint))
} else {
- //found in cache
+ // found in cache
logger.Debugw(ctx, "omci-indication-for-a-device-in-cache.", log.Fields{"intf-id": omciInd.IntfId, "onu-id": omciInd.OnuId, "device-id": dh.device.Id})
deviceType = onuInCache.(*OnuDevice).deviceType
deviceID = onuInCache.(*OnuDevice).deviceID
@@ -1572,7 +1555,6 @@
onuSecOmciMsgList := omciMsgs.GetMessages()
for _, onuSecOmciMsg := range onuSecOmciMsgList {
-
var omciMessage *oop.OmciMsg
hexPkt := make([]byte, hex.EncodedLen(len(onuSecOmciMsg)))
hex.Encode(hexPkt, onuSecOmciMsg)
@@ -1683,7 +1665,6 @@
st, _ := status.FromError(err)
if st.Code() == codes.AlreadyExists {
logger.Debugw(ctx, "onu-activation-in-progress", log.Fields{"SerialNumber": serialNumber, "onu-id": onuID, "device-id": dh.device.Id})
-
} else {
return olterrors.NewErrAdapter("onu-activate-failed", log.Fields{"onu": Onu, "device-id": dh.device.Id}, err)
}
@@ -1704,7 +1685,7 @@
}
return true
})
- //Got the onu device from cache return
+ // Got the onu device from cache return
if InCacheOnuDev != nil {
logger.Debugw(ctx, "Got child device from cache", log.Fields{"onudev": InCacheOnuDev.serialNumber})
return InCacheOnuDev
@@ -1714,7 +1695,7 @@
SerialNumber: sn,
ParentPortNo: parentPortNo,
})
- //No device found in core return nil
+ // No device found in core return nil
if onuDevice == nil {
return nil
}
@@ -1733,7 +1714,7 @@
parentPortNo := plt.IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
tpInstExists := false
- //CheckOnuDevExistenceAtOnuDiscovery if true , a check will be made for the existence of the onu device. If the onu device
+ // CheckOnuDevExistenceAtOnuDiscovery if true , a check will be made for the existence of the onu device. If the onu device
// still exists , the onu discovery will be ignored, else a check for active techprofiles for ONU is checked.
if !dh.openOLT.CheckOnuDevExistenceAtOnuDiscovery {
onuDev := dh.getChildDevice(ctx, sn, parentPortNo)
@@ -1771,7 +1752,6 @@
logger.Infow(ctx, "No device present in core , continuing with discovery", log.Fields{"sn": sn})
return false, nil
-
}
// processDiscONULOSClear clears the LOS Alarm if it's needed
@@ -1834,7 +1814,7 @@
return error
}
if tpInstExists {
- //ignore the discovery if tpinstance is present.
+ // ignore the discovery if tpinstance is present.
logger.Debugw(ctx, "ignoring-onu-indication-as-tp-already-exists", log.Fields{"sn": sn})
return nil
}
@@ -1842,7 +1822,6 @@
// if the ONU existed, handle the LOS Alarm
if existing {
-
if inProcess.(bool) {
// if we're currently processing the ONU on a different thread, do nothing
logger.Warnw(ctx, "onu-sn-is-being-processed", log.Fields{"sn": sn})
@@ -1887,7 +1866,6 @@
// we need to create a new ChildDevice
ponintfid := onuDiscInd.GetIntfId()
onuID, error = dh.resourceMgr[ponintfid].GetONUID(ctx)
-
logger.Infow(ctx, "creating-new-onu-got-onu-id", log.Fields{"sn": sn, "onuId": onuID})
if error != nil {
@@ -1917,7 +1895,7 @@
"serial-number": sn}, error)
return error
}
- if error := dh.eventMgr.OnuDiscoveryIndication(ctx, onuDiscInd, dh.device.Id, onuDevice.Id, onuID, sn, time.Now().Unix()); error != nil {
+ if error = dh.eventMgr.OnuDiscoveryIndication(ctx, onuDiscInd, dh.device.Id, onuDevice.Id, onuID, sn, time.Now().Unix()); error != nil {
logger.Error(ctx, "discovery-indication-failed", log.Fields{"err": error})
error = olterrors.NewErrAdapter("discovery-indication-failed", log.Fields{
"onu-id": onuID,
@@ -1937,14 +1915,13 @@
error = dh.setupChildInterAdapterClient(subCtx, onuDevice.AdapterEndpoint)
cancel()
if error != nil {
-
error = olterrors.NewErrCommunication("no-connection-to-child-adapter", log.Fields{"device-id": onuDevice.Id}, error)
return error
}
// we can now use the existing ONU Id
onuID = onuDevice.ProxyAddress.OnuId
- //Insert the ONU into cache to use in OnuIndication.
+ // Insert the ONU into cache to use in OnuIndication.
//TODO: Do we need to remove this from the cache on ONU change, or wait for overwritten on next discovery.
logger.Debugw(ctx, "onu-discovery-indication-key-create",
log.Fields{"onu-id": onuID,
@@ -1964,7 +1941,6 @@
OperStatus: common.OperStatus_DISCOVERED,
ConnStatus: common.ConnectStatus_REACHABLE,
}); error != nil {
-
error = olterrors.NewErrAdapter("failed-to-update-device-state", log.Fields{
"device-id": onuDevice.Id,
"serial-number": sn}, error)
@@ -1973,7 +1949,6 @@
logger.Infow(ctx, "onu-discovered-reachable", log.Fields{"device-id": onuDevice.Id, "sn": sn})
if error = dh.activateONU(ctx, onuDiscInd.IntfId, int64(onuID), onuDiscInd.SerialNumber, sn); error != nil {
-
error = olterrors.NewErrAdapter("onu-activation-failed", log.Fields{
"device-id": onuDevice.Id,
"serial-number": sn}, error)
@@ -1983,7 +1958,6 @@
}
func (dh *DeviceHandler) onuIndication(ctx context.Context, onuInd *oop.OnuIndication) error {
-
ponPort := plt.IntfIDToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
var onuDevice *voltha.Device
var err error
@@ -1994,17 +1968,15 @@
"device-id": dh.device.Id})
onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.OnuId)
serialNumber := dh.stringifySerialNumber(onuInd.SerialNumber)
-
errFields := log.Fields{"device-id": dh.device.Id}
if onuInCache, ok := dh.onus.Load(onuKey); ok {
-
- //If ONU id is discovered before then use GetDevice to get onuDevice because it is cheaper.
+ // If ONU id is discovered before then use GetDevice to get onuDevice because it is cheaper.
foundInCache = true
errFields["onu-id"] = onuInCache.(*OnuDevice).deviceID
onuDevice, err = dh.getDeviceFromCore(ctx, onuInCache.(*OnuDevice).deviceID)
} else {
- //If ONU not found in adapter cache then we have to use GetChildDevice to get onuDevice
+ // If ONU not found in adapter cache then we have to use GetChildDevice to get onuDevice
if serialNumber != "" {
errFields["serial-number"] = serialNumber
} else {
@@ -2037,9 +2009,7 @@
}
if !foundInCache {
onuKey := dh.formOnuKey(onuInd.GetIntfId(), onuInd.GetOnuId())
-
dh.onus.Store(onuKey, NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuInd.GetOnuId(), onuInd.GetIntfId(), onuDevice.ProxyAddress.DeviceId, false, onuDevice.AdapterEndpoint))
-
}
if onuInd.OperState == "down" && onuInd.FailReason != oop.OnuIndication_ONU_ACTIVATION_FAIL_REASON_NONE {
if err := dh.eventMgr.onuActivationIndication(ctx, onuActivationFailEvent, onuInd, dh.device.Id, time.Now().Unix()); err != nil {
@@ -2192,7 +2162,6 @@
metrics := dh.metrics.GetSubscriberMetrics()
for _, m := range pmConfigs.Metrics {
metrics[m.Name].Enabled = m.Enabled
-
}
}
}
@@ -2209,7 +2178,7 @@
if flows != nil {
for _, flow := range flows.ToRemove.Items {
- intfID := dh.getIntfIDFromFlow(ctx, flow)
+ intfID := dh.getIntfIDFromFlow(flow)
logger.Debugw(ctx, "removing-flow",
log.Fields{"device-id": device.Id,
@@ -2226,7 +2195,7 @@
}
if err != nil {
if werr, ok := err.(olterrors.WrappedError); ok && status.Code(werr.Unwrap()) == codes.NotFound {
- //The flow we want to remove is not there, there is no need to throw an error
+ // The flow we want to remove is not there, there is no need to throw an error
logger.Warnw(ctx, "flow-to-remove-not-found",
log.Fields{
"ponIf": intfID,
@@ -2240,7 +2209,7 @@
}
for _, flow := range flows.ToAdd.Items {
- intfID := dh.getIntfIDFromFlow(ctx, flow)
+ intfID := dh.getIntfIDFromFlow(flow)
logger.Debugw(ctx, "adding-flow",
log.Fields{"device-id": device.Id,
"ponIf": intfID,
@@ -2305,7 +2274,6 @@
// UpdateFlowsIncrementally updates the device flow
func (dh *DeviceHandler) UpdateFlowsIncrementally(ctx context.Context, device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *of.FlowMetadata) error {
-
var errorsList []error
if dh.getDeviceDeletionInProgressFlag() {
@@ -2350,7 +2318,7 @@
dh.onus = sync.Map{}
dh.lockDevice.RLock()
- //stopping the stats collector
+ // stopping the stats collector
if dh.isCollectorActive {
dh.stopCollector <- true
}
@@ -2358,7 +2326,7 @@
go dh.notifyChildDevices(ctx, "unreachable")
cloned := proto.Clone(device).(*voltha.Device)
- //Update device Admin state
+ // Update device Admin state
dh.device = cloned
// Update the all pon ports state on that device to disable and NNI remains active as NNI remains active in openolt agent.
@@ -2378,7 +2346,7 @@
onuInd := oop.OnuIndication{}
onuInd.OperState = state
- //get the child device for the parent device
+ // get the child device for the parent device
onuDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil {
logger.Errorw(ctx, "failed-to-get-child-devices-information", log.Fields{"device-id": dh.device.Id, "err": err})
@@ -2393,10 +2361,8 @@
logger.Errorw(ctx, "failed-to-send-inter-adapter-message", log.Fields{"OnuInd": onuInd,
"From Adapter": dh.openOLT.config.AdapterEndpoint, "DeviceType": onuDevice.Type, "device-id": onuDevice.Id})
}
-
}
}
-
}
// ReenableDevice re-enables the olt device after disable
@@ -2413,9 +2379,7 @@
}
} else {
return olterrors.NewErrAdapter("olt-reenable-failed", log.Fields{"device-id": dh.device.Id}, errors.New("nil device client"))
-
}
-
logger.Debug(ctx, "olt-reenabled")
// Update the all ports state on that device to enable
@@ -2429,10 +2393,10 @@
}
}
if retError == nil {
- //Update the device oper status as ACTIVE
+ // Update the device oper status as ACTIVE
device.OperStatus = voltha.OperStatus_ACTIVE
} else {
- //Update the device oper status as FAILED
+ // Update the device oper status as FAILED
device.OperStatus = voltha.OperStatus_FAILED
}
dh.device = device
@@ -2510,7 +2474,6 @@
*/
dh.setDeviceDeletionInProgressFlag(true)
-
dh.StopAllFlowRoutines(ctx)
dh.lockDevice.RLock()
@@ -2536,13 +2499,13 @@
}
dh.removeOnuIndicationChannels(ctx)
- //Reset the state
+ // Reset the state
if dh.Client != nil {
- if _, err := dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {
+ if _, err = dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {
go func() {
failureReason := fmt.Sprintf("Failed to reboot during device delete request with error: %s", err.Error())
- if err = dh.eventMgr.oltRebootFailedEvent(ctx, dh.device.Id, failureReason, time.Now().Unix()); err != nil {
- logger.Errorw(ctx, "on-olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err})
+ if err1 := dh.eventMgr.oltRebootFailedEvent(ctx, dh.device.Id, failureReason, time.Now().Unix()); err1 != nil {
+ logger.Errorw(ctx, "on-olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err1})
}
}()
logger.Errorw(ctx, "olt-reboot-failed", log.Fields{"device-id": dh.device.Id, "err": err})
@@ -2641,7 +2604,6 @@
}
} else {
return olterrors.NewErrAdapter("olt-reboot-failed", log.Fields{"device-id": dh.device.Id}, errors.New("nil device client"))
-
}
logger.Debugw(ctx, "rebooted-device-successfully", log.Fields{"device-id": device.Id})
@@ -2832,7 +2794,6 @@
}
func startHeartbeatCheck(ctx context.Context, dh *DeviceHandler) {
-
defer func() {
dh.lockDevice.Lock()
dh.isHeartbeatCheckActive = false
@@ -2887,14 +2848,12 @@
}()
}
dh.lockDevice.RUnlock()
-
} else {
logger.Warn(ctx, "Heartbeat signature changed, OLT is rebooted. Cleaningup resources.")
dh.updateHeartbeatSignature(ctx, heartBeat.HeartbeatSignature)
dh.heartbeatSignature = heartBeat.HeartbeatSignature
go dh.updateStateRebooted(ctx)
}
-
}
cancel()
case <-dh.stopHeartbeatCheck:
@@ -2937,7 +2896,7 @@
}
*/
- //raise olt communication failure event
+ // raise olt communication failure event
raisedTs := time.Now().Unix()
cloned := proto.Clone(device).(*voltha.Device)
cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
@@ -2963,7 +2922,6 @@
}
dh.lockDevice.RUnlock()
dh.transitionMap.Handle(ctx, DeviceInit)
-
}
}
@@ -2979,7 +2937,7 @@
// Immediately return, otherwise accessing a null 'device' struct would cause panic
return
}
- //Starting the cleanup process
+ // Starting the cleanup process
dh.setDeviceDeletionInProgressFlag(true)
logger.Warnw(ctx, "update-state-rebooted", log.Fields{"device-id": dh.device.Id, "connect-status": device.ConnectStatus,
@@ -3031,10 +2989,9 @@
dh.StopAllFlowRoutines(ctx)
- //reset adapter reconcile flag
+ // reset adapter reconcile flag
dh.adapterPreviouslyConnected = false
for {
-
childDevices, err := dh.getChildDevicesFromCore(ctx, dh.device.Id)
if err != nil || childDevices == nil {
logger.Errorw(ctx, "Failed to get child devices from core", log.Fields{"deviceID": dh.device.Id})
@@ -3047,13 +3004,11 @@
logger.Warn(ctx, "Not all child devices are cleared, continuing to wait")
time.Sleep(5 * time.Second)
}
-
}
- //Cleanup completed , reset the flag
+ // Cleanup completed , reset the flag
dh.setDeviceDeletionInProgressFlag(false)
logger.Infow(ctx, "cleanup complete after reboot , moving to init", log.Fields{"deviceID": device.Id})
dh.transitionMap.Handle(ctx, DeviceInit)
-
}
// EnablePort to enable Pon interface
@@ -3186,7 +3141,7 @@
}
onu := &oop.Onu{IntfId: intfID, OnuId: onuID, SerialNumber: sn}
- //clear PON resources associated with ONU
+ // clear PON resources associated with ONU
onuGem, err := dh.resourceMgr[intfID].GetOnuGemInfo(ctx, onuID)
if err != nil || onuGem == nil || onuGem.OnuID != onuID {
logger.Warnw(ctx, "failed-to-get-onu-info-for-pon-port", log.Fields{
@@ -3202,8 +3157,8 @@
for _, gem := range onuGem.GemPorts {
if flowIDs, err := dh.resourceMgr[intfID].GetFlowIDsForGem(ctx, gem); err == nil {
for _, flowID := range flowIDs {
- //multiple gem port can have the same flow id
- //it is better to send only one flowRemove request to the agent
+ // multiple gem port can have the same flow id
+ // it is better to send only one flowRemove request to the agent
var alreadyRemoved bool
for _, removedFlowID := range removedFlows {
if removedFlowID == flowID {
@@ -3232,10 +3187,9 @@
"onu-device": onu,
"onu-gem": onuGem,
"err": err})
- //Not returning error on cleanup.
+ // Not returning error on cleanup.
}
logger.Debugw(ctx, "removed-onu-gem-info", log.Fields{"intf": intfID, "onu-device": onu, "onugem": onuGem})
-
}
dh.resourceMgr[intfID].FreeonuID(ctx, []uint32{onuID})
dh.onus.Delete(onuKey)
@@ -3364,7 +3318,7 @@
return resp, nil
}
-func (dh *DeviceHandler) getIntfIDFromFlow(ctx context.Context, flow *of.OfpFlowStats) uint32 {
+func (dh *DeviceHandler) getIntfIDFromFlow(flow *of.OfpFlowStats) uint32 {
// Default to NNI
var intfID = dh.totalPonPorts
inPort, outPort := getPorts(flow)
@@ -3374,15 +3328,15 @@
return intfID
}
-func (dh *DeviceHandler) getOnuIndicationChannel(ctx context.Context, intfID uint32) chan onuIndicationMsg {
+func (dh *DeviceHandler) getOnuIndicationChannel(intfID uint32) chan onuIndicationMsg {
dh.perPonOnuIndicationChannelLock.Lock()
if ch, ok := dh.perPonOnuIndicationChannel[intfID]; ok {
dh.perPonOnuIndicationChannelLock.Unlock()
return ch.indicationChannel
}
channels := onuIndicationChannels{
- //We create a buffered channel here to avoid calling function to be blocked
- //in case of multiple indications from the ONUs,
+ // We create a buffered channel here to avoid calling function to be blocked
+ // in case of multiple indications from the ONUs,
//especially in the case where indications are buffered in OLT.
indicationChannel: make(chan onuIndicationMsg, 500),
stopChannel: make(chan struct{}),
@@ -3391,7 +3345,6 @@
dh.perPonOnuIndicationChannelLock.Unlock()
go dh.onuIndicationsRoutine(&channels)
return channels.indicationChannel
-
}
func (dh *DeviceHandler) removeOnuIndicationChannels(ctx context.Context) {
@@ -3411,7 +3364,7 @@
}
logger.Debugw(ctx, "put-onu-indication-to-channel", log.Fields{"indication": indication, "intfID": intfID})
// Send the onuIndication on the ONU channel
- dh.getOnuIndicationChannel(ctx, intfID) <- ind
+ dh.getOnuIndicationChannel(intfID) <- ind
}
func (dh *DeviceHandler) onuIndicationsRoutine(onuChannels *onuIndicationChannels) {
@@ -3582,8 +3535,8 @@
logger.Debug(ctx, "stopped all mcast handler routines")
}
+// nolint: unparam
func (dh *DeviceHandler) getOltPortCounters(ctx context.Context, oltPortInfo *extension.GetOltPortCounters) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Response: &extension.GetValueResponse_PortCoutners{
@@ -3592,8 +3545,7 @@
},
}
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3604,14 +3556,14 @@
if oltPortInfo.PortType != extension.GetOltPortCounters_Port_ETHERNET_NNI &&
oltPortInfo.PortType != extension.GetOltPortCounters_Port_PON_OLT {
- //send error response
+ // send error response
logger.Debugw(ctx, "getOltPortCounters invalid portType", log.Fields{"oltPortInfo": oltPortInfo.PortType})
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_PORT_TYPE)
}
statIndChn := make(chan bool, 1)
dh.portStats.RegisterForStatIndication(ctx, portStatsType, statIndChn, oltPortInfo.PortNo, oltPortInfo.PortType)
defer dh.portStats.DeRegisterFromStatIndication(ctx, portStatsType, statIndChn)
- //request openOlt agent to send the the port statistics indication
+ // request openOlt agent to send the the port statistics indication
go func() {
_, err := dh.Client.CollectStatistics(ctx, new(oop.Empty))
@@ -3621,7 +3573,7 @@
}()
select {
case <-statIndChn:
- //indication received for ports stats
+ // indication received for ports stats
logger.Debugw(ctx, "getOltPortCounters recvd statIndChn", log.Fields{"oltPortInfo": oltPortInfo})
case <-time.After(oltPortInfoTimeout * time.Second):
logger.Debugw(ctx, "getOltPortCounters timeout happened", log.Fields{"oltPortInfo": oltPortInfo})
@@ -3631,24 +3583,23 @@
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_TIMEOUT)
}
if oltPortInfo.PortType == extension.GetOltPortCounters_Port_ETHERNET_NNI {
- //get nni stats
+ // get nni stats
intfID := plt.PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_ETHERNET_NNI)
logger.Debugw(ctx, "getOltPortCounters intfID ", log.Fields{"intfID": intfID})
cmnni := dh.portStats.collectNNIMetrics(intfID)
if cmnni == nil {
- //TODO define the error reason
+ // TODO define the error reason
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
dh.portStats.updateGetOltPortCountersResponse(ctx, &singleValResp, cmnni)
return &singleValResp
-
} else if oltPortInfo.PortType == extension.GetOltPortCounters_Port_PON_OLT {
// get pon stats
intfID := plt.PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_PON_OLT)
if val, ok := dh.activePorts.Load(intfID); ok && val == true {
cmpon := dh.portStats.collectPONMetrics(intfID)
if cmpon == nil {
- //TODO define the error reason
+ // TODO define the error reason
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
dh.portStats.updateGetOltPortCountersResponse(ctx, &singleValResp, cmpon)
@@ -3658,8 +3609,8 @@
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INTERNAL_ERROR)
}
+//nolint:unparam
func (dh *DeviceHandler) getOltOffloadStats(ctx context.Context, oltPortInfo *extension.GetOffloadedAppsStatisticsRequest) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: extension.GetValueResponse_OK,
@@ -3672,8 +3623,8 @@
return &singleValResp
}
+//nolint:unparam
func (dh *DeviceHandler) setOltOffload(ctx context.Context, congig *extension.AppOffloadConfig) *extension.SingleSetValueResponse {
-
singleValResp := extension.SingleSetValueResponse{
Response: &extension.SetValueResponse{
Status: extension.SetValueResponse_OK,
@@ -3683,8 +3634,8 @@
return &singleValResp
}
+//nolint:unparam
func (dh *DeviceHandler) setOnuOffload(ctx context.Context, config *extension.AppOffloadOnuConfig) *extension.SingleSetValueResponse {
-
singleValResp := extension.SingleSetValueResponse{
Response: &extension.SetValueResponse{
Status: extension.SetValueResponse_OK,
@@ -3695,7 +3646,6 @@
}
func (dh *DeviceHandler) getOnuPonCounters(ctx context.Context, onuPonInfo *extension.GetOnuCountersRequest) *extension.SingleGetValueResponse {
-
singleValResp := extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Response: &extension.GetValueResponse_OnuPonCounters{
@@ -3704,8 +3654,7 @@
},
}
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3728,33 +3677,27 @@
}
dh.portStats.updateGetOnuPonCountersResponse(ctx, &singleValResp, cmnni)
return &singleValResp
-
}
func (dh *DeviceHandler) getOnuInfo(ctx context.Context, intfID uint32, onuID *uint32) (*oop.OnuInfo, error) {
-
Onu := oop.Onu{IntfId: intfID, OnuId: *onuID}
OnuInfo, err := dh.Client.GetOnuInfo(ctx, &Onu)
if err != nil {
return nil, err
}
return OnuInfo, nil
-
}
func (dh *DeviceHandler) getIntfInfo(ctx context.Context, intfID uint32) (*oop.PonIntfInfo, error) {
-
Intf := oop.Interface{IntfId: intfID}
IntfInfo, err := dh.Client.GetPonInterfaceInfo(ctx, &Intf)
if err != nil {
return nil, err
}
return IntfInfo, nil
-
}
func (dh *DeviceHandler) getRxPower(ctx context.Context, rxPowerRequest *extension.GetRxPowerRequest) *extension.SingleGetValueResponse {
-
Onu := oop.Onu{IntfId: rxPowerRequest.IntfId, OnuId: rxPowerRequest.OnuId}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
@@ -3778,9 +3721,7 @@
}
func (dh *DeviceHandler) getPONRxPower(ctx context.Context, OltRxPowerRequest *extension.GetOltRxPowerRequest) *extension.SingleGetValueResponse {
-
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -3816,17 +3757,13 @@
}
if serialNumber != "" {
-
onuDev := dh.getChildDevice(ctx, serialNumber, (uint32)(portNumber))
if onuDev != nil {
-
Onu := oop.Onu{IntfId: uint32(portNumber), OnuId: onuDev.onuID}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
-
logger.Errorw(ctx, "error-while-getting-rx-power", log.Fields{"Onu": Onu, "err": err})
return generateSingleGetValueErrorResponse(err)
-
}
rxPowerValue := extension.RxPower{}
@@ -3836,24 +3773,18 @@
rxPowerValue.FailReason = rxPower.GetFailReason().String()
resp.Response.GetOltRxPower().RxPower = append(resp.Response.GetOltRxPower().RxPower, &rxPowerValue)
-
} else {
-
logger.Errorw(ctx, "getPONRxPower invalid Device", log.Fields{"portLabel": portLabel, "serialNumber": serialNumber})
return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_DEVICE)
}
-
} else {
-
dh.onus.Range(func(Onukey interface{}, onuInCache interface{}) bool {
if onuInCache.(*OnuDevice).intfID == (uint32)(portNumber) {
-
Onu := oop.Onu{IntfId: (uint32)(portNumber), OnuId: onuInCache.(*OnuDevice).onuID}
rxPower, err := dh.Client.GetPonRxPower(ctx, &Onu)
if err != nil {
logger.Errorw(ctx, "error-while-getting-rx-power, however considering to proceed further with other ONUs on PON", log.Fields{"Onu": Onu, "err": err})
} else {
-
rxPowerValue := extension.RxPower{}
rxPowerValue.OnuSn = onuInCache.(*OnuDevice).serialNumber
rxPowerValue.Status = rxPower.GetStatus()
@@ -3862,7 +3793,6 @@
resp.Response.GetOltRxPower().RxPower = append(resp.Response.GetOltRxPower().RxPower, &rxPowerValue)
}
-
}
logger.Infow(ctx, "getPONRxPower response ", log.Fields{"Response": resp})
return true
@@ -3872,9 +3802,9 @@
return &resp
}
+// nolint: unparam
func generateSingleGetValueErrorResponse(err error) *extension.SingleGetValueResponse {
- errResp := func(status extension.GetValueResponse_Status,
- reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
+ errResp := func(status extension.GetValueResponse_Status, reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse {
return &extension.SingleGetValueResponse{
Response: &extension.GetValueResponse{
Status: status,
@@ -4161,7 +4091,6 @@
}
func (dh *DeviceHandler) getChildAdapterServiceClient(endpoint string) (onu_inter_adapter_service.OnuInterAdapterServiceClient, error) {
-
// First check from cache
dh.lockChildAdapterClients.RLock()
if cgClient, ok := dh.childAdapterClients[endpoint]; ok {
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 2616e4f..834c560 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -304,7 +304,7 @@
}{
{"generateMacFromHost-1", args{host: "localhost"}, "00:00:7f:00:00:01", false},
{"generateMacFromHost-2", args{host: "10.10.10.10"}, "00:00:0a:0a:0a:0a", false},
- //{"generateMacFromHost-3", args{host: "google.com"}, "00:00:d8:3a:c8:8e", false},
+ // {"generateMacFromHost-3", args{host: "google.com"}, "00:00:d8:3a:c8:8e", false},
{"generateMacFromHost-4", args{host: "testing3"}, "", true},
}
for _, tt := range tests {
@@ -461,7 +461,6 @@
t.Errorf("GetportLabel() => want=(%v, %v) got=(%v, %v)",
tt.want, tt.errType, got, reflect.TypeOf(err))
}
-
})
}
}
@@ -721,9 +720,7 @@
case "sendProxiedMessage-6":
err := tt.devicehandler.ProxyOmciRequests(ctx, tt.args.omciMsg)
assert.Contains(t, err.Error(), "no deviceID")
-
}
-
})
}
}
@@ -822,7 +819,6 @@
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
-
if err := tt.devicehandler.RebootDevice(context.Background(), tt.args.device); (err != nil) != tt.wantErr {
t.Errorf("DeviceHandler.RebootDevice() error = %v, wantErr %v", err, tt.wantErr)
}
@@ -958,7 +954,7 @@
t.Run(tt.name, func(t *testing.T) {
_ = tt.devicehandler.addPort(context.Background(), tt.args.intfID, tt.args.portType, tt.args.state, tt.args.speedMbps)
- //Check if the correct state is stored
+ // Check if the correct state is stored
storedState, ok := tt.devicehandler.activePorts.Load(tt.args.intfID)
expectedState := tt.args.state == "up"
@@ -968,7 +964,7 @@
t.Errorf("Expected stored port state: %v, found: %v in test %v", expectedState, storedState, tt.name)
}
- //Check if the reported speed values are correct
+ // Check if the reported speed values are correct
ofpPort := makeOfpPort(tt.devicehandler.device.MacAddress, tt.args.speedMbps)
if ofpPort.Curr != tt.expectedCapacity ||
@@ -1016,7 +1012,6 @@
}
func TestDeviceHandler_handleOltIndication(t *testing.T) {
-
type args struct {
oltIndication *oop.OltIndication
}
@@ -1056,9 +1051,9 @@
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- //dh.doStateInit()
+ // dh.doStateInit()
// context.
- //dh.AdoptDevice(tt.args.device)
+ // dh.AdoptDevice(tt.args.device)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := tt.devicehandler.postInit(ctx); err != nil {
@@ -1105,7 +1100,6 @@
dh1.start(context.Background())
dh1.Stop(context.Background())
-
}
func TestDeviceHandler_PacketOut(t *testing.T) {
@@ -1128,7 +1122,7 @@
wantErr bool
}{
// TODO: Add test cases.
- //{"test1", args{egressPortNo: 0, packet: &ofp.OfpPacketOut{}}, true},
+ // {"test1", args{egressPortNo: 0, packet: &ofp.OfpPacketOut{}}, true},
{"PacketOut-1", dh1, args{egressPortNo: 0, packet: pktout}, false},
{"PacketOut-2", dh2, args{egressPortNo: 1, packet: pktout}, false},
{"PacketOut-3", dh2, args{egressPortNo: 4112, packet: pktout}, false},
@@ -1170,7 +1164,7 @@
if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
}
- tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
+ tt.devicehandler.stopCollector <- true // stop the stat collector invoked from doStateUp
})
}
}
@@ -1230,7 +1224,6 @@
}
func TestDeviceHandler_onuDiscIndication(t *testing.T) {
-
dh1 := newMockDeviceHandler()
dh1.discOnus = sync.Map{}
dh1.discOnus.Store("onu1", true)
@@ -1289,13 +1282,11 @@
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
-
_, err := tt.devicehandler.populateDeviceInfo(context.Background())
if (err != nil) != tt.wantErr {
t.Errorf("DeviceHandler.populateDeviceInfo() error = %v, wantErr %v", err, tt.wantErr)
return
}
-
})
}
}
@@ -1486,7 +1477,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
diff --git a/internal/pkg/core/olt_state_transitions.go b/internal/pkg/core/olt_state_transitions.go
index 613e4e4..b012a64 100644
--- a/internal/pkg/core/olt_state_transitions.go
+++ b/internal/pkg/core/olt_state_transitions.go
@@ -63,9 +63,9 @@
// Transition to store state machine
type Transition struct {
previousState []DeviceState
- currentState DeviceState
before []TransitionHandler
after []TransitionHandler
+ currentState DeviceState
}
// TransitionMap to store all the states and current device state
@@ -146,7 +146,6 @@
// Handle moves the state machine to next state based on the trigger and invokes the before and
// after handlers if the transition is a valid transition
func (tMap *TransitionMap) Handle(ctx context.Context, trigger Trigger) {
-
// Check whether the transtion is valid from current state
if !tMap.isValidTransition(trigger) {
logger.Errorw(ctx, "invalid-transition-triggered",
diff --git a/internal/pkg/core/olt_state_transitions_test.go b/internal/pkg/core/olt_state_transitions_test.go
index df4e8c6..4cb4218 100644
--- a/internal/pkg/core/olt_state_transitions_test.go
+++ b/internal/pkg/core/olt_state_transitions_test.go
@@ -18,10 +18,11 @@
import (
"context"
- "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
"reflect"
"testing"
"time"
+
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
)
/*
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 88e3efe..44ac313 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -44,22 +44,22 @@
// OpenOLT structure holds the OLT information
type OpenOLT struct {
+ eventProxy eventif.EventProxy
configManager *conf.ConfigManager
deviceHandlers map[string]*DeviceHandler
coreClient *vgrpc.Client
- eventProxy eventif.EventProxy
config *config.AdapterFlags
- numOnus int
+ exitChannel chan struct{}
KVStoreAddress string
KVStoreType string
- exitChannel chan struct{}
+ numOnus int
HeartbeatCheckInterval time.Duration
HeartbeatFailReportInterval time.Duration
GrpcTimeoutInterval time.Duration
+ rpcTimeout time.Duration
lockDeviceHandlersMap sync.RWMutex
enableONUStats bool
enableGemStats bool
- rpcTimeout time.Duration
CheckOnuDevExistenceAtOnuDiscovery bool
}
@@ -264,7 +264,6 @@
return &empty.Empty{}, nil
}
return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil)
-
}
// DeleteDevice deletes a device
@@ -333,7 +332,6 @@
return &empty.Empty{}, nil
}
return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": packet.DeviceId}, nil)
-
}
// EnablePort to Enable PON/NNI interface
@@ -507,7 +505,6 @@
return handler.GetTechProfileDownloadMessage(ctx, request)
}
return nil, olterrors.NewErrNotFound("no-device-handler", log.Fields{"parent-device-id": request.ParentDeviceId, "child-device-id": request.DeviceId}, nil).Log()
-
}
// GetHealthStatus is used by a OltAdapterService client to detect a connection
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index f17814e..a8bc359 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -342,6 +342,7 @@
logger.Debugw(ctx, "olt-los-event-sent-to-kafka", log.Fields{"intf-id": ponIntdID})
return nil
}
+
func (em *OpenOltEventMgr) oltRebootFailedEvent(ctx context.Context, deviceID string, reason string, raisedTs int64) error {
de := voltha.DeviceEvent{
Context: map[string]string{ContextOltFailureReason: "olt-reboot-failed"},
@@ -350,10 +351,10 @@
if err := em.eventProxy.SendDeviceEvent(ctx, &de, voltha.EventCategory_COMMUNICATION, voltha.EventSubCategory_OLT,
raisedTs); err != nil {
return olterrors.NewErrCommunication("send-olt-reboot-failed-event", log.Fields{
- "device-id": deviceID, "raised-ts": raisedTs}, err)
+ "device-id": deviceID, "raised-ts": raisedTs, "reason": reason}, err)
}
logger.Debugw(ctx, "olt-reboot-failed-event-sent-to-kafka", log.Fields{
- "device-id": deviceID, "raised-ts": raisedTs})
+ "device-id": deviceID, "raised-ts": raisedTs, "reason": reason})
return nil
}
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 6ad68ea..7389cb7 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -47,109 +47,109 @@
)
const (
- //IPProtoDhcp flow category
+ // IPProtoDhcp flow category
IPProtoDhcp = 17
- //IgmpProto proto value
+ // IgmpProto proto value
IgmpProto = 2
- //EapEthType eapethtype value
+ // EapEthType eapethtype value
EapEthType = 0x888e
- //LldpEthType lldp ethtype value
+ // LldpEthType lldp ethtype value
LldpEthType = 0x88cc
- //IPv4EthType IPv4 ethernet type value
+ // IPv4EthType IPv4 ethernet type value
IPv4EthType = 0x800
- //PPPoEDEthType PPPoE discovery ethernet type value
+ // PPPoEDEthType PPPoE discovery ethernet type value
PPPoEDEthType = 0x8863
- //ReservedVlan Transparent Vlan (Masked Vlan, VLAN_ANY in ONOS Flows)
+ // ReservedVlan Transparent Vlan (Masked Vlan, VLAN_ANY in ONOS Flows)
ReservedVlan = 4096
- //DefaultMgmtVlan default vlan value
+ // DefaultMgmtVlan default vlan value
DefaultMgmtVlan = 4091
// Openolt Flow
- //Upstream constant
+ // Upstream constant
Upstream = "upstream"
- //Downstream constant
+ // Downstream constant
Downstream = "downstream"
- //Multicast constant
+ // Multicast constant
Multicast = "multicast"
- //PacketTagType constant
+ // PacketTagType constant
PacketTagType = "pkt_tag_type"
- //Untagged constant
+ // Untagged constant
Untagged = "untagged"
- //SingleTag constant
+ // SingleTag constant
SingleTag = "single_tag"
- //DoubleTag constant
+ // DoubleTag constant
DoubleTag = "double_tag"
// classifierInfo
- //EthType constant
+ // EthType constant
EthType = "eth_type"
- //EthDst constant
+ // EthDst constant
EthDst = "eth_dst"
- //EthSrc constant
+ // EthSrc constant
EthSrc = "eth_src"
- //TPID constant
+ // TPID constant
TPID = "tpid"
- //IPProto constant
+ // IPProto constant
IPProto = "ip_proto"
- //InPort constant
+ // InPort constant
InPort = "in_port"
- //VlanVid constant
+ // VlanVid constant
VlanVid = "vlan_vid"
- //VlanPcp constant
+ // VlanPcp constant
VlanPcp = "vlan_pcp"
- //UDPDst constant
+ // UDPDst constant
UDPDst = "udp_dst"
- //UDPSrc constant
+ // UDPSrc constant
UDPSrc = "udp_src"
- //Ipv4Dst constant
+ // Ipv4Dst constant
Ipv4Dst = "ipv4_dst"
- //Ipv4Src constant
+ // Ipv4Src constant
Ipv4Src = "ipv4_src"
- //Metadata constant
+ // Metadata constant
Metadata = "metadata"
- //TunnelID constant
+ // TunnelID constant
TunnelID = "tunnel_id"
- //Output constant
+ // Output constant
Output = "output"
- //GroupID constant
+ // GroupID constant
GroupID = "group_id"
// Actions
- //PopVlan constant
+ // PopVlan constant
PopVlan = "pop_vlan"
- //PushVlan constant
+ // PushVlan constant
PushVlan = "push_vlan"
- //TrapToHost constant
+ // TrapToHost constant
TrapToHost = "trap_to_host"
- //MaxMeterBand constant
+ // MaxMeterBand constant
MaxMeterBand = 2
- //VlanPCPMask contant
+ // VlanPCPMask contant
VlanPCPMask = 0xFF
- //VlanvIDMask constant
+ // VlanvIDMask constant
VlanvIDMask = 0xFFF
- //IntfID constant
+ // IntfID constant
IntfID = "intfId"
- //OnuID constant
+ // OnuID constant
OnuID = "onuId"
- //UniID constant
+ // UniID constant
UniID = "uniId"
- //PortNo constant
+ // PortNo constant
PortNo = "portNo"
- //AllocID constant
+ // AllocID constant
AllocID = "allocId"
- //GemID constant
+ // GemID constant
GemID = "gemId"
- //NoneOnuID constant
+ // NoneOnuID constant
NoneOnuID = -1
- //NoneUniID constant
+ // NoneUniID constant
NoneUniID = -1
// Max number of flows that can be queued per ONU
@@ -160,30 +160,30 @@
)
type schedQueue struct {
+ tpInst interface{}
+ flowMetadata *ofp.FlowMetadata
direction tp_pb.Direction
intfID uint32
onuID uint32
uniID uint32
tpID uint32
uniPort uint32
- tpInst interface{}
meterID uint32
- flowMetadata *ofp.FlowMetadata
}
type flowContext struct {
+ classifier map[string]interface{}
+ action map[string]interface{}
+ logicalFlow *ofp.OfpFlowStats
+ pbitToGem map[uint32]uint32
+ gemToAes map[uint32]bool
intfID uint32
onuID uint32
uniID uint32
portNo uint32
- classifier map[string]interface{}
- action map[string]interface{}
- logicalFlow *ofp.OfpFlowStats
allocID uint32
gemPortID uint32
tpID uint32
- pbitToGem map[uint32]uint32
- gemToAes map[uint32]bool
}
// This control block is created per flow add/remove and pushed on the incomingFlows channel slice
@@ -192,28 +192,29 @@
// flow and processes it serially
type flowControlBlock struct {
ctx context.Context // Flow handler context
- addFlow bool // if true flow to be added, else removed
flow *ofp.OfpFlowStats // Flow message
flowMetadata *ofp.FlowMetadata // FlowMetadata that contains flow meter information. This can be nil for Flow remove
errChan *chan error // channel to report the Flow handling error
+ addFlow bool // if true flow to be added, else removed
}
// OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
type OpenOltFlowMgr struct {
- ponPortIdx uint32 // Pon Port this FlowManager is responsible for
techprofile tp.TechProfileIf
deviceHandler *DeviceHandler
grpMgr *OpenOltGroupMgr
resourceMgr *rsrcMgr.OpenOltResourceMgr
- packetInGemPort map[rsrcMgr.PacketInInfoKey]uint32 //packet in gem port local cache
- packetInGemPortLock sync.RWMutex
+ packetInGemPort map[rsrcMgr.PacketInInfoKey]uint32 // packet in gem port local cache
// Slice of channels. Each channel in slice, index by ONU ID, queues flows per ONU.
// A go routine per ONU, waits on the unique channel (indexed by ONU ID) for incoming flows (add/remove)
incomingFlows []chan flowControlBlock
stopFlowHandlerRoutine []chan bool
flowHandlerRoutineActive []bool
+ packetInGemPortLock sync.RWMutex
+
+ ponPortIdx uint32 // Pon Port this FlowManager is responsible for
}
// CloseKVClient closes open KV clients
@@ -257,7 +258,7 @@
go flowMgr.perOnuFlowHandlerRoutine(i, flowMgr.incomingFlows[i], flowMgr.stopFlowHandlerRoutine[i])
}
- //load interface to multicast queue map from kv store
+ // load interface to multicast queue map from kv store
flowMgr.grpMgr.LoadInterfaceToMulticastQueueMap(ctx)
logger.Info(ctx, "initialization-of-flow-manager-success")
return &flowMgr
@@ -354,7 +355,6 @@
// CreateSchedulerQueues creates traffic schedulers on the device with the given scheduler configuration and traffic shaping info
// nolint: gocyclo
func (f *OpenOltFlowMgr) CreateSchedulerQueues(ctx context.Context, sq schedQueue) error {
-
logger.Debugw(ctx, "CreateSchedulerQueues",
log.Fields{"dir": sq.direction,
"intf-id": sq.intfID,
@@ -516,7 +516,7 @@
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficQueues: trafficQueues,
TechProfileId: TrafficSched[0].TechProfileId}
- if _, err := f.deviceHandler.Client.CreateTrafficQueues(ctx, queues); err != nil {
+ if _, err = f.deviceHandler.Client.CreateTrafficQueues(ctx, queues); err != nil {
if len(queues.TrafficQueues) > 1 {
logger.Debug(ctx, "removing-queues-for-1tcont-multi-gem", log.Fields{"intfID": sq.intfID, "onuID": sq.onuID, "dir": sq.direction})
_, _ = f.deviceHandler.Client.RemoveTrafficQueues(ctx, queues)
@@ -583,9 +583,9 @@
if sq.direction == tp_pb.Direction_DOWNSTREAM {
multicastTrafficQueues := f.techprofile.GetMulticastTrafficQueues(ctx, sq.tpInst.(*tp_pb.TechProfileInstance))
if len(multicastTrafficQueues) > 0 {
- if _, present := f.grpMgr.GetInterfaceToMcastQueueMap(sq.intfID); !present { //assumed that there is only one queue per PON for the multicast service
- //the default queue with multicastQueuePerPonPort.Priority per a pon interface is used for multicast service
- //just put it in interfaceToMcastQueueMap to use for building group members
+ if _, present := f.grpMgr.GetInterfaceToMcastQueueMap(sq.intfID); !present { // assumed that there is only one queue per PON for the multicast service
+ // the default queue with multicastQueuePerPonPort.Priority per a pon interface is used for multicast service
+ // just put it in interfaceToMcastQueueMap to use for building group members
logger.Debugw(ctx, "multicast-traffic-queues", log.Fields{"device-id": f.deviceHandler.device.Id})
multicastQueuePerPonPort := multicastTrafficQueues[0]
val := &QueueInfoBrief{
@@ -593,7 +593,7 @@
servicePriority: multicastQueuePerPonPort.Priority,
}
f.grpMgr.UpdateInterfaceToMcastQueueMap(sq.intfID, val)
- //also store the queue info in kv store
+ // also store the queue info in kv store
if err := f.resourceMgr.AddMcastQueueForIntf(ctx, multicastQueuePerPonPort.GemportId, multicastQueuePerPonPort.Priority); err != nil {
logger.Errorw(ctx, "failed-to-add-mcast-queue", log.Fields{"err": err})
return err
@@ -694,7 +694,7 @@
// Delete the TCONT on the ONU.
uni := getUniPortPath(f.deviceHandler.device.Id, sq.intfID, int32(sq.onuID), int32(sq.uniID))
tpPath := f.getTPpath(ctx, uni, sq.tpID)
- if err := f.sendDeleteTcontToChild(ctx, sq.intfID, sq.onuID, sq.uniID, allocID, tpPath); err != nil {
+ if err = f.sendDeleteTcontToChild(ctx, sq.intfID, sq.onuID, sq.uniID, allocID, tpPath); err != nil {
logger.Errorw(ctx, "error-processing-delete-tcont-towards-onu",
log.Fields{
"intf": sq.intfID,
@@ -716,9 +716,7 @@
// We ignore any errors encountered in the process. The errors most likely are encountered when
// the schedulers and queues are already cleared for the given key.
func (f *OpenOltFlowMgr) forceRemoveSchedulerQueues(ctx context.Context, sq schedQueue) {
-
var schedCfg *tp_pb.SchedulerConfig
- var err error
logger.Infow(ctx, "removing-schedulers-and-queues-in-olt",
log.Fields{
"direction": sq.direction,
@@ -764,7 +762,6 @@
"tp-id": sq.tpID,
"device-id": f.deviceHandler.device.Id,
"err": err})
-
} else {
logger.Infow(ctx, "removed-traffic-queues-successfully", log.Fields{"device-id": f.deviceHandler.device.Id,
"direction": sq.direction,
@@ -777,7 +774,7 @@
}
// Remove traffic schedulers. Ignore any errors, just log them.
- if _, err = f.deviceHandler.Client.RemoveTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{
+ if _, err := f.deviceHandler.Client.RemoveTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{
IntfId: sq.intfID, OnuId: sq.onuID,
UniId: sq.uniID, PortNo: sq.uniPort,
TrafficScheds: TrafficSched}); err != nil {
@@ -938,7 +935,6 @@
}
func (f *OpenOltFlowMgr) storeTcontsGEMPortsIntoKVStore(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, allocID []uint32, gemPortIDs []uint32) {
-
logger.Debugw(ctx, "storing-allocated-tconts-and-gem-ports-into-KV-store",
log.Fields{
"intf-id": intfID,
@@ -1039,7 +1035,6 @@
}
func (f *OpenOltFlowMgr) addSymmetricDataPathFlow(ctx context.Context, flowContext *flowContext, direction string) error {
-
intfID := flowContext.intfID
onuID := flowContext.onuID
uniID := flowContext.uniID
@@ -1134,7 +1129,6 @@
}
func (f *OpenOltFlowMgr) addDHCPTrapFlow(ctx context.Context, flowContext *flowContext) error {
-
intfID := flowContext.intfID
onuID := flowContext.onuID
uniID := flowContext.uniID
@@ -1233,7 +1227,6 @@
// addUpstreamTrapFlow creates a trap-to-host flow
func (f *OpenOltFlowMgr) addUpstreamTrapFlow(ctx context.Context, flowContext *flowContext) error {
-
intfID := flowContext.intfID
onuID := flowContext.onuID
uniID := flowContext.uniID
@@ -1363,7 +1356,7 @@
log.Fields{"intf-id": intfID, "onu-id": onuID, "flow-id": logicalFlow.Id})
return err
}
- //Add Uplink EthType Flow
+ // Add Uplink EthType Flow
logger.Debugw(ctx, "creating-ul-ethType-flow",
log.Fields{
"ul_classifier": uplinkClassifier,
@@ -1454,7 +1447,7 @@
vid := uint32(metadata)
// Set the OVid or IVid classifier based on the whether OLT is using a transparent tag or not
// If OLT is using transparent tag mechanism, then it classifies whatever tag it sees to/from ONU which
- //is OVid from the perspective of the OLT. When OLT also places or pops the outer tag, then classifierInfo[Metadata]
+ // is OVid from the perspective of the OLT. When OLT also places or pops the outer tag, then classifierInfo[Metadata]
// becomes the IVid.
if classifier.OVid != 0 && classifier.OVid != ReservedVlan { // This is case when classifier.OVid is not set
if vid != ReservedVlan {
@@ -1492,6 +1485,8 @@
return &classifier, nil
}
+// nolint: unparam
+// TODO: Improvise the function & remove the unparam lint, currently it is always returning 'nil' as error.
func makeOpenOltActionField(actionInfo map[string]interface{}, classifierInfo map[string]interface{}) (*openoltpb2.Action, error) {
var actionCmd openoltpb2.ActionCmd
var action openoltpb2.Action
@@ -1559,7 +1554,6 @@
uniPortName := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
for _, tpID := range tpIDList {
-
// Force cleanup scheduler/queues -- start
uniPortNum := plt.MkUniPortNum(ctx, intfID, onuID, uniID)
uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
@@ -1605,7 +1599,6 @@
}
func (f *OpenOltFlowMgr) addFlowToDevice(ctx context.Context, logicalFlow *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) error {
-
var intfID uint32
/* For flows which trap out of the NNI, the AccessIntfId is invalid
(set to -1). In such cases, we need to refer to the NetworkIntfId .
@@ -1668,11 +1661,10 @@
"err": err,
"deviceFlow": deviceFlow,
"device-id": f.deviceHandler.device.Id})
- //Assume the flow is removed
+ // Assume the flow is removed
return nil
}
return olterrors.NewErrFlowOp("remove", deviceFlow.FlowId, log.Fields{"deviceFlow": deviceFlow}, err)
-
}
logger.Infow(ctx, "flow-removed-from-device-successfully", log.Fields{
"of-flow-id": ofFlowID,
@@ -1683,7 +1675,6 @@
}
func (f *OpenOltFlowMgr) addLLDPFlow(ctx context.Context, flow *ofp.OfpFlowStats, portNo uint32) error {
-
classifierInfo := make(map[string]interface{})
actionInfo := make(map[string]interface{})
@@ -1794,7 +1785,7 @@
"device-id": f.deviceHandler.device.Id}, err)
}
onuDev = NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuDevice.ProxyAddress.OnuId, onuDevice.ProxyAddress.ChannelId, onuDevice.ProxyAddress.DeviceId, false, onuDevice.AdapterEndpoint)
- //better to ad the device to cache here.
+ // better to ad the device to cache here.
f.deviceHandler.StoreOnuDevice(onuDev.(*OnuDevice))
} else {
logger.Debugw(ctx, "found-onu-in-cache",
@@ -1904,7 +1895,6 @@
"onu-id": onuDev.deviceID,
"proxyDeviceID": onuDev.proxyDeviceID,
"device-id": f.deviceHandler.device.Id}, err)
-
}
logger.Infow(ctx, "success-sending-del-tcont-to-onu-adapter",
log.Fields{
@@ -1918,7 +1908,6 @@
// nolint: gocyclo
func (f *OpenOltFlowMgr) clearResources(ctx context.Context, intfID uint32, onuID int32, uniID int32,
flowID uint64, portNum uint32, tpID uint32, sendDeleteGemRequest bool) error {
-
logger.Debugw(ctx, "clearing-resources", log.Fields{"intfID": intfID, "onuID": onuID, "uniID": uniID, "tpID": tpID})
uni := getUniPortPath(f.deviceHandler.device.Id, intfID, onuID, uniID)
@@ -2005,15 +1994,14 @@
"device-id": f.deviceHandler.device.Id,
"gemport-id": gemPortID})
}
-
}
// Remove queues at OLT in upstream and downstream direction
- schedQueue := schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum, tpInst: techprofileInst}
- if err := f.RemoveQueues(ctx, schedQueue); err != nil {
+ schedQ := schedQueue{tpInst: techprofileInst, direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum}
+ if err := f.RemoveQueues(ctx, schedQ); err != nil {
logger.Warn(ctx, err)
}
- schedQueue.direction = tp_pb.Direction_DOWNSTREAM
- if err := f.RemoveQueues(ctx, schedQueue); err != nil {
+ schedQ.direction = tp_pb.Direction_DOWNSTREAM
+ if err := f.RemoveQueues(ctx, schedQ); err != nil {
logger.Warn(ctx, err)
}
}
@@ -2021,12 +2009,12 @@
switch techprofileInst := techprofileInst.(type) {
case *tp_pb.TechProfileInstance:
// Proceed to free allocid and cleanup schedulers (US/DS) if no other references are found for this TP across all the UNIs on the ONU
- schedQueue := schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum, tpInst: techprofileInst}
- allocExists := f.isAllocUsedByAnotherUNI(ctx, schedQueue)
+ schedQ := schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum, tpInst: techprofileInst}
+ allocExists := f.isAllocUsedByAnotherUNI(ctx, schedQ)
if !allocExists {
// all alloc object references removed, remove upstream scheduler
if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "upstream", uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
- if err := f.RemoveScheduler(ctx, schedQueue); err != nil {
+ if err := f.RemoveScheduler(ctx, schedQ); err != nil {
logger.Warn(ctx, err)
}
}
@@ -2035,7 +2023,7 @@
} else {
// just remove meter reference for the upstream direction for the current pon/onu/uni
// The upstream scheduler, alloc id and meter-reference for the last remaining pon/onu/uni will be removed when no other alloc references that TP
- if err := f.removeMeterReference(ctx, "upstream", schedQueue); err != nil {
+ if err := f.removeMeterReference(ctx, "upstream", schedQ); err != nil {
return err
}
// setting 'freeFromResourcePool' to false in resourceMgr.FreeAllocID will only remove alloc-id data for the given pon/onu/uni
@@ -2044,9 +2032,9 @@
}
// Downstream scheduler removal is simple, just invoke RemoveScheduler without all the complex handling we do for the alloc object.
- schedQueue.direction = tp_pb.Direction_DOWNSTREAM
+ schedQ.direction = tp_pb.Direction_DOWNSTREAM
if KvStoreMeter, _ := f.resourceMgr.GetMeterInfoForOnu(ctx, "downstream", uint32(onuID), uint32(uniID), tpID); KvStoreMeter != nil {
- if err := f.RemoveScheduler(ctx, schedQueue); err != nil {
+ if err := f.RemoveScheduler(ctx, schedQ); err != nil {
logger.Warn(ctx, err)
}
}
@@ -2094,7 +2082,7 @@
f.resourceMgr.FreeGemPortID(ctx, uint32(onuID), uint32(uniID), gemPort.GemportId)
}
}
- //Delete the tp instance and the techprofileid for onu at the end
+ // Delete the tp instance and the techprofileid for onu at the end
if err := f.DeleteTechProfileInstance(ctx, intfID, uint32(onuID), uint32(uniID), "", tpID); err != nil {
logger.Warn(ctx, err)
}
@@ -2191,7 +2179,6 @@
// RemoveFlow removes the flow from the device
func (f *OpenOltFlowMgr) RemoveFlow(ctx context.Context, flow *ofp.OfpFlowStats) error {
-
logger.Infow(ctx, "removing-flow", log.Fields{"flow": *flow})
var direction string
actionInfo := make(map[string]interface{})
@@ -2482,13 +2469,13 @@
return olterrors.NewErrFlowOp("add", flow.Id, log.Fields{"flow": multicastFlow}, err)
}
logger.Info(ctx, "multicast-flow-added-to-device-successfully")
- //get cached group
+ // get cached group
if group, _, err := f.grpMgr.getFlowGroupFromKVStore(ctx, groupID, true); err == nil {
- //calling groupAdd to set group members after multicast flow creation
+ // calling groupAdd to set group members after multicast flow creation
if err := f.grpMgr.ModifyGroup(ctx, group); err != nil {
return olterrors.NewErrGroupOp("modify", groupID, log.Fields{"group": group}, err)
}
- //cached group can be removed now
+ // cached group can be removed now
if err := f.resourceMgr.RemoveFlowGroupFromKVStore(ctx, groupID, true); err != nil {
logger.Warnw(ctx, "failed-to-remove-flow-group", log.Fields{"group-id": groupID, "err": err})
}
@@ -2513,7 +2500,6 @@
// sendTPDownloadMsgToChild send payload
func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uni string, TpID uint32, tpInst tp_pb.TechProfileInstance) error {
-
onuDev, err := f.getOnuDevice(ctx, intfID, onuID)
if err != nil {
logger.Errorw(ctx, "couldnt-find-onu-child-device",
@@ -2601,7 +2587,7 @@
return gemPortID, nil
}
- //If gem is not found in cache try to get it from kv store, if found in kv store, update the cache and return.
+ // If gem is not found in cache try to get it from kv store, if found in kv store, update the cache and return.
gemPortID, err = f.resourceMgr.GetGemPortFromOnuPktIn(ctx, pktInkey)
if err == nil {
if gemPortID != 0 {
@@ -2619,7 +2605,6 @@
log.Fields{
"pktinkey": pktInkey,
"gem": gemPortID}, err)
-
}
func (f *OpenOltFlowMgr) addTrapFlowOnNNI(ctx context.Context, logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) error {
@@ -2872,8 +2857,7 @@
}
}
- flowContext := &flowContext{intfID, onuID, uniID, portNo, classifierInfo, actionInfo,
- flow, allocID, gemPortID, tpID, pbitToGem, gemToAes}
+ flowContext := &flowContext{classifierInfo, actionInfo, flow, pbitToGem, gemToAes, intfID, onuID, uniID, portNo, allocID, gemPortID, tpID}
if ipProto, ok := classifierInfo[IPProto]; ok {
if ipProto.(uint32) == IPProtoDhcp {
@@ -2884,14 +2868,13 @@
"onu-id": onuID,
"uni-id": uniID,
})
- //Adding DHCP upstream flow
+ // Adding DHCP upstream flow
if err := f.addDHCPTrapFlow(ctx, flowContext); err != nil {
logger.Warn(ctx, err)
logger.Errorw(ctx, "reverting-scheduler-and-queue-for-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "uni-id": uniID, "flow-id": flow.Id, "tp-id": tpID})
_ = f.clearResources(ctx, intfID, int32(onuID), int32(uniID), flow.Id, portNo, tpID, false)
return err
}
-
} else if ipProto.(uint32) == IgmpProto {
logger.Infow(ctx, "adding-us-igmp-flow",
log.Fields{
@@ -2937,7 +2920,7 @@
"onu-id": onuID,
"uni-id": uniID,
})
- //Adding PPPOED upstream flow
+ // Adding PPPOED upstream flow
if err := f.addUpstreamTrapFlow(ctx, flowContext); err != nil {
logger.Warn(ctx, err)
logger.Errorw(ctx, "reverting-scheduler-and-queue-for-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "uni-id": uniID, "flow-id": flow.Id, "tp-id": tpID})
@@ -2951,7 +2934,7 @@
"onu-id": onuID,
"uni-id": uniID,
})
- //Adding HSIA upstream flow
+ // Adding HSIA upstream flow
if err := f.addUpstreamDataPathFlow(ctx, flowContext); err != nil {
logger.Warn(ctx, err)
logger.Errorw(ctx, "reverting-scheduler-and-queue-for-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "uni-id": uniID, "flow-id": flow.Id, "tp-id": tpID})
@@ -2964,7 +2947,7 @@
"onu-id": onuID,
"uni-id": uniID,
})
- //Adding HSIA downstream flow
+ // Adding HSIA downstream flow
if err := f.addDownstreamDataPathFlow(ctx, flowContext); err != nil {
logger.Warn(ctx, err)
logger.Errorw(ctx, "reverting-scheduler-and-queue-for-onu", log.Fields{"intf-id": intfID, "onu-id": onuID, "uni-id": uniID, "flow-id": flow.Id, "tp-id": tpID})
@@ -3228,7 +3211,6 @@
// getNniIntfID gets nni intf id from the flow classifier/action
func getNniIntfID(ctx context.Context, classifier map[string]interface{}, action map[string]interface{}) (uint32, error) {
-
portType := plt.IntfIDToPortTypeName(classifier[InPort].(uint32))
if portType == voltha.Port_PON_OLT {
intfID, err := plt.IntfIDFromNniPortNum(ctx, action[Output].(uint32))
@@ -3309,7 +3291,7 @@
index = 14
}
priority := (packet[index] >> 5) & 0x7
- //13 bits composes vlanId value
+ // 13 bits composes vlanId value
vlan := ((uint16(packet[index]) << 8) & 0x0fff) | uint16(packet[index+1])
return vlan, priority, nil
}
@@ -3375,7 +3357,6 @@
// revertTechProfileInstance is called when CreateScheduler or CreateQueues request fails
func (f *OpenOltFlowMgr) revertTechProfileInstance(ctx context.Context, sq schedQueue) {
-
intfID := sq.intfID
onuID := sq.onuID
uniID := sq.uniID
diff --git a/internal/pkg/core/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
index 7e27afb..ca64bdd 100644
--- a/internal/pkg/core/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -85,30 +85,30 @@
wantErr bool
}{
// TODO: Add test cases.
- {"CreateSchedulerQueues-1", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 1, Upstream)}, false},
- {"CreateSchedulerQueues-2", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 1, Downstream)}, false},
- {"CreateSchedulerQueues-13", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 2, Upstream)}, false},
- {"CreateSchedulerQueues-14", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 2, Downstream)}, false},
- {"CreateSchedulerQueues-15", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 3, Upstream)}, false},
- {"CreateSchedulerQueues-16", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 3, Downstream)}, false},
- {"CreateSchedulerQueues-17", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 4, Upstream)}, false},
- {"CreateSchedulerQueues-18", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 4, Downstream)}, false},
- {"CreateSchedulerQueues-19", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 5, Upstream)}, false},
- {"CreateSchedulerQueues-20", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 5, Downstream)}, false},
+ {"CreateSchedulerQueues-1", schedQueue{tprofile, createFlowMetadata(tprofile, 1, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, false},
+ {"CreateSchedulerQueues-2", schedQueue{tprofile2, createFlowMetadata(tprofile2, 1, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, false},
+ {"CreateSchedulerQueues-13", schedQueue{tprofile, createFlowMetadata(tprofile, 2, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, false},
+ {"CreateSchedulerQueues-14", schedQueue{tprofile2, createFlowMetadata(tprofile2, 2, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, false},
+ {"CreateSchedulerQueues-15", schedQueue{tprofile, createFlowMetadata(tprofile, 3, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, false},
+ {"CreateSchedulerQueues-16", schedQueue{tprofile2, createFlowMetadata(tprofile2, 3, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, false},
+ {"CreateSchedulerQueues-17", schedQueue{tprofile, createFlowMetadata(tprofile, 4, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, false},
+ {"CreateSchedulerQueues-18", schedQueue{tprofile2, createFlowMetadata(tprofile2, 4, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, false},
+ {"CreateSchedulerQueues-19", schedQueue{tprofile, createFlowMetadata(tprofile, 5, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, false},
+ {"CreateSchedulerQueues-20", schedQueue{tprofile2, createFlowMetadata(tprofile2, 5, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, false},
- //Negative testcases
- {"CreateSchedulerQueues-1", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, createFlowMetadata(tprofile, 0, Upstream)}, true},
- {"CreateSchedulerQueues-2", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, createFlowMetadata(tprofile2, 0, Downstream)}, true},
- {"CreateSchedulerQueues-3", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 2, createFlowMetadata(tprofile, 2, Upstream)}, true},
- {"CreateSchedulerQueues-4", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 2, createFlowMetadata(tprofile2, 2, Downstream)}, true},
- {"CreateSchedulerQueues-5", schedQueue{tp_pb.Direction_UPSTREAM, 1, 2, 2, 64, 2, tprofile, 2, createFlowMetadata(tprofile, 3, Upstream)}, true},
- {"CreateSchedulerQueues-6", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 2, 2, 65, 2, tprofile2, 2, createFlowMetadata(tprofile2, 3, Downstream)}, true},
- {"CreateSchedulerQueues-7", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 1, &ofp.FlowMetadata{}}, true},
- {"CreateSchedulerQueues-8", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 0, &ofp.FlowMetadata{}}, true},
- {"CreateSchedulerQueues-9", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 1, &ofp.FlowMetadata{}}, true},
- {"CreateSchedulerQueues-10", schedQueue{tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, tprofile, 2, &ofp.FlowMetadata{}}, true},
- {"CreateSchedulerQueues-11", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 2, &ofp.FlowMetadata{}}, true},
- {"CreateSchedulerQueues-12", schedQueue{tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, tprofile2, 2, nil}, true},
+ // Negative testcases
+ {"CreateSchedulerQueues-1", schedQueue{tprofile, createFlowMetadata(tprofile, 0, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, true},
+ {"CreateSchedulerQueues-2", schedQueue{tprofile2, createFlowMetadata(tprofile2, 0, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, true},
+ {"CreateSchedulerQueues-3", schedQueue{tprofile, createFlowMetadata(tprofile, 2, Upstream), tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 2}, true},
+ {"CreateSchedulerQueues-4", schedQueue{tprofile2, createFlowMetadata(tprofile2, 2, Downstream), tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 2}, true},
+ {"CreateSchedulerQueues-5", schedQueue{tprofile, createFlowMetadata(tprofile, 3, Upstream), tp_pb.Direction_UPSTREAM, 1, 2, 2, 64, 2, 2}, true},
+ {"CreateSchedulerQueues-6", schedQueue{tprofile2, createFlowMetadata(tprofile2, 3, Downstream), tp_pb.Direction_DOWNSTREAM, 1, 2, 2, 65, 2, 2}, true},
+ {"CreateSchedulerQueues-7", schedQueue{tprofile, &ofp.FlowMetadata{}, tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 1}, true},
+ {"CreateSchedulerQueues-8", schedQueue{tprofile, &ofp.FlowMetadata{}, tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 0}, true},
+ {"CreateSchedulerQueues-9", schedQueue{tprofile2, &ofp.FlowMetadata{}, tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 1}, true},
+ {"CreateSchedulerQueues-10", schedQueue{tprofile, &ofp.FlowMetadata{}, tp_pb.Direction_UPSTREAM, 0, 1, 1, 64, 1, 2}, true},
+ {"CreateSchedulerQueues-11", schedQueue{tprofile2, &ofp.FlowMetadata{}, tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 2}, true},
+ {"CreateSchedulerQueues-12", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 0, 1, 1, 65, 1, 2}, true},
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@@ -126,26 +126,26 @@
bands := make([]*ofp.OfpMeterBandHeader, 0)
switch tcontType {
case 1:
- //tcont-type-1
+ // tcont-type-1
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 10000, BurstSize: 0, Data: &ofp.OfpMeterBandHeader_Drop{}})
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 10000, BurstSize: 0, Data: &ofp.OfpMeterBandHeader_Drop{}})
additionalBw = tp_pb.AdditionalBW_AdditionalBW_None
case 2:
- //tcont-type-2
+ // tcont-type-2
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 60000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 50000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
additionalBw = tp_pb.AdditionalBW_AdditionalBW_None
case 3:
- //tcont-type-3
+ // tcont-type-3
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 100000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 50000, BurstSize: 20000, Data: &ofp.OfpMeterBandHeader_Drop{}})
additionalBw = tp_pb.AdditionalBW_AdditionalBW_NA
case 4:
- //tcont-type-4
+ // tcont-type-4
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 200000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
additionalBw = tp_pb.AdditionalBW_AdditionalBW_BestEffort
case 5:
- //tcont-type-5
+ // tcont-type-5
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 50000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 100000, BurstSize: 10000, Data: &ofp.OfpMeterBandHeader_Drop{}})
bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 10000, BurstSize: 0, Data: &ofp.OfpMeterBandHeader_Drop{}})
@@ -180,16 +180,16 @@
tprofile2.DsScheduler.Direction = tp_pb.Direction_DOWNSTREAM
tprofile2.DsScheduler.AdditionalBw = tp_pb.AdditionalBW_AdditionalBW_None
tprofile2.DsScheduler.QSchedPolicy = tp_pb.SchedulingPolicy_WRR
- //defTprofile := &tp.DefaultTechProfile{}
+ // defTprofile := &tp.DefaultTechProfile{}
tests := []struct {
name string
schedQueue schedQueue
wantErr bool
}{
- {"RemoveScheduler-1", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 0, nil}, false},
- {"RemoveScheduler-2", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
- {"RemoveScheduler-3", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
- {"RemoveScheduler-4", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
+ {"RemoveScheduler-1", schedQueue{tprofile, nil, tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, 0}, false},
+ {"RemoveScheduler-2", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
+ {"RemoveScheduler-3", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
+ {"RemoveScheduler-4", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@@ -200,7 +200,6 @@
}
})
}
-
}
func TestOpenOltFlowMgr_RemoveQueues(t *testing.T) {
@@ -245,16 +244,16 @@
tprofile2.DownstreamGemPortAttributeList = make([]*tp_pb.GemPortAttributes, 0)
tprofile2.DownstreamGemPortAttributeList = append(tprofile.DownstreamGemPortAttributeList, &tp_pb.GemPortAttributes{GemportId: 1, PbitMap: "0b11111111"})
- //defTprofile := &tp.DefaultTechProfile{}
+ // defTprofile := &tp.DefaultTechProfile{}
tests := []struct {
name string
schedQueue schedQueue
wantErr bool
}{
- {"RemoveQueues-1", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 0, nil}, false},
- {"RemoveQueues-2", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
- {"RemoveQueues-3", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
- {"RemoveQueues-4", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
+ {"RemoveQueues-1", schedQueue{tprofile, nil, tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, 0}, false},
+ {"RemoveQueues-2", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
+ {"RemoveQueues-3", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
+ {"RemoveQueues-4", schedQueue{tprofile2, nil, tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, 0}, false},
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@@ -265,7 +264,6 @@
}
})
}
-
}
func TestOpenOltFlowMgr_createTcontGemports(t *testing.T) {
@@ -343,14 +341,14 @@
},
}
lldpofpstats, _ := fu.MkFlowStat(lldpFa)
- //lldpofpstats.Cookie = lldpofpstats.Id
+ // lldpofpstats.Cookie = lldpofpstats.Id
dhcpFa := &fu.FlowArgs{
KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
fu.UdpSrc(67),
- //fu.TunnelId(536870912),
+ // fu.TunnelId(536870912),
fu.IpProto(17),
},
Actions: []*ofp.OfpAction{
@@ -358,16 +356,16 @@
},
}
dhcpofpstats, _ := fu.MkFlowStat(dhcpFa)
- //dhcpofpstats.Cookie = dhcpofpstats.Id
+ // dhcpofpstats.Cookie = dhcpofpstats.Id
- //multicast flow
+ // multicast flow
multicastFa := &fu.FlowArgs{
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(16777216),
- fu.VlanVid(660), //vlan
- fu.Metadata_ofp(uint64(66)), //inner vlan
- fu.EthType(0x800), //ipv4
- fu.Ipv4Dst(3809869825), //227.22.0.1
+ fu.VlanVid(660), // vlan
+ fu.Metadata_ofp(uint64(66)), // inner vlan
+ fu.EthType(0x800), // ipv4
+ fu.Ipv4Dst(3809869825), // 227.22.0.1
},
Actions: []*ofp.OfpAction{
fu.Group(1),
@@ -429,7 +427,7 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(16777216),
fu.PushVlan(0x8100),
@@ -445,8 +443,8 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
- //fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
fu.PopVlan(),
fu.Output(536870912),
},
@@ -460,7 +458,7 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
fu.Output(65533),
},
@@ -510,7 +508,7 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(65535),
},
@@ -534,7 +532,7 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
fu.UdpSrc(67),
- //fu.TunnelId(536870912),
+ // fu.TunnelId(536870912),
fu.IpProto(17),
},
Actions: []*ofp.OfpAction{
@@ -546,7 +544,7 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(1),
fu.UdpSrc(67),
- //fu.TunnelId(536870912),
+ // fu.TunnelId(536870912),
fu.IpProto(2),
},
Actions: []*ofp.OfpAction{
@@ -580,7 +578,7 @@
fu.Ipv4Src(536870912),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(65535),
},
@@ -600,20 +598,20 @@
fu.Ipv4Src(536870912),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(65535),
},
KV: kw6,
}
- //multicast flow
+ // multicast flow
fa11 := &fu.FlowArgs{
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(16777216),
- fu.VlanVid(660), //vlan
- fu.Metadata_ofp(uint64(66)), //inner vlan
- fu.EthType(0x800), //ipv4
- fu.Ipv4Dst(3809869825), //227.22.0.1
+ fu.VlanVid(660), // vlan
+ fu.Metadata_ofp(uint64(66)), // inner vlan
+ fu.EthType(0x800), // ipv4
+ fu.Ipv4Dst(3809869825), // 227.22.0.1
},
Actions: []*ofp.OfpAction{
fu.Group(1),
@@ -654,13 +652,13 @@
{"AddFlow", args{flow: ofpstats3, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: ofpstats4, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: ofpstats5, flowMetadata: flowMetadata}},
- //{"AddFlow", args{flow: ofpstats6, flowMetadata: flowMetadata}},
+ // {"AddFlow", args{flow: ofpstats6, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: ofpstats7, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: ofpstats8, flowMetadata: flowMetadata}},
- //{"AddFlow", args{flow: ofpstats9, flowMetadata: flowMetadata}},
+ // {"AddFlow", args{flow: ofpstats9, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: igmpstats, flowMetadata: flowMetadata}},
- //{"AddFlow", args{flow: ofpstats10, flowMetadata: flowMetadata}},
- //ofpstats10
+ // {"AddFlow", args{flow: ofpstats10, flowMetadata: flowMetadata}},
+ // ofpstats10
{"AddFlow", args{flow: ofpstats11, flowMetadata: flowMetadata}},
{"AddFlow", args{flow: pppoedstats, flowMetadata: flowMetadata}},
}
@@ -695,7 +693,6 @@
defer cancel()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
-
got, err := flowMgr[tt.args.packetIn.IntfId].GetLogicalPortFromPacketIn(ctx, tt.args.packetIn)
if (err != nil) != tt.wantErr {
t.Errorf("OpenOltFlowMgr.GetLogicalPortFromPacketIn() error = %v, wantErr %v", err, tt.wantErr)
@@ -712,21 +709,21 @@
// Create fresh flowMgr instance
flowMgr = newMockFlowmgr()
- //untagged packet in hex string
+ // untagged packet in hex string
untaggedStr := "01005e000002000000000001080046c00020000040000102fa140a000001e00000029404000017000705e10000fa"
untagged, err := hex.DecodeString(untaggedStr)
if err != nil {
t.Error("Unable to parse hex string", err)
panic(err)
}
- //single-tagged packet in hex string. vlanID.pbit: 1.1
+ // single-tagged packet in hex string. vlanID.pbit: 1.1
singleTaggedStr := "01005e0000010025ba48172481002001080046c0002000004000010257deab140023e0000001940400001164ee9b0000000000000000000000000000"
singleTagged, err := hex.DecodeString(singleTaggedStr)
if err != nil {
t.Error("Unable to parse hex string", err)
panic(err)
}
- //double-tagged packet in hex string. vlanID.pbit: 210.0-0.0
+ // double-tagged packet in hex string. vlanID.pbit: 210.0-0.0
doubleTaggedStr := "01005e000016deadbeefba118100021081000000080046000028000000000102c5b87f000001e0000016940400002200f8030000000104000000e10000fa"
doubleTagged, err := hex.DecodeString(doubleTaggedStr)
if err != nil {
@@ -758,16 +755,15 @@
defer cancel()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
-
got, err := flowMgr[tt.args.intfID].GetPacketOutGemPortID(ctx, tt.args.intfID, tt.args.onuID, tt.args.portNum, tt.args.packet)
if tt.wantErr {
if err == nil {
- //error expected but got value
+ // error expected but got value
t.Errorf("OpenOltFlowMgr.GetPacketOutGemPortID() = %v, wantErr %v", got, tt.wantErr)
}
} else {
if err != nil {
- //error is not expected but got error
+ // error is not expected but got error
t.Errorf("OpenOltFlowMgr.GetPacketOutGemPortID() error = %v, wantErr %v", err, tt.wantErr)
return
}
@@ -823,7 +819,7 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(16777216),
fu.PushVlan(0x8100),
@@ -841,7 +837,7 @@
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(16777216),
fu.PushVlan(0x8100),
@@ -854,11 +850,11 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(536870912),
fu.Metadata_ofp(1),
- //fu.EthType(0x8100),
+ // fu.EthType(0x8100),
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
fu.Output(16777216),
fu.PushVlan(0x8100),
@@ -874,7 +870,7 @@
fu.VlanPcp(1),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
fu.Output(536870912),
fu.PopVlan(),
@@ -1137,21 +1133,21 @@
func TestOpenOltFlowMgr_TestMulticastFlowAndGroup(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- //create group
+ // create group
group := newGroup(2, []uint32{1})
err := flowMgr[0].grpMgr.AddGroup(ctx, group)
if err != nil {
t.Error("group-add failed", err)
return
}
- //create multicast flow
+ // create multicast flow
multicastFlowArgs := &fu.FlowArgs{
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(16777216),
- fu.VlanVid(660), //vlan
- fu.Metadata_ofp(uint64(66)), //inner vlan
- fu.EthType(0x800), //ipv4
- fu.Ipv4Dst(3809869825), //227.22.0.1
+ fu.VlanVid(660), // vlan
+ fu.Metadata_ofp(uint64(66)), // inner vlan
+ fu.EthType(0x800), // ipv4
+ fu.Ipv4Dst(3809869825), // 227.22.0.1
},
Actions: []*ofp.OfpAction{
fu.Group(1),
@@ -1165,21 +1161,21 @@
return
}
- //add bucket to the group
+ // add bucket to the group
group = newGroup(2, []uint32{1, 2})
err = flowMgr[0].grpMgr.ModifyGroup(ctx, group)
if err != nil {
t.Error("modify-group failed", err)
return
}
- //remove the multicast flow
+ // remove the multicast flow
err = flowMgr[0].RemoveFlow(ctx, ofpStats)
if err != nil {
t.Error("Multicast flow-remove failed", err)
return
}
- //remove the group
+ // remove the group
err = flowMgr[0].grpMgr.DeleteGroup(ctx, group)
if err != nil {
t.Error("delete-group failed", err)
@@ -1260,7 +1256,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
@@ -1279,7 +1275,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
@@ -1292,12 +1288,12 @@
MatchFields: []*ofp.OfpOxmOfbField{
fu.InPort(536870912),
fu.Metadata_ofp(1),
- //fu.EthType(0x8100),
+ // fu.EthType(0x8100),
fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
fu.Output(16777216),
fu.PushVlan(0x8100),
@@ -1315,7 +1311,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
fu.Output(536870912),
fu.PopVlan(),
@@ -1334,7 +1330,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 259)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
@@ -1353,7 +1349,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
@@ -1372,7 +1368,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
@@ -1391,7 +1387,7 @@
fu.TunnelId(256),
},
Actions: []*ofp.OfpAction{
- //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
+ // fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
fu.Output(2147483645),
fu.PushVlan(0x8100),
diff --git a/internal/pkg/core/openolt_groupmgr.go b/internal/pkg/core/openolt_groupmgr.go
index 670eeaf..6da8475 100644
--- a/internal/pkg/core/openolt_groupmgr.go
+++ b/internal/pkg/core/openolt_groupmgr.go
@@ -99,7 +99,7 @@
logger.Errorw(ctx, "delete-group-failed-on-dev", log.Fields{"groupToOlt": groupToOlt, "err": err})
return olterrors.NewErrAdapter("delete-group-operation-failed", log.Fields{"groupToOlt": groupToOlt}, err)
}
- //remove group from the store
+ // remove group from the store
if err := g.resourceMgr.RemoveFlowGroupFromKVStore(ctx, group.Desc.GroupId, false); err != nil {
return olterrors.NewErrPersistence("delete", "flow-group", uint64(group.Desc.GroupId), log.Fields{"group": group}, err)
}
@@ -114,7 +114,7 @@
return olterrors.NewErrInvalidValue(log.Fields{"group": group}, nil)
}
newGroup := g.buildGroup(ctx, group.Desc.GroupId, group.Desc.Buckets)
- //get existing members of the group
+ // get existing members of the group
val, groupExists, err := g.getFlowGroupFromKVStore(ctx, group.Desc.GroupId, false)
if err != nil {
return olterrors.NewErrNotFound("flow-group-in-kv-store", log.Fields{"groupId": group.Desc.GroupId}, err)
@@ -149,16 +149,16 @@
if len(membersToBeAdded) > 0 {
groupToOlt.Command = openoltpb2.Group_ADD_MEMBERS
groupToOlt.Members = membersToBeAdded
- //execute addMembers
+ // execute addMembers
errAdd = g.callGroupAddRemove(ctx, &groupToOlt)
}
if len(membersToBeRemoved) > 0 {
groupToOlt.Command = openoltpb2.Group_REMOVE_MEMBERS
groupToOlt.Members = membersToBeRemoved
- //execute removeMembers
+ // execute removeMembers
errRemoved = g.callGroupAddRemove(ctx, &groupToOlt)
}
- //save the modified group
+ // save the modified group
if errAdd == nil && errRemoved == nil {
if err := g.resourceMgr.AddFlowGroupToKVStore(ctx, group, false); err != nil {
return olterrors.NewErrPersistence("add", "flow-group", uint64(group.Desc.GroupId), log.Fields{"group": group}, err)
@@ -252,7 +252,7 @@
var actionCmd openoltpb2.ActionCmd
var action openoltpb2.Action
action.Cmd = &actionCmd
- //pop outer vlan
+ // pop outer vlan
action.Cmd.RemoveOuterTag = true
return &action
}
@@ -261,7 +261,7 @@
func (g *OpenOltGroupMgr) callGroupAddRemove(ctx context.Context, group *openoltpb2.Group) error {
if err := g.performGroupOperation(ctx, group); err != nil {
st, _ := status.FromError(err)
- //ignore already exists error code
+ // ignore already exists error code
if st.Code() != codes.AlreadyExists {
return olterrors.NewErrGroupOp("groupAddRemove", group.GroupId, log.Fields{"status": st}, err)
}
@@ -346,7 +346,7 @@
GemPortId: groupInfo.gemPortID,
Priority: groupInfo.servicePriority,
}
- //add member to the group
+ // add member to the group
return &member
}
logger.Warnf(ctx, "bucket-skipped-since-interface-2-gem-mapping-cannot-be-found", log.Fields{"ofBucket": ofBucket})
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index 4b592ec..b2bcfb4 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -230,7 +230,7 @@
{"delete_device-1", &fields{}, args{oo1, mockDevice()},
olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
{"delete_device-2", &fields{}, args{oo2, mockDevice()}, nil},
- {"delete_device-3", &fields{}, args{oo3, mockDevice()}, nil},
+ {"delete_device-3", &fields{}, args{oo3, mockDevice()}, errors.New("reboot failed")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -704,7 +704,6 @@
if _, err := oo.UpdatePmConfig(context.Background(), &ca.PmConfigsInfo{DeviceId: tt.args.device.Id, PmConfigs: tt.args.pmConfigs}); !reflect.DeepEqual(err, tt.wantErr) {
t.Errorf("Update_pm_config() error = %v, wantErr %v", err, tt.wantErr)
}
-
})
}
}
diff --git a/internal/pkg/core/statsmanager.go b/internal/pkg/core/statsmanager.go
old mode 100755
new mode 100644
index c9e15eb..1f9d7f9
--- a/internal/pkg/core/statsmanager.go
+++ b/internal/pkg/core/statsmanager.go
@@ -35,62 +35,62 @@
)
const (
- //NNIStats statType constant
+ // NNIStats statType constant
NNIStats = "NNIStats"
- //PONStats statType constant
+ // PONStats statType constant
PONStats = "PONStats"
- //ONUStats statType constant
+ // ONUStats statType constant
ONUStats = "ONUStats"
- //GEMStats statType constant
+ // GEMStats statType constant
GEMStats = "GEMStats"
- //RxBytes constant
+ // RxBytes constant
RxBytes = "RxBytes"
- //RxPackets constant
+ // RxPackets constant
RxPackets = "RxPackets"
- //TxBytes constant
+ // TxBytes constant
TxBytes = "TxBytes"
- //TxPackets constant
+ // TxPackets constant
TxPackets = "TxPackets"
- //FecCodewords constant
+ // FecCodewords constant
FecCodewords = "FecCodewords"
- //BipUnits constant
+ // BipUnits constant
BipUnits = "BipUnits"
- //BipErrors constant
+ // BipErrors constant
BipErrors = "BipErrors"
- //RxPloamsNonIdle constant
+ // RxPloamsNonIdle constant
RxPloamsNonIdle = "RxPloamsNonIdle"
- //RxPloamsError constant
+ // RxPloamsError constant
RxPloamsError = "RxPloamsError"
- //RxOmci constant
+ // RxOmci constant
RxOmci = "RxOmci"
- //RxOmciPacketsCrcError constant
+ // RxOmciPacketsCrcError constant
RxOmciPacketsCrcError = "RxOmciPacketsCrcError"
- //PositiveDrift constant
+ // PositiveDrift constant
PositiveDrift = "PositiveDrift"
- //NegativeDrift constant
+ // NegativeDrift constant
NegativeDrift = "NegativeDrift"
- //DelimiterMissDetection constant
+ // DelimiterMissDetection constant
DelimiterMissDetection = "DelimiterMissDetection"
- //FecCorrectedSymbols constant
+ // FecCorrectedSymbols constant
FecCorrectedSymbols = "FecCorrectedSymbols"
- //FecCodewordsCorrected constant
+ // FecCodewordsCorrected constant
FecCodewordsCorrected = "FecCodewordsCorrected"
- //fecCodewordsUncorrectable constant
+ // fecCodewordsUncorrectable constant
fecCodewordsUncorrectable = "fec_codewords_uncorrectable"
- //FecCorrectedUnits constant
+ // FecCorrectedUnits constant
FecCorrectedUnits = "FecCorrectedUnits"
- //XGEMKeyErrors constant
+ // XGEMKeyErrors constant
XGEMKeyErrors = "XGEMKeyErrors"
- //XGEMLoss constant
+ // XGEMLoss constant
XGEMLoss = "XGEMLOSS"
- //BerReported constant
+ // BerReported constant
BerReported = "BerReported"
- //LcdgErrors constant
+ // LcdgErrors constant
LcdgErrors = "LcdgErrors"
- //RdiErrors constant
+ // RdiErrors constant
RdiErrors = "RdiErrors"
- //Timestamp constant
+ // Timestamp constant
Timestamp = "Timestamp"
)
@@ -109,29 +109,12 @@
// PonPort representation
type PonPort struct {
- /*
- This is a highly reduced version taken from the adtran pon_port.
- TODO: Extend for use in the openolt adapter set.
- */
- /* MAX_ONUS_SUPPORTED = 256
- DEFAULT_ENABLED = False
- MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum)
-
- _MCAST_ONU_ID = 253
- _MCAST_ALLOC_BASE = 0x500
-
- _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate']
- _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number']
- */
- PONID uint32
- DeviceID string
- IntfID uint32
- PortNum uint32
- PortID uint32
- Label string
ONUs map[uint32]interface{}
ONUsByID map[uint32]interface{}
+ DeviceID string
+ Label string
+
RxBytes uint64
RxPackets uint64
RxUcastPackets uint64
@@ -146,11 +129,28 @@
TxErrorPackets uint64
RxCrcErrors uint64
BipErrors uint64
+ /*
+ This is a highly reduced version taken from the adtran pon_port.
+ TODO: Extend for use in the openolt adapter set.
+ */
+ /* MAX_ONUS_SUPPORTED = 256
+ DEFAULT_ENABLED = False
+ MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum)
+
+ _MCAST_ONU_ID = 253
+ _MCAST_ALLOC_BASE = 0x500
+
+ _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate']
+ _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number']
+ */
+ PONID uint32
+ IntfID uint32
+ PortNum uint32
+ PortID uint32
}
// NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum
func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort {
-
var PON PonPort
PON.PONID = PONID
@@ -202,16 +202,7 @@
// NniPort representation
type NniPort struct {
- /*
- Northbound network port, often Ethernet-based
-
- This is a highly reduced version taken from the adtran nni_port code set
- TODO: add functions to allow for port specific values and operations
- */
- PortNum uint32
- Name string
- LogicalPort uint32
- IntfID uint32
+ Name string
RxBytes uint64
RxPackets uint64
@@ -227,11 +218,19 @@
TxErrorPackets uint64
RxCrcErrors uint64
BipErrors uint64
+ /*
+ Northbound network port, often Ethernet-based
+
+ This is a highly reduced version taken from the adtran nni_port code set
+ TODO: add functions to allow for port specific values and operations
+ */
+ PortNum uint32
+ LogicalPort uint32
+ IntfID uint32
}
// NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID
func NewNniPort(PortNum uint32, IntfID uint32) *NniPort {
-
var NNI NniPort
NNI.PortNum = PortNum
@@ -266,18 +265,17 @@
// OpenOltStatisticsMgr structure
type OpenOltStatisticsMgr struct {
- Device *DeviceHandler
- NorthBoundPort map[uint32]*NniPort
- SouthBoundPort map[uint32]*PonPort
+ Device *DeviceHandler
+ NorthBoundPort map[uint32]*NniPort
+ SouthBoundPort map[uint32]*PonPort
+ statIndListners map[StatType]*list.List
// TODO PMMetrics Metrics
- //statIndListners is the list of requests to be notified when port and flow stats indication is received
+ // statIndListners is the list of requests to be notified when port and flow stats indication is received
statIndListnerMu sync.Mutex
- statIndListners map[StatType]*list.List
}
// NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr
func NewOpenOltStatsMgr(ctx context.Context, Dev *DeviceHandler) *OpenOltStatisticsMgr {
-
var StatMgr OpenOltStatisticsMgr
StatMgr.Device = Dev
@@ -347,8 +345,8 @@
:return:
*/
- //This builds a port object which is added to the
- //appropriate northbound or southbound values
+ // This builds a port object which is added to the
+ // appropriate northbound or southbound values
if IntfType == "nni" {
IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
nniID := plt.PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
@@ -375,7 +373,6 @@
// collectNNIMetrics will collect the nni port metrics
func (StatMgr *OpenOltStatisticsMgr) collectNNIMetrics(nniID uint32) map[string]float32 {
-
nnival := make(map[string]float32)
mutex.Lock()
cm := StatMgr.Device.portStats.NorthBoundPort[nniID]
@@ -416,7 +413,6 @@
// collectPONMetrics will collect the pon port metrics
func (StatMgr *OpenOltStatisticsMgr) collectPONMetrics(pID uint32) map[string]float32 {
-
ponval := make(map[string]float32)
mutex.Lock()
cm := StatMgr.Device.portStats.SouthBoundPort[pID]
@@ -520,7 +516,6 @@
if stats, err = StatMgr.Device.Client.GetOnuStatistics(context.Background(), onu); err == nil {
statValue := StatMgr.convertONUStats(stats)
return statValue
-
}
logger.Errorw(ctx, "error-while-getting-onu-stats-for-onu", log.Fields{"IntfID": intfID, "OnuID": onuID, "err": err})
return nil
@@ -620,8 +615,8 @@
func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) {
StatMgr.PortsStatisticsKpis(ctx, PortStats, NumPonPorts)
logger.Debugw(ctx, "received-port-stats-indication", log.Fields{"port-stats": PortStats})
- //Indicate that PortStatisticsIndication is handled
- //PortStats.IntfId is actually the port number
+ // Indicate that PortStatisticsIndication is handled
+ // PortStats.IntfId is actually the port number
StatMgr.processStatIndication(ctx, portStatsType, PortStats.IntfId)
// TODO send stats to core topic to the voltha kafka or a different kafka ?
}
@@ -629,19 +624,18 @@
// FlowStatisticsIndication to be implemented
func FlowStatisticsIndication(ctx context.Context, self, FlowStats *openolt.FlowStatistics) {
logger.Debugw(ctx, "flow-stats-collected", log.Fields{"flow-stats": FlowStats})
- //TODO send to kafka ?
+ // TODO send to kafka ?
}
// PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka
func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) {
-
/*map the port stats values into a dictionary
Create a kpoEvent and publish to Kafka
:param port_stats:
:return:
*/
- //var err error
+ // var err error
IntfID := PortStats.IntfId
if (plt.IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
@@ -653,7 +647,6 @@
*/
return
} else if plt.IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
-
var portNNIStat NniPort
portNNIStat.IntfID = IntfID
portNNIStat.PortNum = uint32(0)
@@ -673,7 +666,6 @@
logger.Debugw(ctx, "received-nni-stats", log.Fields{"nni-stats": StatMgr.NorthBoundPort})
}
for i := uint32(0); i < NumPonPorts; i++ {
-
if plt.IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
var portPonStat PonPort
portPonStat.IntfID = IntfID
@@ -695,7 +687,6 @@
logger.Debugw(ctx, "received-pon-stats-for-port", log.Fields{"port-pon-stats": portPonStat})
}
}
-
/*
Based upon the intf_id map to an nni port or a pon port
the intf_id is the key to the north or south bound collections
@@ -705,7 +696,7 @@
For prefixing the rule is currently to use the port number and not the intf_id
*/
- //FIXME : Just use first NNI for now
+ // FIXME : Just use first NNI for now
/* TODO should the data be marshaled before sending it ?
if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
//NNI port (just the first one)
@@ -718,11 +709,9 @@
logger.Error(ctx, "Error publishing statistics data")
}
*/
-
}
func (StatMgr *OpenOltStatisticsMgr) updateGetOltPortCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) {
-
metrics := singleValResp.GetResponse().GetPortCoutners()
metrics.TxBytes = uint64(stats["TxBytes"])
metrics.RxBytes = uint64(stats["RxBytes"])
@@ -753,7 +742,6 @@
StatMgr.statIndListnerMu.Lock()
StatMgr.statIndListners[t].PushBack(statInd)
StatMgr.statIndListnerMu.Unlock()
-
}
// DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
@@ -791,16 +779,13 @@
// message sent
statInd.chn <- true
deRegList = append(deRegList, e)
-
}
for _, e := range deRegList {
StatMgr.statIndListners[t].Remove(e)
}
-
}
func (StatMgr *OpenOltStatisticsMgr) updateGetOnuPonCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) {
-
metrics := singleValResp.GetResponse().GetOnuPonCounters()
metrics.IsIntfId = &extension.GetOnuCountersResponse_IntfId{
IntfId: uint32(stats[IntfID]),
diff --git a/internal/pkg/core/statsmanager_test.go b/internal/pkg/core/statsmanager_test.go
index 5e60af9..1cec548 100644
--- a/internal/pkg/core/statsmanager_test.go
+++ b/internal/pkg/core/statsmanager_test.go
@@ -56,7 +56,6 @@
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
-
StatMgr.PortStatisticsIndication(context.Background(), tt.args.PortStats, 16)
})
}