VOL-4413 Apply port-number changes in voltha-lib to components
Change-Id: I704a6659be19f879259cdc29c035fb2e920207bf
diff --git a/go.mod b/go.mod
index e40a045..ae7e2e8 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.1
+ github.com/opencord/voltha-lib-go/v7 v7.0.4
github.com/opencord/voltha-protos/v5 v5.0.1
github.com/stretchr/testify v1.7.0
google.golang.org/grpc v1.41.0
diff --git a/go.sum b/go.sum
index 30698ac..e30b4f3 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.1 h1:3rwfJL+IalcWp/JzH0yDXv+tkPKBjz9b6GA5q0s16TQ=
-github.com/opencord/voltha-lib-go/v7 v7.0.1/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
+github.com/opencord/voltha-lib-go/v7 v7.0.4 h1:nVVRkEZyfEkGYewfgmO3NzIAIVdm8G/vVyEaCUwYW6g=
+github.com/opencord/voltha-lib-go/v7 v7.0.4/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
github.com/opencord/voltha-protos/v5 v5.0.0/go.mod h1:uVKXQB499Ir6G+rc47dSThNja1S4Vy3h9JLSDuJGmzI=
github.com/opencord/voltha-protos/v5 v5.0.1 h1:mHpCEqPy0CRMn4plrZ2XAktn8P6UGWkWIQoCUJa6+PE=
github.com/opencord/voltha-protos/v5 v5.0.1/go.mod h1:uVKXQB499Ir6G+rc47dSThNja1S4Vy3h9JLSDuJGmzI=
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
index de649d6..a3dec75 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
@@ -228,8 +228,8 @@
isGrpcMonitorKeyPresentInContext(ctx) {
c.stateLock.Lock()
if c.state == stateConnected {
- logger.Warnw(context.Background(), "sending-disconnect-event", log.Fields{"endpoint": c.apiEndPoint, "error": err})
c.state = stateDisconnected
+ logger.Warnw(context.Background(), "sending-disconnect-event", log.Fields{"endpoint": c.apiEndPoint, "error": err, "curr-state": stateConnected, "new-state": c.state})
c.events <- eventDisconnected
}
c.stateLock.Unlock()
@@ -290,6 +290,9 @@
c.activeCh = make(chan struct{}, 10)
c.activeChMutex.Unlock()
+ grpcMonitorCheckRunning := false
+ var grpcMonitorCheckRunningLock sync.RWMutex
+
// Interval to wait for no activity before probing the connection
timeout := c.monitorInterval
loop:
@@ -298,11 +301,14 @@
select {
case <-c.activeCh:
- logger.Debugw(ctx, "received-active-notification", log.Fields{"endpoint": c.apiEndPoint})
+ logger.Debugw(ctx, "endpoint-reachable", log.Fields{"endpoint": c.apiEndPoint})
// Reset timer
if !timeoutTimer.Stop() {
- <-timeoutTimer.C
+ select {
+ case <-timeoutTimer.C:
+ default:
+ }
}
case <-ctx.Done():
@@ -312,10 +318,21 @@
// Trigger an activity check if the state is connected. If the state is not connected then there is already
// a backoff retry mechanism in place to retry establishing connection.
c.stateLock.RLock()
- runCheck := c.state == stateConnected
+ grpcMonitorCheckRunningLock.RLock()
+ runCheck := (c.state == stateConnected) && !grpcMonitorCheckRunning
+ grpcMonitorCheckRunningLock.RUnlock()
c.stateLock.RUnlock()
if runCheck {
go func() {
+ grpcMonitorCheckRunningLock.Lock()
+ if grpcMonitorCheckRunning {
+ grpcMonitorCheckRunningLock.Unlock()
+ logger.Debugw(ctx, "connection-check-already-in-progress", log.Fields{"api-endpoint": c.apiEndPoint})
+ return
+ }
+ grpcMonitorCheckRunning = true
+ grpcMonitorCheckRunningLock.Unlock()
+
logger.Debugw(ctx, "connection-check-start", log.Fields{"api-endpoint": c.apiEndPoint})
subCtx, cancel := context.WithTimeout(ctx, c.backoffMaxInterval)
defer cancel()
@@ -326,6 +343,9 @@
response := handler(subCtx, c.connection)
logger.Debugw(ctx, "connection-check-response", log.Fields{"api-endpoint": c.apiEndPoint, "up": response != nil})
}
+ grpcMonitorCheckRunningLock.Lock()
+ grpcMonitorCheckRunning = false
+ grpcMonitorCheckRunningLock.Unlock()
}()
}
}
@@ -362,9 +382,8 @@
logger.Debugw(ctx, "received-event", log.Fields{"event": event, "endpoint": c.apiEndPoint})
switch event {
case eventConnecting:
- logger.Debugw(ctx, "connection-start", log.Fields{"endpoint": c.apiEndPoint, "attempts": attempt})
-
c.stateLock.Lock()
+ logger.Debugw(ctx, "connection-start", log.Fields{"endpoint": c.apiEndPoint, "attempts": attempt, "curr-state": c.state})
if c.state == stateConnected {
c.state = stateDisconnected
}
@@ -393,9 +412,9 @@
c.stateLock.Unlock()
case eventConnected:
- logger.Debugw(ctx, "endpoint-connected", log.Fields{"endpoint": c.apiEndPoint})
attempt = 1
c.stateLock.Lock()
+ logger.Debugw(ctx, "endpoint-connected", log.Fields{"endpoint": c.apiEndPoint, "curr-state": c.state})
if c.state != stateConnected {
c.state = stateConnected
if initialConnection {
@@ -418,7 +437,9 @@
if p != nil {
p.UpdateStatus(ctx, c.apiEndPoint, probe.ServiceStatusNotReady)
}
- logger.Debugw(ctx, "endpoint-disconnected", log.Fields{"endpoint": c.apiEndPoint, "status": c.state})
+ c.stateLock.RLock()
+ logger.Debugw(ctx, "endpoint-disconnected", log.Fields{"endpoint": c.apiEndPoint, "curr-state": c.state})
+ c.stateLock.RUnlock()
// Try to connect again
c.events <- eventConnecting
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
index 470d4a9..688ccd8 100644
--- 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
@@ -32,19 +32,20 @@
OpenFlow port number corresponding to PON UNI
- 20 12 4 0
- +--+--------+--------------+------+
- |0 | pon id | onu id |uni id|
- +--+--------+--------------+------+
+ 24 16 8 0
+ +--+--------+----------+----------+
+ |0 | pon id | onu id | uni id |
+ +--+--------+----------+----------+
pon id = 8 bits = 256 PON ports
onu id = 8 bits = 256 ONUs per PON port
+ uni id = 8 bits = 256 UNIs per ONU
Logical (OF) NNI port number
OpenFlow port number corresponding to PON NNI
- 20 0
+ 24 0
+--+----------------------------+
|1 | intf_id |
+--+----------------------------+
@@ -64,7 +65,7 @@
const (
// Number of bits for the physical UNI of the ONUs
- bitsForUniID = 4
+ bitsForUniID = 8
// Number of bits for the ONU ID
bitsForONUID = 8
// Number of bits for PON ID
@@ -81,33 +82,39 @@
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
+ // minNniPortNum is used to store start range of nni port number (1 << 24) 16777216
+ minNniPortNum = (1 << nniUniDiffPos)
+ // maxNniPortNum is used to store the maximum range of nni port number ((1 << 25)-1) 33554431
+ maxNniPortNum = ((1 << (nniUniDiffPos + 1)) - 1)
+ // minPonIntfPortNum stores the minimum pon port number (536870912)
minPonIntfPortNum = ponIntfMarkerValue << ponIntfMarkerPos
- // maxPonIntfPortNum stores the maximum pon port number
- maxPonIntfPortNum = (ponIntfMarkerValue << ponIntfMarkerPos) | (1 << bitsForPONID)
+ // maxPonIntfPortNum stores the maximum pon port number (536871167)
+ maxPonIntfPortNum = ((ponIntfMarkerValue << ponIntfMarkerPos) | (1 << bitsForPONID)) - 1
upstream = "upstream"
downstream = "downstream"
+ //Technology Profiles ID start value
+ TpIDStart = 64
+ //Technology Profiles ID end value
+ TpIDEnd = 256
+ //Number of Technology Profiles can be defined.
+ TpRange = TpIDEnd - TpIDStart
)
-//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)
+ 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, "exceeded-the-max-onus-per-pon")
+ 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
}
@@ -151,11 +158,11 @@
//IntfIDFromNniPortNum returns Intf ID derived from portNum
func IntfIDFromNniPortNum(ctx context.Context, portNum uint32) (uint32, error) {
- if portNum < minNniIntPortNum || portNum > maxNniPortNum {
+ if portNum < minNniPortNum || 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
+ return (portNum & (minNniPortNum - 1)), nil
}
//IntfIDFromPonPortNum returns Intf ID derived from portNum
@@ -164,7 +171,7 @@
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
+ return (portNum & ((1 << ponIntfMarkerPos) - 1)), nil
}
//IntfIDToPortTypeName returns port type derived from the intfId
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 9cbe32a..f412695 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.1
+# github.com/opencord/voltha-lib-go/v7 v7.0.4
## explicit
github.com/opencord/voltha-lib-go/v7/pkg/config
github.com/opencord/voltha-lib-go/v7/pkg/db