VOL-2014: Rebase bal30-dev branch with master and re-verify sanity with SEBA2.0 and VOLTHA2.x before merge to master
          Squashed all commits from bal30-dev branch to master branch as a single commit.
          Bumped version to 2.0.0-dev .
          Update README.md with the required ONL version for BAL3.1 .

VOL-2130: Wrong queue id assigned for downstream queue on tm_sched
          for the subscriber when using single gem port.
          Use queue_id as 0 when using single gem port.

          Issues need to be taken care:
          VOL-1580: Support reporting ONU Registration ID as part of ONU Activation Indication
          - commented the code developed for VOL-1580 to fetch ONU registration ID as it uses BAL2.6 specific API's.
          - Need to check how the same can be achieved using BAL3.x API's to fetch ONU registration ID

Set .gitreview defaultbranch to bal30-dev
Rebase change - Removed .gitreview defaultbranch so that by default it will point to master

Change-Id: Ib57e52e98cf09f4fa3dbaa9156a4375b7dc6ee43

Rebase: [VOL-1635] [BAL3.0 Bridade] OLT Activation [VOL-1636] [BAL3.0 Bridade] ONU Discovery,
        This OpenOLT agent supports the BAL V3.0.3.3 SDK. OLT/ONU activation from voltha-1.7 is successful

Change-Id: I860b31317172139cd4c4244a93e79e0c3ce4fdf8

Rebase: [VOL-1685][BAL3.0 Bridade] generate OpenOLT debian package file

Change-Id: Ib0332d948602bf7892b6aae91a4147356237f7e2

Rebase: [VOL-1685][BAL3.0 Brigade] generate OpenOLT debian package file
missing copy shell files (dev_mgmt_daemon and openolt).

Change-Id: Id29dc24be4d1d5fc12a26884e5b5a69de91fbd69

Rebase: [VOL-1685][BAL3.0 Brigade] generate OpenOLT debian package file

Change-Id: Ic5453616c0dbdbc1fb1eb241feba1cbfca5e8e85

Rebase: [VOL-1852][BAL3.0 Brigade] Support Edge-core OLT ASFvOLT16 (XGS-PON) and
ASGvOLT64 (GPON) devices

Change-Id: I316d35bc76c38b5381e8896148b4ee5cebbd1099

VOL-1850: Fix packet duplication with TM Queue Mapping profile
          Fix for US and DS scheduler ID allocation irrespective of device type(asfvolt16/asfvolt64)
          README.md file update with BAL3.1.1.1 specifications

Change-Id: I255bf7a4ff35771e9c628bb822ba2190a1fcd5ed

Rebase: [VOL-1787] : This commit sets up a unit-test framework for openolt
                     agent based on gtest, gmock and c-mock utilities.
                     A sample unit-test case to test EnableOlt success case is also
                     added. More test cases will be added in future commit.

Change-Id: If020be489a04d97df5fcbc15e9207deeee2fcfac

Rebase: [VOL-2040]: Patch the macro required by core.cc into bcmos_system.h file

Change-Id: Ic841785b2ce451b1acaf007074b8c458687bc753

Rebase: [VOL-2043] : OLT Enable Test Case

        - Added more test cases for OLT Enable. Now covers all scenarios.
        - Fixed typos in unit test README.md

Change-Id: Ib931d89cedee78fe40ca67761a028365a047ebc3

Rebase: VOL-1941: Use protobufs from the voltha-protos repo, not a copy

        - Use protobufs from the voltha-protos repo, not a copy
        - Provided option to specify the openolt proto version via make option
        - Removed duplicate README.md

Change-Id: Id67714c8119521f8358aaa9245268c47b7e843cf
diff --git a/agent/Makefile.in b/agent/Makefile.in
index b68b15e..cee6f34 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -19,6 +19,7 @@
 ##        Config
 ##
 ##
+TOP_DIR=`pwd`
 OPENOLTDEVICE ?= generic
 
 #
@@ -26,14 +27,24 @@
 # SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK.
 # sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK.
 # ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch.
-BAL_MAJOR_VER = 02.06
-BAL_VER = 2.6.0.1
-SDK_VER = 6.5.7
-DEV_VER ?= 201804301043
+BAL_MAJOR_VER = 3
+BAL_MINOR_VER = 1
+BAL_REV_A_VER = 1
+BAL_REV_B_VER = 1
+BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER)
+BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
+SDK_VER = 6.5.13
+DEV_VER ?= 201908010203
 #
 # Version of Open Network Linux (ONL).
-ONL_KERN_VER_MAJOR = 3.7
-ONL_KERN_VER_MINOR = 10
+ONL_KERN_VER_MAJOR = 4.14
+
+# OpenOLT Proto version.
+# This specifies the GIT tag in https://github.com/opencord/voltha-protos
+# repo that we need to refer to, to pick the right version of
+# openolt.proto and tech_profile.proto
+OPENOLT_PROTO_VER ?= v1.0.3
+
 #
 # Build directory
 BUILD_DIR = build
@@ -65,7 +76,7 @@
 LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
 LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
 
-CXX = @CXX@
+CXX = @CXX@-4.9
 CXXFLAGS += @CXXFLAGS@
 CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
 CPPFLAGS += @CPPFLAGS@
@@ -78,12 +89,11 @@
 LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
 CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
 
-export CXX CXXFLAGS
+export CXX CXXFLAGS OPENOLT_PROTO_VER
 
 prereq:
-	sudo apt-get -q -y install pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io
-	sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers
-	sudo add-apt-repository -y ppa:git-core/ppa && apt-get -y update && apt-get -y install git
+	sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io
+	sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers curl cmake ccache g++-4.9
 
 	# Install GRPC, libprotobuf and protoc
 	rm -rf $(GRPC_DST)
@@ -110,14 +120,15 @@
 ##        ONL
 ##
 ##
-ONL_KERN_VER = $(ONL_KERN_VER_MAJOR).$(ONL_KERN_VER_MINOR)
-ONL_REPO = $(OPENOLTDEVICE)-onl
+ONL_REPO = onl
 ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
 onl:
 	if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
 		mkdir -p $(ONL_DIR); \
-		git clone https://gerrit.opencord.org/$(ONL_REPO) $(ONL_DIR); \
-		make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR); \
+		git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
+		cp download/Makefile.onl $(ONL_DIR)/Makefile; \
+		install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
+		make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR); \
 	fi;
 onl-force:
 	make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
@@ -127,68 +138,65 @@
 ########################################################################
 ##
 ##
+##        Broadcom LIBRARY APIs
+##
+##
+BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
+
+bal-api-$(BAL_API_VER):
+	if [ ! -d "$(BAL_API_DIR)" ]; then \
+		mkdir -p $(BAL_API_DIR); \
+		git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
+	fi;
+bal-api-clean:
+	rm $(BAL_API_DIR)
+
+########################################################################
+##
+##
 ##        BAL
 ##
 ##
-BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).zip
+BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).tgz
 SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
 ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
-OPENOLT_BAL_PATCH = OPENOLT_BAL_$(BAL_VER).patch
 BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
-ONL_KERNDIR = $(PWD)/$(ONL_DIR)/OpenNetworkLinux/packages/base/amd64/kernels/kernel-$(ONL_KERN_VER_MAJOR)-x86-64-all/builds
-MAPLE_KERNDIR = $(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/kernels
-BCM_SDK = $(BAL_DIR)/bal_release/3rdparty/bcm-sdk
-BALLIBDIR = $(BAL_DIR)/bal_release/build/core/src/apps/bal_api_dist_shared_lib
-BALLIBNAME = bal_api_dist
-BAL_INC = -I$(BAL_DIR)/bal_release/src/common/os_abstraction \
-	-I$(BAL_DIR)/bal_release/src/common/os_abstraction/posix \
-	-I$(BAL_DIR)/bal_release/src/common/config \
-	-I$(BAL_DIR)/bal_release/src/core/platform \
-	-I$(BAL_DIR)/bal_release/src/core/main \
-	-I$(BAL_DIR)/bal_release/src/common/include \
-	-I$(BAL_DIR)/bal_release/src/lib/libbalapi \
-	-I$(BAL_DIR)/bal_release/src/balapiend \
-	-I$(BAL_DIR)/bal_release/src/common/dev_log \
-	-I$(BAL_DIR)/bal_release/src/common/bal_dist_utils  \
-	-I$(BAL_DIR)/bal_release/src/lib/libtopology \
-	-I$(BAL_DIR)/bal_release/src/lib/libcmdline \
-	-I$(BAL_DIR)/bal_release/src/lib/libutils \
-	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/utils \
-	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/model \
-	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/api \
-	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_reference/cli
+BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
+BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
+BALLIBNAME = bal_host_api
+BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
+          -I$(BAL_DIR)/host_driver/topology \
+          -I$(BAL_DIR)/host_driver/utils \
+          -I$(BAL_DIR)/host_driver/api \
+          -I$(BAL_DIR)/host_customized/os_abstraction \
+          -I$(BAL_DIR)/host_customized/os_abstraction/posix \
+          -I$(BAL_DIR)/host_customized/config \
+          -I$(BAL_DIR)/host_driver/api_conn_mgr \
+          -I$(BAL_DIR)/host_driver/conn_mgr \
+          -I$(BAL_DIR)/host_driver/api/host/topology \
+          -I$(BAL_DIR)/host_reference/cli \
+          -I$(BAL_DIR)/host_reference/api_cli \
+          -I$(BAL_API_DIR)/include \
+          -I$(BAL_API_DIR)/include/object_model
 CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
-CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG
+CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DENABLE_CLI
 
-sdk: onl
+sdk: onl bal-api-$(BAL_API_VER)
 ifeq ("$(wildcard $(BAL_DIR))","")
 	mkdir $(BAL_DIR)
-	unzip download/$(BAL_ZIP) -d $(BAL_DIR)
+	tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
 	cp download/$(SDK_ZIP) $(BCM_SDK)
 	chmod -R 744 $(BAL_DIR)
 	cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
-	mkdir -p $(MAPLE_KERNDIR)
-	ln -s $(ONL_KERNDIR)/linux-$(ONL_KERN_VER) $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER)
-	ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/archives/linux-$(ONL_KERN_VER).tar.xz $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER).tar.xz
-	ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/$(ONL_KERN_VER_MAJOR)/configs/x86_64-all/x86_64-all.config $(MAPLE_KERNDIR)/x86_64-all.config
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk_dir
-	cat download/$(OPENOLT_BAL_PATCH) | patch -p1 -d $(BAL_DIR)
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk_dir
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk
-	KERNDIR=$(ONL_KERNDIR)/linux-$(ONL_KERN_VER) BOARD=$(OPENOLTDEVICE) ARCH=x86_64 SDKBUILD=build_bcm_user make -C $(BCM_SDK)/build-$(OPENOLTDEVICE)/sdk-all-$(SDK_VER)/systems/linux/user/x86-generic_64-2_6
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal
-	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/$(OPENOLTDEVICE)/board_files/broadcom/bal_config.ini
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board
+	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
+	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
 endif
 
-bal: sdk
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal
-	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/asfvolt16/board_files/broadcom/bal_config.ini
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board
+bal-release: sdk
+	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
 
 bal-clean:
-	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) clean_bal
+	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
 
 ########################################################################
 ##
@@ -255,51 +263,62 @@
 all: $(BUILD_DIR)/openolt
 $(BUILD_DIR)/openolt: sdk protos $(OBJS)
 	$(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc)
-	ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
-	ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/release/broadcom/libbal_api_dist.so $(BUILD_DIR)/.
-	ln -sf $(PWD)/$(BAL_DIR)/bal_release/build/core/src/apps/bal_core_dist/bal_core_dist $(BUILD_DIR)/.
+	ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
+	ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
+	ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
 	ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6
 	ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1
+	ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
+	strip $(BUILD_DIR)/openolt
 src/%.o: src/%.cc
 	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
 
 deb:
-	cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz mkdebian/debian
-	cp $(BUILD_DIR)/openolt mkdebian/debian
-	cp $(BUILD_DIR)/libgrpc.so.6 mkdebian/debian
-	cp $(BUILD_DIR)/libgrpc++.so.1 mkdebian/debian
-	cp -a scripts/init.d mkdebian/debian
-	cd mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
-	mv *.deb $(BUILD_DIR)/openolt.deb
+	cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp $(BUILD_DIR)/libgrpc.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp $(BUILD_DIR)/libgrpc++.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
+	cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
+	cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
+	mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE).deb
 	make deb-cleanup
 
 src/%.o: %.cpp
 	$(CXX) -MMD -c $< -o $@
 
 deb-cleanup:
-	rm -f mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
-	rm -f mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
-	rm -f mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
-	rm -f mkdebian/debian/$(OPENOLTDEVICE).substvars
-	rm -rf mkdebian/debian/$(OPENOLTDEVICE)/
-	rm -f mkdebian/debian/libgrpc++.so.1
-	rm -f mkdebian/debian/libgrpc.so.6
-	rm -f mkdebian/debian/openolt
-	rm -f mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz
-	rm -rf mkdebian/debian/tmp/
-	rm -f $(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
+	@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc++.so.1
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc.so.6
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
+	@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
+	@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz
+	@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
+	@rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
 
 clean: protos-clean deb-cleanup
-	rm -f $(OBJS) $(DEPS)
-	rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
-	rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1
-	rm -f $(BUILD_DIR)/libbal_api_dist.so
-	rm -f $(BUILD_DIR)/openolt
-	rm -f $(BUILD_DIR)/bal_core_dist
-	rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz
-	rm -f $(BUILD_DIR)/openolt.deb
+	@rm -f $(OBJS) $(DEPS)
+	@rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
+	@rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1
+	@rm -f $(BUILD_DIR)/libbal_api_dist.so
+	@rm -f $(BUILD_DIR)/openolt
+	@rm -f $(BUILD_DIR)/bal_core_dist
+	@rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz
+	@rm -f $(BUILD_DIR)/openolt.deb
 
-distclean:
-	rm -rf $(BUILD_DIR)
+clean-src: protos-clean
+	@rm -f $(OBJS) $(DEPS)
+
+distclean: clean-src clean
+	@rm -rf $(BUILD_DIR)
 
 .PHONY: onl sdk bal protos prereq sim
diff --git a/agent/README.md b/agent/README.md
deleted file mode 100644
index 6427faf..0000000
--- a/agent/README.md
+++ /dev/null
@@ -1,385 +0,0 @@
-# OpenOLT agent
-
-The *OpenOLT agent* runs on white box Optical Line Terminals (OLTs) and
-provides a gRPC-based management and control interface to OLTs.
-
-The OpenOLT agent is used by [VOLTHA](https://github.com/opencord/voltha)
-through the [OpenOLT
-adapter](https://github.com/opencord/voltha/tree/master/voltha/adapters/openolt).
-
-OpenOLT agent currently supports Broadcom's Maple/Qumran chipsets.
-
-```text
-
-  +---------------------------------+
-  |             VOLTHA              |
-  |                                 |
-  |       +------------------+      |
-  |       | OpenOLT adapter  |      |
-  +-------+--------+---------+------+
-                   |
-  OpenOLT gRPC API |
-                   |
-+--------------------- ---------------+
-|                  |                  |
-|         +------------------+        |
-|         |   OpenOLT agent  |        |
-|         +--------+---------+        |
-|                  |                  |
-| Vendor specific  | (e.g. Broadcom   |
-|       API        |     BAL API      |
-|                  |                  |
-|         +------------------+        |
-|         | Vendor SoC/FPGA  |        |
-|         |(e.g Maple/Qumran)|        |
-|         +------------------+        |
-|                                     |
-|           White box OLT             |
-+-------------------------------------+
-
-```
-
-## Hardware requirements
-
-A list of tested devices and optics can be found in the [CORD hardware
-requirements](https://github.com/opencord/docs/blob/master/prereqs/hardware.md#suggested-hardware)
-guide, in the *R-CORD access equipment and optics* section.
-
-## Pre-built debian packages of OpenOLT agent for Accton/Edgecore ASFVOLT16
-
-Accton/Edgecore makes available pre-built debian packages of OpenOLT agent to their customers.
-Contact your Accton/Edgecore representative for more information.
-
-The pre-built debian packages have been tested on [this specific version of
-OpenNetworkingLinux
-(ONL)](https://github.com/opencord/OpenNetworkLinux/releases/download/20180124-olt-kernel-3.7.10/ONL-2.0.0_ONL-OS_2018-01-24.0118-1303f20_AMD64_INSTALLED_INSTALLER).
-
-More info on how to install ONL can be found on the official [ONL
-website](https://opennetlinux.org/docs/deploy).
-
-## Install OpenOLT
-
-Copy the debian package to the OLT. For example:
-
-```shell
-scp openolt.deb root@10.6.0.201:~/.
-```
-
-Install the *openolt.deb* package using *dpkg*:
-
-```shell
-dpkg -i openolt.deb
-```
-
-## Run OpenOLT as a Linux service
-
-Rebooting the OLT (after the installation) will start bal_core_dist and openolt as init.d services:
-
-Rebooting the OLT will start the bal_core_dist and openolt services:
-
-```shell
-reboot
-```
-The services can also be stopped/started manually:
-
-```shell
-service bal_core_dist stop
-service openolt stop
-service bal_core_dist start
-service openolt start
-```
-
-Check the status of the services:
-
-```shell
-service bal_core_dist status
-service openolt status
-```
-
-## Run OpenOLT in foreground
-
-Running the bal_core_dist and/or openolt services in the forground is useful for development and debugging. Make sure to first stop the services if they are running in background.
-
-Open a terminal and run the Broadcom BAL software (*bal_core_dist*):
-
-```shell
-cd /broadcom
-./bal_core_dist -C :55001
-```
-
-The `bal_core_dist` executable, when run in foreground, presents the CLI for Broadcom's BAL - Broadband Access Layer which is useful for debugging.
-
-While the first executable still runs (even in background), open another
-terminal and run *openolt*:
-
-```shell
-cd /broadcom
-./openolt -C 127.0.0.1:55001
-```
-
-> **NOTE**: the two executables will remain open in the terminals, unless they
-> are put in background.
-
-### Connect from VOLTHA
-
-At the VOLTHA CLI, preprovision and enable the OLT:
-
-```shell
-(voltha) preprovision_olt -t openolt -H YOUR_OLT_MGMT_IP:9191
-(voltha) enable
-```
-
-### Additional notes
-
-* *9191* is the TCP port that the *OpenOLT* agent uses for its gRPC channel
-* In the commands above, you can either use the loopback IP address (127.0.0.1)
-  or substitute all its occurrences with the management IP of your OLT
-
-## Build OpenOLT
-
-### Supported BAL API versions
-
-Currently, OpenOLT support the Broadcom BAL APIs, version *2.6.0.1*.
-
-### Proprietary software requirements
-
-The following proprietary source code is required to build the OpenOLT agent.
-
-* `SW-BCM68620_<BAL_VER>.zip` - Broadcom BAL source and Maple SDK
-* `sdk-all-<SDK_VER>.tar.gz` - Broadcom Qumran SDK
-* `ACCTON_BAL_<BAL_VER>-<ACCTON_VER>.patch` - Accton/Edgecore's patch
-* `OPENOLT_BAL_<BAL_VER>.patch` - A patch to Broadcom software to allow
-  compilation with C++ based openolt
-
-The versions currently supported by the OpenOLT agent are:
-
-* SW-BCM68620_2_6_0_1.zip
-* sdk-all-6.5.7.tar.gz
-* ACCTON_BAL_2.6.0.1-V201804301043.patch
-* OPENOLT_BAL_2.6.0.1.patch
-
-> NOTE: the repository does not contain the above four source packages.  These
-> are needed to build the OpenOLT agent executable. Contact
-> [Broadcom](mailto:dave.baron@broadcom.com) to access the source packages.
-
-### System Requirements
-
-
-**Hardware** :
-
-CPU: Dual-core (4 Threads) up.
-
-Memory: 6G bytes.
-
-Hard Disk: 40G of disk free space.
-
-**Software** :
-
-1. docker  - to grab the build workspace
-    Follow below instructions for docker installation :
-https://docs.docker.com/engine/installation/debian/
-
-2. binfmt-support -  kernel support for ppc builds
-
-       `sudo apt-get install binfmt-support`
-
-3. Essential tools for building packages
-
-       `sudo apt-get install build-essential`
-
-4. At least 4G of ram and 4G of swap -  compilation is memory intensive
-
-5. All of the testing is done with Debian, other Linux distributions may  work, but we suggest using Debian 8.
-
-### Build procedure
-
-Clone the *openolt* repository either from GitHub or from OpenCORD Gerrit:
-
-```shell
-git clone git@github.com:opencord/openolt.git
-or
-git clone https://gerrit.opencord.org/openolt
-```
-
-Copy the Broadcom source and patch files to the openolt/download directory:
-
-```shell
-cd openolt/agent/download
-cp SW-BCM68620_2_6_0_1.zip sdk-all-6.5.7.tar.gz ACCTON_BAL_2.6.0.1-V201804301043.patch OPENOLT_BAL_2.6.0.1.patch ./download
-```
-
-Run Autoconfig to generate the appropriate makefile scaffolding for the desired target
-
-```shell
-cd openolt/agent
-./configure
-```
-
-Run *make prereq* to install the package dependencies.
-This is usually a one-time thing, unless there is a change in the dependencies.
-
-```shell
-make OPENOLTDEVICE=asfvolt16 prereq
-```
-
-Run *make*. This can take a while to complete the first time, since it builds
-ONL and the Broadcom SDKs. Following runs will be much faster, as they only
-build the OpenOLT agent source.
-
-```shell
-make OPENOLTDEVICE=asfvolt16
-```
-
-If the build process succeeds, libraries and executables will be created in the
-*openolt/build* directory.
-
-Optionally, build the debian package that will be installed on the OLT.
-
-```shell
-make OPENOLTDEVICE=asfvolt16 deb
-```
-
-If the build process succeeds, the *openolt.deb* package will be created as
-well in the *openolt/build* directory.
-
-### Cleanup
-
-To cleanup the repository and start the build procedure again, run:
-
-```shell
-make OPENOLTDEVICE=asfvolt16 clean-all
-```
-
-## FAQ
-
-### How to change speed of ASFVOLT16 NNI interface?
-
-Auto-negotiation on the NNI (uplink) interfaces is not tested. By default, the OpenOLT agent sets the speed of the NNI interfaces to 100G. To downgrade the network interface speed to 40G, add the following lines at the end of the qax.soc (/broadcom/qax.soc) configuration file. A restart of the bal_core_dist and openolt executables is required after the change.
-
-```shell
-port ce128 sp=40000
-```
-
-This change can also be made at run-time from the CLI of the bal_core_dist:
-
-```shell
-d/s/shell
-port ce128 speed=40000
-```
-(It is safe to ignore the error msgs.)
-
-### How do I configure rate limiting?
-
-By default, the full 1G xgs-pon bandwidth is available to an ONU when no rate-limiting is applied. There is experimental support available to change the default bandwith and also rate-limit specific ONUs from the voltha CLI.
-
-
-Configure default rate limit (PIR = 5Mbps):
-
-```shell
-(voltha) xpon
-(voltha-xpon )traffic_descriptor_profile create -n "default" -f 1000 -a 1000 -m 5000
-```
-
-
-Configure ONU BRCM12345678 to be rate-limited to 100Mbps:
-```shell
-(voltha) xpon
-(voltha-xpon )traffic_descriptor_profile create -n "default" -f 50000 -a 70000 -m 100000
-```
-
-### Why does the Broadcom ONU not forward eapol packets?
-
-The firmware on the ONU is likely not setup to forward 802.1x on the linux bridge. Drop down to the shell in the Broadcom ONU's console and configure the Linux bridge to forward 802.1x.
-
-```shell
-> sh
-# echo 8 > /sys/class/net/bronu513/bridge/group_fwd_mask
-```
-
-### How do I check packet counters on the ONU?
-
-LAN port packet counters:
-
-```shell
-bs /b/e port/index=lan{0,1,2,3,4,5,6}
-```
-
-WAN port packt counters:
-```shell
-bs /b/e port/index=wan0
-```
-
-### How do I check packet counters on the OLT's PON interface?
-
-Following is an example of retrieving the interface description for PON intf_id 0 (TODO: document PON interface numbering for Edgecore OLT).
-
-```shell
-ACC.0>b/t clear=no object=interface intf_id=0 intf_type=pon
-[-- API Start: bcmbal_stat_get --]
-[-- API Message Data --]
-object: interface - BAL interface object
-get stat: response: OK
-key:
-   intf_id=0
-   intf_type=pon
-data:
-   rx_bytes=18473516
-   rx_packets=176416
-   rx_ucast_packets=30627
-   rx_mcast_packets=2230
-   rx_bcast_packets=143559
-   rx_error_packets=0
-   rx_unknown_protos=0
-   rx_crc_errors=0
-   bip_errors=0
-   tx_bytes=5261350
-   tx_packets=39164
-   tx_ucast_packets=30583
-   tx_mcast_packets=0
-   tx_bcast_packets=8581
-   tx_error_packets=0
-[-- API Complete: 0 (OK) --]
-```
-
-#### How do I check packet counters on the OLT's NNI interface?
-
-Following command retrieves NNI intf_id 0:
-
-```shell
-ACC.0>b/t clear=no object=interface intf_id=0 intf_type=nniCollecting statistics
-[-- API Start: bcmbal_stat_get --]
-[-- API Message Data --]
-object: interface - BAL interface object
-get stat: response: OK
-key:
-   intf_id=0
-   intf_type=nni
-data:
-   rx_bytes=8588348
-   rx_packets=69774
-   rx_ucast_packets=61189
-   rx_mcast_packets=0
-   rx_bcast_packets=8585
-   rx_error_packets=0
-   rx_unknown_protos=0
-   tx_bytes=35354878
-   tx_packets=347167
-   tx_ucast_packets=61274
-   tx_mcast_packets=4447
-   tx_bcast_packets=281446
-   tx_error_packets=0
-[-- API Complete: 0 (OK) --]
-```
-
-### How do I list flows installed in the OLT?
-
-In the bal_core_dist CLI:
-
-```shell
-> ~, Debug/, Maple/, Board/, Cld/, Transport/, Logger/, Quit
-> Debug
-.../Debug> Rsc_mgr/, Mac_util/, Switch/, sLeep, sHow_config, os/
-> Mac_util
-.../Mac_util> Print_flows, pRint_flows_for_gem, prInt_flows_for_alloc_id, Epon_helper
-> Print_flow
-```
diff --git a/agent/common/core.h b/agent/common/core.h
index 7f8bfe4..1caf3cc 100644
--- a/agent/common/core.h
+++ b/agent/common/core.h
@@ -20,16 +20,61 @@
 
 #include <grpc++/grpc++.h>
 using grpc::Status;
-#include <openolt.grpc.pb.h>
+#include <voltha_protos/openolt.grpc.pb.h>
 
 #include "state.h"
 
+#define NONE "\033[m"
+#define LIGHT_RED "\033[1;31m"
+#define BROWN "\033[0;33m"
+#define LIGHT_GREEN "\033[1;32m"
+#define OPENOLT_LOG(level, id, fmt, ...)  \
+    if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_ERROR) \
+        BCM_LOG(level, id, "%s" fmt "%s", LIGHT_RED, ##__VA_ARGS__, NONE); \
+    else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_INFO) \
+        BCM_LOG(level, id, "%s" fmt "%s", NONE, ##__VA_ARGS__, NONE); \
+    else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_WARNING) \
+        BCM_LOG(level, id, "%s" fmt "%s", BROWN, ##__VA_ARGS__, NONE); \
+    else if (DEV_LOG_LEVEL_##level == DEV_LOG_LEVEL_DEBUG) \
+        BCM_LOG(level, id, "%s" fmt "%s", LIGHT_GREEN, ##__VA_ARGS__, NONE); \
+    else \
+        BCM_LOG(INFO, id, fmt, ##__VA_ARGS__);
 #define COLLECTION_PERIOD 15
 #define BAL_DYNAMIC_LIST_BUFFER_SIZE (32 * 1024)
 #define MAX_REGID_LENGTH  36
 
 extern State state;
 
+enum FLOW_CFG {
+    ONU_ID = 0,
+    FLOW_TYPE = 1,
+    SVC_PORT_ID = 2,
+    PRIORITY = 3,
+    COOKIE = 4,
+    INGRESS_INTF_TYPE= 5,
+    EGRESS_INTF_TYPE= 6,
+    INGRESS_INTF_ID = 7,
+    EGRESS_INTF_ID = 8,
+    CLASSIFIER_O_VID = 9,
+    CLASSIFIER_O_PBITS = 10,
+    CLASSIFIER_I_VID = 11,
+    CLASSIFIER_I_PBITS = 12,
+    CLASSIFIER_ETHER_TYPE = 13,
+    CLASSIFIER_IP_PROTO =14,
+    CLASSIFIER_SRC_PORT = 15,
+    CLASSIFIER_DST_PORT = 16,
+    CLASSIFIER_PKT_TAG_TYPE = 17,
+    EGRESS_QOS_TYPE = 18,
+    EGRESS_QOS_QUEUE_ID = 19,
+    EGRESS_QOS_TM_SCHED_ID = 20,
+    ACTION_CMDS_BITMASK = 21,
+    ACTION_O_VID = 22,
+    ACTION_O_PBITS = 23,
+    ACTION_I_VID = 24,
+    ACTION_I_PBITS = 25,
+    STATE = 26
+};
+
 Status Enable_(int argc, char *argv[]);
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific, uint32_t pir);
@@ -39,8 +84,7 @@
     const char *vendor_id, const char *vendor_specific);
 Status EnablePonIf_(uint32_t intf_id);
 Status DisablePonIf_(uint32_t intf_id);
-Status EnableUplinkIf_(uint32_t intf_id);
-Status DisableUplinkIf_(uint32_t intf_id);
+Status SetStateUplinkIf_(uint32_t intf_id, bool set_state);
 unsigned NumNniIf_();
 unsigned NumPonIf_();
 Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
@@ -62,6 +106,10 @@
 Status CreateTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
 Status RemoveTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues);
 uint32_t GetPortNum_(uint32_t flow_id);
+int get_status_bcm_cli_quit(void);
+uint16_t get_dev_id(void); 
+Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state);
+uint64_t get_flow_status(uint16_t flow_id, uint16_t flow_type, uint16_t data_id);
 
 void stats_collection();
 #endif
diff --git a/agent/common/main.cc b/agent/common/main.cc
index c4a0b53..49caf5a 100644
--- a/agent/common/main.cc
+++ b/agent/common/main.cc
@@ -99,6 +99,39 @@
         }
     }
 
+    ProbeDeviceCapabilities_();
+    sleep(2);
+    // Enable all PON interfaces. 
+    for (int i = 0; i < NumPonIf_(); i++) {
+        status = EnablePonIf_(i);
+        if (!status.ok()) {
+            // raise alarm to report error in enabling PON
+            pushOltOperInd(i, "pon", "down");
+        }
+        else
+            pushOltOperInd(i, "pon", "up");
+    }
+    sleep(2);
+    // Enable all NNI interfaces.
+#if 0
+    for (int i = 0; i < NumNniIf_(); i++) {
+        status = EnableUplinkIf_(i);
+        if (!status.ok()) {
+            // raise alarm to report error in enabling PON
+            pushOltOperInd(i, "nni", "down");
+        }
+        else
+            pushOltOperInd(i, "nni", "up");
+    }
+#endif
+    //only for nni-65536 mapping to intf_id 0
+    status = SetStateUplinkIf_(0, true);
+    if (!status.ok()) {
+        // raise alarm to report error in enabling NNI
+        pushOltOperInd(0, "nni", "down");
+    }
+    else
+        pushOltOperInd(0, "nni", "up");
     RunServer();
 
     return 0;
diff --git a/agent/common/server.cc b/agent/common/server.cc
index 0f2e59c..10ae4fa 100644
--- a/agent/common/server.cc
+++ b/agent/common/server.cc
@@ -30,8 +30,8 @@
 #include "state.h"
 
 #include <grpc++/grpc++.h>
-#include <openolt.grpc.pb.h>
-#include <tech_profile.grpc.pb.h>
+#include <voltha_protos/openolt.grpc.pb.h>
+#include <voltha_protos/tech_profile.grpc.pb.h>
 
 using grpc::Server;
 using grpc::ServerBuilder;
@@ -220,14 +220,14 @@
         return EnablePonIf_(request->intf_id());
     }
 
-    Status GetPonIf(
+    /*Status GetPonIf(
             ServerContext* context,
             const openolt::Interface* request,
             openolt::IntfIndication* response) override {
 
         // TODO - Return the oper status of the pon interface
         return Status::OK;
-    }
+    }*/
 
     Status DisablePonIf(
             ServerContext* context,
@@ -252,7 +252,7 @@
             const openolt::Empty* request,
             openolt::Empty* response) override {
 
-        system("shutdown -r now");
+        uint8_t ret = system("shutdown -r now");
 
         return Status::OK;
 
diff --git a/agent/mkdebian/build_asfvolt16_deb.sh b/agent/device/asfvolt16/mkdebian/build_asfvolt16_deb.sh
similarity index 100%
rename from agent/mkdebian/build_asfvolt16_deb.sh
rename to agent/device/asfvolt16/mkdebian/build_asfvolt16_deb.sh
diff --git a/agent/device/asfvolt16/mkdebian/debian/.debhelper/generated/asfvolt16/triggers b/agent/device/asfvolt16/mkdebian/debian/.debhelper/generated/asfvolt16/triggers
new file mode 100644
index 0000000..884a015
--- /dev/null
+++ b/agent/device/asfvolt16/mkdebian/debian/.debhelper/generated/asfvolt16/triggers
@@ -0,0 +1,2 @@
+# Triggers added by dh_makeshlibs
+activate-noawait ldconfig
diff --git a/agent/mkdebian/debian/asfvolt16.install b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.install
similarity index 100%
rename from agent/mkdebian/debian/asfvolt16.install
rename to agent/device/asfvolt16/mkdebian/debian/asfvolt16.install
diff --git a/agent/mkdebian/debian/asfvolt16.postinst b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
similarity index 73%
rename from agent/mkdebian/debian/asfvolt16.postinst
rename to agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
index 66bb97d..44693f2 100644
--- a/agent/mkdebian/debian/asfvolt16.postinst
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
@@ -17,19 +17,21 @@
 
 rm -rf /opt/bcm68620
 rm -rf /broadcom
-tar zxf /tmp/release_asfvolt16_V02.06.201804301043.tar.gz -C / 2>&1 > /dev/null
+tar zxf /tmp/release_asfvolt16_V3.1.1.201908010203.tar.gz -C / 2>&1 > /dev/null
 grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
 rm -f /run/bcm68620
-cp /tmp/init.d/bal_core_dist /etc/init.d
+cp /tmp/init.d/dev_mgmt_daemon /etc/init.d
 cp /tmp/init.d/openolt /etc/init.d
 cp /tmp/logrotate.d/openolt /etc/logrotate.d
-chmod +x /etc/init.d/bal_core_dist
+chmod +x /etc/init.d/dev_mgmt_daemon
 chmod +x /etc/init.d/openolt
-update-rc.d bal_core_dist defaults
+update-rc.d dev_mgmt_daemon defaults
 update-rc.d openolt defaults
 mv /tmp/openolt /broadcom
 mv /tmp/libgrpc++.so.1 /usr/local/lib
 mv /tmp/libgrpc.so.6 /usr/local/lib
-mv /broadcom/libbal_api_dist.so /usr/local/lib
+mv /tmp/libstdc++.so.6 /usr/local/lib
+mv /tmp/libbal_host_api.so /usr/local/lib
 /opt/bcm68620/svk_init.sh
-ldconfig
+[ "A`cat ~/.bashrc| grep LD_LIBRARY_PATH`" = "A" ] && echo "export LD_LIBRARY_PATH=/broadcom:\$LD_LIBRARY_PATH" >> ~/.bashrc; . ~/.bashrc
+ldconfig /broadcom
diff --git a/agent/mkdebian/debian/asfvolt16.postrm b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
similarity index 91%
rename from agent/mkdebian/debian/asfvolt16.postrm
rename to agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
index e99a65a..3f45572 100644
--- a/agent/mkdebian/debian/asfvolt16.postrm
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
@@ -21,4 +21,5 @@
 rm -rf /run/bcm68620
 rm -rf /usr/local/lib/libgrpc++.so.1
 rm -rf /usr/local/lib/libgrpc.so.6
-rm -rf /usr/local/lib/libbal_api_dist.so
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
diff --git a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.preinst b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.preinst
new file mode 100644
index 0000000..f3c0cbf
--- /dev/null
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.preinst
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# Copyright 2018-present Open Networking Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# kill CLI applications
+echo "kill running time application"
+[ -n "`pidof dev_mgmt_daemon`" ] && killall dev_mgmt_daemon
+[ -n "`pidof bcm.user`" ] && killall bcm.user
+[ -n "`pidof dev_mgmt_attach`" ] && killall dev_mgmt_attach
+[ -n "`pidof embedded_console`" ] && killall embedded_console 
+[ -n "`pidof example_user_appl`" ] && killall example_user_appl 
+[ -n "`pidof openolt`" ] && killall openolt
+rm -f /tmp/root_dev_mgmt_pid /tmp/root_dev_mgmt_init_done
+sleep 3
+# unload drivers
+echo "unload kernel drivers"
+[ -n "`lsmod | grep i2c_devs`" ] && rmmod i2c_devs && sleep 1
+[ -n "`lsmod | grep nltr`" ] &&  rmmod nltr && sleep 1
+[ -n "`lsmod | grep pcie_proxy`" ] && rmmod pcie_proxy && sleep 1
+[ -n "`lsmod | grep devmem`" ] && rmmod devmem && sleep 1
+[ -n "`lsmod | grep fld_linux`" ] && rmmod fld_linux && sleep 1
+[ -n "`lsmod | grep os_linux`" ] && rmmod os_linux && sleep 1
+[ -n "`lsmod | grep ll_pcie`" ] && rmmod ll_pcie && sleep 1
+[ -n "`lsmod | grep linux_user_bde`" ] && rmmod linux-user-bde && sleep 1
+[ -n "`lsmod | grep linux_kernel_bde`" ] && rmmod linux-kernel-bde && sleep 1
+rm -rf /dev/maple_i2c
+rm -rf /dev/bcmolt_pcie_proxy
+rm -rf /dev/linux-uk-proxy
+rm -rf /dev/linux-user-bde
+rm -rf /dev/linux-kernel-bde
+rm -rf /dev/coop_dba_example
+rm -rf /dev/coop_dba
+for i in {0..7}; do
+    [ ! -f /dev/bcmolt_devmem_sram$i ] && rm -f /dev/bcmolt_devmem_sram$i
+    [ ! -f /dev/bcmolt_devmem_ddr$i ] && rm -f /dev/bcmolt_devmem_ddr$i
+    [ ! -f /dev/bcmolt_devmem_regs$i ] && rm -f /dev/bcmolt_devmem_regs$i
+done
+
+rm -rf /opt/bcm68620
+rm -rf /run/bcm68620
+
+rm -rf  /broadcom
+
+rm -rf /usr/local/lib/libgrpc++.so.1
+rm -rf /usr/local/lib/libgrpc.so.6
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
+
diff --git a/agent/device/asfvolt16/mkdebian/debian/changelog b/agent/device/asfvolt16/mkdebian/debian/changelog
new file mode 100644
index 0000000..26396dd
--- /dev/null
+++ b/agent/device/asfvolt16/mkdebian/debian/changelog
@@ -0,0 +1,6 @@
+asfvolt16 (3.1.1.1+edgecore-V201908010203) stable; urgency=high
+
+    * Based on code from SW-BCM68620_3_1_1_1.tgz.
+    * Merged the Accton's fixed to ACCTON_BAL_3.1.1.1-V201908010203.patch.
+
+ -- Jason Huang <jasonsc_huang@edge-core.com>  Thu, 08 AUG 2019 01:02:03 +0800
diff --git a/agent/mkdebian/debian/compat b/agent/device/asfvolt16/mkdebian/debian/compat
similarity index 100%
rename from agent/mkdebian/debian/compat
rename to agent/device/asfvolt16/mkdebian/debian/compat
diff --git a/agent/mkdebian/debian/control b/agent/device/asfvolt16/mkdebian/debian/control
similarity index 86%
rename from agent/mkdebian/debian/control
rename to agent/device/asfvolt16/mkdebian/debian/control
index c68f14e..1c0e2bd 100644
--- a/agent/mkdebian/debian/control
+++ b/agent/device/asfvolt16/mkdebian/debian/control
@@ -9,5 +9,5 @@
 Architecture: amd64
 Depends: ${shlibs:Depends}
 Description: Broadcom OLT drivers,CLI
-  ported from Broadcom SDK-2.6.0.1 package
+  ported from Broadcom SDK-3.1.1.1 package
 
diff --git a/agent/mkdebian/debian/copyright b/agent/device/asfvolt16/mkdebian/debian/copyright
similarity index 100%
rename from agent/mkdebian/debian/copyright
rename to agent/device/asfvolt16/mkdebian/debian/copyright
diff --git a/agent/device/asfvolt16/mkdebian/debian/files b/agent/device/asfvolt16/mkdebian/debian/files
new file mode 100644
index 0000000..3f61427
--- /dev/null
+++ b/agent/device/asfvolt16/mkdebian/debian/files
@@ -0,0 +1 @@
+asfvolt16_3.1.1.1+edgecore-V201908010203_amd64.deb misc optional
diff --git a/agent/mkdebian/debian/logrotate.d/openolt b/agent/device/asfvolt16/mkdebian/debian/logrotate.d/openolt
similarity index 100%
rename from agent/mkdebian/debian/logrotate.d/openolt
rename to agent/device/asfvolt16/mkdebian/debian/logrotate.d/openolt
diff --git a/agent/mkdebian/debian/rules b/agent/device/asfvolt16/mkdebian/debian/rules
similarity index 92%
rename from agent/mkdebian/debian/rules
rename to agent/device/asfvolt16/mkdebian/debian/rules
index 61e1bb7..0fa5d87 100755
--- a/agent/mkdebian/debian/rules
+++ b/agent/device/asfvolt16/mkdebian/debian/rules
@@ -26,9 +26,11 @@
 
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/release_asfvolt16_V02.06.201804301043.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/release_asfvolt16_V3.1.1.201908010203.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc++.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libstdc++.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libbal_host_api.so $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
diff --git a/agent/device/asfvolt16/vendor.h b/agent/device/asfvolt16/vendor.h
index 12cc60c..6a34814 100644
--- a/agent/device/asfvolt16/vendor.h
+++ b/agent/device/asfvolt16/vendor.h
@@ -18,5 +18,7 @@
 #ifndef __VENDOR_H__
 #define __VENDOR_H__
 #define VENDOR_ID "EdgeCore"
+#define ASFVOLT16
 #define MODEL_ID  "asfvolt16"
+#define MAX_SUPPORTED_PON 16
 #endif
diff --git a/agent/mkdebian/build_asfvolt16_deb.sh b/agent/device/asgvolt64/mkdebian/build_asgvolt64_deb.sh
similarity index 100%
copy from agent/mkdebian/build_asfvolt16_deb.sh
copy to agent/device/asgvolt64/mkdebian/build_asgvolt64_deb.sh
diff --git a/agent/device/asgvolt64/mkdebian/debian/.debhelper/generated/asgvolt64/triggers b/agent/device/asgvolt64/mkdebian/debian/.debhelper/generated/asgvolt64/triggers
new file mode 100644
index 0000000..884a015
--- /dev/null
+++ b/agent/device/asgvolt64/mkdebian/debian/.debhelper/generated/asgvolt64/triggers
@@ -0,0 +1,2 @@
+# Triggers added by dh_makeshlibs
+activate-noawait ldconfig
diff --git a/agent/mkdebian/debian/asfvolt16.install b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.install
similarity index 100%
copy from agent/mkdebian/debian/asfvolt16.install
copy to agent/device/asgvolt64/mkdebian/debian/asgvolt64.install
diff --git a/agent/mkdebian/debian/asfvolt16.postinst b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
similarity index 73%
copy from agent/mkdebian/debian/asfvolt16.postinst
copy to agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
index 66bb97d..e9c752c 100644
--- a/agent/mkdebian/debian/asfvolt16.postinst
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
@@ -17,19 +17,21 @@
 
 rm -rf /opt/bcm68620
 rm -rf /broadcom
-tar zxf /tmp/release_asfvolt16_V02.06.201804301043.tar.gz -C / 2>&1 > /dev/null
+tar zxf /tmp/release_asgvolt64_V3.1.1.201908010203.tar.gz -C / 2>&1 > /dev/null
 grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
 rm -f /run/bcm68620
-cp /tmp/init.d/bal_core_dist /etc/init.d
+cp /tmp/init.d/dev_mgmt_daemon /etc/init.d
 cp /tmp/init.d/openolt /etc/init.d
 cp /tmp/logrotate.d/openolt /etc/logrotate.d
-chmod +x /etc/init.d/bal_core_dist
+chmod +x /etc/init.d/dev_mgmt_daemon
 chmod +x /etc/init.d/openolt
-update-rc.d bal_core_dist defaults
+update-rc.d dev_mgmt_daemon defaults
 update-rc.d openolt defaults
 mv /tmp/openolt /broadcom
 mv /tmp/libgrpc++.so.1 /usr/local/lib
 mv /tmp/libgrpc.so.6 /usr/local/lib
-mv /broadcom/libbal_api_dist.so /usr/local/lib
+mv /tmp/libstdc++.so.6 /usr/local/lib
+mv /tmp/libbal_host_api.so /usr/local/lib
 /opt/bcm68620/svk_init.sh
-ldconfig
+[ "A`cat ~/.bashrc| grep LD_LIBRARY_PATH`" = "A" ] && echo "export LD_LIBRARY_PATH=/broadcom:\$LD_LIBRARY_PATH" >> ~/.bashrc; . ~/.bashrc
+ldconfig /broadcom
diff --git a/agent/mkdebian/debian/asfvolt16.postrm b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
similarity index 91%
copy from agent/mkdebian/debian/asfvolt16.postrm
copy to agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
index e99a65a..3f45572 100644
--- a/agent/mkdebian/debian/asfvolt16.postrm
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
@@ -21,4 +21,5 @@
 rm -rf /run/bcm68620
 rm -rf /usr/local/lib/libgrpc++.so.1
 rm -rf /usr/local/lib/libgrpc.so.6
-rm -rf /usr/local/lib/libbal_api_dist.so
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
diff --git a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.preinst b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.preinst
new file mode 100644
index 0000000..f3c0cbf
--- /dev/null
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.preinst
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# Copyright 2018-present Open Networking Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# kill CLI applications
+echo "kill running time application"
+[ -n "`pidof dev_mgmt_daemon`" ] && killall dev_mgmt_daemon
+[ -n "`pidof bcm.user`" ] && killall bcm.user
+[ -n "`pidof dev_mgmt_attach`" ] && killall dev_mgmt_attach
+[ -n "`pidof embedded_console`" ] && killall embedded_console 
+[ -n "`pidof example_user_appl`" ] && killall example_user_appl 
+[ -n "`pidof openolt`" ] && killall openolt
+rm -f /tmp/root_dev_mgmt_pid /tmp/root_dev_mgmt_init_done
+sleep 3
+# unload drivers
+echo "unload kernel drivers"
+[ -n "`lsmod | grep i2c_devs`" ] && rmmod i2c_devs && sleep 1
+[ -n "`lsmod | grep nltr`" ] &&  rmmod nltr && sleep 1
+[ -n "`lsmod | grep pcie_proxy`" ] && rmmod pcie_proxy && sleep 1
+[ -n "`lsmod | grep devmem`" ] && rmmod devmem && sleep 1
+[ -n "`lsmod | grep fld_linux`" ] && rmmod fld_linux && sleep 1
+[ -n "`lsmod | grep os_linux`" ] && rmmod os_linux && sleep 1
+[ -n "`lsmod | grep ll_pcie`" ] && rmmod ll_pcie && sleep 1
+[ -n "`lsmod | grep linux_user_bde`" ] && rmmod linux-user-bde && sleep 1
+[ -n "`lsmod | grep linux_kernel_bde`" ] && rmmod linux-kernel-bde && sleep 1
+rm -rf /dev/maple_i2c
+rm -rf /dev/bcmolt_pcie_proxy
+rm -rf /dev/linux-uk-proxy
+rm -rf /dev/linux-user-bde
+rm -rf /dev/linux-kernel-bde
+rm -rf /dev/coop_dba_example
+rm -rf /dev/coop_dba
+for i in {0..7}; do
+    [ ! -f /dev/bcmolt_devmem_sram$i ] && rm -f /dev/bcmolt_devmem_sram$i
+    [ ! -f /dev/bcmolt_devmem_ddr$i ] && rm -f /dev/bcmolt_devmem_ddr$i
+    [ ! -f /dev/bcmolt_devmem_regs$i ] && rm -f /dev/bcmolt_devmem_regs$i
+done
+
+rm -rf /opt/bcm68620
+rm -rf /run/bcm68620
+
+rm -rf  /broadcom
+
+rm -rf /usr/local/lib/libgrpc++.so.1
+rm -rf /usr/local/lib/libgrpc.so.6
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
+
diff --git a/agent/device/asgvolt64/mkdebian/debian/changelog b/agent/device/asgvolt64/mkdebian/debian/changelog
new file mode 100644
index 0000000..de698d3
--- /dev/null
+++ b/agent/device/asgvolt64/mkdebian/debian/changelog
@@ -0,0 +1,6 @@
+asgvolt64 (3.1.1.1+edgecore-V201908010203) stable; urgency=high
+
+    * Based on code from SW-BCM68620_3_1_1_1.tgz.
+    * Merged the Accton's fixed to ACCTON_BAL_3.1.1.1-V201908010203.patch.
+
+ -- Jason Huang <jasonsc_huang@edge-core.com>  Thu, 08 AUG 2019 01:02:03 +0800
diff --git a/agent/mkdebian/debian/compat b/agent/device/asgvolt64/mkdebian/debian/compat
similarity index 100%
copy from agent/mkdebian/debian/compat
copy to agent/device/asgvolt64/mkdebian/debian/compat
diff --git a/agent/mkdebian/debian/control b/agent/device/asgvolt64/mkdebian/debian/control
similarity index 74%
copy from agent/mkdebian/debian/control
copy to agent/device/asgvolt64/mkdebian/debian/control
index c68f14e..535ebb1 100644
--- a/agent/mkdebian/debian/control
+++ b/agent/device/asgvolt64/mkdebian/debian/control
@@ -1,13 +1,13 @@
-Source: asfvolt16
+Source: asgvolt64
 Section: misc
 Priority: optional
 Maintainer: Jason Huang  <jasonsc_huang@edge-core.com>
 Build-Depends: debhelper (>= 4.0.0)
 Standards-Version: 3.6.2
 
-Package: asfvolt16
+Package: asgvolt64
 Architecture: amd64
 Depends: ${shlibs:Depends}
 Description: Broadcom OLT drivers,CLI
-  ported from Broadcom SDK-2.6.0.1 package
+  ported from Broadcom SDK-3.1.1.1 package
 
diff --git a/agent/mkdebian/debian/copyright b/agent/device/asgvolt64/mkdebian/debian/copyright
similarity index 100%
copy from agent/mkdebian/debian/copyright
copy to agent/device/asgvolt64/mkdebian/debian/copyright
diff --git a/agent/device/asgvolt64/mkdebian/debian/files b/agent/device/asgvolt64/mkdebian/debian/files
new file mode 100644
index 0000000..35eaf0c
--- /dev/null
+++ b/agent/device/asgvolt64/mkdebian/debian/files
@@ -0,0 +1 @@
+asgvolt64_3.1.1.1+edgecore-V201908010203_amd64.deb misc optional
diff --git a/agent/mkdebian/debian/logrotate.d/openolt b/agent/device/asgvolt64/mkdebian/debian/logrotate.d/openolt
similarity index 100%
copy from agent/mkdebian/debian/logrotate.d/openolt
copy to agent/device/asgvolt64/mkdebian/debian/logrotate.d/openolt
diff --git a/agent/mkdebian/debian/rules b/agent/device/asgvolt64/mkdebian/debian/rules
similarity index 92%
copy from agent/mkdebian/debian/rules
copy to agent/device/asgvolt64/mkdebian/debian/rules
index 61e1bb7..a8b6901 100755
--- a/agent/mkdebian/debian/rules
+++ b/agent/device/asgvolt64/mkdebian/debian/rules
@@ -26,9 +26,11 @@
 
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/release_asfvolt16_V02.06.201804301043.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/release_asgvolt64_V3.1.1.201908010203.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc++.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libstdc++.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libbal_host_api.so $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
diff --git a/agent/device/asgvolt64/vendor.cc b/agent/device/asgvolt64/vendor.cc
new file mode 100644
index 0000000..12aade8
--- /dev/null
+++ b/agent/device/asgvolt64/vendor.cc
@@ -0,0 +1,22 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "vendor.h"
+
+void vendor_init()
+{
+}
diff --git a/agent/device/asgvolt64/vendor.h b/agent/device/asgvolt64/vendor.h
new file mode 100644
index 0000000..a0d21c3
--- /dev/null
+++ b/agent/device/asgvolt64/vendor.h
@@ -0,0 +1,24 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __VENDOR_H__
+#define __VENDOR_H__
+#define VENDOR_ID "EdgeCore"
+#define ASGVOLT64
+#define MODEL_ID  "asgvolt64"
+#define MAX_SUPPORTED_PON 64
+#endif
diff --git a/agent/download/Makefile.onl b/agent/download/Makefile.onl
new file mode 100644
index 0000000..986d9dd
--- /dev/null
+++ b/agent/download/Makefile.onl
@@ -0,0 +1,18 @@
+# Copyright (C) 2018 Makefile
+#
+# 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.
+
+COMMIT_ID = b4af32e
+
+onl-4.14:
+	cd OpenNetworkLinux && git checkout -b $@ $(COMMIT_ID) && docker/tools/onlbuilder --non-interactive -8 -c ./build-onl.sh
diff --git a/agent/download/build-onl.sh b/agent/download/build-onl.sh
new file mode 100644
index 0000000..ae86073
--- /dev/null
+++ b/agent/download/build-onl.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Copyright (C) 2018 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.
+
+apt-cacher-ng && source setup.env && make amd64
+exit
diff --git a/agent/mkdebian/debian/asfvolt16.preinst b/agent/mkdebian/debian/asfvolt16.preinst
deleted file mode 100644
index 1237c87..0000000
--- a/agent/mkdebian/debian/asfvolt16.preinst
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-# Copyright 2018-present Open Networking Foundation
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# kill CLI applications
-echo "kill running time application"
-[ -n "`pidof bcm_user_appl`" ] && killall bcm_user_appl
-[ -n "`pidof bcm.user`" ] && killall bcm.user
-[ -n "`pidof voltha_bal_driver`" ] && killall voltha_bal_driver
-# service bal_core_dist stop
-# service openolt stop
-[ -n "`pidof bal_core_dist`" ] && killall bal_core_dist
-rm -f /var/run/bal_core_dist.pid
-[ -n "`pidof openolt`" ] && killall openolt
-rm -f /var/run/openolt.pid
-
-# unload drivers
-echo "unload kernel drivers"
-[ -n "`lsmod | grep bcm_coop_dba_linux`" ] && rmmod bcm_coop_dba_linux && sleep 1
-[ -n "`lsmod | grep bcm_dev_ctrl_linux`" ] &&  rmmod bcm_dev_ctrl_linux && sleep 1
-[ -n "`lsmod | grep i2c_devs`" ] && rmmod i2c_devs && sleep 1
-[ -n "`lsmod | grep trmux`" ] && rmmod trmux && sleep 1
-[ -n "`lsmod | grep fld`" ] && rmmod fld && sleep 1
-[ -n "`lsmod | grep os_linux`" ] && rmmod os_linux && sleep 1
-[ -n "`lsmod | grep ll_pcie`" ] && rmmod ll_pcie && sleep 1
-[ -n "`lsmod | grep linux_user_bde`" ] && rmmod linux-user-bde && sleep 1
-[ -n "`lsmod | grep linux_kernel_bde`" ] && rmmod linux-kernel-bde && sleep 1
-rm -rf /dev/maple_i2c
-rm -rf /dev/bcm_log
-rm -rf /dev/maple_dev_ctrl
-rm -rf /dev/linux-user-bde
-rm -rf /dev/linux-kernel-bde
-rm -rf /dev/coop_dba
-
-rm -rf /opt/bcm68620
-rm -rf /run/bcm68620
-
-rm -rf  /broadcom
-
-rm -rf /usr/local/lib/libgrpc++.so.1
-rm -rf /usr/local/lib/libgrpc.so.5
-rm -rf /usr/local/lib/libbal_api_dist.so
-
diff --git a/agent/mkdebian/debian/changelog b/agent/mkdebian/debian/changelog
deleted file mode 100644
index 3969177..0000000
--- a/agent/mkdebian/debian/changelog
+++ /dev/null
@@ -1,10 +0,0 @@
-asfvolt16 (2.6.0.1+edgecore-V201804301043) stable; urgency=high
-
-    * Based on code from SW-BCM68620_2_6_0_1.zip.
-    * Merged the Accton's fixed done in ACCTON_BAL_2.4.7.12-V201712061142.patch.
-    * To increase the stack size to 2M to avoid segment fault while init bcm.user code.
-    * To modify the BALAPI_OPER_TIMEOUT from 5 to 10 seconds to avoid timeout warning message.
-    * Patch file name: ACCTON_BAL_2.6.0.1-V201804301043.patch
-
- -- Jason Huang <jasonsc_huang@edge-core.com>  Thu, 31 May 2018 10:36:32 +0800
-
diff --git a/agent/mkdebian/debian/files b/agent/mkdebian/debian/files
deleted file mode 100644
index 4061fba..0000000
--- a/agent/mkdebian/debian/files
+++ /dev/null
@@ -1 +0,0 @@
-asfvolt16_2.6.0.1+edgecore-V201804301043_amd64.deb misc optional
diff --git a/agent/scripts/init.d/bal_core_dist b/agent/scripts/init.d/dev_mgmt_daemon
similarity index 67%
rename from agent/scripts/init.d/bal_core_dist
rename to agent/scripts/init.d/dev_mgmt_daemon
index 3fc9d78..9e5a5a3 100755
--- a/agent/scripts/init.d/bal_core_dist
+++ b/agent/scripts/init.d/dev_mgmt_daemon
@@ -10,12 +10,12 @@
 # Description:       Broadcom BAL core daemon
 ### END INIT INFO
 
-NAME="bal_core_dist"
+NAME="dev_mgmt_daemon"
 PATH="/broadcom:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 APPDIR="/broadcom"
-#APPBIN="/broadcom/bal_core_dist"
-APPBIN="bal_core_dist"
-APPARGS="-C :55001"
+APPBIN="dev_mgmt_daemon"
+APPARGS="-pcie -syslog"
+PID_FILE="root_dev_mgmt_pid"
 USER="root"
 GROUP="root"
 
@@ -24,9 +24,11 @@
 . /lib/lsb/init-functions
 
 start() {
-  touch /var/log/$NAME.log
+  /opt/bcm68620/svk_init.sh
+  sleep 10
   printf "Starting '$NAME'... "
-  start-stop-daemon --verbose --start --chuid "$USER:$GROUP" --background --no-close --make-pidfile --pidfile /var/run/$NAME.pid --chdir "$APPDIR" --exec "$APPBIN" -- $APPARGS < /dev/tty1 >> /var/log/$NAME.log 2>&1 || true
+  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR
+  start-stop-daemon --verbose --start --chuid "$USER:$GROUP" --background --no-close --chdir "$APPDIR" --exec "$APPBIN" -- $APPARGS 2>&1 || true
   printf "done\n"
 }
 
@@ -42,17 +44,17 @@
 
 stop() {
   printf "Stopping '$NAME'... "
-  [ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || \
-  while test -d /proc/$(cat /var/run/$NAME.pid); do
-    killtree $(cat /var/run/$NAME.pid) 15
+  [ -z `cat /tmp/$PID_FILE 2>/dev/null` ] || \
+  while test -d /proc/$(cat /tmp/$PID_FILE); do
+    killtree $(cat /tmp/$PID_FILE) 15
     sleep 0.5
   done 
-  [ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || rm /var/run/$NAME.pid
+  [ -z `cat /tmp/$PID_FILE 2>/dev/null` ] || rm /tmp/$PID_FILE
   printf "done\n"
 }
 
 status() {
-  status_of_proc -p /var/run/$NAME.pid $APPDIR/$APPBIN $NAME && exit 0 || exit $?
+  status_of_proc -p /tmp/$PID_FILE $APPDIR/$APPBIN $NAME && exit 0 || exit $?
 }
 
 case "$1" in
diff --git a/agent/scripts/init.d/openolt b/agent/scripts/init.d/openolt
index bd414c9..1db4fbb 100755
--- a/agent/scripts/init.d/openolt
+++ b/agent/scripts/init.d/openolt
@@ -15,7 +15,7 @@
 APPDIR="/broadcom"
 #APPBIN="/broadcom/openolt"
 APPBIN="openolt"
-APPARGS="-C 127.0.0.1:55001"
+APPARGS=""
 USER="root"
 GROUP="root"
 
@@ -24,9 +24,12 @@
 . /lib/lsb/init-functions
 
 start() {
-  touch /var/log/$NAME.log
   printf "Starting '$NAME'... "
-  sleep 20
+  # TODO: If openolt agent has a way to figure out progamatically
+  # if the BAL is ready, the below timer may not be needed.
+  sleep 120
+  rm -f /var/log/$NAME.log
+  touch /var/log/$NAME.log
   start-stop-daemon --verbose --start --chuid "$USER:$GROUP" --background --no-close --make-pidfile --pidfile /var/run/$NAME.pid --chdir "$APPDIR" --exec "$APPBIN" -- $APPARGS < /dev/tty1 >> /var/log/$NAME.log 2>&1 || true
   printf "done\n"
 }
@@ -49,6 +52,7 @@
     sleep 0.5
   done 
   [ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || rm /var/run/$NAME.pid
+  rm -f /var/log/$NAME.log
   printf "done\n"
 }
 
diff --git a/agent/sim/core.h b/agent/sim/core.h
index 5d95997..f656b1f 100644
--- a/agent/sim/core.h
+++ b/agent/sim/core.h
@@ -38,7 +38,7 @@
 Status DisableUplinkIf_(uint32_t intf_id);
 Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt);
 Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, uint32_t port_no, const std::string pkt);
-Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt);
+Status UplinkPacketOut_(bcmolt_flow_id flow_id, uint32_t intf_id, const std::string pkt);
 Status FlowAdd_(int32_t access_intf_id, int32_t onu_id, int32_t uni_id, uint32_t port_no,
                 uint32_t flow_id, const std::string flow_type,
                 int32_t alloc_id, int32_t network_intf_id,
diff --git a/agent/src/core.cc b/agent/src/core.cc
index 83bd99a..ef92547 100644
--- a/agent/src/core.cc
+++ b/agent/src/core.cc
@@ -20,11 +20,11 @@
 #include <string>
 
 #include "Queue.h"
-#include <iostream>
 #include <sstream>
 #include <chrono>
 #include <thread>
 #include <bitset>
+#include <inttypes.h>
 
 #include "device.h"
 #include "core.h"
@@ -36,47 +36,86 @@
 
 extern "C"
 {
-#include <bcmos_system.h>
-#include <bal_api.h>
-#include <bal_api_end.h>
+#include <bcmolt_api.h>
+#include <bcmolt_host_api.h>
+#include <bcmolt_api_model_supporting_enums.h>
+
+#include <bal_version.h>
+#include <bcmolt_api_conn_mgr.h>
+//CLI header files
+#include <bcmcli_session.h>
+#include <bcmcli.h>
+#include <bcm_api_cli.h>
+
+#include <bcmos_common.h>
+#include <bcm_config.h>
 // FIXME : dependency problem
 // #include <bcm_common_gpon.h>
 // #include <bcm_dev_log_task.h>
 }
-// These need patched into bal_model_types.h directly. But, with above extern "C", it cannot be done
-inline bcmbal_action_cmd_id& operator|=(bcmbal_action_cmd_id& a, bcmbal_action_cmd_id b) {return a = static_cast<bcmbal_action_cmd_id>(static_cast<int>(a) | static_cast<int>(b));}
-inline bcmbal_action_id& operator|=(bcmbal_action_id& a, bcmbal_action_id b) {return a = static_cast<bcmbal_action_id>(static_cast<int>(a) | static_cast<int>(b));}
-inline bcmbal_classifier_id& operator|=(bcmbal_classifier_id& a, bcmbal_classifier_id b) {return a = static_cast<bcmbal_classifier_id>(static_cast<int>(a) | static_cast<int>(b));}
-inline bcmbal_tm_sched_owner_agg_port_id& operator|=(bcmbal_tm_sched_owner_agg_port_id& a, bcmbal_tm_sched_owner_agg_port_id b) {return a = static_cast<bcmbal_tm_sched_owner_agg_port_id>(static_cast<int>(a) | static_cast<int>(b));}
-inline bcmbal_tm_sched_parent_id& operator|=(bcmbal_tm_sched_parent_id& a, bcmbal_tm_sched_parent_id b) {return a = static_cast<bcmbal_tm_sched_parent_id>(static_cast<int>(a) | static_cast<int>(b));}
-inline bcmbal_tm_shaping_id& operator|=(bcmbal_tm_shaping_id& a, bcmbal_tm_shaping_id b) {return a = static_cast<bcmbal_tm_shaping_id>(static_cast<int>(a) | static_cast<int>(b));}
+
 
 dev_log_id openolt_log_id = bcm_dev_log_id_register("OPENOLT", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
 dev_log_id omci_log_id = bcm_dev_log_id_register("OMCI", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
 
-#define MAX_SUPPORTED_INTF 16
 #define BAL_RSC_MANAGER_BASE_TM_SCHED_ID 16384
 #define MAX_TM_QUEUE_ID 8192
-#define MAX_TM_SCHED_ID 16384
+#define MAX_TM_QMP_ID 16
+#define TMQ_MAP_PROFILE_SIZE 8
+#define MAX_TM_SCHED_ID 1023
+#define MAX_SUBS_TM_SCHED_ID (MAX_SUPPORTED_PON == 16 ? MAX_TM_SCHED_ID-4-16 : MAX_TM_SCHED_ID-10-64)
 #define EAP_ETHER_TYPE 34958
+#define XGS_BANDWIDTH_GRANULARITY 16000
+#define GPON_BANDWIDTH_GRANULARITY 32000
+#define FILL_ARRAY(ARRAY,START,END,VALUE) for(int i=START;i<END;ARRAY[i++]=VALUE);
+#define COUNT_OF(array) (sizeof(array) / sizeof(array[0]))
+
+#define GET_FLOW_INTERFACE_TYPE(type) \
+       (type == BCMOLT_FLOW_INTERFACE_TYPE_PON) ? "PON" : \
+       (type == BCMOLT_FLOW_INTERFACE_TYPE_NNI) ? "NNI" : \
+       (type == BCMOLT_FLOW_INTERFACE_TYPE_HOST) ? "HOST" : "unknown"
+#define GET_PKT_TAG_TYPE(type) \
+       (type == BCMOLT_PKT_TAG_TYPE_UNTAGGED) ? "UNTAG" : \
+       (type == BCMOLT_PKT_TAG_TYPE_SINGLE_TAG) ? "SINGLE_TAG" : \
+       (type == BCMOLT_PKT_TAG_TYPE_DOUBLE_TAG) ? "DOUBLE_TAG" : "unknown"
 
 static unsigned int num_of_nni_ports = 0;
 static unsigned int num_of_pon_ports = 0;
-static std::string intf_technologies[MAX_SUPPORTED_INTF];
+static std::string intf_technologies[MAX_SUPPORTED_PON];
 static const std::string UNKNOWN_TECH("unknown");
 static const std::string MIXED_TECH("mixed");
 static std::string board_technology(UNKNOWN_TECH);
+static std::string chip_family(UNKNOWN_TECH);
 static unsigned int OPENOLT_FIELD_LEN = 200;
-static std::string firmware_version = "Openolt.2018.10.04";
+static std::string firmware_version = "Openolt.2019.07.01";
 
-const uint32_t tm_upstream_sched_id_start = 18432;
-const uint32_t tm_downstream_sched_id_start = 16384;
-//0 to 3 are default queues. Lets not use them.
-const uint32_t tm_queue_id_start = 4;
-// Upto 8 fixed Upstream. Queue id 0 to 3 are pre-created, lets not use them.
-const uint32_t us_fixed_queue_id_list[8] = {4, 5, 6, 7, 8, 9, 10, 11};
+const uint32_t tm_upstream_sched_id_start = (MAX_SUPPORTED_PON == 16 ? \
+    MAX_TM_SCHED_ID-3 : MAX_TM_SCHED_ID-9);
+const uint32_t tm_downstream_sched_id_start = (MAX_SUPPORTED_PON == 16 ? \
+    tm_upstream_sched_id_start-16 : tm_upstream_sched_id_start-64);
+
+/* Max Queue ID supported is 7 so based on priority_q configured for GEMPORTS
+in TECH PROFILE respective Queue ID from this list will be used for both
+US and DS Queues*/
+const uint32_t queue_id_list[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+
 const std::string upstream = "upstream";
 const std::string downstream = "downstream";
+bcmolt_oltid dev_id = 0;
+
+/* Current session */
+static bcmcli_session *current_session;
+static bcmcli_entry *api_parent_dir;
+bcmos_bool status_bcm_cli_quit = BCMOS_FALSE;
+bcmos_task bal_cli_thread;
+const char *bal_cli_thread_name = "bal_cli_thread";
+uint16_t flow_id_counters = 0;
+int flow_id_data[16384][2];
+
+/* QOS Type has been pre-defined as Fixed Queue but it will be updated based on number of GEMPORTS
+   associated for a given subscriber. If GEM count = 1 for a given subscriber, qos_type will be Fixed Queue
+   else Priority to Queue */
+bcmolt_egress_qos_type qos_type = BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE;
 
 State state;
 
@@ -84,23 +123,23 @@
 static std::map<uint32_t, uint32_t> flowid_to_gemport; // For mapping downstream flows into gemports
 static std::map<uint32_t, std::set<uint32_t> > port_to_flows; // For mapping logical ports to downstream flows
 
-// This represents the Key to 'queue_map' map.
-// Represents (pon_intf_id, onu_id, uni_id, gemport_id, direction)
-typedef std::tuple<uint32_t, uint32_t, uint32_t, uint32_t, std::string> queue_map_key_tuple;
-// 'queue_map' maps queue_map_key_tuple to downstream queue id present
-// on the Subscriber Scheduler
-static std::map<queue_map_key_tuple, int> queue_map;
-// This represents the Key to 'sched_map' map.
-// Represents (pon_intf_id, onu_id, uni_id, direction)
-
+/* This represents the Key to 'sched_map' map.
+ Represents (pon_intf_id, onu_id, uni_id, direction) */
 typedef std::tuple<uint32_t, uint32_t, uint32_t, std::string> sched_map_key_tuple;
-// 'sched_map' maps sched_map_key_tuple to DBA (Upstream) or
-// Subscriber (Downstream) Scheduler ID
+/* 'sched_map' maps sched_map_key_tuple to DBA (Upstream) or
+ Subscriber (Downstream) Scheduler ID */
 static std::map<sched_map_key_tuple, int> sched_map;
 
+/* This represents the Key to 'sched_qmp_id_map' map.
+Represents (sched_id, pon_intf_id, onu_id, uni_id) */
+typedef std::tuple<uint32_t, uint32_t, uint32_t, uint32_t> sched_qmp_id_map_key_tuple;
+/* 'sched_qmp_id_map' maps sched_qmp_id_map_key_tuple to TM Queue Mapping Profile ID */
+static std::map<sched_qmp_id_map_key_tuple, int> sched_qmp_id_map;
+/* 'qmp_id_to_qmp_map' maps TM Queue Mapping Profile ID to TM Queue Mapping Profile */
+static std::map<int, std::vector < uint32_t > > qmp_id_to_qmp_map;
 
-std::bitset<MAX_TM_QUEUE_ID> tm_queue_bitset;
 std::bitset<MAX_TM_SCHED_ID> tm_sched_bitset;
+std::bitset<MAX_TM_QMP_ID> tm_qmp_bitset;
 
 static bcmos_fastlock data_lock;
 
@@ -111,10 +150,16 @@
                           uint32_t port_no, uint32_t alloc_id, tech_profile::AdditionalBW additional_bw, uint32_t weight, \
                           uint32_t priority, tech_profile::SchedulingPolicy sched_policy,
                           tech_profile::TrafficShapingInfo traffic_shaping_info);
-static bcmos_errno RemoveSched(int intf_id, int onu_id, int uni_id, std::string direction);
+static bcmos_errno RemoveSched(int intf_id, int onu_id, int uni_id, int alloc_id, std::string direction);
 static bcmos_errno CreateQueue(std::string direction, uint32_t access_intf_id, uint32_t onu_id, uint32_t uni_id, \
                                uint32_t priority, uint32_t gemport_id);
 static bcmos_errno RemoveQueue(std::string direction, int intf_id, int onu_id, int uni_id, uint32_t port_no, int alloc_id);
+static bcmos_errno CreateDefaultSched(uint32_t intf_id, const std::string direction);
+static bcmos_errno CreateDefaultQueue(uint32_t intf_id, const std::string direction);
+
+uint16_t get_dev_id(void) {
+    return dev_id;
+}
 
 /**
 * Returns the default NNI (Upstream direction) or PON (Downstream direction) scheduler
@@ -134,96 +179,12 @@
         return tm_downstream_sched_id_start + intf_id;
     }
     else {
-        BCM_LOG(ERROR, openolt_log_id, "invalid direction - %s\n", direction.c_str());
+        OPENOLT_LOG(ERROR, openolt_log_id, "invalid direction - %s\n", direction.c_str());
         return 0;
     }
 }
 
 /**
-* Gets a unique tm_queue_id for a given intf_id, onu_id, uni_id, gemport_id, direction
-* The tm_queue_id is locally cached in a map, so that it can rendered when necessary.
-* VOLTHA replays whole configuration on OLT reboot, so caching locally is not a problem
-*
-* @param intf_id NNI or PON intf ID
-* @param onu_id ONU ID
-* @param uni_id UNI ID
-* @param gemport_id GEM Port ID
-* @param direction Upstream or downstream
-*
-* @return tm_queue_id
-*/
-int get_tm_queue_id(int intf_id, int onu_id, int uni_id, int gemport_id, std::string direction) {
-    queue_map_key_tuple key(intf_id, onu_id, uni_id, gemport_id, direction);
-    int queue_id = -1;
-
-    std::map<queue_map_key_tuple, int>::const_iterator it = queue_map.find(key);
-    if (it != queue_map.end()) {
-        queue_id = it->second;
-    }
-    if (queue_id != -1) {
-        return queue_id;
-    }
-
-    bcmos_fastlock_lock(&data_lock);
-    // Complexity of O(n). Is there better way that can avoid linear search?
-    for (queue_id = 0; queue_id < MAX_TM_QUEUE_ID; queue_id++) {
-        if (tm_queue_bitset[queue_id] == 0) {
-            tm_queue_bitset[queue_id] = 1;
-            break;
-        }
-    }
-    bcmos_fastlock_unlock(&data_lock, 0);
-
-    if (queue_id < MAX_TM_QUEUE_ID) {
-        bcmos_fastlock_lock(&data_lock);
-        queue_map[key] = queue_id;
-        bcmos_fastlock_unlock(&data_lock, 0);
-        return queue_id;
-    } else {
-        return -1;
-    }
-}
-
-/**
-* Update tm_queue_id for a given intf_id, onu_id, uni_id, gemport_id, direction
-*
-* @param intf_id NNI or PON intf ID
-* @param onu_id ONU ID
-* @param uni_id UNI ID
-* @param gemport_id GEM Port ID
-* @param direction Upstream or downstream
-* @param tm_queue_id tm_queue_id
-*/
-void update_tm_queue_id(int pon_intf_id, int onu_id, int uni_id, int gemport_id, std::string direction,
-                                  uint32_t queue_id) {
-    queue_map_key_tuple key(pon_intf_id, onu_id, uni_id, gemport_id, direction);
-    bcmos_fastlock_lock(&data_lock);
-    queue_map[key] = queue_id;
-    bcmos_fastlock_unlock(&data_lock, 0);
-}
-
-/**
-* Free tm_queue_id for a given intf_id, onu_id, uni_id, gemport_id, direction
-*
-* @param intf_id NNI or PON intf ID
-* @param onu_id ONU ID
-* @param uni_id UNI ID
-* @param gemport_id GEM Port ID
-* @param direction Upstream or downstream
-*/
-void free_tm_queue_id(int pon_intf_id, int onu_id, int uni_id, int gemport_id, std::string direction) {
-    queue_map_key_tuple key(pon_intf_id, onu_id, uni_id, gemport_id, direction);
-    std::map<queue_map_key_tuple, int>::const_iterator it;
-    bcmos_fastlock_lock(&data_lock);
-    it = queue_map.find(key);
-    if (it != queue_map.end()) {
-        tm_queue_bitset[it->second] = 0;
-        queue_map.erase(it);
-    }
-    bcmos_fastlock_unlock(&data_lock, 0);
-}
-
-/**
 * Gets a unique tm_sched_id for a given intf_id, onu_id, uni_id, gemport_id, direction
 * The tm_sched_id is locally cached in a map, so that it can rendered when necessary.
 * VOLTHA replays whole configuration on OLT reboot, so caching locally is not a problem
@@ -291,15 +252,248 @@
 
 bool is_tm_sched_id_present(int pon_intf_id, int onu_id, int uni_id, std::string direction) {
     sched_map_key_tuple key(pon_intf_id, onu_id, uni_id, direction);
-    return sched_map.count(key) > 0 ? true: false;
+    std::map<sched_map_key_tuple, int>::const_iterator it = sched_map.find(key);
+    if (it != sched_map.end()) {
+        return true;
+    }
+    return false;
 }
 
-bool is_tm_queue_id_present(int pon_intf_id, int onu_id, int uni_id, int gemport_id, std::string direction) {
-    queue_map_key_tuple key(pon_intf_id, onu_id, uni_id, gemport_id, direction);
-    return queue_map.count(key) > 0 ? true: false;
+/**
+* Check whether given two tm qmp profiles are equal or not
+*
+* @param tmq_map_profileA <vector> TM QUEUE MAPPING PROFILE
+* @param tmq_map_profileB <vector> TM QUEUE MAPPING PROFILE
+*
+* @return boolean, true if given tmq_map_profiles are equal else false
+*/
+
+bool check_tm_qmp_equality(std::vector<uint32_t> tmq_map_profileA, std::vector<uint32_t> tmq_map_profileB) {
+    for (uint32_t i = 0; i < TMQ_MAP_PROFILE_SIZE; i++) {
+        if (tmq_map_profileA[i] != tmq_map_profileB[i]) {
+            return false;
+        }
+    }
+    return true;
 }
 
-char* openolt_read_sysinfo(char* field_name, char* field_val)
+/**
+* Modifies given queues_pbit_map to parsable format
+* e.g: Modifes "0b00000101" to "10100000"
+*
+* @param queues_pbit_map PBIT MAP configured for each GEM in TECH PROFILE
+* @param size Queue count
+*
+* @return string queues_pbit_map
+*/
+std::string* get_valid_queues_pbit_map(std::string *queues_pbit_map, uint32_t size) {
+    for(uint32_t i=0; i < size; i++) {
+        /* Deletes 2 characters from index number 0 */
+        queues_pbit_map[i].erase(0, 2);
+        std::reverse(queues_pbit_map[i].begin(), queues_pbit_map[i].end());
+    }
+    return queues_pbit_map;
+}
+
+/**
+* Creates TM QUEUE MAPPING PROFILE for given queues_pbit_map and queues_priority_q
+*
+* @param queues_pbit_map PBIT MAP configured for each GEM in TECH PROFILE
+* @param queues_priority_q PRIORITY_Q configured for each GEM in TECH PROFILE
+* @param size Queue count
+*
+* @return <vector> TM QUEUE MAPPING PROFILE
+*/
+std::vector<uint32_t> get_tmq_map_profile(std::string *queues_pbit_map, uint32_t *queues_priority_q, uint32_t size) {
+    std::vector<uint32_t> tmq_map_profile(8,0);
+
+    for(uint32_t i=0; i < size; i++) {
+        for (uint32_t j = 0; j < queues_pbit_map[i].size(); j++) {
+            if (queues_pbit_map[i][j]=='1') {
+                tmq_map_profile.at(j) = queue_id_list[queues_priority_q[i]];
+            }
+        }
+    }
+    return tmq_map_profile;
+}
+
+/**
+* Gets corresponding tm_qmp_id for a given tmq_map_profile
+*
+* @param <vector> TM QUEUE MAPPING PROFILE
+*
+* @return tm_qmp_id
+*/
+int get_tm_qmp_id(std::vector<uint32_t> tmq_map_profile) {
+    int tm_qmp_id = -1;
+
+    std::map<int, std::vector < uint32_t > >::const_iterator it = qmp_id_to_qmp_map.begin();
+    while(it != qmp_id_to_qmp_map.end()) {
+        if(check_tm_qmp_equality(tmq_map_profile, it->second)) {
+            tm_qmp_id = it->first;
+            break;
+        }
+        it++;
+    }
+    return tm_qmp_id;
+}
+
+/**
+* Updates sched_qmp_id_map with given sched_id, pon_intf_id, onu_id, uni_id, tm_qmp_id
+*
+* @param upstream/downstream sched_id
+* @param PON intf ID
+* @param onu_id ONU ID
+* @param uni_id UNI ID
+* @param tm_qmp_id TM QUEUE MAPPING PROFILE ID
+*/
+void update_sched_qmp_id_map(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, \
+                             uint32_t uni_id, int tm_qmp_id) {
+   bcmos_fastlock_lock(&data_lock);
+   sched_qmp_id_map_key_tuple key(sched_id, pon_intf_id, onu_id, uni_id);
+   sched_qmp_id_map.insert(make_pair(key, tm_qmp_id));
+   bcmos_fastlock_unlock(&data_lock, 0);
+}
+
+/**
+* Gets corresponding tm_qmp_id for a given sched_id, pon_intf_id, onu_id, uni_id
+*
+* @param upstream/downstream sched_id
+* @param PON intf ID
+* @param onu_id ONU ID
+* @param uni_id UNI ID
+*
+* @return tm_qmp_id
+*/
+int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id) {
+    sched_qmp_id_map_key_tuple key(sched_id, pon_intf_id, onu_id, uni_id);
+    int tm_qmp_id = -1;
+
+    std::map<sched_qmp_id_map_key_tuple, int>::const_iterator it = sched_qmp_id_map.find(key);
+    if (it != sched_qmp_id_map.end()) {
+        tm_qmp_id = it->second;
+    }
+    return tm_qmp_id;
+}
+
+/**
+* Gets a unique tm_qmp_id for a given tmq_map_profile
+* The tm_qmp_id is locally cached in a map, so that it can be rendered when necessary.
+* VOLTHA replays whole configuration on OLT reboot, so caching locally is not a problem
+*
+* @param upstream/downstream sched_id
+* @param PON intf ID
+* @param onu_id ONU ID
+* @param uni_id UNI ID
+* @param <vector> TM QUEUE MAPPING PROFILE
+*
+* @return tm_qmp_id
+*/
+int get_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, uint32_t uni_id, \
+                  std::vector<uint32_t> tmq_map_profile) {
+    int tm_qmp_id;
+
+    bcmos_fastlock_lock(&data_lock);
+    /* Complexity of O(n). Is there better way that can avoid linear search? */
+    for (tm_qmp_id = 0; tm_qmp_id < MAX_TM_QMP_ID; tm_qmp_id++) {
+        if (tm_qmp_bitset[tm_qmp_id] == 0) {
+            tm_qmp_bitset[tm_qmp_id] = 1;
+            break;
+        }
+    }
+    bcmos_fastlock_unlock(&data_lock, 0);
+
+    if (tm_qmp_id < MAX_TM_QMP_ID) {
+        bcmos_fastlock_lock(&data_lock);
+        qmp_id_to_qmp_map.insert(make_pair(tm_qmp_id, tmq_map_profile));
+        bcmos_fastlock_unlock(&data_lock, 0);
+        update_sched_qmp_id_map(sched_id, pon_intf_id, onu_id, uni_id, tm_qmp_id);
+        return tm_qmp_id;
+    } else {
+        return -1;
+    }
+}
+
+/**
+* Free tm_qmp_id for a given sched_id, pon_intf_id, onu_id, uni_id
+*
+* @param upstream/downstream sched_id
+* @param PON intf ID
+* @param onu_id ONU ID
+* @param uni_id UNI ID
+* @param tm_qmp_id TM QUEUE MAPPING PROFILE ID
+*
+* @return boolean, true if no more reference for TM QMP else false
+*/
+bool free_tm_qmp_id(uint32_t sched_id,uint32_t pon_intf_id, uint32_t onu_id, \
+                    uint32_t uni_id, int tm_qmp_id) {
+    bool result;
+    sched_qmp_id_map_key_tuple key(sched_id, pon_intf_id, onu_id, uni_id);
+    std::map<sched_qmp_id_map_key_tuple, int>::const_iterator it = sched_qmp_id_map.find(key);
+    bcmos_fastlock_lock(&data_lock);
+    if (it != sched_qmp_id_map.end()) {
+        sched_qmp_id_map.erase(it);
+    }
+    bcmos_fastlock_unlock(&data_lock, 0);
+
+    uint32_t tm_qmp_ref_count = 0;
+    std::map<sched_qmp_id_map_key_tuple, int>::const_iterator it2 = sched_qmp_id_map.begin();
+    while(it2 != sched_qmp_id_map.end()) {
+        if(it2->second == tm_qmp_id) {
+            tm_qmp_ref_count++;
+        }
+        it2++;
+    }
+
+    if (tm_qmp_ref_count == 0) {
+        std::map<int, std::vector < uint32_t > >::const_iterator it3 = qmp_id_to_qmp_map.find(tm_qmp_id);
+        if (it3 != qmp_id_to_qmp_map.end()) {
+            bcmos_fastlock_lock(&data_lock);
+            tm_qmp_bitset[tm_qmp_id] = 0;
+            qmp_id_to_qmp_map.erase(it3);
+            bcmos_fastlock_unlock(&data_lock, 0);
+            OPENOLT_LOG(INFO, openolt_log_id, "Reference count for tm qmp profile id %d is : %d. So clearing it\n", \
+                        tm_qmp_id, tm_qmp_ref_count);
+            result = true;
+        }
+    } else {
+        OPENOLT_LOG(INFO, openolt_log_id, "Reference count for tm qmp profile id %d is : %d. So not clearing it\n", \
+                    tm_qmp_id, tm_qmp_ref_count);
+        result = false;
+    }
+    return result;
+}
+
+/**
+* Returns Scheduler/Queue direction as string
+*
+* @param direction as specified in tech_profile.proto
+*/
+std::string GetDirection(int direction) {
+    switch (direction)
+    {
+        case tech_profile::Direction::UPSTREAM: return upstream;
+        case tech_profile::Direction::DOWNSTREAM: return downstream;
+        default: OPENOLT_LOG(ERROR, openolt_log_id, "direction-not-supported %d\n", direction);
+                 return "direction-not-supported";
+    }
+}
+
+inline const char *get_flow_acton_command(uint32_t command) {
+    char actions[200] = { };
+    char *s_actions_ptr = actions;
+    if (command & BCMOLT_ACTION_CMD_ID_ADD_OUTER_TAG) strcat(s_actions_ptr, "ADD_OUTER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_REMOVE_OUTER_TAG) strcat(s_actions_ptr, "REMOVE_OUTER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_XLATE_OUTER_TAG) strcat(s_actions_ptr, "TRANSLATE_OUTER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_ADD_INNER_TAG) strcat(s_actions_ptr, "ADD_INNTER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_REMOVE_INNER_TAG) strcat(s_actions_ptr, "REMOVE_INNER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_XLATE_INNER_TAG) strcat(s_actions_ptr, "TRANSLATE_INNER_TAG|");
+    if (command & BCMOLT_ACTION_CMD_ID_REMARK_OUTER_PBITS) strcat(s_actions_ptr, "REMOVE_OUTER_PBITS|");
+    if (command & BCMOLT_ACTION_CMD_ID_REMARK_INNER_PBITS) strcat(s_actions_ptr, "REMAKE_INNER_PBITS|");
+    return s_actions_ptr;
+}
+
+char* openolt_read_sysinfo(const char* field_name, char* field_val)
 {
    FILE *fp;
    /* Prepare the command*/
@@ -310,13 +504,16 @@
    fp = popen(command, "r");
    if (fp == NULL) {
        /*The client has to check for a Null field value in this case*/
-       BCM_LOG(INFO, openolt_log_id,  "Failed to query the %s\n", field_name);
+       OPENOLT_LOG(INFO, openolt_log_id,  "Failed to query the %s\n", field_name);
        return field_val;
    }
 
    /*Read the field value*/
    if (fp) {
-       fread(field_val, OPENOLT_FIELD_LEN, 1, fp);
+       uint8_t ret;
+       ret = fread(field_val, OPENOLT_FIELD_LEN, 1, fp);
+       if (ret >= OPENOLT_FIELD_LEN)
+           OPENOLT_LOG(INFO, openolt_log_id,  "Read data length %u\n", ret);
        pclose(fp);
    }
    return field_val;
@@ -333,18 +530,18 @@
     char serial_number[OPENOLT_FIELD_LEN];
     memset(serial_number, '\0', OPENOLT_FIELD_LEN);
     openolt_read_sysinfo("Serial Number", serial_number);
-    BCM_LOG(INFO, openolt_log_id, "Fetched device serial number %s\n", serial_number);
+    OPENOLT_LOG(INFO, openolt_log_id, "Fetched device serial number %s\n", serial_number);
     device_info->set_device_serial_number(serial_number);
 
     char device_id[OPENOLT_FIELD_LEN];
     memset(device_id, '\0', OPENOLT_FIELD_LEN);
     openolt_read_sysinfo("MAC", device_id);
-    BCM_LOG(INFO, openolt_log_id, "Fetched device mac address %s\n", device_id);
+    OPENOLT_LOG(INFO, openolt_log_id, "Fetched device mac address %s\n", device_id);
     device_info->set_device_id(device_id);
 
     // Legacy, device-wide ranges. To be deprecated when adapter
     // is upgraded to support per-interface ranges
-    if (board_technology == "xgspon") {
+    if (board_technology == "XGS-PON") {
         device_info->set_onu_id_start(1);
         device_info->set_onu_id_end(255);
         device_info->set_alloc_id_start(MIN_ALLOC_ID_XGSPON);
@@ -354,7 +551,7 @@
         device_info->set_flow_id_start(1);
         device_info->set_flow_id_end(16383);
     }
-    else if (board_technology == "gpon") {
+    else if (board_technology == "GPON") {
         device_info->set_onu_id_start(1);
         device_info->set_onu_id_end(127);
         device_info->set_alloc_id_start(MIN_ALLOC_ID_GPON);
@@ -374,7 +571,7 @@
             ranges[intf_technology] = range;
             range->set_technology(intf_technology);
 
-            if (intf_technology == "xgspon") {
+            if (intf_technology == "XGS-PON") {
                 openolt::DeviceInfo::DeviceResourceRanges::Pool* pool;
 
                 pool = range->add_pools();
@@ -401,7 +598,7 @@
                 pool->set_start(1);
                 pool->set_end(16383);
             }
-            else if (intf_technology == "gpon") {
+            else if (intf_technology == "GPON") {
                 openolt::DeviceInfo::DeviceResourceRanges::Pool* pool;
 
                 pool = range->add_pools();
@@ -445,39 +642,199 @@
     return Status::OK;
 }
 
+Status pushOltOperInd(uint32_t intf_id, const char *type, const char *state)
+{
+    openolt::Indication ind;
+    openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
+
+    intf_oper_ind->set_type(type);
+    intf_oper_ind->set_intf_id(intf_id);
+    intf_oper_ind->set_oper_state(state);
+    ind.set_allocated_intf_oper_ind(intf_oper_ind);
+    oltIndQ.push(ind);
+    return Status::OK;
+}
+
+#define CLI_HOST_PROMPT_FORMAT "BCM.%u> "
+
+/* Build CLI prompt */
+static void openolt_cli_get_prompt_cb(bcmcli_session *session, char *buf, uint32_t max_len)
+{
+    snprintf(buf, max_len, CLI_HOST_PROMPT_FORMAT, dev_id);
+}
+
+static int _bal_apiend_cli_thread_handler(long data)
+{
+    char init_string[]="\n";
+    bcmcli_session *sess = current_session;
+    bcmos_task_parm bal_cli_task_p_dummy;
+
+    /* Switch to interactive mode if not stopped in the init script */
+    if (!bcmcli_is_stopped(sess))
+    {       
+        /* Force a CLI command prompt
+         * The string passed into the parse function
+         * must be modifiable, so a string constant like
+         * bcmcli_parse(current_session, "\n") will not
+         * work.
+         */
+        bcmcli_parse(sess, init_string);
+
+        /* Process user input until EOF or quit command */
+        bcmcli_driver(sess);
+    };      
+    OPENOLT_LOG(INFO, openolt_log_id, "BAL API End CLI terminated\n");
+
+    /* Cleanup */
+    bcmcli_session_close(current_session);
+    bcmcli_token_destroy(NULL);
+    return 0;
+}
+
+/* Init API CLI commands for the current device */
+bcmos_errno bcm_openolt_api_cli_init(bcmcli_entry *parent_dir, bcmcli_session *session)
+{
+    bcmos_errno rc;
+
+    api_parent_dir = parent_dir;
+
+    rc = bcm_api_cli_set_commands(session);
+
+#ifdef BCM_SUBSYSTEM_HOST
+    /* Subscribe for device change indication */
+    rc = rc ? rc : bcmolt_olt_sel_ind_register(_api_cli_olt_change_ind);
+#endif
+
+    return rc;
+}
+
+static bcmos_errno bcm_cli_quit(bcmcli_session *session, const bcmcli_cmd_parm parm[], uint16_t n_parms)
+{
+    bcmcli_stop(session);
+    bcmcli_session_print(session, "CLI terminated by 'Quit' command\n");
+    status_bcm_cli_quit = BCMOS_TRUE;
+
+    return BCM_ERR_OK;
+}
+
+int get_status_bcm_cli_quit(void) {
+     return status_bcm_cli_quit;
+}
+
+bcmos_errno bcmolt_apiend_cli_init() {
+    bcmos_errno ret;
+    bcmos_task_parm bal_cli_task_p = {};
+    bcmos_task_parm bal_cli_task_p_dummy;
+
+    /** before creating the task, check if it is already created by the other half of BAL i.e. Core side */
+    if (BCM_ERR_OK != bcmos_task_query(&bal_cli_thread, &bal_cli_task_p_dummy))
+    {
+        /* Create BAL CLI thread */
+        bal_cli_task_p.name = bal_cli_thread_name;
+        bal_cli_task_p.handler = _bal_apiend_cli_thread_handler;
+        bal_cli_task_p.priority = TASK_PRIORITY_CLI;
+
+        ret = bcmos_task_create(&bal_cli_thread, &bal_cli_task_p);
+        if (BCM_ERR_OK != ret)
+        {
+            bcmos_printf("Couldn't create BAL API end CLI thread\n");
+            return ret;
+        }
+    }
+}
+
 Status Enable_(int argc, char *argv[]) {
-    bcmbal_access_terminal_cfg acc_term_obj;
-    bcmbal_access_terminal_key key = { };
+    bcmos_errno err;
+    bcmolt_host_init_parms init_parms = {};
+    init_parms.transport.type = BCM_HOST_API_CONN_LOCAL;
+    unsigned int failed_enable_device_cnt = 0;
 
     if (!state.is_activated()) {
 
         vendor_init();
-        bcmbal_init(argc, argv, NULL);
+        /* Initialize host subsystem */
+        err = bcmolt_host_init(&init_parms);
+        if (BCM_ERR_OK != err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to init OLT\n");
+            return bcm_to_grpc_err(err, "Failed to init OLT");
+        }
+
+        bcmcli_session_parm mon_session_parm;
+        /* Create CLI session */
+        memset(&mon_session_parm, 0, sizeof(mon_session_parm));
+        mon_session_parm.get_prompt = openolt_cli_get_prompt_cb;
+        mon_session_parm.access_right = BCMCLI_ACCESS_ADMIN;
+        bcmos_errno rc = bcmcli_session_open(&mon_session_parm, &current_session);
+        BUG_ON(rc != BCM_ERR_OK);
+
+        /* API CLI */
+        bcm_openolt_api_cli_init(NULL, current_session);
+
+        /* Add quit command */
+        BCMCLI_MAKE_CMD_NOPARM(NULL, "quit", "Quit", bcm_cli_quit);
+
+        err = bcmolt_apiend_cli_init();
+        if (BCM_ERR_OK != err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to add apiend init\n");
+            return bcm_to_grpc_err(err, "Failed to add apiend init");
+        }
+
         bcmos_fastlock_init(&data_lock, 0);
+        OPENOLT_LOG(INFO, openolt_log_id, "Enable OLT - %s-%s\n", VENDOR_ID, MODEL_ID);
 
-        BCM_LOG(INFO, openolt_log_id, "Enable OLT - %s-%s\n", VENDOR_ID, MODEL_ID);
-
-        Status status = SubscribeIndication();
-        if (!status.ok()) {
-            BCM_LOG(ERROR, openolt_log_id, "SubscribeIndication failed - %s : %s\n",
-                grpc_status_code_to_string(status.error_code()).c_str(),
-                status.error_message().c_str());
-
-            return status;
+        if (bcmolt_api_conn_mgr_is_connected(dev_id))
+        {
+            Status status = SubscribeIndication();
+            if (!status.ok()) {
+                OPENOLT_LOG(ERROR, openolt_log_id, "SubscribeIndication failed - %s : %s\n",
+                    grpc_status_code_to_string(status.error_code()).c_str(),
+                    status.error_message().c_str());
+                return status;
+            }
+            bcmos_errno err;
+            bcmolt_odid dev;
+            OPENOLT_LOG(INFO, openolt_log_id, "Enabling PON %d Devices ... \n", BCM_MAX_DEVS_PER_LINE_CARD);
+            for (dev = 0; dev < BCM_MAX_DEVS_PER_LINE_CARD; dev++) {
+                bcmolt_device_cfg dev_cfg = { }; 
+                bcmolt_device_key dev_key = { };
+                dev_key.device_id = dev;
+                BCMOLT_CFG_INIT(&dev_cfg, device, dev_key);
+                BCMOLT_MSG_FIELD_GET(&dev_cfg, system_mode);
+                err = bcmolt_cfg_get(dev_id, &dev_cfg.hdr);
+                if (err == BCM_ERR_NOT_CONNECTED) { 
+                    bcmolt_device_key key = {.device_id = dev};
+                    bcmolt_device_connect oper;
+                    BCMOLT_OPER_INIT(&oper, device, connect, key);
+                    if (MODEL_ID == "asfvolt16") {
+                        BCMOLT_MSG_FIELD_SET(&oper, inni_config.mode, BCMOLT_INNI_MODE_ALL_10_G_XFI);
+                        BCMOLT_MSG_FIELD_SET (&oper, system_mode, BCMOLT_SYSTEM_MODE_XGS__2_X);
+                    } else if (MODEL_ID == "asgvolt64") {
+                        BCMOLT_MSG_FIELD_SET(&oper, inni_config.mode, BCMOLT_INNI_MODE_ALL_10_G_XFI);
+                        BCMOLT_MSG_FIELD_SET(&oper, inni_config.mux, BCMOLT_INNI_MUX_FOUR_TO_ONE);
+                        BCMOLT_MSG_FIELD_SET (&oper, system_mode, BCMOLT_SYSTEM_MODE_GPON__16_X);
+                    }
+                    err = bcmolt_oper_submit(dev_id, &oper.hdr);
+                    if (err) {
+                        failed_enable_device_cnt ++;
+                        OPENOLT_LOG(ERROR, openolt_log_id, "Enable PON device %d failed, err %d\n", dev, err);
+                        if (failed_enable_device_cnt == BCM_MAX_DEVS_PER_LINE_CARD) {
+                            OPENOLT_LOG(ERROR, openolt_log_id, "failed to enable all the pon ports\n");
+                            return Status(grpc::StatusCode::INTERNAL, "Failed to activate all PON ports");
+                        }
+                    }
+                    bcmos_usleep(200000);
+                }
+                else {
+                    OPENOLT_LOG(WARNING, openolt_log_id, "PON deivce %d already connected\n", dev);
+                    state.activate();
+                }
+            }
+            init_stats();
         }
-
-        key.access_term_id = DEFAULT_ATERM_ID;
-        BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
-        BCMBAL_CFG_PROP_SET(&acc_term_obj, access_terminal, admin_state, BCMBAL_STATE_UP);
-        bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
-        if (err) {
-            BCM_LOG(ERROR, openolt_log_id, "Failed to enable OLT\n");
-            return bcm_to_grpc_err(err, "Failed to enable OLT");
-        }
-
-        init_stats();
     }
 
+    /* Start CLI */
+    OPENOLT_LOG(INFO, def_log_id, "Starting CLI\n");
     //If already enabled, generate an extra indication ????
     return Status::OK;
 }
@@ -502,168 +859,457 @@
     //This fails with Operation Not Supported, bug ???
 
     //TEMPORARY WORK AROUND
-    Status status = DisableUplinkIf_(nni_intf_id);
+    Status status = SetStateUplinkIf_(nni_intf_id, false);
     if (status.ok()) {
         state.deactivate();
-        openolt::Indication ind;
-        openolt::OltIndication* olt_ind = new openolt::OltIndication;
-        olt_ind->set_oper_state("down");
-        ind.set_allocated_olt_ind(olt_ind);
-        BCM_LOG(INFO, openolt_log_id, "Disable OLT, add an extra indication\n");
-        oltIndQ.push(ind);
+        OPENOLT_LOG(INFO, openolt_log_id, "Disable OLT, add an extra indication\n");
+        pushOltOperInd(nni_intf_id, "nni", "up");
     }
     return status;
 
 }
 
 Status Reenable_() {
-    Status status = EnableUplinkIf_(0);
+    Status status = SetStateUplinkIf_(0, true);
     if (status.ok()) {
         state.activate();
-        openolt::Indication ind;
-        openolt::OltIndication* olt_ind = new openolt::OltIndication;
-        olt_ind->set_oper_state("up");
-        ind.set_allocated_olt_ind(olt_ind);
-        BCM_LOG(INFO, openolt_log_id, "Reenable OLT, add an extra indication\n");
-        oltIndQ.push(ind);
+        OPENOLT_LOG(INFO, openolt_log_id, "Reenable OLT, add an extra indication\n");
+        pushOltOperInd(0, "nni", "up");
     }
     return status;
 }
 
-Status EnablePonIf_(uint32_t intf_id) {
-    bcmbal_interface_cfg interface_obj;
-    bcmbal_interface_key interface_key;
+bcmos_errno get_pon_interface_status(bcmolt_interface pon_ni, bcmolt_interface_state *state) {
+    bcmos_errno err;
+    bcmolt_pon_interface_key pon_key;
+    bcmolt_pon_interface_cfg pon_cfg;
+    pon_key.pon_ni = pon_ni;
 
-    interface_key.intf_id = intf_id;
-    interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
-
-    BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
-
-    BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
-    bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-    if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
-        BCM_LOG(DEBUG, openolt_log_id, "PON interface: %d already enabled\n", intf_id);
-        return Status::OK;
-    }
-
-    BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
-
-    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to enable PON interface: %d\n", intf_id);
-        return bcm_to_grpc_err(err, "Failed to enable PON interface");
-    }
-
-    return Status::OK;
+    BCMOLT_CFG_INIT(&pon_cfg, pon_interface, pon_key);
+    BCMOLT_FIELD_SET_PRESENT(&pon_cfg.data, pon_interface_cfg_data, state);
+    BCMOLT_FIELD_SET_PRESENT(&pon_cfg.data, pon_interface_cfg_data, itu);
+    err = bcmolt_cfg_get(dev_id, &pon_cfg.hdr);
+    *state = pon_cfg.data.state;
+    return err;
 }
 
-Status DisableUplinkIf_(uint32_t intf_id) {
-    bcmbal_interface_cfg interface_obj;
-    bcmbal_interface_key interface_key;
+inline uint64_t get_flow_status(uint16_t flow_id, uint16_t flow_type, uint16_t data_id) {
+    bcmos_errno err;
+    bcmolt_flow_key flow_key;
+    bcmolt_flow_cfg flow_cfg;
 
-    interface_key.intf_id = intf_id;
-    interface_key.intf_type = BCMBAL_INTF_TYPE_NNI;
+    flow_key.flow_id = flow_id;
+    flow_key.flow_type = (bcmolt_flow_type)flow_type;
 
-    BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
-    BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_DOWN);
+    BCMOLT_CFG_INIT(&flow_cfg, flow, flow_key);
 
-    bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to disable Uplink interface: %d\n", intf_id);
-        return bcm_to_grpc_err(err, "Failed to disable Uplink interface");
+    switch (data_id) {
+        case ONU_ID: //onu_id
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, onu_id);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get onu_id\n");
+                return err;
+            }
+            return flow_cfg.data.onu_id;
+        case FLOW_TYPE: 
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get flow_type\n");
+                return err;
+            }
+            return flow_cfg.key.flow_type; 
+        case SVC_PORT_ID: //svc_port_id
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, svc_port_id);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get svc_port_id\n");
+                return err;
+            }
+            return flow_cfg.data.svc_port_id;
+        case PRIORITY:  
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, priority);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get priority\n");
+                return err;
+            }
+            return flow_cfg.data.priority;
+        case COOKIE: //cookie 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, cookie);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get cookie\n");
+                return err;
+            }
+            return flow_cfg.data.cookie;
+        case INGRESS_INTF_TYPE: //ingress intf_type
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, ingress_intf);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get ingress intf_type\n");
+                return err;
+            }
+            return flow_cfg.data.ingress_intf.intf_type;
+        case EGRESS_INTF_TYPE: //egress intf_type
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, egress_intf);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get egress intf_type\n");
+                return err;
+            }
+            return flow_cfg.data.egress_intf.intf_type;
+        case INGRESS_INTF_ID: //ingress intf_id
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, ingress_intf);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get ingress intf_id\n");
+                return err;
+            }
+            return flow_cfg.data.ingress_intf.intf_id;
+        case EGRESS_INTF_ID: //egress intf_id
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, egress_intf);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get egress intf_id\n");
+                return err;
+            }
+            return flow_cfg.data.egress_intf.intf_id;
+        case CLASSIFIER_O_VID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier o_vid\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.o_vid;
+        case CLASSIFIER_O_PBITS:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier o_pbits\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.o_pbits;
+        case CLASSIFIER_I_VID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier i_vid\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.i_vid;
+        case CLASSIFIER_I_PBITS: 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier i_pbits\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.i_pbits;
+        case CLASSIFIER_ETHER_TYPE:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier ether_type\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.ether_type;
+        case CLASSIFIER_IP_PROTO: 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier ip_proto\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.ip_proto;
+        case CLASSIFIER_SRC_PORT:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier src_port\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.src_port;
+        case CLASSIFIER_DST_PORT: 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier dst_port\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.dst_port;
+        case CLASSIFIER_PKT_TAG_TYPE: 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, classifier);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get classifier pkt_tag_type\n");
+                return err;
+            }
+            return flow_cfg.data.classifier.pkt_tag_type;
+        case EGRESS_QOS_TYPE:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, egress_qos);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get egress_qos type\n");
+                return err;
+            }
+            return flow_cfg.data.egress_qos.type;
+        case EGRESS_QOS_QUEUE_ID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, egress_qos);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get egress_qos queue_id\n");
+                return err;
+            }
+            switch (flow_cfg.data.egress_qos.type) {
+                case BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE:
+                    return flow_cfg.data.egress_qos.u.fixed_queue.queue_id;
+                case BCMOLT_EGRESS_QOS_TYPE_TC_TO_QUEUE:
+                    return flow_cfg.data.egress_qos.u.tc_to_queue.tc_to_queue_id;
+                case BCMOLT_EGRESS_QOS_TYPE_PBIT_TO_TC:
+                    return flow_cfg.data.egress_qos.u.pbit_to_tc.tc_to_queue_id;
+                case BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE:
+                    return flow_cfg.data.egress_qos.u.priority_to_queue.tm_q_set_id;
+                case BCMOLT_EGRESS_QOS_TYPE_NONE:
+                default:
+                    return -1;
+            }
+        case EGRESS_QOS_TM_SCHED_ID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, egress_qos);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get egress_qos tm_sched_id\n");
+                return err;
+            }
+            return flow_cfg.data.egress_qos.tm_sched.id;
+        case ACTION_CMDS_BITMASK:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, action);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get action cmds_bitmask\n");
+                return err;
+            }
+            return flow_cfg.data.action.cmds_bitmask;
+        case ACTION_O_VID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, action);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get action o_vid\n");
+                return err;
+            }
+            return flow_cfg.data.action.o_vid;
+        case ACTION_O_PBITS: 
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, action);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get action o_pbits\n");
+                return err;
+            }
+            return flow_cfg.data.action.o_pbits;
+        case ACTION_I_VID:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, action);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get action i_vid\n");
+                return err;
+            }
+            return flow_cfg.data.action.i_vid;
+        case ACTION_I_PBITS:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, action);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get action i_pbits\n");
+                return err;
+            }
+            return flow_cfg.data.action.i_pbits;
+        case STATE:
+            BCMOLT_FIELD_SET_PRESENT(&flow_cfg.data, flow_cfg_data, state);
+            err = bcmolt_cfg_get(dev_id, &flow_cfg.hdr);
+            if (err) {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to get state\n");
+                return err;
+            }
+            return flow_cfg.data.state;
+        default:
+            return BCM_ERR_INTERNAL;
+    }
+
+    return err;
+}
+
+Status EnablePonIf_(uint32_t intf_id) {
+    bcmos_errno err = BCM_ERR_OK; 
+    bcmolt_pon_interface_cfg interface_obj;
+    bcmolt_pon_interface_key intf_key = {.pon_ni = (bcmolt_interface)intf_id};
+    bcmolt_pon_interface_set_pon_interface_state pon_interface_set_state;
+    bcmolt_interface_state state;
+
+    err = get_pon_interface_status((bcmolt_interface)intf_id, &state); 
+    if (err == BCM_ERR_OK) {
+        if (state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) {
+            OPENOLT_LOG(INFO, openolt_log_id, "PON interface: %d already enabled\n", intf_id);
+            return Status::OK;
+        }
+    } 
+    BCMOLT_CFG_INIT(&interface_obj, pon_interface, intf_key);
+    BCMOLT_OPER_INIT(&pon_interface_set_state, pon_interface, set_pon_interface_state, intf_key);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, discovery.control, BCMOLT_CONTROL_STATE_ENABLE);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, discovery.interval, 5000);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, discovery.onu_post_discovery_mode,
+        BCMOLT_ONU_POST_DISCOVERY_MODE_ACTIVATE);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.los, true);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.onu_alarms, true);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.tiwi, true);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.ack_timeout, true);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.sfi, true);
+    BCMOLT_MSG_FIELD_SET(&interface_obj, itu.automatic_onu_deactivation.loki, true);
+    BCMOLT_FIELD_SET(&pon_interface_set_state.data, pon_interface_set_pon_interface_state_data,
+        operation, BCMOLT_INTERFACE_OPERATION_ACTIVE_WORKING);
+
+    err = bcmolt_cfg_set(dev_id, &interface_obj.hdr);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to enable discovery onu, PON interface %d, err %d\n", intf_id, err);
+        return bcm_to_grpc_err(err, "Failed to enable discovery onu");
+    }
+    err = bcmolt_oper_submit(dev_id, &pon_interface_set_state.hdr);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to enable PON interface: %d\n", intf_id);
+        return bcm_to_grpc_err(err, "Failed to enable PON interface");
+    }
+    else {
+        OPENOLT_LOG(INFO, openolt_log_id, "Successfully enabled PON interface: %d\n", intf_id);
+        OPENOLT_LOG(INFO, openolt_log_id, "Initializing tm sched creation for PON interface: %d\n", intf_id);
+        CreateDefaultSched(intf_id, downstream);
+        CreateDefaultQueue(intf_id, downstream);
     }
 
     return Status::OK;
 }
 
 Status ProbeDeviceCapabilities_() {
-    bcmbal_access_terminal_cfg acc_term_obj;
-    bcmbal_access_terminal_key key = { };
+    bcmos_errno err;
+    bcmolt_device_cfg dev_cfg = { }; 
+    bcmolt_device_key dev_key = { };
+    bcmolt_olt_cfg olt_cfg = { };
+    bcmolt_olt_key olt_key = { };
+    bcmolt_topology_map topo_map[BCM_MAX_PONS_PER_OLT] = { };
+    bcmolt_topology topo = { };
 
-    key.access_term_id = DEFAULT_ATERM_ID;
-    BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
-    BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, admin_state);
-    BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, oper_status);
-    BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, topology);
-    BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, sw_version);
-    BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, conn_id);
-    bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to query OLT\n");
-        return bcm_to_grpc_err(err, "Failed to query OLT");
+    topo.topology_maps.len = BCM_MAX_PONS_PER_OLT;
+    topo.topology_maps.arr = &topo_map[0];
+    BCMOLT_CFG_INIT(&olt_cfg, olt, olt_key);
+    BCMOLT_MSG_FIELD_GET(&olt_cfg, bal_state);
+    BCMOLT_FIELD_SET_PRESENT(&olt_cfg.data, olt_cfg_data, topology);
+    BCMOLT_CFG_LIST_BUF_SET(&olt_cfg, olt, topo.topology_maps.arr, 
+        sizeof(bcmolt_topology_map) * topo.topology_maps.len);
+    err = bcmolt_cfg_get(dev_id, &olt_cfg.hdr);
+    if (err) { 
+        OPENOLT_LOG(ERROR, openolt_log_id, "cfg: Failed to query OLT\n");
+        return bcm_to_grpc_err(err, "cfg: Failed to query OLT");
     }
 
-    BCM_LOG(INFO, openolt_log_id, "OLT capabilitites, admin_state: %s oper_state: %s\n", 
-            acc_term_obj.data.admin_state == BCMBAL_STATE_UP ? "up" : "down",
-            acc_term_obj.data.oper_status == BCMBAL_STATUS_UP ? "up" : "down");
+    num_of_nni_ports = olt_cfg.data.topology.num_switch_ports;
+    num_of_pon_ports = olt_cfg.data.topology.topology_maps.len;
 
-    std::string bal_version;
-    bal_version += std::to_string(acc_term_obj.data.sw_version.major_rev)
-                + "." + std::to_string(acc_term_obj.data.sw_version.minor_rev)
-                + "." + std::to_string(acc_term_obj.data.sw_version.release_rev);
-    firmware_version = "BAL." + bal_version + "__" + firmware_version;
+    OPENOLT_LOG(INFO, openolt_log_id, "OLT capabilitites, oper_state: %s\n", 
+            olt_cfg.data.bal_state == BCMOLT_BAL_STATE_BAL_AND_SWITCH_READY 
+            ? "up" : "down");
 
-    BCM_LOG(INFO, openolt_log_id, "--------------- version %s object model: %d\n", bal_version.c_str(),
-            acc_term_obj.data.sw_version.om_version);
+    OPENOLT_LOG(INFO, openolt_log_id, "topology nni: %d pon: %d dev: %d\n",
+            num_of_nni_ports,
+            num_of_pon_ports,
+            BCM_MAX_DEVS_PER_LINE_CARD); 
 
-    BCM_LOG(INFO, openolt_log_id, "--------------- topology nni:%d pon:%d dev:%d ppd:%d family: %d:%d\n",
-            acc_term_obj.data.topology.num_of_nni_ports,
-            acc_term_obj.data.topology.num_of_pon_ports,
-            acc_term_obj.data.topology.num_of_mac_devs,
-            acc_term_obj.data.topology.num_of_pons_per_mac_dev,
-            acc_term_obj.data.topology.pon_family,
-            acc_term_obj.data.topology.pon_sub_family
-            );
+    for (int devid = 0; devid < BCM_MAX_DEVS_PER_LINE_CARD; devid++) {
+        dev_key.device_id = devid;
+        BCMOLT_CFG_INIT(&dev_cfg, device, dev_key);
+        BCMOLT_MSG_FIELD_GET(&dev_cfg, firmware_sw_version);
+        BCMOLT_MSG_FIELD_GET(&dev_cfg, chip_family);
+        BCMOLT_MSG_FIELD_GET(&dev_cfg, system_mode);
+        err = bcmolt_cfg_get(dev_id, &dev_cfg.hdr);
+        if (err) { 
+            OPENOLT_LOG(ERROR, openolt_log_id, "device: Failed to query OLT\n");
+            return bcm_to_grpc_err(err, "device: Failed to query OLT");
+        }
 
-    switch(acc_term_obj.data.topology.pon_sub_family)
-    {
-    case BCMBAL_PON_SUB_FAMILY_GPON:  board_technology = "gpon"; break;
-    case BCMBAL_PON_SUB_FAMILY_XGS:   board_technology = "xgspon"; break;
+        std::string bal_version;
+        bal_version += std::to_string(dev_cfg.data.firmware_sw_version.major)
+                    + "." + std::to_string(dev_cfg.data.firmware_sw_version.minor)
+                    + "." + std::to_string(dev_cfg.data.firmware_sw_version.revision);
+        firmware_version = "BAL." + bal_version + "__" + firmware_version;
+
+        switch(dev_cfg.data.system_mode) {
+            case 10: board_technology = "GPON"; FILL_ARRAY(intf_technologies,devid*4,(devid+1)*4,"GPON"); break;
+            case 11: board_technology = "GPON"; FILL_ARRAY(intf_technologies,devid*8,(devid+1)*8,"GPON"); break;
+            case 12: board_technology = "GPON"; FILL_ARRAY(intf_technologies,devid*16,(devid+1)*16,"GPON"); break;
+            case 13: board_technology = "XGPON"; FILL_ARRAY(intf_technologies,devid*2,(devid+1)*2,"XGPON"); break;
+            case 14: board_technology = "XGPON"; FILL_ARRAY(intf_technologies,devid*4,(devid+1)*4,"XGPON"); break;
+            case 15: board_technology = "XGPON"; FILL_ARRAY(intf_technologies,devid*8,(devid+1)*8,"XGPON"); break;
+            case 16: board_technology = "XGPON"; FILL_ARRAY(intf_technologies,devid*16,(devid+1)*16,"XGPON"); break;
+            case 18: board_technology = "XGS-PON"; FILL_ARRAY(intf_technologies,devid*2,(devid+1)*2,"XGS-PON"); break;
+            case 19: board_technology = "XGS-PON"; FILL_ARRAY(intf_technologies,devid*16,(devid+1)*16,"XGS-PON"); break;
+            case 20: board_technology = MIXED_TECH; FILL_ARRAY(intf_technologies,devid*2,(devid+1)*2,MIXED_TECH); break;
+        }
+
+        switch(dev_cfg.data.chip_family) {
+            case BCMOLT_CHIP_FAMILY_CHIP_FAMILY_6862_X_: chip_family = "Maple"; break;
+            case BCMOLT_CHIP_FAMILY_CHIP_FAMILY_6865_X_: chip_family = "Aspen"; break;
+        }
+
+        OPENOLT_LOG(INFO, openolt_log_id, "device %d, pon: %d, version %s object model: %d, family: %s, board_technology: %s\n",
+            devid, BCM_MAX_PONS_PER_DEV, bal_version.c_str(), BAL_API_VERSION, chip_family.c_str(), board_technology.c_str());
+
+        bcmos_usleep(500000);
     }
 
-    num_of_nni_ports = acc_term_obj.data.topology.num_of_nni_ports;
-    num_of_pon_ports = acc_term_obj.data.topology.num_of_pon_ports;
-
-    BCM_LOG(INFO, openolt_log_id, "PON num_intfs: %d global board_technology: %s\n", num_of_pon_ports, board_technology.c_str());
-
     return Status::OK;
 }
-
+#if 0
 Status ProbePonIfTechnology_() {
     // Probe maximum extent possible as configured into BAL driver to determine
     // which are active in the current BAL topology. And for those
     // that are active, determine each port's access technology, i.e. "gpon" or "xgspon".
     for (uint32_t intf_id = 0; intf_id < num_of_pon_ports; ++intf_id) {
-        bcmbal_interface_cfg interface_obj;
-        bcmbal_interface_key interface_key;
+        bcmolt_pon_interface_cfg interface_obj;
+        bcmolt_pon_interface_key interface_key;
 
-        interface_key.intf_id = intf_id;
-        interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
+        interface_key.pon_ni = intf_id;
+        BCMOLT_CFG_INIT(&interface_obj, pon_interface, interface_key);
+        if (board_technology == "XGS-PON") 
+            BCMOLT_MSG_FIELD_GET(&interface_obj, xgs_ngpon2_trx);
+        else if (board_technology == "GPON")
+            BCMOLT_MSG_FIELD_GET(&interface_obj, gpon_trx);
 
-        BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
-        BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
-        BCMBAL_CFG_PROP_GET(&interface_obj, interface, transceiver_type);
-
-        bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+        bcmos_errno err = bcmolt_cfg_get(dev_id, &interface_obj.hdr);
         if (err != BCM_ERR_OK) {
             intf_technologies[intf_id] = UNKNOWN_TECH;
-            if(err != BCM_ERR_RANGE) BCM_LOG(ERROR, openolt_log_id, "Failed to get PON config: %d\n", intf_id);
+            if(err != BCM_ERR_RANGE) OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get PON config: %d err %d\n", intf_id, err);
         }
         else {
-            switch(interface_obj.data.transceiver_type) {
-            case BCMBAL_TRX_TYPE_GPON_SPS_43_48:
-            case BCMBAL_TRX_TYPE_GPON_SPS_SOG_4321:
-            case BCMBAL_TRX_TYPE_GPON_LTE_3680_M:
-            case BCMBAL_TRX_TYPE_GPON_SOURCE_PHOTONICS:
-            case BCMBAL_TRX_TYPE_GPON_LTE_3680_P:
-                intf_technologies[intf_id] = "gpon";
-                break;
-            default:
-                intf_technologies[intf_id] = "xgspon";
-                break;
+            if (board_technology == "XGS-PON") {
+                switch(interface_obj.data.xgpon_trx.transceiver_type) {
+                    case BCMOLT_XGPON_TRX_TYPE_LTH_7222_PC:
+                    case BCMOLT_XGPON_TRX_TYPE_WTD_RTXM266_702: 
+                    case BCMOLT_XGPON_TRX_TYPE_LTH_7222_BC_PLUS: 
+                    case BCMOLT_XGPON_TRX_TYPE_LTH_7226_PC:
+                    case BCMOLT_XGPON_TRX_TYPE_LTH_5302_PC: 
+                    case BCMOLT_XGPON_TRX_TYPE_LTH_7226_A_PC_PLUS: 
+                    case BCMOLT_XGPON_TRX_TYPE_D272RR_SSCB_DM: 
+                        intf_technologies[intf_id] = "XGS-PON";
+                        break;
+                }
+            } else if (board_technology == "GPON") {
+                switch(interface_obj.data.gpon_trx.transceiver_type) {
+                    case BCMOLT_TRX_TYPE_SPS_43_48_H_HP_CDE_SD_2013: 
+                    case BCMOLT_TRX_TYPE_LTE_3680_M:
+                    case BCMOLT_TRX_TYPE_SOURCE_PHOTONICS:
+                    case BCMOLT_TRX_TYPE_LTE_3680_P_TYPE_C_PLUS:
+                    case BCMOLT_TRX_TYPE_LTE_3680_P_BC: 
+                        intf_technologies[intf_id] = "GPON";
+                        break;
+                }
             }
-            BCM_LOG(INFO, openolt_log_id, "PON intf_id: %d intf_technologies: %d:%s\n", intf_id,
-                    interface_obj.data.transceiver_type, intf_technologies[intf_id].c_str());
 
             if (board_technology != UNKNOWN_TECH) {
                 board_technology = intf_technologies[intf_id];
@@ -673,53 +1319,81 @@
 
         }
     }
-
     return Status::OK;
 }
-
+#endif
 unsigned NumNniIf_() {return num_of_nni_ports;}
 unsigned NumPonIf_() {return num_of_pon_ports;}
 
-Status EnableUplinkIf_(uint32_t intf_id) {
-    bcmbal_interface_cfg interface_obj;
-    bcmbal_interface_key interface_key;
+bcmos_errno get_nni_interface_status(bcmolt_interface id, bcmolt_interface_state *state) {
+    bcmos_errno err;
+    bcmolt_nni_interface_key nni_key;
+    bcmolt_nni_interface_cfg nni_cfg;
+    nni_key.id = id;
 
-    interface_key.intf_id = intf_id;
-    interface_key.intf_type = BCMBAL_INTF_TYPE_NNI;
+    BCMOLT_CFG_INIT(&nni_cfg, nni_interface, nni_key);
+    BCMOLT_FIELD_SET_PRESENT(&nni_cfg.data, nni_interface_cfg_data, state);
+    err = bcmolt_cfg_get(dev_id, &nni_cfg.hdr);
+    *state = nni_cfg.data.state;
+    return err;
+}
 
-    BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
+Status SetStateUplinkIf_(uint32_t intf_id, bool set_state) {
+    bcmos_errno err = BCM_ERR_OK; 
+    bcmolt_nni_interface_key intf_key = {.id = (bcmolt_interface)intf_id};
+    bcmolt_nni_interface_set_nni_state nni_interface_set_state;
+    bcmolt_interface_state state;
 
-    BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
-    bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-    if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
-        BCM_LOG(DEBUG, openolt_log_id, "Uplink interface: %d already enabled\n", intf_id);
-        return Status::OK;
+    err = get_nni_interface_status((bcmolt_interface)intf_id, &state); 
+    if (err == BCM_ERR_OK) {
+        if (set_state && state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) {
+            OPENOLT_LOG(INFO, openolt_log_id, "NNI interface: %d already enabled\n", intf_id);
+            OPENOLT_LOG(INFO, openolt_log_id, "Initializing tm sched creation for NNI interface: %d\n", intf_id);
+            CreateDefaultSched(intf_id, upstream);
+            CreateDefaultQueue(intf_id, upstream);
+            return Status::OK;
+        } else if (!set_state && state == BCMOLT_INTERFACE_STATE_INACTIVE) {
+            OPENOLT_LOG(INFO, openolt_log_id, "NNI interface: %d already disabled\n", intf_id);
+            return Status::OK;
+        }
     }
 
-    BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
-
-    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to enable Uplink interface: %d\n", intf_id);
-        return bcm_to_grpc_err(err, "Failed to enable Uplink interface");
+    BCMOLT_OPER_INIT(&nni_interface_set_state, nni_interface, set_nni_state, intf_key);
+    if (set_state) {
+        BCMOLT_FIELD_SET(&nni_interface_set_state.data, nni_interface_set_nni_state_data,
+            nni_state, BCMOLT_INTERFACE_OPERATION_ACTIVE_WORKING);
+    } else {
+        BCMOLT_FIELD_SET(&nni_interface_set_state.data, nni_interface_set_nni_state_data,
+            nni_state, BCMOLT_INTERFACE_OPERATION_INACTIVE);
+    }
+    err = bcmolt_oper_submit(dev_id, &nni_interface_set_state.hdr);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to %s NNI interface: %d, err %d\n",
+            (set_state)?"enable":"disable", intf_id, err);
+        return bcm_to_grpc_err(err, "Failed to enable NNI interface");
+    }
+    else {
+        OPENOLT_LOG(INFO, openolt_log_id, "Successfully %s NNI interface: %d\n", (set_state)?"enable":"disable", intf_id);
+        if (set_state) {
+            OPENOLT_LOG(INFO, openolt_log_id, "Initializing tm sched creation for NNI interface: %d\n", intf_id);
+            CreateDefaultSched(intf_id, upstream);
+            CreateDefaultQueue(intf_id, upstream);
+        }
     }
 
     return Status::OK;
 }
 
 Status DisablePonIf_(uint32_t intf_id) {
-    bcmbal_interface_cfg interface_obj;
-    bcmbal_interface_key interface_key;
+    bcmolt_pon_interface_cfg interface_obj;
+    bcmolt_pon_interface_key interface_key;
 
-    interface_key.intf_id = intf_id;
-    interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
-
-    BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
-    BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_DOWN);
-
-    bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    interface_key.pon_ni = intf_id;
+    BCMOLT_CFG_INIT(&interface_obj, pon_interface, interface_key);
+    BCMOLT_MSG_FIELD_GET(&interface_obj, state);
+    bcmos_errno err = bcmolt_cfg_get(dev_id, &interface_obj.hdr);
     if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to disable PON interface: %d\n", intf_id);
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to disable PON interface: %d\n", intf_id);
         return bcm_to_grpc_err(err, "Failed to disable PON interface");
     }
 
@@ -728,60 +1402,78 @@
 
 Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific, uint32_t pir) {
+    bcmos_errno err = BCM_ERR_OK;
+    bcmolt_onu_cfg onu_cfg;
+    bcmolt_onu_key onu_key;
+    bcmolt_serial_number serial_number; /**< ONU serial number */
+    bcmolt_bin_str_36 registration_id; /**< ONU registration ID */
 
-    bcmbal_subscriber_terminal_cfg sub_term_obj = {};
-    bcmbal_subscriber_terminal_key subs_terminal_key;
-    bcmbal_serial_number serial_num = {};
-    bcmbal_registration_id registration_id = {};
-
-    BCM_LOG(INFO, openolt_log_id,  "Enabling ONU %d on PON %d : vendor id %s, vendor specific %s, pir %d\n",
-        onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str(), pir);
-
-    subs_terminal_key.sub_term_id = onu_id;
-    subs_terminal_key.intf_id = intf_id;
-    BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, subs_terminal_key);
-
-    memcpy(serial_num.vendor_id, vendor_id, 4);
-    memcpy(serial_num.vendor_specific, vendor_specific, 4);
-    BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, serial_number, serial_num);
-
-#if 0
-    // Commenting out as this is causing issues with onu activation
-    // with BAL 2.6 (Broadcom CS5248819).
-
-    // FIXME - Use a default (all zeros) registration id.
-    memset(registration_id.arr, 0, sizeof(registration_id.arr));
-    BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, registration_id, registration_id);
-#endif
-
-    BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, admin_state, BCMBAL_STATE_UP);
-
-    bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to enable ONU %d on PON %d\n", onu_id, intf_id);
-        return bcm_to_grpc_err(err, "Failed to enable ONU");
+    onu_key.onu_id = onu_id;
+    onu_key.pon_ni = intf_id;
+    BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key);
+    BCMOLT_FIELD_SET_PRESENT(&onu_cfg.data, onu_cfg_data, onu_state);
+    err = bcmolt_cfg_get(dev_id, &onu_cfg.hdr);
+    if (err == BCM_ERR_OK) { 
+        if ((onu_cfg.data.onu_state == BCMOLT_ONU_STATE_PROCESSING || 
+             onu_cfg.data.onu_state == BCMOLT_ONU_STATE_ACTIVE) ||
+           (onu_cfg.data.onu_state == BCMOLT_ONU_STATE_INACTIVE &&
+             onu_cfg.data.onu_old_state == BCMOLT_ONU_STATE_NOT_CONFIGURED))
+            return Status::OK;
     }
+
+    OPENOLT_LOG(INFO, openolt_log_id,  "Enabling ONU %d on PON %d : vendor id %s, \
+vendor specific %s, pir %d\n", onu_id, intf_id, vendor_id, 
+        vendor_specific_to_str(vendor_specific).c_str(), pir);
+
+    memcpy(serial_number.vendor_id.arr, vendor_id, 4);
+    memcpy(serial_number.vendor_specific.arr, vendor_specific, 4);
+    BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key);
+    BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.serial_number, serial_number);
+    BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.auto_learning, BCMOS_TRUE);
+    /*set burst and data profiles to fec disabled*/
+    if (board_technology == "XGS-PON") {
+        BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.xgpon.ranging_burst_profile, 2);
+        BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.xgpon.data_burst_profile, 1);
+    } else if (board_technology == "GPON") {
+        BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.gpon.ds_ber_reporting_interval, 1000000);
+        BCMOLT_MSG_FIELD_SET(&onu_cfg, itu.gpon.omci_port_id, onu_id);
+    }
+    err = bcmolt_cfg_set(dev_id, &onu_cfg.hdr);
+    if (err != BCM_ERR_OK) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to set activate ONU %d on PON %d, err %d\n", onu_id, intf_id, err);
+        return bcm_to_grpc_err(err, "Failed to activate ONU");
+    }
+
     return Status::OK;
 }
 
 Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific) {
+    bcmos_errno err = BCM_ERR_OK;
+    bcmolt_onu_set_onu_state onu_oper; /* declare main API struct */
+    bcmolt_onu_cfg onu_cfg;
+    bcmolt_onu_key onu_key; /**< Object key. */
+    bcmolt_onu_state onu_state;
 
-    bcmbal_subscriber_terminal_cfg sub_term_obj = {};
-    bcmbal_subscriber_terminal_key subs_terminal_key;
-
-    BCM_LOG(INFO, openolt_log_id,  "Deactivating ONU %d on PON %d : vendor id %s, vendor specific %s\n",
-        onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
-
-    subs_terminal_key.sub_term_id = onu_id;
-    subs_terminal_key.intf_id = intf_id;
-    BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, subs_terminal_key);
-
-    BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, admin_state, BCMBAL_STATE_DOWN);
-
-    if (bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr))) {
-        BCM_LOG(ERROR, openolt_log_id,  "Failed to deactivate ONU %d on PON %d\n", onu_id, intf_id);
-        return Status(grpc::StatusCode::INTERNAL, "Failed to deactivate ONU");
+    onu_key.onu_id = onu_id;
+    onu_key.pon_ni = intf_id;
+    BCMOLT_CFG_INIT(&onu_cfg, onu, onu_key);
+    BCMOLT_FIELD_SET_PRESENT(&onu_cfg.data, onu_cfg_data, onu_state);
+    err = bcmolt_cfg_get(dev_id, &onu_cfg.hdr);
+    if (err == BCM_ERR_OK) { 
+        switch (onu_state) {
+            case BCMOLT_ONU_OPERATION_ACTIVE:
+                BCMOLT_OPER_INIT(&onu_oper, onu, set_onu_state, onu_key);
+                BCMOLT_FIELD_SET(&onu_oper.data, onu_set_onu_state_data, 
+                    onu_state, BCMOLT_ONU_OPERATION_INACTIVE);
+                err = bcmolt_oper_submit(dev_id, &onu_oper.hdr);
+                if (err != BCM_ERR_OK) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Failed to \
+deactivate ONU %d on PON %d, err %d\n", onu_id, intf_id, err);
+                    return bcm_to_grpc_err(err, "Failed to deactivate ONU");
+                }
+                break;
+        }
     }
 
     return Status::OK;
@@ -790,7 +1482,7 @@
 Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
     const char *vendor_id, const char *vendor_specific) {
 
-    BCM_LOG(INFO, openolt_log_id,  "DeleteOnu ONU %d on PON %d : vendor id %s, vendor specific %s\n",
+    OPENOLT_LOG(INFO, openolt_log_id,  "DeleteOnu ONU %d on PON %d : vendor id %s, vendor specific %s\n",
         onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
 
     // Need to deactivate before removing it (BAL rules)
@@ -803,48 +1495,40 @@
 
     // TODO: Delete the schedulers and queues.
 
-    bcmos_errno err = BCM_ERR_OK;
-    bcmbal_subscriber_terminal_cfg cfg;
-    bcmbal_subscriber_terminal_key key = { };
+    bcmolt_onu_cfg cfg_obj;
+    bcmolt_onu_key key;
 
-    BCM_LOG(INFO, openolt_log_id, "Processing subscriber terminal cfg clear for sub_term_id %d  and intf_id %d\n",
+    OPENOLT_LOG(INFO, openolt_log_id, "Processing subscriber terminal cfg clear for sub_term_id %d  and intf_id %d\n",
         onu_id, intf_id);
 
-    key.sub_term_id = onu_id ;
-    key.intf_id = intf_id ;
+    key.onu_id = onu_id;
+    key.pon_ni = intf_id;
+    BCMOLT_CFG_INIT(&cfg_obj, onu, key);
 
-    if (0 == key.sub_term_id)
-    {
-            BCM_LOG(INFO, openolt_log_id,"Invalid Key to handle subscriber terminal clear subscriber_terminal_id %d, \
-                    Interface ID %d\n", onu_id, intf_id);
-            return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
-    }
-
-    BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
-
-    err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
+    bcmos_errno err = bcmolt_cfg_clear(dev_id, &cfg_obj.hdr);
     if (err != BCM_ERR_OK)
     {
-       BCM_LOG(ERROR, openolt_log_id, "Failed to clear information for BAL subscriber_terminal_id %d, Interface ID %d\n",
+       OPENOLT_LOG(ERROR, openolt_log_id, "Failed to clear information for BAL subscriber_terminal_id %d, Interface ID %d\n",
             onu_id, intf_id);
         return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
     }
 
-    return Status::OK;;
+    return Status::OK;
 }
 
 #define MAX_CHAR_LENGTH  20
 #define MAX_OMCI_MSG_LENGTH 44
 Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt) {
-    bcmbal_u8_list_u32_max_2048 buf; /* A structure with a msg pointer and length value */
-    bcmos_errno err = BCM_ERR_OK;
+    bcmolt_bin_str buf = {};
+    bcmolt_onu_cpu_packets omci_cpu_packets;
+    bcmolt_onu_key key;
 
-    /* The destination of the OMCI packet is a registered ONU on the OLT PON interface */
-    bcmbal_dest proxy_pkt_dest;
+    key.pon_ni = intf_id;
+    key.onu_id = onu_id;
 
-    proxy_pkt_dest.type = BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL;
-    proxy_pkt_dest.u.itu_omci_channel.sub_term_id = onu_id;
-    proxy_pkt_dest.u.itu_omci_channel.intf_id = intf_id;
+    BCMOLT_OPER_INIT(&omci_cpu_packets, onu, cpu_packets, key);
+    BCMOLT_MSG_FIELD_SET(&omci_cpu_packets, packet_type, BCMOLT_PACKET_TYPE_OMCI);
+    BCMOLT_MSG_FIELD_SET(&omci_cpu_packets, calc_crc, BCMOS_TRUE);
 
     // ???
     if ((pkt.size()/2) > MAX_OMCI_MSG_LENGTH) {
@@ -868,27 +1552,32 @@
        arraySend[idx2] = strtol(str1, NULL, 16);
     }
 
-    buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
-    memcpy(buf.val, (uint8_t *)arraySend, buf.len);
+    buf.arr = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
+    memcpy(buf.arr, (uint8_t *)arraySend, buf.len);
 
-    err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
+    BCMOLT_MSG_FIELD_SET(&omci_cpu_packets, number_of_packets, 1);
+    BCMOLT_MSG_FIELD_SET(&omci_cpu_packets, packet_size, buf.len);
+    BCMOLT_MSG_FIELD_SET(&omci_cpu_packets, buffer, buf);
 
+    bcmos_errno err = bcmolt_oper_submit(dev_id, &omci_cpu_packets.hdr);
     if (err) {
-        BCM_LOG(ERROR, omci_log_id, "Error sending OMCI message to ONU %d on PON %d\n", onu_id, intf_id);
+        OPENOLT_LOG(ERROR, omci_log_id, "Error sending OMCI message to ONU %d on PON %d\n", onu_id, intf_id);
+        return bcm_to_grpc_err(err, "send OMCI failed");
     } else {
-        BCM_LOG(DEBUG, omci_log_id, "OMCI request msg of length %d sent to ONU %d on PON %d : %s\n",
+        OPENOLT_LOG(DEBUG, omci_log_id, "OMCI request msg of length %d sent to ONU %d on PON %d : %s\n",
             buf.len, onu_id, intf_id, pkt.c_str());
     }
-
-    free(buf.val);
+    free(buf.arr);
 
     return Status::OK;
 }
 
 Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, uint32_t port_no, uint32_t gemport_id, const std::string pkt) {
-    bcmos_errno err = BCM_ERR_OK;
-    bcmbal_dest proxy_pkt_dest;
-    bcmbal_u8_list_u32_max_2048 buf;
+    bcmolt_pon_interface_cpu_packets pon_interface_cpu_packets; /**< declare main API struct */
+    bcmolt_pon_interface_key key = {.pon_ni = (bcmolt_interface)intf_id}; /**< declare key */
+    bcmolt_bin_str buf = {};
+    bcmolt_gem_port_id gem_port_id_array[1];
+    bcmolt_gem_port_id_list_u8_max_16 gem_port_list = {};
 
     if (port_no > 0) {
         bool found = false;
@@ -908,63 +1597,99 @@
             bcmos_fastlock_unlock(&data_lock, 0);
 
             if (!found) {
-                BCM_LOG(ERROR, openolt_log_id, "Packet out failed to find destination for ONU %d port_no %u on PON %d\n",
+                OPENOLT_LOG(ERROR, openolt_log_id, "Packet out failed to find destination for ONU %d port_no %u on PON %d\n",
                         onu_id, port_no, intf_id);
                 return grpc::Status(grpc::StatusCode::NOT_FOUND, "no flow for port_no");
             }
-            BCM_LOG(INFO, openolt_log_id, "Gem port %u found for ONU %d port_no %u on PON %d\n",
+            OPENOLT_LOG(INFO, openolt_log_id, "Gem port %u found for ONU %d port_no %u on PON %d\n",
                     gemport_id, onu_id, port_no, intf_id);
         }
 
-        proxy_pkt_dest.type = BCMBAL_DEST_TYPE_SVC_PORT;
-        proxy_pkt_dest.u.svc_port.svc_port_id = gemport_id;
-        proxy_pkt_dest.u.svc_port.intf_id = intf_id;
-        BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent to gemport %d on pon %d port_no %u\n",
-            pkt.size(), gemport_id, intf_id, port_no);
+        gem_port_id_array[0] = gemport_id;
+        gem_port_list.len = 1;
+        gem_port_list.arr = gem_port_id_array;
+        buf.len = pkt.size();
+        buf.arr = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
+        memcpy(buf.arr, (uint8_t *)pkt.data(), buf.len);
+
+        /* init the API struct */
+        BCMOLT_OPER_INIT(&pon_interface_cpu_packets, pon_interface, cpu_packets, key);
+        BCMOLT_MSG_FIELD_SET(&pon_interface_cpu_packets, packet_type, BCMOLT_PACKET_TYPE_ETH);
+        BCMOLT_MSG_FIELD_SET(&pon_interface_cpu_packets, calc_crc, BCMOS_TRUE);
+        BCMOLT_MSG_FIELD_SET(&pon_interface_cpu_packets, gem_port_list, gem_port_list);
+        BCMOLT_MSG_FIELD_SET(&pon_interface_cpu_packets, buffer, buf);
+
+        OPENOLT_LOG(INFO, openolt_log_id, "Packet out of length %d sent to gemport %d on pon %d port_no %u\n",
+            (uint8_t)pkt.size(), gemport_id, intf_id, port_no);
+
+        /* call API */
+        bcmolt_oper_submit(dev_id, &pon_interface_cpu_packets.hdr);
     }
     else {
-        proxy_pkt_dest.type = BCMBAL_DEST_TYPE_SUB_TERM,
-        proxy_pkt_dest.u.sub_term.sub_term_id = onu_id;
-        proxy_pkt_dest.u.sub_term.intf_id = intf_id;
-        BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent to onu %d on pon %d\n",
-            pkt.size(), onu_id, intf_id);
+        //TODO: Port No is 0, it is coming sender requirement.
+        OPENOLT_LOG(INFO, openolt_log_id, "port_no %d onu %d on pon %d\n",
+            port_no, onu_id, intf_id);
     }
-
-    buf.len = pkt.size();
-    buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
-    memcpy(buf.val, (uint8_t *)pkt.data(), buf.len);
-
-    err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
-
-    free(buf.val);
+    free(buf.arr);
 
     return Status::OK;
 }
 
 Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt) {
-    bcmos_errno err = BCM_ERR_OK;
-    bcmbal_dest proxy_pkt_dest;
-    bcmbal_u8_list_u32_max_2048 buf;
+    bcmolt_flow_key key = {}; /* declare key */
+    bcmolt_bin_str buffer = {};
+    bcmolt_flow_send_eth_packet oper; /* declare main API struct */
 
-    proxy_pkt_dest.type = BCMBAL_DEST_TYPE_NNI,
-    proxy_pkt_dest.u.nni.intf_id = intf_id;
+    // TODO: flow_id is currently not passed in UplinkPacket message from voltha.
+    bcmolt_flow_id flow_id = 0;
 
-    buf.len = pkt.size();
-    buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
-    memcpy(buf.val, (uint8_t *)pkt.data(), buf.len);
+    //validate flow_id and find flow_id/flow type: upstream/ingress type: PON/egress type: NNI
+    if (get_flow_status(flow_id, BCMOLT_FLOW_TYPE_UPSTREAM, FLOW_TYPE) == BCMOLT_FLOW_TYPE_UPSTREAM && \
+        get_flow_status(flow_id, BCMOLT_FLOW_TYPE_UPSTREAM, INGRESS_INTF_TYPE) == BCMOLT_FLOW_INTERFACE_TYPE_PON && \
+        get_flow_status(flow_id, BCMOLT_FLOW_TYPE_UPSTREAM, EGRESS_INTF_TYPE) == BCMOLT_FLOW_INTERFACE_TYPE_NNI)
+        key.flow_id = flow_id;
+    else {
+        if (flow_id_counters != 0) {
+            for (int flowid=0; flowid < flow_id_counters; flowid++) {
+                int flow_index = flow_id_data[flowid][0];
+                if (get_flow_status(flow_index, BCMOLT_FLOW_TYPE_UPSTREAM, FLOW_TYPE) == BCMOLT_FLOW_TYPE_UPSTREAM && \
+                    get_flow_status(flow_index, BCMOLT_FLOW_TYPE_UPSTREAM, INGRESS_INTF_TYPE) == BCMOLT_FLOW_INTERFACE_TYPE_PON && \
+                    get_flow_status(flow_index, BCMOLT_FLOW_TYPE_UPSTREAM, EGRESS_INTF_TYPE) == BCMOLT_FLOW_INTERFACE_TYPE_NNI) {
+                    key.flow_id = flow_index;
+                    break;
+                }
+            }
+        }
+        else {
+            return grpc::Status(grpc::StatusCode::NOT_FOUND, "no flow id found");
+        }
+    }
 
-    err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
+    key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM; /* send from uplink direction */
 
-    BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent through uplink port %d\n",
-        buf.len, intf_id);
+    /* Initialize the API struct. */
+    BCMOLT_OPER_INIT(&oper, flow, send_eth_packet, key);
 
-    free(buf.val);
+    buffer.len = pkt.size();
+    buffer.arr = (uint8_t *)malloc((buffer.len)*sizeof(uint8_t));
+    memcpy(buffer.arr, (uint8_t *)pkt.data(), buffer.len);
+    if (buffer.arr == NULL) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "allocate packet buffer failed\n");
+        return bcm_to_grpc_err(BCM_ERR_PARM, "allocate packet buffer failed");
+    }
+    BCMOLT_FIELD_SET(&oper.data, flow_send_eth_packet_data, buffer, buffer);
+
+    bcmos_errno err = bcmolt_oper_submit(dev_id, &oper.hdr);
+    if (err) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Error sending packets via nni port %d, flow_id %d err %d\n", intf_id, key.flow_id, err);
+    } else {
+        OPENOLT_LOG(INFO, openolt_log_id, "sent packets to port %d in upstream direction, flow_id %d \n", intf_id, key.flow_id);
+    }
 
     return Status::OK;
 }
 
-uint32_t GetPortNum_(uint32_t flow_id)
-{
+uint32_t GetPortNum_(uint32_t flow_id) {
     bcmos_fastlock_lock(&data_lock);
     uint32_t port_no = 0;
     std::map<uint32_t, uint32_t >::const_iterator it = flowid_to_port.find(flow_id);
@@ -975,52 +1700,150 @@
     return port_no;
 }
 
+#define FLOW_LOG(level,msg,err) \
+    do { \
+    OPENOLT_LOG(level, openolt_log_id, "--------> %s (flow_id %d) err: %d <--------\n", msg, key.flow_id, err); \
+    OPENOLT_LOG(level, openolt_log_id, "intf_id %d, onu_id %d, uni_id %d, port_no %u, cookie %"PRIu64"\n", \
+        access_intf_id, onu_id, uni_id, port_no, cookie); \
+    OPENOLT_LOG(level, openolt_log_id, "flow_type %s, queue_id %d, sched_id %d\n", flow_type.c_str(), \
+        cfg.data.egress_qos.u.fixed_queue.queue_id, cfg.data.egress_qos.tm_sched.id); \
+    OPENOLT_LOG(level, openolt_log_id, "Ingress(intfd_type %s, intf_id %d), Egress(intf_type %s, intf_id %d)\n", \
+        GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type), cfg.data.ingress_intf.intf_id,  \
+        GET_FLOW_INTERFACE_TYPE(cfg.data.egress_intf.intf_type), cfg.data.egress_intf.intf_id); \
+    OPENOLT_LOG(level, openolt_log_id, "classifier(o_vid %d, o_pbits %d, i_vid %d, i_pbits %d, ether type 0x%x)\n", \
+        c_val.o_vid, c_val.o_pbits, c_val.i_vid, c_val.i_pbits,  classifier.eth_type()); \
+    OPENOLT_LOG(level, openolt_log_id, "classifier(ip_proto 0x%x, gemport_id %d, src_port %d, dst_port %d, pkt_tag_type %s)\n", \
+        c_val.ip_proto, gemport_id, c_val.src_port,  c_val.dst_port, GET_PKT_TAG_TYPE(c_val.pkt_tag_type)); \
+    OPENOLT_LOG(level, openolt_log_id, "action(cmds_bitmask %s, o_vid %d, o_pbits %d, i_vid %d, i_pbits %d)\n\n", \
+        get_flow_acton_command(a_val.cmds_bitmask), a_val.o_vid, a_val.o_pbits, a_val.i_vid, a_val.i_pbits); \
+    } while(0) 
+
+#define FLOW_PARAM_LOG() \
+    do { \
+    OPENOLT_LOG(INFO, openolt_log_id, "--------> flow comparison (now before) <--------\n"); \
+    OPENOLT_LOG(INFO, openolt_log_id, "flow_id (%d %d)\n", \
+        key.flow_id, flow_index); \
+    OPENOLT_LOG(INFO, openolt_log_id, "onu_id (%d %lu)\n", \
+        cfg.data.onu_id , get_flow_status(flow_index, flow_id_data[flowid][1], ONU_ID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "type (%d %lu)\n", \
+        key.flow_type, get_flow_status(flow_index, flow_id_data[flowid][1], FLOW_TYPE)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "svc_port_id (%d %lu)\n", \
+        cfg.data.svc_port_id, get_flow_status(flow_index, flow_id_data[flowid][1], SVC_PORT_ID));  \
+    OPENOLT_LOG(INFO, openolt_log_id, "priority (%d %lu)\n", \
+        cfg.data.priority, get_flow_status(flow_index, flow_id_data[flowid][1], PRIORITY)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "cookie (%lu %lu)\n", \
+        cfg.data.cookie, get_flow_status(flow_index, flow_id_data[flowid][1], COOKIE)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "ingress intf_type (%s %s)\n", \
+        GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type), \
+        GET_FLOW_INTERFACE_TYPE(get_flow_status(flow_index, flow_id_data[flowid][1], INGRESS_INTF_TYPE))); \
+    OPENOLT_LOG(INFO, openolt_log_id, "ingress intf id (%d %lu)\n", \
+        cfg.data.ingress_intf.intf_id , get_flow_status(flow_index, flow_id_data[flowid][1], INGRESS_INTF_ID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "egress intf_type (%d %lu)\n", \
+        cfg.data.egress_intf.intf_type , get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_INTF_TYPE)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "egress intf_id (%d %lu)\n", \
+        cfg.data.egress_intf.intf_id , get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_INTF_ID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier o_vid (%d %lu)\n", \
+        c_val.o_vid , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_O_VID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier o_pbits (%d %lu)\n", \
+        c_val.o_pbits , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_O_PBITS)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier i_vid (%d %lu)\n", \
+        c_val.i_vid , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_I_VID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier i_pbits (%d %lu)\n", \
+        c_val.i_pbits , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_I_PBITS)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier ether_type (0x%x 0x%lx)\n", \
+        c_val.ether_type , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_ETHER_TYPE));  \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier ip_proto (%d %lu)\n", \
+        c_val.ip_proto , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_IP_PROTO)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier src_port (%d %lu)\n", \
+        c_val.src_port , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_SRC_PORT)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier dst_port (%d %lu)\n", \
+        c_val.dst_port , get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_DST_PORT)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier pkt_tag_type (%s %s)\n", \
+        GET_PKT_TAG_TYPE(c_val.pkt_tag_type), \
+        GET_PKT_TAG_TYPE(get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_PKT_TAG_TYPE))); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier egress_qos type (%d %lu)\n", \
+        cfg.data.egress_qos.type , get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_TYPE)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier egress_qos queue_id (%d %lu)\n", \
+        cfg.data.egress_qos.u.fixed_queue.queue_id, \
+        get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_QUEUE_ID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier egress_qos sched_id (%d %lu)\n", \
+        cfg.data.egress_qos.tm_sched.id, \
+        get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_TM_SCHED_ID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "classifier cmds_bitmask (%s %s)\n", \
+        get_flow_acton_command(a_val.cmds_bitmask), \
+        get_flow_acton_command(get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_CMDS_BITMASK))); \
+    OPENOLT_LOG(INFO, openolt_log_id, "action o_vid (%d %lu)\n", \
+        a_val.o_vid , get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_O_VID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "action i_vid (%d %lu)\n", \
+        a_val.i_vid , get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_I_VID)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "action o_pbits (%d %lu)\n", \
+        a_val.o_pbits , get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_O_PBITS)); \
+    OPENOLT_LOG(INFO, openolt_log_id, "action i_pbits (%d %lu)\n\n", \
+        a_val.i_pbits, get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_I_PBITS)); \
+    } while(0)
+
+#define FLOW_CHECKER
+//#define SHOW_FLOW_PARAM
+
 Status FlowAdd_(int32_t access_intf_id, int32_t onu_id, int32_t uni_id, uint32_t port_no,
                 uint32_t flow_id, const std::string flow_type,
                 int32_t alloc_id, int32_t network_intf_id,
                 int32_t gemport_id, const ::openolt::Classifier& classifier,
                 const ::openolt::Action& action, int32_t priority_value, uint64_t cookie) {
-    bcmos_errno err;
-    bcmbal_flow_cfg cfg;
-    bcmbal_flow_key key = { };
+    bcmolt_flow_cfg cfg;
+    bcmolt_flow_key key = { }; /**< Object key. */
     int32_t o_vid = -1;
     bool single_tag = false;
     uint32_t ether_type = 0;
-
-    BCM_LOG(INFO, openolt_log_id, "flow add - intf_id %d, onu_id %d, uni_id %d, port_no %u, flow_id %d, flow_type %s, \
-            gemport_id %d, network_intf_id %d, cookie %llu\n", \
-            access_intf_id, onu_id, uni_id, port_no, flow_id, flow_type.c_str(), gemport_id, network_intf_id, cookie);
+    bcmolt_classifier c_val = { };
+    bcmolt_action a_val = { };
+    bcmolt_tm_queue_ref tm_val = { };
+    int tm_qmp_id, tm_q_set_id;
 
     key.flow_id = flow_id;
     if (flow_type.compare(upstream) == 0 ) {
-        key.flow_type = BCMBAL_FLOW_TYPE_UPSTREAM;
+        key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM;
     } else if (flow_type.compare(downstream) == 0) {
-        key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
+        key.flow_type = BCMOLT_FLOW_TYPE_DOWNSTREAM;
     } else {
-        BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
+        OPENOLT_LOG(ERROR, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
         return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
     }
 
-    BCMBAL_CFG_INIT(&cfg, flow, key);
+    BCMOLT_CFG_INIT(&cfg, flow, key);
+    BCMOLT_MSG_FIELD_SET(&cfg, cookie, cookie);
 
-    BCMBAL_CFG_PROP_SET(&cfg, flow, admin_state, BCMBAL_STATE_UP);
-    BCMBAL_CFG_PROP_SET(&cfg, flow, cookie, cookie);
+    if (access_intf_id >= 0 && network_intf_id >= 0) {
+        if (key.flow_type == BCMOLT_FLOW_TYPE_UPSTREAM) { //upstream
+            BCMOLT_MSG_FIELD_SET(&cfg, ingress_intf.intf_type, BCMOLT_FLOW_INTERFACE_TYPE_PON);
+            BCMOLT_MSG_FIELD_SET(&cfg, ingress_intf.intf_id, access_intf_id);
+            if (classifier.eth_type() == EAP_ETHER_TYPE || //EAPOL packet
+               (classifier.ip_proto() == 17 && classifier.src_port() == 68 && classifier.dst_port() == 67)) { //DHCP packet
+                BCMOLT_MSG_FIELD_SET(&cfg, egress_intf.intf_type, BCMOLT_FLOW_INTERFACE_TYPE_HOST);
+            } else {
+                BCMOLT_MSG_FIELD_SET(&cfg, egress_intf.intf_type, BCMOLT_FLOW_INTERFACE_TYPE_NNI);
+                BCMOLT_MSG_FIELD_SET(&cfg, egress_intf.intf_id, network_intf_id);
+            }
+        } else if (key.flow_type == BCMOLT_FLOW_TYPE_DOWNSTREAM) { //downstream
+            BCMOLT_MSG_FIELD_SET(&cfg, ingress_intf.intf_type, BCMOLT_FLOW_INTERFACE_TYPE_NNI);
+            BCMOLT_MSG_FIELD_SET(&cfg, ingress_intf.intf_id, network_intf_id);
+            BCMOLT_MSG_FIELD_SET(&cfg, egress_intf.intf_type, BCMOLT_FLOW_INTERFACE_TYPE_PON);
+            BCMOLT_MSG_FIELD_SET(&cfg, egress_intf.intf_id, access_intf_id);
+        }
+    } else {
+        OPENOLT_LOG(ERROR, openolt_log_id, "flow network setting invalid\n");
+        return bcm_to_grpc_err(BCM_ERR_PARM, "flow network setting invalid");
+    }
 
-    if (access_intf_id >= 0) {
-        BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, access_intf_id);
-    }
-    if (network_intf_id >= 0) {
-        BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, network_intf_id);
-    }
     if (onu_id >= 0) {
-        BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, onu_id);
+        BCMOLT_MSG_FIELD_SET(&cfg, onu_id, onu_id);
     }
     if (gemport_id >= 0) {
-        BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, gemport_id);
+        BCMOLT_MSG_FIELD_SET(&cfg, svc_port_id, gemport_id);
     }
     if (gemport_id >= 0 && port_no != 0) {
         bcmos_fastlock_lock(&data_lock);
-        if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
+        if (key.flow_type == BCMOLT_FLOW_TYPE_DOWNSTREAM) {
             port_to_flows[port_no].insert(key.flow_id);
             flowid_to_gemport[key.flow_id] = gemport_id;
         }
@@ -1031,36 +1854,35 @@
         bcmos_fastlock_unlock(&data_lock, 0);
     }
     if (priority_value >= 0) {
-        BCMBAL_CFG_PROP_SET(&cfg, flow, priority, priority_value);
+        BCMOLT_MSG_FIELD_SET(&cfg, priority, priority_value);
     }
 
     {
-        bcmbal_classifier val = { };
-
+        /* removed by BAL v3.0
         if (classifier.o_tpid()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify o_tpid 0x%04x\n", classifier.o_tpid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify o_tpid 0x%04x\n", classifier.o_tpid());
             BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_tpid, classifier.o_tpid());
         }
-
+        */
         if (classifier.o_vid()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify o_vid %d\n", classifier.o_vid());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_vid, classifier.o_vid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify o_vid %d\n", classifier.o_vid());
+            BCMOLT_FIELD_SET(&c_val, classifier, o_vid, classifier.o_vid());
         }
-
+        /* removed by BAL v3.0
         if (classifier.i_tpid()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify i_tpid 0x%04x\n", classifier.i_tpid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify i_tpid 0x%04x\n", classifier.i_tpid());
             BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, i_tpid, classifier.i_tpid());
         }
-
+        */
         if (classifier.i_vid()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify i_vid %d\n", classifier.i_vid());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, i_vid, classifier.i_vid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify i_vid %d\n", classifier.i_vid());
+            BCMOLT_FIELD_SET(&c_val, classifier, i_vid, classifier.i_vid());
         }
 
         if (classifier.eth_type()) {
             ether_type = classifier.eth_type();
-            BCM_LOG(DEBUG, openolt_log_id, "classify ether_type 0x%04x\n", classifier.eth_type());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, ether_type, classifier.eth_type());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify ether_type 0x%04x\n", classifier.eth_type());
+            BCMOLT_FIELD_SET(&c_val, classifier, ether_type, classifier.eth_type());
         }
 
         /*
@@ -1074,8 +1896,8 @@
         */
 
         if (classifier.ip_proto()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify ip_proto %d\n", classifier.ip_proto());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, ip_proto, classifier.ip_proto());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify ip_proto %d\n", classifier.ip_proto());
+            BCMOLT_FIELD_SET(&c_val, classifier, ip_proto, classifier.ip_proto());
         }
 
         /*
@@ -1089,149 +1911,243 @@
         */
 
         if (classifier.src_port()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify src_port %d\n", classifier.src_port());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, src_port, classifier.src_port());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify src_port %d\n", classifier.src_port());
+            BCMOLT_FIELD_SET(&c_val, classifier, src_port, classifier.src_port());
         }
 
         if (classifier.dst_port()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify dst_port %d\n", classifier.dst_port());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, dst_port, classifier.dst_port());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify dst_port %d\n", classifier.dst_port());
+            BCMOLT_FIELD_SET(&c_val, classifier, dst_port, classifier.dst_port());
         }
 
         if (!classifier.pkt_tag_type().empty()) {
-            BCM_LOG(DEBUG, openolt_log_id, "classify tag_type %s\n", classifier.pkt_tag_type().c_str());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "classify tag_type %s\n", classifier.pkt_tag_type().c_str());
             if (classifier.pkt_tag_type().compare("untagged") == 0) {
-                BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_UNTAGGED);
+                BCMOLT_FIELD_SET(&c_val, classifier, pkt_tag_type, BCMOLT_PKT_TAG_TYPE_UNTAGGED);
             } else if (classifier.pkt_tag_type().compare("single_tag") == 0) {
-                BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_SINGLE_TAG);
+                BCMOLT_FIELD_SET(&c_val, classifier, pkt_tag_type, BCMOLT_PKT_TAG_TYPE_SINGLE_TAG);
                 single_tag = true;
 
-		BCM_LOG(DEBUG, openolt_log_id, "classify o_pbits 0x%x\n", classifier.o_pbits());
-                BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_pbits, classifier.o_pbits());
+                OPENOLT_LOG(DEBUG, openolt_log_id, "classify o_pbits 0x%x\n", classifier.o_pbits());
+                BCMOLT_FIELD_SET(&c_val, classifier, o_pbits, classifier.o_pbits());
             } else if (classifier.pkt_tag_type().compare("double_tag") == 0) {
-                BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_DOUBLE_TAG);
+                BCMOLT_FIELD_SET(&c_val, classifier, pkt_tag_type, BCMOLT_PKT_TAG_TYPE_DOUBLE_TAG);
 
-		BCM_LOG(DEBUG, openolt_log_id, "classify o_pbits 0x%x\n", classifier.o_pbits());
-                BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_pbits, classifier.o_pbits());
+                OPENOLT_LOG(DEBUG, openolt_log_id, "classify o_pbits 0x%x\n", classifier.o_pbits());
+                BCMOLT_FIELD_SET(&c_val, classifier, o_pbits, classifier.o_pbits());
             }
         }
-
-        BCMBAL_CFG_PROP_SET(&cfg, flow, classifier, val);
+        BCMOLT_MSG_FIELD_SET(&cfg, classifier, c_val);
     }
 
-    {
-        bcmbal_action val = { };
-
+    if (cfg.data.egress_intf.intf_type != BCMOLT_FLOW_INTERFACE_TYPE_HOST) {
         const ::openolt::ActionCmd& cmd = action.cmd();
 
         if (cmd.add_outer_tag()) {
-            BCM_LOG(INFO, openolt_log_id, "action add o_tag\n");
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_ADD_OUTER_TAG);
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action add o_tag\n");
+            BCMOLT_FIELD_SET(&a_val, action, cmds_bitmask, BCMOLT_ACTION_CMD_ID_ADD_OUTER_TAG);
         }
 
         if (cmd.remove_outer_tag()) {
-            BCM_LOG(INFO, openolt_log_id, "action pop o_tag\n");
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_REMOVE_OUTER_TAG);
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action pop o_tag\n");
+            BCMOLT_FIELD_SET(&a_val, action, cmds_bitmask, BCMOLT_ACTION_CMD_ID_REMOVE_OUTER_TAG);
         }
-
+        /* removed by BAL v3.0
         if (cmd.trap_to_host()) {
-            BCM_LOG(INFO, openolt_log_id, "action trap-to-host\n");
+            OPENOLT_LOG(INFO, openolt_log_id, "action trap-to-host\n");
             BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_TRAP_TO_HOST);
         }
-
+        */
         if (action.o_vid()) {
-            BCM_LOG(INFO, openolt_log_id, "action o_vid=%d\n", action.o_vid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action o_vid=%d\n", action.o_vid());
             o_vid = action.o_vid();
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_vid, action.o_vid());
+            BCMOLT_FIELD_SET(&a_val, action, o_vid, action.o_vid());
         }
 
         if (action.o_pbits()) {
-            BCM_LOG(INFO, openolt_log_id, "action o_pbits=0x%x\n", action.o_pbits());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_pbits, action.o_pbits());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action o_pbits=0x%x\n", action.o_pbits());
+            BCMOLT_FIELD_SET(&a_val, action, o_pbits, action.o_pbits());
         }
-
+        /* removed by BAL v3.0
         if (action.o_tpid()) {
-            BCM_LOG(INFO, openolt_log_id, "action o_tpid=0x%04x\n", action.o_tpid());
+            OPENOLT_LOG(INFO, openolt_log_id, "action o_tpid=0x%04x\n", action.o_tpid());
             BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_tpid, action.o_tpid());
         }
-
+        */
         if (action.i_vid()) {
-            BCM_LOG(INFO, openolt_log_id, "action i_vid=%d\n", action.i_vid());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_vid, action.i_vid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action i_vid=%d\n", action.i_vid());
+            BCMOLT_FIELD_SET(&a_val, action, i_vid, action.i_vid());
         }
 
         if (action.i_pbits()) {
-            BCM_LOG(DEBUG, openolt_log_id, "action i_pbits=0x%x\n", action.i_pbits());
-            BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_pbits, action.i_pbits());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action i_pbits=0x%x\n", action.i_pbits());
+            BCMOLT_FIELD_SET(&a_val, action, i_pbits, action.i_pbits());
         }
-
+        /* removed by BAL v3.0
         if (action.i_tpid()) {
-            BCM_LOG(DEBUG, openolt_log_id, "action i_tpid=0x%04x\n", action.i_tpid());
+            OPENOLT_LOG(DEBUG, openolt_log_id, "action i_tpid=0x%04x\n", action.i_tpid());
             BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_tpid, action.i_tpid());
         }
-
-        BCMBAL_CFG_PROP_SET(&cfg, flow, action, val);
+        */
+        BCMOLT_MSG_FIELD_SET(&cfg, action, a_val);
     }
 
     if ((access_intf_id >= 0) && (onu_id >= 0)) {
+        if(single_tag && ether_type == EAP_ETHER_TYPE) {
+            tm_val.sched_id = (flow_type.compare(upstream) == 0) ? \
+                get_default_tm_sched_id(network_intf_id, upstream) : \
+                get_default_tm_sched_id(access_intf_id, downstream);
+            tm_val.queue_id = 0;
 
-        if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
-            bcmbal_tm_queue_ref val = { };
-            if (single_tag && ether_type == EAP_ETHER_TYPE) {
-                val.sched_id = get_default_tm_sched_id(access_intf_id, downstream);
-                val.queue_id = 0;
+            BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.type, BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE);
+            BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.tm_sched.id, tm_val.sched_id);
+            BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.fixed_queue.queue_id, tm_val.queue_id);
 
-            } else {
-                val.sched_id = get_tm_sched_id(access_intf_id, onu_id, uni_id, downstream); // Subscriber Scheduler
-                val.queue_id = get_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, downstream);
+            OPENOLT_LOG(DEBUG, openolt_log_id, "direction = %s, queue_id = %d, sched_id = %d, intf_type %s\n", \
+                flow_type.c_str(), tm_val.queue_id, tm_val.sched_id, \
+                GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type));
+        } else {
+            if (key.flow_type == BCMOLT_FLOW_TYPE_DOWNSTREAM) {
+                tm_val.sched_id = get_tm_sched_id(access_intf_id, onu_id, uni_id, downstream);
+
+                    if (qos_type == BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE) {
+                        // Queue 0 on DS subscriber scheduler
+                        tm_val.queue_id = 0;
+
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.type, qos_type);
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.tm_sched.id, tm_val.sched_id);
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.fixed_queue.queue_id, tm_val.queue_id);
+
+                        OPENOLT_LOG(DEBUG, openolt_log_id, "direction = %s, queue_id = %d, sched_id = %d, intf_type %s\n", \
+                            downstream.c_str(), tm_val.queue_id, tm_val.sched_id, \
+                            GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type));
+
+                    } else if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE) {
+                        /* Fetch TM QMP ID mapped to DS subscriber scheduler */
+                        tm_qmp_id = tm_q_set_id = get_tm_qmp_id(tm_val.sched_id, access_intf_id, onu_id, uni_id);
+
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.type, qos_type);
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.tm_sched.id, tm_val.sched_id);
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.priority_to_queue.tm_qmp_id, tm_qmp_id);
+                        BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.priority_to_queue.tm_q_set_id, tm_q_set_id);
+
+                        OPENOLT_LOG(DEBUG, openolt_log_id, "direction = %s, q_set_id = %d, sched_id = %d, intf_type %s\n", \
+                            downstream.c_str(), tm_q_set_id, tm_val.sched_id, \
+                            GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type));
+                    }
+            } else if (key.flow_type == BCMOLT_FLOW_TYPE_UPSTREAM) {
+                // NNI Scheduler ID
+                tm_val.sched_id = get_default_tm_sched_id(network_intf_id, upstream);
+                if (qos_type == BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE) {
+                    // Queue 0 on NNI scheduler
+                    tm_val.queue_id = 0;
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.type, qos_type);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.tm_sched.id, tm_val.sched_id);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.fixed_queue.queue_id, tm_val.queue_id);
+
+                    OPENOLT_LOG(DEBUG, openolt_log_id, "direction = %s, queue_id = %d, sched_id = %d, intf_type %s\n", \
+                        upstream.c_str(), tm_val.queue_id, tm_val.sched_id, \
+                        GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type));
+
+                } else if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE) {
+                    /* Fetch TM QMP ID mapped to US NNI scheduler */
+                    tm_qmp_id = tm_q_set_id = get_tm_qmp_id(tm_val.sched_id, access_intf_id, onu_id, uni_id);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.type, qos_type);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.tm_sched.id, tm_val.sched_id);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.priority_to_queue.tm_qmp_id, tm_qmp_id);
+                    BCMOLT_MSG_FIELD_SET(&cfg , egress_qos.u.priority_to_queue.tm_q_set_id, tm_q_set_id);
+
+                    OPENOLT_LOG(DEBUG, openolt_log_id, "direction = %s, q_set_id = %d, sched_id = %d, intf_type %s\n", \
+                        upstream.c_str(), tm_q_set_id, tm_val.sched_id, \
+                        GET_FLOW_INTERFACE_TYPE(cfg.data.ingress_intf.intf_type));
+                }
             }
-            BCM_LOG(INFO, openolt_log_id, "direction = %s, queue_id = %d, sched_id = %d\n", \
-                    downstream.c_str(), val.queue_id, val.sched_id);
-            BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);
-        } else if (key.flow_type == BCMBAL_FLOW_TYPE_UPSTREAM) {
-            bcmbal_tm_sched_id val1;
-            val1 = get_tm_sched_id(access_intf_id, onu_id, uni_id, upstream); // DBA Scheduler ID
-            BCMBAL_CFG_PROP_SET(&cfg, flow, dba_tm_sched_id, val1);
-
-            bcmbal_tm_queue_ref val2 = { };
-            val2.sched_id = get_default_tm_sched_id(network_intf_id, upstream); // NNI Scheduler ID
-            val2.queue_id = get_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, upstream); // Queue on NNI
-            BCM_LOG(INFO, openolt_log_id, "direction = %s, queue_id = %d, sched_id = %d\n", \
-                    upstream.c_str(), val2.queue_id, val2.sched_id);
-            BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val2);
         }
     }
 
-    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id,  "Flow add failed\n");
-        return bcm_to_grpc_err(err, "flow add failed");
-    }
+    BCMOLT_MSG_FIELD_SET(&cfg, state, BCMOLT_FLOW_STATE_ENABLE);
+    BCMOLT_MSG_FIELD_SET(&cfg, statistics, BCMOLT_CONTROL_STATE_ENABLE);
+#ifdef FLOW_CHECKER
+    //Flow Checker, To avoid duplicate flow. 
+    if (flow_id_counters != 0) {
+        bool b_duplicate_flow = false;
+        for (int flowid=0; flowid < flow_id_counters; flowid++) {
+            int flow_index = flow_id_data[flowid][0];
+            b_duplicate_flow = (cfg.data.onu_id == get_flow_status(flow_index, flow_id_data[flowid][1], ONU_ID)) && \
+                (key.flow_type == flow_id_data[flowid][1]) && \
+                (cfg.data.svc_port_id == get_flow_status(flow_index, flow_id_data[flowid][1], SVC_PORT_ID)) && \
+                (cfg.data.priority == get_flow_status(flow_index, flow_id_data[flowid][1], PRIORITY)) && \
+                (cfg.data.cookie == get_flow_status(flow_index, flow_id_data[flowid][1], COOKIE)) && \
+                (cfg.data.ingress_intf.intf_type == get_flow_status(flow_index, flow_id_data[flowid][1], INGRESS_INTF_TYPE)) && \
+                (cfg.data.ingress_intf.intf_id == get_flow_status(flow_index, flow_id_data[flowid][1], INGRESS_INTF_ID)) && \
+                (cfg.data.egress_intf.intf_type == get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_INTF_TYPE)) && \
+                (cfg.data.egress_intf.intf_id == get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_INTF_ID)) && \
+                (c_val.o_vid == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_O_VID)) && \
+                (c_val.o_pbits == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_O_PBITS)) && \
+                (c_val.i_vid == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_I_VID)) && \
+                (c_val.i_pbits == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_I_PBITS)) && \
+                (c_val.ether_type == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_ETHER_TYPE)) && \
+                (c_val.ip_proto == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_IP_PROTO)) && \
+                (c_val.src_port == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_SRC_PORT)) && \
+                (c_val.dst_port == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_DST_PORT)) && \
+                (c_val.pkt_tag_type == get_flow_status(flow_index, flow_id_data[flowid][1], CLASSIFIER_PKT_TAG_TYPE)) && \
+                (cfg.data.egress_qos.type == get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_TYPE)) && \
+                (cfg.data.egress_qos.u.fixed_queue.queue_id == get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_QUEUE_ID)) && \
+                (cfg.data.egress_qos.tm_sched.id == get_flow_status(flow_index, flow_id_data[flowid][1], EGRESS_QOS_TM_SCHED_ID)) && \
+                (a_val.cmds_bitmask == get_flow_status(flowid, flow_id_data[flowid][1], ACTION_CMDS_BITMASK)) && \
+                (a_val.o_vid == get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_O_VID)) && \
+                (a_val.i_vid == get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_I_VID)) && \
+                (a_val.o_pbits == get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_O_PBITS)) && \
+                (a_val.i_pbits == get_flow_status(flow_index, flow_id_data[flowid][1], ACTION_I_PBITS)) && \
+                (cfg.data.state == get_flow_status(flowid, flow_id_data[flowid][1], STATE)); 
+#ifdef SHOW_FLOW_PARAM
+            // Flow Parameter
+            FLOW_PARAM_LOG();
+#endif
 
-    // register_new_flow(key);
+            if (b_duplicate_flow) {
+                FLOW_LOG(WARNING, "Flow duplicate", 0);
+                return bcm_to_grpc_err(BCM_ERR_ALREADY, "flow exists");
+            }
+        }
+    }
+#endif
+
+    bcmos_errno err = bcmolt_cfg_set(dev_id, &cfg.hdr);
+    if (err) {
+        FLOW_LOG(ERROR, "Flow add failed", err);
+        return bcm_to_grpc_err(err, "flow add failed");
+    } else {
+        FLOW_LOG(INFO, "Flow add ok", err);
+        bcmos_fastlock_lock(&data_lock);
+        flow_id_data[flow_id_counters][0] = key.flow_id;
+        flow_id_data[flow_id_counters][1] = key.flow_type;
+        flow_id_counters += 1;
+        bcmos_fastlock_unlock(&data_lock, 0);
+    }
 
     return Status::OK;
 }
 
 Status FlowRemove_(uint32_t flow_id, const std::string flow_type) {
 
-    bcmbal_flow_cfg cfg;
-    bcmbal_flow_key key = { };
+    bcmolt_flow_cfg cfg;
+    bcmolt_flow_key key = { };
 
-    key.flow_id = (bcmbal_flow_id) flow_id;
+    key.flow_id = (bcmolt_flow_id) flow_id;
     key.flow_id = flow_id;
     if (flow_type.compare(upstream) == 0 ) {
-        key.flow_type = BCMBAL_FLOW_TYPE_UPSTREAM;
+        key.flow_type = BCMOLT_FLOW_TYPE_UPSTREAM;
     } else if (flow_type.compare(downstream) == 0) {
-        key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
+        key.flow_type = BCMOLT_FLOW_TYPE_DOWNSTREAM;
     } else {
-        BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
+        OPENOLT_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
         return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
     }
 
     bcmos_fastlock_lock(&data_lock);
     uint32_t port_no = flowid_to_port[key.flow_id];
-    if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
+    if (key.flow_type == BCMOLT_FLOW_TYPE_DOWNSTREAM) {
         flowid_to_gemport.erase(key.flow_id);
         port_to_flows[port_no].erase(key.flow_id);
         if (port_to_flows[port_no].empty()) port_to_flows.erase(port_no);
@@ -1242,20 +2158,86 @@
     }
     bcmos_fastlock_unlock(&data_lock, 0);
 
-    BCMBAL_CFG_INIT(&cfg, flow, key);
+    BCMOLT_CFG_INIT(&cfg, flow, key);
 
-
-    bcmos_errno err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
+    bcmos_errno err = bcmolt_cfg_clear(dev_id, &cfg.hdr);
     if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Error %d while removing flow %d, %s\n",
+        OPENOLT_LOG(ERROR, openolt_log_id, "Error %d while removing flow %d, %s\n",
             err, flow_id, flow_type.c_str());
         return Status(grpc::StatusCode::INTERNAL, "Failed to remove flow");
     }
 
-    BCM_LOG(INFO, openolt_log_id, "Flow %d, %s removed\n", flow_id, flow_type.c_str());
+    bcmos_fastlock_lock(&data_lock);
+    for (int flowid=0; flowid < flow_id_counters; flowid++) {
+        if (flow_id_data[flowid][0] == flow_id && flow_id_data[flowid][1] == key.flow_type) {
+            flow_id_counters -= 1;
+            for (int i=flowid; i < flow_id_counters; i++) {
+                flow_id_data[i][0] = flow_id_data[i + 1][0]; 
+                flow_id_data[i][1] = flow_id_data[i + 1][1]; 
+            }
+            break;
+        }
+    }
+    bcmos_fastlock_unlock(&data_lock, 0);
+
+    OPENOLT_LOG(INFO, openolt_log_id, "Flow %d, %s removed\n", flow_id, flow_type.c_str());
     return Status::OK;
 }
 
+bcmos_errno CreateDefaultSched(uint32_t intf_id, const std::string direction) {
+    bcmos_errno err;
+    bcmolt_tm_sched_cfg tm_sched_cfg;
+    bcmolt_tm_sched_key tm_sched_key = {.id = 1};
+    tm_sched_key.id = get_default_tm_sched_id(intf_id, direction);
+
+    // bcmbal_tm_sched_owner
+    BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key);
+
+    /**< The output of the tm_sched object instance */
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.type, BCMOLT_TM_SCHED_OUTPUT_TYPE_INTERFACE);
+
+    if (direction.compare(upstream) == 0) {
+        // In upstream it is NNI scheduler
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.u.interface.interface_ref.intf_type, BCMOLT_INTERFACE_TYPE_NNI);
+    } else if (direction.compare(downstream) == 0) {
+        // In downstream it is PON scheduler
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.u.interface.interface_ref.intf_type, BCMOLT_INTERFACE_TYPE_PON);
+    }
+
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.u.interface.interface_ref.intf_id, intf_id);
+
+    // bcmbal_tm_sched_type
+    // set the deafult policy to strict priority
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, sched_type, BCMOLT_TM_SCHED_TYPE_SP);
+
+    // num_priorities: Max number of strict priority scheduling elements
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, num_priorities, 8);
+
+    // bcmbal_tm_shaping
+    uint32_t cir = 1000000;
+    uint32_t pir = 1000000;
+    uint32_t burst = 65536;
+    OPENOLT_LOG(INFO, openolt_log_id, "applying traffic shaping in %s pir=%u, burst=%u\n",
+       direction.c_str(), pir, burst);
+    BCMOLT_FIELD_SET_PRESENT(&tm_sched_cfg.data.rate, tm_shaping, pir);
+    BCMOLT_FIELD_SET_PRESENT(&tm_sched_cfg.data.rate, tm_shaping, burst);
+    // FIXME: Setting CIR, results in BAL throwing error 'tm_sched minimum rate is not supported yet'
+    // BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.cir, cir);
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.pir, pir);
+    BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.burst, burst);
+
+    err = bcmolt_cfg_set(dev_id, &tm_sched_cfg.hdr);
+    if (err) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create %s scheduler, id %d, intf_id %d, err %d\n", \
+            direction.c_str(), tm_sched_key.id, intf_id, err);
+        return err;
+    }
+
+    OPENOLT_LOG(INFO, openolt_log_id, "Create %s scheduler success, id %d, intf_id %d\n", \
+        direction.c_str(), tm_sched_key.id, intf_id);
+    return BCM_ERR_OK;
+}
+
 bcmos_errno CreateSched(std::string direction, uint32_t intf_id, uint32_t onu_id, uint32_t uni_id, uint32_t port_no,
                  uint32_t alloc_id, tech_profile::AdditionalBW additional_bw, uint32_t weight, uint32_t priority,
                  tech_profile::SchedulingPolicy sched_policy, tech_profile::TrafficShapingInfo tf_sh_info) {
@@ -1263,115 +2245,170 @@
     bcmos_errno err;
 
     if (direction == downstream) {
+        bcmolt_tm_sched_cfg tm_sched_cfg;
+        bcmolt_tm_sched_key tm_sched_key = {.id = 1};
+        tm_sched_key.id = get_tm_sched_id(intf_id, onu_id, uni_id, direction);
 
-        bcmbal_tm_sched_cfg cfg;
-        bcmbal_tm_sched_key key = { };
-        key.id = get_tm_sched_id(intf_id, onu_id, uni_id, direction);
-        key.dir = BCMBAL_TM_SCHED_DIR_DS;
+        // bcmbal_tm_sched_owner
+        // In downstream it is sub_term scheduler
+        BCMOLT_CFG_INIT(&tm_sched_cfg, tm_sched, tm_sched_key);
 
-        BCMBAL_CFG_INIT(&cfg, tm_sched, key);
+        /**< The output of the tm_sched object instance */
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.type, BCMOLT_TM_SCHED_OUTPUT_TYPE_TM_SCHED);
 
-        {
-            // bcmbal_tm_sched_owner
-            // In downstream it is sub_term scheduler
-            bcmbal_tm_sched_owner tm_sched_owner = { };
-            tm_sched_owner.type = BCMBAL_TM_SCHED_OWNER_TYPE_SUB_TERM;
-            tm_sched_owner.u.sub_term.intf_id = intf_id;
-            tm_sched_owner.u.sub_term.sub_term_id = onu_id;
-            BCMBAL_CFG_PROP_SET(&cfg, tm_sched, owner, tm_sched_owner);
+        // bcmbal_tm_sched_parent
+        // The parent for the sub_term scheduler is the PON scheduler in the downstream
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.u.tm_sched.tm_sched_id, get_default_tm_sched_id(intf_id, direction));
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, attachment_point.u.tm_sched.tm_sched_param.u.priority.priority, priority);
+        /* removed by BAL v3.0, N/A - No direct attachment point of type ONU, same functionality may 
+           be achieved using the' virtual' type of attachment.
+        tm_sched_owner.u.sub_term.intf_id = intf_id;
+        tm_sched_owner.u.sub_term.sub_term_id = onu_id;
+        */
 
-            // bcmbal_tm_sched_type
-            // set the deafult policy to strict priority
-            BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_type, BCMBAL_TM_SCHED_TYPE_SP);
+        // bcmbal_tm_sched_type
+        // set the deafult policy to strict priority
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, sched_type, BCMOLT_TM_SCHED_TYPE_SP);
 
-            // bcmbal_tm_sched_parent
-            // The parent for the sub_term scheduler is the PON scheduler in the downstream
-            bcmbal_tm_sched_parent tm_sched_parent = { };
-            tm_sched_parent.presence_mask |= (BCMBAL_TM_SCHED_PARENT_ID_SCHED_ID);
-            tm_sched_parent.sched_id = get_default_tm_sched_id(intf_id, downstream);
-            tm_sched_parent.presence_mask |= (BCMBAL_TM_SCHED_PARENT_ID_PRIORITY);
-            tm_sched_parent.priority = 1; // TODO: Hardcoded priority as 1
-            BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_parent, tm_sched_parent);
+        // num_priorities: Max number of strict priority scheduling elements
+        BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, num_priorities, 8);
 
-            // num_priorities: Max number of strict priority scheduling elements
-            BCMBAL_CFG_PROP_SET(&cfg, tm_sched, num_priorities, 8); // TODO: hardcoded 8 priorities.
-
-            // bcmbal_tm_shaping
-            if (tf_sh_info.cir() >= 0 && tf_sh_info.pir() > 0) {
-                bcmbal_tm_shaping rate = {};
-                uint32_t cir = tf_sh_info.cir();
-                uint32_t pir = tf_sh_info.pir();
-                uint32_t burst = tf_sh_info.pbs();
-                BCM_LOG(INFO, openolt_log_id, "applying traffic shaping in DL cir=%u, pir=%u, burst=%u\n",
-                   cir, pir, burst);
-                rate.presence_mask = BCMBAL_TM_SHAPING_ID_NONE;
-                rate.presence_mask |= BCMBAL_TM_SHAPING_ID_PIR;
-                rate.presence_mask |= BCMBAL_TM_SHAPING_ID_BURST;
-                // FIXME: Setting CIR, results in BAL throwing error 'tm_sched minimum rate is not supported yet'
-                // rate.cir = cir;
-                rate.pir = pir;
-                rate.burst = burst;
-
-                BCMBAL_CFG_PROP_SET(&cfg, tm_sched, rate, rate);
-            }
-
-            // creation_mode
-            // BCMBAL_CFG_PROP_SET(&cfg, tm_sched, creation_mode, BCMBAL_TM_CREATION_MODE_MANUAL);
+        // bcmbal_tm_shaping
+        if (tf_sh_info.cir() >= 0 && tf_sh_info.pir() > 0) {
+            uint32_t cir = tf_sh_info.cir();
+            uint32_t pir = tf_sh_info.pir();
+            uint32_t burst = tf_sh_info.pbs();
+            OPENOLT_LOG(INFO, openolt_log_id, "applying traffic shaping in DL cir=%u, pir=%u, burst=%u\n",
+               cir, pir, burst);
+            BCMOLT_FIELD_SET_PRESENT(&tm_sched_cfg.data.rate, tm_shaping, pir);
+            BCMOLT_FIELD_SET_PRESENT(&tm_sched_cfg.data.rate, tm_shaping, burst);
+            // FIXME: Setting CIR, results in BAL throwing error 'tm_sched minimum rate is not supported yet'
+            //BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.cir, cir);
+            BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.pir, pir);
+            BCMOLT_MSG_FIELD_SET(&tm_sched_cfg, rate.burst, burst);
         }
 
-        err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
+        err = bcmolt_cfg_set(dev_id, &tm_sched_cfg.hdr);
         if (err) {
-            BCM_LOG(ERROR, openolt_log_id, "Failed to create downstream subscriber scheduler, id %d, intf_id %d, \
-                    onu_id %d, uni_id %d, port_no %u\n", key.id, intf_id, onu_id,uni_id,port_no);
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create downstream subscriber scheduler, id %d, \
+intf_id %d, onu_id %d, uni_id %d, port_no %u\n", tm_sched_key.id, intf_id, onu_id, \
+                    uni_id, port_no);
             return err;
         }
-        BCM_LOG(INFO, openolt_log_id, "Create downstream subscriber sched, id %d, intf_id %d, onu_id %d, \
-                uni_id %d, port_no %u\n", key.id,intf_id,onu_id,uni_id,port_no);
+        OPENOLT_LOG(INFO, openolt_log_id, "Create downstream subscriber sched, id %d, intf_id %d, onu_id %d, \
+uni_id %d, port_no %u\n", tm_sched_key.id, intf_id, onu_id, uni_id, port_no);
 
     } else { //upstream
-        bcmbal_tm_sched_cfg cfg;
-        bcmbal_tm_sched_key key = { };
+        bcmolt_itupon_alloc_cfg cfg;
+        bcmolt_itupon_alloc_key key = { };
+        key.pon_ni = intf_id;
+        key.alloc_id = alloc_id;
+        int bw_granularity = (board_technology == "XGS-PON")?XGS_BANDWIDTH_GRANULARITY:GPON_BANDWIDTH_GRANULARITY;
+        int pir_bw = tf_sh_info.pir();
+        int cir_bw = tf_sh_info.cir();
+        //offset to match bandwidth granularity
+        int offset_pir_bw = pir_bw%bw_granularity;
+        int offset_cir_bw = cir_bw%bw_granularity;
 
-        key.id = get_tm_sched_id(intf_id, onu_id, uni_id, direction);
-        key.dir = BCMBAL_TM_SCHED_DIR_US;
+        pir_bw = pir_bw - offset_pir_bw;
+        cir_bw = cir_bw - offset_cir_bw;
 
-        BCMBAL_CFG_INIT(&cfg, tm_sched, key);
+        BCMOLT_CFG_INIT(&cfg, itupon_alloc, key);
 
-        {
-            // bcmbal_tm_sched_owner: AGG PORT
-            bcmbal_tm_sched_owner tm_sched_owner = { };
-            tm_sched_owner.type = BCMBAL_TM_SCHED_OWNER_TYPE_AGG_PORT;
-            tm_sched_owner.u.agg_port.presence_mask |= bcmbal_tm_sched_owner_agg_port_id_all;
-            tm_sched_owner.u.agg_port.intf_id = intf_id;
-            tm_sched_owner.u.agg_port.sub_term_id = onu_id;
-            tm_sched_owner.u.agg_port.agg_port_id = alloc_id;
-            BCMBAL_CFG_PROP_SET(&cfg, tm_sched, owner, tm_sched_owner);
-
-            // bcmbal_tm_shaping
-            if (tf_sh_info.cir() >= 0 && tf_sh_info.pir() > 0) {
-                bcmbal_tm_shaping rate = {};
-                uint32_t cir = tf_sh_info.cir();
-                uint32_t pir = tf_sh_info.pir();
-                uint32_t burst = tf_sh_info.pbs();
-                BCM_LOG(INFO, openolt_log_id, "applying traffic shaping in UL cir=%u, pir=%u, burst=%u\n",
-                   cir, pir, burst);
-                rate.presence_mask = BCMBAL_TM_SHAPING_ID_ALL;
-                rate.cir = cir;
-                rate.pir = pir;
-                rate.burst = burst;
-
-                BCMBAL_CFG_PROP_SET(&cfg, tm_sched, rate, rate);
-            }
+        switch (additional_bw) {
+            case 2: //AdditionalBW_BestEffort
+                if (pir_bw == 0) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth was set to 0, must be at least \
+%d bytes/sec\n", (board_technology == "XGS-PON")?XGS_BANDWIDTH_GRANULARITY:GPON_BANDWIDTH_GRANULARITY);
+                } else if (pir_bw < cir_bw) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth (%d) can't be less than Guaranteed \
+bandwidth (%d)\n", pir_bw, cir_bw);
+                   return BCM_ERR_PARM;
+                } else if (pir_bw == cir_bw) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth must be greater than Guaranteed \
+bandwidth for additional bandwidth eligibility of type best_effort\n");
+                   return BCM_ERR_PARM;
+                }
+                BCMOLT_MSG_FIELD_SET(&cfg, sla.additional_bw_eligibility, BCMOLT_ADDITIONAL_BW_ELIGIBILITY_BEST_EFFORT);
+                break;
+            case 1: //AdditionalBW_NA
+                if (pir_bw == 0) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth was set to 0, must be at least \
+%d bytes/sec\n", (board_technology == "XGS-PON")?XGS_BANDWIDTH_GRANULARITY:GPON_BANDWIDTH_GRANULARITY);
+                    return BCM_ERR_PARM;
+                } else if (cir_bw == 0) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Guaranteed bandwidth must be greater than zero for \
+additional bandwidth eligibility of type Non-Assured (NA)\n");
+                    return BCM_ERR_PARM;
+                } else if (pir_bw < cir_bw) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth (%d) can't be less than Guaranteed \
+bandwidth (%d)\n", pir_bw, cir_bw);
+                    return BCM_ERR_PARM;
+                } else if (pir_bw == cir_bw) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth must be greater than Guaranteed \
+bandwidth for additional bandwidth eligibility of type non_assured\n");
+                    return BCM_ERR_PARM;
+                }
+                BCMOLT_MSG_FIELD_SET(&cfg, sla.additional_bw_eligibility, BCMOLT_ADDITIONAL_BW_ELIGIBILITY_NON_ASSURED);
+                break;
+            case 0: //AdditionalBW_None
+                if (pir_bw == 0) {
+                    OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth was set to 0, must be at least \
+16000 bytes/sec\n");
+                    return BCM_ERR_PARM;
+                } else if (cir_bw == 0) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth must be equal to Guaranteed bandwidth \
+for additional bandwidth eligibility of type None\n");
+                    return BCM_ERR_PARM;
+                } else if (pir_bw > cir_bw) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth must be equal to Guaranteed bandwidth \
+for additional bandwidth eligibility of type None\n");
+                   OPENOLT_LOG(ERROR, openolt_log_id, "set Maximum bandwidth (%d) to Guaranteed \
+bandwidth in None eligibility\n", pir_bw);
+                   cir_bw = pir_bw;
+                } else if (pir_bw < cir_bw) {
+                   OPENOLT_LOG(ERROR, openolt_log_id, "Maximum bandwidth (%d) can't be less than Guaranteed \
+bandwidth (%d)\n", pir_bw, cir_bw);
+                   OPENOLT_LOG(ERROR, openolt_log_id, "set Maximum bandwidth (%d) to Guaranteed \
+bandwidth in None eligibility\n", pir_bw);
+                   cir_bw = pir_bw;
+                }
+                BCMOLT_MSG_FIELD_SET(&cfg, sla.additional_bw_eligibility, BCMOLT_ADDITIONAL_BW_ELIGIBILITY_NONE);
+                break;
+            default:
+                return BCM_ERR_PARM;
         }
+        /* CBR Real Time Bandwidth which require shaping of the bandwidth allocations
+           in a fine granularity. */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.cbr_rt_bw, 0);
+        /* Fixed Bandwidth with no critical requirement of shaping */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.cbr_nrt_bw, 0);
+        /* Dynamic bandwidth which the OLT is committed to allocate upon demand */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.guaranteed_bw, cir_bw);
+        /* Maximum allocated bandwidth allowed for this alloc ID */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.maximum_bw, pir_bw);
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.alloc_type, BCMOLT_ALLOC_TYPE_NSR);
+        /* Set to True for AllocID with CBR RT Bandwidth that requires compensation 
+           for skipped allocations during quiet window */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.cbr_rt_compensation, BCMOS_FALSE);
+        /**< Allocation Profile index for CBR non-RT Bandwidth */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.cbr_nrt_ap_index, 0);
+        /**< Allocation Profile index for CBR RT Bandwidth */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.cbr_rt_ap_index, 0);
+        /**< Alloc ID Weight used in case of Extended DBA mode */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.weight, 0);
+        /**< Alloc ID Priority used in case of Extended DBA mode */
+        BCMOLT_MSG_FIELD_SET(&cfg, sla.priority, 0);
+        BCMOLT_MSG_FIELD_SET(&cfg, onu_id, onu_id);
 
-        err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
+        err = bcmolt_cfg_set(dev_id, &cfg.hdr);
         if (err) {
-            BCM_LOG(ERROR, openolt_log_id, "Failed to create upstream DBA sched, id %d, intf_id %d, onu_id %d, uni_id %d,\
-                    port_no %u, alloc_id %d\n", key.id, intf_id, onu_id,uni_id,port_no,alloc_id);
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create upstream bandwidth allocation, intf_id %d, onu_id %d, uni_id %d,\
+port_no %u, alloc_id %d, err %d\n", intf_id, onu_id,uni_id,port_no,alloc_id, err);
             return err;
         }
-        BCM_LOG(INFO, openolt_log_id, "Create upstream DBA sched, id %d, intf_id %d, onu_id %d, uni_id %d, port_no %u, \
-                alloc_id %d\n", key.id,intf_id,onu_id,uni_id,port_no,alloc_id);
+        OPENOLT_LOG(INFO, openolt_log_id, "Create upstream bandwidth allocation, intf_id %d, onu_id %d, uni_id %d, port_no %u, \
+alloc_id %d\n", intf_id,onu_id,uni_id,port_no,alloc_id);
     }
 
     return BCM_ERR_OK;
@@ -1394,15 +2431,11 @@
 
     for (int i = 0; i < traffic_scheds->traffic_scheds_size(); i++) {
         tech_profile::TrafficScheduler traffic_sched = traffic_scheds->traffic_scheds(i);
-        if (traffic_sched.direction() == tech_profile::Direction::UPSTREAM) {
-            direction = upstream;
-        } else if (traffic_sched.direction() == tech_profile::Direction::DOWNSTREAM) {
-            direction = downstream;
-        }
-        else {
-            BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", traffic_sched.direction());
-            return Status::CANCELLED;
-        }
+
+        direction = GetDirection(traffic_sched.direction());
+        if (direction.compare("direction-not-supported") == 0)
+            return bcm_to_grpc_err(BCM_ERR_PARM, "direction-not-supported");
+
         alloc_id = traffic_sched.alloc_id();
         sched_config = traffic_sched.scheduler();
         additional_bw = sched_config.additional_bw();
@@ -1419,39 +2452,47 @@
     return Status::OK;
 }
 
-bcmos_errno RemoveSched(int intf_id, int onu_id, int uni_id, std::string direction) {
+bcmos_errno RemoveSched(int intf_id, int onu_id, int uni_id, int alloc_id, std::string direction) {
 
     bcmos_errno err;
 
-    bcmbal_tm_sched_cfg tm_cfg_us;
-    bcmbal_tm_sched_key tm_key_us = { };
-
-    if (is_tm_sched_id_present(intf_id, onu_id, uni_id, direction)) {
-        tm_key_us.id = get_tm_sched_id(intf_id, onu_id, uni_id, direction);
-    } else {
-        BCM_LOG(INFO, openolt_log_id, "schduler not present in %s\n", direction.c_str());
-        return BCM_ERR_OK;
-    }
     if (direction == upstream) {
-        tm_key_us.dir = BCMBAL_TM_SCHED_DIR_US;
-    } else {
-        tm_key_us.dir = BCMBAL_TM_SCHED_DIR_DS;
-    }
+        bcmolt_itupon_alloc_cfg cfg;
+        bcmolt_itupon_alloc_key key = { };
+        key.pon_ni = intf_id;
+        key.alloc_id = alloc_id;
 
-    BCMBAL_CFG_INIT(&tm_cfg_us, tm_sched, tm_key_us);
+        BCMOLT_CFG_INIT(&cfg, itupon_alloc, key); 
+        err = bcmolt_cfg_clear(dev_id, &cfg.hdr);
+        if (err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to remove scheduler sched, direction = %s, intf_id %d, alloc_id %d, err %d\n", \
+                direction.c_str(), intf_id, alloc_id, err);
+            return err;
+        }
+        OPENOLT_LOG(INFO, openolt_log_id, "Removed sched, direction = %s, intf_id %d, alloc_id %d\n", \
+            direction.c_str(), intf_id, alloc_id);
+    } else if (direction == downstream) {
+        bcmolt_tm_sched_cfg cfg;
+        bcmolt_tm_sched_key key = { };
 
-    err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(tm_cfg_us.hdr));
-    if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to remove scheduler sched, direction = %s, id %d, intf_id %d, onu_id %d\n", \
-                direction.c_str(), tm_key_us.id, intf_id, onu_id);
-        return err;
+        if (is_tm_sched_id_present(intf_id, onu_id, uni_id, direction)) {
+            key.id = get_tm_sched_id(intf_id, onu_id, uni_id, direction);
+        } else {
+            OPENOLT_LOG(INFO, openolt_log_id, "schduler not present in %s, err %d\n", direction.c_str(), err);
+            return BCM_ERR_OK;
+        }
+        BCMOLT_CFG_INIT(&cfg, tm_sched, key);
+        err = bcmolt_cfg_clear(dev_id, &(cfg.hdr));
+        if (err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to remove scheduler, direction = %s, id %d, intf_id %d, onu_id %d\n", \
+                direction.c_str(), key.id, intf_id, onu_id);
+            return err;
+        }
+        OPENOLT_LOG(INFO, openolt_log_id, "Removed sched, direction = %s, id %d, intf_id %d, onu_id %d\n", \
+            direction.c_str(), key.id, intf_id, onu_id);
     }
 
     free_tm_sched_id(intf_id, onu_id, uni_id, direction);
-
-    BCM_LOG(INFO, openolt_log_id, "Removed sched, direction = %s, id %d, intf_id %d, onu_id %d\n", \
-            direction.c_str(), tm_key_us.id, intf_id, onu_id);
-
     return BCM_ERR_OK;
 }
 
@@ -1464,16 +2505,13 @@
 
     for (int i = 0; i < traffic_scheds->traffic_scheds_size(); i++) {
         tech_profile::TrafficScheduler traffic_sched = traffic_scheds->traffic_scheds(i);
-        if (traffic_sched.direction() == tech_profile::Direction::UPSTREAM) {
-            direction = upstream;
-        } else if (traffic_sched.direction() == tech_profile::Direction::DOWNSTREAM) {
-            direction = downstream;
-        }
-        else {
-            BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", traffic_sched.direction());
-            return Status::CANCELLED;
-        }
-        err = RemoveSched(intf_id, onu_id, uni_id, direction);
+
+        direction = GetDirection(traffic_sched.direction());
+        if (direction.compare("direction-not-supported") == 0)
+            return bcm_to_grpc_err(BCM_ERR_PARM, "direction-not-supported");
+
+        int alloc_id = traffic_sched.alloc_id();
+        err = RemoveSched(intf_id, onu_id, uni_id, alloc_id, direction);
         if (err) {
             return bcm_to_grpc_err(err, "error-removing-traffic-scheduler");
         }
@@ -1481,85 +2519,195 @@
     return Status::OK;
 }
 
-bcmos_errno CreateQueue(std::string direction, uint32_t access_intf_id, uint32_t onu_id, uint32_t uni_id, uint32_t priority,
-                        uint32_t gemport_id) {
+bcmos_errno CreateTrafficQueueMappingProfile(uint32_t sched_id, uint32_t intf_id, uint32_t onu_id, uint32_t uni_id, \
+                                             std::string direction, std::vector<uint32_t> tmq_map_profile) {
     bcmos_errno err;
-    bcmbal_tm_queue_cfg cfg;
-    bcmbal_tm_queue_key key = { };
-    BCM_LOG(INFO, openolt_log_id, "creating queue. access_intf_id = %d, onu_id = %d, uni_id = %d \
-            gemport_id = %d, direction = %s\n", access_intf_id, onu_id, uni_id, gemport_id, direction.c_str());
-    if (direction == downstream) {
-        // In the downstream, the queues are on the 'sub term' scheduler
-        // There is one queue per gem port
-        key.sched_dir = BCMBAL_TM_SCHED_DIR_DS;
-        key.sched_id = get_tm_sched_id(access_intf_id, onu_id, uni_id, direction);
-        key.id = get_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, direction);
+    bcmolt_tm_qmp_cfg tm_qmp_cfg;
+    bcmolt_tm_qmp_key tm_qmp_key;
+    bcmolt_arr_u8_8 pbits_to_tmq_id = {0};
 
-    } else {
-        queue_map_key_tuple map_key(access_intf_id, onu_id, uni_id, gemport_id, direction);
-        if (queue_map.count(map_key) > 0) {
-            BCM_LOG(INFO, openolt_log_id, "upstream queue exists for intf_id %d, onu_id %d, uni_id %d\n. Not re-creating", \
-                    access_intf_id, onu_id, uni_id); 
-            return BCM_ERR_OK;
-        }
-        key.sched_dir = BCMBAL_TM_SCHED_DIR_US;
-        key.sched_id = get_default_tm_sched_id(nni_intf_id, direction);
-        if (priority > 7) {
-            return BCM_ERR_RANGE;
-        }
-        // There are 8 queues (one per p-bit)
-        key.id = us_fixed_queue_id_list[priority];
-        update_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, direction, key.id);
-        // FIXME: The upstream queues have to be created once only.
-        // The upstream queues on the NNI scheduler are shared by all subscribers.
-        // When the first scheduler comes in, the queues get created, and are re-used by all others.
-        // Also, these queues should be present until the last subscriber exits the system.
-        // One solution is to have these queues always, i.e., create it as soon as OLT is enabled.
+    int tm_qmp_id = get_tm_qmp_id(sched_id, intf_id, onu_id, uni_id, tmq_map_profile);
+    if (tm_qmp_id == -1) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create tm queue mapping profile. Max allowed profile count is 16.\n");
     }
-    BCM_LOG(INFO, openolt_log_id, "queue assigned queue_id = %d\n", key.id);
 
-    BCMBAL_CFG_INIT(&cfg, tm_queue, key);
+    tm_qmp_key.id = tm_qmp_id;
+    for (uint32_t priority=0; priority<tmq_map_profile.size(); priority++) {
+        pbits_to_tmq_id.arr[priority] = tmq_map_profile[priority];
+    }
 
-    BCMBAL_CFG_PROP_SET(&cfg, tm_queue, priority, priority);
+    BCMOLT_CFG_INIT(&tm_qmp_cfg, tm_qmp, tm_qmp_key);
+    BCMOLT_MSG_FIELD_SET(&tm_qmp_cfg, type, BCMOLT_TM_QMP_TYPE_PBITS);
+    BCMOLT_MSG_FIELD_SET(&tm_qmp_cfg, pbits_to_tmq_id, pbits_to_tmq_id);
+    BCMOLT_MSG_FIELD_SET(&tm_qmp_cfg, ref_count, 0);
+    BCMOLT_MSG_FIELD_SET(&tm_qmp_cfg, state, BCMOLT_CONFIG_STATE_CONFIGURED);
 
-    // BCMBAL_CFG_PROP_SET(&cfg, tm_queue, creation_mode, BCMBAL_TM_CREATION_MODE_MANUAL);
-
-
-    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
+    err = bcmolt_cfg_set(dev_id, &tm_qmp_cfg.hdr);
     if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to create subscriber tm queue, direction = %s, id %d, sched_id %d, \
-                intf_id %d, onu_id %d, uni_id %d\n", \
-                direction.c_str(), key.id, key.sched_id, access_intf_id, onu_id, uni_id);
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create tm queue mapping profile, id %d\n", \
+            tm_qmp_key.id);
         return err;
     }
 
-    BCM_LOG(INFO, openolt_log_id, "Created tm_queue, direction %s, id %d, intf_id %d, onu_id %d, uni_id %d", \
-            direction.c_str(), key.id, access_intf_id, onu_id, uni_id);
-
+    OPENOLT_LOG(INFO, openolt_log_id, "Create tm queue mapping profile success, id %d\n", \
+        tm_qmp_key.id);
     return BCM_ERR_OK;
+}
 
+bcmos_errno RemoveTrafficQueueMappingProfile(uint32_t tm_qmp_id) {
+    bcmos_errno err;
+    bcmolt_tm_qmp_cfg tm_qmp_cfg;
+    bcmolt_tm_qmp_key tm_qmp_key;
+    tm_qmp_key.id = tm_qmp_id;
+
+    BCMOLT_CFG_INIT(&tm_qmp_cfg, tm_qmp, tm_qmp_key);
+    err = bcmolt_cfg_clear(dev_id, &tm_qmp_cfg.hdr);
+    if (err) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to remove tm queue mapping profile, id %d\n", \
+            tm_qmp_key.id);
+        return err;
+    }
+
+    OPENOLT_LOG(INFO, openolt_log_id, "Remove tm queue mapping profile success, id %d\n", \
+        tm_qmp_key.id);
+    return BCM_ERR_OK;
+}
+
+bcmos_errno CreateDefaultQueue(uint32_t intf_id, const std::string direction) {
+    bcmos_errno err;
+
+    /* Create 4 Queues on given PON/NNI scheduler */
+    for (int queue_id = 0; queue_id < 4; queue_id++) {
+        bcmolt_tm_queue_cfg tm_queue_cfg;
+        bcmolt_tm_queue_key tm_queue_key = {};
+        tm_queue_key.sched_id = get_default_tm_sched_id(intf_id, direction);
+        tm_queue_key.id = queue_id;
+        if (qos_type == BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE)
+            tm_queue_key.tm_q_set_id = BCMOLT_TM_QUEUE_SET_ID_QSET_NOT_USE;
+        else
+            tm_queue_key.tm_q_set_id = BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT;
+
+        BCMOLT_CFG_INIT(&tm_queue_cfg, tm_queue, tm_queue_key);
+        BCMOLT_MSG_FIELD_SET(&tm_queue_cfg, tm_sched_param.type, BCMOLT_TM_SCHED_PARAM_TYPE_PRIORITY);
+        BCMOLT_MSG_FIELD_SET(&tm_queue_cfg, tm_sched_param.u.priority.priority, queue_id);
+
+        err = bcmolt_cfg_set(dev_id, &tm_queue_cfg.hdr);
+        if (err) {
+            OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create %s tm queue, id %d, sched_id %d, tm_q_set_id %d\n", \
+                    direction.c_str(), tm_queue_key.id, tm_queue_key.sched_id, tm_queue_key.tm_q_set_id);
+            return err;
+        }
+
+        OPENOLT_LOG(INFO, openolt_log_id, "Create %s tm_queue success, id %d, sched_id %d, tm_q_set_id %d\n", \
+                direction.c_str(), tm_queue_key.id, tm_queue_key.sched_id, tm_queue_key.tm_q_set_id);
+    }
+    return BCM_ERR_OK;
+}
+
+bcmos_errno CreateQueue(std::string direction, uint32_t access_intf_id, uint32_t onu_id, uint32_t uni_id, uint32_t priority,
+                        uint32_t gemport_id) {
+    bcmos_errno err;
+    bcmolt_tm_queue_cfg cfg;
+    bcmolt_tm_queue_key key = { };
+    OPENOLT_LOG(INFO, openolt_log_id, "creating %s queue. access_intf_id = %d, onu_id = %d, uni_id = %d \
+gemport_id = %d\n", direction.c_str(), access_intf_id, onu_id, uni_id, gemport_id);
+
+    key.sched_id = (direction.compare(upstream) == 0) ? get_default_tm_sched_id(nni_intf_id, direction) : \
+        get_tm_sched_id(access_intf_id, onu_id, uni_id, direction);
+
+    if (priority > 7) {
+        return BCM_ERR_RANGE;
+    }
+
+    /* FIXME: The upstream queues have to be created once only.
+    The upstream queues on the NNI scheduler are shared by all subscribers.
+    When the first scheduler comes in, the queues get created, and are re-used by all others.
+    Also, these queues should be present until the last subscriber exits the system.
+    One solution is to have these queues always, i.e., create it as soon as OLT is enabled.
+
+    There is one queue per gem port and Queue ID is fetched based on priority_q configuration
+    for each GEM in TECH PROFILE */
+    key.id = queue_id_list[priority];
+
+    if (qos_type == BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE) {
+        // Reset the Queue ID to 0, if it is fixed queue, i.e., there is only one queue for subscriber.
+        key.id = 0;
+        key.tm_q_set_id = BCMOLT_TM_QUEUE_SET_ID_QSET_NOT_USE;
+    }
+    else if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE) {
+        key.tm_q_set_id = get_tm_qmp_id(key.sched_id, access_intf_id, onu_id, uni_id);
+    }
+    else {
+        key.tm_q_set_id = BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT;
+    }
+
+    OPENOLT_LOG(INFO, openolt_log_id, "queue assigned queue_id = %d\n", key.id);
+
+    BCMOLT_CFG_INIT(&cfg, tm_queue, key);
+    BCMOLT_MSG_FIELD_SET(&cfg, tm_sched_param.u.priority.priority, priority);
+
+    err = bcmolt_cfg_set(dev_id, &cfg.hdr);
+    if (err) {
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to create subscriber tm queue, direction = %s, id %d, \
+sched_id %d, tm_q_set_id %d, intf_id %d, onu_id %d, uni_id %d, err %d\n", \
+            direction.c_str(), key.id, key.sched_id, key.tm_q_set_id, access_intf_id, onu_id, uni_id, err);
+        return err;
+    }
+
+    OPENOLT_LOG(INFO, openolt_log_id, "Created tm_queue, direction %s, id %d, sched_id %d, tm_q_set_id %d, \
+intf_id %d, onu_id %d, uni_id %d\n", direction.c_str(), key.id, key.sched_id, key.tm_q_set_id, access_intf_id, onu_id, uni_id);
+    return BCM_ERR_OK;
 }
 
 Status CreateTrafficQueues_(const tech_profile::TrafficQueues *traffic_queues) {
     uint32_t intf_id = traffic_queues->intf_id();
     uint32_t onu_id = traffic_queues->onu_id();
     uint32_t uni_id = traffic_queues->uni_id();
+    uint32_t sched_id;
     std::string direction;
-    unsigned int alloc_id;
     bcmos_errno err;
 
+    qos_type = (traffic_queues->traffic_queues_size() > 1) ? \
+        BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE : BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE;
+
+    if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE) {
+        uint32_t queues_priority_q[traffic_queues->traffic_queues_size()] = {0};
+        std::string queues_pbit_map[traffic_queues->traffic_queues_size()];
+        for (int i = 0; i < traffic_queues->traffic_queues_size(); i++) {
+            tech_profile::TrafficQueue traffic_queue = traffic_queues->traffic_queues(i);
+
+            direction = GetDirection(traffic_queue.direction());
+            if (direction.compare("direction-not-supported") == 0)
+                return bcm_to_grpc_err(BCM_ERR_PARM, "direction-not-supported");
+
+            queues_priority_q[i] = traffic_queue.priority();
+            queues_pbit_map[i] = traffic_queue.pbit_map();
+        }
+
+        std::vector<uint32_t> tmq_map_profile(8, 0);
+        tmq_map_profile = get_tmq_map_profile(get_valid_queues_pbit_map(queues_pbit_map, COUNT_OF(queues_pbit_map)), \
+                                              queues_priority_q, COUNT_OF(queues_priority_q));
+        sched_id = (direction.compare(upstream) == 0) ? get_default_tm_sched_id(nni_intf_id, direction) : \
+            get_tm_sched_id(intf_id, onu_id, uni_id, direction);
+
+        int tm_qmp_id = get_tm_qmp_id(tmq_map_profile);
+        if (tm_qmp_id == -1) {
+            CreateTrafficQueueMappingProfile(sched_id, intf_id, onu_id, uni_id, direction, tmq_map_profile);
+        } else if (tm_qmp_id != -1 && get_tm_qmp_id(sched_id, intf_id, onu_id, uni_id) == -1) {
+            OPENOLT_LOG(INFO, openolt_log_id, "tm queue mapping profile present already with id %d\n", tm_qmp_id);
+            update_sched_qmp_id_map(sched_id, intf_id, onu_id, uni_id, tm_qmp_id);
+        }
+    }
+
     for (int i = 0; i < traffic_queues->traffic_queues_size(); i++) {
         tech_profile::TrafficQueue traffic_queue = traffic_queues->traffic_queues(i);
-        if (traffic_queue.direction() == tech_profile::Direction::UPSTREAM) {
-            direction = upstream;
-        } else if (traffic_queue.direction() == tech_profile::Direction::DOWNSTREAM) {
-            direction = downstream;
-        }
-        else {
-            BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", traffic_queue.direction());
-            return Status::CANCELLED;
-        }
+
+        direction = GetDirection(traffic_queue.direction());
+        if (direction.compare("direction-not-supported") == 0)
+            return bcm_to_grpc_err(BCM_ERR_PARM, "direction-not-supported");
+
         err = CreateQueue(direction, intf_id, onu_id, uni_id, traffic_queue.priority(), traffic_queue.gemport_id());
+
         // If the queue exists already, lets not return failure and break the loop.
         if (err && err != BCM_ERR_ALREADY) {
             return bcm_to_grpc_err(err, "Failed to create queue");
@@ -1568,41 +2716,49 @@
     return Status::OK;
 }
 
-
 bcmos_errno RemoveQueue(std::string direction, uint32_t access_intf_id, uint32_t onu_id, uint32_t uni_id, uint32_t priority,
                         uint32_t gemport_id) {
-    bcmbal_tm_queue_cfg queue_cfg;
-    bcmbal_tm_queue_key queue_key = { };
+    bcmolt_tm_queue_cfg cfg;
+    bcmolt_tm_queue_key key = { };
     bcmos_errno err;
 
     if (direction == downstream) {
-        queue_key.sched_dir = BCMBAL_TM_SCHED_DIR_DS;
-        if (is_tm_queue_id_present(access_intf_id, onu_id, uni_id, gemport_id, direction) && \
-            is_tm_sched_id_present(access_intf_id, onu_id, uni_id, direction)) {
-            queue_key.sched_id = get_tm_sched_id(access_intf_id, onu_id, uni_id, direction);
-            queue_key.id = get_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, direction);
+        if (is_tm_sched_id_present(access_intf_id, onu_id, uni_id, direction)) {
+            key.sched_id = get_tm_sched_id(access_intf_id, onu_id, uni_id, direction);
+            key.id = queue_id_list[priority];
         } else {
-            BCM_LOG(INFO, openolt_log_id, "queue not present in DS. Not clearing");
+            OPENOLT_LOG(INFO, openolt_log_id, "queue not present in DS. Not clearing, access_intf_id %d, onu_id %d, uni_id %d, gemport_id %d, direction %s\n", access_intf_id, onu_id, uni_id, gemport_id, direction.c_str());
             return BCM_ERR_OK;
         }
     } else {
-        free_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, direction);
-        // In the upstream we use pre-created queues on the NNI scheduler that are used by all subscribers.
-        // They should not be removed. So, lets return OK.
+        /* In the upstream we use pre-created queues on the NNI scheduler that are used by all subscribers.
+        They should not be removed. So, lets return OK. */
         return BCM_ERR_OK;
     }
 
-    BCMBAL_CFG_INIT(&queue_cfg, tm_queue, queue_key);
+    if (qos_type == BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE) {
+         key.tm_q_set_id = BCMOLT_TM_QUEUE_SET_ID_QSET_NOT_USE;
+        // Reset the queue id to 0 when using fixed queue.
+        key.id = 0;
+    }
+    else if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE) {
+         key.tm_q_set_id = get_tm_qmp_id(key.sched_id, access_intf_id, onu_id, uni_id);
+    }
+    else {
+         key.tm_q_set_id = BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT;
+    }
 
-    err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(queue_cfg.hdr));
-
+    BCMOLT_CFG_INIT(&cfg, tm_queue, key);
+    err = bcmolt_cfg_clear(dev_id, &(cfg.hdr));
     if (err) {
-        BCM_LOG(ERROR, openolt_log_id, "Failed to remove queue, direction = %s, id %d, sched_id %d, intf_id %d, onu_id %d, uni_id %d\n",
-                direction.c_str(), queue_key.id, queue_key.sched_id, access_intf_id, onu_id, uni_id);
+        OPENOLT_LOG(ERROR, openolt_log_id, "Failed to remove queue, direction = %s, id %d, sched_id %d, \
+tm_q_set_id %d, intf_id %d, onu_id %d, uni_id %d\n",
+                direction.c_str(), key.id, key.sched_id, key.tm_q_set_id, access_intf_id, onu_id, uni_id);
         return err;
     }
 
-    free_tm_queue_id(access_intf_id, onu_id, uni_id, gemport_id, direction);
+    OPENOLT_LOG(INFO, openolt_log_id, "Removed tm_queue, direction %s, id %d, sched_id %d, tm_q_set_id %d, \
+intf_id %d, onu_id %d, uni_id %d\n", direction.c_str(), key.id, key.sched_id, key.tm_q_set_id, access_intf_id, onu_id, uni_id);
 
     return BCM_ERR_OK;
 }
@@ -1612,25 +2768,34 @@
     uint32_t onu_id = traffic_queues->onu_id();
     uint32_t uni_id = traffic_queues->uni_id();
     uint32_t port_no = traffic_queues->port_no();
+    uint32_t sched_id;
     std::string direction;
-    unsigned int alloc_id;
     bcmos_errno err;
 
+    qos_type = (traffic_queues->traffic_queues_size() > 1) ? \
+        BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE : BCMOLT_EGRESS_QOS_TYPE_FIXED_QUEUE;
+
     for (int i = 0; i < traffic_queues->traffic_queues_size(); i++) {
         tech_profile::TrafficQueue traffic_queue = traffic_queues->traffic_queues(i);
-        if (traffic_queue.direction() == tech_profile::Direction::UPSTREAM) {
-            direction = upstream;
-        } else if (traffic_queue.direction() == tech_profile::Direction::DOWNSTREAM) {
-            direction = downstream;
-        } else {
-            BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", traffic_queue.direction());
-            return Status::CANCELLED;
-        }
+
+        direction = GetDirection(traffic_queue.direction());
+        if (direction.compare("direction-not-supported") == 0)
+            return bcm_to_grpc_err(BCM_ERR_PARM, "direction-not-supported");
+
         err = RemoveQueue(direction, intf_id, onu_id, uni_id, traffic_queue.priority(), traffic_queue.gemport_id());
         if (err) {
             return bcm_to_grpc_err(err, "Failed to remove queue");
         }
     }
 
+    if (qos_type == BCMOLT_EGRESS_QOS_TYPE_PRIORITY_TO_QUEUE && (direction.compare(upstream) == 0 || direction.compare(downstream) == 0 && is_tm_sched_id_present(intf_id, onu_id, uni_id, direction))) {
+        sched_id = (direction.compare(upstream) == 0) ? get_default_tm_sched_id(nni_intf_id, direction) : \
+            get_tm_sched_id(intf_id, onu_id, uni_id, direction);
+
+        int tm_qmp_id = get_tm_qmp_id(sched_id, intf_id, onu_id, uni_id);
+        if (free_tm_qmp_id(sched_id, intf_id, onu_id, uni_id, tm_qmp_id)) {
+            RemoveTrafficQueueMappingProfile(tm_qmp_id);
+        }
+    }
     return Status::OK;
 }
diff --git a/agent/src/error_format.h b/agent/src/error_format.h
index 9736456..3928dc1 100644
--- a/agent/src/error_format.h
+++ b/agent/src/error_format.h
@@ -24,8 +24,7 @@
 extern "C"
 {
 #include <bcmos_system.h>
-#include <bal_api.h>
-#include <bal_api_end.h>
+#include <bcmolt_api.h>
 }
 
 grpc::Status bcm_to_grpc_err(bcmos_errno bcm_err, std::string message);
diff --git a/agent/src/indications.cc b/agent/src/indications.cc
index 789702f..1826b77 100644
--- a/agent/src/indications.cc
+++ b/agent/src/indications.cc
@@ -26,8 +26,9 @@
 extern "C"
 {
 #include <bcmos_system.h>
-#include <bal_api.h>
-#include <bal_api_end.h>
+#include <bcmolt_api.h>
+#include <bcmolt_host_api.h>
+#include <bcmolt_api_model_api_structs.h>
 }
 
 using grpc::Status;
@@ -38,20 +39,59 @@
 
 bool subscribed = false;
 uint32_t nni_intf_id = 0;
+#define current_device 0
 
-bcmos_errno OmciIndication(bcmbal_obj *obj);
+static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
 
-std::string bcmbal_to_grpc_intf_type(bcmbal_intf_type intf_type)
+#define INTERFACE_STATE_IF_DOWN(state) \
+       ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
+         state == BCMOLT_INTERFACE_STATE_PROCESSING || \
+         state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
+#define INTERFACE_STATE_IF_UP(state) \
+       ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
+#define ONU_STATE_IF_DOWN(state) \
+       ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
+         state == BCMOLT_ONU_OPERATION_DISABLE || \
+         state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
+#define ONU_STATE_IF_UP(state) \
+       ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
+#define ONU_RANGING_STATE_IF_UP(state) \
+       ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
+#define ONU_RANGING_STATE_IF_DOWN(state) \
+       ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
+#define SET_OPER_STATE(indication,state) \
+       (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
+       indication->set_oper_state("down")
+#define GET_FLOW_TYPE(type) \
+       (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
+       (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
+       (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
+
+std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
 {
-    if (intf_type == BCMBAL_INTF_TYPE_NNI) {
+    if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
         return "nni";
-    } else if (intf_type == BCMBAL_INTF_TYPE_PON) {
+    } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
         return "pon";
+    } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
+        return "host";
     }
     return "unknown";
 }
 
-std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
+std::string bcmolt_to_grpc_flow_intf_type(bcmolt_flow_interface_type intf_type)
+{
+    if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_NNI) {
+        return "nni";
+    } else if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_PON) {
+        return "pon";
+    } else if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_HOST) {
+        return "host";
+    }
+    return "unknown";
+}
+
+/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
     bcmbal_subscriber_terminal_key key;
     bcmbal_subscriber_terminal_cfg sub_term_obj = {};
     uint8_t  *list_mem;// to fetch config details for ONU
@@ -100,553 +140,658 @@
 
     free(list_mem);
     return reg_id;
-}
+}*/
 
-bcmos_errno OltOperIndication(bcmbal_obj *obj) {
+static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::OltIndication* olt_ind = new openolt::OltIndication;
     Status status;
-
-    bcmbal_access_terminal_oper_status_change *acc_term_ind = (bcmbal_access_terminal_oper_status_change *)obj;
     std::string admin_state;
-    if (acc_term_ind->data.admin_state == BCMBAL_STATE_UP) {
-        admin_state = "up";
-    } else {
-        admin_state = "down";
-    }
 
-    if (acc_term_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
-        // Determine device capabilities before transitionto acive state
-        ProbeDeviceCapabilities_();
-        olt_ind->set_oper_state("up");
-    } else {
-        olt_ind->set_oper_state("down");
+    switch (msg->subgroup) {
+        case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
+            admin_state = "up";
+            olt_ind->set_oper_state("up");
+            break;
+        case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
+             admin_state = "down";
+             olt_ind->set_oper_state("down");
+            break;
+        case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
+             admin_state = "failure";
+             olt_ind->set_oper_state("failure");
+            break;
     }
     ind.set_allocated_olt_ind(olt_ind);
 
-    BCM_LOG(INFO, openolt_log_id, "Olt oper status indication, admin_state: %s oper_state: %s\n",
-            admin_state.c_str(),
-            olt_ind->oper_state().c_str());
-
-    oltIndQ.push(ind);
-
-    // Enable all PON interfaces. 
-    // 
-    for (int i = 0; i < NumPonIf_(); i++) {
-        status = EnablePonIf_(i);
-        if (!status.ok()) {
-            // FIXME - raise alarm to report error in enabling PON
+    if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
+        /* register for omci indication */
+        {
+            bcmolt_rx_cfg rx_cfg = {};
+            rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+            rx_cfg.rx_cb = OmciIndication;
+            rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
+            rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
+            bcmolt_ind_subscribe(current_device, &rx_cfg);
         }
-    }
-
-    // Enable all NNI interfaces. 
-    // 
-    for (int i = 0; i < NumNniIf_(); i++) {
-        status = EnableUplinkIf_(i);
-        if (!status.ok()) {
-            // FIXME - raise alarm to report error in enabling PON
-        }
-    }
-
-    /* register for omci indication */
-    {
-        bcmbal_cb_cfg cb_cfg = {};
-        uint16_t ind_subgroup;
-
-        cb_cfg.module = BCMOS_MODULE_ID_NONE;
-        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)OmciIndication;
-        bcmbal_subscribe_ind(0, &cb_cfg);
-    }
-
-    if (acc_term_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
-        ProbePonIfTechnology_();
         state.activate();
     }
     else {
         state.deactivate();
     }
 
-    return BCM_ERR_OK;
+    oltIndQ.push(ind);
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno LosIndication(bcmbal_obj *obj) {
+static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::LosIndication* los_ind = new openolt::LosIndication;
 
-    bcmbal_interface_los* bcm_los_ind = (bcmbal_interface_los *) obj;
-    int intf_id = interface_key_to_port_no(bcm_los_ind->key);
-    std::string status = alarm_status_to_string(bcm_los_ind->data.status);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_PON_INTERFACE:
+            switch (msg->subgroup) {
+                 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
+                 {
+                     bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
+                     int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
+                         BCMOLT_INTERFACE_TYPE_PON);
+                     std::string status = alarm_status_to_string(bcm_los_ind->data.status);
 
-    BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_type: %d intf_id: %d port: %d status %s\n", 
-            bcm_los_ind->key.intf_type, bcm_los_ind->key.intf_id, intf_id, status.c_str());
+                     OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n", 
+                             bcm_los_ind->key.pon_ni, intf_id, status.c_str());
 
-    los_ind->set_intf_id(intf_id);
-    los_ind->set_status(status);
+                     los_ind->set_intf_id(intf_id);
+                     los_ind->set_status(status);
 
-    alarm_ind->set_allocated_los_ind(los_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                     alarm_ind->set_allocated_los_ind(los_ind);
+                     ind.set_allocated_alarm_ind(alarm_ind);
+                     break;
+                 }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno IfIndication(bcmbal_obj *obj) {
+static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
 
-    BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
-        ((bcmbal_interface_oper_status_change *)obj)->key.intf_id );
+    switch (msg->obj_type) { 
+        case BCMOLT_OBJ_ID_PON_INTERFACE:
+            switch (msg->subgroup) {
+                case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
+                { 
+                    bcmolt_pon_interface_key *key = 
+                        &((bcmolt_pon_interface_state_change_completed*)msg)->key;
+                    bcmolt_pon_interface_state_change_completed_data *data = 
+                        &((bcmolt_pon_interface_state_change_completed*)msg)->data;
 
-    intf_ind->set_intf_id(((bcmbal_interface_oper_status_change *)obj)->key.intf_id);
-    if (((bcmbal_interface_oper_status_change *)obj)->data.new_oper_status == BCMBAL_STATUS_UP) {
-        intf_ind->set_oper_state("up");
-    } else {
-        intf_ind->set_oper_state("down");
+                    intf_ind->set_intf_id(key->pon_ni);
+                    SET_OPER_STATE(intf_ind, data->new_state);
+                    ind.set_allocated_intf_ind(intf_ind);
+                    break;
+                }
+            }
+            break;
+        case BCMOLT_OBJ_ID_NNI_INTERFACE:
+            switch (msg->subgroup) {
+                case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
+                {
+                    OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
+                        ((bcmolt_nni_interface_state_change *)msg)->key.id);
+                    bcmolt_nni_interface_key *key = 
+                        &((bcmolt_nni_interface_state_change *)msg)->key;
+                    bcmolt_nni_interface_state_change_data *data = 
+                        &((bcmolt_nni_interface_state_change *)msg)->data;
+
+                    intf_ind->set_intf_id(key->id);
+                    SET_OPER_STATE(intf_ind, data->new_state);
+                    ind.set_allocated_intf_ind(intf_ind);
+                    break;
+                }
+            }
     }
-    ind.set_allocated_intf_ind(intf_ind);
 
     oltIndQ.push(ind);
-
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno IfOperIndication(bcmbal_obj *obj) {
+static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
-    bcmbal_interface_oper_status_change* bcm_if_oper_ind = (bcmbal_interface_oper_status_change *) obj;
 
-    intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(bcm_if_oper_ind->key.intf_type));
-    intf_oper_ind->set_intf_id(bcm_if_oper_ind->key.intf_id);
-
-    if (bcm_if_oper_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
-        intf_oper_ind->set_oper_state("up");
-        if (bcm_if_oper_ind->key.intf_type == BCMBAL_INTF_TYPE_NNI) {
-            nni_intf_id = bcm_if_oper_ind->key.intf_id;
-        }
-    } else {
-        intf_oper_ind->set_oper_state("down");
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_PON_INTERFACE:
+            switch (msg->subgroup) {
+                case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
+                {
+                    bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
+                    bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
+                    intf_oper_ind->set_intf_id(key->pon_ni);
+                    intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
+                    SET_OPER_STATE(intf_oper_ind, data->new_state);
+                    OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
+                        intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
+                    ind.set_allocated_intf_oper_ind(intf_oper_ind);
+                    break;
+                }
+            }
+        case BCMOLT_OBJ_ID_NNI_INTERFACE:
+            switch (msg->subgroup) {
+                case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
+                {
+                    bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
+                    bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
+                    bcmolt_interface intf_id = key->id;
+                    bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
+                    intf_oper_ind->set_intf_id(key->id);
+                    intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
+                    SET_OPER_STATE(intf_oper_ind, data->new_state);           
+                    OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
+                        intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
+                    ind.set_allocated_intf_oper_ind(intf_oper_ind);
+                    break;
+                }
+            }
     }
 
-    BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s, admin_state %d\n",
-        intf_oper_ind->type().c_str(),
-        bcm_if_oper_ind->key.intf_id,
-        intf_oper_ind->oper_state().c_str(),
-        bcm_if_oper_ind->data.admin_state);
-
-    ind.set_allocated_intf_oper_ind(intf_oper_ind);
-
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuAlarmIndication(bcmbal_obj *obj) {
+static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &((bcmbal_subscriber_terminal_sub_term_alarm*)obj)->key;
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
+                {
+                    bcmolt_xgpon_onu_alarms *onu_alarms = 
+                        &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
+                    onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
+                    onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
+                    onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
+                        onu_alarms->lopci_miss));
+                    onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
+                        onu_alarms->lopci_mic_error));
 
-    bcmbal_subscriber_terminal_alarms *alarms =
-        &(((bcmbal_subscriber_terminal_sub_term_alarm*)obj)->data.alarm);
-
-    BCM_LOG(WARNING, openolt_log_id, "onu alarm indication intf_id %d, onu_id %d, alarm: los %d, lob %d, lopc_miss %d, lopc_mic_error %d\n",
-        key->intf_id, key->sub_term_id, alarms->los, alarms->lob, alarms->lopc_miss, alarms->lopc_mic_error);
-
-    onu_alarm_ind->set_intf_id(key->intf_id);
-    onu_alarm_ind->set_onu_id(key->sub_term_id);
-    onu_alarm_ind->set_los_status(alarm_status_to_string(alarms->los));
-    onu_alarm_ind->set_lob_status(alarm_status_to_string(alarms->lob));
-    onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(alarms->lopc_miss));
-    onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(alarms->lopc_mic_error));
-
-    alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                    break;
+                }
+                case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
+                {
+                    bcmolt_gpon_onu_alarms *onu_alarms = 
+                        &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
+                    onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
+                    /* TODO: need to set lofi and loami 
+                        onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
+                        onu_alarm_ind->set_loami_status(alarm_status_to_string(
+                        onu_alarms->loami));
+                    */ 
+                    alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                    break;
+                 }
+        }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuDyingGaspIndication(bcmbal_obj *obj) {
+static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
-    openolt::DyingGaspIndication* dg_ind = new openolt::DyingGaspIndication;
+    openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_dgi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
+                {
+                    bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg;
+                    dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status));
 
-    bcmbal_subscriber_terminal_dgi_data *data =
-        &(((bcmbal_subscriber_terminal_dgi*)obj)->data);
-
-
-    BCM_LOG(WARNING, openolt_log_id, "onu dying-gasp indication, intf_id %d, onu_id %d, alarm %d\n",
-        key->intf_id, key->sub_term_id, data->dgi_status);
-
-    dg_ind->set_intf_id(key->intf_id);
-    dg_ind->set_onu_id(key->sub_term_id);
-    dg_ind->set_status(alarm_status_to_string(data->dgi_status));
-
-    alarm_ind->set_allocated_dying_gasp_ind(dg_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                    break;
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuDiscoveryIndication(bcmbal_cfg *obj) {
+static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
     openolt::SerialNumber* serial_number = new openolt::SerialNumber;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_sub_term_disc*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_PON_INTERFACE:
+            switch (msg->subgroup) {
+                case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
+                {
+                    bcmolt_pon_interface_key *key =
+                        &((bcmolt_pon_interface_onu_discovered *)msg)->key;
 
-    bcmbal_subscriber_terminal_sub_term_disc_data *data =
-        &(((bcmbal_subscriber_terminal_sub_term_disc*)obj)->data);
+                    bcmolt_pon_interface_onu_discovered_data *data = 
+                        &((bcmolt_pon_interface_onu_discovered *)msg)->data;
 
-    bcmbal_serial_number *in_serial_number = &(data->serial_number);
+                    bcmolt_serial_number *in_serial_number = &(data->serial_number);
 
-    BCM_LOG(INFO, openolt_log_id, "onu discover indication, intf_id %d, serial_number %s\n",
-        key->intf_id, serial_number_to_str(in_serial_number).c_str());
+                    OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
+                        key->pon_ni, serial_number_to_str(in_serial_number).c_str());
 
-    onu_disc_ind->set_intf_id(key->intf_id);
-    serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id), 4);
-    serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific), 8);
-    onu_disc_ind->set_allocated_serial_number(serial_number);
-    ind.set_allocated_onu_disc_ind(onu_disc_ind);
+                    onu_disc_ind->set_intf_id(key->pon_ni);
+                    serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
+                    serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
+                    onu_disc_ind->set_allocated_serial_number(serial_number);
+                    ind.set_allocated_onu_disc_ind(onu_disc_ind);
+                    break;
+                }
+        }
+    }
 
     oltIndQ.push(ind);
-
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuIndication(bcmbal_obj *obj) {
+static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_RANGING_COMPLETED:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_ranging_completed*)msg)->key;
+                    bcmolt_onu_ranging_completed_data *data = &((bcmolt_onu_ranging_completed*)msg)->data;
 
-    bcmbal_subscriber_terminal_oper_status_change_data *data =
-        &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->data);
-
-    BCM_LOG(INFO, openolt_log_id, "onu indication, intf_id %d, onu_id %d, oper_state %d, admin_state %d\n",
-        key->intf_id, key->sub_term_id, data->new_oper_status, data->admin_state);
-
-    onu_ind->set_intf_id(key->intf_id);
-    onu_ind->set_onu_id(key->sub_term_id);
-    if (data->new_oper_status == BCMBAL_STATUS_UP) {
-        onu_ind->set_oper_state("up");
-    } else {
-        onu_ind->set_oper_state("down");
+                    onu_ind->set_intf_id(key->pon_ni);
+                    onu_ind->set_onu_id(key->onu_id);
+                    if (ONU_RANGING_STATE_IF_UP(data->status))
+                        onu_ind->set_oper_state("up");
+                    if (ONU_RANGING_STATE_IF_DOWN(data->status))
+                        onu_ind->set_oper_state("down");
+                    (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
+                    ind.set_allocated_onu_ind(onu_ind);
+                    OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n", 
+                        key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
+                        (key->onu_id)?"up":"down");
+                }
+            }
     }
-    if (data->admin_state == BCMBAL_STATE_UP) {
-        onu_ind->set_admin_state("up");
-    } else {
-        onu_ind->set_admin_state("down");
-    }
-    const std::string  reg_id = getOnuRegistrationId(key->intf_id,key->sub_term_id);
+    /*const std::string  reg_id = getOnuRegistrationId(key->intf_id,key->sub_term_id);
     onu_ind->set_registration_id(reg_id);
 
     BCM_LOG(INFO, openolt_log_id, "onu indication, intf_id %d, onu_id %d, oper state %s, admin_state %s,registration id %s\n",
-        onu_ind->intf_id(), onu_ind->onu_id(),onu_ind->oper_state().c_str(), onu_ind->admin_state().c_str(),onu_ind->registration_id().c_str());
-
-    ind.set_allocated_onu_ind(onu_ind);
+        onu_ind->intf_id(), onu_ind->onu_id(),onu_ind->oper_state().c_str(), onu_ind->admin_state().c_str(),onu_ind->registration_id().c_str());*/
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuOperIndication(bcmbal_obj *obj) {
+static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
+                    bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
 
-    bcmbal_subscriber_terminal_oper_status_change_data *data =
-        &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->data);
+                    onu_ind->set_intf_id(key->pon_ni);
+                    onu_ind->set_onu_id(key->onu_id);
+                    if (ONU_STATE_IF_UP(data->new_onu_state))
+                        onu_ind->set_oper_state("up");
+                    if (ONU_STATE_IF_DOWN(data->new_onu_state))
+                        onu_ind->set_oper_state("down");
+                    ind.set_allocated_onu_ind(onu_ind);
 
-    onu_ind->set_intf_id(key->intf_id);
-    onu_ind->set_onu_id(key->sub_term_id);
-    if (data->new_oper_status == BCMBAL_STATUS_UP) {
-        onu_ind->set_oper_state("up");
-    } else {
-        onu_ind->set_oper_state("down");
+                    OPENOLT_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %s\n",
+                        key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str());
+                }
+            }
     }
-    if (data->admin_state == BCMBAL_STATE_UP) {
-        onu_ind->set_admin_state("up");
-    } else {
-        onu_ind->set_admin_state("down");
-    }
-    const std::string  reg_id = getOnuRegistrationId(key->intf_id,key->sub_term_id);
+    /*const std::string  reg_id = getOnuRegistrationId(key->intf_id,key->sub_term_id);
     onu_ind->set_registration_id(reg_id);
     ind.set_allocated_onu_ind(onu_ind);
 
     BCM_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %s, admin_state %s registraion_id %s\n",
-        key->intf_id, key->sub_term_id, data->old_oper_status, onu_ind->oper_state().c_str(), onu_ind->admin_state().c_str(),onu_ind->registration_id().c_str());
+        key->intf_id, key->sub_term_id, data->old_oper_status, onu_ind->oper_state().c_str(), onu_ind->admin_state().c_str(),onu_ind->registration_id().c_str());*/
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OmciIndication(bcmbal_obj *obj) {
+static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
-    bcmbal_packet_itu_omci_channel_rx *in =
-        (bcmbal_packet_itu_omci_channel_rx *)obj;
 
-    BCM_LOG(DEBUG, omci_log_id, "OMCI indication: intf_id %d, onu_id %d\n",
-        in->key.packet_send_dest.u.itu_omci_channel.intf_id,
-        in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
+                    bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
 
-    omci_ind->set_intf_id(in->key.packet_send_dest.u.itu_omci_channel.intf_id);
-    omci_ind->set_onu_id(in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
-    omci_ind->set_pkt(in->data.pkt.val, in->data.pkt.len);
+                    OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n", 
+                        key->pon_ni, key->onu_id);
 
-    ind.set_allocated_omci_ind(omci_ind);
+                    omci_ind->set_intf_id(key->pon_ni);
+                    omci_ind->set_onu_id(key->onu_id);
+                    omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
+
+                    ind.set_allocated_omci_ind(omci_ind);
+                    break;
+                }
+        }
+    }
+
     oltIndQ.push(ind);
-
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno PacketIndication(bcmbal_obj *obj) {
+static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
-    bcmbal_packet_bearer_channel_rx *in = (bcmbal_packet_bearer_channel_rx *)obj;
 
-    uint32_t port_no = GetPortNum_(in->data.flow_id);
-    pkt_ind->set_intf_type(bcmbal_to_grpc_intf_type(in->data.intf_type));
-    pkt_ind->set_intf_id(in->data.intf_id);
-    pkt_ind->set_gemport_id(in->data.svc_port);
-    pkt_ind->set_flow_id(in->data.flow_id);
-    pkt_ind->set_pkt(in->data.pkt.val, in->data.pkt.len);
-    pkt_ind->set_port_no(port_no);
-    pkt_ind->set_cookie(in->data.flow_cookie);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_FLOW:
+            switch (msg->subgroup) {
+                case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
+                {
+                    bcmolt_flow_receive_eth_packet *pkt = 
+                        (bcmolt_flow_receive_eth_packet*)msg;
+                    bcmolt_flow_receive_eth_packet_data *pkt_data = 
+                        &((bcmolt_flow_receive_eth_packet*)msg)->data;
 
-    ind.set_allocated_pkt_ind(pkt_ind);
+                    uint32_t port_no = GetPortNum_(pkt->key.flow_id);
+                    pkt_ind->set_intf_type(bcmolt_to_grpc_flow_intf_type((bcmolt_flow_interface_type)get_flow_status(pkt->key.flow_id, pkt->key.flow_type, INGRESS_INTF_TYPE)));
+                    pkt_ind->set_intf_id(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, INGRESS_INTF_ID));
+                    pkt_ind->set_gemport_id(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, SVC_PORT_ID));
+                    pkt_ind->set_flow_id(pkt->key.flow_id);
+                    pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
+                    pkt_ind->set_port_no(port_no);
+                    pkt_ind->set_cookie(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, COOKIE));
+                    ind.set_allocated_pkt_ind(pkt_ind);
 
-    BCM_LOG(INFO, openolt_log_id, "packet indication, intf_type %s, intf_id %d, svc_port %d, flow_id %d port_no %d cookie %llu\n",
-        pkt_ind->intf_type().c_str(), in->data.intf_id, in->data.svc_port, in->data.flow_id, port_no, in->data.flow_cookie);
+                    OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, egress intf_type %s, egress intf_id %lu, svc_port %d, flow_type %s, flow_id %d, port_no %d, cookie %"PRIu64"\n",
+                        pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), 
+                        bcmolt_to_grpc_flow_intf_type((bcmolt_flow_interface_type)get_flow_status(pkt->key.flow_id, pkt->key.flow_type, EGRESS_INTF_TYPE)).c_str(),
+                        get_flow_status(pkt->key.flow_id, pkt->key.flow_type, EGRESS_INTF_ID),
+                        pkt_ind->gemport_id(), GET_FLOW_TYPE(pkt->key.flow_type), 
+                        pkt_ind->flow_id(), port_no, pkt_ind->cookie());
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno FlowOperIndication(bcmbal_obj *obj) {
+static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
-    BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
-    return BCM_ERR_OK;
+    OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno FlowIndication(bcmbal_obj *obj) {
+static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
-    BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
-    return BCM_ERR_OK;
+    OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno TmQIndication(bcmbal_obj *obj) {
+static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
-    BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
-    return BCM_ERR_OK;
+    OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno TmSchedIndication(bcmbal_obj *obj) {
+static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
-    BCM_LOG(DEBUG, openolt_log_id,  "traffic mgmt sheduler indication\n");
-    return BCM_ERR_OK;
+    OPENOLT_LOG(DEBUG, openolt_log_id,  "traffic mgmt sheduler indication\n");
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno McastGroupIndication(bcmbal_obj *obj) {
+static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
-    BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
-    return BCM_ERR_OK;
+    OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuStartupFailureIndication(bcmbal_obj *obj) {
+static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_sufi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
+                    bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
 
-    bcmbal_subscriber_terminal_sufi_data *data =
-        &(((bcmbal_subscriber_terminal_sufi*)obj)->data);
+                    OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status);
 
-    BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
-        key->intf_id, key->sub_term_id, data->sufi_status);
+                    sufi_ind->set_intf_id(key->pon_ni);
+                    sufi_ind->set_onu_id(key->onu_id);
+                    sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
 
-    sufi_ind->set_intf_id(key->intf_id);
-    sufi_ind->set_onu_id(key->sub_term_id);
-    sufi_ind->set_status(alarm_status_to_string(data->sufi_status));
-
-    alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuSignalDegradeIndication(bcmbal_obj *obj) {
+static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_sdi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
+                    bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
 
-    bcmbal_subscriber_terminal_sdi_data *data =
-        &(((bcmbal_subscriber_terminal_sdi*)obj)->data);
+                    OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status, data->ber);
 
-    BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
-        key->intf_id, key->sub_term_id, data->sdi_status, data->ber);
+                    sdi_ind->set_intf_id(key->pon_ni);
+                    sdi_ind->set_onu_id(key->onu_id);
+                    sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    sdi_ind->set_inverse_bit_error_rate(data->ber);
+                    alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
 
-    sdi_ind->set_intf_id(key->intf_id);
-    sdi_ind->set_onu_id(key->sub_term_id);
-    sdi_ind->set_status(alarm_status_to_string(data->sdi_status));
-    sdi_ind->set_inverse_bit_error_rate(data->ber);
-
-    alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuDriftOfWindowIndication(bcmbal_obj *obj) {
+static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_dowi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key; 
+                    bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
 
-    bcmbal_subscriber_terminal_dowi_data *data =
-        &(((bcmbal_subscriber_terminal_dowi*)obj)->data);
+                    OPENOLT_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
 
-    BCM_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n",
-        key->intf_id, key->sub_term_id, data->dowi_status, data->drift_value, data->new_eqd);
+                    dowi_ind->set_intf_id(key->pon_ni);
+                    dowi_ind->set_onu_id(key->onu_id);
+                    dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    dowi_ind->set_drift(data->drift_value);
+                    dowi_ind->set_new_eqd(data->new_eqd);
+                    alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
 
-    dowi_ind->set_intf_id(key->intf_id);
-    dowi_ind->set_onu_id(key->sub_term_id);
-    dowi_ind->set_status(alarm_status_to_string(data->dowi_status));
-    dowi_ind->set_drift(data->drift_value);
-    dowi_ind->set_new_eqd(data->new_eqd);
-
-    alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuLossOfOmciChannelIndication(bcmbal_obj *obj) {
+static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_looci*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
+                    bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
 
-    bcmbal_subscriber_terminal_looci_data *data =
-        &(((bcmbal_subscriber_terminal_looci*)obj)->data);
+                    OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status);
 
-    BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
-        key->intf_id, key->sub_term_id, data->looci_status);
+                    looci_ind->set_intf_id(key->pon_ni);
+                    looci_ind->set_onu_id(key->onu_id);
+                    looci_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
 
-    looci_ind->set_intf_id(key->intf_id);
-    looci_ind->set_onu_id(key->sub_term_id);
-    looci_ind->set_status(alarm_status_to_string(data->looci_status));
-
-    alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuSignalsFailureIndication(bcmbal_obj *obj) {
+static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_sfi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
+                    bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
 
-    bcmbal_subscriber_terminal_sfi_data *data =
-        &(((bcmbal_subscriber_terminal_sfi*)obj)->data);
-
-    BCM_LOG(WARNING, openolt_log_id,  "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
-        key->intf_id, key->sub_term_id, data->sfi_status, data->ber);
+                    OPENOLT_LOG(WARNING, openolt_log_id,  "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status, data->ber);
 
 
-    sfi_ind->set_intf_id(key->intf_id);
-    sfi_ind->set_onu_id(key->sub_term_id);
-    sfi_ind->set_status(alarm_status_to_string(data->sfi_status));
-    sfi_ind->set_inverse_bit_error_rate(data->ber);
+                    sfi_ind->set_intf_id(key->pon_ni);
+                    sfi_ind->set_onu_id(key->onu_id);
+                    sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    sfi_ind->set_inverse_bit_error_rate(data->ber);
+                    alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
 
-    alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuTransmissionInterferenceWarningIndication(bcmbal_obj *obj) {
+static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_tiwi*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
+                    bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
 
-    bcmbal_subscriber_terminal_tiwi_data *data =
-        &(((bcmbal_subscriber_terminal_tiwi*)obj)->data);
+                    OPENOLT_LOG(WARNING, openolt_log_id,  "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
+                        key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
 
-    BCM_LOG(WARNING, openolt_log_id,  "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
-        key->intf_id, key->sub_term_id, data->tiwi_status, data->drift_value);
+                    tiwi_ind->set_intf_id(key->pon_ni);
+                    tiwi_ind->set_onu_id(key->onu_id);
+                    tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
+                    tiwi_ind->set_drift(data->drift_value);
+                    alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
 
-    tiwi_ind->set_intf_id(key->intf_id);
-    tiwi_ind->set_onu_id(key->sub_term_id);
-    tiwi_ind->set_status(alarm_status_to_string(data->tiwi_status));
-    tiwi_ind->set_drift(data->drift_value);
-
-    alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
-bcmos_errno OnuActivationFailureIndication(bcmbal_obj *obj) {
+static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
     openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
 
-    bcmbal_subscriber_terminal_key *key =
-        &(((bcmbal_subscriber_terminal_sub_term_act_fail*)obj)->key);
+    switch (msg->obj_type) {
+        case BCMOLT_OBJ_ID_ONU:
+            switch (msg->subgroup) {
+                case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
+                {
+                    bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
+                    bcmolt_onu_onu_activation_completed_data *data = 
+                        &((bcmolt_onu_onu_activation_completed*)msg)->data;
 
-    BCM_LOG(WARNING, openolt_log_id, "onu activation failure indication, intf_id %d, onu_id %d\n",
-        key->intf_id, key->sub_term_id);
+                    OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d\n",
+                        key->pon_ni, key->onu_id, data->fail_reason);
 
+                    activation_fail_ind->set_intf_id(key->pon_ni);
+                    activation_fail_ind->set_onu_id(key->onu_id);
+                    alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
 
-    activation_fail_ind->set_intf_id(key->intf_id);
-    activation_fail_ind->set_onu_id(key->sub_term_id);
-
-    alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
-    ind.set_allocated_alarm_ind(alarm_ind);
+                    ind.set_allocated_alarm_ind(alarm_ind);
+                }
+            }
+    }
 
     oltIndQ.push(ind);
-    return BCM_ERR_OK;
+    bcmolt_msg_free(msg);
 }
 
+/* removed by BAL v3.0
 bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
     openolt::Indication ind;
     openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
@@ -655,7 +800,7 @@
     bcmbal_subscriber_terminal_key *key =
         &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
 
-    BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
+    OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
         key->intf_id, key->sub_term_id);
 
 
@@ -668,226 +813,180 @@
     oltIndQ.push(ind);
     return BCM_ERR_OK;
 }
+*/
 
 Status SubscribeIndication() {
-    bcmbal_cb_cfg cb_cfg = {};
-    uint16_t ind_subgroup;
+    bcmolt_rx_cfg rx_cfg = {};
+    bcmos_errno rc;
 
     if (subscribed) {
         return Status::OK;
     }
 
-    cb_cfg.module = BCMOS_MODULE_ID_NONE;
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
+    rx_cfg.rx_cb = OltOperIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "Olt connection complete state indication subscribe failed");
 
-    /* OLT device operational state change indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_ACCESS_TERMINAL;
-    ind_subgroup = bcmbal_access_terminal_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OltOperIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Olt operations state change indication subscribe failed");
-    }
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
+    rx_cfg.rx_cb = OltOperIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "Olt disconnection complete state indication subscribe failed");
+
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
+    rx_cfg.rx_cb = OltOperIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "Olt connection failure state indication subscribe failed");
 
     /* Interface LOS indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
-    ind_subgroup = bcmbal_interface_auto_id_los;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)LosIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
+    rx_cfg.rx_cb = LosIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
-    }
 
-    /* Interface indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
-    ind_subgroup = bcmbal_interface_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)IfIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Interface indication subscribe failed");
-    }
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
+    rx_cfg.rx_cb = IfOperIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "PON Interface operations state change indication subscribe failed");
 
-    /* Interface operational state change indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
-    ind_subgroup = bcmbal_interface_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)IfOperIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Interface operations state change indication subscribe failed");
-    }
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
+    rx_cfg.rx_cb = IfOperIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "NNI Interface operations state change indication subscribe failed");
 
-    /* onu alarm indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_alarm;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuAlarmIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuAlarmIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
-    }
 
-    /* onu dying-gasp indication  */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_dgi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDyingGaspIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuAlarmIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
+
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuDyingGaspIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
-    }
 
-    /* onu discovery indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_disc;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDiscoveryIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
+    rx_cfg.rx_cb = OnuDiscoveryIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
-    }
 
-    /* onu indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_ranging_completed;
+
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed");
-    }
-    /* onu operational state change indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuOperIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "onu operational state change indication subscribe failed");
-    }
 
-    /* Packet (bearer) indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_PACKET;
-    ind_subgroup = bcmbal_packet_auto_id_bearer_channel_rx;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)PacketIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
-    }
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuStartupFailureIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "onu startup failure indication subscribe failed");
 
-    /* Flow Operational State Change */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW;
-    ind_subgroup = bcmbal_flow_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)FlowOperIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Flow operational state change indication subscribe failed");
-    }
-#if 0
-    /* Flow Indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW;
-    ind_subgroup = bcmbal_flow_auto_id_ind;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)FlowIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Flow indication subscribe failed");
-    }
-
-    /* TM queue indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_QUEUE;
-    ind_subgroup = bcmbal_tm_queue_auto_id_ind;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)TmQIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Traffic mgmt queue indication subscribe failed");
-    }
-#endif
-
-    /* TM sched indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_SCHED;
-    ind_subgroup = bcmbal_tm_sched_auto_id_oper_status_change;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)TmSchedIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Traffic mgmt queue indication subscribe failed");
-    }
-
-#if 0
-    /* Multicast group indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_GROUP;
-    ind_subgroup = bcmbal_group_auto_id_ind;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)McastGroupIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "Multicast group indication subscribe failed");
-    }
-#endif
-
-
-    /* ONU startup failure indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sufi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuStartupFailureIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "onu startup failure indication subscribe failed");
-    }
-
-    /* SDI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sdi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuSignalDegradeIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuSignalDegradeIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
-    }
 
-    /* DOWI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_dowi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDriftOfWindowIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuDriftOfWindowIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
-    }
 
     /* LOOCI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_looci;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuLossOfOmciChannelIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
-    }
 
     /* SFI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sfi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuSignalsFailureIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuSignalsFailureIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
-    }
 
     /* TIWI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_tiwi;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuTransmissionInterferenceWarningIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
         return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
-    }
 
-    /* TIWI indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_act_fail;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuActivationFailureIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "onu activation falaire indication subscribe failed");
-    }
+    /* ONU Activation Failure Indiction */
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
+    rx_cfg.rx_cb = OnuActivationFailureIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, 
+            "onu activation falaire indication subscribe failed");
 
-    /* ONU processing error indication */
-    cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
-    ind_subgroup = bcmbal_subscriber_terminal_auto_id_processing_error;
-    cb_cfg.p_subgroup = &ind_subgroup;
-    cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuProcessingErrorIndication;
-    if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
-        return Status(grpc::StatusCode::INTERNAL, "onu processing error indication subscribe failed");
-    }
+    rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW;
+    rx_cfg.rx_cb = PacketIndication;
+    rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
+    rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet;
+    rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
+    if(rc != BCM_ERR_OK)
+        return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
 
     subscribed = true;
 
diff --git a/agent/src/indications.h b/agent/src/indications.h
index c2f0724..f762e72 100644
--- a/agent/src/indications.h
+++ b/agent/src/indications.h
@@ -19,7 +19,7 @@
 #define OPENOLT_INDICATIONS_H_
 
 #include <grpc++/grpc++.h>
-#include <openolt.grpc.pb.h>
+#include <voltha_protos/openolt.grpc.pb.h>
 #include "Queue.h"
 
 extern "C" {
diff --git a/agent/src/stats_collection.cc b/agent/src/stats_collection.cc
index 7bdde4c..62213c2 100644
--- a/agent/src/stats_collection.cc
+++ b/agent/src/stats_collection.cc
@@ -19,7 +19,6 @@
 
 #include <unistd.h>
 
-#include <openolt.grpc.pb.h>
 #include "indications.h"
 #include "core.h"
 #include "translation.h"
@@ -27,18 +26,18 @@
 extern "C"
 {
 #include <bcmos_system.h>
-#include <bal_api.h>
-#include <bal_api_end.h>
-#include <flow_fsm.h>
+#include <bcmolt_api.h>
+#include <bcmolt_api_model_api_structs.h>
 }
 
 //FIXME
 #define FLOWS_COUNT 100
 
-bcmbal_flow_key* flows_keys = new bcmbal_flow_key[FLOWS_COUNT];
+bcmolt_flow_key* flows_keys = new bcmolt_flow_key[FLOWS_COUNT];
+bcmolt_odid device_id = 0;    
 
 void init_stats() {
-    memset(flows_keys, 0, FLOWS_COUNT * sizeof(bcmbal_flow_key));
+    memset(flows_keys, 0, FLOWS_COUNT * sizeof(bcmolt_flow_key));
 }
 
 openolt::PortStatistics* get_default_port_statistics() {
@@ -75,50 +74,110 @@
 }
 #endif
 
-openolt::PortStatistics* collectPortStatistics(bcmbal_interface_key key) {
-
-    bcmos_errno err;
-    bcmbal_interface_stat stat;     /**< declare main API struct */
-    bcmos_bool clear_on_read = false;
+openolt::PortStatistics* collectPortStatistics(bcmolt_intf_ref intf_ref) {
 
     openolt::PortStatistics* port_stats = get_default_port_statistics();
+#ifndef TEST_MODE
+    bcmos_errno err;
+    bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE;
+    bcmolt_nni_interface_stats nni_stats;
+    bcmolt_onu_itu_pon_stats pon_stats;
+    bcmolt_pon_interface_itu_pon_stats itu_pon_stats;
 
-    /* init the API struct */
-    BCMBAL_STAT_INIT(&stat, interface, key);
-    BCMBAL_STAT_PROP_GET(&stat, interface, all_properties);
 
-    /* call API */
-    err = bcmbal_stat_get(DEFAULT_ATERM_ID, &stat.hdr, clear_on_read);
-    if (err == BCM_ERR_OK)
-    {
-        //std::cout << "Interface statistics retrieved"
-        //          << " intf_id:" << intf_id << std::endl;
+    switch (intf_ref.intf_type) {
+        case BCMOLT_INTERFACE_TYPE_NNI:
+        {
+            bcmolt_nni_interface_key nni_intf_key;
+            nni_intf_key.id = intf_ref.intf_id;
+            /* init the API struct */
+            BCMOLT_STAT_INIT(&nni_stats, nni_interface, stats, nni_intf_key);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_bytes);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_ucast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_mcast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_bcast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, rx_error_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_bytes);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_ucast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_mcast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_bcast_packets);
+            BCMOLT_MSG_FIELD_GET(&nni_stats, tx_error_packets);
 
-        port_stats->set_rx_bytes(stat.data.rx_bytes);
-        port_stats->set_rx_packets(stat.data.rx_packets);
-        port_stats->set_rx_ucast_packets(stat.data.rx_ucast_packets);
-        port_stats->set_rx_mcast_packets(stat.data.rx_mcast_packets);
-        port_stats->set_rx_bcast_packets(stat.data.rx_bcast_packets);
-        port_stats->set_rx_error_packets(stat.data.rx_error_packets);
-        port_stats->set_tx_bytes(stat.data.tx_bytes);
-        port_stats->set_tx_packets(stat.data.tx_packets);
-        port_stats->set_tx_ucast_packets(stat.data.tx_ucast_packets);
-        port_stats->set_tx_mcast_packets(stat.data.tx_mcast_packets);
-        port_stats->set_tx_bcast_packets(stat.data.tx_bcast_packets);
-        port_stats->set_tx_error_packets(stat.data.tx_error_packets);
-        port_stats->set_rx_crc_errors(stat.data.rx_crc_errors);
-        port_stats->set_bip_errors(stat.data.bip_errors);
+            /* call API */
+            err = bcmolt_stat_get((bcmolt_oltid)device_id, &nni_stats.hdr, clear_on_read);
+            if (err == BCM_ERR_OK)
+            {
+                //std::cout << "Interface statistics retrieved"
+                //          << " intf_id:" << intf_id << std::endl;
+            
+                port_stats->set_rx_bytes(nni_stats.data.rx_bytes);
+                port_stats->set_rx_packets(nni_stats.data.rx_packets);
+                port_stats->set_rx_ucast_packets(nni_stats.data.rx_ucast_packets);
+                port_stats->set_rx_mcast_packets(nni_stats.data.rx_mcast_packets);
+                port_stats->set_rx_bcast_packets(nni_stats.data.rx_bcast_packets);
+                port_stats->set_rx_error_packets(nni_stats.data.rx_error_packets);
+                port_stats->set_tx_bytes(nni_stats.data.tx_bytes);
+                port_stats->set_tx_packets(nni_stats.data.tx_packets);
+                port_stats->set_tx_ucast_packets(nni_stats.data.tx_ucast_packets);
+                port_stats->set_tx_mcast_packets(nni_stats.data.tx_mcast_packets);
+                port_stats->set_tx_bcast_packets(nni_stats.data.tx_bcast_packets);
+                port_stats->set_tx_error_packets(nni_stats.data.tx_error_packets);
+            
+            } else {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to retrieve port statistics, intf_id %d, intf_type %d\n",
+                    (int)intf_ref.intf_id, (int)intf_ref.intf_type);
+            }
+            break;
+        }
+        case BCMOLT_INTERFACE_TYPE_PON:
+        {
+            bcmolt_pon_interface_key key;
+            key.pon_ni = (bcmolt_interface)intf_ref.intf_id;
+            BCMOLT_STAT_INIT(&itu_pon_stats, pon_interface, itu_pon_stats, key);
+            BCMOLT_MSG_FIELD_GET(&itu_pon_stats, tx_packets);
+            BCMOLT_MSG_FIELD_GET(&itu_pon_stats, bip_errors);
+            BCMOLT_MSG_FIELD_GET(&itu_pon_stats, rx_crc_error);
 
-    } else {
-        BCM_LOG(ERROR, openolt_log_id,  "Failed to retrieve port statistics, intf_id %d, intf_type %d\n",
-            (int)key.intf_id, (int)key.intf_type);
-    }
+            /* call API */
+            err = bcmolt_stat_get((bcmolt_oltid)device_id, &itu_pon_stats.hdr, clear_on_read);
+            if (err == BCM_ERR_OK) {
+                port_stats->set_tx_packets(itu_pon_stats.data.tx_packets);
+                port_stats->set_bip_errors(itu_pon_stats.data.bip_errors);
+                port_stats->set_rx_crc_errors(itu_pon_stats.data.rx_crc_error);
+            } else {
+                OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to retrieve port statistics, intf_id %d, intf_type %d, err %d\n",
+                    (int)intf_ref.intf_id, (int)intf_ref.intf_type, err);
+            }
+            {
+                bcmolt_onu_key key;
+                key.pon_ni = (bcmolt_interface)intf_ref.intf_id;
+                BCMOLT_STAT_INIT(&pon_stats, onu, itu_pon_stats, key);
+                BCMOLT_MSG_FIELD_GET(&pon_stats, rx_bytes);
+                BCMOLT_MSG_FIELD_GET(&pon_stats, rx_packets);
+                BCMOLT_MSG_FIELD_GET(&pon_stats, tx_bytes);
 
-    port_stats->set_intf_id(interface_key_to_port_no(key));
+                /* call API */
+                err = bcmolt_stat_get((bcmolt_oltid)device_id, &pon_stats.hdr, clear_on_read);
+                if (err == BCM_ERR_OK) {
+                    port_stats->set_rx_bytes(pon_stats.data.rx_bytes);
+                    port_stats->set_rx_packets(pon_stats.data.rx_packets);
+                    port_stats->set_tx_bytes(pon_stats.data.tx_bytes);
+                } else {
+                    OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to retrieve port statistics, intf_id %d, intf_type %d, err %d\n",
+                        (int)intf_ref.intf_id, (int)intf_ref.intf_type, err);
+                }
+            }
+            break;
+        }
+    } 
+
+    port_stats->set_intf_id(interface_key_to_port_no((bcmolt_interface_id)intf_ref.intf_id, (bcmolt_interface_type)intf_ref.intf_type));
     time_t now;
     time(&now);
     port_stats->set_timestamp((int)now);
-
+#endif
     return port_stats;
 
 }
@@ -167,26 +226,27 @@
 void stats_collection() {
 
     if (!state.is_connected()) {
-        BCM_LOG(INFO, openolt_log_id, "Voltha is not connected, do not collect stats\n");
+        OPENOLT_LOG(INFO, openolt_log_id, "Voltha is not connected, do not collect stats\n");
         return;
     }
     if (!state.is_activated()) {
-        BCM_LOG(INFO, openolt_log_id, "The OLT is not up, do not collect stats\n");
+        OPENOLT_LOG(INFO, openolt_log_id, "The OLT is not up, do not collect stats\n");
         return;
     }
 
 
-    BCM_LOG(DEBUG, openolt_log_id, "Collecting statistics\n");
+    OPENOLT_LOG(DEBUG, openolt_log_id, "Collecting statistics\n");
 
     //Ports statistics
 
     //Uplink ports
     for (int i = 0; i < NumNniIf_(); i++) {
-        bcmbal_interface_key nni_interface;
-        nni_interface.intf_type = BCMBAL_INTF_TYPE_NNI;
-        nni_interface.intf_id = i;
+        bcmolt_intf_ref intf_ref;
+        intf_ref.intf_type = BCMOLT_INTERFACE_TYPE_NNI;
+        intf_ref.intf_id = i;
 
-        openolt::PortStatistics* port_stats = collectPortStatistics(nni_interface);
+        openolt::PortStatistics* port_stats =
+            collectPortStatistics(intf_ref);
 
         openolt::Indication ind;
         ind.set_allocated_port_stats(port_stats);
@@ -194,11 +254,12 @@
     }
     //Pon ports
     for (int i = 0; i < NumPonIf_(); i++) {
-        bcmbal_interface_key pon_interface;
-        pon_interface.intf_type = BCMBAL_INTF_TYPE_PON;
-        pon_interface.intf_id = i;
+        bcmolt_intf_ref intf_ref;
+        intf_ref.intf_type = BCMOLT_INTERFACE_TYPE_PON;
+        intf_ref.intf_id = i;
 
-        openolt::PortStatistics* port_stats = collectPortStatistics(pon_interface);
+        openolt::PortStatistics* port_stats = 
+            collectPortStatistics(intf_ref);
 
         openolt::Indication ind;
         ind.set_allocated_port_stats(port_stats);
diff --git a/agent/src/stats_collection.h b/agent/src/stats_collection.h
index 743d0be..8e1c00f 100644
--- a/agent/src/stats_collection.h
+++ b/agent/src/stats_collection.h
@@ -18,17 +18,17 @@
 #ifndef OPENOLT_STATS_COLLECTION_H_
 #define OPENOLT_STATS_COLLECTION_H_
 
-#include <openolt.grpc.pb.h>
+#include <voltha_protos/openolt.grpc.pb.h>
 
 extern "C"
 {
-#include <bal_model_types.h>
+#include <bcmolt_api_model_supporting_structs.h>
 }
 
 void init_stats();
 void stop_collecting_statistics();
 openolt::PortStatistics* get_default_port_statistics();
-openolt::PortStatistics* collectPortStatistics(bcmbal_interface_key key);
+openolt::PortStatistics* collectPortStatistics(bcmolt_interface_id intf_id, bcmolt_interface_type intf_type);
 #if 0
 openolt::FlowStatistics* get_default_flow_statistics();
 openolt::FlowStatistics* collectFlowStatistics(bcmbal_flow_id flow_id, bcmbal_flow_type flow_type);
diff --git a/agent/src/translation.cc b/agent/src/translation.cc
index 3279acd..2c82f58 100644
--- a/agent/src/translation.cc
+++ b/agent/src/translation.cc
@@ -15,25 +15,27 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <string.h>
 #include "translation.h"
 
-int interface_key_to_port_no(bcmbal_interface_key key) {
-    if (key.intf_type == BCMBAL_INTF_TYPE_NNI) {
-        return (0x1 << 16) + key.intf_id;
+int interface_key_to_port_no(bcmolt_interface_id intf_id, 
+        bcmolt_interface_type intf_type) {
+    if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
+        return (0x1 << 16) + intf_id;
     }
-    if (key.intf_type == BCMBAL_INTF_TYPE_PON) {
-        return (0x2 << 28) + key.intf_id;
+    if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
+        return (0x2 << 28) + intf_id;
     }
-    return key.intf_id;
+    return intf_id;
 }
 
-std::string alarm_status_to_string(bcmbal_alarm_status status) {
+std::string alarm_status_to_string(bcmolt_status status) {
     switch (status) {
-        case BCMBAL_ALARM_STATUS_OFF:
+        case BCMOLT_STATUS_OFF:
             return "off";
-        case BCMBAL_ALARM_STATUS_ON:
+        case BCMOLT_STATUS_ON:
             return "on";
-        case BCMBAL_ALARM_STATUS_NO__CHANGE:
+        case BCMOLT_STATUS_NO_CHANGE:
             return "no_change";
     }
     return "unknown";
diff --git a/agent/src/translation.h b/agent/src/translation.h
index 285eaf1..34fe69e 100644
--- a/agent/src/translation.h
+++ b/agent/src/translation.h
@@ -21,12 +21,11 @@
 #include <string>
 extern "C"
 {
-#include <bal_model_types.h>
+#include <bcmolt_api_model_api_structs.h>
 }
 
-int interface_key_to_port_no(bcmbal_interface_key key);
-std::string alarm_status_to_string(bcmbal_alarm_status status);
-
-
+int interface_key_to_port_no(bcmolt_interface_id intf_id, 
+        bcmolt_interface_type intf_type);
+std::string alarm_status_to_string(bcmolt_status status);
 
 #endif
diff --git a/agent/src/utils.cc b/agent/src/utils.cc
index 0ddff3f..9fde90e 100644
--- a/agent/src/utils.cc
+++ b/agent/src/utils.cc
@@ -15,25 +15,26 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <string.h>
 #include "utils.h"
 
-std::string serial_number_to_str(bcmbal_serial_number* serial_number) {
+std::string serial_number_to_str(bcmolt_serial_number* serial_number) {
 #define SERIAL_NUMBER_SIZE 12
     char buff[SERIAL_NUMBER_SIZE+1];
 
     sprintf(buff, "%c%c%c%c%1X%1X%1X%1X%1X%1X%1X%1X",
-            serial_number->vendor_id[0],
-            serial_number->vendor_id[1],
-            serial_number->vendor_id[2],
-            serial_number->vendor_id[3],
-            serial_number->vendor_specific[0]>>4 & 0x0f,
-            serial_number->vendor_specific[0] & 0x0f,
-            serial_number->vendor_specific[1]>>4 & 0x0f,
-            serial_number->vendor_specific[1] & 0x0f,
-            serial_number->vendor_specific[2]>>4 & 0x0f,
-            serial_number->vendor_specific[2] & 0x0f,
-            serial_number->vendor_specific[3]>>4 & 0x0f,
-            serial_number->vendor_specific[3] & 0x0f);
+            serial_number->vendor_id.arr[0],
+            serial_number->vendor_id.arr[1],
+            serial_number->vendor_id.arr[2],
+            serial_number->vendor_id.arr[3],
+            serial_number->vendor_specific.arr[0]>>4 & 0x0f,
+            serial_number->vendor_specific.arr[0] & 0x0f,
+            serial_number->vendor_specific.arr[1]>>4 & 0x0f,
+            serial_number->vendor_specific.arr[1] & 0x0f,
+            serial_number->vendor_specific.arr[2]>>4 & 0x0f,
+            serial_number->vendor_specific.arr[2] & 0x0f,
+            serial_number->vendor_specific.arr[3]>>4 & 0x0f,
+            serial_number->vendor_specific.arr[3] & 0x0f);
 
     return buff;
 }
diff --git a/agent/src/utils.h b/agent/src/utils.h
index 53f4a99..52c018a 100644
--- a/agent/src/utils.h
+++ b/agent/src/utils.h
@@ -23,11 +23,11 @@
 extern "C"
 {
 #include <bcmos_system.h>
-#include <bal_api.h>
-#include <bal_api_end.h>
+#include <bcmolt_api.h>
+#include <bcmolt_api_model_supporting_structs.h>
 }
 
-std::string serial_number_to_str(bcmbal_serial_number* serial_number);
+std::string serial_number_to_str(bcmolt_serial_number* serial_number);
 std::string vendor_specific_to_str(const char* const serial_number);
 
 #endif
diff --git a/agent/test/Makefile.in b/agent/test/Makefile.in
new file mode 100644
index 0000000..2122266
--- /dev/null
+++ b/agent/test/Makefile.in
@@ -0,0 +1,169 @@
+# Copyright (C) 2018 Open Networking Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+########################################################################
+##
+##
+##        Config
+##
+##
+TOP_DIR=`pwd`
+OPENOLTDEVICE ?= asfvolt16
+
+# OpenOLT Proto version.
+# This specifies the GIT tag in https://github.com/opencord/voltha-protos
+# repo that we need to refer to, to pick the right version of
+# openolt.proto and tech_profile.proto
+OPENOLT_PROTO_VER ?= v1.0.3
+
+# GRPC installation
+GRPC_ADDR = https://github.com/grpc/grpc
+GRPC_DST = /tmp/grpc
+GRPC_VER = v1.10.x
+
+USER := $(shell echo $(USER))
+#
+########################################################################
+##
+##
+##        Install prerequisites
+##
+##
+
+CXX = g++-4.9
+CXXFLAGS += -g -O2
+CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
+CPPFLAGS += `pkg-config --cflags protobuf grpc`
+CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
+CXXFLAGS += -DTEST_MODE -DENABLE_LOG
+LDFLAGS +=
+LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
+CXXFLAGSDEVICE = -I../device -I../device/$(OPENOLTDEVICE) -I../device/generic
+
+export CXX CXXFLAGS OPENOLT_PROTO_VER
+
+BAL_API_DIR=bal-api-3.1.0
+BALLIBNAME=bcm_host_api_stubs
+BALLIBDIR=$(BAL_API_DIR)/stubs
+BAL_INC = -I$(BAL_API_DIR)/include \
+          -I$(BAL_API_DIR)/include/object_model
+CXXFLAGS += $(BAL_INC)
+
+
+
+prereq:
+	sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io
+	sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers curl cmake ccache g++-4.9
+
+	# Install GRPC, libprotobuf and protoc
+	rm -rf $(GRPC_DST)
+	git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST)
+	cd $(GRPC_DST) && git submodule update --init
+	cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh && ./configure
+	make -C $(GRPC_DST)/third_party/protobuf
+	sudo make -C $(GRPC_DST)/third_party/protobuf install
+	sudo ldconfig
+	make -C $(GRPC_DST)
+	sudo make -C $(GRPC_DST) install
+	sudo ldconfig
+
+prereq-mock-lib: gtest cmock
+
+gtest:
+	# Install gtest and gmock
+	rm -rf /tmp/googletest && cd /tmp && git clone https://github.com/google/googletest.git
+	cd /tmp/googletest && git checkout release-1.8.0
+	cd /tmp/googletest && cmake CMakeLists.txt
+	make -C /tmp/googletest
+	sudo make -C /tmp/googletest install
+
+cmock:
+	# Install c-mock
+	rm -rf /tmp/C-Mock && cd /tmp && git clone https://github.com/hjagodzinski/C-Mock.git
+	cd /tmp/C-Mock && git checkout 0207b3026f04bbdf0bd9d9f8dfd00945a4318251
+	make -C /tmp/C-Mock
+	sudo make -C /tmp/C-Mock install
+
+########################################################################
+##
+##
+##        build
+##
+##
+
+.DEFAULT_GOAL := all
+
+.PHONY = bcm_host_api_stubs libopenoltapi.a libopenolt.a build clean
+
+all: bcm_host_api_stubs libopenoltapi.a libopenolt.a build
+
+# test
+TEST_OPENOLT_LIB_DIR=./lib
+TEST_BIN=test_openolt
+# The below way of getting source files is not working
+#TEST_SRCS = $($(filter-out src/bal_stub.cc, $(wildcard src/*.cc)))
+TEST_SRCS = src/main_test.cc src/bal_mocker.cc src/test_enable_olt.cc
+TEST_OBJS = $(TEST_SRCS:.cc=.o)
+build: $(TEST_OBJS)
+	$(CXX) $(shell cmock-config --libs) -L$(TEST_OPENOLT_LIB_DIR) -L/usr/lib/ -I/usr/include -I./inc -o $(TEST_BIN) $(TEST_OBJS) -lgmock -lgtest -lopenolt -lopenoltapi  $(LDFLAGS)
+src/%.o: src/%.cc
+	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I./inc -I../common -I/usr/include -c $< -o $@
+
+
+# bcm_host_api_stubs
+BAL_API_DIR=bal-api-3.1.0
+bcm_host_api_stubs: 
+	# TODO: There is temporary hack below to introduce the definition of bcmos_mutex.
+	# This should ideally come as part of bal-api-3.1.0
+	if [ -d $(BAL_API_DIR) ]; then \
+		echo "$(BAL_API_DIR) exists"; \
+	else \
+		git clone https://github.com/balapi/bal-api-3.1.0.git ;\
+        sed -i "\$$i #define BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT 0" ./bal-api-3.1.0/include/bcmos_system.h; \
+        sed -i "\$$i struct bcmos_mutex \{ pthread_mutex_t m; };" ./bal-api-3.1.0/include/bcmos_system.h; \
+	fi
+
+# openoltapi
+OPENOLT_PROTOS_DIR = ../../protos
+OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
+CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
+libopenoltapi.a:
+	make -C $(OPENOLT_PROTOS_DIR) all
+	mkdir -p lib
+	cp $(OPENOLT_PROTOS_DIR)/$@ lib/
+libproto-clean:
+	make -C $(OPENOLT_PROTOS_DIR) clean
+
+# openolt
+OPENOLT_SRCS = $(wildcard ../src/*.cc) ../common/server.cc $(wildcard ../device/$(OPENOLTDEVICE)/*.cc) src/bal_stub.cc
+OPENOLT_OBJS = $(OPENOLT_SRCS:.cc=.o)
+libopenolt.a: $(OPENOLT_OBJS)
+	mkdir -p lib
+	ar cr lib/$@ $^
+	ranlib lib/$@
+../common/%.o: ../common/%.cc
+	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I./device/$(OPENOLTDEVICE) -c $< -o $@
+../src/%.o: ../src/%.cc
+	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I./device/$(OPENOLTDEVICE) -c $< -o $@
+src/%.o: src/%.cc
+	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I./device/$(OPENOLTDEVICE) -c $< -o $@
+../device/$(OPENOLTDEVICE)/%.o: ../device/$(OPENOLTDEVICE)/%.cc
+	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I./device/$(OPENOLTDEVICE) -c $< -o $@
+
+test: all
+	./test_openolt --gtest_output="xml:./test_openolt_report.xml"
+
+clean:
+	rm -f src/*.o lib/*.a ../src/*.o ../common/*.o ./test_openolt  ./test_openolt_report.xml
diff --git a/agent/test/README.md b/agent/test/README.md
new file mode 100644
index 0000000..6a3b40a
--- /dev/null
+++ b/agent/test/README.md
@@ -0,0 +1,52 @@
+# OpenOLT Agent Unit Test
+
+OpenOLT agent unit test framework is based on the following frameworks
+
+- Google Test: https://github.com/google/googletest
+- C-Mock: https://github.com/hjagodzinski/C-Mock
+ 
+The goal of the unit tests for OpenOLT agent is to test the OpenOLT application by stubbing and mocking the external interfaces, especially the BAL API and GRPC.
+
+## Building and Running Unit Test
+
+Follow the below steps to build and run unit test
+```shell
+$ cd agent/test
+# Run Autoconfig to generate the appropriate makefile scaffolding for the desired target
+./configure
+# This will build pre-requisite software to build openolt. Needed once only.
+$ make prereq
+# This will install gtest and c-mock libraries. Needed once only
+$ make prereq-mock-lib
+# This will build and run the unit test cases
+$ make test
+```
+
+If you need to use a specific version of voltha-protos, then specify the git tag/branch corresponding to
+tht specific version as below. For ex:
+
+```shell
+make OPENOLT_PROTO_VER=master test
+```
+
+By default, the OPENOLT_PROTO_VER defaults to git tag *v1.0.3* of https://github.com/opencord/voltha-protos repo.
+
+Once you have successfully built and run the unit-test, the test report will be available in `test_openolt_report.xml` file in `agent/test`.
+To clean all build artifacts and test reports, do `make clean` in `agent/test`.
+
+## Adding new Unit Test Cases
+
+Before you add new test cases please read [GOOGLE TEST COOKBOOK](https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md) and [USING CMOCK](https://github.com/hjagodzinski/C-Mock/blob/master/README.md) to get acquainted with frameworks used for the unit-test cases.
+
+### Create mocks, if needed
+
+Refer `agent/test/src/bal_mocker.cc` and `agent/test/src/bal_mocker.h` to see how mock functions are created (if needed by your test case). In the aforementioned examples, mocks are created for certain BAL APIs.
+
+### Create Unit Test Case
+
+Please refer example `agent/test/src/test_enable_olt.cc`.
+Tests are grouped under Test Fixtures, i.e., `TEST_F` which takes argument of Test Fixture Name and the Test Case. There will typically be many test cases under a test fixture. Also it is preferrable to create a new file for different test fixtures.
+If your test case needs mocking, you will need to instantiate the appropriate mocker class you have created and use the `ON_CALL`, `EXPECT_CALL` or other utilities from the gtest suite to produce the required behavior.
+Use the `ASSERT_XXX` utility from the gtest suite to verify the required result.
+Please refer the [GOOGLE TEST COOKBOOK](https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md) for detailed documentation.
+
diff --git a/agent/test/config.h.in b/agent/test/config.h.in
new file mode 100644
index 0000000..08d1691
--- /dev/null
+++ b/agent/test/config.h.in
@@ -0,0 +1,105 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+#undef HAVE_LIBDL
+
+/* Define to 1 if you have the `gpr' library (-lgpr). */
+#undef HAVE_LIBGPR
+
+/* Define to 1 if you have the `grpc' library (-lgrpc). */
+#undef HAVE_LIBGRPC
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint16_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint8_t
diff --git a/agent/test/configure b/agent/test/configure
new file mode 100755
index 0000000..7c41265
--- /dev/null
+++ b/agent/test/configure
@@ -0,0 +1,5494 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for openolt 1.4.0.
+#
+# Report bugs to <voltha-discuss@opencord.org>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir/$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: voltha-discuss@opencord.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='openolt'
+PACKAGE_TARNAME='openolt'
+PACKAGE_VERSION='1.4.0'
+PACKAGE_STRING='openolt 1.4.0'
+PACKAGE_BUGREPORT='voltha-discuss@opencord.org'
+PACKAGE_URL=''
+
+ac_unique_file="config.h.in"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+EGREP
+GREP
+CPP
+SET_MAKE
+LN_S
+SED
+AWK
+ac_ct_CC
+CFLAGS
+CC
+OBJEXT
+EXEEXT
+ac_ct_CXX
+CPPFLAGS
+LDFLAGS
+CXXFLAGS
+CXX
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_sysroot
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures openolt 1.4.0 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking ...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/openolt]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of openolt 1.4.0:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-sysroot=DIR      search for usr/include, usr/lib, usr/lib64 etal
+                          within DIR
+
+Some influential environment variables:
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <voltha-discuss@opencord.org>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+openolt configure 1.4.0
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------------------ ##
+## Report this to voltha-discuss@opencord.org ##
+## ------------------------------------------ ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+	 return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+	    return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     # Order is important - never check a type that is potentially smaller
+     # than half of the expected target width.
+     for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  case $ac_type in #(
+  uint$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_uintX_t
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by openolt $as_me 1.4.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+	ac_must_keep_next=false # Got value, back to normal.
+      else
+	case $ac_arg in
+	  *=* | --config-cache | -C | -disable-* | --disable-* \
+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+	  | -with-* | --with-* | -without-* | --without-* | --x)
+	    case "$ac_configure_args0 " in
+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+	    esac
+	    ;;
+	  -* ) ac_must_keep_next=true ;;
+	esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	$as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+  withval=$with_sysroot;
+  sysroot=$withval
+
+  if test "$sysroot" = "yes"; then
+    sysroot='${exec_prefix}/${target_alias}/sys-root'
+  elif test "$sysroot" = "no"; then
+    sysroot=
+  fi
+
+  if test "x$sysroot" != x; then
+    CXXFLAGS="$CXXFLAGS --sysroot=$sysroot"
+    LDFLAGS="$LDFLAGS --sysroot=$sysroot"
+  fi
+
+fi
+
+
+# Checks for programs.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C++ compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+# Checks for libraries.
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ldl" >&5
+$as_echo_n "checking for main in -ldl... " >&6; }
+if ${ac_cv_lib_dl_main+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_main=yes
+else
+  ac_cv_lib_dl_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_main" >&5
+$as_echo "$ac_cv_lib_dl_main" >&6; }
+if test "x$ac_cv_lib_dl_main" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
+$as_echo_n "checking for main in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_main+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pthread_main=yes
+else
+  ac_cv_lib_pthread_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5
+$as_echo "$ac_cv_lib_pthread_main" >&6; }
+if test "x$ac_cv_lib_pthread_main" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
+
+  LIBS="-lpthread $LIBS"
+
+fi
+
+
+# Checks for header files.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unistd.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
+if test "x$ac_cv_header_unistd_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UNISTD_H 1
+_ACEOF
+
+fi
+
+done
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
+if ${ac_cv_header_stdbool_h+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+             #include <stdbool.h>
+             #ifndef bool
+              "error: bool is not defined"
+             #endif
+             #ifndef false
+              "error: false is not defined"
+             #endif
+             #if false
+              "error: false is not 0"
+             #endif
+             #ifndef true
+              "error: true is not defined"
+             #endif
+             #if true != 1
+              "error: true is not 1"
+             #endif
+             #ifndef __bool_true_false_are_defined
+              "error: __bool_true_false_are_defined is not defined"
+             #endif
+
+             struct s { _Bool s: 1; _Bool t; } s;
+
+             char a[true == 1 ? 1 : -1];
+             char b[false == 0 ? 1 : -1];
+             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+             char d[(bool) 0.5 == true ? 1 : -1];
+             /* See body of main program for 'e'.  */
+             char f[(_Bool) 0.0 == false ? 1 : -1];
+             char g[true];
+             char h[sizeof (_Bool)];
+             char i[sizeof s.t];
+             enum { j = false, k = true, l = false * true, m = true * 256 };
+             /* The following fails for
+                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+             _Bool n[m];
+             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+             /* Catch a bug in an HP-UX C compiler.  See
+                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+              */
+             _Bool q = true;
+             _Bool *pq = &q;
+
+int
+main ()
+{
+
+             bool e = &s;
+             *pq |= q;
+             *pq |= ! q;
+             /* Refer to every declared value, to avoid compiler optimizations.  */
+             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                     + !m + !n + !o + !p + !q + !pq);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdbool_h=yes
+else
+  ac_cv_header_stdbool_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+   ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+if test "x$ac_cv_type__Bool" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if ${ac_cv_c_inline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
+case $ac_cv_c_uint16_t in #(
+  no|yes) ;; #(
+  *)
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint16_t $ac_cv_c_uint16_t
+_ACEOF
+;;
+  esac
+
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT32_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+  esac
+
+ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
+case $ac_cv_c_uint8_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT8_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint8_t $ac_cv_c_uint8_t
+_ACEOF
+;;
+  esac
+
+
+# Checks for library functions.
+for ac_header in stdlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdlib_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
+$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
+if ${ac_cv_func_malloc_0_nonnull+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_malloc_0_nonnull=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *malloc ();
+#endif
+
+int
+main ()
+{
+return ! malloc (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_malloc_0_nonnull=yes
+else
+  ac_cv_func_malloc_0_nonnull=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
+$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
+if test $ac_cv_func_malloc_0_nonnull = yes; then :
+
+$as_echo "#define HAVE_MALLOC 1" >>confdefs.h
+
+else
+  $as_echo "#define HAVE_MALLOC 0" >>confdefs.h
+
+   case " $LIBOBJS " in
+  *" malloc.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS malloc.$ac_objext"
+ ;;
+esac
+
+
+$as_echo "#define malloc rpl_malloc" >>confdefs.h
+
+fi
+
+
+for ac_func in memset strtol
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    if test "x$cache_file" != "x/dev/null"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by openolt $as_me 1.4.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <voltha-discuss@opencord.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+openolt config.status 1.4.0
+configured by $0, generated by GNU Autoconf 2.69,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
+  case $ac_file in
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+ ;;
+
+
+  esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/agent/test/configure.ac b/agent/test/configure.ac
new file mode 100644
index 0000000..dbd77f0
--- /dev/null
+++ b/agent/test/configure.ac
@@ -0,0 +1,53 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([openolt], [1.4.0], [voltha-discuss@opencord.org])
+AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_HEADERS([config.h])
+
+AC_ARG_WITH(sysroot,
+  [AS_HELP_STRING([--with-sysroot[=DIR]], [search for usr/include, usr/lib, usr/lib64 etal within DIR])],
+  [
+  sysroot=$withval
+
+  if test "$sysroot" = "yes"; then
+    sysroot='${exec_prefix}/${target_alias}/sys-root'
+  elif test "$sysroot" = "no"; then
+    sysroot=
+  fi
+
+  if test "x$sysroot" != x; then
+    CXXFLAGS="$CXXFLAGS --sysroot=$sysroot"
+    LDFLAGS="$LDFLAGS --sysroot=$sysroot"
+  fi
+  ], [])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_AWK
+AC_PROG_SED
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+# Checks for libraries.
+AC_CHECK_LIB([dl], [main])
+AC_CHECK_LIB([pthread], [main])
+
+# Checks for header files.
+AC_CHECK_HEADERS([unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([memset strtol])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/agent/test/inc/bal_mocker.h b/agent/test/inc/bal_mocker.h
new file mode 100644
index 0000000..85bdb22
--- /dev/null
+++ b/agent/test/inc/bal_mocker.h
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __BAL_MOCKER_H__
+#define __BAL_MOCKER_H__
+#include <cmock/cmock.h>
+#include <cstdlib>
+extern "C" {
+#include <bcmos_system.h>
+#include <bcmolt_api.h>
+#include <bcm_dev_log.h>
+#include "bcmos_errno.h"
+#include "bcmolt_system_types_typedefs.h"
+#include "bcmolt_msg.h"
+
+/** Host subsystem initialization parameters */
+typedef struct bcmolt_host_init_parms
+{
+    int dummy;
+} bcmolt_host_init_parms;
+
+}
+
+class BalMocker : public CMockMocker<BalMocker>
+{
+public:
+    MOCK_METHOD1(bcmolt_host_init, bcmos_errno(bcmolt_host_init_parms*));
+    MOCK_METHOD2(bcmolt_cfg_get, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
+    MOCK_METHOD2(bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
+};
+#endif
diff --git a/agent/test/inc/bal_stub.h b/agent/test/inc/bal_stub.h
new file mode 100644
index 0000000..4001327
--- /dev/null
+++ b/agent/test/inc/bal_stub.h
@@ -0,0 +1,29 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _BAL_STUB_H_
+#define _BAl_STUB_H_
+extern "C" {
+#include <test_stub.h>
+
+
+void bcmos_usleep(uint32_t us);
+void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags);
+long bcmos_fastlock_lock(bcmos_fastlock *lock);
+void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags);
+}
+#endif
diff --git a/agent/test/inc/bal_version.h b/agent/test/inc/bal_version.h
new file mode 100644
index 0000000..dbeb1e7
--- /dev/null
+++ b/agent/test/inc/bal_version.h
@@ -0,0 +1,22 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __BAL_VERSION_H__
+#define __BAL_VERSION_H__
+// This is stub header file for unit test case only
+
+#endif
+
diff --git a/agent/test/inc/bcm_api_cli.h b/agent/test/inc/bcm_api_cli.h
new file mode 100644
index 0000000..f0c98af
--- /dev/null
+++ b/agent/test/inc/bcm_api_cli.h
@@ -0,0 +1,22 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __BCMAPI_CLI_H__
+#define __BCMAPI_CLI_H__
+// This is stub header file for unit test case only
+//
+#endif
diff --git a/agent/test/inc/bcmcli.h b/agent/test/inc/bcmcli.h
new file mode 100644
index 0000000..daef962
--- /dev/null
+++ b/agent/test/inc/bcmcli.h
@@ -0,0 +1,22 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __BCMCLI_H__
+#define __BCMCLI_H__
+// This is stub header file for unit test case only
+//
+#endif
diff --git a/agent/test/inc/bcmcli_session.h b/agent/test/inc/bcmcli_session.h
new file mode 100644
index 0000000..0855ad5
--- /dev/null
+++ b/agent/test/inc/bcmcli_session.h
@@ -0,0 +1,49 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __BCMCLI_SESSION_H__
+#define __BCMCLI_SESSION_H__
+#include "bcmos_errno.h"
+// This is a stub header file for unit test case only
+typedef int bcmcli_session;
+typedef char bcmcli_entry[50];
+typedef char bcmcli_cmd_parm;
+struct bcmos_task {
+    char task_name[50];
+};
+
+typedef struct bcmcli_session_parm {
+    void *get_prompt;
+    int access_right;
+} bcmcli_session_parm;
+
+#define BCMCLI_ACCESS_ADMIN 0xff
+#define BUG_ON //
+#define BCMCLI_MAKE_CMD_NOPARM(ptr, command1, command2, command3)
+#define BAL_API_VERSION 3
+
+
+extern bool bcmcli_is_stopped(bcmcli_session *sess);
+extern bool bcmcli_parse(bcmcli_session *sess, char *s);
+extern bool bcmcli_driver(bcmcli_session *sess);
+extern void bcmcli_token_destroy(void *);
+extern void bcmcli_session_close(bcmcli_session *sess);
+extern bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess);
+extern void bcmcli_stop(bcmcli_session *sess);
+extern void bcmcli_session_print(bcmcli_session *sess, const char *s);
+extern bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess);
+#endif
+
diff --git a/agent/test/inc/bcmolt_api_topology.h b/agent/test/inc/bcmolt_api_topology.h
new file mode 100644
index 0000000..17709ea
--- /dev/null
+++ b/agent/test/inc/bcmolt_api_topology.h
@@ -0,0 +1,23 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __BCMOLT_API_TOPOLOGY_H__
+#define __BCMOLT_API_TOPOLOGY_H__
+// This is stub header file for unit test case only
+
+#endif
+
+
diff --git a/agent/test/inc/bcmolt_conn_mgr.h b/agent/test/inc/bcmolt_conn_mgr.h
new file mode 100644
index 0000000..124da6c
--- /dev/null
+++ b/agent/test/inc/bcmolt_conn_mgr.h
@@ -0,0 +1,31 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __BCMOLT_CONN_MGR_H__
+#define __BCMOLT_CONN_MGR_H__
+// This is stub header file for unit tets case only
+//
+extern "C" {
+typedef char bcmolt_cm_addr[100];
+
+typedef int bcmolt_goid;
+
+typedef struct bcmos_fastlock {
+    pthread_mutex_t lock;
+} bcmos_fastlock;
+
+}
+#endif
diff --git a/agent/test/inc/test_stub.h b/agent/test/inc/test_stub.h
new file mode 100644
index 0000000..f2e87b1
--- /dev/null
+++ b/agent/test/inc/test_stub.h
@@ -0,0 +1,40 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __TEST_STUB_H__
+#define __TEST_STUB_H__
+
+#include <pthread.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#include "bcmolt_conn_mgr.h"
+#include "bcmcli_session.h"
+#include "bcmos_errno.h"
+
+// defines some stub definitions that are not available to openolt application
+// when compoling in TEST_MODE
+//#define BCMOLT_TM_QUEUE_KEY_TM_Q_SET_ID_DEFAULT 0
+#define MAX_SUPPORTED_PON 16
+
+
+void bcmos_usleep(uint32_t us);
+void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags);
+long bcmos_fastlock_lock(bcmos_fastlock *lock);
+void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags);
+
+#endif //__TEST_STUB_H__
+
diff --git a/agent/test/src/bal_mocker.cc b/agent/test/src/bal_mocker.cc
new file mode 100644
index 0000000..b38906f
--- /dev/null
+++ b/agent/test/src/bal_mocker.cc
@@ -0,0 +1,25 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+
+#include "bal_mocker.h"
+extern "C" {
+CMOCK_MOCK_FUNCTION1(BalMocker, bcmolt_host_init, bcmos_errno(bcmolt_host_init_parms*));
+CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_cfg_get, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
+CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
+}
diff --git a/agent/test/src/bal_stub.cc b/agent/test/src/bal_stub.cc
new file mode 100644
index 0000000..5ab1b79
--- /dev/null
+++ b/agent/test/src/bal_stub.cc
@@ -0,0 +1,318 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+// This file stub definitions for some BAL APIs that are unavailable
+// in TEST_MODE
+//
+extern "C" {
+#include <test_stub.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <bcmos_system.h>
+#include <bcmolt_msg.h>
+#include <bcmolt_host_api.h>
+
+char log_string[500];
+dev_log_id def_log_id=0;
+
+void bcmos_usleep(uint32_t us) {
+    // let always sleep for 1s irrespective of the value passed.
+    sleep (1);
+}
+
+void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags)  {
+    pthread_mutex_init(&(lock->lock), NULL);
+}
+
+long bcmos_fastlock_lock(bcmos_fastlock *lock) {
+    pthread_mutex_lock(&(lock->lock));
+}
+
+void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags) {
+    pthread_mutex_unlock(&(lock->lock));
+}
+
+/* Initialize API layer */
+bcmos_errno bcmolt_api_init(void)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Set configuration */
+bcmos_errno bcmolt_cfg_set(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Get configuration */
+/*
+bcmos_errno bcmolt_cfg_get(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+*/
+
+/* Clear configuration */
+bcmos_errno bcmolt_cfg_clear(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Get statistics */
+bcmos_errno bcmolt_stat_get(bcmolt_oltid olt, bcmolt_stat *stat, bcmolt_stat_flags flags)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Get statistics configuration */
+bcmos_errno bcmolt_stat_cfg_get(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Set statistics configuration */
+bcmos_errno bcmolt_stat_cfg_set(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Register Autonomous Indication Message Handler */
+bcmos_errno bcmolt_ind_subscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Un-register Autonomous Indication Message Handler registered by bcmolt_ind_subscribe() */
+bcmos_errno bcmolt_ind_unsubscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Submit Operation */
+/*
+bcmos_errno bcmolt_oper_submit(bcmolt_oltid olt, bcmolt_oper *oper)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+*/
+
+/* Get configuration of multiple objects */
+bcmos_errno bcmolt_multi_cfg_get(
+    bcmolt_oltid olt,
+    bcmolt_multi_cfg *cfg,
+    bcmolt_filter_flags filter_flags)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Get statistics of multiple objects */
+bcmos_errno bcmolt_multi_stat_get(
+    bcmolt_oltid olt,
+    bcmolt_multi_stat *stat,
+    bcmolt_stat_flags stat_flags,
+    bcmolt_filter_flags filter_flags)
+{
+    printf("-- entering :stubbed %s\n", __FUNCTION__);
+    return BCM_ERR_OK;
+}
+
+/* Map error code to error string */
+const char *bcmos_strerror(bcmos_errno err)
+{
+    static const char *errstr[] = {
+        [-BCM_ERR_OK]                        = "OK",
+        [-BCM_ERR_IN_PROGRESS]               = "In progress",
+        [-BCM_ERR_PARM]                      = "Error in parameters",
+        [-BCM_ERR_NOMEM]                     = "No memory",
+        [-BCM_ERR_NORES]                     = "No resources",
+        [-BCM_ERR_INTERNAL]                  = "Internal error",
+        [-BCM_ERR_NOENT]                     = "Entry doesn't exist",
+        [-BCM_ERR_NODEV]                     = "Device doesn't exist",
+        [-BCM_ERR_ALREADY]                   = "Entry already exists/already in requested state",
+        [-BCM_ERR_RANGE]                     = "Out of range",
+        [-BCM_ERR_PERM]                      = "No permission to perform an operation",
+        [-BCM_ERR_NOT_SUPPORTED]             = "Operation is not supported",
+        [-BCM_ERR_PARSE]                     = "Parsing error",
+        [-BCM_ERR_INVALID_OP]                = "Invalid operation",
+        [-BCM_ERR_IO]                        = "I/O error",
+        [-BCM_ERR_STATE]                     = "Object is in bad state",
+        [-BCM_ERR_DELETED]                   = "Object is deleted",
+        [-BCM_ERR_TOO_MANY]                  = "Too many objects",
+        [-BCM_ERR_NO_MORE]                   = "No more entries",
+        [-BCM_ERR_OVERFLOW]                  = "Buffer overflow",
+        [-BCM_ERR_COMM_FAIL]                 = "Communication failure",
+        [-BCM_ERR_NOT_CONNECTED]             = "No connection with the target system",
+        [-BCM_ERR_SYSCALL_ERR]               = "System call returned error",
+        [-BCM_ERR_MSG_ERROR]                 = "Received message is insane",
+        [-BCM_ERR_TOO_MANY_REQS]             = "Too many outstanding requests",
+        [-BCM_ERR_TIMEOUT]                   = "Operation timed out",
+        [-BCM_ERR_TOO_MANY_FRAGS]            = "Too many fragments",
+        [-BCM_ERR_NULL]                      = "Got NULL pointer",
+        [-BCM_ERR_READ_ONLY]                 = "Attempt to set read-only parameter",
+        [-BCM_ERR_ONU_ERR_RESP]              = "ONU returned an error response",
+        [-BCM_ERR_MANDATORY_PARM_IS_MISSING] = "Mandatory parameter is missing",
+        [-BCM_ERR_KEY_RANGE]                 = "Key field out of range",
+        [-BCM_ERR_QUEUE_EMPTY]               = "Rx of PCIe empty",
+        [-BCM_ERR_QUEUE_FULL]                = "Tx of PCIe full",
+        [-BCM_ERR_TOO_LONG]                  = "Processing is taking too long, but will finish eventually",
+        [-BCM_ERR_INSUFFICIENT_LIST_MEM]     = "Insufficient list memory provided",
+        [-BCM_ERR_OUT_OF_SYNC]               = "Sequence number or operation step was out of sync",
+        [-BCM_ERR_CHECKSUM]                  = "Checksum error",
+        [-BCM_ERR_IMAGE_TYPE]                = "Unsupported file/image type",
+        [-BCM_ERR_INCOMPLETE_TERMINATION]    = "Incomplete premature termination",
+        [-BCM_ERR_MISMATCH]                  = "Parameters mismatch",
+    };
+    static const char *unknown = "*unknown*";
+
+    if ((unsigned)(-err) >= sizeof(errstr)/sizeof(errstr[0]) || !errstr[-err])
+        return unknown;
+    return errstr[-err];
+}
+
+void bcmolt_msg_free(bcmolt_msg *msg)
+{
+    return;
+}
+
+void bcmolt_api_set_prop_present(bcmolt_msg *msg, const void *prop_ptr)
+{
+    return;
+}
+
+const bcmolt_enum_val bcmolt_obj_id_string_table[] = {"dummy string, never used"};
+const bcmolt_enum_val bcmolt_interface_state_string_table[] = {"dummy string, never used"};
+
+dev_log_id bcm_dev_log_id_register(const char *xi_name,
+     bcm_dev_log_level xi_default_log_level,
+     bcm_dev_log_id_type xi_default_log_type) {
+    return 0;
+}
+bool bcmcli_is_stopped(bcmcli_session *sess) {
+    printf("-- stub bcmcli_is_stopped called --\n");
+    return true;
+}
+
+bool bcmcli_parse(bcmcli_session *sess, char *s) {
+    printf("--  stub bcmcli_parse called --\n");
+    return true;
+}
+
+bool bcmcli_driver(bcmcli_session *sess) {
+    printf("--  stub bcmcli_driver called --\n");
+    return true;
+}
+void bcmcli_token_destroy(void *ptr) {
+    printf("--  stub  bcmcli_token_destroy called --\n");
+    return;
+}
+
+void bcmcli_session_close( bcmcli_session*ptr) {
+    printf("--  stub bcmcli_session_close called --\n");
+    return;
+}
+
+bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess) {
+    printf("-- stub bcm_api_cli_set_commands called --\n");
+    return BCM_ERR_OK;
+}
+
+void bcmcli_stop(bcmcli_session *sess) {
+    printf("-- stub bcmcli_stop called --\n");
+    return;
+}
+
+void bcmcli_session_print(bcmcli_session *sess, const char *s) {
+    printf("-- stub bcmcli_session_print called --\n");
+    return;
+}
+
+bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess) {
+    printf("-- stub bcmcli_session_open called --\n");
+    return BCM_ERR_OK;
+}
+
+void bcm_dev_log_log(dev_log_id xi_id,
+    bcm_dev_log_level xi_log_level,
+    uint32_t xi_flags,
+    const char *fmt,
+    ...) {
+    memset(log_string, '\0', sizeof(log_string));
+    va_list args;
+    va_start(args, fmt);
+    vsnprintf(log_string, 490, fmt, args);
+    switch (xi_log_level) {
+        case DEV_LOG_LEVEL_FATAL:
+            printf("FATAL: %s\n", log_string);
+            // exit (0);
+            break;
+        case DEV_LOG_LEVEL_ERROR:
+            printf("ERROR : %s\n", log_string);
+            break;
+        case DEV_LOG_LEVEL_WARNING:
+            printf("WARNING : %s\n", log_string);
+            break;
+        case DEV_LOG_LEVEL_INFO:
+            printf("INFO : %s\n", log_string);
+            break;
+        case DEV_LOG_LEVEL_DEBUG:
+            printf("DEBUG : %s\n", log_string);
+            break;
+        default:
+            printf("%s\n", log_string);
+    }
+    va_end(args);
+}
+
+bcmos_errno bcmos_task_query(const bcmos_task *task, bcmos_task_parm *parm) {
+    printf (" -- stub bcmos_task_query called --\n");
+    return BCM_ERR_OK;
+}
+
+bcmos_errno bcmos_task_create(bcmos_task *task, const bcmos_task_parm *parm) {
+    printf (" -- stub bcmos_task_create called --\n");
+    return BCM_ERR_OK;
+}
+
+int bcmos_printf(const char *fmt, ...) {
+    memset(log_string, '\0', sizeof(log_string));
+    va_list args;
+    va_start(args, fmt);
+    vsnprintf(log_string, 490, fmt, args);
+    printf("%s\n", log_string);
+    va_end(args);
+
+}
+
+bcmos_bool bcmolt_api_conn_mgr_is_connected(bcmolt_goid olt) {
+    printf ("-- stub bcmolt_api_conn_mgr_is_connected called --\n");
+    return true;
+}
+}
diff --git a/agent/test/src/main_test.cc b/agent/test/src/main_test.cc
new file mode 100644
index 0000000..7f04e9c
--- /dev/null
+++ b/agent/test/src/main_test.cc
@@ -0,0 +1,23 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "gtest/gtest.h"
+
+int main(int argc, char **argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/agent/test/src/test_enable_olt.cc b/agent/test/src/test_enable_olt.cc
new file mode 100644
index 0000000..0cdb965
--- /dev/null
+++ b/agent/test/src/test_enable_olt.cc
@@ -0,0 +1,162 @@
+/*
+    Copyright (C) 2018 Open Networking Foundation
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "gtest/gtest.h"
+#include "bal_mocker.h"
+#include "core.h"
+
+class TestOltEnable : public ::testing::Test {
+ protected:
+  virtual void SetUp() {
+  }
+
+  virtual void TearDown() {
+    // Code here will be called immediately after each test
+    // (right before the destructor).
+  }
+};
+
+
+// Test Fixture for OltEnable
+
+// Test 1: OltEnableSuccess case
+TEST_F(TestOltEnable, OltEnableSuccess){
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}
+
+// Test 2: OltEnableFail_host_init_fail
+TEST_F(TestOltEnable, OltEnableFail_host_init_fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_INTERNAL;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 3: OltEnableSuccess_PON_Device_Connected
+TEST_F(TestOltEnable, OltEnableSuccess_PON_Device_Connected) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}
+
+// Test 4: OltEnableFail_All_PON_Enable_Fail
+TEST_F(TestOltEnable, OltEnableFail_All_PON_Enable_Fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res = BCM_ERR_INTERNAL;
+
+    Status olt_enable_res;
+
+    // Ensure that the state of the OLT is in deactivated to start with..
+    state.deactivate();
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 5 OltEnableSuccess_One_PON_Enable_Fail : One PON device enable fails, but all others succeed.
+TEST_F(TestOltEnable, OltEnableSuccess_One_PON_Enable_Fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res_fail = BCM_ERR_INTERNAL;
+    bcmos_errno olt_oper_res_success = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // Ensure that the state of the OLT is in deactivated to start with..
+    state.deactivate();
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    // For the the first PON mac device, the activation result will fail, and will succeed for all other PON mac devices.
+    EXPECT_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_))
+                         .WillOnce(::testing::Return(olt_oper_res_fail))
+                         .WillRepeatedly(::testing::Return(olt_oper_res_success));
+
+    olt_enable_res = Enable_(1, NULL);
+    // The OLT activation should succeed if at least one PON mac device activation succeeds.
+    ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}