[Add support for MBSS]

[Description]
Add support for MBSS

[Release-log]

diff --git a/src/logan_wifi/wifi_hal.c b/src/logan_wifi/wifi_hal.c
index a881f10..d8d7f8a 100644
--- a/src/logan_wifi/wifi_hal.c
+++ b/src/logan_wifi/wifi_hal.c
@@ -1313,7 +1313,7 @@
 
 
 	if (_syscmd_secure(buf, sizeof(buf), "grep SET_BW%d %s", radioIndex, BW_FNAME)) {
-		res = _syscmd_secure(buf, sizeof(buf), "echo SET_BW%d=%s >> %s", radioIndex, bw_value, BW_FNAME);
+		res = _syscmd_secure(buf, sizeof(buf), "echo SET_BW%d=%s >> /nvram/bw_file.txt", radioIndex, bw_value);
 		if (res) {
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 		}
@@ -1849,13 +1849,26 @@
 	char config_file[MAX_SUB_CMD_SIZE] = {0};
 	char ret_buf[MAX_BUF_SIZE] = {0};
 	char inf_name[IF_NAME_SIZE] = {0};
-	int res;
+	int res, ret, bss_num;
 
     WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
 
 	bss_idx = 0;
+
+	ret = wifi_BandProfileRead(0, radio_idx, "BssidNum", ret_buf, sizeof(ret_buf), "1");
+	if (ret != 0) {
+		wifi_debug(DEBUG_ERROR, "wifi_BandProfileRead BssidNum failed\n");
+		return;
+	}
+
+	bss_num = atoi(ret_buf);
+	if (bss_num <= 0)  {
+		wifi_debug(DEBUG_ERROR, "invalid BssidNum %s\n", ret_buf);
+		return ;
+	}
+	wifi_debug(DEBUG_ERROR, "band %d BssidNum %d\n", radio_idx, bss_num);
 	/*TBD: we need refine setup flow and mbss flow*/
-//    for (bss_idx = 0; bss_idx < 5; bss_idx++) {
+    for (bss_idx = 0; bss_idx < bss_num; bss_idx++) {
 		ap_idx = array_index_to_vap_index(radio_idx, bss_idx);
 
 		res = _syscmd_secure(ret_buf, sizeof(ret_buf), "touch %s%d.psk", PSK_FILE, ap_idx);
@@ -1871,13 +1884,14 @@
 			wifi_debug(DEBUG_ERROR, "Unexpected snprintf fail\n");
 			return;
 		}
-
+		
 		res = _syscmd_secure(ret_buf, sizeof(ret_buf), "hostapd_cli -i global raw ADD bss_config=phy%d:%s", radio_idx, config_file);
 		if (res) {
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 		}
 
 		wifi_GetInterfaceName(ap_idx, inf_name);
+		wifi_debug(DEBUG_ERROR, "bring up %s\n", inf_name);
 
 		memset(cmd, 0, MAX_CMD_SIZE);
 		memset(ret_buf, 0, MAX_BUF_SIZE);
@@ -1888,7 +1902,7 @@
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 		}
 
-//    }
+    }
 
     WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
 }
@@ -2023,7 +2037,7 @@
 
 	for (radio_idx = 0; radio_idx < MAX_NUM_RADIOS; radio_idx++)
 		for (bss_idx = 0; bss_idx < 5; bss_idx++) {
-			res = _syscmd_secure(ret_buf, sizeof(ret_buf), "echo %s%d=0 >> %s", ext_prefix[radio_idx], bss_idx, VAP_STATUS_FILE);
+			res = _syscmd_secure(ret_buf, sizeof(ret_buf), "echo %s%d=0 >> /nvram/vap-status", ext_prefix[radio_idx], bss_idx);
 			if (res) {
 				wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 			}
@@ -2043,7 +2057,7 @@
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 		}
 	} else {
-		res =  _syscmd_secure(ret_buf, sizeof(ret_buf), "echo '' > %s", RADIO_RESET_FILE);
+		res =  _syscmd_secure(ret_buf, sizeof(ret_buf), "echo '' > /nvram/radio_reset");
 		if (res) {
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
 		}
@@ -17544,6 +17558,7 @@
 	int set_mode = 0;
 	BOOL drv_dat_change = 0, hapd_conf_change = 0;
 	wifi_radio_operationParam_t current_param;
+	int ApIndex;
 
 	WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
 
@@ -17687,9 +17702,27 @@
 		if (operationParam->enable == TRUE)
 			wifi_setRadioEnable(index, TRUE);
 	} else if (hapd_conf_change == TRUE) {
-		hostapd_raw_remove_bss(index);
-		if (operationParam->enable == TRUE)
-			hostapd_raw_add_bss(index);
+		int ret, bss_num, i;
+		char ret_buf[MAX_BUF_SIZE] = {0};
+
+		ret = wifi_BandProfileRead(0, index, "BssidNum", ret_buf, sizeof(ret_buf), "1");
+		if (ret != 0) {
+			wifi_debug(DEBUG_ERROR, "wifi_BandProfileRead BssidNum failed\n");
+			return RETURN_ERR;
+		}
+		bss_num = atoi(ret_buf);
+		if (bss_num <= 0)  {
+			wifi_debug(DEBUG_ERROR, "invalid BssidNum %s\n", ret_buf);
+			return RETURN_ERR;
+		}
+		wifi_debug(DEBUG_ERROR, "band %d BssidNum %d\n", index, bss_num);
+
+		for (i = 0; i < bss_num; i++) {
+			ApIndex = array_index_to_vap_index(index, i);
+			hostapd_raw_remove_bss(ApIndex);
+			if (operationParam->enable == TRUE)
+				hostapd_raw_add_bss(ApIndex);
+		}
 	}
 
 	WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
@@ -18201,12 +18234,14 @@
 	if (enable == TRUE) {
 		int radioIndex = apIndex % max_radio_num;
 		phyId = radio_index_to_phy(radioIndex);
-		wifi_debug(DEBUG_ERROR, "%s %d\n", __func__, __LINE__);
 		res = snprintf(config_file, MAX_BUF_SIZE, "%s%d.conf", CONFIG_PREFIX, apIndex);
 		if (os_snprintf_error(MAX_CMD_SIZE, res)) {
 			wifi_debug(DEBUG_ERROR, "Unexpected snprintf fail\n");
 			return RETURN_ERR;
 		}
+
+		wifi_debug(DEBUG_ERROR, "raw ADD bss_config config_file=%s\n", config_file);
+
 		res = _syscmd_secure(buf, sizeof(buf), "hostapd_cli -i global raw ADD bss_config=phy%d:%s", phyId, config_file);
 		if (res) {
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
@@ -18215,6 +18250,8 @@
 
 	} else {
 		wifi_debug(DEBUG_ERROR, "%s %d\n", __func__, __LINE__);
+		
+		wifi_debug(DEBUG_ERROR, "global raw REMOVE %s\n", interface_name);
 		res = _syscmd_secure(buf, sizeof(buf), "hostapd_cli -i global raw REMOVE %s", interface_name);
 		if (res) {
 			wifi_debug(DEBUG_ERROR, "_syscmd_secure fail\n");
@@ -18273,7 +18310,7 @@
 
 	WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
 	printf("Entering %s index = %d\n", __func__, (int)index);
-	for (i = 0; i < map->num_vaps; i++)
+	for (i = 1; i < map->num_vaps; i++)
 	{
 		multiple_set = TRUE;
 		vap_info = &map->vap_array[i];