First version of asfvolt16 device driver code
Change-Id: I806c2eaeebc7f8df7073c8264a7fdc6011b0d103
diff --git a/src/Makefile b/src/Makefile
new file mode 100755
index 0000000..eb8c6ef
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,118 @@
+
+CC=/usr/bin/gcc
+AR=/usr/bin/ar
+
+LIB=libEdgecoreDriver.a
+
+BRDCM_SRC=/home/asfvolt/shared/OpenNetworkLinux/bal_src_release_2.4.3.6/bal_release
+GRPC_C_PATH= /home/asfvolt/shared/OpenNetworkLinux/grpc-c/
+
+GRPC_C_INC= -I$(GRPC_C_PATH)/build/ \
+ -I$(GRPC_C_PATH)/build/examples/ \
+ -I$(GRPC_C_PATH)/lib/h/
+
+INCL=*.h
+SRC=asfvolt16_driver.c \
+ bal_access_terminal_hdlr.c \
+ bal_flow_hdlr.c \
+ bal_group_hdlr.c \
+ bal_indications_hdlr.c \
+ bal_interface_hdlr.c \
+ bal_packet_hdlr.c \
+ bal_stats_hdlr.c \
+ bal_subscriber_terminal_hdlr.c \
+ bal_tmqueue_hdlr.c \
+ bal_tmsched_hdlr.c
+
+C_OPTS=-std=c99 -Wextra -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wparentheses -Wswitch -Wswitch-default -Wunused -Wuninitialized -Wunused-but-set-variable -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wshadow -Wno-inline -MMD -MP -Wno-strict-aliasing -g -gdwarf-3 -O0 -Wall -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_DEBUG -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DDEV_LOG_SYSLOG -DENABLE_CLI -DCONFIG_LINENOISE -DCONFIG_EDITLINE -DQAX_SWITCH -Wno-redundant-decls -DOMCI_SVC -Wno-redundant-decls -DBCM_SUBSYSTEM_CORE -DBCM_PLATFORM_MAPLE -DBCM_OS_POSIX -DBCM_SUBSYSTEM_HOST -D_KERNEL_SPACE -DBCM_EPON -DBCM_GPON -DBCM_XGPON -DCONFIG_MAC_RPC -DCONFIG_SWITCH_RPC -DSIMULATION_BUILD -DBAL_MONOLITHIC -D_XOPEN_SOURCE=600
+
+INC_PATH= -I. -I$(BRDCM_SRC)/src/common/os_abstraction \
+ -I$(BRDCM_SRC)/src/common/os_abstraction/posix \
+ -I$(BRDCM_SRC)/src/core/platform \
+ -I$(BRDCM_SRC)/src/common/config \
+ -I$(BRDCM_SRC)/src/common/include \
+ -I$(BRDCM_SRC)/build/core/src/common/include \
+ -I$(BRDCM_SRC)/src/common/utils \
+ -I$(BRDCM_SRC)/build/core/src/common/utils\
+ -I$(BRDCM_SRC)/3rdparty/linenoise \
+ -I$(BRDCM_SRC)/build/core/3rdparty/linenoise \
+ -I$(BRDCM_SRC)/build/core/src/common/bal_dist_utils \
+ -I$(BRDCM_SRC)/src/common/bal_dist_utils \
+ -I$(BRDCM_SRC)/src/common/cli \
+ -I$(BRDCM_SRC)/build/core/src/common/cli \
+ -I$(BRDCM_SRC)/src/common/dev_log \
+ -I$(BRDCM_SRC)/build/core/src/common/dev_log \
+ -I$(BRDCM_SRC)/src/common/os_abstraction/os_cli \
+ -I$(BRDCM_SRC)/build/core/src/common/os_abstraction/os_cli \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/api \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/host_api \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_customized/embedded_cli \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_customized/os_abstraction/os_cli \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/transport \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/model \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/common_gpon \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_driver/sw_version \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_reference/api_dev_log \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_reference/api_cli \
+ -I$(BRDCM_SRC)/3rdparty/maple/sdk/host_reference/device_selector \
+ -I$(BRDCM_SRC)/src/lib/libobjmsg \
+ -I$(BRDCM_SRC)/build/core/src/lib/libobjmsg \
+ -I$(BRDCM_SRC)/src/lib/libbalapi \
+ -I$(BRDCM_SRC)/build/core/src/lib/libbalapi \
+ -I$(BRDCM_SRC)/src/lib/libbalapicli \
+ -I$(BRDCM_SRC)/build/core/src/lib/libbalapicli \
+ -I$(BRDCM_SRC)/src/common/bal_app_utils \
+ -I$(BRDCM_SRC)/build/core/src/common/bal_app_utils \
+ -I$(BRDCM_SRC)/src/balapiend \
+ -I$(BRDCM_SRC)/build/core/src/balapiend \
+ -I$(BRDCM_SRC)/src/common/bal_intg_app_calls \
+ -I$(BRDCM_SRC)/build/core/src/common/bal_intg_app_calls \
+ -I$(BRDCM_SRC)/src/lib/libautostart \
+ -I$(BRDCM_SRC)/build/core/src/lib/libautostart \
+ -I$(BRDCM_SRC)/src/lib/libutils \
+ -I$(BRDCM_SRC)/build/core/src/lib/libutils \
+ -I$(BRDCM_SRC)/src/lib/libtopology \
+ -I$(BRDCM_SRC)/build/core/src/lib/libtopology \
+ -I$(BRDCM_SRC)/src/core/util/mac \
+ -I$(BRDCM_SRC)/build/core/src/core/util/mac \
+ -I$(BRDCM_SRC)/3rdparty/bcm-sdk/build/sdk-all-6.5.7/include \
+ -I$(BRDCM_SRC)/3rdparty/bcm-sdk/build/sdk-all-6.5.7/libs/phymod/include \
+ -I$(BRDCM_SRC)/src/core/util/switch/dpp \
+ -I$(BRDCM_SRC)/build/core/src/core/util/switch/dpp \
+ -I$(BRDCM_SRC)/src/core/util/switch/esw \
+ -I$(BRDCM_SRC)/build/core/src/core/util/switch/esw \
+ -I$(BRDCM_SRC)/src/core/util/switch \
+ -I$(BRDCM_SRC)/build/core/src/core/util/switch \
+ -I$(BRDCM_SRC)/src/lib/librscmgr \
+ -I$(BRDCM_SRC)/build/core/src/lib/librscmgr \
+ -I$(BRDCM_SRC)/src/lib/libcmdline \
+ -I$(BRDCM_SRC)/build/core/src/lib/libcmdline \
+ -I$(BRDCM_SRC)/src/core/main \
+ -I$(BRDCM_SRC)/build/core/src/core/main \
+ -I$(BRDCM_SRC)/src/core/main \
+ -I$(BRDCM_SRC)/src/common/include \
+ -I$(BRDCM_SRC)/build/core/src/common/include \
+ -I$(BRDCM_SRC)/build/core/include \
+ $(GRPC_C_INC)
+
+VERBOSE=@
+ifeq ($V, 1)
+ VERBOSE=
+endif
+
+OBJ=$(SRC:.c=.o)
+
+%.o: %.c
+ @echo "(CC) $*.c ..."
+ $(VERBOSE) $(CC) $(C_OPTS) $(INC_PATH) -c $*.c
+
+$(LIB):$(OBJ)
+ @echo "Creating Archive $(LIB) ..."
+ $(VERBOSE) $(AR) rcs $(LIB) $(OBJ)
+
+all: $(LIB)
+
+clean:
+ rm -f *.o \
+ rm -f *.d \
+ rm -f *.a
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 71aa0d1..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-bin_PROGRAMS = asfvolt16
-asfvolt16_SOURCES = main.c
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 0000000..7d2a1fd
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,89 @@
+GRPC_C DEVICE SIMULATOR
+
+ This is a executable(voltha_bal_driver), which will recevie asfvolt16 adapter grpc-c messages and call respective device stub.
+ It will send recevied responses/asynchronous indications from Device stub to Adapter.
+
+GETTING STARTED
+
+prerequisites to install grpc
+ - sudo apt-get install build-essential libxml2-dev libgeos++-dev libpq-dev libbz2-dev libtool automake openssl libssl-dev golang-goprotobuf-dev
+
+
+INSTALLATION
+
+steps to install grpc
+ - Download as zip "grpc", "grpc-c", "protobuf" and "protobuf-c" from "https://github.com/opennetworkinglab/asfvolt16-driver/tree/master/third_party"
+ - place downloaded protobuf folder at grpc/thirdparty
+ - place downloaded protobuf-c folder at grpc-c/thirdparty
+ - cd grpc/thirdparty/protobuf
+ - ./autogen.sh
+ - ./configure
+ - make
+ - sudo make install
+ - cd grpc/
+ - make
+ - sudo make install
+
+steps to install grpc-c
+ - cd grpc-c/thirdparty/protobuf-c
+ - ./autogen.sh
+ - ./configure
+ - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/protobuf
+ - export LD_LIBRARY_PATH=/usr/local/lib
+ - make
+ - sudo make install
+
+Apply grpc-c patch
+ - cd grpc-c/
+ Patch 1:
+ Apply patch in following link for grpc-c/lib - "https://github.com/Juniper/grpc-c/commit/353b40cd920cd749ed6cf71f8df17f1d5cf2c89d"
+ Note:
+ (This patch is having very few changes in two files(grpc-c/lib/client.c, grpc-c/lib/service.c.
+ Download these two files from above link and replace at grpc-c/lib or merge these changes manually.)
+ Patch 2:
+ Apply patch in service.c.patch and client.c.patch
+ - cp Makefile.am grpc-c/examples/
+ - cp voltha_bal_driver.c grpc-c/examples/
+ - cp bal_stub.c grpc-c/examples/
+ - cp bal_stub.h grpc-c/examples/
+ - Note: Update voltha adaptor IP in bal_stub.c
+ - autoreconf --install
+ - mkdir build && cd build
+ - ../configure
+ - make
+ - sudo make install
+
+To obtain proto files - Have a repo sync of opencord code base:
+ - cp opencord/incubator/voltha/voltha/adapters/asfvolt16_olt/protos/* examples/
+
+To autogenerate code from proto files:
+ - make autogen
+
+Build voltha_bal_driver:
+ - Note: Remove "-O2" from Makefile
+ - make clean_all;make
+
+The ultimate executable voltha_bal_driver can be found under ~/grpc-c/build/examples/.libs/
+
+USAGE:
+ ./voltha_bal_driver "serverIP:port1" -C "serverIP:port2" -A "serverIP:port3"
+ ./bal_core_dist -C "serverIP:port2" -A "serverIP:port3"
+
+NOTE: bal_core_dist is a broadcom executable
+
+CONTRIBUTING
+ <TBD>
+
+VERSIONING
+ <TBD>
+
+AUTHORS
+ Radisys Adapter Team
+
+Licence
+ <TBD>
+
+Acknowledgments
+ <TBD>
+
+
diff --git a/src/asfvolt16_driver.c b/src/asfvolt16_driver.c
new file mode 100755
index 0000000..1178ff2
--- /dev/null
+++ b/src/asfvolt16_driver.c
@@ -0,0 +1,486 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bcmos_system.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+#include "asfvolt16_driver.h"
+#include "bal_access_terminal_hdlr.h"
+#include "bal_subscriber_terminal_hdlr.h"
+#include "bal_flow_hdlr.h"
+#include "bal_group_hdlr.h"
+#include "bal_interface_hdlr.h"
+#include "bal_tmqueue_hdlr.h"
+#include "bal_tmsched_hdlr.h"
+#include "bal_packet_hdlr.h"
+#include "bal_indications_hdlr.h"
+
+bcmbal_access_term_id access_term_id = DEFAULT_ATERM_ID;
+
+/********************************************************************\
+ * Function : bal_register_indication_cbs *
+ * Description : Registering the Call back function to handle the *
+ * indciations from BAL *
+ ********************************************************************/
+uint32_t bal_register_indication_cbs()
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_cb_cfg cb_cfg = {};
+ uint16_t ind_subgroup;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Subscription for other messages\n");
+
+ cb_cfg.module = BCMOS_MODULE_ID_NONE;
+
+ /* Register to get indications for interface objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
+
+ /* Interface los */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_los_indication_cb;
+ ind_subgroup = bcmbal_interface_auto_id_los;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Interface Indication */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_indication_cb;
+ ind_subgroup = bcmbal_interface_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indications for subscriber terminal objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
+
+ /* Subscriber Terminal Alarm */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_alarm_indication_cb;
+ ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_alarm;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Subscriber Terminal Discovery */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_disc_indication_cb;
+ ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_disc;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Subscriber Terminal Indication */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_indication_cb;
+ ind_subgroup = bcmbal_subscriber_terminal_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indication callbacks for OMCI objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_PACKET;
+
+ ind_subgroup = BCMBAL_IND_SUBGROUP(packet, itu_omci_channel_rx);
+ cb_cfg.p_object_key_info = NULL;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler )bal_omci_data_indication_cb;
+ bcmbal_subscribe_ind(0, &cb_cfg);
+
+#if 0
+ /* Access Terminal Operational State Change */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_acc_term_osc_indication_cb;
+ ind_subgroup = bcmbal_access_terminal_auto_id_oper_status_change;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indication callbacks for flow objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW;
+
+ /* Flow Operational State Change */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_flow_osc_indication_cb;
+ ind_subgroup = bcmbal_flow_auto_id_oper_status_change;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Flow Indication */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_flow_indication_cb;
+ ind_subgroup = bcmbal_flow_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indication callbacks for group objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_GROUP;
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_group_indication_cb;
+ ind_subgroup = bcmbal_group_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Interface Operational State Change */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_osc_indication_cb;
+ ind_subgroup = bcmbal_interface_auto_id_oper_status_change;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Interface los */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_los_indication_cb;
+ ind_subgroup = bcmbal_interface_auto_id_los;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Subscriber Terminal Operational State Change */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_osc_indication_cb;
+ ind_subgroup = bcmbal_subscriber_terminal_auto_id_oper_status_change;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Subscriber Terminal dgi */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_dgi_indication_cb;
+ ind_subgroup = bcmbal_subscriber_terminal_auto_id_dgi;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indication callbacks for tm queue objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_QUEUE;
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_tm_queue_indication_cb;
+ ind_subgroup = bcmbal_tm_queue_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Register to get indication callbacks for tm sched objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_SCHED;
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_tm_sched_indication_cb;
+ ind_subgroup = bcmbal_tm_sched_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* Bearer Channel Data */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_packet_data_indication_cb;
+ ind_subgroup = bcmbal_packet_auto_id_bearer_channel_rx;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ /* OAM Channel Data - oam response indication */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_oam_data_indication_cb;
+ ind_subgroup = bcmbal_packet_auto_id_ieee_oam_channel_rx;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+#endif
+ return err;
+}
+
+
+/********************************************************************
+ * *
+ * gRPC service RPC function implementation *
+ * *
+ ********************************************************************/
+
+/********************************************************************\
+ * Function : asfvolt16_bal_init *
+ * Description : This function will initialize the BAL module *
+ ********************************************************************/
+uint32_t asfvolt16_bal_init(BalInit *bal_init, balCoreIpInfo *coreInfo)
+
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ char *ip_and_port = NULL;
+ if (NULL == bal_init)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Recvied NULL balInit Structure from VOLTHA \n");
+ return BAL_ERRNO__BAL_ERR_PERM;
+ }
+ else
+ {
+ ip_and_port = bal_init->voltha_adapter_ip_port;
+ ASFVOLT_LOG(ASFVOLT_DEBUG,"\nRecevied Adapter IP and Port from VOLTHA is %s\n",ip_and_port);
+ }
+ char *argv[6];
+ /* Initialize BAL */
+ argv[1] = coreInfo->bal_core_arg1;
+ argv[2] = coreInfo->bal_core_ip_port;
+ argv[3] = coreInfo->bal_core_arg2;
+ argv[4] = coreInfo->bal_shared_lib_ip_port;
+ int argc = 5;
+ client = grpc_c_client_init(ip_and_port, "bal_client", NULL);
+
+ /* Init BAL */
+ err = bcmbal_apiend_init_all(argc, argv, NULL,3);
+ if(err != BCM_ERR_OK)
+ {
+ printf("\n Failed in bcmbal_init \n");
+ }
+
+#if 0
+ err = (err != BCM_ERR_OK) ? err : bcmbal_autostart(); /* Execute bal_autostart.ini script if any */
+
+ if (err)
+ {
+ /* Let logger task have enough time to drain its message queue. */
+ usleep(1000000);
+ ASFVOLT_LOG(ASFVOLT_ERROR, "failed to Initialize the BAL\n");
+ return err;
+ }
+#endif
+
+ /* Register the call back functions to handle any
+ * indications from the BAL */
+ bcmbal_cb_cfg cb_cfg = {};
+ uint16_t ind_subgroup;
+
+ cb_cfg.module = BCMOS_MODULE_ID_NONE;
+ /* Register to get indications for access terminal objects
+ */
+ cb_cfg.obj_type = BCMBAL_OBJ_ID_ACCESS_TERMINAL;
+
+ /* Access Terminal Indication */
+ cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_acc_term_indication_cb;
+ ind_subgroup = bcmbal_access_terminal_auto_id_ind;
+ cb_cfg.p_subgroup = &ind_subgroup;
+ err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg);
+
+ if (err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "failed to register call back functions to BAL\n");
+ }
+
+ return err;
+}
+
+/********************************************************************\
+ * Function : asfvolt16_bal_finish *
+ * Description : This function will Un-initialize the BAL module *
+ ********************************************************************/
+uint32_t asfvolt16_bal_finish(void)
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ /* Un-Initialize the BAL function */
+ bcmbal_apiend_finish();
+
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : asfvolt16_bal_cfg_set *
+ * Description : Handles below configuration *
+ * 1) Access Terminal Cfg *
+ * 2) Interface(PON & NNI) Cfg *
+ * 3) Subscriber Terminal (ONU) cfg *
+ * 4) Flow Cfg *
+ * 5) Group Cfg (In case of Multicast) *
+ ********************************************************************/
+uint32_t asfvolt16_bal_cfg_set(BalCfg *cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ memset(&voltha_device_id, 0, ASFVOLT_MAX_DEVICE_ID_SIZE);
+ strcpy(voltha_device_id,cfg->device_id);
+
+ switch(cfg->hdr->obj_type)
+ {
+ case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+ {
+ err = bal_access_terminal_cfg_set(cfg->cfg);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
+ {
+ err = bal_interface_cfg_set(cfg->interface);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
+ {
+ err = bal_subscriber_terminal_cfg_set(cfg->terminal);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_FLOW:
+ {
+ err = bal_flow_cfg_set(cfg->flow);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_GROUP:
+ {
+ err = bal_group_cfg_set(cfg->group);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE:
+ {
+ err = bal_tm_queue_cfg_set(cfg->tm_queue_cfg);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED:
+ {
+ err = bal_tm_sched_cfg_set(cfg->tm_sched_cfg);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
+ {
+ err = bal_packet_cfg_req(cfg->packet);
+ break;
+ }
+ default:
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid objet type for configuration\n");
+ err = BAL_ERRNO__BAL_ERR_INVALID_OP;
+ break;
+ }
+ }
+ return err;
+}
+
+/********************************************************************\
+ * Function : asfvolt16_bal_cfg_clear *
+ * Description : Clears the configuration related to below objects *
+ * 1) Access Terminal Cfg *
+ * 2) Interface(PON & NNI) Cfg *
+ * 3) Subscriber Terminal (ONU) cfg *
+ * 4) Flow Cfg *
+ * 5) Group Cfg (In case of Multicast) *
+ ********************************************************************/
+uint32_t asfvolt16_bal_cfg_clear(BalKey *key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ if(!key->hdr->has_obj_type)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "object type is not present for clear\n");
+ return BAL_ERRNO__BAL_ERR_INVALID_OP;
+ }
+
+ switch(key->hdr->obj_type)
+ {
+ case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+ {
+ err = bal_access_terminal_cfg_clear(key->access_term_key);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
+ {
+ err = bal_interface_cfg_clear(key->interface_key);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
+ {
+ err = bal_subscriber_terminal_cfg_clear(key->terminal_key);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_FLOW:
+ {
+ err = bal_flow_cfg_clear(key->flow_key);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_GROUP:
+ {
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE:
+ {
+ err = bal_tm_queue_cfg_clear(key->tm_queue_key);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED:
+ {
+ err = bal_tm_sched_cfg_clear(key->tm_sched_key);
+ break;
+ }
+ /*case BAL_KEY__OBJ_PACKET_KEY:
+ {
+ break;
+ }*/
+ default:
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid objet type to handle clear\n");
+ err = BAL_ERRNO__BAL_ERR_INVALID_OP;
+ break;
+ }
+ }
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : asfvolt16_bal_cfg_get *
+ * Description : Get the configuration related to below objects *
+ * 1) Access Terminal Cfg *
+ * 2) Interface(PON & NNI) Cfg *
+ * 3) Subscriber Terminal (ONU) cfg *
+ * 4) Flow Cfg *
+ * 5) Group Cfg (In case of Multicast) *
+ ********************************************************************/
+uint32_t asfvolt16_bal_cfg_get(BalKey *key, BalCfg *cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+
+ if(!key->hdr->has_obj_type)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "object type is not present for get\n");
+ return BAL_ERRNO__BAL_ERR_INVALID_OP;
+ }
+
+ switch(key->hdr->obj_type)
+ {
+ case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+ {
+ err = bal_access_terminal_cfg_get(key->access_term_key, cfg->cfg );
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
+ {
+ err = bal_interface_cfg_get(key->interface_key, cfg->interface);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
+ {
+ err = bal_subscriber_terminal_cfg_get(key->terminal_key, cfg->terminal);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_FLOW:
+ {
+ err = bal_flow_cfg_get(key->flow_key, cfg->flow);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_GROUP:
+ {
+ err = bal_group_cfg_get(key->group_key, cfg->group);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE:
+ {
+ err = bal_tm_queue_cfg_get(key->tm_queue_key, cfg->tm_queue_cfg);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED:
+ {
+ err = bal_tm_sched_cfg_get(key->tm_sched_key, cfg->tm_sched_cfg);
+ break;
+ }
+ case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
+ {
+ break;
+ }
+ default:
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid objet type to handle Get\n");
+ err = BAL_ERRNO__BAL_ERR_INVALID_OP;
+ break;
+ }
+ }
+ return err;
+}
+
+
diff --git a/src/asfvolt16_driver.h b/src/asfvolt16_driver.h
new file mode 100755
index 0000000..db74e62
--- /dev/null
+++ b/src/asfvolt16_driver.h
@@ -0,0 +1,76 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#ifndef DRIVERAPP_ASFVOLT16_DRIVER
+#define DRIVERAPP_ASFVOLT16_DRIVER
+
+/* Includes related to proto buf */
+#include "bal_msg_type.grpc-c.h"
+#include "bal_osmsg.grpc-c.h"
+#include "bal_model_ids.grpc-c.h"
+#include "bal_obj.grpc-c.h"
+#include "bal_model_types.grpc-c.h"
+#include "bal_errno.grpc-c.h"
+#include "bal.grpc-c.h"
+
+#define ASFVOLT_ERROR 1
+#define ASFVOLT_INFO 2
+#define ASFVOLT_DEBUG 3
+#define ASFVOLT_MAX_PKT_SIZE 500
+#define ASFVOLT_MAX_DEVICE_ID_SIZE 50
+#define MAX_CHAR_LENGTH 20
+#define MAX_OMCI_MSG_LENGTH 44
+
+char voltha_device_id[ASFVOLT_MAX_DEVICE_ID_SIZE];
+
+typedef struct BalCoreIpInfo
+{
+ char bal_core_arg1[4];
+ char bal_core_ip_port[24];
+ char bal_core_arg2[4];
+ char bal_shared_lib_ip_port[24];
+}balCoreIpInfo;
+
+#define ASFVOLT_LOG(log_type, args...) \
+ if(log_type) \
+ {\
+ printf("File(%s): Line(%d): ", __FUNCTION__, __LINE__);\
+ printf(args);\
+ }
+
+
+#define ASFVOLT_CFG_PROP_SET(cfg, obj, param, pram_prst, param_val) \
+ if(pram_prst)\
+ {\
+ BCMBAL_CFG_PROP_SET(&cfg, obj, param, param_val);\
+ }
+
+/***************************************************************
+* *
+* Function Declarations *
+* *
+****************************************************************/
+extern uint32_t asfvolt16_bal_init(BalInit *bal_init, balCoreIpInfo *coreInfo);
+extern uint32_t asfvolt16_bal_finish(void);
+extern uint32_t bal_register_indication_cbs(void);
+extern uint32_t asfvolt16_bal_cfg_set(BalCfg *cfg);
+extern uint32_t asfvolt16_bal_cfg_clear(BalKey *key);
+extern uint32_t asfvolt16_bal_cfg_get(BalKey *key, BalCfg *cfg);
+extern void asfvolt16_send_omci_msg(uint16_t olt_no, uint32_t onu_nu, char* packet_to_send);
+extern uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData);
+grpc_c_client_t *client;
+
+#endif /* DRIVERAPP_ASFVOLT16_DRIVER */
diff --git a/src/bal_access_terminal_hdlr.c b/src/bal_access_terminal_hdlr.c
new file mode 100755
index 0000000..c05e5cf
--- /dev/null
+++ b/src/bal_access_terminal_hdlr.c
@@ -0,0 +1,137 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+#include "asfvolt16_driver.h"
+#include "bal_access_terminal_hdlr.h"
+
+
+/********************************************************************\
+ * Function : bal_access_terminal_cfg_set *
+ * Description : Configures the OLT device *
+ ********************************************************************/
+
+uint32_t bal_access_terminal_cfg_set(BalAccessTerminalCfg *access_term_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_access_terminal_cfg acc_term_obj; /**< declare main API struct */
+ bcmbal_access_terminal_key key = { }; /**< declare key */
+
+ key.access_term_id = access_term_cfg->key->access_term_id;
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
+
+ /* decode API parameters from CLI */
+ ASFVOLT_CFG_PROP_SET(acc_term_obj, access_terminal, admin_state, BCMOS_TRUE, BCMBAL_STATE_UP);
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the access-terminal(OLT) to ADMIN-UP\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Access Terminal UP configuration sent to OLT\n");
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_access_term_indication_cb *
+ * Description : Call back function registered with BAL to handle *
+ * event related to access terminal *
+ ********************************************************************/
+bcmos_errno bal_access_term_indication_cb(bcmbal_obj *obj)
+{
+ /*bcmos_errno result = BCM_ERR_OK;*/
+ ASFVOLT_LOG(ASFVOLT_INFO, "Processing API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type),
+ bcmos_strerror(obj->status));
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_access_terminal_cfg_clear *
+ * Description : Handles the clear/Delete of access terminal *
+ ********************************************************************/
+uint32_t bal_access_terminal_cfg_clear(BalAccessTerminalKey *access_term_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_access_terminal_cfg cfg_clear; /**< declare main API struct */
+ bcmbal_access_terminal_key key = { }; /**< declare key */
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "processing the clear request on access terminal\n");
+
+ key.access_term_id = access_term_key->access_term_id;
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg_clear, access_terminal, key);
+
+
+ /* call API */
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg_clear.hdr);
+
+ if( err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_INFO, "Failed to clear the access terminal\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Successfully cleared the access terminal\n");
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_access_terminal_cfg_get *
+ * Description : Handles the clear/Delete of access terminal *
+ ********************************************************************/
+uint32_t bal_access_terminal_cfg_get (BalAccessTerminalKey *access_term_key,
+ BalAccessTerminalCfg *access_term_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_access_terminal_cfg cfg; /**< declare main API struct */
+ bcmbal_access_terminal_key key = { }; /**< declare key */
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "processing the get request on access terminal\n");
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg, access_terminal, key);
+
+ BCMBAL_CFG_PROP_GET(&cfg, access_terminal, all_properties);
+
+ /* call API */
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &cfg.hdr);
+ if (err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get access terminal configuration\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "To-Do. Send access terminal details to Adapter\n");
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
diff --git a/src/main.c b/src/bal_access_terminal_hdlr.h
old mode 100644
new mode 100755
similarity index 62%
copy from src/main.c
copy to src/bal_access_terminal_hdlr.h
index b62bc6e..3b0cc49
--- a/src/main.c
+++ b/src/bal_access_terminal_hdlr.h
@@ -13,13 +13,8 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_access_terminal_cfg_set(BalAccessTerminalCfg *access_term_cfg);
+extern uint32_t bal_access_terminal_cfg_clear(BalAccessTerminalKey *access_term_key);
+extern uint32_t bal_access_terminal_cfg_get (BalAccessTerminalKey *access_term_key, BalAccessTerminalCfg *access_term_cfg);
+extern bcmos_errno bal_access_term_indication_cb(bcmbal_obj *obj);
diff --git a/src/bal_flow_hdlr.c b/src/bal_flow_hdlr.c
new file mode 100755
index 0000000..5a330b1
--- /dev/null
+++ b/src/bal_flow_hdlr.c
@@ -0,0 +1,527 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+#include "asfvolt16_driver.h"
+#include "bal_flow_hdlr.h"
+
+
+/********************************************************************\
+ * Function : bal_fill_queue_cfg *
+ * Description : copy queue information from proto structure to *
+ * BAL structure *
+ ********************************************************************/
+static uint32_t bal_fill_queue_cfg(BalTmQueueRef *tmp_que,
+ bcmbal_tm_queue_ref *que_val)
+{
+ if(tmp_que->has_sched_id)
+ {
+ que_val->sched_id = tmp_que->sched_id;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->sched_id = %d\n", que_val->sched_id);
+ }
+
+ if(tmp_que->has_queue_id)
+ {
+ que_val->queue_id = tmp_que->queue_id;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->queue_id = %d\n", que_val->queue_id);
+ }
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_fill_action_cfg *
+ * Description : copy action information from proto structure to *
+ * BAL structure *
+ ********************************************************************/
+static uint32_t bal_fill_action_cfg(BalAction *tmp_action,
+ bcmbal_action *action_val)
+{
+
+ if(tmp_action->has_presence_mask)
+ {
+ action_val->presence_mask = tmp_action->presence_mask;
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_CMDS_BITMASK)
+ {
+ action_val->cmds_bitmask = tmp_action->cmds_bitmask;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->cmds_bitmask = %x\n", action_val->cmds_bitmask);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_O_VID)
+ {
+ action_val->o_vid = tmp_action->o_vid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_vid = %d\n", action_val->o_vid);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_O_PBITS)
+ {
+ action_val->o_pbits = tmp_action->o_pbits;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_pbits = %d\n", action_val->o_pbits);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_O_TPID)
+ {
+ action_val->o_tpid = tmp_action->o_tpid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_tpid = %d\n", action_val->o_tpid);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_I_VID)
+ {
+ action_val->i_vid = tmp_action->i_vid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_vid = %d\n", action_val->i_vid);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_I_PBITS)
+ {
+ action_val->i_pbits = tmp_action->i_pbits;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_pbits = %d\n", action_val->i_pbits);
+ }
+
+ if (action_val->presence_mask & BCMBAL_ACTION_ID_I_TPID)
+ {
+ action_val->i_tpid = tmp_action->i_tpid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_tpid = %d\n", action_val->i_tpid);
+ }
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->presence_mask = %x\n", action_val->presence_mask);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Action is not present in the flow\n");
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_fill_classifier_cfg *
+ * Description : copy classifier information from proto structure to*
+ * BAL structure
+ ********************************************************************/
+uint32_t bal_fill_classifier_cfg(BalClassifier *tmp_classifier,
+ bcmbal_classifier *classifier_val)
+{
+
+ if(tmp_classifier->has_presence_mask)
+ {
+ classifier_val->presence_mask = tmp_classifier->presence_mask;
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_TPID)
+ {
+ classifier_val->o_tpid = tmp_classifier->o_tpid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_tpid = %d\n", classifier_val->o_tpid);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_VID)
+ {
+ classifier_val->o_vid = tmp_classifier->o_vid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_vid = %d\n", classifier_val->o_vid);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_TPID)
+ {
+ classifier_val->i_tpid = tmp_classifier->i_tpid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_tpid = %d\n", classifier_val->i_tpid);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_VID)
+ {
+ classifier_val->i_vid = tmp_classifier->i_vid;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_vid = %d\n", classifier_val->i_vid);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_PBITS)
+ {
+ classifier_val->o_pbits = tmp_classifier->o_pbits;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_pbits = %d\n", classifier_val->o_pbits);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_PBITS)
+ {
+ classifier_val->i_pbits = tmp_classifier->i_pbits;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_pbits = %d\n", classifier_val->i_pbits);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_ETHER_TYPE)
+ {
+ classifier_val->ether_type = tmp_classifier->ether_type;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ether_type = %x\n", classifier_val->ether_type);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_MAC)
+ {
+ if(tmp_classifier->dst_mac.len > BCMOS_ETH_ALEN)
+ {
+ memcpy(classifier_val->dst_mac.u8,
+ tmp_classifier->dst_mac.data, tmp_classifier->dst_mac.len);
+ /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_mac= %d\n", classifier_val->dst_mac);*/
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "dst_mac should not be more than 6 bytes."
+ "actual bytes %lud\n", tmp_classifier->dst_mac.len);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_MAC)
+ {
+ if(tmp_classifier->src_mac.len > BCMOS_ETH_ALEN)
+ {
+ memcpy(classifier_val->src_mac.u8,
+ tmp_classifier->src_mac.data, tmp_classifier->src_mac.len);
+ /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_mac= %x\n", classifier_val->src_mac);*/
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "src_mac should not be more than 6 bytes."
+ "actual bytes %lud\n", tmp_classifier->src_mac.len);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_IP_PROTO)
+ {
+ classifier_val->ip_proto = tmp_classifier->ip_proto;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ip_proto = %x\n", classifier_val->ip_proto);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_IP)
+ {
+ classifier_val->dst_ip.u32 = tmp_classifier->dst_ip;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_ip = %x\n", classifier_val->dst_ip.u32);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_IP)
+ {
+ classifier_val->src_ip.u32 = tmp_classifier->src_ip;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_ip = %x\n", classifier_val->src_ip.u32);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_PORT)
+ {
+ classifier_val->src_port = tmp_classifier->src_port;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_port = %d\n", classifier_val->src_port);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_PORT)
+ {
+ classifier_val->dst_port = tmp_classifier->dst_port;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_port = %d\n", classifier_val->dst_port);
+ }
+
+ if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_PKT_TAG_TYPE)
+ {
+ classifier_val->pkt_tag_type = tmp_classifier->pkt_tag_type;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->pkt_tag_type = %x\n", classifier_val->pkt_tag_type);
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->presence_mask = %x\n", classifier_val->presence_mask);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Classifier is not present in the flow\n");
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+/********************************************************************\
+ * Function : bal_flow_cfg_req *
+ * Description : Configure the the OLT DEVICE with flow information *
+ * using BAL Apis *
+ ********************************************************************/
+uint32_t bal_flow_cfg_set(BalFlowCfg *flow_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ BalErrno bal_err = BAL_ERRNO__BAL_ERR_OK;
+ bcmbal_flow_cfg cfg; /**< declare main API struct */
+ bcmbal_flow_key key = { 0, 0}; /**< declare key */
+ bcmbal_classifier classifier_value = {};
+ bcmbal_action action_value = {};
+ bcmbal_tm_queue_ref queue_value = {};
+
+ /* build key from CLI parameters */
+ if(flow_cfg->key->has_flow_id)
+ {
+ key.flow_id = (bcmbal_flow_id) flow_cfg->key->flow_id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid Flow Id (%d)\n", flow_cfg->key->flow_id);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Adding the flow to OLT. FlowID(%d)\n", flow_cfg->key->flow_id);
+
+ if (!flow_cfg->key->has_flow_type &&
+ ((flow_cfg->key->flow_type < BAL_FLOW_TYPE__BAL_FLOW_TYPE_UPSTREAM) ||
+ flow_cfg->key->flow_type > BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST ))
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Flow type is not supported (%d)\n", flow_cfg->key->flow_type);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "flow_type = %d\n", flow_cfg->key->flow_type);
+ key.flow_type = (bcmbal_flow_type) flow_cfg->key->flow_type;
+ }
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg, flow, key);
+
+ /* decode API parameters from grpc-c */
+ /* Admin State */
+ ASFVOLT_CFG_PROP_SET(cfg, flow, admin_state,
+ flow_cfg->data->has_admin_state,
+ flow_cfg->data->admin_state);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "admin state = %d\n", flow_cfg->data->admin_state);
+
+ /* Operational status */
+ ASFVOLT_CFG_PROP_SET(cfg, flow, oper_status,
+ flow_cfg->data->has_oper_status,
+ flow_cfg->data->oper_status);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Oper. status = %d\n", flow_cfg->data->oper_status);
+
+ /* Access Side interface ID */
+ ASFVOLT_CFG_PROP_SET(cfg, flow, access_int_id,
+ BCMOS_TRUE,
+ flow_cfg->data->access_int_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "access_int_id = %d\n", flow_cfg->data->access_int_id);
+
+ /* Network interface ID */
+ ASFVOLT_CFG_PROP_SET(cfg, flow, network_int_id,
+ BCMOS_TRUE,
+ flow_cfg->data->network_int_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "network_int_id = %d\n", flow_cfg->data->network_int_id);
+
+ /* ONU ID */
+ if(BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST != flow_cfg->key->flow_type)
+ {
+ ASFVOLT_CFG_PROP_SET(cfg, flow, sub_term_id,
+ flow_cfg->data->has_sub_term_id,
+ flow_cfg->data->sub_term_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "sub_term_id = %d\n", flow_cfg->data->sub_term_id);
+ }
+ else if (BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST == flow_cfg->key->flow_type)
+ {
+ /* In case of Multicast the flow belongs to particular group */
+ ASFVOLT_CFG_PROP_SET(cfg, flow, group_id,
+ flow_cfg->data->has_group_id,
+ flow_cfg->data->group_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "group_id = %d\n", flow_cfg->data->group_id);
+ }
+
+ /*Subscriber Terminal UNI index*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, sub_term_uni_idx,
+ flow_cfg->data->has_sub_term_uni_idx,
+ flow_cfg->data->sub_term_uni_idx);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "sub_term_uni_idx = %d\n", flow_cfg->data->sub_term_uni_idx);
+
+ /*Resolve MAC*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, resolve_mac,
+ flow_cfg->data->has_resolve_mac,
+ flow_cfg->data->resolve_mac);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "resolve_mac = %d\n", flow_cfg->data->resolve_mac);
+
+ /*Gem port*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, svc_port_id,
+ flow_cfg->data->has_svc_port_id,
+ flow_cfg->data->svc_port_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "svc_port_id = %d\n", flow_cfg->data->svc_port_id);
+
+ /*priority*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, priority,
+ flow_cfg->data->has_priority,
+ flow_cfg->data->priority);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "priority = %d\n",flow_cfg->data->priority);
+
+ BalClassifier *tmp_classifier = (BalClassifier*)(flow_cfg->data->classifier);
+
+ if (tmp_classifier != NULL)
+ {
+ bal_err = bal_fill_classifier_cfg(tmp_classifier, &classifier_value);
+
+ if(bal_err != BAL_ERRNO__BAL_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Addition of flow %d failed while processing classifier\n",
+ flow_cfg->key->flow_id);
+ return bal_err;
+ }
+
+ ASFVOLT_CFG_PROP_SET(cfg, flow, classifier, BCMOS_TRUE, classifier_value);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "No Classifier for flow\n");
+ }
+
+ BalAction *tmp_action = (BalAction*)(flow_cfg->data->action);
+
+ if (tmp_action != NULL)
+ {
+ bal_err = bal_fill_action_cfg(tmp_action, &action_value);
+
+ if(bal_err != BAL_ERRNO__BAL_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Addition of flow %d failed while processing action\n",
+ flow_cfg->key->flow_id);
+ return bal_err;
+ }
+ ASFVOLT_CFG_PROP_SET(cfg, flow, action, BCMOS_TRUE, action_value);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "No Action for flow\n");
+ }
+
+ /*cookie*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, cookie,
+ flow_cfg->data->has_cookie,
+ flow_cfg->data->cookie);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "priority = %lx\n",flow_cfg->data->cookie);
+
+ /*Egress queue*/
+ BalTmQueueRef *tmp_que = (BalTmQueueRef*)(flow_cfg->data->queue);
+
+ if (tmp_que != NULL)
+ {
+ bal_err = bal_fill_queue_cfg(tmp_que, &queue_value);
+
+ if(bal_err != BAL_ERRNO__BAL_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Addition of flow %d failed while processing queue\n",
+ flow_cfg->key->flow_id);
+ return bal_err;
+ }
+ ASFVOLT_CFG_PROP_SET(cfg, flow, queue, BCMOS_TRUE, queue_value);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "No queue Information for flow");
+ }
+ /*dba_tm_sched_id*/
+ ASFVOLT_CFG_PROP_SET(cfg, flow, dba_tm_sched_id,
+ flow_cfg->data->has_dba_tm_sched_id,
+ flow_cfg->data->dba_tm_sched_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "tm_sched used for dba = %d\n",flow_cfg->data->dba_tm_sched_id);
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
+ if(err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Failed to configure the flow. FlowId(%d)\n", key.flow_id);
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_flow_cfg_clear *
+ * Description : Deletes/Clears the OLT DEVICE with flow
+ * information using BAL Apis *
+ ********************************************************************/
+uint32_t bal_flow_cfg_clear(BalFlowKey *flow_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_flow_cfg cfg; /**< declare main API struct */
+ bcmbal_flow_key key = { }; /**< declare key */
+
+ if (flow_key->has_flow_id && flow_key->has_flow_type)
+ {
+ key.flow_id = flow_key->flow_id;
+ key.flow_type = flow_key->flow_type;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to clear FlowId(%d), FlowType(%d)\n",
+ key.flow_id, key.flow_type);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "FlowId(%d), FlowType(%d)\n", key.flow_id, key.flow_type);
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg, flow, key);
+
+ /* call API */
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
+ if( err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "Failed to clear the Flow. FlowID(%d) FlowType(%d)\n",
+ key.flow_id, key.flow_type);
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_flow_cfg_get *
+ * Description : Get flow information from BAL. *
+ ********************************************************************/
+uint32_t bal_flow_cfg_get(BalFlowKey *flow_key, BalFlowCfg *flow_cfg)
+{
+
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_flow_cfg cfg; /**< declare main API struct */
+ bcmbal_flow_key key = { }; /**< declare key */
+
+ if (flow_key->has_flow_id && flow_key->has_flow_type)
+ {
+ key.flow_id = flow_key->flow_id;
+ key.flow_type = flow_key->flow_type;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to get cfg FlowId(%d), FlowType(%d)\n",
+ key.flow_id, key.flow_type);
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg, flow, key);
+
+ BCMBAL_CFG_PROP_GET(&cfg, flow, all_properties);
+
+ /* call API */
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &cfg.hdr);
+ if( err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "Failed to get Flow Info. FlowID(%d) FlowType(%d)\n",
+ key.flow_id, key.flow_type);
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "To-Do. Send Flow details to Adapter\n");
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
diff --git a/src/main.c b/src/bal_flow_hdlr.h
old mode 100644
new mode 100755
similarity index 64%
copy from src/main.c
copy to src/bal_flow_hdlr.h
index b62bc6e..1b6cfc6
--- a/src/main.c
+++ b/src/bal_flow_hdlr.h
@@ -13,13 +13,9 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_flow_cfg_set(BalFlowCfg *flow_cfg);
+extern uint32_t bal_flow_cfg_clear(BalFlowKey *flow_key);
+extern uint32_t bal_flow_cfg_get(BalFlowKey *flow_key, BalFlowCfg *flow_cfg);
+extern uint32_t bal_fill_classifier_cfg(BalClassifier *tmp_classifier,
+ bcmbal_classifier *classifier_val);
diff --git a/src/bal_group_hdlr.c b/src/bal_group_hdlr.c
new file mode 100755
index 0000000..5c05425
--- /dev/null
+++ b/src/bal_group_hdlr.c
@@ -0,0 +1,282 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "asfvolt16_driver.h"
+#include "bal_group_hdlr.h"
+
+
+/********************************************************************\
+ * Function : bal_group_cfg_req *
+ * Description : Configures the OLT device *
+ ********************************************************************/
+
+uint32_t bal_group_cfg_set(BalGroupCfg *tm_group_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_group_cfg grp_cfg_obj; /**< declare main API struct */
+ bcmbal_group_key key = { }; /**< declare key */
+ int grp_mem_idx;
+
+ if(tm_group_cfg->key->has_group_id)
+ {
+ key.group_id = tm_group_cfg->key->group_id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the group cfg(OLT): Group Id was not present \n");
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT(group cfg) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&grp_cfg_obj, group, key);
+
+ /* decode API parameters from GRPC */
+ if(tm_group_cfg->data->has_members_cmd)
+ {
+ ASFVOLT_CFG_PROP_SET(grp_cfg_obj, group, members_cmd,
+ tm_group_cfg->data->has_members_cmd,
+ tm_group_cfg->data->members_cmd);
+ }
+
+ if(tm_group_cfg->data->has_cookie)
+ {
+ ASFVOLT_CFG_PROP_SET(grp_cfg_obj, group, cookie,
+ tm_group_cfg->data->has_cookie,
+ tm_group_cfg->data->cookie);
+ }
+
+ BalIdList *balFlows = (BalIdList *)tm_group_cfg->data->flows;
+ bcmbal_flow_id_list_u32 valFlows = {};
+
+ valFlows.len = balFlows->n_val;
+ valFlows.val = (bcmbal_flow_id *)malloc((valFlows.len)*sizeof(bcmbal_flow_id));
+ if(!valFlows.val)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the group cfg(OLT): Memory Exhausted\n");
+ return BAL_ERRNO__BAL_ERR_NOMEM;
+ }
+ memcpy((void *)valFlows.val, (const void *)balFlows->val,
+ (balFlows->n_val)*sizeof(bcmbal_flow_id));
+ ASFVOLT_CFG_PROP_SET(grp_cfg_obj, group, flows, BCMOS_TRUE, valFlows);
+
+ if(tm_group_cfg->data->has_owner)
+ {
+ ASFVOLT_CFG_PROP_SET(grp_cfg_obj, group, owner,
+ tm_group_cfg->data->has_owner,
+ tm_group_cfg->data->owner);
+ }
+
+ BalGroupMemberInfoList *balMembers =
+ (BalGroupMemberInfoList *)tm_group_cfg->data->members;
+ bcmbal_group_member_info_list_u16 valMembers = {};
+ /*if(balMembers->has_len)*/
+ {
+ valMembers.len = balMembers->n_val;
+ valMembers.val =
+ (bcmbal_group_member_info *)malloc((valMembers.len)*sizeof(bcmbal_group_member_info));
+ if(!valMembers.val)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the group cfg(OLT): Memory Exhausted\n");
+ return BAL_ERRNO__BAL_ERR_NOMEM;
+ }
+ //check
+ //valMembers.val = &balMembers->val;
+ for(grp_mem_idx = 0; grp_mem_idx < valMembers.len; grp_mem_idx++)
+ {
+ if(balMembers->val[grp_mem_idx]->has_intf_id)
+ {
+ valMembers.val[grp_mem_idx].intf_id
+ = balMembers->val[grp_mem_idx]->intf_id;
+ }
+ if(balMembers->val[grp_mem_idx]->has_svc_port_id)
+ {
+ valMembers.val[grp_mem_idx].svc_port_id
+ = balMembers->val[grp_mem_idx]->svc_port_id;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_presence_mask)
+ {
+ valMembers.val[grp_mem_idx].action.presence_mask
+ = balMembers->val[grp_mem_idx]->action->presence_mask;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_cmds_bitmask)
+ {
+ valMembers.val[grp_mem_idx].action.cmds_bitmask
+ = balMembers->val[grp_mem_idx]->action->cmds_bitmask;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_o_vid)
+ {
+ valMembers.val[grp_mem_idx].action.o_vid
+ = balMembers->val[grp_mem_idx]->action->o_vid;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_o_pbits)
+ {
+ valMembers.val[grp_mem_idx].action.o_pbits
+ = balMembers->val[grp_mem_idx]->action->o_pbits;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_o_tpid)
+ {
+ valMembers.val[grp_mem_idx].action.o_tpid
+ = balMembers->val[grp_mem_idx]->action->o_tpid;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_i_vid)
+ {
+ valMembers.val[grp_mem_idx].action.i_vid
+ = balMembers->val[grp_mem_idx]->action->i_vid;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_i_pbits)
+ {
+ valMembers.val[grp_mem_idx].action.i_pbits
+ = balMembers->val[grp_mem_idx]->action->i_pbits;
+ }
+ if(balMembers->val[grp_mem_idx]->action->has_i_tpid)
+ {
+ valMembers.val[grp_mem_idx].action.i_tpid
+ = balMembers->val[grp_mem_idx]->action->i_tpid;
+ }
+ if(balMembers->val[grp_mem_idx]->queue->has_sched_id)
+ {
+ valMembers.val[grp_mem_idx].queue.sched_id
+ = balMembers->val[grp_mem_idx]->queue->sched_id;
+ }
+ if(balMembers->val[grp_mem_idx]->queue->has_queue_id)
+ {
+ valMembers.val[grp_mem_idx].queue.queue_id
+ = balMembers->val[grp_mem_idx]->queue->queue_id;
+ }
+ }
+ ASFVOLT_CFG_PROP_SET(grp_cfg_obj, group, members, BCMOS_TRUE, valMembers);
+ }
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(grp_cfg_obj.hdr));
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the group cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nSet Group configuration sent to OLT for Group Id(%d)\n",
+ key.group_id);
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_group_get_req *
+ * Description : get the OLT device group cfg *
+ ********************************************************************/
+
+uint32_t bal_group_cfg_get(BalGroupKey *tm_group_cfg_key,
+ BalGroupCfg *tm_group_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_group_cfg grp_cfg_obj; /**< declare main API struct */
+ bcmbal_group_key key = { }; /**< declare key */
+
+ if(tm_group_cfg_key->has_group_id)
+ {
+ key.group_id = tm_group_cfg_key->group_id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the group cfg(OLT): Group Id was not present\n");
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Get group cfg(for OLT) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&grp_cfg_obj, group, key);
+
+ /* request all properties, include everything */
+ BCMBAL_CFG_PROP_GET(&grp_cfg_obj, group, all_properties);
+
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &grp_cfg_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the group Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nGet Group cfg sent to OLT for Group Id(%d)\n",
+ key.group_id);
+ return err;
+}
+
+/********************************************************************\
+ * Function : bal_group_clear_req *
+ * Description : clears the OLT device group cfg *
+ ********************************************************************/
+
+uint32_t bal_group_cfg_clear(BalGroupKey *tm_group_cfg_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_group_cfg grp_cfg_obj; /**< declare main API struct */
+ bcmbal_group_key key = { }; /**< declare key */
+
+ if(tm_group_cfg_key->has_group_id)
+ {
+ key.group_id = tm_group_cfg_key->group_id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the group cfg(OLT): Group Id was not present\n");
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(group cfg) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&grp_cfg_obj, group, key);
+
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &grp_cfg_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the group Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nClear Group cfg clear sent to OLT for Group Id(%d) \n",
+ key.group_id);
+ return err;
+}
+
+/********************************************************************\
+ * Function : bal_group_cfg_indication_cb *
+ * Description : Call back function registered with BAL to handle *
+ * event related to access terminal *
+ ********************************************************************/
+bcmos_errno bal_group_cfg_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+ ASFVOLT_LOG(ASFVOLT_INFO, "Processing API ('%s)\n' IND callback status is (%s)\n",
+ bcmbal_objtype_str(obj->obj_type),
+ bcmos_strerror(obj->status));
+
+ return result;
+}
+
+
diff --git a/src/main.c b/src/bal_group_hdlr.h
old mode 100644
new mode 100755
similarity index 65%
copy from src/main.c
copy to src/bal_group_hdlr.h
index b62bc6e..9e046fb
--- a/src/main.c
+++ b/src/bal_group_hdlr.h
@@ -13,13 +13,9 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_group_cfg_set(BalGroupCfg *tm_group_cfg);
+extern uint32_t bal_group_cfg_get(BalGroupKey *tm_group_cfg_key,
+ BalGroupCfg *tm_group_cfg);
+extern uint32_t bal_group_cfg_clear(BalGroupKey *tm_group_cfg_key);
+extern bcmos_errno bal_group_cfg_indication_cb(bcmbal_obj *obj);
diff --git a/src/bal_indications_hdlr.c b/src/bal_indications_hdlr.c
new file mode 100755
index 0000000..1c34d6e
--- /dev/null
+++ b/src/bal_indications_hdlr.c
@@ -0,0 +1,1816 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "bal_indications_hdlr.h"
+
+/*static bcmos_mutex bal_ind_lock; - Need to define bcm independent mutex*/
+/********************************************************************\
+ * Function : bal_acc_term_indication_cb *
+ * Description : This function will handle the indications for *
+ * Access Terminal Indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_acc_term_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
+ bcmbal_access_terminal_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "suhas:Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_access_terminal_ind *acc_term_ind = (bcmbal_access_terminal_ind *)obj;
+
+
+ BalAccessTerminalInd acessTermInd;
+ memset(&acessTermInd, 0, sizeof(BalAccessTerminalInd));
+ bal_access_terminal_ind__init(&acessTermInd);
+ balIndCfg.access_term_ind = &acessTermInd;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.access_term_ind->hdr = &hdr;
+
+ BalAccessTerminalKey accessTermkey;
+ memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
+ bal_access_terminal_key__init(&accessTermkey);
+ balIndCfg.access_term_ind->key = &accessTermkey;
+
+ balIndCfg.access_term_ind->key->has_access_term_id = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->key->access_term_id = acc_term_ind->key.access_term_id;
+
+ BalAccessTerminalIndData accessTermIndData;
+ memset(&accessTermIndData, 0, sizeof(BalAccessTerminalIndData));
+ bal_access_terminal_ind_data__init(&accessTermIndData);
+ balIndCfg.access_term_ind->data = &accessTermIndData;
+
+ balIndCfg.access_term_ind->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->admin_state = acc_term_ind->data.admin_state;
+ balIndCfg.access_term_ind->data->has_oper_status = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->oper_status = acc_term_ind->data.oper_status;
+ balIndCfg.access_term_ind->data->has_iwf_mode = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->iwf_mode = acc_term_ind->data.iwf_mode;
+
+ BalTopology balTop;
+ memset(&balTop, 0, sizeof(BalTopology));
+ bal_topology__init(&balTop);
+ balIndCfg.access_term_ind->data->topology = &balTop;
+
+ balIndCfg.access_term_ind->data->topology->has_num_of_nni_ports = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->num_of_nni_ports =
+ acc_term_ind->data.topology.num_of_nni_ports;
+ balIndCfg.access_term_ind->data->topology->has_num_of_pon_ports = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->num_of_pon_ports =
+ acc_term_ind->data.topology.num_of_pon_ports;
+ balIndCfg.access_term_ind->data->topology->has_num_of_mac_devs = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->num_of_mac_devs =
+ acc_term_ind->data.topology.num_of_mac_devs;
+ balIndCfg.access_term_ind->data->topology->has_num_of_pons_per_mac_dev = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->num_of_pons_per_mac_dev =
+ acc_term_ind->data.topology.num_of_pons_per_mac_dev;
+ balIndCfg.access_term_ind->data->topology->has_pon_family = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->pon_family =
+ acc_term_ind->data.topology.pon_family;
+ balIndCfg.access_term_ind->data->topology->has_pon_sub_family = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->topology->pon_sub_family =
+ acc_term_ind->data.topology.pon_sub_family;
+
+ BalSwVersion balsv;
+ memset(&balsv, 0, sizeof(BalSwVersion));
+ bal_sw_version__init(&balsv);
+ balIndCfg.access_term_ind->data->sw_version = &balsv;
+
+ balIndCfg.access_term_ind->data->sw_version->has_version_type = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->version_type =
+ acc_term_ind->data.sw_version.version_type;
+ balIndCfg.access_term_ind->data->sw_version->has_major_rev = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->major_rev =
+ acc_term_ind->data.sw_version.major_rev;
+ balIndCfg.access_term_ind->data->sw_version->has_minor_rev = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->minor_rev =
+ acc_term_ind->data.sw_version.minor_rev;
+ balIndCfg.access_term_ind->data->sw_version->has_patch_rev = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->patch_rev =
+ acc_term_ind->data.sw_version.patch_rev;
+ balIndCfg.access_term_ind->data->sw_version->has_om_version = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->om_version =
+ acc_term_ind->data.sw_version.om_version;
+ balIndCfg.access_term_ind->data->sw_version->has_dev_point = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind->data->sw_version->dev_point =
+ acc_term_ind->data.sw_version.dev_point;
+
+ bal_register_indication_cbs();
+
+ BalErr *output;
+ result = bal_ind__bal_acc_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_acc_term_osc_indication_cb *
+ * Description : This function will handle the indications for *
+ * Access Terminal Operational State Change *
+ * *
+ ********************************************************************/
+bcmos_errno bal_acc_term_osc_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
+ bcmbal_access_terminal_auto_id_oper_status_change != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND_OP_STATE;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_access_terminal_oper_status_change *acc_term_osc =
+ (bcmbal_access_terminal_oper_status_change *)obj;
+
+ BalAccessTerminalOperStatusChange acessTermOSC;
+ memset(&acessTermOSC, 0, sizeof(BalAccessTerminalOperStatusChange));
+ bal_access_terminal_oper_status_change__init(&acessTermOSC);
+ balIndCfg.access_term_ind_op_state = &acessTermOSC;
+
+ BalAccessTerminalKey accessTermkey;
+ memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
+ bal_access_terminal_key__init(&accessTermkey);
+ balIndCfg.access_term_ind_op_state->key = &accessTermkey;
+
+ balIndCfg.access_term_ind_op_state->key->has_access_term_id = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind_op_state->key->access_term_id =
+ acc_term_osc->key.access_term_id;
+
+ BalAccessTerminalOperStatusChangeData accessTermOscData;
+ memset(&accessTermOscData, 0, sizeof(BalAccessTerminalOperStatusChangeData));
+ bal_access_terminal_oper_status_change_data__init(&accessTermOscData);
+ balIndCfg.access_term_ind_op_state->data = &accessTermOscData;
+
+ balIndCfg.access_term_ind_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind_op_state->data->new_oper_status =
+ acc_term_osc->data.new_oper_status;
+ balIndCfg.access_term_ind_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind_op_state->data->old_oper_status =
+ acc_term_osc->data.old_oper_status;
+ balIndCfg.access_term_ind_op_state->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.access_term_ind_op_state->data->admin_state =
+ acc_term_osc->data.admin_state;
+
+ BalErr *output;
+ result = bal_ind__bal_acc_term_oper_sts_cng_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_flow_osc_indication_cb *
+ * Description : This function will handle the indications for *
+ * Flow Operational State Change *
+ * *
+ ********************************************************************/
+bcmos_errno bal_flow_osc_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
+ bcmbal_flow_auto_id_oper_status_change != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_OP_STATE;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_flow_oper_status_change *flow_osc = (bcmbal_flow_oper_status_change *)obj;
+
+ BalFlowOperStatusChange flowOscInd;
+ memset(&flowOscInd, 0, sizeof(BalFlowOperStatusChange));
+ bal_flow_oper_status_change__init(&flowOscInd);
+ balIndCfg.flow_op_state = &flowOscInd;
+
+ BalFlowKey flowkey;
+ memset(&flowkey, 0, sizeof(BalFlowKey));
+ bal_flow_key__init(&flowkey);
+ balIndCfg.flow_op_state->key = &flowkey;
+
+ balIndCfg.flow_op_state->key->has_flow_id = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->key->flow_id = flow_osc->key.flow_id;
+ balIndCfg.flow_op_state->key->has_flow_type = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->key->flow_type = flow_osc->key.flow_type;
+
+ BalFlowOperStatusChangeData flowOscIndData;
+ memset(&flowOscIndData, 0, sizeof(BalFlowOperStatusChangeData));
+ bal_flow_oper_status_change_data__init(&flowOscIndData);
+ balIndCfg.flow_op_state->data = &flowOscIndData;
+
+ balIndCfg.flow_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->new_oper_status = flow_osc->data.new_oper_status;
+ balIndCfg.flow_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->old_oper_status = flow_osc->data.old_oper_status;
+ balIndCfg.flow_op_state->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->admin_state = flow_osc->data.admin_state;
+ balIndCfg.flow_op_state->data->has_svc_port_id = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->svc_port_id = flow_osc->data.svc_port_id;
+ balIndCfg.flow_op_state->data->has_dba_tm_sched_id = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->dba_tm_sched_id = flow_osc->data.dba_tm_sched_id;
+ balIndCfg.flow_op_state->data->has_cookie = BAL_GRPC_PRES;
+ balIndCfg.flow_op_state->data->cookie = flow_osc->data.cookie;
+
+ BalErr *output;
+ result = bal_ind__bal_flow_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_flow_indication_cb *
+ * Description : This function will handle the indications for *
+ * Flow Indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_flow_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
+ bcmbal_flow_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_flow_ind *flow_ind = (bcmbal_flow_ind *)obj;
+
+ BalFlowInd flowInd;
+ memset(&flowInd, 0, sizeof(BalFlowInd));
+ bal_flow_ind__init(&flowInd);
+ balIndCfg.flow_ind = &flowInd;
+
+ BalFlowKey flowkey;
+ memset(&flowkey, 0, sizeof(BalFlowKey));
+ bal_flow_key__init(&flowkey);
+ balIndCfg.flow_ind->key = &flowkey;
+
+ balIndCfg.flow_ind->key->has_flow_id = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->key->flow_id = flow_ind->key.flow_id;
+ balIndCfg.flow_ind->key->has_flow_type = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->key->flow_type = flow_ind->key.flow_type;
+
+ BalFlowIndData flowIndData;
+ memset(&flowIndData, 0, sizeof(BalFlowIndData));
+ bal_flow_ind_data__init(&flowIndData);
+ balIndCfg.flow_ind->data = &flowIndData;
+
+ balIndCfg.flow_ind->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->admin_state = flow_ind->data.admin_state;
+ balIndCfg.flow_ind->data->has_oper_status= BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->oper_status= flow_ind->data.oper_status;
+ balIndCfg.flow_ind->data->has_access_int_id = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->access_int_id = flow_ind->data.access_int_id;
+ balIndCfg.flow_ind->data->has_network_int_id = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->network_int_id = flow_ind->data.network_int_id;
+ balIndCfg.flow_ind->data->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->sub_term_id = flow_ind->data.sub_term_id;
+ balIndCfg.flow_ind->data->has_sub_term_uni_idx = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->sub_term_uni_idx = flow_ind->data.sub_term_uni_idx;
+ balIndCfg.flow_ind->data->has_svc_port_id = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->svc_port_id = flow_ind->data.svc_port_id;
+ balIndCfg.flow_ind->data->has_resolve_mac = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->resolve_mac = flow_ind->data.resolve_mac;
+ balIndCfg.flow_ind->data->has_cookie = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->cookie = flow_ind->data.cookie;
+
+ BalClassifier balClassifier;
+ memset(&balClassifier, 0, sizeof(BalClassifier));
+ bal_classifier__init(&balClassifier);
+ balIndCfg.flow_ind->data->classifier = &balClassifier;
+
+ balIndCfg.flow_ind->data->classifier->has_presence_mask = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->presence_mask = flow_ind->data.classifier.presence_mask;
+ balIndCfg.flow_ind->data->classifier->has_o_tpid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->o_tpid = flow_ind->data.classifier.o_tpid;
+ balIndCfg.flow_ind->data->classifier->has_o_vid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->o_vid = flow_ind->data.classifier.o_vid;
+ balIndCfg.flow_ind->data->classifier->has_i_tpid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->i_tpid = flow_ind->data.classifier.i_tpid;
+ balIndCfg.flow_ind->data->classifier->has_i_vid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->i_vid = flow_ind->data.classifier.i_vid;
+ balIndCfg.flow_ind->data->classifier->has_o_pbits = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->o_pbits = flow_ind->data.classifier.o_pbits;
+ balIndCfg.flow_ind->data->classifier->has_i_pbits = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->i_pbits = flow_ind->data.classifier.i_pbits;
+ balIndCfg.flow_ind->data->classifier->has_ether_type = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->ether_type = flow_ind->data.classifier.ether_type;
+ balIndCfg.flow_ind->data->classifier->has_dst_mac = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->dst_mac.len =
+ (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.dst_mac.u8);
+ memcpy(balIndCfg.flow_ind->data->classifier->dst_mac.data,
+ flow_ind->data.classifier.dst_mac.u8,
+ balIndCfg.flow_ind->data->classifier->dst_mac.len);
+ balIndCfg.flow_ind->data->classifier->has_src_mac = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->src_mac.len =
+ (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.src_mac.u8);
+ memcpy(balIndCfg.flow_ind->data->classifier->src_mac.data,
+ flow_ind->data.classifier.src_mac.u8,
+ balIndCfg.flow_ind->data->classifier->src_mac.len);
+ balIndCfg.flow_ind->data->classifier->has_ip_proto = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->ip_proto = flow_ind->data.classifier.ip_proto;
+ balIndCfg.flow_ind->data->classifier->has_dst_ip = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->dst_ip = flow_ind->data.classifier.dst_ip.u32;
+ balIndCfg.flow_ind->data->classifier->has_src_ip = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->src_ip = flow_ind->data.classifier.src_ip.u32;
+ balIndCfg.flow_ind->data->classifier->has_src_port = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->src_port = flow_ind->data.classifier.src_port;
+ balIndCfg.flow_ind->data->classifier->has_dst_port = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->dst_port = flow_ind->data.classifier.dst_port;
+ balIndCfg.flow_ind->data->classifier->has_pkt_tag_type = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->classifier->pkt_tag_type = flow_ind->data.classifier.pkt_tag_type;
+
+ BalAction balAction;
+ memset(&balAction, 0, sizeof(BalAction));
+ bal_action__init(&balAction);
+ balIndCfg.flow_ind->data->action = &balAction;
+
+ balIndCfg.flow_ind->data->action->has_presence_mask = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->presence_mask = flow_ind->data.action.presence_mask;
+ balIndCfg.flow_ind->data->action->has_cmds_bitmask = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->cmds_bitmask = flow_ind->data.action.cmds_bitmask;
+ balIndCfg.flow_ind->data->action->has_o_vid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->o_vid = flow_ind->data.action.o_vid;
+ balIndCfg.flow_ind->data->action->has_o_pbits = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->o_pbits = flow_ind->data.action.o_pbits;
+ balIndCfg.flow_ind->data->action->has_o_tpid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->o_tpid = flow_ind->data.action.o_tpid;
+ balIndCfg.flow_ind->data->action->has_i_vid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->i_vid = flow_ind->data.action.i_vid;
+ balIndCfg.flow_ind->data->action->has_i_pbits = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->i_pbits = flow_ind->data.action.i_pbits;
+ balIndCfg.flow_ind->data->action->has_i_tpid = BAL_GRPC_PRES;
+ balIndCfg.flow_ind->data->action->i_tpid = flow_ind->data.action.i_tpid;
+ BalErr *output;
+ result = bal_ind__bal_flow_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_group_indication_cb *
+ * Description : This function will handle the indications for *
+ * Group Indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_group_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_GROUP != obj->obj_type ||
+ bcmbal_group_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_GROUP_IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_group_ind *group_ind = (bcmbal_group_ind *)obj;
+
+ BalGroupInd groupInd;
+ memset(&groupInd, 0, sizeof(BalGroupInd));
+ bal_group_ind__init(&groupInd);
+ balIndCfg.group_ind = &groupInd;
+
+ BalGroupKey groupkey;
+ memset(&groupkey, 0, sizeof(BalGroupKey));
+ bal_group_key__init(&groupkey);
+ balIndCfg.group_ind->key = &groupkey;
+
+ balIndCfg.group_ind->key->has_group_id = BAL_GRPC_PRES;
+ balIndCfg.group_ind->key->group_id = group_ind->key.group_id;
+
+ BalGroupIndData groupIndData;
+ memset(&groupIndData, 0, sizeof(BalGroupIndData));
+ bal_group_ind_data__init(&groupIndData);
+ balIndCfg.group_ind->data = &groupIndData;
+
+ balIndCfg.group_ind->data->has_members_cmd = BAL_GRPC_PRES;
+ balIndCfg.group_ind->data->members_cmd = group_ind->data.members_cmd;
+ balIndCfg.group_ind->data->has_cookie = BAL_GRPC_PRES;
+ balIndCfg.group_ind->data->cookie = group_ind->data.cookie;
+ balIndCfg.group_ind->data->has_owner = BAL_GRPC_PRES;
+ balIndCfg.group_ind->data->owner = group_ind->data.owner;
+
+ BalGroupMemberInfoList balMembers;
+ memset(&balMembers, 0, sizeof(BalGroupMemberInfoList));
+ bal_group_member_info_list__init(&balMembers);
+ balIndCfg.group_ind->data->members = &balMembers;
+
+ balIndCfg.group_ind->data->members->n_val = group_ind->data.members.len;
+
+ BalGroupMemberInfo *balMemberInfo;
+ balMemberInfo = (BalGroupMemberInfo *)malloc(sizeof(BalGroupMemberInfo));
+ memset(&balMemberInfo, 0, sizeof(BalGroupMemberInfo));
+ bal_group_member_info__init(balMemberInfo);
+ balIndCfg.group_ind->data->members->val = &balMemberInfo;
+
+ balMemberInfo->has_intf_id = BAL_GRPC_PRES;
+ balMemberInfo->intf_id = group_ind->data.members.val->intf_id;
+ balMemberInfo->has_svc_port_id = BAL_GRPC_PRES;
+ balMemberInfo->svc_port_id = group_ind->data.members.val->svc_port_id;
+
+ BalAction balAction;
+ memset(&balAction, 0, sizeof(BalAction));
+ bal_action__init(&balAction);
+ balMemberInfo->action = &balAction;
+
+ balMemberInfo->action->has_presence_mask = BAL_GRPC_PRES;
+ balMemberInfo->action->presence_mask = group_ind->data.members.val->action.presence_mask;
+ balMemberInfo->action->has_cmds_bitmask = BAL_GRPC_PRES;
+ balMemberInfo->action->cmds_bitmask = group_ind->data.members.val->action.cmds_bitmask;
+ balMemberInfo->action->has_o_vid = BAL_GRPC_PRES;
+ balMemberInfo->action->o_vid = group_ind->data.members.val->action.o_vid;
+ balMemberInfo->action->has_o_pbits = BAL_GRPC_PRES;
+ balMemberInfo->action->o_pbits = group_ind->data.members.val->action.o_pbits;
+ balMemberInfo->action->has_o_tpid = BAL_GRPC_PRES;
+ balMemberInfo->action->o_tpid = group_ind->data.members.val->action.o_tpid;
+ balMemberInfo->action->has_i_vid = BAL_GRPC_PRES;
+ balMemberInfo->action->i_vid = group_ind->data.members.val->action.i_vid;
+ balMemberInfo->action->has_i_pbits = BAL_GRPC_PRES;
+ balMemberInfo->action->i_pbits = group_ind->data.members.val->action.i_pbits;
+ balMemberInfo->action->has_i_tpid = BAL_GRPC_PRES;
+ balMemberInfo->action->i_tpid = group_ind->data.members.val->action.i_tpid;
+
+ BalTmQueueRef balQueue;
+ memset(&balQueue, 0, sizeof(BalTmQueueRef));
+ bal_tm_queue_ref__init(&balQueue);
+ balMemberInfo->queue = &balQueue;
+
+ balMemberInfo->queue->has_sched_id = BAL_GRPC_PRES;
+ balMemberInfo->queue->sched_id = group_ind->data.members.val->queue.sched_id;
+ balMemberInfo->queue->has_queue_id = BAL_GRPC_PRES;
+ balMemberInfo->queue->queue_id = group_ind->data.members.val->queue.queue_id;
+
+ BalIdList balFlows;
+ memset(&balFlows, 0, sizeof(BalIdList));
+ bal_id_list__init(&balFlows);
+ balIndCfg.group_ind->data->flows = &balFlows;
+
+ balIndCfg.group_ind->data->flows->n_val = group_ind->data.flows.len;
+ memcpy(balIndCfg.group_ind->data->flows->val, group_ind->data.flows.val,
+ balIndCfg.group_ind->data->flows->n_val);
+
+ BalErr *output;
+ result = bal_ind__bal_group_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_interface_osc_indication_cb *
+ * Description : This function will handle the indications for *
+ * Interface Operational State Change *
+ * *
+ ********************************************************************/
+bcmos_errno bal_interface_osc_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
+ bcmbal_interface_auto_id_oper_status_change != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_OP_STATE;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_interface_oper_status_change *int_osc_ind =
+ (bcmbal_interface_oper_status_change *)obj;
+
+ BalInterfaceOperStatusChange ifOsc;
+ memset(&ifOsc, 0, sizeof(BalInterfaceOperStatusChange));
+ bal_interface_oper_status_change__init(&ifOsc);
+ balIndCfg.interface_op_state = &ifOsc;
+
+ BalInterfaceKey ifkey;
+ memset(&ifkey, 0, sizeof(BalInterfaceKey));
+ bal_interface_key__init(&ifkey);
+ balIndCfg.interface_op_state->key = &ifkey;
+
+ balIndCfg.interface_op_state->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.interface_op_state->key->intf_id = int_osc_ind->key.intf_id;
+ balIndCfg.interface_op_state->key->has_intf_type = BAL_GRPC_PRES;
+ balIndCfg.interface_op_state->key->intf_type = int_osc_ind->key.intf_type;
+
+ BalInterfaceOperStatusChangeData ifOscIndData;
+ memset(&ifOscIndData, 0, sizeof(BalInterfaceOperStatusChangeData));
+ bal_interface_oper_status_change_data__init(&ifOscIndData);
+ balIndCfg.interface_op_state->data = &ifOscIndData;
+
+ balIndCfg.interface_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
+ balIndCfg.interface_op_state->data->new_oper_status = int_osc_ind->data.new_oper_status;
+ balIndCfg.interface_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
+ balIndCfg.interface_op_state->data->old_oper_status = int_osc_ind->data.old_oper_status;
+ balIndCfg.interface_op_state->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.interface_op_state->data->admin_state = int_osc_ind->data.admin_state;
+
+ BalErr *output;
+ result = bal_ind__bal_iface_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_interface_los_indication_cb *
+ * Description : This function will handle the indications for *
+ * Interface los Indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_interface_los_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
+ bcmbal_interface_auto_id_los != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_LOS;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_interface_los *int_los_ind =
+ (bcmbal_interface_los *)obj;
+
+ BalInterfaceLos ifLos;
+ memset(&ifLos, 0, sizeof(BalInterfaceLos));
+ bal_interface_los__init(&ifLos);
+ balIndCfg.interface_los = &ifLos;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.interface_los->hdr = &hdr;
+
+ BalInterfaceKey ifkey;
+ memset(&ifkey, 0, sizeof(BalInterfaceKey));
+ bal_interface_key__init(&ifkey);
+ balIndCfg.interface_los->key = &ifkey;
+
+ balIndCfg.interface_los->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.interface_los->key->intf_id = int_los_ind->key.intf_id;
+ balIndCfg.interface_los->key->has_intf_type = BAL_GRPC_PRES;
+ balIndCfg.interface_los->key->intf_type = int_los_ind->key.intf_type;
+
+ BalInterfaceLosData ifLosIndData;
+ memset(&ifLosIndData, 0, sizeof(BalInterfaceLosData));
+ bal_interface_los_data__init(&ifLosIndData);
+ balIndCfg.interface_los->data = &ifLosIndData;
+
+ balIndCfg.interface_los->data->has_status = BAL_GRPC_PRES;
+ balIndCfg.interface_los->data->status = int_los_ind->data.status;
+
+ BalErr *output;
+ result = bal_ind__bal_iface_los(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_interface_indication_cb *
+ * Description : This function will handle the indications for *
+ * Interface Indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_interface_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
+ bcmbal_interface_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_interface_ind *interface_ind = (bcmbal_interface_ind *)obj;
+
+ BalInterfaceInd ifInd;
+ memset(&ifInd, 0, sizeof(BalInterfaceInd));
+ bal_interface_ind__init(&ifInd);
+ balIndCfg.interface_ind = &ifInd;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.interface_ind->hdr = &hdr;
+
+ BalInterfaceKey ifkey;
+ memset(&ifkey, 0, sizeof(BalInterfaceKey));
+ bal_interface_key__init(&ifkey);
+ balIndCfg.interface_ind->key = &ifkey;
+
+ balIndCfg.interface_ind->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->key->intf_id = interface_ind->key.intf_id;
+ balIndCfg.interface_ind->key->has_intf_type = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->key->intf_type = interface_ind->key.intf_type;
+
+ BalInterfaceIndData ifIndData;
+ memset(&ifIndData, 0, sizeof(BalInterfaceIndData));
+ bal_interface_ind_data__init(&ifIndData);
+ balIndCfg.interface_ind->data = &ifIndData;
+
+ balIndCfg.interface_ind->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->admin_state = interface_ind->data.admin_state;
+ balIndCfg.interface_ind->data->has_oper_status = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->oper_status = interface_ind->data.oper_status;
+ balIndCfg.interface_ind->data->has_min_data_agg_port_id = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->min_data_agg_port_id = interface_ind->data.min_data_agg_port_id;
+ balIndCfg.interface_ind->data->has_min_data_svc_port_id = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->min_data_svc_port_id = interface_ind->data.min_data_svc_port_id;
+ balIndCfg.interface_ind->data->has_transceiver_type = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->transceiver_type = interface_ind->data.transceiver_type;
+ balIndCfg.interface_ind->data->has_ds_miss_mode = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->ds_miss_mode = interface_ind->data.ds_miss_mode;
+ balIndCfg.interface_ind->data->has_mtu = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->mtu = interface_ind->data.mtu;
+ balIndCfg.interface_ind->data->has_flow_control = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->flow_control = interface_ind->data.flow_control;
+ balIndCfg.interface_ind->data->has_ds_tm = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->ds_tm = interface_ind->data.ds_tm;
+ balIndCfg.interface_ind->data->has_us_tm = BAL_GRPC_PRES;
+ balIndCfg.interface_ind->data->us_tm = interface_ind->data.us_tm;
+
+ BalIdList balFlows;
+ memset(&balFlows, 0, sizeof(BalIdList));
+ bal_id_list__init(&balFlows);
+ balIndCfg.interface_ind->data->sub_term_id_list = &balFlows;
+
+ balIndCfg.interface_ind->data->sub_term_id_list->n_val = interface_ind->data.sub_term_id_list.len;
+ memcpy(balIndCfg.interface_ind->data->sub_term_id_list->val, interface_ind->data.sub_term_id_list.val,
+ balIndCfg.interface_ind->data->sub_term_id_list->n_val);
+
+ BalErr *output;
+ result = bal_ind__bal_iface_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_sub_term_osc_indication_cb *
+ * Description : This function will handle the indications for *
+ * Subscriber term Operational State Change *
+ * *
+ ********************************************************************/
+bcmos_errno bal_sub_term_osc_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
+ bcmbal_subscriber_terminal_auto_id_oper_status_change != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_OP_STATE;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_subscriber_terminal_oper_status_change *sub_osc_ind =
+ (bcmbal_subscriber_terminal_oper_status_change *)obj;
+
+ BalSubscriberTerminalOperStatusChange subOscInd;
+ memset(&subOscInd, 0, sizeof(BalSubscriberTerminalOperStatusChange));
+ bal_subscriber_terminal_oper_status_change__init(&subOscInd);
+ balIndCfg.terminal_op_state = &subOscInd;
+
+ BalSubscriberTerminalKey subkey;
+ memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
+ bal_subscriber_terminal_key__init(&subkey);
+ balIndCfg.terminal_op_state->key = &subkey;
+
+ balIndCfg.terminal_op_state->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_op_state->key->intf_id = sub_osc_ind->key.intf_id;
+ balIndCfg.terminal_op_state->key->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_op_state->key->sub_term_id = sub_osc_ind->key.sub_term_id;
+
+ BalSubscriberTerminalOperStatusChangeData subOscIndData;
+ memset(&subOscIndData, 0, sizeof(BalSubscriberTerminalOperStatusChangeData));
+ bal_subscriber_terminal_oper_status_change_data__init(&subOscIndData);
+ balIndCfg.terminal_op_state->data = &subOscIndData;
+
+ balIndCfg.terminal_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
+ balIndCfg.terminal_op_state->data->new_oper_status =
+ sub_osc_ind->data.new_oper_status;
+ balIndCfg.terminal_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
+ balIndCfg.terminal_op_state->data->old_oper_status =
+ sub_osc_ind->data.old_oper_status;
+ balIndCfg.terminal_op_state->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.terminal_op_state->data->admin_state =
+ sub_osc_ind->data.admin_state;
+
+ BalErr *output;
+ result = bal_ind__bal_subs_term_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_sub_term_disc_indication_cb *
+ * Description : This function will handle the indications for *
+ * Subscriber term disc indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_sub_term_disc_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
+ bcmbal_subscriber_terminal_auto_id_sub_term_disc != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DISC;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_subscriber_terminal_sub_term_disc *sub_disc_ind =
+ (bcmbal_subscriber_terminal_sub_term_disc *)obj;
+
+ BalSubscriberTerminalSubTermDisc subDiscInd;
+ memset(&subDiscInd, 0, sizeof(BalSubscriberTerminalSubTermDisc));
+ bal_subscriber_terminal_sub_term_disc__init(&subDiscInd);
+ balIndCfg.terminal_disc = &subDiscInd;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.terminal_disc->hdr = &hdr;
+
+ BalSubscriberTerminalKey subkey;
+ memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
+ bal_subscriber_terminal_key__init(&subkey);
+ balIndCfg.terminal_disc->key = &subkey;
+
+ balIndCfg.terminal_disc->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_disc->key->intf_id = sub_disc_ind->key.intf_id;
+ balIndCfg.terminal_disc->key->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_disc->key->sub_term_id = sub_disc_ind->key.sub_term_id;
+
+ BalSubscriberTerminalSubTermDiscData subDiscIndData;
+ memset(&subDiscIndData, 0, sizeof(BalSubscriberTerminalSubTermDiscData));
+ bal_subscriber_terminal_sub_term_disc_data__init(&subDiscIndData);
+ balIndCfg.terminal_disc->data = &subDiscIndData;
+
+ BalSerialNumber serial_number;
+ memset(&serial_number, 0, sizeof(BalSerialNumber));
+ bal_serial_number__init(&serial_number);
+
+ balIndCfg.terminal_disc->data->serial_number = &serial_number;
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Discovered ONU serial number "
+ "%2X%2X%2X%2X%1X%1X%1X%1X%1X%1X%1X%1X ",
+ sub_disc_ind->data.serial_number.vendor_id[0],
+ sub_disc_ind->data.serial_number.vendor_id[1],
+ sub_disc_ind->data.serial_number.vendor_id[2],
+ sub_disc_ind->data.serial_number.vendor_id[3],
+ sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor id is %s\n", sub_disc_ind->data.serial_number.vendor_id);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor specific is %s\n", sub_disc_ind->data.serial_number.vendor_specific);
+
+ char vendor_id[MAX_CHAR_LENGTH];
+ memset(&vendor_id, 0, MAX_CHAR_LENGTH);
+ sprintf(vendor_id,"%c%c%c%c",
+ sub_disc_ind->data.serial_number.vendor_id[0],
+ sub_disc_ind->data.serial_number.vendor_id[1],
+ sub_disc_ind->data.serial_number.vendor_id[2],
+ sub_disc_ind->data.serial_number.vendor_id[3]);
+ balIndCfg.terminal_disc->data->serial_number->vendor_id = vendor_id;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor id is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_id);
+ char vendor_specific[MAX_CHAR_LENGTH];
+ memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
+ sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
+ sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
+ sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
+ balIndCfg.terminal_disc->data->serial_number->vendor_specific = vendor_specific;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor specific is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_specific);
+
+ BalErr *output;
+ result = bal_ind__bal_subs_term_discovery_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_sub_term_alarm_indication_cb *
+ * Description : This function will handle the indications for *
+ * Subscriber term alarm indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_sub_term_alarm_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
+ bcmbal_subscriber_terminal_auto_id_sub_term_alarm != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_ALARM;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_subscriber_terminal_sub_term_alarm *sub_term_alarm =
+ (bcmbal_subscriber_terminal_sub_term_alarm *)obj;
+
+ BalSubscriberTerminalSubTermAlarm subTermAlarm;
+ memset(&subTermAlarm, 0, sizeof(BalSubscriberTerminalSubTermAlarm));
+ bal_subscriber_terminal_sub_term_alarm__init(&subTermAlarm);
+ balIndCfg.terminal_alarm = &subTermAlarm;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.terminal_alarm->hdr = &hdr;
+
+ BalSubscriberTerminalKey subkey;
+ memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
+ bal_subscriber_terminal_key__init(&subkey);
+ balIndCfg.terminal_alarm->key = &subkey;
+
+ balIndCfg.terminal_alarm->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->key->intf_id = sub_term_alarm->key.intf_id;
+ balIndCfg.terminal_alarm->key->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->key->sub_term_id = sub_term_alarm->key.sub_term_id;
+
+ BalsubscriberTerminalSubTermAlarmData subTermAlarmData;
+ memset(&subTermAlarmData, 0, sizeof(BalsubscriberTerminalSubTermAlarmData));
+ balsubscriber_terminal_sub_term_alarm_data__init(&subTermAlarmData);
+ balIndCfg.terminal_alarm->data = &subTermAlarmData;
+
+ BalSubscriberTerminalAlarms balSubAlarms;
+ memset(&balSubAlarms, 0, sizeof(BalSubscriberTerminalAlarms));
+ bal_subscriber_terminal_alarms__init(&balSubAlarms);
+ balIndCfg.terminal_alarm->data->alarm = &balSubAlarms;
+
+ balIndCfg.terminal_alarm->data->alarm->has_los = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->data->alarm->los = sub_term_alarm->data.alarm.los;
+ balIndCfg.terminal_alarm->data->alarm->has_lob = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->data->alarm->lob = sub_term_alarm->data.alarm.lob;
+ balIndCfg.terminal_alarm->data->alarm->has_lopc_miss = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->data->alarm->lopc_miss = sub_term_alarm->data.alarm.lopc_miss;
+ balIndCfg.terminal_alarm->data->alarm->has_lopc_mic_error = BAL_GRPC_PRES;
+ balIndCfg.terminal_alarm->data->alarm->lopc_mic_error = sub_term_alarm->data.alarm.lopc_mic_error;
+
+ BalErr *output;
+ result = bal_ind__bal_subs_term_alarm_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_sub_term_dgi_indication_cb *
+ * Description : This function will handle the indications for *
+ * Subscriber term dgi indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_sub_term_dgi_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
+ bcmbal_subscriber_terminal_auto_id_dgi != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DGI;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_subscriber_terminal_dgi *sub_dgi_ind =
+ (bcmbal_subscriber_terminal_dgi *)obj;
+
+ BalSubscriberTerminalDgi subDgiInd;
+ memset(&subDgiInd, 0, sizeof(BalSubscriberTerminalDgi));
+ bal_subscriber_terminal_dgi__init(&subDgiInd);
+ balIndCfg.terminal_dgi= &subDgiInd;
+
+ BalSubscriberTerminalKey subkey;
+ memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
+ bal_subscriber_terminal_key__init(&subkey);
+ balIndCfg.terminal_disc->key = &subkey;
+
+ balIndCfg.terminal_dgi->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_dgi->key->intf_id = sub_dgi_ind->key.intf_id;
+ balIndCfg.terminal_dgi->key->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_dgi->key->sub_term_id = sub_dgi_ind->key.sub_term_id;
+
+ BalSubscriberTerminalDgiData subDgiIndData;
+ memset(&subDgiIndData, 0, sizeof(BalSubscriberTerminalDgiData));
+ bal_subscriber_terminal_dgi_data__init(&subDgiIndData);
+ balIndCfg.terminal_dgi->data = &subDgiIndData;
+
+ balIndCfg.terminal_dgi->data->has_dgi_status = BAL_GRPC_PRES;
+ balIndCfg.terminal_dgi->data->dgi_status = sub_dgi_ind->data.dgi_status;
+
+ BalErr *output;
+ result = bal_ind__bal_subs_term_dgi_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_sub_term_indication_cb *
+ * Description : This function will handle the indications for *
+ * Subscriber term indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_sub_term_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
+ bcmbal_subscriber_terminal_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_subscriber_terminal_ind *sub_ind = (bcmbal_subscriber_terminal_ind *)obj;
+
+ BalSubscriberTerminalInd subInd;
+ memset(&subInd, 0, sizeof(BalSubscriberTerminalInd));
+ bal_subscriber_terminal_ind__init(&subInd);
+ balIndCfg.terminal_ind = &subInd;
+
+ BalObj hdr;
+ memset(&hdr, 0, sizeof(BalObj));
+ bal_obj__init(&hdr);
+ balIndCfg.terminal_ind->hdr = &hdr;
+
+ BalSubscriberTerminalKey subkey;
+ memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
+ bal_subscriber_terminal_key__init(&subkey);
+ balIndCfg.terminal_ind->key = &subkey;
+
+ balIndCfg.terminal_ind->key->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->key->intf_id = sub_ind->key.intf_id;
+ balIndCfg.terminal_ind->key->has_sub_term_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->key->sub_term_id = sub_ind->key.sub_term_id;
+
+ BalSubscriberTerminalIndData subIndData;
+ memset(&subIndData, 0, sizeof(BalSubscriberTerminalIndData));
+ bal_subscriber_terminal_ind_data__init(&subIndData);
+ balIndCfg.terminal_ind->data = &subIndData;
+
+ balIndCfg.terminal_ind->data->has_admin_state = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->admin_state = sub_ind->data.admin_state;
+ balIndCfg.terminal_ind->data->has_oper_status = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->oper_status = sub_ind->data.oper_status;
+ balIndCfg.terminal_ind->data->has_svc_port_id = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->svc_port_id = sub_ind->data.svc_port_id;
+ balIndCfg.terminal_ind->data->has_ds_tm = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->ds_tm = sub_ind->data.ds_tm;
+ balIndCfg.terminal_ind->data->has_us_tm = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->us_tm = sub_ind->data.us_tm;
+ balIndCfg.terminal_ind->data->has_sub_term_rate = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->sub_term_rate = sub_ind->data.sub_term_rate;
+ char password[MAX_CHAR_LENGTH*2];
+ memset(&password, 0, MAX_CHAR_LENGTH*2);
+ strcpy(password,(const char *)sub_ind->data.password.arr);
+ balIndCfg.terminal_ind->data->password = password;
+ char registration_id[MAX_CHAR_LENGTH*8];
+ memset(®istration_id, 0, MAX_CHAR_LENGTH*8);
+ strcpy(registration_id,(const char *)sub_ind->data.registration_id.arr);
+ balIndCfg.terminal_ind->data->registration_id = registration_id;
+
+#if 0
+ balIndCfg.terminal_ind->data->has_mac_address = BAL_GRPC_PRES;
+ balIndCfg.terminal_ind->data->mac_address.len =
+ (BCMOS_ETH_ALEN)*sizeof(sub_ind->data.mac_address.u8);
+ uint8_t mac_address[balIndCfg.terminal_ind->data->mac_address.len];
+ memset(&mac_address, 0 ,balIndCfg.terminal_ind->data->mac_address.len);
+ strcpy((char *)mac_address,(const char *)sub_ind->data.mac_address.u8);
+ balIndCfg.terminal_ind->data->mac_address.data = mac_address;
+#endif
+
+ BalSerialNumber serialNum;
+ memset(&serialNum, 0, sizeof(BalSerialNumber));
+ bal_serial_number__init(&serialNum);
+ balIndCfg.terminal_ind->data->serial_number = &serialNum;
+
+ ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor id is %s\n", sub_ind->data.serial_number.vendor_id);
+ ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor specific is %s\n", sub_ind->data.serial_number.vendor_specific);
+
+ char vendor_id[MAX_CHAR_LENGTH];
+ memset(&vendor_id, 0, MAX_CHAR_LENGTH);
+ sprintf(vendor_id,"%c%c%c%c",
+ sub_ind->data.serial_number.vendor_id[0],
+ sub_ind->data.serial_number.vendor_id[1],
+ sub_ind->data.serial_number.vendor_id[2],
+ sub_ind->data.serial_number.vendor_id[3]);
+ balIndCfg.terminal_ind->data->serial_number->vendor_id = vendor_id;
+ ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor id is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_id);
+ char vendor_specific[MAX_CHAR_LENGTH];
+ memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
+ sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
+ sub_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[0] & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[1] & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[2] & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
+ sub_ind->data.serial_number.vendor_specific[3] & 0x0f);
+ balIndCfg.terminal_ind->data->serial_number->vendor_specific = vendor_specific;
+ ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor specific is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_specific);
+
+ BalIdList balAggportList;
+ memset(&balAggportList, 0, sizeof(BalIdList));
+ bal_id_list__init(&balAggportList);
+ balIndCfg.terminal_ind->data->agg_port_id_list = &balAggportList;
+
+#if 0
+ balIndCfg.terminal_ind->data->agg_port_id_list->n_val = sub_ind->data.agg_port_id_list.len;
+ uint32_t agg_port_id_list[balIndCfg.terminal_ind->data->agg_port_id_list->n_val];
+ memset(&agg_port_id_list, 0, balIndCfg.terminal_ind->data->agg_port_id_list->n_val);
+ strcpy((char *)agg_port_id_list,(const char *)sub_ind->data.agg_port_id_list.val);
+ balIndCfg.terminal_ind->data->agg_port_id_list->val = agg_port_id_list;
+#endif
+
+ BalErr *output;
+ result = bal_ind__bal_subs_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : fill_bal_tm_red *
+ * Description : This function will fill grpc-BalTmred struture *
+ * from bal-bcmbal_tm_red structure *
+ * *
+ ********************************************************************/
+void fill_bal_tm_red(BalTmred *grpc_red, bcmbal_tm_red *bal_red)
+{
+ grpc_red->has_min_threshold = BAL_GRPC_PRES;
+ grpc_red->min_threshold = bal_red->min_threshold;
+ grpc_red->has_max_threshold = BAL_GRPC_PRES;
+ grpc_red->max_threshold = bal_red->max_threshold;
+ grpc_red->has_max_probability = BAL_GRPC_PRES;
+ grpc_red->max_probability = bal_red->max_probability;
+ return;
+}
+
+/********************************************************************\
+ * Function : bal_tm_queue_indication_cb *
+ * Description : This function will handle the indications for *
+ * TM Queue indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_tm_queue_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_TM_QUEUE != obj->obj_type ||
+ bcmbal_tm_queue_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TM_QUEUE__IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_tm_queue_ind *tm_que_ind = (bcmbal_tm_queue_ind *)obj;
+
+ BalTmQueueInd tmQueInd;
+ memset(&tmQueInd, 0, sizeof(BalTmQueueInd));
+ bal_tm_queue_ind__init(&tmQueInd);
+ balIndCfg.tm_queue_ind = &tmQueInd;
+
+ BalTmQueueKey tmQkey;
+ memset(&tmQkey, 0, sizeof(BalTmQueueKey));
+ bal_tm_queue_key__init(&tmQkey);
+ balIndCfg.tm_queue_ind->key = &tmQkey;
+
+ balIndCfg.tm_queue_ind->key->has_sched_id = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->key->sched_id = tm_que_ind->key.sched_id;
+ balIndCfg.tm_queue_ind->key->has_sched_dir = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->key->sched_dir = tm_que_ind->key.sched_dir;
+ balIndCfg.tm_queue_ind->key->has_id = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->key->id = tm_que_ind->key.id;
+
+ BalTmQueueIndData tmQIndData;
+ memset(&tmQIndData, 0, sizeof(BalTmQueueIndData));
+ bal_tm_queue_ind_data__init(&tmQIndData);
+ balIndCfg.tm_queue_ind->data = &tmQIndData;
+
+ balIndCfg.tm_queue_ind->data->has_priority = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->priority = tm_que_ind->data.priority;
+ balIndCfg.tm_queue_ind->data->has_weight = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->weight = tm_que_ind->data.weight;
+ balIndCfg.tm_queue_ind->data->has_create_mode = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->create_mode = tm_que_ind->data.create_mode;
+ balIndCfg.tm_queue_ind->data->has_ref_count = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->ref_count = tm_que_ind->data.ref_count;
+
+ BalTmShaping balShape;
+ memset(&balShape, 0, sizeof(BalTmShaping));
+ bal_tm_shaping__init(&balShape);
+ balIndCfg.tm_queue_ind->data->rate = &balShape;
+
+ balIndCfg.tm_queue_ind->data->rate->has_presence_mask = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->rate->presence_mask = tm_que_ind->data.rate.presence_mask;
+ balIndCfg.tm_queue_ind->data->rate->has_cir = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->rate->cir = tm_que_ind->data.rate.cir;
+ balIndCfg.tm_queue_ind->data->rate->has_pir = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->rate->pir = tm_que_ind->data.rate.pir;
+ balIndCfg.tm_queue_ind->data->rate->has_burst = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->rate->burst = tm_que_ind->data.rate.burst;
+
+ BalTmBac balBac;
+ memset(&balBac, 0, sizeof(BalTmBac));
+ bal_tm_bac__init(&balBac);
+ balIndCfg.tm_queue_ind->data->bac = &balBac;
+
+ balIndCfg.tm_queue_ind->data->bac->has_type = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->bac->type = tm_que_ind->data.bac.type;
+ switch(tm_que_ind->data.bac.type)
+ {
+ case BCMBAL_TM_BAC_TYPE_TAILDROP:
+ {
+ balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_TAILDROP;
+ BalTMBacTaildrop balTaildrop;
+ memset(&balTaildrop, 0, sizeof(BalTMBacTaildrop));
+ bal_tmbac_taildrop__init(&balTaildrop);
+ balIndCfg.tm_queue_ind->data->bac->taildrop = &balTaildrop;
+
+ balIndCfg.tm_queue_ind->data->bac->taildrop->has_max_size = BAL_GRPC_PRES;
+ balIndCfg.tm_queue_ind->data->bac->taildrop->max_size =
+ tm_que_ind->data.bac.u.taildrop.max_size;
+ }
+ break;
+ case BCMBAL_TM_BAC_TYPE_WTAILDROP:
+ {
+ /* No bal/grpc structure was defined */
+ }
+ break;
+ case BCMBAL_TM_BAC_TYPE_RED:
+ {
+ balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_RED;
+ BalTMBacRed balBacRed;
+ memset(&balBacRed, 0, sizeof(BalTMBacRed));
+ bal_tmbac_red__init(&balBacRed);
+ balIndCfg.tm_queue_ind->data->bac->red = &balBacRed;
+
+ BalTmred balRed;
+ memset(&balRed, 0, sizeof(BalTmred));
+ bal_tmred__init(&balRed);
+ balIndCfg.tm_queue_ind->data->bac->red->red = &balRed;
+ fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->red->red, &tm_que_ind->data.bac.u.red.red);
+ }
+ break;
+ case BCMBAL_TM_BAC_TYPE_WRED:
+ {
+ balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_WRED;
+ BalTMBacWred balBacWred;
+ memset(&balBacWred, 0, sizeof(BalTMBacWred));
+ bal_tmbac_wred__init(&balBacWred);
+ balIndCfg.tm_queue_ind->data->bac->wred = &balBacWred;
+
+ BalTmred balGreen;
+ memset(&balGreen, 0, sizeof(BalTmred));
+ bal_tmred__init(&balGreen);
+ balIndCfg.tm_queue_ind->data->bac->wred->green = &balGreen;
+ fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->green, &tm_que_ind->data.bac.u.wred.green);
+
+ BalTmred balYellow;
+ memset(&balYellow, 0, sizeof(BalTmred));
+ bal_tmred__init(&balYellow);
+ balIndCfg.tm_queue_ind->data->bac->wred->yellow = &balYellow;
+ fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->yellow, &tm_que_ind->data.bac.u.wred.yellow);
+
+ BalTmred balRed;
+ memset(&balRed, 0, sizeof(BalTmred));
+ bal_tmred__init(&balRed);
+ balIndCfg.tm_queue_ind->data->bac->wred->red = &balRed;
+ fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->red, &tm_que_ind->data.bac.u.wred.red);
+ }
+ break;
+ default:
+ {
+ balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U__NOT_SET;
+ }
+ break;
+
+ }
+
+ BalErr *output;
+ result = bal_ind__bal_tm_queue_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_tm_sched_indication_cb *
+ * Description : This function will handle the indications for *
+ * TM Sched indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_tm_sched_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_TM_SCHED != obj->obj_type ||
+ bcmbal_tm_sched_auto_id_ind != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_TM_SCHED__IND;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ bcmbal_tm_sched_ind *tm_sched_ind = (bcmbal_tm_sched_ind *)obj;
+
+ BalTmSchedInd tmSchedInd;
+ memset(&tmSchedInd, 0, sizeof(BalTmSchedInd));
+ bal_tm_sched_ind__init(&tmSchedInd);
+ balIndCfg.tm_sched_ind = &tmSchedInd;
+
+ BalTmSchedKey tmSchedkey;
+ memset(&tmSchedkey, 0, sizeof(BalTmSchedKey));
+ bal_tm_sched_key__init(&tmSchedkey);
+ balIndCfg.tm_sched_ind->key = &tmSchedkey;
+
+ balIndCfg.tm_sched_ind->key->has_dir = BAL_GRPC_PRES;
+ balIndCfg.tm_sched_ind->key->dir = tm_sched_ind->key.dir;
+ balIndCfg.tm_sched_ind->key->has_id = BAL_GRPC_PRES;
+ balIndCfg.tm_sched_ind->key->id = tm_sched_ind->key.id;
+
+ BalTmSchedIndData tmSIndData;
+ memset(&tmSIndData, 0, sizeof(BalTmSchedIndData));
+ bal_tm_sched_ind_data__init(&tmSIndData);
+ balIndCfg.tm_sched_ind->data = &tmSIndData;
+ /* TODO: data should be populate */
+
+ BalErr *output;
+ result = bal_ind__bal_tm_sched_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_packet_data_indication_cb *
+ * Description : This function will handle the indications for *
+ * Packet Data indication *
+ * *
+ ********************************************************************/
+bcmos_errno bal_packet_data_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
+ bcmbal_packet_auto_id_bearer_channel_rx != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ /*bcmos_mutex_lock(&bal_ind_lock);-- Need to define bcm independent mutex*/
+
+ BalIndications balIndCfg;
+ balIndCfg.u_case = BAL_INDICATIONS__U_PKT_DATA;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ BalPacketBearerChannelRx rxChannel;
+ memset(&rxChannel, 0, sizeof(BalPacketBearerChannelRx));
+ bal_packet_bearer_channel_rx__init(&rxChannel);
+ balIndCfg.pktdata = &rxChannel;
+
+ BalPacketKey packetkey;
+ memset(&packetkey, 0, sizeof(BalPacketKey));
+ bal_packet_key__init(&packetkey);
+ balIndCfg.pktdata->key = &packetkey;
+
+ bcmbal_packet_bearer_channel_rx *rx_channel =
+ (bcmbal_packet_bearer_channel_rx *)obj;
+
+ balIndCfg.pktdata->key->has_reserved = BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->reserved = rx_channel->key.reserved;
+
+ BalDest PktSndDest;
+ memset(&PktSndDest, 0, sizeof(BalDest));
+ bal_dest__init(&PktSndDest);
+ balIndCfg.pktdata->key->packet_send_dest = &PktSndDest;
+
+ balIndCfg.pktdata->key->packet_send_dest->has_type = BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->type =
+ rx_channel->key.packet_send_dest.type;
+ switch( rx_channel->key.packet_send_dest.type)
+ {
+ case BCMBAL_DEST_TYPE_NNI:
+ {
+ balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_NNI;
+ BalDestNni balNni;
+ memset(&balNni, 0, sizeof(BalDestNni));
+ bal_dest_nni__init(&balNni);
+ balIndCfg.pktdata->key->packet_send_dest->nni = &balNni;
+ balIndCfg.pktdata->key->packet_send_dest->nni->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->nni->intf_id =
+ rx_channel->key.packet_send_dest.u.nni.intf_id;
+ }
+ break;
+ case BCMBAL_DEST_TYPE_SUB_TERM:
+ {
+ balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SUB_TERM;
+ BalDestSubTerm balSubTerm;
+ memset(&balSubTerm, 0, sizeof(BalDestSubTerm));
+ bal_dest_sub_term__init(&balSubTerm);
+ balIndCfg.pktdata->key->packet_send_dest->sub_term = &balSubTerm;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_id =
+ BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_id =
+ rx_channel->key.packet_send_dest.u.sub_term.sub_term_id;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_uni =
+ BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_uni =
+ rx_channel->key.packet_send_dest.u.sub_term.sub_term_uni;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->has_intf_id =
+ BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->sub_term->intf_id =
+ rx_channel->key.packet_send_dest.u.sub_term.intf_id;
+ }
+ break;
+ case BCMBAL_DEST_TYPE_SVC_PORT:
+ {
+ balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SVC_PORT;
+ BalDestSvcPort balSvcPort;
+ memset(&balSvcPort, 0, sizeof(BalDestSvcPort));
+ bal_dest_svc_port__init(&balSvcPort);
+ balIndCfg.pktdata->key->packet_send_dest->svc_port = &balSvcPort;
+ balIndCfg.pktdata->key->packet_send_dest->svc_port->has_svc_port_id =
+ BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->svc_port->svc_port_id =
+ rx_channel->key.packet_send_dest.u.svc_port.svc_port_id;
+ balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
+ BAL_GRPC_PRES;
+ balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
+ rx_channel->key.packet_send_dest.u.svc_port.intf_id;
+ }
+ break;
+ default:
+ {
+ balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
+ }
+ break;
+ }
+
+ BalPacketBearerChannelRxData pkdData;
+ memset(&pkdData, 0, sizeof(BalPacketBearerChannelRxData));
+ bal_packet_bearer_channel_rx_data__init(&pkdData);
+ balIndCfg.pktdata->data = &pkdData;
+
+ balIndCfg.pktdata->data->has_flow_id = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->flow_id = rx_channel->data.flow_id;
+ balIndCfg.pktdata->data->has_flow_type = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->flow_type = rx_channel->data.flow_type;
+ balIndCfg.pktdata->data->has_intf_id = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->intf_id = rx_channel->data.intf_id;
+ balIndCfg.pktdata->data->has_intf_type = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->intf_type = rx_channel->data.intf_type;
+ balIndCfg.pktdata->data->has_svc_port = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->svc_port = rx_channel->data.svc_port;
+ balIndCfg.pktdata->data->has_flow_cookie = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->flow_cookie = rx_channel->data.flow_cookie;
+ balIndCfg.pktdata->data->has_pkt = BAL_GRPC_PRES;
+ balIndCfg.pktdata->data->pkt.len = rx_channel->data.pkt.len;
+ memcpy(balIndCfg.pktdata->data->pkt.data, rx_channel->data.pkt.val, balIndCfg.pktdata->data->pkt.len);
+
+ /*bcmos_mutex_unlock(&bal_ind_lock);-- Need to define bcm independent mutex*/
+
+ BalErr *output;
+ result = bal_ind__bal_pkt_bearer_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_omci_data_indication_cb *
+ * Description : This function will handle the indications for *
+ * OMCI Data Response *
+ * *
+ ********************************************************************/
+bcmos_errno bal_omci_data_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
+ bcmbal_packet_auto_id_itu_omci_channel_rx != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Received OMCI response via BAL APIs\n");
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OMCI_RESP;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ BalPacketItuOmciChannelRx omciChannel;
+ memset(&omciChannel, 0, sizeof(BalPacketItuOmciChannelRx));
+ bal_packet_itu_omci_channel_rx__init(&omciChannel);
+ balIndCfg.balomciresp = &omciChannel;
+
+ BalPacketKey packetkey;
+ memset(&packetkey, 0, sizeof(BalPacketKey));
+ bal_packet_key__init(&packetkey);
+ balIndCfg.balomciresp->key = &packetkey;
+
+ BalPacketItuOmciChannelRxData omciData;
+ memset(&omciData, 0, sizeof(BalPacketItuOmciChannelRxData));
+ bal_packet_itu_omci_channel_rx_data__init(&omciData);
+ balIndCfg.balomciresp->data = &omciData;
+
+ bcmbal_packet_itu_omci_channel_rx *omci_channel =
+ (bcmbal_packet_itu_omci_channel_rx *)obj;
+
+ balIndCfg.balomciresp->data->has_pkt = BAL_GRPC_PRES;
+ balIndCfg.balomciresp->data->pkt.len = omci_channel->data.pkt.len;
+ balIndCfg.balomciresp->data->pkt.data = (uint8_t *)malloc((omci_channel->data.pkt.len)*sizeof(uint8_t));
+ memcpy(balIndCfg.balomciresp->data->pkt.data, omci_channel->data.pkt.val,
+ balIndCfg.balomciresp->data->pkt.len);
+
+ balIndCfg.balomciresp->key->has_reserved = BAL_GRPC_PRES;
+ balIndCfg.balomciresp->key->reserved = omci_channel->key.reserved;
+
+ BalDest PktSndDest;
+ memset(&PktSndDest, 0, sizeof(BalDest));
+ bal_dest__init(&PktSndDest);
+ balIndCfg.balomciresp->key->packet_send_dest = &PktSndDest;
+
+ balIndCfg.balomciresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
+ balIndCfg.balomciresp->key->packet_send_dest->type =
+ omci_channel->key.packet_send_dest.type;
+ switch( omci_channel->key.packet_send_dest.type)
+ {
+ case BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL:
+ {
+ balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U_ITU_OMCI_CHANNEL;
+ BalItuOmciChannel balOmci;
+ memset(&balOmci, 0, sizeof(BalItuOmciChannel));
+ bal_itu_omci_channel__init(&balOmci);
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel = &balOmci;
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_sub_term_id =
+ BAL_GRPC_PRES;
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id =
+ omci_channel->key.packet_send_dest.u.itu_omci_channel.sub_term_id;
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_intf_id =
+ BAL_GRPC_PRES;
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->intf_id =
+ omci_channel->key.packet_send_dest.u.itu_omci_channel.intf_id;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
+ }
+ break;
+ default:
+ {
+ balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
+ }
+ break;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response with %zd bytes is \n",balIndCfg.balomciresp->data->pkt.len);
+ uint16_t idx;
+ for(idx=0; idx<balIndCfg.balomciresp->data->pkt.len; idx++)
+ {
+ printf("%02x", balIndCfg.balomciresp->data->pkt.data[idx]);
+ }
+ printf("\n");
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
+ balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
+ BalErr *output;
+ result = bal_ind__bal_pkt_omci_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+ }
+
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_oam_data_indication_cb *
+ * Description : This function will handle the indications for *
+ * OAM Data Response *
+ * *
+ ********************************************************************/
+bcmos_errno bal_oam_data_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+ if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
+ bcmbal_packet_auto_id_ieee_oam_channel_rx != obj->subgroup)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
+ result = BCM_ERR_INTERNAL;
+ }
+ else
+ {
+ BalIndications balIndCfg;
+ memset(&balIndCfg, 0, sizeof(BalIndications));
+ bal_indications__init(&balIndCfg);
+ balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OAM_RESP;
+ balIndCfg.has_objtype = BAL_GRPC_PRES;
+ balIndCfg.objtype = obj->obj_type;
+ balIndCfg.has_sub_group = BAL_GRPC_PRES;
+ balIndCfg.sub_group = obj->subgroup;
+ balIndCfg.device_id = voltha_device_id;
+
+ BalPacketIeeeOamChannelRx oamChannel;
+ memset(&oamChannel, 0, sizeof(BalPacketIeeeOamChannelRx));
+ bal_packet_ieee_oam_channel_rx__init(&oamChannel);
+ balIndCfg.baloamresp = &oamChannel;
+
+ BalPacketKey packetkey;
+ memset(&packetkey, 0, sizeof(BalPacketKey));
+ bal_packet_key__init(&packetkey);
+ balIndCfg.baloamresp->key = &packetkey;
+
+ bcmbal_packet_ieee_oam_channel_rx *oam_channel =
+ (bcmbal_packet_ieee_oam_channel_rx *)obj;
+
+ balIndCfg.baloamresp->key->has_reserved = BAL_GRPC_PRES;
+ balIndCfg.baloamresp->key->reserved = oam_channel->key.reserved;
+
+ BalDest PktSndDest;
+ memset(&PktSndDest, 0, sizeof(BalDest));
+ bal_dest__init(&PktSndDest);
+ balIndCfg.baloamresp->key->packet_send_dest = &PktSndDest;
+
+ balIndCfg.baloamresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
+ balIndCfg.baloamresp->key->packet_send_dest->type =
+ oam_channel->key.packet_send_dest.type;
+ switch( oam_channel->key.packet_send_dest.type)
+ {
+ case BCMBAL_DEST_TYPE_IEEE_OAM_CHANNEL:
+ {
+ balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U_IEEE_OAM_CHANNEL;
+ BalIeeeOamChannel balOam;
+ memset(&balOam, 0, sizeof(BalIeeeOamChannel));
+ bal_ieee_oam_channel__init(&balOam);
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel = &balOam;
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_intf_id =
+ BAL_GRPC_PRES;
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->intf_id =
+ oam_channel->key.packet_send_dest.u.ieee_oam_channel.intf_id;
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_mac_address = BAL_GRPC_PRES;
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len =
+ (BCMOS_ETH_ALEN)*sizeof(oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8);
+ memcpy(balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data,
+ oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8,
+ balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len);
+
+ }
+ break;
+ default:
+ {
+ balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
+ }
+ break;
+ }
+
+ BalPacketIeeeOamChannelRxData oamData;
+ memset(&oamData, 0, sizeof(BalPacketIeeeOamChannelRxData));
+ bal_packet_ieee_oam_channel_rx_data__init(&oamData);
+ balIndCfg.baloamresp->data = &oamData;
+
+ balIndCfg.baloamresp->data->pkt.len = oam_channel->data.pkt.len;
+ memcpy(balIndCfg.baloamresp->data->pkt.data, oam_channel->data.pkt.val,
+ balIndCfg.baloamresp->data->pkt.len);
+
+ BalErr *output;
+ result = bal_ind__bal_pkt_ieee_oam_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
+
+ }
+
+ return result;
+}
diff --git a/src/bal_indications_hdlr.h b/src/bal_indications_hdlr.h
new file mode 100755
index 0000000..8622776
--- /dev/null
+++ b/src/bal_indications_hdlr.h
@@ -0,0 +1,55 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "bal_msg_type.grpc-c.h"
+#include "bal_osmsg.grpc-c.h"
+#include "bal_model_ids.grpc-c.h"
+#include "bal_obj.grpc-c.h"
+#include "bal_model_types.grpc-c.h"
+#include "bal_errno.grpc-c.h"
+#include "bal_indications.grpc-c.h"
+#include "bal.grpc-c.h"
+
+#include "asfvolt16_driver.h"
+
+#define BAL_GRPC_PRES 1
+
+extern bcmos_errno bal_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_acc_term_osc_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_acc_term_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_flow_osc_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_flow_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_group_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_interface_osc_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_interface_los_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_interface_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_sub_term_osc_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_sub_term_disc_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_sub_term_alarm_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_sub_term_dgi_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_sub_term_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_tm_queue_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_tm_sched_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_packet_data_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_omci_data_indication_cb(bcmbal_obj *obj);
+extern bcmos_errno bal_oam_data_indication_cb(bcmbal_obj *obj);
+void fill_bal_tm_red(BalTmred *grpc_red, bcmbal_tm_red *bal_red);
diff --git a/src/bal_interface_hdlr.c b/src/bal_interface_hdlr.c
new file mode 100755
index 0000000..33847ea
--- /dev/null
+++ b/src/bal_interface_hdlr.c
@@ -0,0 +1,196 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+#include "asfvolt16_driver.h"
+#include "bal_interface_hdlr.h"
+
+/********************************************************************\
+ * Function : bal_interface_cfg_set *
+ * Description : Configures the PON and NNI interfaces *
+ * of OLT Device *
+ ********************************************************************/
+uint32_t bal_interface_cfg_set(BalInterfaceCfg *interface_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_interface_cfg interface_obj;
+ bcmbal_interface_key intf_key;
+
+ intf_key.intf_id = interface_cfg->key->intf_id;
+ intf_key.intf_type = interface_cfg->key->intf_type;
+
+
+ /*
+ * Set the key in the interface object and initialize the object itself
+ */
+ BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
+
+ bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+
+ if(BCMBAL_STATUS_UP != ((bcmbal_interface_cfg *)&interface_obj.hdr)->data.oper_status)
+ {
+ BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, admin_state, BCMOS_TRUE, BCMBAL_STATE_UP);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_agg_port_id,
+ interface_cfg->data->has_min_data_svc_port_id,
+ interface_cfg->data->min_data_agg_port_id);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_svc_port_id,
+ interface_cfg->data->has_min_data_svc_port_id,
+ interface_cfg->data->min_data_svc_port_id);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, transceiver_type,
+ BCMOS_TRUE,
+ interface_cfg->data->transceiver_type);
+ ASFVOLT_LOG(ASFVOLT_INFO, "Setting transceiver_type to : %d\n", interface_cfg->data->transceiver_type);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_miss_mode,
+ interface_cfg->data->has_ds_miss_mode,
+ interface_cfg->data->ds_miss_mode);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu,
+ interface_cfg->data->has_mtu,
+ interface_cfg->data->mtu);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, flow_control,
+ interface_cfg->data->has_flow_control,
+ interface_cfg->data->flow_control);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm,
+ interface_cfg->data->has_ds_tm,
+ interface_cfg->data->ds_tm);
+
+ ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm,
+ interface_cfg->data->has_us_tm,
+ interface_cfg->data->us_tm);
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d\n", intf_key.intf_id);
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+ }
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n Set Interface configuration sent to OLT.Interface ID(%d) Interface Type(%d)\n",
+ intf_key.intf_id, intf_key.intf_type);
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_interface_cfg_get *
+ * Description : get the PON and NNI interfaces *
+ * of OLT Device *
+ ********************************************************************/
+uint32_t bal_interface_cfg_get(BalInterfaceKey *interface_cfg_key,
+ BalInterfaceCfg *interface_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_interface_cfg interface_obj;
+ bcmbal_interface_key intf_key;
+
+ if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type))
+ {
+ intf_key.intf_id = interface_cfg_key->intf_id;
+ intf_key.intf_type = interface_cfg_key->intf_type;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface cfg(OLT): Missing Key values\
+ Recevied key values intf-id(%d), intf-type(%d) \n",
+ interface_cfg_key->intf_id, interface_cfg_key->intf_type);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Get interface cfg(for OLT) starts\n");
+ /*
+ * Set the key in the interface object and initialize the object itself
+ */
+ BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
+
+ /* request all properties, include everything */
+ BCMBAL_CFG_PROP_GET(&interface_obj, interface, all_properties);
+
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &interface_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface Cfg(OLT)\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nGet Interface cfg sent to OLT. \
+ Interface ID(%d) Interface Type(%d)\n",
+ intf_key.intf_id, intf_key.intf_type);
+ /* TODO - Add code to call grpc */
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_interface_cfg_clear *
+ * Description : Clears the PON and NNI interfaces *
+ * of OLT Device *
+ ********************************************************************/
+uint32_t bal_interface_cfg_clear(BalInterfaceKey *interface_cfg_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_interface_cfg interface_obj;
+ bcmbal_interface_key intf_key;
+
+ if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type))
+ {
+ intf_key.intf_id = interface_cfg_key->intf_id;
+ intf_key.intf_type = interface_cfg_key->intf_type;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface cfg(OLT): Missing Key values\
+ Recevied key values intf-id(%d), intf-type(%d) \n",
+ interface_cfg_key->intf_id, interface_cfg_key->intf_type);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(interface cfg) starts\n");
+ /*
+ * Set the key in the interface object and initialize the object itself
+ */
+ BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
+
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &interface_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface Cfg(OLT)\n");
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nClear Interface cfg sent to OLT. \
+ Interface ID(%d) Interface Type(%d)\n",
+ intf_key.intf_id, intf_key.intf_type);
+ return BAL_ERRNO__BAL_ERR_OK;
+}
diff --git a/src/main.c b/src/bal_interface_hdlr.h
old mode 100644
new mode 100755
similarity index 63%
copy from src/main.c
copy to src/bal_interface_hdlr.h
index b62bc6e..98d3079
--- a/src/main.c
+++ b/src/bal_interface_hdlr.h
@@ -13,13 +13,9 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_interface_cfg_set(BalInterfaceCfg *interface_cfg);
+extern uint32_t bal_interface_cfg_get(BalInterfaceKey *interface_cfg_key,
+ BalInterfaceCfg *interface_cfg);
+extern uint32_t bal_interface_cfg_clear(BalInterfaceKey *interface_cfg_key);
+extern bcmos_errno bal_interface_indication_cb(bcmbal_obj *obj);
diff --git a/src/bal_packet_hdlr.c b/src/bal_packet_hdlr.c
new file mode 100755
index 0000000..ec2129c
--- /dev/null
+++ b/src/bal_packet_hdlr.c
@@ -0,0 +1,118 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "bal_msg_type.grpc-c.h"
+#include "bal_osmsg.grpc-c.h"
+#include "bal_model_ids.grpc-c.h"
+#include "bal_obj.grpc-c.h"
+#include "bal_model_types.grpc-c.h"
+#include "bal_errno.grpc-c.h"
+#include "bal.grpc-c.h"
+
+#include "asfvolt16_driver.h"
+#include "bal_packet_hdlr.h"
+
+/********************************************************************\
+ * Function : bal_access_terminal_cfg_req *
+ * Description : Configures the PON and NNI interfaces *
+ * of OLT Device *
+ ********************************************************************/
+uint32_t bal_packet_cfg_req(BalPacketCfg *packet)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ switch(packet->key->packet_send_dest->type)
+ {
+ case BAL_DEST_TYPE__BAL_DEST_TYPE_NNI:
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n Send packet msg to NNI not yet implemented\n");
+ }
+ break;
+ case BAL_DEST_TYPE__BAL_DEST_TYPE_SUB_TERM:
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n Send packet msg to ONU not yet implemented\n");
+ }
+ break;
+ case BAL_DEST_TYPE__BAL_DEST_TYPE_SVC_PORT:
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n Send packet msg to PON not yet implemented\n");
+ }
+ break;
+ case BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL:
+ {
+ bcmbal_access_term_id aterm_id = 0; /* Assume a single access_terminal instance */
+ bcmbal_u8_list_u32_max_2048 buf; /* A structure with a msg pointer and length value */
+ /* The destination of the OMCI packet is a registered ONU on the OLT PON interface */
+ bcmbal_dest proxy_pkt_dest = { .type = BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL,
+ .u.itu_omci_channel.sub_term_id = packet->key->packet_send_dest->itu_omci_channel->sub_term_id,
+ .u.itu_omci_channel.intf_id = packet->key->packet_send_dest->itu_omci_channel->intf_id };
+ buf.len = ((strlen((const char *)(packet->data->pkt.data))/2)) > MAX_OMCI_MSG_LENGTH ? MAX_OMCI_MSG_LENGTH : ((strlen((const char *)(packet->data->pkt.data))/2)); /* is the length of your OMCI message */
+ /* Send the OMCI packet using the BAL remote proxy API */
+ uint16_t idx1 = 0;
+ uint16_t idx2 = 0;
+ uint8_t arraySend[buf.len];
+ char str1[MAX_CHAR_LENGTH];
+ char str2[MAX_CHAR_LENGTH];
+ memset(&arraySend,0,buf.len);
+ ASFVOLT_LOG(ASFVOLT_DEBUG,"\nSending omci msg to ONU of length is %d\n",buf.len);
+ for(idx1=0,idx2=0; idx1<((buf.len)*2); idx1++,idx2++)
+ {
+ sprintf(str1,"%c",packet->data->pkt.data[idx1]);
+ sprintf(str2,"%c",packet->data->pkt.data[++idx1]);
+ strcat(str1,str2);
+ arraySend[idx2] = strtol(str1, NULL, 16);
+ }
+ buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
+ memcpy(buf.val,(uint8_t *)arraySend,buf.len);
+ ASFVOLT_LOG(ASFVOLT_DEBUG,"\nAfter converting it into hex\n");
+ for(idx2=0; idx2<buf.len; idx2++)
+ {
+ printf("%02x", buf.val[idx2]);
+ }
+ printf("\n");
+ err = bcmbal_pkt_send(aterm_id,
+ proxy_pkt_dest,
+ (const char *)(buf.val),
+ buf.len);
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n OMCI request msg of length(%d) sent to ONU(%d) through PON(%d)\n",
+ buf.len,
+ packet->key->packet_send_dest->itu_omci_channel->sub_term_id,
+ packet->key->packet_send_dest->itu_omci_channel->intf_id);
+ bcmos_free(buf.val);
+ }
+ break;
+ case BAL_DEST_TYPE__BAL_DEST_TYPE_IEEE_OAM_CHANNEL:
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n PLOAM msg not yet implemented\n");
+ }
+ break;
+ default:
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "\n Invalid dest type\n");
+ }
+ break;
+ }
+ if (BCM_ERR_OK != err)
+ {
+ /* recover from any error encountered while sending */
+ }
+ return err;
+}
diff --git a/src/main.c b/src/bal_packet_hdlr.h
old mode 100644
new mode 100755
similarity index 81%
rename from src/main.c
rename to src/bal_packet_hdlr.h
index b62bc6e..446ff3c
--- a/src/main.c
+++ b/src/bal_packet_hdlr.h
@@ -13,13 +13,5 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_packet_cfg_req(BalPacketCfg *packet);
diff --git a/src/bal_stats_hdlr.c b/src/bal_stats_hdlr.c
new file mode 100755
index 0000000..b1c49d2
--- /dev/null
+++ b/src/bal_stats_hdlr.c
@@ -0,0 +1,90 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "bal_stats_hdlr.h"
+
+/********************************************************************\
+ * Function : asfvolt16_bal_stats_get *
+ * Description : Function to get stats based on *
+ * interface type(NNI/PON/EPON 1G/EPON 10G) *
+ * port number *
+ ********************************************************************/
+uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData)
+{
+ bcmbal_interface_stat interface_stats;
+
+ bcmos_errno err = BCM_ERR_OK;
+
+ if(intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_NNI || intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_PON||
+ intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_1G_PATH ||
+ intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_10G_PATH)
+ {
+ err = BCM_ERR_PARM;
+ }
+
+ if(err == BCM_ERR_OK)
+ {
+ bcmbal_interface_key key = { .intf_id = intf_id,
+ .intf_type = intf_type };
+
+ /* Prepare to retrieve stat on NNI interface 0 */
+ BCMBAL_STAT_INIT(&interface_stats, interface, key);
+
+ /* Retrieve the Upstream packet and byte counts */
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_bytes);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_ucast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_mcast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_bcast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_error_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_unknown_protos);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_bytes);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_ucast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_mcast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_bcast_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_error_packets);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_crc_errors);
+ BCMBAL_STAT_PROP_GET(&interface_stats, interface, bip_errors);
+
+ /* Read the NNI stats.
+ * NOTE: When a CLEAR is specified during a NNI stats GET operation,
+ * all of the NNI stats are cleared, even the ones that are not retrieved.
+ */
+ err = bcmbal_stat_get(DEFAULT_ATERM_ID, &interface_stats.hdr, BCMOS_TRUE);
+
+ if(err == BCM_ERR_OK)
+ {
+ statData->rx_bytes = interface_stats.data.rx_bytes;
+ statData->rx_packets = interface_stats.data.rx_packets;
+ statData->rx_ucast_packets = interface_stats.data.rx_ucast_packets;
+ statData->rx_mcast_packets = interface_stats.data.rx_mcast_packets;
+ statData->rx_bcast_packets = interface_stats.data.rx_bcast_packets;
+ statData->rx_error_packets = interface_stats.data.rx_error_packets;
+ statData->rx_unknown_protos = interface_stats.data.rx_unknown_protos;
+ statData->tx_bytes = interface_stats.data.tx_bytes;
+ statData->tx_packets = interface_stats.data.tx_packets;
+ statData->tx_ucast_packets = interface_stats.data.tx_ucast_packets;
+ statData->tx_mcast_packets = interface_stats.data.tx_mcast_packets;
+ statData->tx_bcast_packets = interface_stats.data.tx_bcast_packets;
+ statData->tx_error_packets = interface_stats.data.tx_error_packets;
+ statData->rx_crc_errors = interface_stats.data.rx_crc_errors;
+ statData->bip_errors = interface_stats.data.bip_errors;
+ }
+ }
+
+ return err;
+}
diff --git a/src/main.c b/src/bal_stats_hdlr.h
old mode 100644
new mode 100755
similarity index 63%
copy from src/main.c
copy to src/bal_stats_hdlr.h
index b62bc6e..0103a8c
--- a/src/main.c
+++ b/src/bal_stats_hdlr.h
@@ -13,13 +13,19 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "bal_msg_type.grpc-c.h"
+#include "bal_osmsg.grpc-c.h"
+#include "bal_model_ids.grpc-c.h"
+#include "bal_obj.grpc-c.h"
+#include "bal_model_types.grpc-c.h"
+#include "bal_errno.grpc-c.h"
+#include "bal_indications.grpc-c.h"
+#include "bal.grpc-c.h"
+#include "asfvolt16_driver.h"
diff --git a/src/bal_subscriber_terminal_hdlr.c b/src/bal_subscriber_terminal_hdlr.c
new file mode 100755
index 0000000..30d89fa
--- /dev/null
+++ b/src/bal_subscriber_terminal_hdlr.c
@@ -0,0 +1,313 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+#include "asfvolt16_driver.h"
+#include "bal_subscriber_terminal_hdlr.h"
+
+/********************************************************************\
+ * Function : bal_subscriber_terminal_cfg_set *
+ * Description : Configures the subscriber terminal(ONU) *
+ ********************************************************************/
+uint32_t bal_subscriber_terminal_cfg_set(BalSubscriberTerminalCfg *onu_cfg)
+{
+
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_subscriber_terminal_cfg sub_term_obj = {};
+ bcmbal_subscriber_terminal_key subs_terminal_key;
+ bcmos_bool skip_onu = BCMOS_FALSE;
+
+ int idx;
+
+ subs_terminal_key.sub_term_id = onu_cfg->key->sub_term_id;
+ subs_terminal_key.intf_id = onu_cfg->key->intf_id;
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the subscriber terminal: %d\n", onu_cfg->key->sub_term_id);
+
+ /*
+ * Set the key in the subscriber terminal object
+ */
+ BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, subs_terminal_key);
+
+ {
+ bcmbal_serial_number serial_num = {} ;
+ bcmbal_serial_number zero_serial_num = {};
+ bcmbal_registration_id registration_id = {};
+ int has_serial_num = BCMOS_FALSE;
+ int has_registration_id = BCMOS_FALSE;
+ char two_digit_buf[3];
+
+ two_digit_buf[2] = 0;
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Before encoding,Vendor Id(%s),Vendor Specific Id(%s), Registration Id(%s)\n",
+ onu_cfg->data->serial_number->vendor_id,
+ onu_cfg->data->serial_number->vendor_specific,
+ onu_cfg->data->registration_id);
+
+ char vendor_id[20];
+ memset(&vendor_id, 0, 20);
+ sprintf(vendor_id,"%2X%2X%2X%2X",
+ onu_cfg->data->serial_number->vendor_id[0],
+ onu_cfg->data->serial_number->vendor_id[1],
+ onu_cfg->data->serial_number->vendor_id[2],
+ onu_cfg->data->serial_number->vendor_id[3]);
+ onu_cfg->data->serial_number->vendor_id = vendor_id;
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "After encoding,Vendor Id(%s),Vendor Specific Id(%s), Registration Id(%s)\n",
+ onu_cfg->data->serial_number->vendor_id,
+ onu_cfg->data->serial_number->vendor_specific,
+ onu_cfg->data->registration_id);
+
+ /* Vendor Id is totally 16 byte string and should be
+ send in hexadecimmal format */
+ for(idx=0; idx<2*sizeof(serial_num.vendor_id); idx+=2)
+ {
+ memcpy(two_digit_buf, &onu_cfg->data->serial_number->vendor_id[idx], 2);
+ serial_num.vendor_id[idx>>1] = strtol(two_digit_buf, NULL, 16);
+ has_serial_num = BCMOS_TRUE;
+ }
+ for(idx=0; idx<2*sizeof(serial_num.vendor_specific); idx+=2)
+ {
+ memcpy(two_digit_buf, &onu_cfg->data->serial_number->vendor_specific[idx], 2);
+ serial_num.vendor_specific[idx>>1] = strtol(two_digit_buf, NULL, 16);
+ }
+
+ ASFVOLT_CFG_PROP_SET(sub_term_obj, subscriber_terminal, serial_number,
+ has_serial_num, serial_num);
+
+ /* Registration ID is a string and should be given in hexadecimal format */
+ for(idx=0; idx<strlen(onu_cfg->data->registration_id) && idx<2*sizeof(registration_id.arr); idx+=2)
+ {
+ memcpy(two_digit_buf, &onu_cfg->data->registration_id[idx], 2);
+ registration_id.arr[idx>>1] = strtol(two_digit_buf, NULL, 16);
+ has_registration_id = BCMOS_TRUE;
+ }
+
+ ASFVOLT_CFG_PROP_SET(sub_term_obj, subscriber_terminal, registration_id,
+ has_registration_id, registration_id);
+
+ if (!memcmp(&serial_num, &zero_serial_num, sizeof(serial_num)))
+ skip_onu = BCMOS_TRUE;
+ }
+
+ ASFVOLT_CFG_PROP_SET(sub_term_obj, subscriber_terminal, admin_state,
+ BCMOS_TRUE, BCMBAL_STATE_UP);
+
+ if (!skip_onu)
+ {
+
+ /*ASFVOLT_LOG(ASFVOLT_DEBUG, "Onu's(%d) Serial number %02x%02x%02x%2x%02x%02x%02x%02x\n",
+ onu_cfg->key->sub_term_id,
+ sub_term_obj.data->serial_number.vendor_id[0], sub_term_obj.data->serial_number.vendor_id[1],
+ sub_term_obj.data->serial_number.vendor_id[2], sub_term_obj.data->serial_number.vendor_id[3],
+ sub_term_obj.data->serial_number.vendor_specific[0], sub_term_obj.data->serial_number.vendor_specific[1],
+ sub_term_obj.data->serial_number.vendor_specific[2], sub_term_obj.data->serial_number.vendor_specific[3]);*/
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr));
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG,
+ "\n ....SENT SUBSCRIBER TERMINAL %s UP %d on interface %d...\n",
+ (BCM_ERR_OK != err) ? "NOT" : "\b",
+ subs_terminal_key.sub_term_id,
+ subs_terminal_key.intf_id);
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_DEBUG,
+ "Skipping activation of subscriber terminal %d on interface %d\n",
+ subs_terminal_key.sub_term_id,
+ subs_terminal_key.intf_id);
+ err = BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ return BAL_ERRNO__BAL_ERR_OK;
+}
+
+
+/********************************************************************\
+ * Function : bal_subscriber_terminal_indication_cb *
+ * Description : Call Back indication registered with BAL to handle *
+ * events related to subscriber terminal(ONU) *
+ ********************************************************************/
+bcmos_errno bal_subscriber_terminal_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+
+#if 0
+ bcmbal_subscriber_terminal_cfg *cfg = ((bcmbal_subscriber_terminal_cfg *)obj);
+
+ if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL == obj->obj_type)
+ {
+ bcmbal_serial_number *p_serial_number =
+ (((bcmbal_subscriber_terminal_cfg *)obj)->data->serial_number);
+
+ if(BCMBAL_SUB_ID_UNKNOWN == (((bcmbal_subscriber_terminal_cfg *)obj)->key.sub_term_id))
+ {
+ ASFVOLT_LOG(ASFVOLT_INFO, "New ONU Discovered. serial number "
+ "%2X%2X%2X%2X%1X%1X%1X%1X%1X%1X%1X%1X "
+ "on PON %d\n",
+ p_serial_number->vendor_id[0],
+ p_serial_number->vendor_id[1],
+ p_serial_number->vendor_id[2],
+ p_serial_number->vendor_id[3],
+ p_serial_number->vendor_specific[0]>>4 & 0x0f,
+ p_serial_number->vendor_specific[0] & 0x0f,
+ p_serial_number->vendor_specific[1]>>4 & 0x0f,
+ p_serial_number->vendor_specific[1] & 0x0f,
+ p_serial_number->vendor_specific[2]>>4 & 0x0f,
+ p_serial_number->vendor_specific[2] & 0x0f,
+ p_serial_number->vendor_specific[3]>>4 & 0x0f,
+ p_serial_number->vendor_specific[3] & 0x0f,
+
+ ((bcmbal_subscriber_terminal_cfg *)obj)->key.intf_id);
+
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_INFO, "Event on existing ONU. serial number "
+ "%2X%2X%2X%2X%1X%1X%1X%1X%1X%1X%1X%1X "
+ "on PON %d\n",
+ p_serial_number->vendor_id[0],
+ p_serial_number->vendor_id[1],
+ p_serial_number->vendor_id[2],
+ p_serial_number->vendor_id[3],
+ p_serial_number->vendor_specific[0]>>4 & 0x0f,
+ p_serial_number->vendor_specific[0] & 0x0f,
+ p_serial_number->vendor_specific[1]>>4 & 0x0f,
+ p_serial_number->vendor_specific[1] & 0x0f,
+ p_serial_number->vendor_specific[2]>>4 & 0x0f,
+ p_serial_number->vendor_specific[2] & 0x0f,
+ p_serial_number->vendor_specific[3]>>4 & 0x0f,
+ p_serial_number->vendor_specific[3] & 0x0f,
+
+ ((bcmbal_subscriber_terminal_cfg *)obj)->key.intf_id);
+
+ }
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Invalid object type %d for subscriber terminal indication\n",
+ obj->obj_type);
+
+ }
+
+#endif
+ return result;
+}
+
+/********************************************************************\
+ * Function : bal_subscriber_terminal_cfg_clear *
+ * Description : clears the subscriber terminal(ONU) configuration *
+ ********************************************************************/
+uint32_t bal_subscriber_terminal_cfg_clear(BalSubscriberTerminalKey *terminal_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_subscriber_terminal_cfg cfg;
+ bcmbal_subscriber_terminal_key key = { };
+
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "Processing subscriber terminal cfg clear: %d\n",
+ terminal_key->sub_term_id);
+
+ if (terminal_key->has_sub_term_id &&
+ terminal_key->has_intf_id)
+ {
+ key.sub_term_id = terminal_key->sub_term_id ;
+ key.intf_id = terminal_key->intf_id ;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Invalid Key to handle subscriber terminal clear Req.subscriber_terminal_id(%d), Interface ID(%d)\n",
+ key.sub_term_id, key.intf_id);
+
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
+ err = BAL_ERRNO__BAL_ERR_OK;
+ return err;
+}
+
+/********************************************************************\
+ * Function : bal_subscriber_terminal_cfg_get *
+ * Description : Get the subscriber terminal(ONU) configuration *
+ ********************************************************************/
+uint32_t bal_subscriber_terminal_cfg_get(BalSubscriberTerminalKey *terminal_key,
+ BalSubscriberTerminalCfg *onu_cfg)
+{
+
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_subscriber_terminal_cfg cfg; /**< declare main API struct */
+ bcmbal_subscriber_terminal_key key = { }; /**< declare key */
+ uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
+
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "Processing subscriber terminal cfg get: %d\n",
+ onu_cfg->key->sub_term_id);
+
+ if (terminal_key->has_sub_term_id &&
+ terminal_key->has_intf_id)
+ {
+ key.sub_term_id = terminal_key->sub_term_id ;
+ key.intf_id = terminal_key->intf_id ;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Invalid Key to handle subscriber terminal Cfg Get subscriber_terminal_id(%d), Interface ID(%d)\n",
+ key.sub_term_id, key.intf_id);
+
+ return BAL_ERRNO__BAL_ERR_PARM;
+ }
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
+
+ BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, all_properties);
+
+ /* set memory to use for variable-sized lists */
+ list_mem = malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
+ if (list_mem == NULL)
+ {
+
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Memory allocation failed while handling subscriber terminal cfg get subscriber_terminal_id(%d), Interface ID(%d)\n",
+ key.sub_term_id, key.intf_id);
+ return BAL_ERRNO__BAL_ERR_NOMEM;
+ }
+
+ memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
+ BCMBAL_CFG_LIST_BUF_SET(&cfg, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
+
+ /* call API */
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &cfg.hdr);
+ if (err != BCM_ERR_OK)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)\n",
+ key.sub_term_id, key.intf_id);
+ return BAL_ERRNO__BAL_ERR_INTERNAL;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO,
+ "To-Do. Send subscriber terminal details to Adapter\n");
+ return BAL_ERRNO__BAL_ERR_OK;
+}
diff --git a/src/bal_subscriber_terminal_hdlr.h b/src/bal_subscriber_terminal_hdlr.h
new file mode 100755
index 0000000..94989cd
--- /dev/null
+++ b/src/bal_subscriber_terminal_hdlr.h
@@ -0,0 +1,23 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+extern uint32_t bal_subscriber_terminal_cfg_set(BalSubscriberTerminalCfg *onu_cfg);
+extern bcmos_errno bal_subscriber_terminal_indication_cb(bcmbal_obj *obj);
+extern uint32_t bal_subscriber_terminal_cfg_clear(BalSubscriberTerminalKey *terminal_key);
+extern uint32_t bal_subscriber_terminal_cfg_get(BalSubscriberTerminalKey *terminal_key,
+ BalSubscriberTerminalCfg *onu_cfg);
+
+#define BAL_DYNAMIC_LIST_BUFFER_SIZE (32 * 1024)
diff --git a/src/bal_tmqueue_hdlr.c b/src/bal_tmqueue_hdlr.c
new file mode 100755
index 0000000..75f26ce
--- /dev/null
+++ b/src/bal_tmqueue_hdlr.c
@@ -0,0 +1,287 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "asfvolt16_driver.h"
+#include "bal_tmqueue_hdlr.h"
+
+
+/********************************************************************\
+ * Function : bal_tm_queue_cfg_set *
+ * Description : Configures the tm queue for OLT device *
+ ********************************************************************/
+
+uint32_t bal_tm_queue_cfg_set(BalTmQueueCfg *tm_queue_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_queue_cfg tm_queue_obj; /**< declare main API struct */
+ bcmbal_tm_queue_key key = { }; /**< declare key */
+
+ if((tm_queue_cfg->key->has_id) && (tm_queue_cfg->key->has_sched_id) && (tm_queue_cfg->key->has_sched_dir))
+ {
+ key.id = tm_queue_cfg->key->id;
+ key.sched_id = tm_queue_cfg->key->sched_id;
+ key.sched_dir = tm_queue_cfg->key->sched_dir;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the tm queue cfg(OLT): Missing Key values\
+ Recevied key values Id(%d), Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_queue_cfg->key->sched_id, tm_queue_cfg->key->sched_dir, tm_queue_cfg->key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT(tm Queue) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_queue_obj, tm_queue, key);
+
+ /* decode API parameters from GRPC */
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, priority,
+ tm_queue_cfg->data->has_priority,
+ tm_queue_cfg->data->priority);
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, weight,
+ tm_queue_cfg->data->has_weight,
+ tm_queue_cfg->data->weight);
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, creation_mode,
+ tm_queue_cfg->data->has_creation_mode,
+ tm_queue_cfg->data->creation_mode);
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, ref_count,
+ tm_queue_cfg->data->has_ref_count,
+ tm_queue_cfg->data->ref_count);
+
+ /* rating/shaping */
+ BalTmShaping *balShaping = (BalTmShaping *)tm_queue_cfg->data->rate;
+ bcmbal_tm_shaping val = {};
+ if (balShaping->has_presence_mask)
+ {
+ val.presence_mask = balShaping->presence_mask;
+ if (balShaping->has_cir)
+ {
+ val.cir = balShaping->cir;
+ }
+ if (balShaping->has_pir)
+ {
+ val.pir = balShaping->pir;
+ }
+ if (balShaping->has_burst)
+ {
+ val.burst = balShaping->burst;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, rate, BCMOS_TRUE, val);
+ }
+
+ /* bac - Buffer addmission Control */
+ BalTmBac *balBac = (BalTmBac *)tm_queue_cfg->data->bac;
+ bcmbal_tm_bac valBac = {};
+ if(balBac->has_type)
+ {
+ valBac.type = balBac->type;
+ switch(valBac.type)
+ {
+ case BAL_TM_BAC__U_TAILDROP:
+ if(balBac->taildrop->has_max_size)
+ {
+ valBac.u.taildrop.max_size = balBac->taildrop->max_size;
+ }
+ break;
+ case BAL_TM_BAC__U_RED:
+ if(balBac->red->red->has_min_threshold)
+ {
+ valBac.u.red.red.min_threshold = balBac->red->red->min_threshold;
+ }
+ if(balBac->red->red->has_max_threshold)
+ {
+ valBac.u.red.red.max_threshold = balBac->red->red->max_threshold;
+ }
+ if(balBac->red->red->has_max_probability)
+ {
+ valBac.u.red.red.max_probability = balBac->red->red->max_probability;
+ }
+ break;
+ case BAL_TM_BAC__U_WRED:
+ if(balBac->wred->red->has_min_threshold)
+ {
+ valBac.u.wred.red.min_threshold = balBac->wred->red->min_threshold;
+ }
+ if(balBac->wred->red->has_max_threshold)
+ {
+ valBac.u.wred.red.max_threshold = balBac->wred->red->max_threshold;
+ }
+ if(balBac->wred->red->has_max_probability)
+ {
+ valBac.u.wred.red.max_probability= balBac->wred->red->max_probability;
+ }
+ if(balBac->wred->green->has_min_threshold)
+ {
+ valBac.u.wred.green.min_threshold = balBac->wred->green->min_threshold;
+ }
+ if(balBac->wred->green->has_max_threshold)
+ {
+ valBac.u.wred.green.max_threshold = balBac->wred->green->max_threshold;
+ }
+ if(balBac->wred->green->has_max_probability)
+ {
+ valBac.u.wred.green.max_probability= balBac->wred->green->max_probability;
+ }
+ if(balBac->wred->yellow->has_min_threshold)
+ {
+ valBac.u.wred.yellow.min_threshold = balBac->wred->yellow->min_threshold;
+ }
+ if(balBac->wred->yellow->has_max_threshold)
+ {
+ valBac.u.wred.yellow.max_threshold = balBac->wred->yellow->max_threshold;
+ }
+ if(balBac->wred->yellow->has_max_probability)
+ {
+ valBac.u.wred.yellow.max_probability= balBac->wred->yellow->max_probability;
+ }
+ break;
+ default:
+ break;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, bac, BCMOS_TRUE, valBac);
+ }
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(tm_queue_obj.hdr));
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the tm Queue Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nSet tm Queue configuration sent to OLT. \
+ Queue ID(%d) Sched ID(%d) Sched Dir(%d)\n",
+ key.id, key.sched_id, key.sched_dir );
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_queue_cfg_clear *
+ * Description : clear the OLT device tm queue configuration *
+ ********************************************************************/
+
+uint32_t bal_tm_queue_cfg_clear(BalTmQueueKey *tm_queue_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_queue_cfg tm_queue_obj; /**< declare main API struct */
+ bcmbal_tm_queue_key key = { }; /**< declare key */
+
+ if((tm_queue_key->has_id) && (tm_queue_key->has_sched_id) && (tm_queue_key->has_sched_dir))
+ {
+ key.id = tm_queue_key->id;
+ key.sched_id = tm_queue_key->sched_id;
+ key.sched_dir = tm_queue_key->sched_dir;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the tm queue cfg(OLT): Missing Key values\
+ Recevied key values Id(%d), Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_queue_key->sched_id, tm_queue_key->sched_dir, tm_queue_key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(tm Queue) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_queue_obj, tm_queue, key);
+
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &tm_queue_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the tm Queue Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nClear tm Queue sent to OLT. \
+ Queue ID(%d) Sched ID(%d) Sched Dir(%d)\n",
+ key.id, key.sched_id, key.sched_dir );
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_queue_cfg_get *
+ * Description : Get the OLT device tm queue configuration *
+ ********************************************************************/
+
+uint32_t bal_tm_queue_cfg_get(BalTmQueueKey *tm_queue_key, BalTmQueueCfg *tm_queue_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_queue_cfg tm_queue_obj; /**< declare main API struct */
+ bcmbal_tm_queue_key key = { }; /**< declare key */
+
+ if((tm_queue_key->has_id) && (tm_queue_key->has_sched_id) && (tm_queue_key->has_sched_dir))
+ {
+ key.id = tm_queue_key->id;
+ key.sched_id = tm_queue_key->sched_id;
+ key.sched_dir = tm_queue_key->sched_dir;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the tm queue cfg(OLT): Missing Key values\
+ Recevied key values Id(%d), Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_queue_key->sched_id, tm_queue_key->sched_dir, tm_queue_key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Get tm queue cfg(for OLT) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_queue_obj, tm_queue, key);
+
+ /* request all properties, include everything */
+ BCMBAL_CFG_PROP_GET(&tm_queue_obj, tm_queue, all_properties);
+
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &tm_queue_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the tm Queue Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "\nGet tm Queue sent to OLT. \
+ Queue ID(%d) Sched ID(%d) Sched Dir(%d)\n",
+ key.id, key.sched_id, key.sched_dir );
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_queue_indication_cb *
+ * Description : Call back function registered with BAL to handle *
+ * event related to access terminal *
+ ********************************************************************/
+bcmos_errno bal_tm_queue_cfg_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+ ASFVOLT_LOG(ASFVOLT_INFO, "Processing API \'%s\' IND callback (status is %s)\n",
+ bcmbal_objtype_str(obj->obj_type),
+ bcmos_strerror(obj->status));
+
+ return result;
+}
+
+
diff --git a/src/main.c b/src/bal_tmqueue_hdlr.h
old mode 100644
new mode 100755
similarity index 66%
copy from src/main.c
copy to src/bal_tmqueue_hdlr.h
index b62bc6e..1ba5196
--- a/src/main.c
+++ b/src/bal_tmqueue_hdlr.h
@@ -13,13 +13,8 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_tm_queue_cfg_set(BalTmQueueCfg *tm_queue_cfg);
+extern uint32_t bal_tm_queue_cfg_clear(BalTmQueueKey *tm_queue_key);
+extern uint32_t bal_tm_queue_cfg_get(BalTmQueueKey *tm_queue_key, BalTmQueueCfg *tm_queue_cfg);
+extern bcmos_errno bal_tm_queue_cfg_indication_cb(bcmbal_obj *obj);
diff --git a/src/bal_tmsched_hdlr.c b/src/bal_tmsched_hdlr.c
new file mode 100755
index 0000000..1ed1b01
--- /dev/null
+++ b/src/bal_tmsched_hdlr.c
@@ -0,0 +1,411 @@
+/*
+** Copyright 2017-present Open Networking Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <bal_api.h>
+
+#undef _SYS_QUEUE_H_
+
+/* Includes related to proto buf */
+#include "asfvolt16_driver.h"
+#include "bal_tmsched_hdlr.h"
+
+/********************************************************************\
+ * Function : bal_tm_sched_cfg_set *
+ * Description : Configures the tm scheduler for OLT device *
+ ********************************************************************/
+
+uint32_t bal_tm_sched_cfg_set(BalTmSchedCfg *tm_sched_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_sched_cfg tm_sched_obj; /**< declare main API struct */
+ bcmbal_tm_sched_key key = { }; /**< declare key */
+
+ if((tm_sched_cfg->key->has_dir) && (tm_sched_cfg->key->has_id))
+ {
+ key.dir = tm_sched_cfg->key->dir;
+ key.id = tm_sched_cfg->key->id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the tm schedule cfg(OLT): Missing Key values\
+ Recevied key values Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_sched_cfg->key->dir, tm_sched_cfg->key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT(tm Sched) starts\n");
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_sched_obj, tm_sched, key);
+
+ /* decode API parameters from GRPC */
+ /* scheduler owner */
+ BalTmSchedOwner *tmScOwn = (BalTmSchedOwner *)tm_sched_cfg->data->owner;
+ bcmbal_tm_sched_owner valtmScOwn = {};
+ if(tmScOwn->has_type)
+ {
+ valtmScOwn.type = tmScOwn->type;
+ switch(valtmScOwn.type)
+ {
+ case BCMBAL_TM_SCHED_OWNER_TYPE_INTERFACE:
+ if(tmScOwn->interface->has_intf_type)
+ {
+ valtmScOwn.u.interface.intf_type = tmScOwn->interface->intf_type;
+ }
+ if(tmScOwn->interface->has_intf_id)
+ {
+ valtmScOwn.u.interface.intf_id = tmScOwn->interface->intf_id;
+ }
+ break;
+ case BCMBAL_TM_SCHED_OWNER_TYPE_SUB_TERM:
+ if(tmScOwn->sub_term->has_intf_id)
+ {
+ valtmScOwn.u.sub_term.intf_id = tmScOwn->sub_term->intf_id;
+ }
+ if(tmScOwn->sub_term->has_sub_term_id)
+ {
+ valtmScOwn.u.sub_term.sub_term_id = tmScOwn->sub_term->sub_term_id;
+ }
+ break;
+ case BCMBAL_TM_SCHED_OWNER_TYPE_AGG_PORT:
+ if(tmScOwn->agg_port->has_presence_mask)
+ {
+ valtmScOwn.u.agg_port.presence_mask = tmScOwn->agg_port->presence_mask;
+ if(tmScOwn->agg_port->has_intf_id)
+ {
+ valtmScOwn.u.agg_port.intf_id= tmScOwn->agg_port->intf_id;
+ }
+ if(tmScOwn->agg_port->has_sub_term_id)
+ {
+ valtmScOwn.u.agg_port.sub_term_id = tmScOwn->agg_port->sub_term_id;
+ }
+ if(tmScOwn->agg_port->has_agg_port_id)
+ {
+ valtmScOwn.u.agg_port.agg_port_id = tmScOwn->agg_port->agg_port_id;
+ }
+ }
+ break;
+ case BCMBAL_TM_SCHED_OWNER_TYPE_UNI:
+ if(tmScOwn->uni->has_intf_id)
+ {
+ valtmScOwn.u.uni.intf_id = tmScOwn->uni->intf_id;
+ }
+ if(tmScOwn->uni->has_sub_term_id)
+ {
+ valtmScOwn.u.uni.sub_term_id = tmScOwn->uni->sub_term_id;
+ }
+ if(tmScOwn->uni->has_idx)
+ {
+ valtmScOwn.u.uni.idx = tmScOwn->uni->idx;
+ }
+ break;
+ case BCMBAL_TM_SCHED_OWNER_TYPE_VIRTUAL:
+ if(tmScOwn->virtual_->has_idx)
+ {
+ valtmScOwn.u.virtual.idx = tmScOwn->virtual_->idx;
+ }
+ break;
+ default:
+ break;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, owner, BCMOS_TRUE, valtmScOwn);
+ }
+
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, sched_type,
+ tm_sched_cfg->data->has_sched_type,
+ tm_sched_cfg->data->sched_type);
+
+ /* scheduler parent */
+ BalTmSchedParent *schedPar = (BalTmSchedParent *)tm_sched_cfg->data->sched_parent;
+ bcmbal_tm_sched_parent valSchedPar = {};
+ if(schedPar != NULL && schedPar->has_presence_mask)
+ {
+ valSchedPar.presence_mask = schedPar->presence_mask;
+ if(schedPar->has_sched_id)
+ {
+ valSchedPar.sched_id = schedPar->sched_id;
+ }
+ if(schedPar->has_priority)
+ {
+ valSchedPar.priority = schedPar->priority;
+ }
+ if(schedPar->has_weight)
+ {
+ valSchedPar.weight = schedPar->weight;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, sched_parent, BCMOS_TRUE, valSchedPar);
+ }
+
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, sched_child_type,
+ tm_sched_cfg->data->has_sched_child_type,
+ tm_sched_cfg->data->sched_child_type);
+
+ /* rating/shaping */
+ BalTmShaping *balShaping = (BalTmShaping *)tm_sched_cfg->data->rate;
+ bcmbal_tm_shaping val = {};
+ if (balShaping != NULL && balShaping->has_presence_mask)
+ {
+ val.presence_mask = balShaping->presence_mask;
+ if (balShaping->has_cir)
+ {
+ val.cir = balShaping->cir;
+ }
+ if (balShaping->has_pir)
+ {
+ val.pir = balShaping->pir;
+ }
+ if (balShaping->has_burst)
+ {
+ val.burst = balShaping->burst;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, rate, BCMOS_TRUE, val);
+ }
+
+ /* Extended itu dba parameters */
+ BalExtendedItuDba *tItuDba = (BalExtendedItuDba *)tm_sched_cfg->data->ext_itu_dba;
+ bcmbal_extended_itu_dba valItuDda = {};
+ if (tItuDba != NULL && tItuDba->has_presence_mask)
+ {
+ valItuDda.presence_mask = tItuDba->presence_mask;
+ if(tItuDba->has_extra_bw_elig)
+ {
+ valItuDda.extra_bw_elig = tItuDba->extra_bw_elig;
+ }
+ if (tItuDba->has_nrt_cbr)
+ {
+ valItuDda.nrt_cbr = tItuDba->nrt_cbr;
+ }
+ if (tItuDba->has_rt_cbr)
+ {
+ valItuDda.rt_cbr = tItuDba->rt_cbr;
+ }
+ if (tItuDba->has_nrt_profile)
+ {
+ valItuDda.nrt_profile = tItuDba->nrt_profile;
+ }
+ if (tItuDba->has_rt_profile)
+ {
+ valItuDda.rt_profile = tItuDba->rt_profile;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, ext_itu_dba, BCMOS_TRUE, valItuDda);
+ }
+
+ /* Creation mode */
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, creation_mode,
+ tm_sched_cfg->data->has_creation_mode,
+ tm_sched_cfg->data->creation_mode);
+
+ /* Extended epon dba parameters */
+ BalExtendedEponDba *teponDba = (BalExtendedEponDba*)tm_sched_cfg->data->ext_epon_dba;
+ bcmbal_extended_epon_dba valeponDda = {};
+ if (teponDba != NULL && teponDba->has_presence_mask)
+ {
+ valeponDda.presence_mask = teponDba->presence_mask;
+ if (teponDba->has_polling_interval_us)
+ {
+ valeponDda.polling_interval_us = teponDba->polling_interval_us;
+ }
+ if (teponDba->has_grant_threshold_tq)
+ {
+ valeponDda.grant_threshold_tq = teponDba->grant_threshold_tq;
+ }
+ if (teponDba->has_cir_priority)
+ {
+ valeponDda.cir_priority = teponDba->cir_priority;
+ }
+ if (teponDba->has_cir_weight_tq)
+ {
+ valeponDda.cir_weight_tq = teponDba->cir_weight_tq;
+ }
+ if (teponDba->has_pir_priority)
+ {
+ valeponDda.pir_priority = teponDba->pir_priority;
+ }
+ if (teponDba->has_pir_weight_tq)
+ {
+ valeponDda.pir_weight_tq = teponDba->pir_weight_tq;
+ }
+ if (teponDba->has_tdm_grant_size_tq)
+ {
+ valeponDda.tdm_grant_size_tq = teponDba->tdm_grant_size_tq;
+ }
+ if (teponDba->has_tdm_grant_interval_us)
+ {
+ valeponDda.tdm_grant_interval_us = teponDba->tdm_grant_interval_us;
+ }
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, ext_epon_dba, BCMOS_TRUE, valeponDda);
+ }
+
+ /* Subsidiary queues */
+ BalIdList *balQueues = (BalIdList *)tm_sched_cfg->data->queues;
+ bcmbal_tm_queue_id_list_u8 valQueues = {};
+ if(balQueues != NULL && balQueues->n_val)
+ {
+ valQueues.len = balQueues->n_val;
+ valQueues.val = (bcmbal_tm_queue_id *)malloc((valQueues.len)*sizeof(bcmbal_tm_queue_id));
+ if(!valQueues.val)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Failed to configure the tm scheduler cfg(OLT): Memory Exhausted\n");
+ return BAL_ERRNO__BAL_ERR_NOMEM;
+ }
+ memcpy((void *)valQueues.val, (const void *)balQueues->val,
+ (balQueues->n_val)*sizeof(uint32_t));
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, queues, BCMOS_TRUE, valQueues);
+ }
+
+ /* Subsidiary schedulers */
+ BalIdList *balSubScheds = (BalIdList *)tm_sched_cfg->data->sub_scheds;
+ bcmbal_tm_sched_id_list_u8 valSubScheds = {};
+ if(balSubScheds != NULL && balSubScheds->n_val)
+ {
+ valSubScheds.len = balSubScheds->n_val;
+ valSubScheds.val = (uint32_t *)malloc((valSubScheds.len)*sizeof(uint32_t));
+ if(!valSubScheds.val)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR,
+ "Failed to configure the tm scheduler cfg(OLT): Memory Exhausted\n");
+ return BAL_ERRNO__BAL_ERR_NOMEM;
+ }
+ memcpy((void *)valSubScheds.val, (const void *)balSubScheds->val,
+ (balSubScheds->n_val)*sizeof(uint32_t));
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, sub_scheds, BCMOS_TRUE, valSubScheds);
+ }
+
+ ASFVOLT_CFG_PROP_SET(tm_sched_obj, tm_sched, num_priorities,
+ tm_sched_cfg->data->has_num_priorities,
+ tm_sched_cfg->data->num_priorities);
+
+ err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(tm_sched_obj.hdr));
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the tm scheduler Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Set tm scheduler configuration sent to OLT. \
+ Sched ID(%d) Sched Dir(%d)\n", key.id, key.dir);
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_sched_cfg_get *
+ * Description : get the OLT device tm queue configuration *
+ ********************************************************************/
+
+uint32_t bal_tm_sched_cfg_get(BalTmSchedKey *tm_sched_key, BalTmSchedCfg *tm_sched_cfg)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_sched_cfg tm_sched_obj; /**< declare main API struct */
+ bcmbal_tm_sched_key key = { }; /**< declare key */
+
+ if((tm_sched_cfg->key->has_dir) && (tm_sched_cfg->key->has_id))
+ {
+ key.dir = tm_sched_cfg->key->dir;
+ key.id = tm_sched_cfg->key->id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the tm schedule cfg(OLT): Missing Key values\
+ Recevied key values Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_sched_cfg->key->dir, tm_sched_cfg->key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Gem tm scheduler cfg (for OLT) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_sched_obj, tm_sched, key);
+
+ /* request all properties, include everything */
+ BCMBAL_CFG_PROP_GET(&tm_sched_obj, tm_sched, all_properties);
+
+ err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &tm_sched_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the tm scheduler Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Get tm scheduler cfg sent to OLT. \
+ Sched ID(%d) Sched Dir(%d)\n", key.id, key.dir);
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_sched_cfg_clear *
+ * Description : Clears the OLT device tm queue configuration *
+ ********************************************************************/
+
+uint32_t bal_tm_sched_cfg_clear(BalTmSchedKey *tm_sched_key)
+{
+ bcmos_errno err = BCM_ERR_OK;
+ bcmbal_tm_sched_cfg tm_sched_obj; /**< declare main API struct */
+ bcmbal_tm_sched_key key = { }; /**< declare key */
+
+ if((tm_sched_key->has_dir) && (tm_sched_key->has_id))
+ {
+ key.dir = tm_sched_key->dir;
+ key.id = tm_sched_key->id;
+ }
+ else
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the tm schedule cfg(OLT): Missing Key values\
+ Recevied key values Sched-Dir(%d), Sched-Id(%d) \n",
+ tm_sched_key->dir, tm_sched_key->id);
+ return BAL_ERRNO__BAL_ERR_NOENT;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_DEBUG, "Clear tm scheduler cfg(for OLT) starts\n");
+
+ /* init the API struct */
+ BCMBAL_CFG_INIT(&tm_sched_obj, tm_sched, key);
+
+ err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &tm_sched_obj.hdr);
+
+ if(BCM_ERR_OK != err)
+ {
+ ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the tm scheduler Cfg(OLT)\n");
+ return err;
+ }
+
+ ASFVOLT_LOG(ASFVOLT_INFO, "Clear tm scheduler clear sent to OLT. \
+ Sched ID(%d) Sched Dir(%d)\n", key.id, key.dir);
+ return err;
+}
+
+
+/********************************************************************\
+ * Function : bal_tm_sched_indication_cb *
+ * Description : Call back function registered with BAL to handle *
+ * event related to access terminal *
+ ********************************************************************/
+bcmos_errno bal_tm_sched_cfg_indication_cb(bcmbal_obj *obj)
+{
+ bcmos_errno result = BCM_ERR_OK;
+ ASFVOLT_LOG(ASFVOLT_INFO, "Processing API (%s) IND callback status is (%s)\n",
+ bcmbal_objtype_str(obj->obj_type),
+ bcmos_strerror(obj->status));
+
+ return result;
+}
+
+
diff --git a/src/main.c b/src/bal_tmsched_hdlr.h
old mode 100644
new mode 100755
similarity index 66%
copy from src/main.c
copy to src/bal_tmsched_hdlr.h
index b62bc6e..a625bee
--- a/src/main.c
+++ b/src/bal_tmsched_hdlr.h
@@ -13,13 +13,9 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-#include <config.h>
-#include <stdio.h>
-int
-main (void)
-{
- puts ("Hello World!");
- puts ("This is " PACKAGE_STRING ".");
- return 0;
-}
+extern uint32_t bal_tm_sched_cfg_set(BalTmSchedCfg *tm_sched_cfg);
+extern uint32_t bal_tm_sched_cfg_get(BalTmSchedKey *tm_sched_key, BalTmSchedCfg *tm_sched_cfg);
+extern uint32_t bal_tm_sched_cfg_clear(BalTmSchedKey *tm_sched_key);
+extern bcmos_errno bal_tm_sched_cfg_indication_cb(bcmbal_obj *obj);
+