[VOL-1707]
Run golang SCA tools on the golang openolt adapter and fix the errors.
Used golangci-lint tool.
Makefile integrated with new target for running golangci-lint tool.
Change-Id: I8458d75bf4a997d6f93740acf10a03bf43c554c7
diff --git a/adaptercore/resourcemanager/resourcemanager.go b/adaptercore/resourcemanager/resourcemanager.go
index 524997a..799a733 100755
--- a/adaptercore/resourcemanager/resourcemanager.go
+++ b/adaptercore/resourcemanager/resourcemanager.go
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+//Package resourcemanager provides the utility for managing resources
package resourcemanager
import (
@@ -30,16 +31,22 @@
"github.com/opencord/voltha-protos/go/openolt"
)
-const KVSTORE_TIMEOUT = 5
-const BASE_PATH_KV_STORE = "service/voltha/openolt/{%s}" // service/voltha/openolt/<device_id>
+// KvstoreTimeout specifies the time out for KV Store Connection
+const KvstoreTimeout = 5
+// BasePathKvStore - service/voltha/openolt/<device_id>
+const BasePathKvStore = "service/voltha/openolt/{%s}"
+
+// FlowInfo holds the flow information
type FlowInfo struct {
Flow *openolt.Flow
FlowStoreCookie uint64
FlowCategory string
}
+
+// OpenOltResourceMgr holds resource related information as provided below for each field
type OpenOltResourceMgr struct {
- DeviceID string //OLT device id
+ DeviceID string // OLT device id
HostAndPort string // Host and port of the kv store to connect to
Args string // args
KVStore *model.Backend // backend kv store connection handle
@@ -51,7 +58,7 @@
ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
}
-func newKVClient(storeType string, address string, timeout uint32) (kvstore.Client, error) {
+func newKVClient(storeType, address string, timeout uint32) (kvstore.Client, error) {
log.Infow("kv-store-type", log.Fields{"store": storeType})
switch storeType {
case "consul":
@@ -62,44 +69,43 @@
return nil, errors.New("unsupported-kv-store")
}
-func SetKVClient(Backend string, Host string, Port int, DeviceID string) *model.Backend {
+// SetKVClient sets the KV client and return a kv backend
+func SetKVClient(backend string, Host string, Port int, DeviceID string) *model.Backend {
addr := Host + ":" + strconv.Itoa(Port)
// TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
// issue between kv store and backend , core is not calling NewBackend directly
- kvClient, err := newKVClient(Backend, addr, KVSTORE_TIMEOUT)
+ kvClient, err := newKVClient(backend, addr, KvstoreTimeout)
if err != nil {
log.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
return nil
}
kvbackend := &model.Backend{
Client: kvClient,
- StoreType: Backend,
+ StoreType: backend,
Host: Host,
Port: Port,
- Timeout: KVSTORE_TIMEOUT,
- PathPrefix: fmt.Sprintf(BASE_PATH_KV_STORE, DeviceID)}
+ Timeout: KvstoreTimeout,
+ PathPrefix: fmt.Sprintf(BasePathKvStore, DeviceID)}
return kvbackend
}
-func NewResourceMgr(DeviceID string, KVStoreHostPort string, KVStoreType string, DeviceType string, DevInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
-
- /* init a New resource maanger instance which in turn instantiates pon resource manager
- instances according to technology. Initializes the default resource ranges for all
- the reources.
- */
+// NewResourceMgr init a New resource maanger instance which in turn instantiates pon resource manager
+// instances according to technology. Initializes the default resource ranges for all
+// the resources.
+func NewResourceMgr(deviceID string, KVStoreHostPort string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
var ResourceMgr OpenOltResourceMgr
- log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, DeviceID)
+ log.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, deviceID)
ResourceMgr.HostAndPort = KVStoreHostPort
- ResourceMgr.DeviceType = DeviceType
- ResourceMgr.DevInfo = DevInfo
- IpPort := strings.Split(KVStoreHostPort, ":")
- ResourceMgr.Host = IpPort[0]
- ResourceMgr.Port, _ = strconv.Atoi(IpPort[1])
+ ResourceMgr.DeviceType = deviceType
+ ResourceMgr.DevInfo = devInfo
+ IPPort := strings.Split(KVStoreHostPort, ":")
+ ResourceMgr.Host = IPPort[0]
+ ResourceMgr.Port, _ = strconv.Atoi(IPPort[1])
- Backend := KVStoreType
+ Backend := kvStoreType
ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
- ResourceMgr.Port, DeviceID)
+ ResourceMgr.Port, deviceID)
if ResourceMgr.KVStore == nil {
log.Error("Failed to setup KV store")
}
@@ -114,11 +120,11 @@
the legacy global per-device informaiton. This, in theory, is temporary until
the legacy drivers are upgrade to support pool ranges.
*/
- if DevInfo.Ranges == nil {
+ if devInfo.Ranges == nil {
var ranges openolt.DeviceInfo_DeviceResourceRanges
- ranges.Technology = DevInfo.GetTechnology()
+ ranges.Technology = devInfo.GetTechnology()
- NumPONPorts := DevInfo.GetPonPorts()
+ NumPONPorts := devInfo.GetPonPorts()
var index uint32
for index = 0; index < NumPONPorts; index++ {
ranges.IntfIds = append(ranges.IntfIds, index)
@@ -126,76 +132,80 @@
var Pool openolt.DeviceInfo_DeviceResourceRanges_Pool
Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ONU_ID
- Pool.Start = DevInfo.OnuIdStart
- Pool.End = DevInfo.OnuIdEnd
+ Pool.Start = devInfo.OnuIdStart
+ Pool.End = devInfo.OnuIdEnd
Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
ranges.Pools = append(ranges.Pools, &Pool)
Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_ALLOC_ID
- Pool.Start = DevInfo.AllocIdStart
- Pool.End = DevInfo.AllocIdEnd
+ Pool.Start = devInfo.AllocIdStart
+ Pool.End = devInfo.AllocIdEnd
Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
ranges.Pools = append(ranges.Pools, &Pool)
Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_GEMPORT_ID
- Pool.Start = DevInfo.GemportIdStart
- Pool.End = DevInfo.GemportIdEnd
+ Pool.Start = devInfo.GemportIdStart
+ Pool.End = devInfo.GemportIdEnd
Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
ranges.Pools = append(ranges.Pools, &Pool)
Pool.Type = openolt.DeviceInfo_DeviceResourceRanges_Pool_FLOW_ID
- Pool.Start = DevInfo.FlowIdStart
- Pool.End = DevInfo.FlowIdEnd
+ Pool.Start = devInfo.FlowIdStart
+ Pool.End = devInfo.FlowIdEnd
Pool.Sharing = openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH
ranges.Pools = append(ranges.Pools, &Pool)
// Add to device info
- DevInfo.Ranges = append(DevInfo.Ranges, &ranges)
+ devInfo.Ranges = append(devInfo.Ranges, &ranges)
}
- //Create a separate Resource Manager instance for each range. This assumes that
+ // Create a separate Resource Manager instance for each range. This assumes that
// each technology is represented by only a single range
var GlobalPONRsrcMgr *ponrmgr.PONResourceManager
var err error
- for _, TechRange := range DevInfo.Ranges {
+ for _, TechRange := range devInfo.Ranges {
technology := TechRange.Technology
log.Debugf("Device info technology %s", technology)
Ranges[technology] = TechRange
- RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, DeviceType, DeviceID,
+ RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, deviceType, deviceID,
Backend, ResourceMgr.Host, ResourceMgr.Port)
if err != nil {
log.Errorf("Failed to create pon resource manager instacnce for technology %s", technology)
return nil
}
- //resource_mgrs_by_tech[technology] = resource_mgr
+ // resource_mgrs_by_tech[technology] = resource_mgr
if GlobalPONRsrcMgr == nil {
GlobalPONRsrcMgr = RsrcMgrsByTech[technology]
}
- for _, IntfId := range TechRange.IntfIds {
- ResourceMgr.ResourceMgrs[uint32(IntfId)] = RsrcMgrsByTech[technology]
+ for _, IntfID := range TechRange.IntfIds {
+ ResourceMgr.ResourceMgrs[uint32(IntfID)] = RsrcMgrsByTech[technology]
}
- //self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
+ // self.initialize_device_resource_range_and_pool(resource_mgr, global_resource_mgr, arange)
InitializeDeviceResourceRangeAndPool(RsrcMgrsByTech[technology], GlobalPONRsrcMgr,
- TechRange, DevInfo)
+ TechRange, devInfo)
}
// After we have initialized resource ranges, initialize the
// resource pools accordingly.
for _, PONRMgr := range RsrcMgrsByTech {
- PONRMgr.InitDeviceResourcePool()
+ _ = PONRMgr.InitDeviceResourcePool()
}
log.Info("Initialization of resource manager success!")
return &ResourceMgr
}
-func InitializeDeviceResourceRangeAndPool(PONRMgr *ponrmgr.PONResourceManager, GlobalPONRMgr *ponrmgr.PONResourceManager,
- TechRange *openolt.DeviceInfo_DeviceResourceRanges, DevInfo *openolt.DeviceInfo) {
+// InitializeDeviceResourceRangeAndPool initializes the resource range pool according to the sharing type, then apply
+// device specific information. If KV doesn't exist
+// or is broader than the device, the device's information will
+// dictate the range limits
+func InitializeDeviceResourceRangeAndPool(ponRMgr *ponrmgr.PONResourceManager, globalPONRMgr *ponrmgr.PONResourceManager,
+ techRange *openolt.DeviceInfo_DeviceResourceRanges, devInfo *openolt.DeviceInfo) {
// init the resource range pool according to the sharing type
- log.Debugf("Resource range pool init for technology %s", PONRMgr.Technology)
- //first load from KV profiles
- status := PONRMgr.InitResourceRangesFromKVStore()
- if status == false {
- log.Debugf("Failed to load resource ranges from KV store for tech %s", PONRMgr.Technology)
+ log.Debugf("Resource range pool init for technology %s", ponRMgr.Technology)
+ // first load from KV profiles
+ status := ponRMgr.InitResourceRangesFromKVStore()
+ if !status {
+ log.Debugf("Failed to load resource ranges from KV store for tech %s", ponRMgr.Technology)
}
/*
@@ -203,22 +213,22 @@
or is broader than the device, the device's informationw ill
dictate the range limits
*/
- log.Debugf("Using device info to init pon resource ranges for tech", PONRMgr.Technology)
+ log.Debugf("Using device info to init pon resource ranges for tech", ponRMgr.Technology)
- ONUIDStart := DevInfo.OnuIdStart
- ONUIDEnd := DevInfo.OnuIdEnd
+ ONUIDStart := devInfo.OnuIdStart
+ ONUIDEnd := devInfo.OnuIdEnd
ONUIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_DEDICATED_PER_INTF
ONUIDSharedPoolID := uint32(0)
- AllocIDStart := DevInfo.AllocIdStart
- AllocIDEnd := DevInfo.AllocIdEnd
+ AllocIDStart := devInfo.AllocIdStart
+ AllocIDEnd := devInfo.AllocIdEnd
AllocIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
AllocIDSharedPoolID := uint32(0)
- GEMPortIDStart := DevInfo.GemportIdStart
- GEMPortIDEnd := DevInfo.GemportIdEnd
+ GEMPortIDStart := devInfo.GemportIdStart
+ GEMPortIDEnd := devInfo.GemportIdEnd
GEMPortIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
GEMPortIDSharedPoolID := uint32(0)
- FlowIDStart := DevInfo.FlowIdStart
- FlowIDEnd := DevInfo.FlowIdEnd
+ FlowIDStart := devInfo.FlowIdStart
+ FlowIDEnd := devInfo.FlowIdEnd
FlowIDShared := openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH // TODO EdgeCore/BAL limitation
FlowIDSharedPoolID := uint32(0)
@@ -227,9 +237,9 @@
/*
* As a zero check is made against SharedPoolID to check whether the resources are shared across all intfs
- * if resources are shared accross interfaces then SharedPoolID is given a positive number.
+ * if resources are shared across interfaces then SharedPoolID is given a positive number.
*/
- for _, FirstIntfPoolID = range TechRange.IntfIds {
+ for _, FirstIntfPoolID = range techRange.IntfIds {
// skip the intf id 0
if FirstIntfPoolID == 0 {
continue
@@ -237,7 +247,7 @@
break
}
- for _, RangePool := range TechRange.Pools {
+ for _, RangePool := range techRange.Pools {
if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
SharedPoolID = FirstIntfPoolID
} else if RangePool.Sharing == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_SAME_TECH {
@@ -268,7 +278,7 @@
}
}
- log.Debugw("Device info init", log.Fields{"technology": TechRange.Technology,
+ log.Debugw("Device info init", log.Fields{"technology": techRange.Technology,
"onu_id_start": ONUIDStart, "onu_id_end": ONUIDEnd, "onu_id_shared_pool_id": ONUIDSharedPoolID,
"alloc_id_start": AllocIDStart, "alloc_id_end": AllocIDEnd,
"alloc_id_shared_pool_id": AllocIDSharedPoolID,
@@ -277,46 +287,47 @@
"flow_id_start": FlowIDStart,
"flow_id_end_idx": FlowIDEnd,
"flow_id_shared_pool_id": FlowIDSharedPoolID,
- "intf_ids": TechRange.IntfIds,
+ "intf_ids": techRange.IntfIds,
"uni_id_start": 0,
- "uni_id_end_idx":/*MaxUNIIDperONU()*/ 1})
+ "uni_id_end_idx": 1, /*MaxUNIIDperONU()*/
+ })
- PONRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
+ ponRMgr.InitDefaultPONResourceRanges(ONUIDStart, ONUIDEnd, ONUIDSharedPoolID,
AllocIDStart, AllocIDEnd, AllocIDSharedPoolID,
GEMPortIDStart, GEMPortIDEnd, GEMPortIDSharedPoolID,
FlowIDStart, FlowIDEnd, FlowIDSharedPoolID, 0, 1,
- DevInfo.PonPorts, TechRange.IntfIds)
+ devInfo.PonPorts, techRange.IntfIds)
// For global sharing, make sure to refresh both local and global resource manager instances' range
if ONUIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
- GlobalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+ globalPONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
"", 0, nil)
- PONRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
- "", 0, GlobalPONRMgr)
+ ponRMgr.UpdateRanges(ponrmgr.ONU_ID_START_IDX, ONUIDStart, ponrmgr.ONU_ID_END_IDX, ONUIDEnd,
+ "", 0, globalPONRMgr)
}
if AllocIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
- GlobalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+ globalPONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
"", 0, nil)
- PONRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
- "", 0, GlobalPONRMgr)
+ ponRMgr.UpdateRanges(ponrmgr.ALLOC_ID_START_IDX, AllocIDStart, ponrmgr.ALLOC_ID_END_IDX, AllocIDEnd,
+ "", 0, globalPONRMgr)
}
if GEMPortIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
- GlobalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+ globalPONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
"", 0, nil)
- PONRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
- "", 0, GlobalPONRMgr)
+ ponRMgr.UpdateRanges(ponrmgr.GEMPORT_ID_START_IDX, GEMPortIDStart, ponrmgr.GEMPORT_ID_END_IDX, GEMPortIDEnd,
+ "", 0, globalPONRMgr)
}
if FlowIDShared == openolt.DeviceInfo_DeviceResourceRanges_Pool_SHARED_BY_ALL_INTF_ALL_TECH {
- GlobalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+ globalPONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
"", 0, nil)
- PONRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
- "", 0, GlobalPONRMgr)
+ ponRMgr.UpdateRanges(ponrmgr.FLOW_ID_START_IDX, FlowIDStart, ponrmgr.FLOW_ID_END_IDX, FlowIDEnd,
+ "", 0, globalPONRMgr)
}
// Make sure loaded range fits the platform bit encoding ranges
- PONRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
+ ponRMgr.UpdateRanges(ponrmgr.UNI_ID_START_IDX, 0, ponrmgr.UNI_ID_END_IDX /* TODO =OpenOltPlatform.MAX_UNIS_PER_ONU-1*/, 1, "", 0, nil)
}
/* TODO
@@ -341,35 +352,35 @@
self.resource_mgrs[pon_intf_id].assert_resource_limits(uni_id, PONResourceManager.UNI_ID)
*/
-func (RsrcMgr *OpenOltResourceMgr) GetONUID(PONIntfID uint32) (uint32, error) {
+// GetONUID returns the available OnuID for the given pon-port
+func (RsrcMgr *OpenOltResourceMgr) GetONUID(ponIntfID uint32) (uint32, error) {
// Get ONU id for a provided pon interface ID.
- ONUID, err := RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+ ONUID, err := RsrcMgr.ResourceMgrs[ponIntfID].GetResourceID(ponIntfID,
ponrmgr.ONU_ID, 1)
if err != nil {
log.Errorf("Failed to get resource for interface %d for type %s",
- PONIntfID, ponrmgr.ONU_ID)
+ ponIntfID, ponrmgr.ONU_ID)
return ONUID[0], err
}
if ONUID != nil {
- RsrcMgr.ResourceMgrs[PONIntfID].InitResourceMap(fmt.Sprintf("%d,%d", PONIntfID, ONUID))
+ RsrcMgr.ResourceMgrs[ponIntfID].InitResourceMap(fmt.Sprintf("%d,%d", ponIntfID, ONUID))
+ return ONUID[0], err
}
- return ONUID[0], err
+ return 0, err // return OnuID 0 on error
}
-func (RsrcMgr *OpenOltResourceMgr) GetFlowIDInfo(PONIntfID uint32, ONUID uint32, UNIID uint32, FlowID uint32) *[]FlowInfo {
-
- /*
- Note: For flows which trap from the NNI and not really associated with any particular
- ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
- */
+// GetFlowIDInfo returns the slice of flow info of the given pon-port
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
+func (RsrcMgr *OpenOltResourceMgr) GetFlowIDInfo(ponIntfID uint32, onuID uint32, uniID uint32, flowID uint32) *[]FlowInfo {
var flows []FlowInfo
- FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
- if err := RsrcMgr.ResourceMgrs[PONIntfID].GetFlowIDInfo(FlowPath, FlowID, &flows); err != nil {
- log.Errorw("Error while getting flows from KV store", log.Fields{"flowId": FlowID})
+ FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+ if err := RsrcMgr.ResourceMgrs[ponIntfID].GetFlowIDInfo(FlowPath, flowID, &flows); err != nil {
+ log.Errorw("Error while getting flows from KV store", log.Fields{"flowId": flowID})
return nil
}
if len(flows) == 0 {
@@ -379,82 +390,82 @@
return &flows
}
+// GetCurrentFlowIDsForOnu fetches flow ID from the resource manager
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
func (RsrcMgr *OpenOltResourceMgr) GetCurrentFlowIDsForOnu(PONIntfID uint32, ONUID uint32, UNIID uint32) []uint32 {
- /*
- Note: For flows which trap from the NNI and not really associated with any particular
- ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
- */
+
FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
return RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
}
-func (RsrcMgr *OpenOltResourceMgr) UpdateFlowIDInfo(PONIntfID int32, ONUID int32, UNIID int32,
- FlowID uint32, FlowData *[]FlowInfo) error {
-
- /*
- Note: For flows which trap from the NNI and not really associated with any particular
- ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
- */
- FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
- return RsrcMgr.ResourceMgrs[uint32(PONIntfID)].UpdateFlowIDInfoForOnu(FlowPath, FlowID, *FlowData)
+// UpdateFlowIDInfo updates flow info for the given pon interface, onu id, and uni id
+// Note: For flows which trap from the NNI and not really associated with any particular
+// ONU (like LLDP), the onu_id and uni_id is set as -1. The intf_id is the NNI intf_id.
+func (RsrcMgr *OpenOltResourceMgr) UpdateFlowIDInfo(ponIntfID int32, onuID int32, uniID int32,
+ flowID uint32, flowData *[]FlowInfo) error {
+ FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+ return RsrcMgr.ResourceMgrs[uint32(ponIntfID)].UpdateFlowIDInfoForOnu(FlowPath, flowID, *flowData)
}
-func (RsrcMgr *OpenOltResourceMgr) GetFlowID(PONIntfID uint32, ONUID uint32, UNIID uint32,
- FlowStoreCookie uint64,
- FlowCategory string) (uint32, error) {
-
- // Get flow ID for a given pon interface id, onu id and uni id.
+// GetFlowID return flow ID for a given pon interface id, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) GetFlowID(ponIntfID uint32, ONUID uint32, uniID uint32,
+ flowStoreCookie uint64,
+ flowCategory string) (uint32, error) {
var err error
- FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
- FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
+ FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, ONUID, uniID)
+ FlowIDs := RsrcMgr.ResourceMgrs[ponIntfID].GetCurrentFlowIDsForOnu(FlowPath)
if FlowIDs != nil {
- log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": PONIntfID, "ONUID": ONUID, "UNIID": UNIID, "KVpath": FlowPath})
- for _, flowId := range FlowIDs {
- FlowInfo := RsrcMgr.GetFlowIDInfo(PONIntfID, ONUID, UNIID, uint32(flowId))
+ log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": ponIntfID, "ONUID": ONUID, "uniID": uniID, "KVpath": FlowPath})
+ for _, flowID := range FlowIDs {
+ FlowInfo := RsrcMgr.GetFlowIDInfo(ponIntfID, ONUID, uniID, uint32(flowID))
if FlowInfo != nil {
for _, Info := range *FlowInfo {
- if FlowCategory != "" && Info.FlowCategory == FlowCategory {
- log.Debug("Found flow matching with flow catagory", log.Fields{"flowId": flowId, "FlowCategory": FlowCategory})
- return flowId, nil
+ if flowCategory != "" && Info.FlowCategory == flowCategory {
+ log.Debug("Found flow matching with flow category", log.Fields{"flowId": flowID, "flowCategory": flowCategory})
+ return flowID, nil
}
- if FlowStoreCookie != 0 && Info.FlowStoreCookie == FlowStoreCookie {
- log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowId, "FlowStoreCookie": FlowStoreCookie})
- return flowId, nil
+ if flowStoreCookie != 0 && Info.FlowStoreCookie == flowStoreCookie {
+ log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowID, "flowStoreCookie": flowStoreCookie})
+ return flowID, nil
}
}
}
}
}
log.Debug("No matching flows with flow cookie or flow category, allocating new flowid")
- FlowIDs, err = RsrcMgr.ResourceMgrs[PONIntfID].GetResourceID(PONIntfID,
+ FlowIDs, err = RsrcMgr.ResourceMgrs[ponIntfID].GetResourceID(ponIntfID,
ponrmgr.FLOW_ID, 1)
if err != nil {
log.Errorf("Failed to get resource for interface %d for type %s",
- PONIntfID, ponrmgr.FLOW_ID)
+ ponIntfID, ponrmgr.FLOW_ID)
return uint32(0), err
}
if FlowIDs != nil {
- RsrcMgr.ResourceMgrs[PONIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
+ _ = RsrcMgr.ResourceMgrs[ponIntfID].UpdateFlowIDForOnu(FlowPath, FlowIDs[0], true)
+ return FlowIDs[0], err
}
- return FlowIDs[0], err
+ return 0, err
}
-func (RsrcMgr *OpenOltResourceMgr) GetAllocID(IntfID uint32, ONUID uint32, UNIID uint32) uint32 {
+// GetAllocID return the first Alloc ID for a given pon interface id and onu id and then update the resource map on
+// the KV store with the list of alloc_ids allocated for the pon_intf_onu_id tuple
+// Currently of all the alloc_ids available, it returns the first alloc_id in the list for tha given ONU
+func (RsrcMgr *OpenOltResourceMgr) GetAllocID(intfID uint32, onuID uint32, uniID uint32) uint32 {
- // Get alloc id for a given pon interface id and onu id.
var err error
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
- AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ AllocID := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
if AllocID != nil {
// Since we support only one alloc_id for the ONU at the moment,
// return the first alloc_id in the list, if available, for that
// ONU.
- log.Debugw("Retrived alloc ID from pon resource mgr", log.Fields{"AllocID": AllocID})
+ log.Debugw("Retrieved alloc ID from pon resource mgr", log.Fields{"AllocID": AllocID})
return AllocID[0]
}
- AllocID, err = RsrcMgr.ResourceMgrs[IntfID].GetResourceID(IntfID,
+ AllocID, err = RsrcMgr.ResourceMgrs[intfID].GetResourceID(intfID,
ponrmgr.ALLOC_ID, 1)
if AllocID == nil || err != nil {
@@ -463,7 +474,7 @@
}
// update the resource map on KV store with the list of alloc_id
// allocated for the pon_intf_onu_id tuple
- err = RsrcMgr.ResourceMgrs[IntfID].UpdateAllocIdsForOnu(IntfOnuIDUniID, AllocID)
+ err = RsrcMgr.ResourceMgrs[intfID].UpdateAllocIdsForOnu(IntfOnuIDUniID, AllocID)
if err != nil {
log.Error("Failed to update Alloc ID")
return 0
@@ -472,30 +483,30 @@
return AllocID[0]
}
-func (RsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(PONPort uint32, ONUID uint32, UNIID uint32, AllocID []uint32) error {
+// UpdateAllocIdsForOnu updates alloc ids in kv store for a given pon interface id, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) UpdateAllocIdsForOnu(ponPort uint32, onuID uint32, uniID uint32, allocID []uint32) error {
- /* update alloc ids in kv store for a given pon interface id,
- onu id and uni id.
- */
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
- return RsrcMgr.ResourceMgrs[PONPort].UpdateAllocIdsForOnu(IntfOnuIDUniID,
- AllocID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+ return RsrcMgr.ResourceMgrs[ponPort].UpdateAllocIdsForOnu(IntfOnuIDUniID,
+ allocID)
}
-func (RsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(IntfID uint32, ONUID uint32,
- UNIID uint32) []uint32 {
+
+// GetCurrentGEMPortIDsForOnu returns gem ports for given pon interface , onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) GetCurrentGEMPortIDsForOnu(intfID uint32, onuID uint32,
+ uniID uint32) []uint32 {
/* Get gem ports for given pon interface , onu id and uni id. */
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
- return RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ return RsrcMgr.ResourceMgrs[intfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
}
-func (RsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDForOnu(IntfID uint32, ONUID uint32, UNIID uint32) uint32 {
+// GetCurrentAllocIDForOnu returns alloc ids for given pon interface and onu id
+// Currently of all the alloc_ids available, it returns the first alloc_id in the list for tha given ONU
+func (RsrcMgr *OpenOltResourceMgr) GetCurrentAllocIDForOnu(intfID uint32, onuID uint32, uniID uint32) uint32 {
- /* Get alloc ids for given pon interface and onu id. */
-
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
- AllocID := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
+ AllocID := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
if AllocID != nil {
// Since we support only one alloc_id for the ONU at the moment,
// return the first alloc_id in the list, if available, for that
@@ -505,22 +516,23 @@
return 0
}
-func (RsrcMgr *OpenOltResourceMgr) UpdateGEMportsPonportToOnuMapOnKVStore(GEMPorts []uint32, PonPort uint32,
- ONUID uint32, UNIID uint32) error {
+// UpdateGEMportsPonportToOnuMapOnKVStore updates onu and uni id associated with the gem port to the kv store
+// This stored information is used when packet_indication is received and we need to derive the ONU Id for which
+// the packet arrived based on the pon_intf and gemport available in the packet_indication
+func (RsrcMgr *OpenOltResourceMgr) UpdateGEMportsPonportToOnuMapOnKVStore(gemPorts []uint32, PonPort uint32,
+ onuID uint32, uniID uint32) error {
/* Update onu and uni id associated with the gem port to the kv store. */
var IntfGEMPortPath string
- Data := fmt.Sprintf("%d %d", ONUID, UNIID)
- for _, GEM := range GEMPorts {
+ Data := fmt.Sprintf("%d %d", onuID, uniID)
+ for _, GEM := range gemPorts {
IntfGEMPortPath = fmt.Sprintf("%d,%d", PonPort, GEM)
Val, err := json.Marshal(Data)
if err != nil {
log.Error("failed to Marshal")
return err
}
- // This information is used when packet_indication is received and
- // we need to derive the ONU Id for which the packet arrived based
- // on the pon_intf and gemport available in the packet_indication
+
if err = RsrcMgr.KVStore.Put(IntfGEMPortPath, Val); err != nil {
log.Errorf("Failed to update resource %s", IntfGEMPortPath)
return err
@@ -529,56 +541,24 @@
return nil
}
-func (RsrcMgr *OpenOltResourceMgr) GetONUUNIfromPONPortGEMPort(PONPort uint32, GEMPort uint32) (err error, OnuID uint32, UniID uint32) {
-
- var ONUID uint32
- var UNIID uint32
- var Data string
-
- /* get the onu and uni id for a given gem port and pon port */
- IntfGEMPortPath := fmt.Sprintf("%d,%d", PONPort, GEMPort)
- Value, err := RsrcMgr.KVStore.Get(IntfGEMPortPath)
- if err == nil {
- if Value != nil {
- Val, _ := kvstore.ToByte(Value.Value)
- if err = json.Unmarshal(Val, &Data); err != nil {
- log.Error("Failed to unmarshal")
- return err, ONUID, UNIID
- }
- IDs := strings.Split(Data, " ")
- for index, val := range IDs {
- switch index {
- case 0:
- if intval, err := strconv.Atoi(val); err == nil {
- ONUID = uint32(intval)
- }
- case 1:
- if intval, err := strconv.Atoi(val); err == nil {
- UNIID = uint32(intval)
- }
- }
- }
- }
- }
- return err, ONUID, UNIID
-}
-
-func (RsrcMgr *OpenOltResourceMgr) GetGEMPortID(PONPort uint32, ONUID uint32,
- UNIID uint32, NumOfPorts uint32) ([]uint32, error) {
+// GetGEMPortID gets gem port id for a particular pon port, onu id and uni id and then update the resource map on
+// the KV store with the list of gemport_id allocated for the pon_intf_onu_id tuple
+func (RsrcMgr *OpenOltResourceMgr) GetGEMPortID(ponPort uint32, onuID uint32,
+ uniID uint32, NumOfPorts uint32) ([]uint32, error) {
/* Get gem port id for a particular pon port, onu id
and uni id.
*/
var err error
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
- GEMPortList := RsrcMgr.ResourceMgrs[PONPort].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+ GEMPortList := RsrcMgr.ResourceMgrs[ponPort].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
if GEMPortList != nil {
return GEMPortList, nil
}
- GEMPortList, err = RsrcMgr.ResourceMgrs[PONPort].GetResourceID(PONPort,
+ GEMPortList, err = RsrcMgr.ResourceMgrs[ponPort].GetResourceID(ponPort,
ponrmgr.GEMPORT_ID, NumOfPorts)
if err != nil && GEMPortList == nil {
log.Errorf("Failed to get gem port id for %s", IntfOnuIDUniID)
@@ -587,123 +567,122 @@
// update the resource map on KV store with the list of gemport_id
// allocated for the pon_intf_onu_id tuple
- err = RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
+ err = RsrcMgr.ResourceMgrs[ponPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
GEMPortList)
if err != nil {
log.Errorf("Failed to update GEM ports to kv store for %s", IntfOnuIDUniID)
return nil, err
}
- RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, PONPort,
- ONUID, UNIID)
+ _ = RsrcMgr.UpdateGEMportsPonportToOnuMapOnKVStore(GEMPortList, ponPort,
+ onuID, uniID)
return GEMPortList, err
}
-func (RsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(PONPort uint32, ONUID uint32,
- UNIID uint32, GEMPortList []uint32) error {
-
- /* Update gemport ids on to kv store for a given pon port,
- onu id and uni id.
- */
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", PONPort, ONUID, UNIID)
- return RsrcMgr.ResourceMgrs[PONPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
+// UpdateGEMPortIDsForOnu updates gemport ids on to the kv store for a given pon port, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) UpdateGEMPortIDsForOnu(ponPort uint32, onuID uint32,
+ uniID uint32, GEMPortList []uint32) error {
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", ponPort, onuID, uniID)
+ return RsrcMgr.ResourceMgrs[ponPort].UpdateGEMPortIDsForOnu(IntfOnuIDUniID,
GEMPortList)
}
-func (RsrcMgr *OpenOltResourceMgr) FreeONUID(IntfID uint32, ONUID []uint32) {
+
+// FreeonuID releases(make free) onu id for a particular pon-port
+func (RsrcMgr *OpenOltResourceMgr) FreeonuID(intfID uint32, onuID []uint32) {
+
+ RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID, ponrmgr.ONU_ID, onuID)
/* Free onu id for a particular interface.*/
- RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.ONU_ID, ONUID)
-
- var IntfONUID string
- for _, onu := range ONUID {
- IntfONUID = fmt.Sprintf("%d,%d", IntfID, onu)
- RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfONUID)
+ var IntfonuID string
+ for _, onu := range onuID {
+ IntfonuID = fmt.Sprintf("%d,%d", intfID, onu)
+ RsrcMgr.ResourceMgrs[intfID].RemoveResourceMap(IntfonuID)
}
- return
}
-func (RsrcMgr *OpenOltResourceMgr) FreeFlowID(IntfID uint32, ONUID uint32,
- UNIID uint32, FlowId uint32) {
+// FreeFlowID returns the free flow id for a given interface, onu id and uni id
+func (RsrcMgr *OpenOltResourceMgr) FreeFlowID(IntfID uint32, onuID uint32,
+ uniID uint32, FlowID uint32) {
var IntfONUID string
var err error
- IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
- err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, FlowId, false)
+ IntfONUID = fmt.Sprintf("%d,%d,%d", IntfID, onuID, uniID)
+ err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfONUID, FlowID, false)
if err != nil {
log.Error("Failed to Update flow id infor for %s", IntfONUID)
}
- RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, FlowId)
+ RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfONUID, FlowID)
}
-func (RsrcMgr *OpenOltResourceMgr) FreeFlowIDs(IntfID uint32, ONUID uint32,
- UNIID uint32, FlowID []uint32) {
-
- /* Free flow id for a given interface, onu id and uni id.*/
+// FreeFlowIDs releases the flow Ids
+func (RsrcMgr *OpenOltResourceMgr) FreeFlowIDs(IntfID uint32, onuID uint32,
+ uniID uint32, FlowID []uint32) {
RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID, ponrmgr.FLOW_ID, FlowID)
var IntfOnuIDUniID string
var err error
for _, flow := range FlowID {
- IntfOnuIDUniID = fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+ IntfOnuIDUniID = fmt.Sprintf("%d,%d,%d", IntfID, onuID, uniID)
err = RsrcMgr.ResourceMgrs[IntfID].UpdateFlowIDForOnu(IntfOnuIDUniID, flow, false)
if err != nil {
log.Error("Failed to Update flow id infor for %s", IntfOnuIDUniID)
}
RsrcMgr.ResourceMgrs[IntfID].RemoveFlowIDInfo(IntfOnuIDUniID, flow)
}
- return
}
-func (RsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(IntfID uint32, ONUID uint32, UNIID uint32) {
+// FreePONResourcesForONU make the pon resources free for a given pon interface and onu id, and the clears the
+// resource map and the onuID associated with (pon_intf_id, gemport_id) tuple,
+func (RsrcMgr *OpenOltResourceMgr) FreePONResourcesForONU(intfID uint32, onuID uint32, uniID uint32) {
- /* Free pon resources for a given pon interface and onu id. */
+ var onuIDs []uint32
+ onuIDs = append(onuIDs, onuID)
+ IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", intfID, onuID, uniID)
- var ONUIDs []uint32
- ONUIDs = append(ONUIDs, ONUID)
- IntfOnuIDUniID := fmt.Sprintf("%d,%d,%d", IntfID, ONUID, UNIID)
+ AllocIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
- AllocIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentAllocIDForOnu(IntfOnuIDUniID)
-
- RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+ RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
ponrmgr.ALLOC_ID,
AllocIDs)
- GEMPortIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
- RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+ GEMPortIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentGEMPortIDsForOnu(IntfOnuIDUniID)
+ RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
ponrmgr.GEMPORT_ID,
GEMPortIDs)
- FlowIDs := RsrcMgr.ResourceMgrs[IntfID].GetCurrentFlowIDsForOnu(IntfOnuIDUniID)
- RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+ FlowIDs := RsrcMgr.ResourceMgrs[intfID].GetCurrentFlowIDsForOnu(IntfOnuIDUniID)
+ RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
ponrmgr.FLOW_ID,
FlowIDs)
- RsrcMgr.ResourceMgrs[IntfID].FreeResourceID(IntfID,
+ RsrcMgr.ResourceMgrs[intfID].FreeResourceID(intfID,
ponrmgr.ONU_ID,
- ONUIDs)
+ onuIDs)
// Clear resource map associated with (pon_intf_id, gemport_id) tuple.
- RsrcMgr.ResourceMgrs[IntfID].RemoveResourceMap(IntfOnuIDUniID)
+ RsrcMgr.ResourceMgrs[intfID].RemoveResourceMap(IntfOnuIDUniID)
// Clear the ONU Id associated with the (pon_intf_id, gemport_id) tuple.
for _, GEM := range GEMPortIDs {
- RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", IntfID, GEM))
+ _ = RsrcMgr.KVStore.Delete(fmt.Sprintf("%d,%d", intfID, GEM))
}
}
-func (RsrcMgr *OpenOltResourceMgr) IsFlowCookieOnKVStore(PONIntfID uint32, ONUID uint32, UNIID uint32,
- FlowStoreCookie uint64) bool {
+// IsFlowCookieOnKVStore checks if the given flow cookie is present on the kv store
+// Returns true if the flow cookie is found, otherwise it returns false
+func (RsrcMgr *OpenOltResourceMgr) IsFlowCookieOnKVStore(ponIntfID uint32, onuID uint32, uniID uint32,
+ flowStoreCookie uint64) bool {
- FlowPath := fmt.Sprintf("%d,%d,%d", PONIntfID, ONUID, UNIID)
- FlowIDs := RsrcMgr.ResourceMgrs[PONIntfID].GetCurrentFlowIDsForOnu(FlowPath)
+ FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, onuID, uniID)
+ FlowIDs := RsrcMgr.ResourceMgrs[ponIntfID].GetCurrentFlowIDsForOnu(FlowPath)
if FlowIDs != nil {
- log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": PONIntfID, "ONUID": ONUID, "UNIID": UNIID, "KVpath": FlowPath})
- for _, flowId := range FlowIDs {
- FlowInfo := RsrcMgr.GetFlowIDInfo(PONIntfID, ONUID, UNIID, uint32(flowId))
+ log.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": ponIntfID, "onuID": onuID, "uniID": uniID, "KVpath": FlowPath})
+ for _, flowID := range FlowIDs {
+ FlowInfo := RsrcMgr.GetFlowIDInfo(ponIntfID, onuID, uniID, uint32(flowID))
if FlowInfo != nil {
- log.Debugw("Found flows", log.Fields{"flows": *FlowInfo, "flowId": flowId})
+ log.Debugw("Found flows", log.Fields{"flows": *FlowInfo, "flowId": flowID})
for _, Info := range *FlowInfo {
- if Info.FlowStoreCookie == FlowStoreCookie {
- log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowId, "FlowStoreCookie": FlowStoreCookie})
+ if Info.FlowStoreCookie == flowStoreCookie {
+ log.Debug("Found flow matching with flowStore cookie", log.Fields{"flowId": flowID, "flowStoreCookie": flowStoreCookie})
return true
}
}