VOL-3011: Make NNI port speed configurable while building openolt
Change-Id: I6f029005358b8c0e48a4adbe3fd3d3874801f0f7
diff --git a/agent/Makefile.in b/agent/Makefile.in
index 18da811..9ec04a6 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -48,7 +48,10 @@
 INBAND = "n"
 VLAN_ID = 4093
 
-#
+# NNI ports speed setting
+PORT_100G_SPEED ?= 100000
+PORT_25G_SPEED ?= 25000
+
 # Build directory
 BUILD_DIR = build
 
@@ -176,6 +179,7 @@
           -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 -DENABLE_CLI
+PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc
 
 sdk: onl bal-api-$(BAL_API_VER)
 ifeq ("$(wildcard $(BAL_DIR))","")
@@ -184,6 +188,12 @@
 	cp download/$(SDK_ZIP) $(BCM_SDK)
 	chmod -R 744 $(BAL_DIR)
 	cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
+ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16")
+	echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
+else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64")
+	echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
+	echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE)
+endif
 	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
diff --git a/agent/scripts/init.d/dev_mgmt_daemon b/agent/scripts/init.d/dev_mgmt_daemon
index 7637c6d..109e34f 100755
--- a/agent/scripts/init.d/dev_mgmt_daemon
+++ b/agent/scripts/init.d/dev_mgmt_daemon
@@ -14,9 +14,25 @@
 PATH="/broadcom:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 APPDIR="/broadcom"
 APPBIN="dev_mgmt_daemon"
-APPARGS="-pcie -d"
 USER="root"
 GROUP="root"
+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
+    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"
+    APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
+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_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
+    Port_100G_SPEED="100000"
+    Port_25G_SPEED="25000"
+    APPARGS="-pcie -d -port_100g_speed $Port_100G_SPEED -pcie -port_25g_speed $Port_25G_SPEED -topology_config_file $TOPOLOGY_CONFIG_FILE"
+fi
 
 # Include functions
 set -e