VOL-4274 Move platform.go file to voltha-lib-go

Change-Id: I81b6f4e000e48aa634c45d173513db92a02f8e50
diff --git a/VERSION b/VERSION
index fcdb2e1..ad6abd3 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.0
+4.0.1-dev
diff --git a/go.mod b/go.mod
index 714b3ea..9ec8bd6 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@
 	github.com/gogo/protobuf v1.3.2
 	github.com/golang/protobuf v1.5.2
 	github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
-	github.com/opencord/voltha-lib-go/v7 v7.0.0
+	github.com/opencord/voltha-lib-go/v7 v7.0.1
 	github.com/opencord/voltha-protos/v5 v5.0.0
 	go.etcd.io/etcd v3.3.25+incompatible
 	google.golang.org/grpc v1.41.0
diff --git a/go.sum b/go.sum
index ad4e29e..ced6807 100644
--- a/go.sum
+++ b/go.sum
@@ -185,8 +185,8 @@
 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
 github.com/onsi/gomega v1.14.0 h1:ep6kpPVwmr/nTbklSx2nrLNSIO62DoYAhnPNIMhK8gI=
 github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
-github.com/opencord/voltha-lib-go/v7 v7.0.0 h1:xDMFbXdku7GOsJeMlsxw8WHAZINBZhy+8m9Hyqt+zdk=
-github.com/opencord/voltha-lib-go/v7 v7.0.0/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
+github.com/opencord/voltha-lib-go/v7 v7.0.1 h1:3rwfJL+IalcWp/JzH0yDXv+tkPKBjz9b6GA5q0s16TQ=
+github.com/opencord/voltha-lib-go/v7 v7.0.1/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
 github.com/opencord/voltha-protos/v5 v5.0.0 h1:US2k7qYPMnOueOCrprq9LjuMT3wK9uyxPwAVwjMmKhc=
 github.com/opencord/voltha-protos/v5 v5.0.0/go.mod h1:uVKXQB499Ir6G+rc47dSThNja1S4Vy3h9JLSDuJGmzI=
 github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index c0e8cc8..50e0539 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -42,6 +42,7 @@
 	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
 	flow_utils "github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	"github.com/opencord/voltha-lib-go/v7/pkg/pmmetrics"
 
 	conf "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
@@ -325,7 +326,7 @@
 		operStatus = voltha.OperStatus_DISCOVERED
 		dh.activePorts.Store(intfID, false)
 	}
-	portNum := IntfIDToPortNo(intfID, portType)
+	portNum := plt.IntfIDToPortNo(intfID, portType)
 	label, err := GetportLabel(intfID, portType)
 	if err != nil {
 		return olterrors.NewErrNotFound("port-label", log.Fields{"port-number": portNum, "port-type": portType}, err)
@@ -1002,7 +1003,7 @@
 			for _, port := range ports.Items {
 				// NNI Stats
 				if port.Type == voltha.Port_ETHERNET_NNI {
-					intfID := PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI)
+					intfID := plt.PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI)
 					cmnni := dh.portStats.collectNNIMetrics(intfID)
 					logger.Debugw(ctx, "collect-nni-metrics", log.Fields{"metrics": cmnni})
 					go dh.portStats.publishMetrics(ctx, NNIStats, cmnni, port, dh.device.Id, dh.device.Type)
@@ -1010,7 +1011,7 @@
 				}
 				// PON Stats
 				if port.Type == voltha.Port_PON_OLT {
-					intfID := PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT)
+					intfID := plt.PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT)
 					if val, ok := dh.activePorts.Load(intfID); ok && val == true {
 						cmpon := dh.portStats.collectPONMetrics(intfID)
 						logger.Debugw(ctx, "collect-pon-metrics", log.Fields{"metrics": cmpon})
@@ -1069,7 +1070,7 @@
 
 // GetTechProfileDownloadMessage fetches the TechProfileDownloadMessage for the caller.
 func (dh *DeviceHandler) GetTechProfileDownloadMessage(ctx context.Context, request *ic.TechProfileInstanceRequestMessage) (*ic.TechProfileDownloadMessage, error) {
-	ifID, err := IntfIDFromPonPortNum(ctx, request.ParentPonPort)
+	ifID, err := plt.IntfIDFromPonPortNum(ctx, request.ParentPonPort)
 	if err != nil {
 		return nil, err
 	}
@@ -1094,7 +1095,7 @@
 	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 := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
+		ponPort := plt.IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
 
 		onuDevice, err := dh.getChildDeviceFromCore(ctx, &ic.ChildDeviceFilter{
 			ParentId:     dh.device.Id,
@@ -1242,7 +1243,7 @@
 
 func (dh *DeviceHandler) onuDiscIndication(ctx context.Context, onuDiscInd *oop.OnuDiscIndication) error {
 	channelID := onuDiscInd.GetIntfId()
-	parentPortNo := IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
+	parentPortNo := plt.IntfIDToPortNo(onuDiscInd.GetIntfId(), voltha.Port_PON_OLT)
 
 	sn := dh.stringifySerialNumber(onuDiscInd.SerialNumber)
 	logger.Infow(ctx, "new-discovery-indication", log.Fields{"sn": sn})
@@ -1393,7 +1394,7 @@
 
 func (dh *DeviceHandler) onuIndication(ctx context.Context, onuInd *oop.OnuIndication) error {
 
-	ponPort := IntfIDToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
+	ponPort := plt.IntfIDToPortNo(onuInd.GetIntfId(), voltha.Port_PON_OLT)
 	var onuDevice *voltha.Device
 	var err error
 	foundInCache := false
@@ -1792,7 +1793,7 @@
 	var uniID uint32
 	var err error
 	for _, port := range onu.UniPorts {
-		uniID = UniIDFromPortNum(port)
+		uniID = plt.UniIDFromPortNum(port)
 		logger.Debugw(ctx, "clearing-resource-data-for-uni-port", log.Fields{"port": port, "uni-id": uniID})
 		/* Delete tech-profile instance from the KV store */
 		if err = dh.flowMgr[onu.IntfID].DeleteTechProfileInstances(ctx, onu.IntfID, onu.OnuID, uniID); err != nil {
@@ -1964,7 +1965,7 @@
 		})
 	}
 
-	egressPortType := IntfIDToPortTypeName(uint32(egressPortNo))
+	egressPortType := plt.IntfIDToPortTypeName(uint32(egressPortNo))
 	if egressPortType == voltha.Port_ETHERNET_UNI {
 		outerEthType := (uint16(packet.Data[12]) << 8) | uint16(packet.Data[13])
 		innerEthType := (uint16(packet.Data[16]) << 8) | uint16(packet.Data[17])
@@ -1991,9 +1992,9 @@
 				}
 			}
 		}
-		intfID := IntfIDFromUniPortNum(uint32(egressPortNo))
-		onuID := OnuIDFromPortNum(uint32(egressPortNo))
-		uniID := UniIDFromPortNum(uint32(egressPortNo))
+		intfID := plt.IntfIDFromUniPortNum(uint32(egressPortNo))
+		onuID := plt.OnuIDFromPortNum(uint32(egressPortNo))
+		uniID := plt.UniIDFromPortNum(uint32(egressPortNo))
 
 		gemPortID, err := dh.flowMgr[intfID].GetPacketOutGemPortID(ctx, intfID, onuID, uint32(egressPortNo), packet.Data)
 		if err != nil {
@@ -2036,7 +2037,7 @@
 			}, err)
 		}
 	} else if egressPortType == voltha.Port_ETHERNET_NNI {
-		nniIntfID, err := IntfIDFromNniPortNum(ctx, uint32(egressPortNo))
+		nniIntfID, err := plt.IntfIDFromNniPortNum(ctx, uint32(egressPortNo))
 		if err != nil {
 			return olterrors.NewErrInvalidValue(log.Fields{
 				"egress-nni-port": egressPortNo,
@@ -2202,7 +2203,7 @@
 			"enable-state": enablePort}, nil)
 	}
 	// fetch interfaceid from PortNo
-	ponID := PortNoToIntfID(port.GetPortNo(), voltha.Port_PON_OLT)
+	ponID := plt.PortNoToIntfID(port.GetPortNo(), voltha.Port_PON_OLT)
 	ponIntf := &oop.Interface{IntfId: ponID}
 	var operStatus voltha.OperStatus_Types
 	if enablePort {
@@ -2264,16 +2265,16 @@
 	for _, port := range ports {
 		if port.Type == voltha.Port_ETHERNET_NNI {
 			if port.OperStatus == voltha.OperStatus_ACTIVE {
-				dh.activePorts.Store(PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI), true)
+				dh.activePorts.Store(plt.PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI), true)
 			} else {
-				dh.activePorts.Store(PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI), false)
+				dh.activePorts.Store(plt.PortNoToIntfID(port.PortNo, voltha.Port_ETHERNET_NNI), false)
 			}
 		}
 		if port.Type == voltha.Port_PON_OLT {
 			if port.OperStatus == voltha.OperStatus_ACTIVE {
-				dh.activePorts.Store(PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT), true)
+				dh.activePorts.Store(plt.PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT), true)
 			} else {
-				dh.activePorts.Store(PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT), false)
+				dh.activePorts.Store(plt.PortNoToIntfID(port.PortNo, voltha.Port_PON_OLT), false)
 			}
 		}
 	}
@@ -2282,7 +2283,7 @@
 // ChildDeviceLost deletes ONU and clears pon resources related to it.
 func (dh *DeviceHandler) ChildDeviceLost(ctx context.Context, pPortNo uint32, onuID uint32, onuSn string) error {
 	logger.Debugw(ctx, "child-device-lost", log.Fields{"parent-device-id": dh.device.Id})
-	intfID := PortNoToIntfID(pPortNo, voltha.Port_PON_OLT)
+	intfID := plt.PortNoToIntfID(pPortNo, voltha.Port_PON_OLT)
 	onuKey := dh.formOnuKey(intfID, onuID)
 
 	var sn *oop.SerialNumber
@@ -2367,21 +2368,21 @@
 		return inPort, outPort
 	}
 
-	if isControllerFlow := IsControllerBoundFlow(outPort); isControllerFlow {
+	if isControllerFlow := plt.IsControllerBoundFlow(outPort); isControllerFlow {
 		/* Get UNI port/ IN Port from tunnel ID field for upstream controller bound flows  */
-		if portType := IntfIDToPortTypeName(inPort); portType == voltha.Port_PON_OLT {
+		if portType := plt.IntfIDToPortTypeName(inPort); portType == voltha.Port_PON_OLT {
 			if uniPort := flow_utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				return uniPort, outPort
 			}
 		}
 	} else {
 		// Downstream flow from NNI to PON port , Use tunnel ID as new OUT port / UNI port
-		if portType := IntfIDToPortTypeName(outPort); portType == voltha.Port_PON_OLT {
+		if portType := plt.IntfIDToPortTypeName(outPort); portType == voltha.Port_PON_OLT {
 			if uniPort := flow_utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				return inPort, uniPort
 			}
 			// Upstream flow from PON to NNI port , Use tunnel ID as new IN port / UNI port
-		} else if portType := IntfIDToPortTypeName(inPort); portType == voltha.Port_PON_OLT {
+		} else if portType := plt.IntfIDToPortTypeName(inPort); portType == voltha.Port_PON_OLT {
 			if uniPort := flow_utils.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				return uniPort, outPort
 			}
@@ -2444,7 +2445,7 @@
 	var intfID uint32
 	inPort, outPort := getPorts(flow)
 	if inPort != InvalidPort && outPort != InvalidPort {
-		_, intfID, _, _ = ExtractAccessFromFlow(inPort, outPort)
+		_, intfID, _, _ = plt.ExtractAccessFromFlow(inPort, outPort)
 	}
 	return intfID
 }
@@ -2673,7 +2674,7 @@
 	}
 	if oltPortInfo.PortType == extension.GetOltPortCounters_Port_ETHERNET_NNI {
 		//get nni stats
-		intfID := PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_ETHERNET_NNI)
+		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 {
@@ -2685,7 +2686,7 @@
 
 	} else if oltPortInfo.PortType == extension.GetOltPortCounters_Port_PON_OLT {
 		// get pon stats
-		intfID := PortNoToIntfID(oltPortInfo.PortNo, voltha.Port_PON_OLT)
+		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 {
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index aa534d0..924355a 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -30,6 +30,7 @@
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/db"
 	fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	"github.com/opencord/voltha-lib-go/v7/pkg/pmmetrics"
 	ponrmgr "github.com/opencord/voltha-lib-go/v7/pkg/ponresourcemanager"
 	"github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
@@ -239,9 +240,9 @@
 
 		// Create a slice of buffered channels for handling concurrent flows per ONU.
 		// The additional entry (+1) is to handle the NNI trap flows on a separate channel from individual ONUs channel
-		dh.flowMgr[i].incomingFlows = make([]chan flowControlBlock, MaxOnusPerPon+1)
-		dh.flowMgr[i].stopFlowHandlerRoutine = make([]chan bool, MaxOnusPerPon+1)
-		dh.flowMgr[i].flowHandlerRoutineActive = make([]bool, MaxOnusPerPon+1)
+		dh.flowMgr[i].incomingFlows = make([]chan flowControlBlock, plt.MaxOnusPerPon+1)
+		dh.flowMgr[i].stopFlowHandlerRoutine = make([]chan bool, plt.MaxOnusPerPon+1)
+		dh.flowMgr[i].flowHandlerRoutineActive = make([]bool, plt.MaxOnusPerPon+1)
 		for j := range dh.flowMgr[i].incomingFlows {
 			dh.flowMgr[i].incomingFlows[j] = make(chan flowControlBlock, maxConcurrentFlowsPerOnu)
 			dh.flowMgr[i].stopFlowHandlerRoutine[j] = make(chan bool, 1)
diff --git a/internal/pkg/core/olt_platform_test.go b/internal/pkg/core/olt_platform_test.go
deleted file mode 100644
index c05282a..0000000
--- a/internal/pkg/core/olt_platform_test.go
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//Package core provides the utility for olt devices, flows and statistics
-package core
-
-import (
-	"context"
-	"math"
-	"reflect"
-	"testing"
-
-	fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
-	"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
-	ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
-	"github.com/opencord/voltha-protos/v5/go/voltha"
-)
-
-func TestMkUniPortNum(t *testing.T) {
-	type args struct {
-		intfID uint32
-		onuID  uint32
-		uniID  uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want uint32
-	}{
-		// TODO: Add test cases.
-		{"MkUniPortNum-1", args{1, 1, 1}, ((1 * 4096) + (1 * 16) + 1)},
-		{"MkUniPortNum-2", args{4, 5, 6}, ((4 * 4096) + (5 * 16) + 6)},
-		// Negative test cases to cover the log.warn
-		{"MkUniPortNum-3", args{4, 130, 6}, ((4 * 4096) + (130 * 16) + 6)},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := MkUniPortNum(context.Background(), tt.args.intfID, tt.args.onuID, tt.args.uniID); got != tt.want {
-				t.Errorf("MkUniPortNum() = %v, want %v", got, tt.want)
-			} else {
-				t.Logf("Expected %v , Actual %v \n", tt.want, got)
-			}
-		})
-	}
-}
-
-func TestOnuIDFromPortNum(t *testing.T) {
-	type args struct {
-		portNum uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want uint32
-	}{
-		// TODO: Add test cases.
-		{"OnuIDFromPortNum-1", args{portNum: 8096}, ((8096 / 16) & 255)},
-		{"OnuIDFromPortNum-2", args{portNum: 9095}, ((9095 / 16) & 255)},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := OnuIDFromPortNum(tt.args.portNum); got != tt.want {
-				t.Errorf("OnuIDFromPortNum() = %v, want %v", got, tt.want)
-			} else {
-				t.Logf("Expected %v , Actual %v \n", tt.want, got)
-			}
-		})
-	}
-}
-
-func TestIntfIDFromUniPortNum(t *testing.T) {
-	type args struct {
-		portNum uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want uint32
-	}{
-		// TODO: Add test cases.
-		{"IntfIDFromUniPortNum-1", args{portNum: 8096}, ((8096 / 4096) & 15)},
-		// Negative Testcase
-		{"IntfIDFromUniPortNum-2", args{portNum: 1024}, ((1024 / 4096) & 15)},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IntfIDFromUniPortNum(tt.args.portNum); got != tt.want {
-				t.Errorf("IntfIDFromUniPortNum() = %v, want %v", got, tt.want)
-			} else {
-				t.Logf("Expected %v , Actual %v \n", tt.want, got)
-			}
-		})
-	}
-}
-
-func TestUniIDFromPortNum(t *testing.T) {
-	type args struct {
-		portNum uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want uint32
-	}{
-
-		// TODO: Add test cases.
-		{"UniIDFromPortNum-1", args{portNum: 8096}, (8096 & 15)},
-		{"UniIDFromPortNum-2", args{portNum: 1024}, (1024 & 15)},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := UniIDFromPortNum(tt.args.portNum); got != tt.want {
-				t.Errorf("UniIDFromPortNum() = %v, want %v", got, tt.want)
-			} else {
-				t.Logf("Expected %v , Actual %v \n", tt.want, got)
-			}
-		})
-	}
-}
-
-func TestIntfIDToPortNo(t *testing.T) {
-	type args struct {
-		intfID   uint32
-		intfType voltha.Port_PortType
-	}
-	tests := []struct {
-		name string
-		args args
-		want uint32
-	}{
-		// TODO: Add test cases.
-		{"IntfIDToPortNo-1", args{intfID: 120, intfType: voltha.Port_ETHERNET_NNI}, (uint32(math.Pow(2, 20)) + 120)},
-		{"IntfIDToPortNo-2", args{intfID: 1024, intfType: voltha.Port_ETHERNET_UNI}, 0},
-		{"IntfIDToPortNo-3", args{intfID: 456, intfType: voltha.Port_PON_OLT}, (uint32(2*math.Pow(2, 28)) + 456)},
-		{"IntfIDToPortNo-4", args{intfID: 28, intfType: voltha.Port_PON_ONU}, 0},
-		{"IntfIDToPortNo-5", args{intfID: 45, intfType: voltha.Port_UNKNOWN}, 0},
-		{"IntfIDToPortNo-6", args{intfID: 45, intfType: voltha.Port_VENET_OLT}, 0},
-		{"IntfIDToPortNo-7", args{intfID: 45, intfType: voltha.Port_VENET_ONU}, 0},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IntfIDToPortNo(tt.args.intfID, tt.args.intfType); got != tt.want {
-				t.Errorf("IntfIDToPortNo() = %v, want %v", got, tt.want)
-			} else {
-				t.Logf("Expected %v , Actual %v \n", tt.want, got)
-			}
-		})
-	}
-}
-
-func TestIntfIDFromNniPortNum(t *testing.T) {
-	type args struct {
-		portNum uint32
-	}
-
-	tests := []struct {
-		name    string
-		args    args
-		want    uint32
-		wantErr error
-	}{
-		// TODO: Add test cases.
-		{"IntfIDFromNniPortNum-01", args{portNum: 8081}, 0, olterrors.ErrInvalidPortRange},
-		{"IntfIDFromNniPortNum-02", args{portNum: 9090}, 0, olterrors.ErrInvalidPortRange},
-		{"IntfIDFromNniPortNum-03", args{portNum: 0}, 0, olterrors.ErrInvalidPortRange},
-		{"IntfIDFromNniPortNum-04", args{portNum: 65535}, 0, olterrors.ErrInvalidPortRange},
-		{"IntfIDFromNniPortNum-05", args{portNum: 1048575}, 0, olterrors.ErrInvalidPortRange},
-		{"IntfIDFromNniPortNum-06", args{portNum: 1048576}, 0, nil},
-		{"IntfIDFromNniPortNum-07", args{portNum: 1048577}, 1, nil},
-		{"IntfIDFromNniPortNum-08", args{portNum: 1048578}, 2, nil},
-		{"IntfIDFromNniPortNum-09", args{portNum: 1048579}, 3, nil},
-		{"IntfIDFromNniPortNum-10", args{portNum: 2097150}, 65534, nil},
-		{"IntfIDFromNniPortNum-11", args{portNum: 2097151}, 65535, nil},
-		{"IntfIDFromNniPortNum-12", args{portNum: 3000000}, 0, olterrors.ErrInvalidPortRange},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, err := IntfIDFromNniPortNum(context.Background(), tt.args.portNum)
-			if got != tt.want || err != tt.wantErr {
-				t.Errorf("IntfIDFromNniPortNum(): FOR[%v] WANT[%v and %v] GOT[%v and %v]",
-					tt.args.portNum, tt.want, tt.wantErr, got, err)
-			}
-		})
-	}
-}
-
-func TestIntfIDToPortTypeName(t *testing.T) {
-	type args struct {
-		intfID uint32
-	}
-	input := uint32(2*math.Pow(2, 28)) | 3
-	tests := []struct {
-		name string
-		args args
-		want voltha.Port_PortType
-	}{
-		// TODO: Add test cases.
-		{"IntfIDToPortTypeName-1", args{intfID: 1048576}, voltha.Port_ETHERNET_NNI},
-		{"IntfIDToPortTypeName-2", args{intfID: 1000}, voltha.Port_ETHERNET_UNI},
-		{"IntfIDToPortTypeName-2", args{intfID: input}, voltha.Port_PON_OLT},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IntfIDToPortTypeName(tt.args.intfID); !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("IntfIDToPortTypeName() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestExtractAccessFromFlow(t *testing.T) {
-	type args struct {
-		inPort  uint32
-		outPort uint32
-	}
-	tests := []struct {
-		name   string
-		args   args
-		port   uint32
-		IntfID uint32
-		onuID  uint32
-		uniID  uint32
-	}{
-		// TODO: Add test cases.
-		{"ExtractAccessFromFlow-1", args{inPort: 100, outPort: 1048576}, 100, 0, 6, 4},
-		{"ExtractAccessFromFlow-2", args{inPort: 1048576, outPort: 10}, 10, 0, 0, 10},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, got1, got2, got3 := ExtractAccessFromFlow(tt.args.inPort, tt.args.outPort)
-			if got != tt.port {
-				t.Errorf("ExtractAccessFromFlow() got = %v, want %v", got, tt.port)
-			}
-			if got1 != tt.IntfID {
-				t.Errorf("ExtractAccessFromFlow() got1 = %v, want %v", got1, tt.IntfID)
-			}
-			if got2 != tt.onuID {
-				t.Errorf("ExtractAccessFromFlow() got2 = %v, want %v", got2, tt.onuID)
-			}
-			if got3 != tt.uniID {
-				t.Errorf("ExtractAccessFromFlow() got3 = %v, want %v", got3, tt.uniID)
-			}
-		})
-	}
-	//t.Error()
-}
-
-func TestIsUpstream(t *testing.T) {
-	type args struct {
-		outPort uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{"TestIsUpstream-1", args{outPort: 65533}, true},
-		{"TestIsUpstream-2", args{outPort: 1048576}, true},
-		{"TestIsUpstream-3", args{outPort: 1048577}, true},
-		{"TestIsUpstream-4", args{outPort: 1048578}, true},
-		{"TestIsUpstream-6", args{outPort: 1000}, false},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IsUpstream(tt.args.outPort); got != tt.want {
-				t.Errorf("IsUpstream() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestIsControllerBoundFlow(t *testing.T) {
-	type args struct {
-		outPort uint32
-	}
-	tests := []struct {
-		name string
-		args args
-		want bool
-	}{
-		// TODO: Add test cases.
-		{"IsControllerBoundFlow-1", args{outPort: 65533}, true},
-		{"IsControllerBoundFlow-2", args{outPort: 65536}, false},
-		{"IsControllerBoundFlow-3", args{outPort: 65537}, false},
-		{"IsControllerBoundFlow-4", args{outPort: 65538}, false},
-		{"IsControllerBoundFlow-5", args{outPort: 65539}, false},
-		{"IsControllerBoundFlow-6", args{outPort: 1000}, false},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := IsControllerBoundFlow(tt.args.outPort); got != tt.want {
-				t.Errorf("IsControllerBoundFlow() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func TestFlowExtractInfo(t *testing.T) {
-	fa := &fu.FlowArgs{
-		MatchFields: []*ofp.OfpOxmOfbField{
-			fu.InPort(2),
-			fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2)),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
-			fu.EthType(2048),
-		},
-
-		Actions: []*ofp.OfpAction{
-			fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
-			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
-			fu.Output(1),
-		},
-	}
-	ofpstats, _ := fu.MkFlowStat(fa)
-	type args struct {
-		flow          *ofp.OfpFlowStats
-		flowDirection string
-	}
-	tests := []struct {
-		name    string
-		args    args
-		want    uint32
-		want1   uint32
-		want2   uint32
-		want3   uint32
-		want4   uint32
-		want5   uint32
-		wantErr bool
-	}{
-		// TODO: Add test cases.
-		{"FlowExtractInfo-1", args{flow: ofpstats, flowDirection: "upstream"}, 2, 0, 0, 2, 0, 0, false},
-
-		// Negative Testcases
-		{"FlowExtractInfo-2", args{flow: ofpstats, flowDirection: "downstream"}, 1, 0, 0, 1, 2, 2048, false},
-		{"FlowExtractInfo-3", args{flow: nil, flowDirection: "downstream"}, 0, 0, 0, 0, 0, 0, true},
-		{"FlowExtractInfo-4", args{flow: &ofp.OfpFlowStats{}, flowDirection: "downstream"}, 0, 0, 0, 0, 0, 0, true},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, got1, got2, got3, got4, got5, err := FlowExtractInfo(context.Background(), tt.args.flow, tt.args.flowDirection)
-			if (err != nil) != tt.wantErr {
-				t.Errorf("FlowExtractInfo() error = %v, wantErr %v", err, tt.wantErr)
-				return
-			}
-			if got != tt.want {
-				t.Errorf("FlowExtractInfo() got = %v, want %v", got, tt.want)
-				return
-			}
-			if got1 != tt.want1 {
-				t.Errorf("FlowExtractInfo() got1 = %v, want %v", got1, tt.want1)
-				return
-			}
-			if got2 != tt.want2 {
-				t.Errorf("FlowExtractInfo() got2 = %v, want %v", got2, tt.want2)
-				return
-			}
-			if got3 != tt.want3 {
-				t.Errorf("FlowExtractInfo() got3 = %v, want %v", got3, tt.want3)
-				return
-			}
-			if got4 != tt.want4 {
-				t.Errorf("FlowExtractInfo() got4 = %v, want %v", got4, tt.want4)
-				return
-			}
-			if got5 != tt.want5 {
-				t.Errorf("FlowExtractInfo() got5 = %v, want %v", got5, tt.want5)
-				return
-			}
-		})
-	}
-}
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index 45b327b..67945dd 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -27,6 +27,7 @@
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/events/eventif"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
 	"github.com/opencord/voltha-protos/v5/go/common"
 	oop "github.com/opencord/voltha-protos/v5/go/openolt"
@@ -299,7 +300,7 @@
 	var err error = nil
 	var de voltha.DeviceEvent
 	var alarmInd oop.OnuAlarmIndication
-	ponIntdID := PortNoToIntfID(oltLos.IntfId, voltha.Port_PON_OLT)
+	ponIntdID := plt.PortNoToIntfID(oltLos.IntfId, voltha.Port_PON_OLT)
 
 	context := make(map[string]string)
 	/* Populating event context */
@@ -667,7 +668,7 @@
 
 // oltIntfOperIndication handles Up and Down state of an OLT PON ports
 func (em *OpenOltEventMgr) oltIntfOperIndication(ctx context.Context, ifindication *oop.IntfOperIndication, deviceID string, raisedTs int64) {
-	portNo := IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT)
+	portNo := plt.IntfIDToPortNo(ifindication.IntfId, voltha.Port_PON_OLT)
 	if port, err := em.handler.getPortFromCore(ctx, &ic.PortFilter{
 		DeviceId: deviceID,
 		Port:     portNo,
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index bd0efd2..852e070 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -31,6 +31,7 @@
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	tp "github.com/opencord/voltha-lib-go/v7/pkg/techprofile"
 	rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
 	"github.com/opencord/voltha-protos/v5/go/common"
@@ -244,9 +245,9 @@
 
 	// Create a slice of buffered channels for handling concurrent flows per ONU.
 	// The additional entry (+1) is to handle the NNI trap flows on a separate channel from individual ONUs channel
-	flowMgr.incomingFlows = make([]chan flowControlBlock, MaxOnusPerPon+1)
-	flowMgr.stopFlowHandlerRoutine = make([]chan bool, MaxOnusPerPon+1)
-	flowMgr.flowHandlerRoutineActive = make([]bool, MaxOnusPerPon+1)
+	flowMgr.incomingFlows = make([]chan flowControlBlock, plt.MaxOnusPerPon+1)
+	flowMgr.stopFlowHandlerRoutine = make([]chan bool, plt.MaxOnusPerPon+1)
+	flowMgr.flowHandlerRoutineActive = make([]bool, plt.MaxOnusPerPon+1)
 	for i := range flowMgr.incomingFlows {
 		flowMgr.incomingFlows[i] = make(chan flowControlBlock, maxConcurrentFlowsPerOnu)
 		flowMgr.stopFlowHandlerRoutine[i] = make(chan bool, 1)
@@ -989,7 +990,7 @@
 	if vlan, exists := downlinkClassifier[VlanVid]; exists {
 		if vlan.(uint32) == (uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 4000) { //private VLAN given by core
 			if metadata, exists := downlinkClassifier[Metadata]; exists { // inport is filled in metadata by core
-				if uint32(metadata.(uint64)) == MkUniPortNum(ctx, flowContext.intfID, flowContext.onuID, flowContext.uniID) {
+				if uint32(metadata.(uint64)) == plt.MkUniPortNum(ctx, flowContext.intfID, flowContext.onuID, flowContext.uniID) {
 					logger.Infow(ctx, "ignoring-dl-trap-device-flow-from-core",
 						log.Fields{
 							"flow":      flowContext.logicalFlow,
@@ -1488,7 +1489,7 @@
 	for _, tpID := range tpIDList {
 
 		// Force cleanup scheduler/queues -- start
-		uniPortNum := MkUniPortNum(ctx, intfID, onuID, uniID)
+		uniPortNum := plt.MkUniPortNum(ctx, intfID, onuID, uniID)
 		uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID))
 		tpPath := f.getTPpath(ctx, intfID, uni, tpID)
 		tpInst, err := f.techprofile.GetTPInstance(ctx, tpPath)
@@ -1638,7 +1639,7 @@
 	var uniID = -1
 	var gemPortID = -1
 
-	networkInterfaceID, err := IntfIDFromNniPortNum(ctx, portNo)
+	networkInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, portNo)
 	if err != nil {
 		return olterrors.NewErrInvalidValue(log.Fields{"nni-port-number": portNo}, err).Log()
 	}
@@ -1740,7 +1741,7 @@
 			"pon-port":  intfID,
 			"onu-id":    onuID,
 			"device-id": f.deviceHandler.device.Id})
-	parentPortNo := IntfIDToPortNo(intfID, voltha.Port_PON_OLT)
+	parentPortNo := plt.IntfIDToPortNo(intfID, voltha.Port_PON_OLT)
 	onuDevice, err := f.deviceHandler.GetChildDevice(ctx, parentPortNo, onuID)
 	if err != nil {
 		return nil, olterrors.NewErrNotFound("onu",
@@ -2017,7 +2018,7 @@
 
 	classifierInfo := make(map[string]interface{})
 
-	portNum, Intf, onu, uni, inPort, ethType, err := FlowExtractInfo(ctx, flow, flowDirection)
+	portNum, Intf, onu, uni, inPort, ethType, err := plt.FlowExtractInfo(ctx, flow, flowDirection)
 	if err != nil {
 		logger.Error(ctx, err)
 		return err
@@ -2053,7 +2054,7 @@
 		onuID = -1
 		uniID = -1
 		logger.Debug(ctx, "trap-on-nni-flow-set-oni--uni-to- -1")
-		Intf, err = IntfIDFromNniPortNum(ctx, inPort)
+		Intf, err = plt.IntfIDFromNniPortNum(ctx, inPort)
 		if err != nil {
 			logger.Errorw(ctx, "invalid-in-port-number",
 				log.Fields{
@@ -2126,7 +2127,7 @@
 	if flows.HasGroup(flow) {
 		direction = Multicast
 		return f.clearFlowFromDeviceAndResourceManager(ctx, flow, direction)
-	} else if IsUpstream(actionInfo[Output].(uint32)) {
+	} else if plt.IsUpstream(actionInfo[Output].(uint32)) {
 		direction = Upstream
 	} else {
 		direction = Downstream
@@ -2140,7 +2141,7 @@
 
 //isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise
 func isIgmpTrapDownstreamFlow(classifierInfo map[string]interface{}) bool {
-	if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_ETHERNET_NNI {
+	if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_ETHERNET_NNI {
 		if ethType, ok := classifierInfo[EthType]; ok {
 			if ethType.(uint32) == IPv4EthType {
 				if ipProto, ok := classifierInfo[IPProto]; ok {
@@ -2173,7 +2174,7 @@
 	inPort, outPort := getPorts(flow)
 	var onuID uint32
 	if inPort != InvalidPort && outPort != InvalidPort {
-		_, _, onuID, _ = ExtractAccessFromFlow(inPort, outPort)
+		_, _, onuID, _ = plt.ExtractAccessFromFlow(inPort, outPort)
 	}
 	if f.flowHandlerRoutineActive[onuID] {
 		// inPort or outPort is InvalidPort for trap-from-nni flows.
@@ -2266,7 +2267,7 @@
 		log.Fields{
 			"classifierinfo_inport": classifierInfo[InPort],
 			"action_output":         actionInfo[Output]})
-	portNo, intfID, onuID, uniID := ExtractAccessFromFlow(classifierInfo[InPort].(uint32), actionInfo[Output].(uint32))
+	portNo, intfID, onuID, uniID := plt.ExtractAccessFromFlow(classifierInfo[InPort].(uint32), actionInfo[Output].(uint32))
 
 	if ethType, ok := classifierInfo[EthType]; ok {
 		if ethType.(uint32) == LldpEthType {
@@ -2274,7 +2275,7 @@
 			return f.addLLDPFlow(ctx, flow, portNo)
 		}
 		if ethType.(uint32) == PPPoEDEthType {
-			if voltha.Port_ETHERNET_NNI == IntfIDToPortTypeName(classifierInfo[InPort].(uint32)) {
+			if voltha.Port_ETHERNET_NNI == plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)) {
 				logger.Debug(ctx, "trap-pppoed-from-nni-flow")
 				return f.addTrapFlowOnNNI(ctx, flow, classifierInfo, portNo)
 			}
@@ -2330,7 +2331,7 @@
 			"intf-id": intfID,
 			"onu-id":  onuID,
 			"uni-id":  uniID})
-	if IsUpstream(actionInfo[Output].(uint32)) {
+	if plt.IsUpstream(actionInfo[Output].(uint32)) {
 		UsMeterID = flows.GetMeterIdFromFlow(flow)
 		logger.Debugw(ctx, "upstream-flow-meter-id", log.Fields{"us-meter-id": UsMeterID})
 	} else {
@@ -2398,7 +2399,7 @@
 //getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise
 func (f *OpenOltFlowMgr) getNNIInterfaceIDOfMulticastFlow(ctx context.Context, classifierInfo map[string]interface{}) (uint32, error) {
 	if inPort, ok := classifierInfo[InPort]; ok {
-		nniInterfaceID, err := IntfIDFromNniPortNum(ctx, inPort.(uint32))
+		nniInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, inPort.(uint32))
 		if err != nil {
 			return 0, olterrors.NewErrInvalidValue(log.Fields{"nni-in-port-number": inPort}, err)
 		}
@@ -2570,12 +2571,12 @@
 		if packetIn.PortNo != 0 {
 			logicalPortNum = packetIn.PortNo
 		} else {
-			logicalPortNum = MkUniPortNum(ctx, packetIn.IntfId, onuID, uniID)
+			logicalPortNum = plt.MkUniPortNum(ctx, packetIn.IntfId, onuID, uniID)
 		}
 		// Store the gem port through which the packet_in came. Use the same gem port for packet_out
 		f.UpdateGemPortForPktIn(ctx, packetIn.IntfId, onuID, logicalPortNum, packetIn.GemportId, packetIn.Pkt)
 	} else if packetIn.IntfType == "nni" {
-		logicalPortNum = IntfIDToPortNo(packetIn.IntfId, voltha.Port_ETHERNET_NNI)
+		logicalPortNum = plt.IntfIDToPortNo(packetIn.IntfId, voltha.Port_ETHERNET_NNI)
 	}
 
 	if logger.V(log.DebugLevel) {
@@ -2822,7 +2823,7 @@
 	var direction = tp_pb.Direction_UPSTREAM
 	switch TpInst := TpInst.(type) {
 	case *tp_pb.TechProfileInstance:
-		if IsUpstream(actionInfo[Output].(uint32)) {
+		if plt.IsUpstream(actionInfo[Output].(uint32)) {
 			attributes = TpInst.UpstreamGemPortAttributeList
 		} else {
 			attributes = TpInst.DownstreamGemPortAttributeList
@@ -3124,10 +3125,10 @@
 }
 
 func formulateControllerBoundTrapFlowInfo(ctx context.Context, actionInfo, classifierInfo map[string]interface{}, flow *ofp.OfpFlowStats) error {
-	if isControllerFlow := IsControllerBoundFlow(actionInfo[Output].(uint32)); isControllerFlow {
+	if isControllerFlow := plt.IsControllerBoundFlow(actionInfo[Output].(uint32)); isControllerFlow {
 		logger.Debug(ctx, "controller-bound-trap-flows--getting-inport-from-tunnelid")
 		/* Get UNI port/ IN Port from tunnel ID field for upstream controller bound flows  */
-		if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
+		if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				classifierInfo[InPort] = uniPort
 				logger.Debugw(ctx, "upstream-pon-to-controller-flow--inport-in-tunnelid",
@@ -3144,7 +3145,7 @@
 	} else {
 		logger.Debug(ctx, "non-controller-flows--getting-uniport-from-tunnelid")
 		// Downstream flow from NNI to PON port , Use tunnel ID as new OUT port / UNI port
-		if portType := IntfIDToPortTypeName(actionInfo[Output].(uint32)); portType == voltha.Port_PON_OLT {
+		if portType := plt.IntfIDToPortTypeName(actionInfo[Output].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				actionInfo[Output] = uniPort
 				logger.Debugw(ctx, "downstream-nni-to-pon-port-flow, outport-in-tunnelid",
@@ -3158,7 +3159,7 @@
 						"flow":   flow}, nil)
 			}
 			// Upstream flow from PON to NNI port , Use tunnel ID as new IN port / UNI port
-		} else if portType := IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
+		} else if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT {
 			if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 {
 				classifierInfo[InPort] = uniPort
 				logger.Debugw(ctx, "upstream-pon-to-nni-port-flow, inport-in-tunnelid",
@@ -3215,9 +3216,9 @@
 // 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 := IntfIDToPortTypeName(classifier[InPort].(uint32))
+	portType := plt.IntfIDToPortTypeName(classifier[InPort].(uint32))
 	if portType == voltha.Port_PON_OLT {
-		intfID, err := IntfIDFromNniPortNum(ctx, action[Output].(uint32))
+		intfID, err := plt.IntfIDFromNniPortNum(ctx, action[Output].(uint32))
 		if err != nil {
 			logger.Debugw(ctx, "invalid-action-port-number",
 				log.Fields{
@@ -3228,7 +3229,7 @@
 		logger.Infow(ctx, "output-nni-intfId-is", log.Fields{"intf-id": intfID})
 		return intfID, nil
 	} else if portType == voltha.Port_ETHERNET_NNI {
-		intfID, err := IntfIDFromNniPortNum(ctx, classifier[InPort].(uint32))
+		intfID, err := plt.IntfIDFromNniPortNum(ctx, classifier[InPort].(uint32))
 		if err != nil {
 			logger.Debugw(ctx, "invalid-classifier-port-number",
 				log.Fields{
diff --git a/internal/pkg/core/openolt_groupmgr.go b/internal/pkg/core/openolt_groupmgr.go
index ff51041..91f32e3 100644
--- a/internal/pkg/core/openolt_groupmgr.go
+++ b/internal/pkg/core/openolt_groupmgr.go
@@ -20,6 +20,7 @@
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
 	rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
 	ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
@@ -329,7 +330,7 @@
 		logger.Debugw(ctx, "bucket-skipped-since-no-out-port-found-in-it", log.Fields{"ofBucket": ofBucket})
 		return nil
 	}
-	interfaceID := IntfIDFromUniPortNum(outPort)
+	interfaceID := plt.IntfIDFromUniPortNum(outPort)
 	logger.Debugw(ctx, "got-associated-interface-id-of-the-port",
 		log.Fields{
 			"portNumber:":  outPort,
diff --git a/internal/pkg/core/statsmanager.go b/internal/pkg/core/statsmanager.go
index 2257425..6b04481 100755
--- a/internal/pkg/core/statsmanager.go
+++ b/internal/pkg/core/statsmanager.go
@@ -24,6 +24,7 @@
 	"sync"
 	"time"
 
+	plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
@@ -326,7 +327,7 @@
 		PONPorts := make(map[uint32]*PonPort)
 		for i = 0; i < numOfPorts; i++ {
 			PONPort := BuildPortObject(ctx, i, "pon", DeviceID).(*PonPort)
-			PONPorts[PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort
+			PONPorts[plt.PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort
 		}
 		return PONPorts, nil
 	} else {
@@ -349,8 +350,8 @@
 	//This builds a port object which is added to the
 	//appropriate northbound or southbound values
 	if IntfType == "nni" {
-		IntfID := IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
-		nniID := PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
+		IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
+		nniID := plt.PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
 		logger.Debugw(ctx, "interface-type-nni",
 			log.Fields{
 				"nni-id":    nniID,
@@ -359,8 +360,8 @@
 	} else if IntfType == "pon" {
 		// PON ports require a different configuration
 		//  intf_id and pon_id are currently equal.
-		IntfID := IntfIDToPortNo(PortNum, voltha.Port_PON_OLT)
-		PONID := PortNoToIntfID(IntfID, voltha.Port_PON_OLT)
+		IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_PON_OLT)
+		PONID := plt.PortNoToIntfID(IntfID, voltha.Port_PON_OLT)
 		logger.Debugw(ctx, "interface-type-pon",
 			log.Fields{
 				"pon-id":    PONID,
@@ -643,15 +644,15 @@
 	//var err error
 	IntfID := PortStats.IntfId
 
-	if (IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
-		(IntfID < IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
+	if (plt.IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
+		(IntfID < plt.IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
 		/*
 		   for this release we are only interested in the first NNI for
 		   Northbound.
 		   we are not using the other 3
 		*/
 		return
-	} else if IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
+	} else if plt.IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
 
 		var portNNIStat NniPort
 		portNNIStat.IntfID = IntfID
@@ -673,7 +674,7 @@
 	}
 	for i := uint32(0); i < NumPonPorts; i++ {
 
-		if IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
+		if plt.IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
 			var portPonStat PonPort
 			portPonStat.IntfID = IntfID
 			portPonStat.PortNum = i
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/common.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/common.go
new file mode 100644
index 0000000..dbef567
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/common.go
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package platform
+
+import (
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+)
+
+var logger log.CLogger
+
+func init() {
+	// Setup this package so that it's log level can be modified at run time
+	var err error
+	logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{})
+	if err != nil {
+		panic(err)
+	}
+}
diff --git a/internal/pkg/core/olt_platform.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go
similarity index 87%
rename from internal/pkg/core/olt_platform.go
rename to vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go
index f9b735f..470d4a9 100644
--- a/internal/pkg/core/olt_platform.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go
@@ -14,45 +14,20 @@
  * limitations under the License.
  */
 
-//Package core provides the utility for olt devices, flows and statistics
-package core
+package platform
 
 import (
 	"context"
 
 	"github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
-	"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
 	ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
 	"github.com/opencord/voltha-protos/v5/go/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
 )
 
 /*=====================================================================
-
-@TODO: Looks like this Flow id concept below is not used anywhere
-       Propose to remove the below documentation of Flow Id on confirmation
-       of the same
-
-Flow id
-
-    Identifies a flow within a single OLT
-    Flow Id is unique per OLT
-    Multiple GEM ports can map to same flow id
-
-     13    11              4      0
-    +--------+--------------+------+
-    | pon id |    onu id    | Flow |
-    |        |              | idx  |
-    +--------+--------------+------+
-
-    14 bits = 16384 flows (per OLT).
-
-    pon id = 4 bits = 16 PON ports
-    onu id = 7 bits = 128 ONUss per PON port
-    Flow index = 3 bits = 4 bi-directional flows per ONU
-                        = 8 uni-directional flows per ONU
-
-
 Logical (OF) UNI port number
 
     OpenFlow port number corresponding to PON UNI
@@ -116,6 +91,8 @@
 	minPonIntfPortNum = ponIntfMarkerValue << ponIntfMarkerPos
 	// maxPonIntfPortNum stores the maximum pon port number
 	maxPonIntfPortNum = (ponIntfMarkerValue << ponIntfMarkerPos) | (1 << bitsForPONID)
+	upstream          = "upstream"
+	downstream        = "downstream"
 )
 
 //MinUpstreamPortID value
@@ -176,7 +153,7 @@
 func IntfIDFromNniPortNum(ctx context.Context, portNum uint32) (uint32, error) {
 	if portNum < minNniIntPortNum || portNum > maxNniPortNum {
 		logger.Errorw(ctx, "nniportnumber-is-not-in-valid-range", log.Fields{"portnum": portNum})
-		return uint32(0), olterrors.ErrInvalidPortRange
+		return uint32(0), status.Errorf(codes.InvalidArgument, "nni-port-number-out-of-range:%d", portNum)
 	}
 	return (portNum & 0xFFFF), nil
 }
@@ -185,7 +162,7 @@
 func IntfIDFromPonPortNum(ctx context.Context, portNum uint32) (uint32, error) {
 	if portNum < minPonIntfPortNum || portNum > maxPonIntfPortNum {
 		logger.Errorw(ctx, "ponportnumber-is-not-in-valid-range", log.Fields{"portnum": portNum})
-		return uint32(0), olterrors.ErrInvalidPortRange
+		return uint32(0), status.Errorf(codes.InvalidArgument, "invalid-pon-port-number:%d", portNum)
 	}
 	return (portNum & 0x7FFF), nil
 }
@@ -243,7 +220,7 @@
 	var inPort uint32
 	var ethType uint32
 
-	if flowDirection == "upstream" {
+	if flowDirection == upstream {
 		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
 			for _, field := range flows.GetOfbFields(flow) {
 				if field.GetType() == flows.IN_PORT {
@@ -252,7 +229,7 @@
 				}
 			}
 		}
-	} else if flowDirection == "downstream" {
+	} else if flowDirection == downstream {
 		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
 			for _, field := range flows.GetOfbFields(flow) {
 				if field.GetType() == flows.METADATA {
@@ -274,7 +251,7 @@
 	}
 
 	if uniPortNo == 0 {
-		return 0, 0, 0, 0, 0, 0, olterrors.NewErrNotFound("pon-interface", log.Fields{"flow-direction": flowDirection}, nil)
+		return 0, 0, 0, 0, 0, 0, status.Errorf(codes.NotFound, "uni-not-found-flow-diraction:%s", flowDirection)
 	}
 
 	ponIntf = IntfIDFromUniPortNum(uniPortNo)
diff --git a/vendor/modules.txt b/vendor/modules.txt
index b0a99c3..85fb517 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -114,7 +114,7 @@
 github.com/klauspost/compress/huff0
 github.com/klauspost/compress/zstd
 github.com/klauspost/compress/zstd/internal/xxhash
-# github.com/opencord/voltha-lib-go/v7 v7.0.0
+# github.com/opencord/voltha-lib-go/v7 v7.0.1
 ## explicit
 github.com/opencord/voltha-lib-go/v7/pkg/config
 github.com/opencord/voltha-lib-go/v7/pkg/db
@@ -127,6 +127,7 @@
 github.com/opencord/voltha-lib-go/v7/pkg/log
 github.com/opencord/voltha-lib-go/v7/pkg/meters
 github.com/opencord/voltha-lib-go/v7/pkg/mocks/grpc
+github.com/opencord/voltha-lib-go/v7/pkg/platform
 github.com/opencord/voltha-lib-go/v7/pkg/pmmetrics
 github.com/opencord/voltha-lib-go/v7/pkg/ponresourcemanager
 github.com/opencord/voltha-lib-go/v7/pkg/probe