[VOL-3774] Remove hardcording of NNI port speed

Change-Id: I1c1e50403ac0faabed31ed11be2b59a863c62cb9
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index 2bdefaf..0e0bb62 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -1105,6 +1105,19 @@
     return Status::OK;
 }
 
+uint32_t GetNniSpeed_(uint32_t intf_id) {
+    bcmos_errno err = BCM_ERR_OK;
+
+    uint32_t speed;
+    err = get_nni_interface_speed((bcmolt_interface)intf_id, &speed);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(WARNING, openolt_log_id, "Failed to read speed of NNI interface: %d\n", intf_id);
+        return 0; //This will cause the adapter to use the default speed value
+    }
+
+    return speed;
+}
+
 Status DisablePonIf_(uint32_t intf_id) {
     bcmos_errno err;
     bcmolt_pon_interface_cfg interface_obj;
diff --git a/agent/src/core_utils.cc b/agent/src/core_utils.cc
index df0b7a1..af3f7ad 100644
--- a/agent/src/core_utils.cc
+++ b/agent/src/core_utils.cc
@@ -778,7 +778,7 @@
    return field_val;
 }
 
-Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state)
+Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state, uint32_t speed)
 {
     ::openolt::Indication ind;
     ::openolt::IntfOperIndication* intf_oper_ind = new ::openolt::IntfOperIndication;
@@ -786,6 +786,7 @@
     intf_oper_ind->set_type(type);
     intf_oper_ind->set_intf_id(intf_id);
     intf_oper_ind->set_oper_state(state);
+    intf_oper_ind->set_speed(speed);
     ind.set_allocated_intf_oper_ind(intf_oper_ind);
     oltIndQ.push(ind);
     return Status::OK;
@@ -998,6 +999,20 @@
     return err;
 }
 
+bcmos_errno get_nni_interface_speed(bcmolt_interface id, uint32_t *speed)
+{
+    bcmos_errno err;
+    bcmolt_nni_interface_key nni_key;
+    bcmolt_nni_interface_cfg nni_cfg;
+    nni_key.id = id;
+
+    BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key);
+    BCMOLT_FIELD_SET_PRESENT(&nni_cfg.data, nni_interface_cfg_data, speed);
+    err = bcmolt_cfg_get(dev_id, &nni_cfg.hdr);
+    *speed = nni_cfg.data.speed;
+    return err;
+}
+
 Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology) {
     gemport_status_map_key_tuple gem_status_key(intf_id, onu_id, uni_id, gemport_id);
 
diff --git a/agent/src/core_utils.h b/agent/src/core_utils.h
index 72ae3bb..344ce5e 100644
--- a/agent/src/core_utils.h
+++ b/agent/src/core_utils.h
@@ -93,6 +93,7 @@
 unsigned NumNniIf_();
 unsigned NumPonIf_();
 bcmos_errno get_nni_interface_status(bcmolt_interface id, bcmolt_interface_state *state);
+bcmos_errno get_nni_interface_speed(bcmolt_interface id, uint32_t *speed);
 Status install_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology);
 Status remove_gem_port(int32_t intf_id, int32_t onu_id, int32_t uni_id, int32_t gemport_id, std::string board_technology);
 Status enable_encryption_for_gem_port(int32_t intf_id, int32_t gemport_id, std::string board_technology);