(VOL-4972)PON and ONU object get apis (the pipeline will fail until
the protos changes (https://gerrit.opencord.org/c/voltha-protos/+/34069)
get merged)
Change-Id: I38c11ae873a24c7b20594b0d484565085f4432a5
diff --git a/Makefile b/Makefile
index 8bf4bc1..f4cec6c 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@
## Variables
OPENOLTDEVICE ?= sim
-OPENOLT_PROTO_VER ?= v5.2.1
+OPENOLT_PROTO_VER ?= v5.4.6
DOCKER ?= docker
DOCKER_REGISTRY ?=
diff --git a/VERSION b/VERSION
index aaf18d2..1981190 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.7.5
+3.8.0
diff --git a/agent/common/core.h b/agent/common/core.h
index dafbf97..f322bf0 100644
--- a/agent/common/core.h
+++ b/agent/common/core.h
@@ -248,6 +248,8 @@
Status GetOnuStatistics_(uint32_t intf_id, uint32_t onu_id, openolt::OnuStatistics *onu_stats);
Status GetGemPortStatistics_(uint32_t intf_id, uint32_t gemport_id, openolt::GemPortStatistics* gemport_stats);
Status GetPonRxPower_(uint32_t intf_id, uint32_t onu_id, openolt::PonRxPowerData* response);
+Status GetOnuInfo_(uint32_t intf_id, uint32_t onu_id, openolt::OnuInfo *response);
+Status GetPonInterfaceInfo_(uint32_t intf_id, openolt::PonIntfInfo *response);
int get_status_bcm_cli_quit(void);
uint16_t get_dev_id(void);
Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state, uint32_t speed);
diff --git a/agent/common/server.cc b/agent/common/server.cc
index 83a66f3..ec52b26 100644
--- a/agent/common/server.cc
+++ b/agent/common/server.cc
@@ -355,6 +355,30 @@
request->onu_id(),
response);
}
+
+ Status GetOnuInfo(
+ ServerContext* context,
+ const openolt::Onu* request,
+ openolt::OnuInfo* response) override {
+ return GetOnuInfo_(
+ request->intf_id(),
+ request->onu_id(),
+ response);
+ }
+
+
+ Status GetPonInterfaceInfo(
+ ServerContext* context,
+ const openolt::Interface* request,
+ openolt::PonIntfInfo* response) override {
+ return GetPonInterfaceInfo_(
+ request->intf_id(),
+ response);
+ }
+
+
+
+
};
bool RunServer(int argc, char** argv) {
diff --git a/agent/src/core_api_handler.cc b/agent/src/core_api_handler.cc
index 8f6ea7b..18f284f 100644
--- a/agent/src/core_api_handler.cc
+++ b/agent/src/core_api_handler.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <cerrno>
#include <iostream>
#include <memory>
#include <string>
@@ -207,7 +208,6 @@
device_info->set_model(MODEL_ID);
device_info->set_hardware_version("");
device_info->set_firmware_version(firmware_version);
- device_info->set_technology(board_technology);
device_info->set_pon_ports(num_of_pon_ports);
char serial_number[OPENOLT_FIELD_LEN];
@@ -237,18 +237,6 @@
}
device_info->set_device_id(device_id);
-
- // Legacy, device-wide ranges. To be deprecated when adapter
- // is upgraded to support per-interface ranges
- device_info->set_onu_id_start(ONU_ID_START);
- device_info->set_onu_id_end(ONU_ID_END);
- device_info->set_alloc_id_start(ALLOC_ID_START);
- device_info->set_alloc_id_end(ALLOC_ID_END);
- device_info->set_gemport_id_start(GEM_PORT_ID_START);
- device_info->set_gemport_id_end(GEM_PORT_ID_END);
- device_info->set_flow_id_start(FLOW_ID_START);
- device_info->set_flow_id_end(FLOW_ID_END);
-
std::map<std::string, ::openolt::DeviceInfo::DeviceResourceRanges*> ranges;
for (uint32_t intf_id = 0; intf_id < num_of_pon_ports; ++intf_id) {
std::string intf_technology = intf_technologies[intf_id];
@@ -3510,3 +3498,136 @@
return bcm_to_grpc_err(err, "timeout waiting for pon rssi measurement complete indication");
}
}
+
+Status GetOnuInfo_(uint32_t intf_id, uint32_t onu_id, openolt::OnuInfo *response)
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ bcmolt_onu_state onu_state;
+
+ bcmolt_status losi;
+ bcmolt_status lofi;
+ bcmolt_status loami;
+ err = get_gpon_onu_info((bcmolt_interface)intf_id, onu_id, &onu_state, &losi, &lofi, &loami);
+
+ if (err == BCM_ERR_OK)
+ {
+
+ response->set_onu_id(onu_id);
+ OPENOLT_LOG(DEBUG, openolt_log_id, "onu state %d\n", onu_state);
+ OPENOLT_LOG(DEBUG, openolt_log_id, "losi %d\n", losi);
+ OPENOLT_LOG(DEBUG, openolt_log_id, "lofi %d\n", lofi);
+ OPENOLT_LOG(DEBUG, openolt_log_id, "loami %d\n", loami);
+
+ switch (onu_state)
+ {
+ case bcmolt_onu_state::BCMOLT_ONU_STATE_ACTIVE:
+ response->set_state(openolt::OnuInfo_OnuState::OnuInfo_OnuState_ACTIVE);
+ break;
+ case bcmolt_onu_state::BCMOLT_ONU_STATE_INACTIVE:
+ response->set_state(openolt::OnuInfo_OnuState::OnuInfo_OnuState_INACTIVE);
+ break;
+ case bcmolt_onu_state::BCMOLT_ONU_STATE_UNAWARE:
+ response->set_state(openolt::OnuInfo_OnuState::OnuInfo_OnuState_UNKNOWN);
+ break;
+ case bcmolt_onu_state::BCMOLT_ONU_STATE_NOT_CONFIGURED:
+ response->set_state(openolt::OnuInfo_OnuState::OnuInfo_OnuState_NOT_CONFIGURED);
+ break;
+ case bcmolt_onu_state::BCMOLT_ONU_STATE_DISABLED:
+ response->set_state(openolt::OnuInfo_OnuState::OnuInfo_OnuState_DISABLED);
+ break;
+ }
+ switch (losi)
+ {
+ case bcmolt_status::BCMOLT_STATUS_ON:
+ response->set_losi(openolt::AlarmState::ON);
+ break;
+ case bcmolt_status::BCMOLT_STATUS_OFF:
+ response->set_losi(openolt::AlarmState::OFF);
+ break;
+ }
+
+ switch (lofi)
+ {
+ case bcmolt_status::BCMOLT_STATUS_ON:
+ response->set_lofi(openolt::AlarmState::ON);
+ break;
+ case bcmolt_status::BCMOLT_STATUS_OFF:
+ response->set_lofi(openolt::AlarmState::OFF);
+ break;
+ }
+
+ switch (loami)
+ {
+ case bcmolt_status::BCMOLT_STATUS_ON:
+ response->set_loami(openolt::AlarmState::ON);
+ break;
+ case bcmolt_status::BCMOLT_STATUS_OFF:
+ response->set_loami(openolt::AlarmState::OFF);
+ break;
+ }
+ return Status::OK;
+ }
+ else
+ {
+ OPENOLT_LOG(ERROR, openolt_log_id, "Failed to fetch Onu status, onu_id = %d, intf_id = %d, err = %s\n",
+ onu_id, intf_id, bcmos_strerror(err));
+ return bcm_to_grpc_err(err, "Failed to fetch Onu status");
+ }
+}
+
+Status GetPonInterfaceInfo_(uint32_t intf_id, openolt::PonIntfInfo *response)
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ bcmolt_status los_status;
+ bcmolt_interface_state state;
+ err = get_pon_interface_status((bcmolt_interface)intf_id, &state, &los_status);
+ OPENOLT_LOG(ERROR, openolt_log_id, "pon state %d\n",state);
+ OPENOLT_LOG(ERROR, openolt_log_id, "pon los status %d\n", los_status);
+
+
+ if (err == BCM_ERR_OK)
+ {
+ response->set_intf_id(intf_id) ;
+ switch (los_status)
+ {
+ case bcmolt_status::BCMOLT_STATUS_ON:
+
+ response->set_los(openolt::AlarmState::ON);
+ break;
+ case bcmolt_status::BCMOLT_STATUS_OFF:
+ response->set_los(openolt::AlarmState::OFF);
+ break;
+ }
+
+ switch (state)
+ {
+ case bcmolt_interface_state::BCMOLT_INTERFACE_STATE_ACTIVE_WORKING:
+ response->set_state(openolt::PonIntfInfo_PonIntfState::PonIntfInfo_PonIntfState_ACTIVE_WORKING);
+ break;
+ case bcmolt_interface_state::BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY:
+ response->set_state(openolt::PonIntfInfo_PonIntfState::PonIntfInfo_PonIntfState_ACTIVE_STANDBY);
+ break;
+
+ case bcmolt_interface_state::BCMOLT_INTERFACE_STATE_DISABLED:
+ response->set_state(openolt::PonIntfInfo_PonIntfState::PonIntfInfo_PonIntfState_DISABLED);
+ break;
+
+ case bcmolt_interface_state::BCMOLT_INTERFACE_STATE_INACTIVE:
+
+ response->set_state(openolt::PonIntfInfo_PonIntfState::PonIntfInfo_PonIntfState_INACTIVE);
+ break;
+ default:
+ response->set_state(openolt::PonIntfInfo_PonIntfState::PonIntfInfo_PonIntfState_UNKNOWN);
+ }
+
+ return Status::OK;
+ }
+ else
+ {
+ OPENOLT_LOG(ERROR, openolt_log_id, "Failed to fetch PON interface los status intf_id = %d, err = %s\n",
+ intf_id, bcmos_strerror(err));
+ return bcm_to_grpc_err(err, "Failed to fetch PON interface los status intf_id");
+ }
+}
diff --git a/agent/src/core_utils.cc b/agent/src/core_utils.cc
index dafc68c..9bc7659 100644
--- a/agent/src/core_utils.cc
+++ b/agent/src/core_utils.cc
@@ -891,6 +891,51 @@
return err;
}
+bcmos_errno get_gpon_onu_info(bcmolt_interface pon_ni, int onu_id, bcmolt_onu_state *onu_state, bcmolt_status *losi, bcmolt_status *lofi, bcmolt_status *loami)
+{
+
+ bcmos_errno err;
+ bcmolt_onu_cfg onu_cfg;
+ bcmolt_itu_onu_params itu = {};
+ bcmolt_gpon_onu_alarm_state alarm_state = {};
+ bcmolt_gpon_onu_params gpon = {};
+
+ bcmolt_onu_cfg onu_cfg_itu;
+ bcmolt_onu_key onu_key;
+ onu_key.pon_ni = pon_ni;
+ onu_key.onu_id = onu_id;
+
+ BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key);
+ BCMOLT_FIELD_SET_PRESENT(&onu_cfg.data, onu_cfg_data, onu_state);
+
+ BCMOLT_FIELD_SET_PRESENT(&onu_cfg.data, onu_cfg_data, itu);
+
+ BCMOLT_FIELD_SET_PRESENT(&itu, itu_onu_params, gpon);
+ BCMOLT_FIELD_SET_PRESENT(&gpon, gpon_onu_params, alarm_state);
+
+ BCMOLT_FIELD_SET_PRESENT(&alarm_state, gpon_onu_alarm_state, losi);
+ BCMOLT_FIELD_SET_PRESENT(&alarm_state, gpon_onu_alarm_state, lofi);
+ BCMOLT_FIELD_SET_PRESENT(&alarm_state, gpon_onu_alarm_state, loami);
+
+ BCMOLT_FIELD_SET(&gpon, gpon_onu_params, alarm_state, alarm_state);
+
+ BCMOLT_FIELD_SET(&itu, itu_onu_params, gpon, gpon);
+
+ BCMOLT_FIELD_SET(&onu_cfg.data, onu_cfg_data, itu, itu);
+
+ err = bcmolt_cfg_get(dev_id, &onu_cfg.hdr);
+
+ *onu_state = onu_cfg.data.onu_state;
+ // fetch onu itu
+ *losi = onu_cfg.data.itu.gpon.alarm_state.losi;
+
+ *lofi = onu_cfg.data.itu.gpon.alarm_state.lofi;
+
+ *loami = onu_cfg.data.itu.gpon.alarm_state.loami;
+
+ return err;
+}
+
bcmos_errno get_gem_obj_state(bcmolt_interface pon_ni, bcmolt_gem_port_id id, bcmolt_activation_state *state) {
bcmos_errno err;
bcmolt_itupon_gem_cfg cfg;
diff --git a/agent/src/core_utils.h b/agent/src/core_utils.h
index 1813a37..644ddec 100644
--- a/agent/src/core_utils.h
+++ b/agent/src/core_utils.h
@@ -89,6 +89,7 @@
bcmos_errno bcmolt_apiend_cli_init();
bcmos_errno get_pon_interface_status(bcmolt_interface pon_ni, bcmolt_interface_state *state, bcmolt_status *los_status);
bcmos_errno get_onu_state(bcmolt_interface pon_ni, int onu_id, bcmolt_onu_state *onu_state);
+bcmos_errno get_gpon_onu_info(bcmolt_interface pon_ni, int onu_id, bcmolt_onu_state *onu_state, bcmolt_status *losi, bcmolt_status *lofi,bcmolt_status *loami);
bcmos_errno bcmolt_cfg_get_mult_retry(bcmolt_oltid olt, bcmolt_cfg *cfg);
unsigned NumNniIf_();
unsigned NumPonIf_();
diff --git a/agent/test/Makefile b/agent/test/Makefile
index 94e0829..8e4f730 100644
--- a/agent/test/Makefile
+++ b/agent/test/Makefile
@@ -21,7 +21,7 @@
TOP_DIR=`pwd`
OPENOLTDEVICE ?= sim
-OPENOLT_PROTO_VER ?= v5.2.1
+OPENOLT_PROTO_VER ?= v5.4.6
########################################################################
##
diff --git a/protos/Makefile b/protos/Makefile
index 27ea254..0fbca86 100644
--- a/protos/Makefile
+++ b/protos/Makefile
@@ -19,8 +19,7 @@
# This specifies the GIT tag in https://github.com/opencord/voltha-protos
# repo that we need to refer to, to pick the right version of
# openolt.proto, ext_config.proto and tech_profile.proto
-OPENOLT_PROTO_VER ?= v5.2.1
-
+OPENOLT_PROTO_VER ?= v5.4.6
CXX ?= g++
CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens -I./
CXXFLAGS += -std=c++11