VOL-1220 Add ability to trap LLDP pkts on NNI to send to controller

Change-Id: I3553c9f343f40d50d8d306b7e38d34cb1320c8cb
diff --git a/common/core.h b/common/core.h
index 1bf84d2..feb33bc 100644
--- a/common/core.h
+++ b/common/core.h
@@ -44,10 +44,11 @@
 Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
 Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
 Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt);
-Status FlowAdd_(uint32_t onu_id,
+Status FlowAdd_(int32_t onu_id,
                 uint32_t flow_id, const std::string flow_type,
-                uint32_t access_intf_id, uint32_t network_intf_id,
-                uint32_t gemport_id, uint32_t alloc_id, uint32_t priority,
+                int32_t access_intf_id, int32_t network_intf_id,
+                uint32_t gemport_id, uint32_t sched_id,
+                int32_t priority_value,
                 const ::openolt::Classifier& classifier,
                 const ::openolt::Action& action);
 Status FlowRemove_(uint32_t flow_id, const std::string flow_type);
diff --git a/protos/openolt.proto b/protos/openolt.proto
index 4178f38..e9e8007 100644
--- a/protos/openolt.proto
+++ b/protos/openolt.proto
@@ -109,13 +109,6 @@
         };
     }
 
-    rpc CollectStatistics(Empty) returns (Empty) {
-        option (google.api.http) = {
-            post: "/v1/CollectStatistics"
-            body: "*"
-        };
-    }
-
     rpc GetDeviceInfo(Empty) returns (DeviceInfo) {
         option (google.api.http) = {
             post: "/v1/GetDeviceInfo"
@@ -130,6 +123,13 @@
         };
     }
 
+    rpc CollectStatistics(Empty) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/CollectStatistics"
+            body: "*"
+        };
+    }
+
     rpc EnableIndication(Empty) returns (stream Indication) {}
 }
 
@@ -289,16 +289,16 @@
 }
 
 message Flow {
-    fixed32 access_intf_id = 1;
-    fixed32 onu_id = 2;
+    sfixed32 access_intf_id = 1;
+    sfixed32 onu_id = 2;
     fixed32 flow_id = 3;
     string flow_type = 4;	// upstream, downstream, broadcast, multicast
-    fixed32 network_intf_id = 5;
-    fixed32 gemport_id = 6;
-    fixed32 alloc_id = 10;
+    sfixed32 alloc_id = 10;
+    sfixed32 network_intf_id = 5;
+    sfixed32 gemport_id = 6;
     Classifier classifier = 7;
     Action action = 8;
-    fixed32 priority = 9;
+    sfixed32 priority = 9;
 }
 
 message SerialNumber {
diff --git a/src/core.cc b/src/core.cc
index eadae88..e1a6e3f 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -461,18 +461,18 @@
     return Status::OK;
 }
 
-Status FlowAdd_(uint32_t onu_id,
+Status FlowAdd_(int32_t onu_id,
                 uint32_t flow_id, const std::string flow_type,
-                uint32_t access_intf_id, uint32_t network_intf_id,
+                int32_t access_intf_id, int32_t network_intf_id,
                 uint32_t gemport_id, uint32_t sched_id,
-                uint32_t priority_value,
+                int32_t priority_value,
                 const ::openolt::Classifier& classifier,
                 const ::openolt::Action& action) {
     bcmos_errno err;
     bcmbal_flow_cfg cfg;
     bcmbal_flow_key key = { };
 
-    BCM_LOG(INFO, openolt_log_id, "flow add - intf_id %d, onu_id %d, fow_id %d, `flow_type` %s, gemport_id %d, network_intf_id %d\n",
+    BCM_LOG(INFO, openolt_log_id, "flow add - intf_id %d, onu_id %d, flow_id %d, `flow_type` %s, gemport_id %d, network_intf_id %d\n",
         access_intf_id, onu_id, flow_id, flow_type.c_str(), gemport_id, network_intf_id);
 
     key.flow_id = flow_id;
@@ -488,12 +488,21 @@
     BCMBAL_CFG_INIT(&cfg, flow, key);
 
     BCMBAL_CFG_PROP_SET(&cfg, flow, admin_state, BCMBAL_STATE_UP);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, access_intf_id);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, network_intf_id);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, onu_id);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, gemport_id);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, priority, priority_value);
-
+    if (access_intf_id >= 0) {
+        BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, access_intf_id);
+    }
+    if (network_intf_id >= 0) {
+        BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, network_intf_id);
+    }
+    if (onu_id >= 0) {
+        BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, onu_id);
+    }
+    if (gemport_id >= 0) {
+        BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, gemport_id);
+    }
+    if (priority_value >= 0) {
+        BCMBAL_CFG_PROP_SET(&cfg, flow, priority, priority_value);
+    }
 
     {
         bcmbal_classifier val = { };
@@ -641,21 +650,21 @@
         BCMBAL_CFG_PROP_SET(&cfg, flow, action, val);
     }
 
-    {
+    if ((access_intf_id >= 0) && (onu_id >= 0)) {
         bcmbal_tm_sched_id val;
         if (sched_id != 0) {
             val = sched_id;
         } else {
-        val = (bcmbal_tm_sched_id) mk_sched_id(access_intf_id, onu_id);
+            val = (bcmbal_tm_sched_id) mk_sched_id(access_intf_id, onu_id);
         }
         BCMBAL_CFG_PROP_SET(&cfg, flow, dba_tm_sched_id, val);
-    }
 
-    if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
-        bcmbal_tm_queue_ref val = { };
-        val.sched_id = access_intf_id << 7 | onu_id;
-        val.queue_id = 0;
-        BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);
+        if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
+            bcmbal_tm_queue_ref val = { };
+            val.sched_id = access_intf_id << 7 | onu_id;
+            val.queue_id = 0;
+            BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);
+        }
     }
 
     err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));