VOL-1296 - OpenOLT driver doesn't enable NNIs on some platforms

Changed OpenOLT agent to enable NNIs at same time it enables PONs during
initial terminal connection to BAL. Made it intelligent to check
current config to avoid errors in BAL that are thrown if already
enabled.

Change-Id: I7914900f2f64654d223961108c3b78bc856b66ef
diff --git a/src/core.cc b/src/core.cc
index 10be676..50676e4 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -207,9 +207,17 @@
     interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
 
     BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
+
+    BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
+    bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
+        BCM_LOG(DEBUG, openolt_log_id, "PON interface: %d already enabled\n", intf_id);
+        return Status::OK;
+    }
+
     BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
 
-    bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
     if (err) {
         BCM_LOG(ERROR, openolt_log_id, "Failed to enable PON interface: %d\n", intf_id);
         return bcm_to_grpc_err(err, "Failed to enable PON interface");
@@ -342,9 +350,17 @@
     interface_key.intf_type = BCMBAL_INTF_TYPE_NNI;
 
     BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
+
+    BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
+    bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
+        BCM_LOG(DEBUG, openolt_log_id, "Uplink interface: %d already enabled\n", intf_id);
+        return Status::OK;
+    }
+
     BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
 
-    bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
     if (err) {
         BCM_LOG(ERROR, openolt_log_id, "Failed to enable Uplink interface: %d\n", intf_id);
         return bcm_to_grpc_err(err, "Failed to enable Uplink interface");
@@ -430,7 +446,7 @@
     bcmbal_subscriber_terminal_key subs_terminal_key;
 
     BCM_LOG(INFO, openolt_log_id,  "Deactivating ONU %d on PON %d : vendor id %s, vendor specific %s\n",
-        onu_id, intf_id, vendor_id, vendor_specific);
+        onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
 
     subs_terminal_key.sub_term_id = onu_id;
     subs_terminal_key.intf_id = intf_id;
@@ -450,6 +466,9 @@
     const char *vendor_id, const char *vendor_specific,
     uint32_t alloc_id) {
 
+    BCM_LOG(INFO, openolt_log_id,  "DeleteOnu ONU %d on PON %d : vendor id %s, vendor specific %s\n",
+        onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
+
     // Need to deactivate before removing it (BAL rules)
 
     DeactivateOnu_(intf_id, onu_id, vendor_id, vendor_specific);
diff --git a/src/indications.cc b/src/indications.cc
index b0ba964..fd40603 100644
--- a/src/indications.cc
+++ b/src/indications.cc
@@ -87,6 +87,15 @@
         }
     }
 
+    // Enable all NNI interfaces. 
+    // 
+    for (int i = 0; i < NumNniIf_(); i++) {
+        status = EnableUplinkIf_(i);
+        if (!status.ok()) {
+            // FIXME - raise alarm to report error in enabling PON
+        }
+    }
+
     /* register for omci indication */
     {
         bcmbal_cb_cfg cb_cfg = {};
diff --git a/src/stats_collection.cc b/src/stats_collection.cc
index 82a178f..7bdde4c 100644
--- a/src/stats_collection.cc
+++ b/src/stats_collection.cc
@@ -176,7 +176,7 @@
     }
 
 
-    BCM_LOG(INFO, openolt_log_id, "Collecting statistics\n");
+    BCM_LOG(DEBUG, openolt_log_id, "Collecting statistics\n");
 
     //Ports statistics