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

Change-Id: Ic28d8187fe2fc7ddcd0af8f582898eb6e1fddce9
diff --git a/VERSION b/VERSION
index 9559721..62a6f53 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.2-dev233
+2.0.2-dev234
diff --git a/go.mod b/go.mod
index 4e92e23..f93cba4 100644
--- a/go.mod
+++ b/go.mod
@@ -16,7 +16,7 @@
 	github.com/google/gopacket v1.1.17
 	github.com/looplab/fsm v0.2.0
 	github.com/opencord/omci-lib-go v1.3.3
-	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
 	github.com/stretchr/testify v1.7.0
 	google.golang.org/grpc v1.41.0
diff --git a/go.sum b/go.sum
index dadc804..6962fed 100644
--- a/go.sum
+++ b/go.sum
@@ -193,8 +193,8 @@
 github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
 github.com/opencord/omci-lib-go v1.3.3 h1:BzywkXVHSphhpl9hHHOJxc9IQ7MrzIB3aY3LG1wbwuk=
 github.com/opencord/omci-lib-go v1.3.3/go.mod h1:moNk4j00XaM3olsu4a8lRAqGmcZJoyIbxtSr+VERLq4=
-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 537533c..216c09d 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -37,6 +37,7 @@
 	flow "github.com/opencord/voltha-lib-go/v7/pkg/flows"
 	vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
 	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	platform "github.com/opencord/voltha-lib-go/v7/pkg/platform"
 	almgr "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/almgr"
 	avcfg "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/avcfg"
 	cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common"
@@ -913,7 +914,7 @@
 
 		var uniPort *cmn.OnuUniPort
 		var exist bool
-		uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
+		uniNo := platform.MkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
 		if uniPort, exist = dh.uniEntityMap[uniNo]; !exist {
 			logger.Errorw(ctx, "reconciling - OnuUniPort data not found  - terminate reconcilement",
 				log.Fields{"uniNo": uniNo, "device-id": dh.DeviceID})
@@ -2348,7 +2349,7 @@
 
 func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType cmn.UniPortType) {
 	// parameters are IntfId, OnuId, uniId
-	uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
+	uniNo := platform.MkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
 		uint32(aUniID))
 	if _, present := dh.uniEntityMap[uniNo]; present {
 		logger.Warnw(ctx, "OnuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
diff --git a/internal/pkg/core/platform.go b/internal/pkg/core/platform.go
deleted file mode 100755
index 9430e92..0000000
--- a/internal/pkg/core/platform.go
+++ /dev/null
@@ -1,291 +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 onu devices, flows and statistics
-package core
-
-import "context"
-
-//Attention: this file is more or less a coopy of file olt_platform.go from the voltha-openolt-adapter
-// which includes system wide definitions and thus normally should be stored more centrally (within some voltha libs)!!
-
-/*=====================================================================
-
-@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
-
-     20        12              4      0
-    +--+--------+--------------+------+
-    |0 | pon id |    onu id    |uni id|
-    +--+--------+--------------+------+
-
-    pon id = 8 bits = 256 PON ports
-    onu id = 8 bits = 256 ONUs per PON port
-
-Logical (OF) NNI port number
-
-    OpenFlow port number corresponding to PON NNI
-
-     20                             0
-    +--+----------------------------+
-    |1 |                    intf_id |
-    +--+----------------------------+
-
-    No overlap with UNI port number space
-
-
-PON OLT (OF) port number
-
-    OpenFlow port number corresponding to PON OLT ports
-
-     31     28                                 0
-    +--------+------------------------~~~------+
-    |  0x2   |          pon intf id            |
-    +--------+------------------------~~~------+
-*/
-
-const (
-	// Number of bits for the physical UNI of the ONUs
-	bitsForUniID = 4
-	// Number of bits for the ONU ID
-	bitsForONUID = 8
-	// Number of bits for PON ID
-	bitsForPONID = 8
-	/*
-		// Number of bits to differentiate between UNI and NNI Logical Port
-		bitsForUNINNIDiff = 1
-	*/
-	//maxOnusPerPon is Max number of ONUs on any PON port
-	maxOnusPerPon = (1 << bitsForONUID)
-	//maxPonsPerOlt is Max number of PON ports on any OLT
-	maxPonsPerOlt = (1 << bitsForPONID)
-	//maxUnisPerOnu is the Max number of UNI ports on any ONU
-	maxUnisPerOnu = (1 << bitsForUniID)
-	/*
-		//Bit position where the differentiation bit is located
-		nniUniDiffPos = (bitsForUniID + bitsForONUID + bitsForPONID)
-		//Bit position where the marker for PON port type of OF port is present
-		ponIntfMarkerPos = 28
-		//Value of marker used to distinguish PON port type of OF port
-		ponIntfMarkerValue = 0x2
-		// Number of bits for NNI ID
-		bitsforNNIID = 20
-		// minNniIntPortNum is used to store start range of nni port number (1 << 20) 1048576
-		minNniIntPortNum = (1 << bitsforNNIID)
-		// maxNniPortNum is used to store the maximum range of nni port number ((1 << 21)-1) 2097151
-		maxNniPortNum = ((1 << (bitsforNNIID + 1)) - 1)
-	*/
-)
-
-/*
-//MinUpstreamPortID value
-var minUpstreamPortID = 0xfffd
-
-//MaxUpstreamPortID value
-var maxUpstreamPortID = 0xfffffffd
-
-var controllerPorts = []uint32{0xfffd, 0x7ffffffd, 0xfffffffd}
-*/
-
-//mkUniPortNum returns new UNIportNum based on intfID, onuID and uniID
-func mkUniPortNum(ctx context.Context, intfID, onuID, uniID uint32) uint32 {
-	//extended for checks available in the python onu adapter:!!
-	var limit = int(intfID)
-	if limit > maxPonsPerOlt {
-		logger.Warn(ctx, "Warning: exceeded the MAX pons per OLT")
-	}
-	limit = int(onuID)
-	if limit > maxOnusPerPon {
-		logger.Warn(ctx, "Warning: exceeded the MAX ONUS per PON")
-	}
-	limit = int(uniID)
-	if limit > maxUnisPerOnu {
-		logger.Warn(ctx, "Warning: exceeded the MAX UNIS per ONU")
-	}
-	return (intfID << (bitsForUniID + bitsForONUID)) | (onuID << bitsForUniID) | uniID
-}
-
-/*
-//onuIDFromPortNum returns ONUID derived from portNumber
-func onuIDFromPortNum(portNum uint32) uint32 {
-	return (portNum >> bitsForUniID) & (maxOnusPerPon - 1)
-}
-
-//intfIDFromUniPortNum returns IntfID derived from portNum
-func intfIDFromUniPortNum(portNum uint32) uint32 {
-	return (portNum >> (bitsForUniID + bitsForONUID)) & (maxPonsPerOlt - 1)
-}
-
-//uniIDFromPortNum return UniID derived from portNum
-func uniIDFromPortNum(portNum uint32) uint32 {
-	return (portNum) & (maxUnisPerOnu - 1)
-}
-
-//intfIDToPortNo returns portId derived from intftype, intfId and portType
-func intfIDToPortNo(intfID uint32, intfType voltha.Port_PortType) uint32 {
-	if (intfType) == voltha.Port_ETHERNET_NNI {
-		return (1 << nniUniDiffPos) | intfID
-	}
-	if (intfType) == voltha.Port_PON_OLT {
-		return (ponIntfMarkerValue << ponIntfMarkerPos) | intfID
-	}
-	return 0
-}
-
-//portNoToIntfID returns portnumber derived from interfaceID
-func portNoToIntfID(portno uint32, intfType voltha.Port_PortType) uint32 {
-	if (intfType) == voltha.Port_ETHERNET_NNI {
-		return (1 << nniUniDiffPos) ^ portno
-	}
-	if (intfType) == voltha.Port_PON_OLT {
-		return (ponIntfMarkerValue << ponIntfMarkerPos) ^ portno
-	}
-	return 0
-}
-
-//intfIDFromNniPortNum returns Intf ID derived from portNum
-func intfIDFromNniPortNum(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), errors.New("invalid-port-range") //olterrors.ErrInvalidPortRange
-	}
-	return (portNum & 0xFFFF), nil
-}
-
-//intfIDToPortTypeName returns port type derived from the intfId
-func intfIDToPortTypeName(intfID uint32) voltha.Port_PortType {
-	if ((ponIntfMarkerValue << ponIntfMarkerPos) ^ intfID) < maxPonsPerOlt {
-		return voltha.Port_PON_OLT
-	}
-	if (intfID & (1 << nniUniDiffPos)) == (1 << nniUniDiffPos) {
-		return voltha.Port_ETHERNET_NNI
-	}
-	return voltha.Port_ETHERNET_UNI
-}
-
-//extractAccessFromFlow returns AccessDevice information
-func extractAccessFromFlow(inPort, outPort uint32) (uint32, uint32, uint32, uint32) {
-	if isUpstream(outPort) {
-		return inPort, intfIDFromUniPortNum(inPort), onuIDFromPortNum(inPort), uniIDFromPortNum(inPort)
-	}
-	return outPort, intfIDFromUniPortNum(outPort), onuIDFromPortNum(outPort), uniIDFromPortNum(outPort)
-}
-
-//isUpstream returns true for Upstream and false for downstream
-func isUpstream(outPort uint32) bool {
-	for _, port := range controllerPorts {
-		if port == outPort {
-			return true
-		}
-	}
-	return (outPort & (1 << nniUniDiffPos)) == (1 << nniUniDiffPos)
-}
-
-//isControllerBoundFlow returns true/false
-func isControllerBoundFlow(outPort uint32) bool {
-	for _, port := range controllerPorts {
-		if port == outPort {
-			return true
-		}
-	}
-	return false
-}
-
-//onuIDFromUniPortNum returns onuId from give portNum information.
-func onuIDFromUniPortNum(portNum uint32) uint32 {
-	return (portNum >> bitsForUniID) & (maxOnusPerPon - 1)
-}
-
-//flowExtractInfo fetches uniport from the flow, based on which it gets and returns ponInf, onuID, uniID, inPort and ethType
-func flowExtractInfo(flow *ofp.OfpFlowStats, flowDirection string) (uint32, uint32, uint32, uint32, uint32, uint32, error) {
-	var uniPortNo uint32
-	var ponIntf uint32
-	var onuID uint32
-	var uniID uint32
-	var inPort uint32
-	var ethType uint32
-
-	if flowDirection == "upstream" {
-		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
-			for _, field := range flows.GetOfbFields(flow) {
-				if field.GetType() == flows.IN_PORT {
-					uniPortNo = field.GetPort()
-					break
-				}
-			}
-		}
-	} else if flowDirection == "downstream" {
-		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
-			for _, field := range flows.GetOfbFields(flow) {
-				if field.GetType() == flows.METADATA {
-					for _, action := range flows.GetActions(flow) {
-						if action.Type == flows.OUTPUT {
-							if out := action.GetOutput(); out != nil {
-								uniPortNo = out.GetPort()
-							}
-							break
-						}
-					}
-				} else if field.GetType() == flows.IN_PORT {
-					inPort = field.GetPort()
-				} else if field.GetType() == flows.ETH_TYPE {
-					ethType = field.GetEthType()
-				}
-			}
-		}
-	}
-
-	if uniPortNo == 0 {
-		return 0, 0, 0, 0, 0, 0, errors.New("notFound: pon-interface (flowDirection)")
-		// olterrors.NewErrNotFound("pon-interface", log.Fields{"flow-direction": flowDirection}, nil)
-	}
-
-	ponIntf = intfIDFromUniPortNum(uniPortNo)
-	onuID = onuIDFromUniPortNum(uniPortNo)
-	uniID = uniIDFromPortNum(uniPortNo)
-
-	logger.Debugw(ctx,"flow extract info result",
-		log.Fields{"uniPortNo": uniPortNo, "ponIntf": ponIntf,
-			"onuID": onuID, "uniID": uniID, "inPort": inPort, "ethType": ethType})
-
-	return uniPortNo, ponIntf, onuID, uniID, inPort, ethType, nil
-}
-*/
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/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go
new file mode 100644
index 0000000..470d4a9
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/platform/platform.go
@@ -0,0 +1,271 @@
+/*
+ * 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 platform
+
+import (
+	"context"
+
+	"github.com/opencord/voltha-lib-go/v7/pkg/flows"
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
+	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"
+)
+
+/*=====================================================================
+Logical (OF) UNI port number
+
+    OpenFlow port number corresponding to PON UNI
+
+     20        12              4      0
+    +--+--------+--------------+------+
+    |0 | pon id |    onu id    |uni id|
+    +--+--------+--------------+------+
+
+    pon id = 8 bits = 256 PON ports
+    onu id = 8 bits = 256 ONUs per PON port
+
+Logical (OF) NNI port number
+
+    OpenFlow port number corresponding to PON NNI
+
+     20                             0
+    +--+----------------------------+
+    |1 |                    intf_id |
+    +--+----------------------------+
+
+    No overlap with UNI port number space
+
+
+PON OLT (OF) port number
+
+    OpenFlow port number corresponding to PON OLT ports
+
+     31     28                                 0
+    +--------+------------------------~~~------+
+    |  0x2   |          pon intf id            |
+    +--------+------------------------~~~------+
+*/
+
+const (
+	// Number of bits for the physical UNI of the ONUs
+	bitsForUniID = 4
+	// Number of bits for the ONU ID
+	bitsForONUID = 8
+	// Number of bits for PON ID
+	bitsForPONID = 8
+	// MaxOnusPerPon is Max number of ONUs on any PON port
+	MaxOnusPerPon = (1 << bitsForONUID)
+	// MaxPonsPerOlt is Max number of PON ports on any OLT
+	MaxPonsPerOlt = (1 << bitsForPONID)
+	// MaxUnisPerOnu is the Max number of UNI ports on any ONU
+	MaxUnisPerOnu = (1 << bitsForUniID)
+	// Bit position where the differentiation bit is located
+	nniUniDiffPos = (bitsForUniID + bitsForONUID + bitsForPONID)
+	// Bit position where the marker for PON port type of OF port is present
+	ponIntfMarkerPos = 28
+	// Value of marker used to distinguish PON port type of OF port
+	ponIntfMarkerValue = 0x2
+	// Number of bits for NNI ID
+	bitsforNNIID = 20
+	// minNniIntPortNum is used to store start range of nni port number (1 << 20) 1048576
+	minNniIntPortNum = (1 << bitsforNNIID)
+	// maxNniPortNum is used to store the maximum range of nni port number ((1 << 21)-1) 2097151
+	maxNniPortNum = ((1 << (bitsforNNIID + 1)) - 1)
+	// minPonIntfPortNum stores the minimum pon port number
+	minPonIntfPortNum = ponIntfMarkerValue << ponIntfMarkerPos
+	// maxPonIntfPortNum stores the maximum pon port number
+	maxPonIntfPortNum = (ponIntfMarkerValue << ponIntfMarkerPos) | (1 << bitsForPONID)
+	upstream          = "upstream"
+	downstream        = "downstream"
+)
+
+//MinUpstreamPortID value
+var MinUpstreamPortID = 0xfffd
+
+//MaxUpstreamPortID value
+var MaxUpstreamPortID = 0xfffffffd
+
+var controllerPorts = []uint32{0xfffd, 0x7ffffffd, 0xfffffffd}
+
+//MkUniPortNum returns new UNIportNum based on intfID, inuID and uniID
+func MkUniPortNum(ctx context.Context, intfID, onuID, uniID uint32) uint32 {
+	var limit = int(onuID)
+	if limit > MaxOnusPerPon {
+		logger.Warn(ctx, "exceeded-the-max-onus-per-pon")
+	}
+	return (intfID << (bitsForUniID + bitsForONUID)) | (onuID << bitsForUniID) | uniID
+}
+
+//OnuIDFromPortNum returns ONUID derived from portNumber
+func OnuIDFromPortNum(portNum uint32) uint32 {
+	return (portNum >> bitsForUniID) & (MaxOnusPerPon - 1)
+}
+
+//IntfIDFromUniPortNum returns IntfID derived from portNum
+func IntfIDFromUniPortNum(portNum uint32) uint32 {
+	return (portNum >> (bitsForUniID + bitsForONUID)) & (MaxPonsPerOlt - 1)
+}
+
+//UniIDFromPortNum return UniID derived from portNum
+func UniIDFromPortNum(portNum uint32) uint32 {
+	return (portNum) & (MaxUnisPerOnu - 1)
+}
+
+//IntfIDToPortNo returns portId derived from intftype, intfId and portType
+func IntfIDToPortNo(intfID uint32, intfType voltha.Port_PortType) uint32 {
+	if (intfType) == voltha.Port_ETHERNET_NNI {
+		return (1 << nniUniDiffPos) | intfID
+	}
+	if (intfType) == voltha.Port_PON_OLT {
+		return (ponIntfMarkerValue << ponIntfMarkerPos) | intfID
+	}
+	return 0
+}
+
+//PortNoToIntfID returns portnumber derived from interfaceID
+func PortNoToIntfID(portno uint32, intfType voltha.Port_PortType) uint32 {
+	if (intfType) == voltha.Port_ETHERNET_NNI {
+		return (1 << nniUniDiffPos) ^ portno
+	}
+	if (intfType) == voltha.Port_PON_OLT {
+		return (ponIntfMarkerValue << ponIntfMarkerPos) ^ portno
+	}
+	return 0
+}
+
+//IntfIDFromNniPortNum returns Intf ID derived from portNum
+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), status.Errorf(codes.InvalidArgument, "nni-port-number-out-of-range:%d", portNum)
+	}
+	return (portNum & 0xFFFF), nil
+}
+
+//IntfIDFromPonPortNum returns Intf ID derived from portNum
+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), status.Errorf(codes.InvalidArgument, "invalid-pon-port-number:%d", portNum)
+	}
+	return (portNum & 0x7FFF), nil
+}
+
+//IntfIDToPortTypeName returns port type derived from the intfId
+func IntfIDToPortTypeName(intfID uint32) voltha.Port_PortType {
+	if ((ponIntfMarkerValue << ponIntfMarkerPos) ^ intfID) < MaxPonsPerOlt {
+		return voltha.Port_PON_OLT
+	}
+	if (intfID & (1 << nniUniDiffPos)) == (1 << nniUniDiffPos) {
+		return voltha.Port_ETHERNET_NNI
+	}
+	return voltha.Port_ETHERNET_UNI
+}
+
+//ExtractAccessFromFlow returns AccessDevice information
+func ExtractAccessFromFlow(inPort, outPort uint32) (uint32, uint32, uint32, uint32) {
+	if IsUpstream(outPort) {
+		return inPort, IntfIDFromUniPortNum(inPort), OnuIDFromPortNum(inPort), UniIDFromPortNum(inPort)
+	}
+	return outPort, IntfIDFromUniPortNum(outPort), OnuIDFromPortNum(outPort), UniIDFromPortNum(outPort)
+}
+
+//IsUpstream returns true for Upstream and false for downstream
+func IsUpstream(outPort uint32) bool {
+	for _, port := range controllerPorts {
+		if port == outPort {
+			return true
+		}
+	}
+	return (outPort & (1 << nniUniDiffPos)) == (1 << nniUniDiffPos)
+}
+
+//IsControllerBoundFlow returns true/false
+func IsControllerBoundFlow(outPort uint32) bool {
+	for _, port := range controllerPorts {
+		if port == outPort {
+			return true
+		}
+	}
+	return false
+}
+
+//OnuIDFromUniPortNum returns onuId from give portNum information.
+func OnuIDFromUniPortNum(portNum uint32) uint32 {
+	return (portNum >> bitsForUniID) & (MaxOnusPerPon - 1)
+}
+
+//FlowExtractInfo fetches uniport from the flow, based on which it gets and returns ponInf, onuID, uniID, inPort and ethType
+func FlowExtractInfo(ctx context.Context, flow *ofp.OfpFlowStats, flowDirection string) (uint32, uint32, uint32, uint32, uint32, uint32, error) {
+	var uniPortNo uint32
+	var ponIntf uint32
+	var onuID uint32
+	var uniID uint32
+	var inPort uint32
+	var ethType uint32
+
+	if flowDirection == upstream {
+		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
+			for _, field := range flows.GetOfbFields(flow) {
+				if field.GetType() == flows.IN_PORT {
+					uniPortNo = field.GetPort()
+					break
+				}
+			}
+		}
+	} else if flowDirection == downstream {
+		if uniPortNo = flows.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
+			for _, field := range flows.GetOfbFields(flow) {
+				if field.GetType() == flows.METADATA {
+					for _, action := range flows.GetActions(flow) {
+						if action.Type == flows.OUTPUT {
+							if out := action.GetOutput(); out != nil {
+								uniPortNo = out.GetPort()
+							}
+							break
+						}
+					}
+				} else if field.GetType() == flows.IN_PORT {
+					inPort = field.GetPort()
+				} else if field.GetType() == flows.ETH_TYPE {
+					ethType = field.GetEthType()
+				}
+			}
+		}
+	}
+
+	if uniPortNo == 0 {
+		return 0, 0, 0, 0, 0, 0, status.Errorf(codes.NotFound, "uni-not-found-flow-diraction:%s", flowDirection)
+	}
+
+	ponIntf = IntfIDFromUniPortNum(uniPortNo)
+	onuID = OnuIDFromUniPortNum(uniPortNo)
+	uniID = UniIDFromPortNum(uniPortNo)
+
+	logger.Debugw(ctx, "flow-extract-info-result",
+		log.Fields{
+			"uniportno": uniPortNo,
+			"pon-intf":  ponIntf,
+			"onu-id":    onuID,
+			"uni-id":    uniID,
+			"inport":    inPort,
+			"ethtype":   ethType})
+
+	return uniPortNo, ponIntf, onuID, uniID, inPort, ethType, nil
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 308412b..0d44c95 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -125,7 +125,7 @@
 ## explicit
 github.com/opencord/omci-lib-go
 github.com/opencord/omci-lib-go/generated
-# 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
@@ -137,6 +137,7 @@
 github.com/opencord/voltha-lib-go/v7/pkg/kafka
 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/platform
 github.com/opencord/voltha-lib-go/v7/pkg/probe
 github.com/opencord/voltha-lib-go/v7/pkg/version
 # github.com/opencord/voltha-protos/v5 v5.0.0