VOL-1878 : Support for LLDP trap flow in OpenOLT adapter
Changes are done to handle LLDP flow implementation.
This commit has dependency on voltha-go, so that needs to
be merged first. Please find the review link
https://gerrit.opencord.org/#/c/15062/
Rebased and fixed sca issue.
Change-Id: I4ce886f68f6f90767eb73cbfa9bd5a25fbcbfb08
diff --git a/adaptercore/olt_platform.go b/adaptercore/olt_platform.go
index 5540392..a75c25d 100644
--- a/adaptercore/olt_platform.go
+++ b/adaptercore/olt_platform.go
@@ -176,12 +176,14 @@
return (portNum >> 4) & 0x7F
}
-//FlowExtractInfo fetches uniport from the flow, based on which it gets and returns ponInf, onuID and uniID
-func FlowExtractInfo(flow *ofp.OfpFlowStats, flowDirection string) (uint32, uint32, uint32, uint32, error) {
+//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 = utils.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
@@ -194,24 +196,32 @@
}
} else if flowDirection == "downstream" {
if uniPortNo = utils.GetChildPortFromTunnelId(flow); uniPortNo == 0 {
- for _, action := range utils.GetActions(flow) {
- if action.Type == utils.OUTPUT {
- if out := action.GetOutput(); out != nil {
- uniPortNo = out.GetPort()
+ for _, field := range utils.GetOfbFields(flow) {
+ if field.GetType() == utils.METADATA {
+ for _, action := range utils.GetActions(flow) {
+ if action.Type == utils.OUTPUT {
+ if out := action.GetOutput(); out != nil {
+ uniPortNo = out.GetPort()
+ }
+ break
+ }
}
- break
+ } else if field.GetType() == utils.IN_PORT {
+ inPort = field.GetPort()
+ } else if field.GetType() == utils.ETH_TYPE {
+ ethType = field.GetEthType()
}
}
}
}
if uniPortNo == 0 {
- return 0, 0, 0, 0, errors.New("failed to extract Pon Interface, ONU Id and Uni Id from flow")
+ return 0, 0, 0, 0, 0, 0, errors.New("failed to extract Pon Interface, ONU Id and Uni Id from flow")
}
ponIntf = IntfIDFromUniPortNum(uniPortNo)
onuID = OnuIDFromUniPortNum(uniPortNo)
uniID = UniIDFromPortNum(uniPortNo)
- return uniPortNo, ponIntf, onuID, uniID, nil
+ return uniPortNo, ponIntf, onuID, uniID, inPort, ethType, nil
}