Bump version to 3.2.0
Update README.md for voltha-2.6 release
Update BUILDING.md file for using BAL3.4.9.6 package
Update debian package files to build for BAL 3.4.9.6
Fix issue in dev_mgmt_daemon service script

Change-Id: I0853bef9f30f67b8db0868f6dbb92c8248ce0130
diff --git a/BUILDING.md b/BUILDING.md
index ef0cc54..8a9283e 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -2,7 +2,7 @@
 
 ## Supported BAL API versions
 
-Currently, OpenOLT supports Broadcom's BAL API, version *3.4.7.5*.
+Currently, OpenOLT supports Broadcom's BAL API, version *3.4.9.6*.
 
 ## Proprietary software requirements
 
@@ -14,9 +14,9 @@
 
 The versions currently supported by the OpenOLT agent are:
 
-* `SW-BCM686OLT_3_4_7_5.tgz`
+* `SW-BCM686OLT_3_4_9_6.tgz`
 * `sdk-all-6.5.13.tar.gz`
-* `ACCTON_BAL_3.4.7.5-V202008030101_rate_limiting_fixed.patch`. This is downloadable from the common CSP CS00003233745. Rename this file as `ACCTON_BAL_3.4.7.5-V202008030101.patch`
+* `ACCTON_BAL_3.4.9.6-V202008310101.patch`. This is downloadable from the common CSP CS00003233745.
 
 > NOTE: the repository does not contain the above three source packages.  These
 > are needed to build the OpenOLT agent executable. Contact [Dave Baron at
@@ -120,7 +120,7 @@
 
 ```shell
 cd <dir containing Broadcom source and patch files>
-cp ACCTON_BAL_3.4.7.5-V202008030101.patch SW-BCM686OLT_3_4_7_5.tgz sdk-all-6.5.13.tar.gz <cloned openolt repo path>/agent/download
+cp ACCTON_BAL_3.4.9.6-V202008310101.patch SW-BCM686OLT_3_4_9_6.tgz sdk-all-6.5.13.tar.gz <cloned openolt repo path>/agent/download
 ```
 
 Run the configure script to generate the appropriate Makefile scaffolding for
@@ -151,7 +151,7 @@
 make OPENOLTDEVICE=asfvolt16 OPENOLT_PROTO_VER=master
 ```
 
-By default, the `OPENOLT_PROTO_VER` defaults to git tag *v4.0.2* of the
+By default, the `OPENOLT_PROTO_VER` defaults to git tag *v4.0.3* of the
 [voltha-protos](https://gerrit.opencord.org/gitweb?p=voltha-protos.git;a=summary)
 repo.
 
diff --git a/Makefile b/Makefile
index 7b8deb9..d3ecd08 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@
 
 ## Variables
 OPENOLTDEVICE     ?= asfvolt16
-OPENOLT_PROTO_VER ?= v4.0.2
+OPENOLT_PROTO_VER ?= v4.0.3
 
 DOCKER                     ?= docker
 DOCKER_REGISTRY            ?=
diff --git a/README.md b/README.md
index 0ec5692..ff9757f 100644
--- a/README.md
+++ b/README.md
@@ -55,13 +55,13 @@
 `/ASXvOLT16/OpenOLT_Agent/From_ONF_Distribution/` and pick the right version of
 `.deb` package required for your testing.
 
-`voltha-2.5/openolt_<OPENOLTDEVICE>-2.5.0-<GIT Commit ID>.deb` is the latest version of package with support
-for BAL v3.4.7.5 .
+`voltha-2.6/openolt_<OPENOLTDEVICE>-2.6.0-<GIT Commit ID>.deb` is the latest version of package with support
+for BAL v3.4.9.6 .
 
 The pre-built debian packages have been tested on [Open Networking Linux
 (ONL)](http://opennetlinux.org/) version 4.14. The ONL Installer required for
-`voltha-2.5/openolt_<OPENOLTDEVICE>-2.5.0-<GIT Commit ID>.deb` is also available at in the same path, i.e.,
-voltha-2.5/.
+`voltha-2.6/openolt_<OPENOLTDEVICE>-2.6.0-<GIT Commit ID>.deb` is also available at in the same path, i.e.,
+voltha-2.6/.
 
 ## Install OpenOLT
 
@@ -74,10 +74,10 @@
 Install the *openolt.deb* package using *dpkg*:
 
 ```shell
-dpkg -i openolt_<OPENOLTDEVICE>-2.5.0-<GIT Commit ID>.deb
+dpkg -i openolt_<OPENOLTDEVICE>-2.6.0-<GIT Commit ID>.deb
 ```
 
-The ONL version required for BAL v3.4.7.5 is ONL `4.14.151-OpenNetworkLinux`. This
+The ONL version required for BAL v3.4.9.6 is ONL `4.14.151-OpenNetworkLinux`. This
 will be built as part of build procedure described `Build OpenOLT` section.
 
 ## Run OpenOLT as a Linux service
diff --git a/VERSION b/VERSION
index 8d70082..944880f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.1.1-dev
+3.2.0
diff --git a/agent/Makefile.in b/agent/Makefile.in
index 9ec04a6..b8000d3 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -28,12 +28,12 @@
 # ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch.
 BAL_MAJOR_VER = 3
 BAL_MINOR_VER = 4
-BAL_REV_A_VER = 7
-BAL_REV_B_VER = 5
+BAL_REV_A_VER = 9
+BAL_REV_B_VER = 6
 BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
 BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
 SDK_VER = 6.5.13
-DEV_VER ?= 202008030101
+DEV_VER ?= 202008310101
 #
 # Version of Open Network Linux (ONL).
 ONL_KERN_VER_MAJOR = 4.14
diff --git a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
index f9fb329..7f2928d 100644
--- a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
@@ -17,7 +17,7 @@
 
 rm -rf /opt/bcm68620
 rm -rf /broadcom
-tar zxf /tmp/release_asfvolt16_V3.4.7.5.202008030101.tar.gz -C / 2>&1 > /dev/null
+tar zxf /tmp/release_asfvolt16_V3.4.9.6.202008310101.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
 mkdir -p /opt/openolt && cp /tmp/watchdog/openolt_dev_mgmt_daemon_process_watchdog /opt/openolt && cp /tmp/watchdog/watchdog.config /opt/openolt
diff --git a/agent/device/asfvolt16/mkdebian/debian/changelog b/agent/device/asfvolt16/mkdebian/debian/changelog
index 86e8f51..cf594d3 100644
--- a/agent/device/asfvolt16/mkdebian/debian/changelog
+++ b/agent/device/asfvolt16/mkdebian/debian/changelog
@@ -1,6 +1,6 @@
-asfvolt16 (3.4.7.5+edgecore-V202008030101) stable; urgency=high
+asfvolt16 (3.4.9.6+edgecore-V202008310101) stable; urgency=high
 
-    * Based on code from SW-BCM686OLT_3_4_7_5.tgz.
-    * Merged the Accton's fixed to ACCTON_BAL_3.4.7.5-V202008030101.patch.
+    * Based on code from SW-BCM686OLT_3_4_9_6.tgz.
+    * Merged the Accton's fixed to ACCTON_BAL_3.4.9.6-V202008310101.patch.
 
- -- Jason Huang <jasonsc_huang@edge-core.com>  Mon, 03 AUG 2020 01:01:03 +0800
+ -- Jason Huang <jasonsc_huang@edge-core.com>  Mon, 30 NOV 2020 01:01:03 +0800
diff --git a/agent/device/asfvolt16/mkdebian/debian/control b/agent/device/asfvolt16/mkdebian/debian/control
index abacf17..d7cc78d 100644
--- a/agent/device/asfvolt16/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-3.4.7.5 package
+  ported from Broadcom SDK-3.4.9.6 package
 
diff --git a/agent/device/asfvolt16/mkdebian/debian/files b/agent/device/asfvolt16/mkdebian/debian/files
index 8ce7e13..6c6932a 100644
--- a/agent/device/asfvolt16/mkdebian/debian/files
+++ b/agent/device/asfvolt16/mkdebian/debian/files
@@ -1 +1 @@
-asfvolt16_3.4.7.5+edgecore-V202008030101_amd64.deb misc optional
+asfvolt16_3.4.9.6+edgecore-V202008310101_amd64.deb misc optional
diff --git a/agent/device/asfvolt16/mkdebian/debian/rules b/agent/device/asfvolt16/mkdebian/debian/rules
index 9ede076..61726b9 100755
--- a/agent/device/asfvolt16/mkdebian/debian/rules
+++ b/agent/device/asfvolt16/mkdebian/debian/rules
@@ -26,7 +26,7 @@
 
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/release_asfvolt16_V3.4.7.5.202008030101.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/release_asfvolt16_V3.4.9.6.202008310101.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libz.so.1 $(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
diff --git a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
index b4309df..ca5f4c9 100644
--- a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
@@ -17,7 +17,7 @@
 
 rm -rf /opt/bcm68620
 rm -rf /broadcom
-tar zxf /tmp/release_asgvolt64_V3.4.7.5.202008030101.tar.gz -C / 2>&1 > /dev/null
+tar zxf /tmp/release_asgvolt64_V3.4.9.6.202008310101.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
 mkdir -p /opt/openolt && cp /tmp/watchdog/openolt_dev_mgmt_daemon_process_watchdog /opt/openolt && cp /tmp/watchdog/watchdog.config /opt/openolt
diff --git a/agent/device/asgvolt64/mkdebian/debian/changelog b/agent/device/asgvolt64/mkdebian/debian/changelog
index 0d57e00..317e3ee 100644
--- a/agent/device/asgvolt64/mkdebian/debian/changelog
+++ b/agent/device/asgvolt64/mkdebian/debian/changelog
@@ -1,6 +1,6 @@
-asgvolt64 (3.4.7.5+edgecore-V202008030101) stable; urgency=high
+asgvolt64 (3.4.9.6+edgecore-V202008310101) stable; urgency=high
 
-    * Based on code from SW-BCM686OLT_3_4_7_5.tgz.
-    * Merged the Accton's fixed to ACCTON_BAL_3.4.7.5-V202008030101.patch.
+    * Based on code from SW-BCM686OLT_3_4_9_6.tgz.
+    * Merged the Accton's fixed to ACCTON_BAL_3.4.9.6-V202008310101.patch.
 
- -- Jason Huang <jasonsc_huang@edge-core.com>  Mon, 03 AUG 2020 01:01:03 +0800
+ -- Jason Huang <jasonsc_huang@edge-core.com>  Mon, 30 NOV 2020 01:01:03 +0800
diff --git a/agent/device/asgvolt64/mkdebian/debian/control b/agent/device/asgvolt64/mkdebian/debian/control
index e82223e..721b2d7 100644
--- a/agent/device/asgvolt64/mkdebian/debian/control
+++ b/agent/device/asgvolt64/mkdebian/debian/control
@@ -9,5 +9,5 @@
 Architecture: amd64
 Depends: ${shlibs:Depends}
 Description: Broadcom OLT drivers,CLI
-  ported from Broadcom SDK-3.4.7.5 package
+  ported from Broadcom SDK-3.4.9.6 package
 
diff --git a/agent/device/asgvolt64/mkdebian/debian/files b/agent/device/asgvolt64/mkdebian/debian/files
index 436e715..365a521 100644
--- a/agent/device/asgvolt64/mkdebian/debian/files
+++ b/agent/device/asgvolt64/mkdebian/debian/files
@@ -1 +1 @@
-asgvolt64_3.4.7.5+edgecore-V202008030101_amd64.deb misc optional
+asgvolt64_3.4.9.6+edgecore-V202008310101_amd64.deb misc optional
diff --git a/agent/device/asgvolt64/mkdebian/debian/rules b/agent/device/asgvolt64/mkdebian/debian/rules
index 2a7d1d8..58f1ecf 100755
--- a/agent/device/asgvolt64/mkdebian/debian/rules
+++ b/agent/device/asgvolt64/mkdebian/debian/rules
@@ -26,7 +26,7 @@
 
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/release_asgvolt64_V3.4.7.5.202008030101.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/release_asgvolt64_V3.4.9.6.202008310101.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libz.so.1 $(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
diff --git a/agent/scripts/init.d/dev_mgmt_daemon b/agent/scripts/init.d/dev_mgmt_daemon
index 109e34f..3b05b8f 100755
--- a/agent/scripts/init.d/dev_mgmt_daemon
+++ b/agent/scripts/init.d/dev_mgmt_daemon
@@ -19,13 +19,13 @@
 PORT_SPEED_FILE="$APPDIR/port_speed.soc"
 TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config.ini"
 OLT_MODEL=`cat /sys/devices/virtual/dmi/id/board_name`
-if [ $OLT_MODEL = "ASXvOLT16" ]; then
+if [ "$OLT_MODEL" = "ASXvOLT16" ]; then
     Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
-    [ $Port_100G_SPEED = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
+    [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
     APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
-elif [ $OLT_MODEL = "ASGvOLT64" ]; then
+elif [ "$OLT_MODEL" = "ASGvOLT64" ]; then
     Port_100G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_100 " '{print $2}'`
-    [ $Port_100G_SPEED = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
+    [ "$Port_100G_SPEED" = "10000" ] && TOPOLOGY_CONFIG_FILE="$APPDIR/topology_config_16_ports.ini"
     Port_25G_SPEED=`cat $PORT_SPEED_FILE | awk -F "port_speed_for_25 " '{print $2}'`
     APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
 else
diff --git a/agent/src/stats_collection.cc b/agent/src/stats_collection.cc
index 11766c7..99747f4 100644
--- a/agent/src/stats_collection.cc
+++ b/agent/src/stats_collection.cc
@@ -103,6 +103,7 @@
     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;
     bcmolt_internal_nni_enet_stats enet_stat;
 
@@ -192,6 +193,27 @@
                 OPENOLT_LOG(ERROR, openolt_log_id,  "Failed to retrieve port statistics, intf_id %d, intf_type %d, err = %s\n",
                     (int)intf_ref.intf_id, (int)intf_ref.intf_type, bcmos_strerror(err));
             }
+#if 1 // Shall be fixed as part of VOL-3691. When fixed, the #else code block should be enabled.
+            {
+                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);
+
+                /* 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 = %s\n",
+                        (int)intf_ref.intf_id, (int)intf_ref.intf_type, bcmos_strerror(err));
+                }
+            }
+#else
 
             {
                 bcmolt_internal_nni_key key = {};
@@ -255,6 +277,7 @@
                         (int)intf_ref.intf_id, (int)intf_ref.intf_type, bcmos_strerror(err));
                 }
             }
+#endif
             break;
         }
     }
diff --git a/agent/test/Makefile b/agent/test/Makefile
index 5245f03..25c7ce0 100644
--- a/agent/test/Makefile
+++ b/agent/test/Makefile
@@ -41,7 +41,7 @@
 
 export CXX CXXFLAGS OPENOLT_PROTO_VER
 
-BAL_API_VER ?= bal-api-3.4.7.5
+BAL_API_VER ?= bal-api-3.4.9.6
 BAL_API_DIR=$(BAL_API_VER)
 BALLIBNAME=bcm_host_api_stubs
 BALLIBDIR=$(BAL_API_DIR)/stubs