VOL-1195 Broadcom logger for format consistency and log rotation
Change-Id: I18d65e382682fcbbcad16676142effae6acbc795
diff --git a/Makefile b/Makefile
index a32dfbd..77ae21b 100644
--- a/Makefile
+++ b/Makefile
@@ -135,7 +135,7 @@
-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/api \
-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_reference/cli
CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
-CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST
+CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG
sdk: onl
ifeq ("$(wildcard $(BAL_DIR))","")
diff --git a/mkdebian/debian/asfvolt16.postinst b/mkdebian/debian/asfvolt16.postinst
index b12bfb2..e7d5a53 100644
--- a/mkdebian/debian/asfvolt16.postinst
+++ b/mkdebian/debian/asfvolt16.postinst
@@ -7,6 +7,7 @@
rm -f /run/bcm68620
cp /tmp/init.d/bal_core_dist /etc/init.d
cp /tmp/init.d/openolt /etc/init.d
+cp /tmp/logrotate.d/openolt /etc/logrotate.d
chmod +x /etc/init.d/bal_core_dist
chmod +x /etc/init.d/openolt
update-rc.d bal_core_dist defaults
diff --git a/mkdebian/debian/logrotate.d/openolt b/mkdebian/debian/logrotate.d/openolt
new file mode 100644
index 0000000..c224dbd
--- /dev/null
+++ b/mkdebian/debian/logrotate.d/openolt
@@ -0,0 +1,10 @@
+/var/log/bal_core_dist.log
+/var/log/openolt.log
+{
+ rotate 7
+ daily
+ compress
+ missingok
+ delaycompress
+ copytruncate
+}
diff --git a/mkdebian/debian/rules b/mkdebian/debian/rules
index 33d257a..61e1bb7 100755
--- a/mkdebian/debian/rules
+++ b/mkdebian/debian/rules
@@ -31,6 +31,7 @@
cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+ cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
#override_dh_shlibdeps:
# dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l$(ONLP_LIB_PATH):$(OFDPA_LIB_PATH)
diff --git a/src/core.cc b/src/core.cc
index bf2a41e..002783c 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -38,11 +38,16 @@
#include <bal_api_end.h>
// FIXME : dependency problem
// #include <bcm_common_gpon.h>
+// #include <bcm_dev_log_task.h>
}
+dev_log_id openolt_log_id = bcm_dev_log_id_register("OPENOLT", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
+dev_log_id omci_log_id = bcm_dev_log_id_register("OMCI", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
+
+
#define NUM_OF_PON_PORTS 16
const std::string technology = "xgspon";
-const std::string firmware_version = "BAL.2.6.0.1__Openolt.2018.09.05";
+const std::string firmware_version = "BAL.2.6.0.1__Openolt.2018.09.10";
State state;
@@ -90,15 +95,16 @@
bcmbal_access_terminal_key key = { };
if (!state.is_activated()) {
- std::cout << "Enable OLT" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Enable OLT");
bcmbal_init(argc, argv, NULL);
Status status = SubscribeIndication();
if (!status.ok()) {
- std::cout << "ERROR: SubscribeIndication failed - "
- << status.error_code() << ": " << status.error_message()
- << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "SubscribeIndication failed - %s : %s\n",
+ grpc_status_code_to_string(status.error_code()).c_str(),
+ status.error_message().c_str());
+
return status;
}
@@ -107,7 +113,7 @@
BCMBAL_CFG_PROP_SET(&acc_term_obj, access_terminal, admin_state, BCMBAL_STATE_UP);
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to enable OLT" << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to enable OLT\n");
return bcm_to_grpc_err(err, "Failed to enable OLT");
}
init_stats();
@@ -144,7 +150,7 @@
openolt::OltIndication* olt_ind = new openolt::OltIndication;
olt_ind->set_oper_state("down");
ind.set_allocated_olt_ind(olt_ind);
- std::cout << "Disable OLT, add an extra indication" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Disable OLT, add an extra indication\n");
oltIndQ.push(ind);
}
return status;
@@ -159,7 +165,7 @@
openolt::OltIndication* olt_ind = new openolt::OltIndication;
olt_ind->set_oper_state("up");
ind.set_allocated_olt_ind(olt_ind);
- std::cout << "Reenable OLT, add an extra indication" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Reenable OLT, add an extra indication\n");
oltIndQ.push(ind);
}
return status;
@@ -177,7 +183,7 @@
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to enable PON interface: " << intf_id << std::endl;
+ 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");
}
@@ -196,7 +202,7 @@
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to disable Uplink interface: " << intf_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to disable Uplink interface: %d\n", intf_id);
return bcm_to_grpc_err(err, "Failed to disable Uplink interface");
}
@@ -215,7 +221,7 @@
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to enable Uplink interface: " << intf_id << std::endl;
+ 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");
}
@@ -234,7 +240,7 @@
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to disable PON interface: " << intf_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to disable PON interface: %d\n", intf_id);
return bcm_to_grpc_err(err, "Failed to disable PON interface");
}
@@ -250,11 +256,8 @@
bcmbal_serial_number serial_num = {};
bcmbal_registration_id registration_id = {};
- std::cout << "Enabling ONU " << onu_id << " on PON " << intf_id << std::endl;
- std::cout << "Vendor Id " << vendor_id
- << "Vendor Specific Id " << vendor_specific
- << "pir " << pir
- << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Enabling ONU %d on PON %d : vendor id %s, vendor specific %s, pir %d\n",
+ onu_id, intf_id, vendor_id, vendor_specific, pir);
subs_terminal_key.sub_term_id = onu_id;
subs_terminal_key.intf_id = intf_id;
@@ -277,7 +280,7 @@
bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr));
if (err) {
- std::cout << "ERROR: Failed to enable ONU: " << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to enable ONU %d on PON %d\n", onu_id, intf_id);
return bcm_to_grpc_err(err, "Failed to enable ONU");
}
@@ -296,10 +299,8 @@
bcmbal_subscriber_terminal_cfg sub_term_obj = {};
bcmbal_subscriber_terminal_key subs_terminal_key;
- std::cout << "Deactivating ONU " << onu_id << " on PON " << intf_id << std::endl;
- std::cout << "Vendor Id " << vendor_id
- << "Vendor Specific Id " << vendor_specific
- << std::endl;
+ 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);
subs_terminal_key.sub_term_id = onu_id;
subs_terminal_key.intf_id = intf_id;
@@ -308,7 +309,7 @@
BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, admin_state, BCMBAL_STATE_DOWN);
if (bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr))) {
- std::cout << "ERROR: Failed to deactivate ONU: " << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to deactivate ONU %d on PON %d\n", onu_id, intf_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to deactivate ONU");
}
@@ -337,16 +338,16 @@
bcmbal_subscriber_terminal_cfg cfg;
bcmbal_subscriber_terminal_key key = { };
- std::cout << "Processing subscriber terminal cfg clear for sub_term_id = "
- << onu_id << " and intf_id = " << intf_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Processing subscriber terminal cfg clear for sub_term_id %d and intf_id %d\n",
+ onu_id, intf_id);
key.sub_term_id = onu_id ;
key.intf_id = intf_id ;
if (0 == key.sub_term_id)
{
- std::cout << "Invalid Key to handle subscriber terminal clear subscriber_terminal_id = "
- << onu_id << " Interface ID = " << intf_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id,"Invalid Key to handle subscriber terminal clear subscriber_terminal_id %d, Interface ID %d\n",
+ onu_id, intf_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
}
@@ -355,8 +356,8 @@
err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
if (err != BCM_ERR_OK)
{
- std::cout << "Failed to clear information for BAL subscriber_terminal_id = "
- << onu_id << " Interface ID = " << intf_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to clear information for BAL subscriber_terminal_id %d, Interface ID %d\n",
+ onu_id, intf_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
}
@@ -391,10 +392,6 @@
char str2[MAX_CHAR_LENGTH];
memset(&arraySend, 0, buf.len);
- // std::cout << "Sending omci msg to ONU of length is "
- // << buf.len
- // << std::endl;
-
for (idx1=0,idx2=0; idx1<((buf.len)*2); idx1++,idx2++) {
sprintf(str1,"%c", pkt[idx1]);
sprintf(str2,"%c", pkt[++idx1]);
@@ -404,15 +401,15 @@
buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
memcpy(buf.val, (uint8_t *)arraySend, buf.len);
- //
- // std::cout << "After converting bytes to hex "
- // << buf.val << buf.len << std::endl;
err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
- // std::cout << "OMCI request msg of length " << buf.len
- // << " sent to ONU" << onu_id
- // << " through PON " << intf_id << std::endl;
+ if (err) {
+ BCM_LOG(ERROR, omci_log_id, "Error sending OMCI message to ONU %d on PON %d\n", onu_id, intf_id);
+ } else {
+ BCM_LOG(DEBUG, omci_log_id, "OMCI request msg of length %d sent to ONU %d on PON %d : %s\n",
+ buf.len, onu_id, intf_id, buf.val);
+ }
free(buf.val);
@@ -434,9 +431,8 @@
err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
- std::cout << "Packet out of length " << buf.len
- << " sent to ONU" << onu_id
- << " through PON " << intf_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent to ONU %d on PON %d\n",
+ buf.len, onu_id, intf_id);
free(buf.val);
@@ -457,8 +453,8 @@
err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
- std::cout << "Packet out of length " << buf.len
- << " sent through uplink port " << intf_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent through uplink port %d\n",
+ buf.len, intf_id);
free(buf.val);
@@ -476,14 +472,8 @@
bcmbal_flow_cfg cfg;
bcmbal_flow_key key = { };
- std::cout << "flow add -"
- << " intf_id:" << access_intf_id
- << " onu_id:" << onu_id
- << " flow_id:" << flow_id
- << " flow_type:" << flow_type
- << " gemport_id:" << gemport_id
- << " network_intf_id:" << network_intf_id
- << std::endl;
+ 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",
+ access_intf_id, onu_id, flow_id, flow_type.c_str(), gemport_id, network_intf_id);
key.flow_id = flow_id;
if (flow_type.compare("upstream") == 0 ) {
@@ -491,7 +481,7 @@
} else if (flow_type.compare("downstream") == 0) {
key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
} else {
- std::cout << "Invalid flow type " << flow_type << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
}
@@ -670,7 +660,7 @@
err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
if (err) {
- std::cout << "ERROR: flow add failed" << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Flow add failed\n");
return bcm_to_grpc_err(err, "flow add failed");
}
@@ -691,7 +681,7 @@
} else if (flow_type.compare("downstream") == 0) {
key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
} else {
- std::cout << "Invalid flow type " << flow_type << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
}
@@ -700,12 +690,12 @@
bcmos_errno err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
if (err) {
- std::cout << "Error " << err << " while removing flow "
- << flow_id << ", " << flow_type << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Error %d while removing flow %d, %s\n",
+ err, flow_id, flow_type.c_str());
return Status(grpc::StatusCode::INTERNAL, "Failed to remove flow");
}
- std::cout << "Flow " << flow_id << ", " << flow_type << " removed";
+ BCM_LOG(INFO, openolt_log_id, "Flow %d, %s removed\n", flow_id, flow_type.c_str());
return Status::OK;
}
@@ -745,10 +735,8 @@
err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
if (err) {
- std::cout << "ERROR: Failed to create subscriber downstream sched"
- << " id:" << key.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to create subscriber downstream sched, id %d, intf_id %d, onu_id %d\n",
+ key.id, intf_id, onu_id);
return bcm_to_grpc_err(err, "Failed to create subscriber downstream sched");
}
}
@@ -766,11 +754,8 @@
err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
if (err) {
- std::cout << "ERROR: Failed to create subscriber downstream tm queue"
- << " id: " << key.id
- << " sched_id: " << key.sched_id
- << " intf_id: " << intf_id
- << " onu_id: " << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to create subscriber downstream tm queue, id %d, sched_id %d, intf_id %d, onu_id %d\n",
+ key.id, key.sched_id, intf_id, onu_id);
return bcm_to_grpc_err(err, "Failed to create subscriber downstream tm queue");
}
@@ -807,16 +792,12 @@
err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
if (err) {
- std::cout << "ERROR: Failed to create upstream DBA sched"
- << " id:" << key.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to create upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
+ key.id, intf_id, onu_id);
return bcm_to_grpc_err(err, "Failed to create upstream DBA sched");
}
- std::cout << "create upstream DBA sched"
- << " id:" << key.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Create upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
+ key.id,intf_id,onu_id);
return Status::OK;
}
@@ -841,17 +822,13 @@
err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(tm_cfg_us.hdr));
if (err) {
- std::cout << "ERROR: Failed to remove upstream DBA sched"
- << " id:" << tm_key_us.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to remove upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
+ tm_key_us.id, intf_id, onu_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to remove upstream DBA sched");
}
- std::cout << "remove upstream DBA sched"
- << " id:" << tm_key_us.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Remove upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
+ tm_key_us.id, intf_id, onu_id);
/* Downstream */
@@ -867,19 +844,13 @@
err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(queue_cfg.hdr));
if (err) {
- std::cout << "ERROR: Failed to remove downstream tm queue"
- << " id:" << queue_key.id
- << " sched_id:" << queue_key.sched_id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to remove downstream tm queue, id %d, sched_id %d, intf_id %d, onu_id %d\n",
+ queue_key.id, queue_key.sched_id, intf_id, onu_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to remove downstream tm queue");
}
- std::cout << "remove upstream DBA sched"
- << " id:" << queue_key.id
- << " sched_id:" << queue_key.sched_id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Remove upstream DBA sched, id %d, sched_id %d, intf_id %d, onu_id %d\n",
+ queue_key.id, queue_key.sched_id, intf_id, onu_id);
// Sheduler
@@ -891,17 +862,13 @@
err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(tm_cfg_ds.hdr));
if (err) {
- std::cout << "ERROR: Failed to remove sub downstream sched"
- << " id:" << tm_key_us.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to remove sub downstream sched, id %d, intf_id %d, onu_id %d\n",
+ tm_key_us.id, intf_id, onu_id);
return Status(grpc::StatusCode::INTERNAL, "Failed to remove sub downstream sched");
}
- std::cout << "remove sub downstream sched"
- << " id:" << tm_key_us.id
- << " intf_id:" << intf_id
- << " onu_id:" << onu_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Remove sub downstream sched, id %d, intf_id %d, onu_id %d\n",
+ tm_key_us.id, intf_id, onu_id);
return Status::OK;
//return 0;
diff --git a/src/error_format.cc b/src/error_format.cc
index 5c88bc7..1bc361f 100644
--- a/src/error_format.cc
+++ b/src/error_format.cc
@@ -39,3 +39,44 @@
return Status(grpc_err, message);
}
+
+std::string grpc_status_code_to_string(StatusCode status_code) {
+ switch (status_code) {
+ case StatusCode::OK:
+ return "StatusCode::OK";
+ case StatusCode::CANCELLED:
+ return "StatusCode::CANCELED";
+ case StatusCode::UNKNOWN:
+ return "StatusCode::UNKNOWN";
+ case StatusCode::INVALID_ARGUMENT:
+ return "StatusCode::INVALID_ARGUMENT";
+ case StatusCode::DEADLINE_EXCEEDED:
+ return "StatusCode::DEADLINE_EXCEEDED";
+ case StatusCode::NOT_FOUND:
+ return "StatusCode::NOT_FOUND";
+ case StatusCode::ALREADY_EXISTS:
+ return "StatusCode::ALREADY_EXISTS";
+ case StatusCode::PERMISSION_DENIED:
+ return "StatusCode::PERMISSION_DENIED";
+ case StatusCode::UNAUTHENTICATED:
+ return "StatusCode::UNAUTHENTICATED";
+ case StatusCode::RESOURCE_EXHAUSTED:
+ return "StatusCode::RESOURCE_EXHAUSTED";
+ case StatusCode::FAILED_PRECONDITION:
+ return "StatusCode::FAILED_PRECONDITION";
+ case StatusCode::ABORTED:
+ return "StatusCode::ABORTED";
+ case StatusCode::OUT_OF_RANGE:
+ return "StatusCode::OUT_OF_RANGE";
+ case StatusCode::INTERNAL:
+ return "StatusCode::INTERNAL";
+ case StatusCode::UNAVAILABLE:
+ return "StatusCode::UNAVAILABLE";
+ case StatusCode::DATA_LOSS:
+ return "StatusCode::DATA_LOSS";
+ case StatusCode::DO_NOT_USE:
+ return "StatusCode::DO_NOT_USE";
+ }
+ return "Unknown GRPC status Code";
+
+}
diff --git a/src/error_format.h b/src/error_format.h
index 5956fba..9fea079 100644
--- a/src/error_format.h
+++ b/src/error_format.h
@@ -12,6 +12,7 @@
}
grpc::Status bcm_to_grpc_err(bcmos_errno bcm_err, std::string message);
+std::string grpc_status_code_to_string(grpc::StatusCode status_code);
#endif
diff --git a/src/indications.cc b/src/indications.cc
index 1d4a7d2..1afcb02 100644
--- a/src/indications.cc
+++ b/src/indications.cc
@@ -54,7 +54,7 @@
state.deactivate();
}
ind.set_allocated_olt_ind(olt_ind);
- std::cout << "olt indication, oper_state:" << ind.olt_ind().oper_state() << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Olt indication, oper_state: %s\n", ind.olt_ind().oper_state().c_str());
oltIndQ.push(ind);
#define MAX_SUPPORTED_INTF 16
@@ -92,7 +92,7 @@
int intf_id = interface_key_to_port_no(bcm_los_ind->key);
std::string status = alarm_status_to_string(bcm_los_ind->data.status);
- std::cout << "LOS indication : " << intf_id << " " << status << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "LOS indication : %d status %s\n", intf_id, status.c_str());
los_ind->set_intf_id(intf_id);
los_ind->set_status(status);
@@ -108,8 +108,8 @@
openolt::Indication ind;
openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
- std::cout << "intf indication, intf_id:"
- << ((bcmbal_interface_oper_status_change *)obj)->key.intf_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
+ ((bcmbal_interface_oper_status_change *)obj)->key.intf_id );
intf_ind->set_intf_id(((bcmbal_interface_oper_status_change *)obj)->key.intf_id);
if (((bcmbal_interface_oper_status_change *)obj)->data.new_oper_status == BCMBAL_STATUS_UP) {
@@ -127,12 +127,11 @@
bcmos_errno IfOperIndication(bcmbal_obj *obj) {
openolt::Indication ind;
openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
- std::cout << "intf oper state indication, intf_id:"
- << ((bcmbal_interface_oper_status_change *)obj)->key.intf_id
- << " type:" << ((bcmbal_interface_oper_status_change *)obj)->key.intf_type
- << " oper_state:" << ((bcmbal_interface_oper_status_change *)obj)->data.new_oper_status
- << " admin_state:" << ((bcmbal_interface_oper_status_change *)obj)->data.admin_state
- << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_id %d, type %d, oper_state %d, admin_state %d\n",
+ ((bcmbal_interface_oper_status_change *)obj)->key.intf_id,
+ ((bcmbal_interface_oper_status_change *)obj)->key.intf_type,
+ ((bcmbal_interface_oper_status_change *)obj)->data.new_oper_status,
+ ((bcmbal_interface_oper_status_change *)obj)->data.admin_state);
intf_oper_ind->set_intf_id(((bcmbal_interface_oper_status_change *)obj)->key.intf_id);
@@ -167,12 +166,8 @@
bcmbal_subscriber_terminal_alarms *alarms =
&(((bcmbal_subscriber_terminal_sub_term_alarm*)obj)->data.alarm);
- std::cout << "onu alarm indication intf_id:" << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: los " << alarms->los << ", lob " << alarms->lob
- << ", lopc_miss " << alarms->lopc_miss << ", lopc_mic_error "
- << alarms->lopc_mic_error << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu alarm indication intf_id %d, onu_id %d, alarm: los %d, lob %d, lopc_miss %d, lopc_mic_error %d\n",
+ key->intf_id, key->sub_term_id, alarms->los, alarms->lob, alarms->lopc_miss, alarms->lopc_mic_error);
onu_alarm_ind->set_intf_id(key->intf_id);
onu_alarm_ind->set_onu_id(key->sub_term_id);
@@ -200,12 +195,8 @@
&(((bcmbal_subscriber_terminal_dgi*)obj)->data);
- std::cout << "onu dying-gasp indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->dgi_status << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu dying-gasp indication, intf_id %d, onu_id %d, alarm %d\n",
+ key->intf_id, key->sub_term_id, data->dgi_status);
dg_ind->set_intf_id(key->intf_id);
dg_ind->set_onu_id(key->sub_term_id);
@@ -231,10 +222,8 @@
bcmbal_serial_number *in_serial_number = &(data->serial_number);
- std::cout << "onu discover indication, intf_id:"
- << key->intf_id
- << " serial_number:"
- << serial_number_to_str(in_serial_number) << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "onu discover indication, intf_id %d, serial_number %s\n",
+ key->intf_id, serial_number_to_str(in_serial_number));
onu_disc_ind->set_intf_id(key->intf_id);
serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id), 4);
@@ -257,11 +246,8 @@
bcmbal_subscriber_terminal_oper_status_change_data *data =
&(((bcmbal_subscriber_terminal_oper_status_change*)obj)->data);
- std::cout << "onu indication, intf_id:"
- << key->intf_id
- << " oper_state:" << data->new_oper_status
- << " admin_state:" << data->admin_state
- << " onu_id:" << key->sub_term_id << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "onu indication, intf_id %d, onu_id %d, oper_state %d, admin_state %d\n",
+ key->intf_id, key->sub_term_id, data->new_oper_status, data->admin_state);
onu_ind->set_intf_id(key->intf_id);
onu_ind->set_onu_id(key->sub_term_id);
@@ -293,14 +279,8 @@
&(((bcmbal_subscriber_terminal_oper_status_change*)obj)->data);
- std::cout << "onu oper state indication, intf_id:"
- << key->intf_id
- << " onu_id: "
- << key->sub_term_id
- << " old oper state: "
- << data->old_oper_status
- << " new oper state:"
- << data->new_oper_status << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %d\n",
+ key->intf_id, key->sub_term_id, data->old_oper_status, data->new_oper_status);
onu_ind->set_intf_id(key->intf_id);
onu_ind->set_onu_id(key->sub_term_id);
@@ -327,7 +307,9 @@
bcmbal_packet_itu_omci_channel_rx *in =
(bcmbal_packet_itu_omci_channel_rx *)obj;
- // std::cout << "omci indication" << std::endl;
+ BCM_LOG(DEBUG, omci_log_id, "OMCI indication: intf_id %d, onu_id %d\n",
+ in->key.packet_send_dest.u.itu_omci_channel.intf_id,
+ in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
omci_ind->set_intf_id(in->key.packet_send_dest.u.itu_omci_channel.intf_id);
omci_ind->set_onu_id(in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
@@ -344,11 +326,8 @@
openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
bcmbal_packet_bearer_channel_rx *in = (bcmbal_packet_bearer_channel_rx *)obj;
- std::cout << "packet indication"
- << " intf_id:" << in->data.intf_id
- << " svc_port:" << in->data.svc_port
- << " flow_id:" << in->data.flow_id
- << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "packet indication, intf_id %d, svc_port %d, flow_id %d\n",
+ in->data.intf_id, in->data.svc_port, in->data.flow_id);
pkt_ind->set_intf_id(in->data.intf_id);
pkt_ind->set_gemport_id(in->data.svc_port);
@@ -363,31 +342,31 @@
bcmos_errno FlowOperIndication(bcmbal_obj *obj) {
openolt::Indication ind;
- std::cout << "flow oper state indication" << std::endl;
+ BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
return BCM_ERR_OK;
}
bcmos_errno FlowIndication(bcmbal_obj *obj) {
openolt::Indication ind;
- std::cout << "flow indication" << std::endl;
+ BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
return BCM_ERR_OK;
}
bcmos_errno TmQIndication(bcmbal_obj *obj) {
openolt::Indication ind;
- std::cout << "traffic mgmt queue indication" << std::endl;
+ BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
return BCM_ERR_OK;
}
bcmos_errno TmSchedIndication(bcmbal_obj *obj) {
openolt::Indication ind;
- std::cout << "traffic mgmt sheduler indication" << std::endl;
+ BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
return BCM_ERR_OK;
}
bcmos_errno McastGroupIndication(bcmbal_obj *obj) {
openolt::Indication ind;
- std::cout << "mcast group indication" << std::endl;
+ BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
return BCM_ERR_OK;
}
@@ -402,12 +381,8 @@
bcmbal_subscriber_terminal_sufi_data *data =
&(((bcmbal_subscriber_terminal_sufi*)obj)->data);
- std::cout << "onu startup failure indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->sufi_status << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
+ key->intf_id, key->sub_term_id, data->sufi_status);
sufi_ind->set_intf_id(key->intf_id);
sufi_ind->set_onu_id(key->sub_term_id);
@@ -431,13 +406,8 @@
bcmbal_subscriber_terminal_sdi_data *data =
&(((bcmbal_subscriber_terminal_sdi*)obj)->data);
- std::cout << "onu signal degrade indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->sdi_status
- << ", BER : " << data->ber << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
+ key->intf_id, key->sub_term_id, data->sdi_status, data->ber);
sdi_ind->set_intf_id(key->intf_id);
sdi_ind->set_onu_id(key->sub_term_id);
@@ -462,14 +432,8 @@
bcmbal_subscriber_terminal_dowi_data *data =
&(((bcmbal_subscriber_terminal_dowi*)obj)->data);
- std::cout << "onu drift of window indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->dowi_status
- << ", drift : " << data->drift_value
- << "new_eqd : " << data->new_eqd << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n",
+ key->intf_id, key->sub_term_id, data->dowi_status, data->drift_value, data->new_eqd);
dowi_ind->set_intf_id(key->intf_id);
dowi_ind->set_onu_id(key->sub_term_id);
@@ -495,13 +459,8 @@
bcmbal_subscriber_terminal_looci_data *data =
&(((bcmbal_subscriber_terminal_looci*)obj)->data);
- std::cout << "onu loss of OMCI channel indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->looci_status << std::endl;
-
+ BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
+ key->intf_id, key->sub_term_id, data->looci_status);
looci_ind->set_intf_id(key->intf_id);
looci_ind->set_onu_id(key->sub_term_id);
@@ -525,13 +484,8 @@
bcmbal_subscriber_terminal_sfi_data *data =
&(((bcmbal_subscriber_terminal_sfi*)obj)->data);
- std::cout << "onu signals failure indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->sfi_status
- << ", BER: " << data->ber << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
+ key->intf_id, key->sub_term_id, data->sfi_status, data->ber);
sfi_ind->set_intf_id(key->intf_id);
@@ -557,13 +511,8 @@
bcmbal_subscriber_terminal_tiwi_data *data =
&(((bcmbal_subscriber_terminal_tiwi*)obj)->data);
- std::cout << "onu transmission interference warning indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id
- << ", alarm: "
- << data->tiwi_status
- << ", drift: " << data->drift_value << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
+ key->intf_id, key->sub_term_id, data->tiwi_status, data->drift_value);
tiwi_ind->set_intf_id(key->intf_id);
tiwi_ind->set_onu_id(key->sub_term_id);
@@ -585,10 +534,8 @@
bcmbal_subscriber_terminal_key *key =
&(((bcmbal_subscriber_terminal_sub_term_act_fail*)obj)->key);
- std::cout << "onu activation failure indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu activation failure indication, intf_id %d, onu_id %d\n",
+ key->intf_id, key->sub_term_id);
activation_fail_ind->set_intf_id(key->intf_id);
@@ -609,10 +556,8 @@
bcmbal_subscriber_terminal_key *key =
&(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
- std::cout << "onu processing error indication, intf_id:"
- << key->intf_id
- << ", onu_id:"
- << key->sub_term_id << std::endl;
+ BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
+ key->intf_id, key->sub_term_id);
onu_proc_error_ind->set_intf_id(key->intf_id);
diff --git a/src/indications.h b/src/indications.h
index 774e689..db064d3 100644
--- a/src/indications.h
+++ b/src/indications.h
@@ -22,7 +22,13 @@
#include <openolt.grpc.pb.h>
#include "Queue.h"
+extern "C" {
+ #include <bcm_dev_log_task.h>
+}
+
extern Queue<openolt::Indication> oltIndQ;
extern grpc::Status SubscribeIndication();
+extern dev_log_id openolt_log_id;
+extern dev_log_id omci_log_id;
#endif
diff --git a/src/stats_collection.cc b/src/stats_collection.cc
index 559b2c1..8afc5f2 100644
--- a/src/stats_collection.cc
+++ b/src/stats_collection.cc
@@ -93,9 +93,8 @@
port_stats->set_bip_errors(stat.data.bip_errors);
} else {
- std::cout << "ERROR: Failed to retrieve port statistics"
- << " intf_id:" << key.intf_id
- << " intf_type:" << key.intf_type << std::endl;
+ BCM_LOG(ERROR, openolt_log_id, "Failed to retrieve port statistics, intf_id %d, intf_type %d\n",
+ (int)key.intf_id, (int)key.intf_type);
}
port_stats->set_intf_id(interface_key_to_port_no(key));
@@ -151,16 +150,16 @@
void stats_collection() {
if (!state.is_connected()) {
- std::cout << "Voltha is not connected, do not collect stats" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Voltha is not connected, do not collect stats\n");
return;
}
if (!state.is_activated()) {
- std::cout << "The OLT is not up, do not collect stats" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "The OLT is not up, do not collect stats\n");
return;
}
- std::cout << "Collecting statistics" << std::endl;
+ BCM_LOG(INFO, openolt_log_id, "Collecting statistics\n");
//Ports statistics