mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-11-01 02:48:18 +00:00 
			
		
		
		
	WIFI-14460: Update RRM using Channel Utilization script - Improve policy_chanutil.uc script - Improve scripts reading pdev_stats - Support 6G radio AP - Support WiFi7 AP
Signed-off-by: Tanya Singh <tanya_singh@accton.com>
This commit is contained in:
		 Tanya Singh
					Tanya Singh
				
			
				
					committed by
					
						 John Crispin
						John Crispin
					
				
			
			
				
	
			
			
			 John Crispin
						John Crispin
					
				
			
						parent
						
							caee55a61f
						
					
				
				
					commit
					954108d742
				
			| @@ -6,26 +6,26 @@ board=$(board_name) | |||||||
|  |  | ||||||
| case "$board" in | case "$board" in | ||||||
|     "edgecore,eap101") |     "edgecore,eap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap102") |     "edgecore,eap102") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e-6e"|\ |     "edgecore,oap101e-6e"|\ | ||||||
|     "edgecore,oap101-6e") |     "edgecore,oap101-6e") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy6g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e"|\ |     "edgecore,oap101e"|\ | ||||||
|     "edgecore,oap101") |     "edgecore,oap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap104") |     "edgecore,eap104") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
| esac | esac | ||||||
|   | |||||||
| @@ -6,26 +6,26 @@ board=$(board_name) | |||||||
|  |  | ||||||
| case "$board" in | case "$board" in | ||||||
|     "edgecore,eap101") |     "edgecore,eap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap102") |     "edgecore,eap102") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e-6e"|\ |     "edgecore,oap101e-6e"|\ | ||||||
|     "edgecore,oap101-6e") |     "edgecore,oap101-6e") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy6g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e"|\ |     "edgecore,oap101e"|\ | ||||||
|     "edgecore,oap101") |     "edgecore,oap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap104") |     "edgecore,eap104") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
| esac | esac | ||||||
|   | |||||||
| @@ -6,26 +6,26 @@ board=$(board_name) | |||||||
|  |  | ||||||
| case "$board" in | case "$board" in | ||||||
|     "edgecore,eap101") |     "edgecore,eap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq6018\ hw1.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap102") |     "edgecore,eap102") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/ipq8074\ hw2.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e-6e"|\ |     "edgecore,oap101e-6e"|\ | ||||||
|     "edgecore,oap101-6e") |     "edgecore,oap101-6e") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy6g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,oap101e"|\ |     "edgecore,oap101e"|\ | ||||||
|     "edgecore,oap101") |     "edgecore,oap101") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_1/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
|     "edgecore,eap104") |     "edgecore,eap104") | ||||||
|         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath11k/ipq5018\ hw1.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath11k/qcn6122_2/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ;; |         ;; | ||||||
| esac | esac | ||||||
|   | |||||||
| @@ -6,8 +6,8 @@ board=$(board_name) | |||||||
|  |  | ||||||
| case "$board" in | case "$board" in | ||||||
|     "edgecore,eap105") |     "edgecore,eap105") | ||||||
|         ln -s /sys/kernel/debug/ath12k/ipq5332\ hw1.0_c000000.wifi/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy0 |         ln -s /sys/kernel/debug/ath12k/ipq5332\ hw1.0_c000000.wifi/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy2g | ||||||
|         ln -s /sys/kernel/debug/ath12k/qcn9274\ hw2.0_0001:01:00.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy1 |         ln -s /sys/kernel/debug/ath12k/qcn9274\ hw2.0_0001:01:00.0/mac0/fw_stats/pdev_stats /tmp/pdev_stats_phy5g | ||||||
|         ln -s /sys/kernel/debug/ath12k/qcn9274\ hw2.0_0001:01:00.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy2 |         ln -s /sys/kernel/debug/ath12k/qcn9274\ hw2.0_0001:01:00.0/mac1/fw_stats/pdev_stats /tmp/pdev_stats_phy6g | ||||||
|         ;; |         ;; | ||||||
| esac | esac | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| let board_info = global.ubus.conn.call('system', 'board'); | let board_info = global.ubus.conn.call('system', 'board'); | ||||||
| let _pdev_stats = {}; |  | ||||||
| let config = { | let config = { | ||||||
|     /* Channel utilization threshold: When Utilization of the current channel or adjacent channel reaches the configured threshold (in %), the AP switches to a different Channel. |     /* Channel utilization threshold: When Utilization of the current channel or adjacent channel reaches the configured threshold (in %), the AP switches to a different Channel. | ||||||
|     Set this field to 0 to disable this feature. Range: 0-99 */ |     Set this field to 0 to disable this feature. Range: 0-99 */ | ||||||
| @@ -30,23 +29,23 @@ function stats_info_read(path) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function stats_info_write(path, value) { | function stats_info_write(path, value) { | ||||||
| 	let file = fs.open(path, 'w+'); | 	let file = fs.open(path, 'w'); | ||||||
| 	if (!file) | 	if (!file) | ||||||
| 		return; | 		return; | ||||||
| 	file.write(value); | 	file.write(value); | ||||||
| 	file.close(); | 	file.close(); | ||||||
| } | } | ||||||
|  |  | ||||||
| function cool_down_check(iface_num, cool_down_period) { | function cool_down_check(iface, cool_down_period) { | ||||||
|     let now_t = time(); |     let now_t = time(); | ||||||
|     let cool_down_f= 0; |     let cool_down_f= 0; | ||||||
|  |  | ||||||
|     // check cool_down_period passed or not |     // check cool_down_period passed or not | ||||||
|     let deltaTS = now_t - stats_info_read("/tmp/chan_switch_t" + iface_num); |     let deltaTS = now_t - stats_info_read("/tmp/chan_switch_time_" + iface); | ||||||
|     ulog_info(`[wlan%d] Cool down check: current_time=%d, chan_switch_time=%d, deltaTS(time passed)=%d \n`, iface_num, now_t, stats_info_read("/tmp/chan_switch_t" + iface_num), deltaTS); |     ulog_info(`[%s] Cool down check: current_time=%d, chan_switch_time=%d, deltaTS(time passed)=%d \n`, iface, now_t, stats_info_read("/tmp/chan_switch_time_" + iface), deltaTS); | ||||||
|  |  | ||||||
|     if (deltaTS < (cool_down_period/1000)) { |     if (deltaTS < (cool_down_period/1000)) { | ||||||
|         ulog_info(`[wlan%d] Need to cool down (%d seconds hasn't passed) before switching channel \n`, iface_num, cool_down_period/1000); |         ulog_info(`[%s] Need to cool down (%d seconds hasn't passed) before switching channel \n`, iface, cool_down_period/1000); | ||||||
|         // Flag cool down |         // Flag cool down | ||||||
|         cool_down_f = 1; |         cool_down_f = 1; | ||||||
|     } |     } | ||||||
| @@ -54,12 +53,12 @@ function cool_down_check(iface_num, cool_down_period) { | |||||||
|     return cool_down_f; |     return cool_down_f; | ||||||
| } | } | ||||||
|  |  | ||||||
| function update_channel_switch_time(iface_num) { | function update_channel_switch_time(iface) { | ||||||
|     stats_info_write("/tmp/chan_switch_t" + iface_num, time()); |     stats_info_write("/tmp/chan_switch_time_" + iface, time()); | ||||||
| } | } | ||||||
|  |  | ||||||
| function update_breach_count(iface_num, breach_count) { | function update_breach_count(iface, breach_count) { | ||||||
|     stats_info_write("/tmp/threshold_breach_count_phy" + iface_num , breach_count); |     stats_info_write("/tmp/threshold_breach_count_" + iface , breach_count); | ||||||
| } | } | ||||||
|  |  | ||||||
| function random_time_calc() { | function random_time_calc() { | ||||||
| @@ -98,94 +97,99 @@ function random_time_calc() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function channel_to_freq(band, channel) { | function channel_to_freq(band, channel) { | ||||||
|     if (band == '2g' && channel >= 1 && channel <= 13) |     let freq = 0; | ||||||
|         return 2407 + channel * 5; |  | ||||||
|     else if (band == '2g' && channel == 14) |  | ||||||
|         return 2484; |  | ||||||
|     else if (band == '5g' && channel >= 7 && channel <= 177) |  | ||||||
|         return 5000 + channel * 5; |  | ||||||
|     else if (band == '5g' && channel >= 183 && channel <= 196) |  | ||||||
|         return 4000 + channel * 5; |  | ||||||
|     else if (band == '6g' && channel >= 5) |  | ||||||
|         return 5950 + channel * 5; |  | ||||||
|     else if (band == '60g' && channel >= 1 && channel <= 6) |  | ||||||
|         return 56160 + channel * 2160; |  | ||||||
|  |  | ||||||
|        return null; |     switch (band) { | ||||||
|  |         case '2g': | ||||||
|  |             if (channel == 14) | ||||||
|  |                 freq = 2484; | ||||||
|  |             else | ||||||
|  |                 freq = 2407 + channel * 5; | ||||||
|  |             break; | ||||||
|  |         case '5g': | ||||||
|  |             if (channel >= 7 && channel <= 177) | ||||||
|  |                 freq = 5000 + channel * 5; | ||||||
|  |             else if (channel >= 183 && channel <= 196) | ||||||
|  |                 freq = 4000 + channel * 5; | ||||||
|  |             break; | ||||||
|  |         case '6g': | ||||||
|  |             if (channel == 2) | ||||||
|  |                 freq = 5935; | ||||||
|  |             else | ||||||
|  |                 freq = 5955 + (channel - 1) * 5; | ||||||
|  |             break; | ||||||
|  |         case '60g': | ||||||
|  |             if (channel >= 1 && channel <= 6) | ||||||
|  |                 freq = 56160 + channel * 2160; | ||||||
|  |             break; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return freq; | ||||||
| } | } | ||||||
|  |  | ||||||
| function center_freq_calc(band, freq, bandwidth) { | function center_freq_calc(band, freq, bandwidth) { | ||||||
|     if (band == '5g') { |  | ||||||
|     if (bandwidth == 40) |     if (bandwidth == 40) | ||||||
|         return +freq + 10; |         return +freq + 10; | ||||||
|     if (bandwidth == 80) |     if (bandwidth == 80) | ||||||
|         return +freq + 30; |         return +freq + 30; | ||||||
|     if (bandwidth == 160) |     if (bandwidth == 160) | ||||||
|         return +freq + 70; |         return +freq + 70; | ||||||
|     } |     if (bandwidth == 320) | ||||||
|  |         if (freq == 6115) | ||||||
|  |             return +freq - 10; | ||||||
|  |         else | ||||||
|  |             return +freq + 150; | ||||||
|  |  | ||||||
|     return +freq; |     return +freq; | ||||||
| } | } | ||||||
|  |  | ||||||
| function channel_offset_calc(band, bandwidth) { | function interface_status_check(iface) { | ||||||
|     let offset=null; |     ulog_info(`[%s] Checking interface status ... \n`, iface); | ||||||
|  |  | ||||||
|     if (band == '5g') { |  | ||||||
|         if (bandwidth == 40) |  | ||||||
|             offset = 1; |  | ||||||
|         if (bandwidth == 80) |  | ||||||
|             offset = 1; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return offset; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function interface_status_check(iface_num) { |  | ||||||
|     ulog_info(`[wlan%d] Checking interface status ... \n`, iface_num); |  | ||||||
|     let radio_status = 'DISABLED'; |     let radio_status = 'DISABLED'; | ||||||
|     let radio_down_f = 0; |     let radio_down_f = 1; | ||||||
|  |  | ||||||
|     let curr_stat = global.ubus.conn.call(`hostapd.wlan${iface_num}`, 'get_status'); |     let curr_stat = global.ubus.conn.call(`hostapd.${iface}`, 'get_status'); | ||||||
|     if (curr_stat) { |     if (curr_stat) { | ||||||
|         radio_status = curr_stat.status; |         radio_status = curr_stat.status; | ||||||
|     } else { |         radio_down_f = 0; | ||||||
|         radio_status = "DISABLED"; |  | ||||||
|         radio_down_f = 1; |  | ||||||
|     } |     } | ||||||
|     ulog_info(`[wlan%d] status: %s \n`, iface_num, radio_status); |     ulog_info(`[%s] status: %s \n`, iface, radio_status); | ||||||
|  |  | ||||||
|     return radio_down_f; |     return radio_down_f; | ||||||
| } | } | ||||||
|  |  | ||||||
| function check_current_channel(iface_num) { | function check_current_channel(iface) { | ||||||
|     // get wireless interface's live status & channel using "ubus call hostapd.wlan<iface_num> get_status" |     // get wireless interface's live status & channel using "ubus call hostapd.<iface> get_status" | ||||||
|     let curr_stat = global.ubus.conn.call(`hostapd.wlan${iface_num}`, 'get_status'); |     let curr_stat = global.ubus.conn.call(`hostapd.${iface}`, 'get_status'); | ||||||
|     let current_channel = curr_stat.channel; |     let current_channel = curr_stat.channel; | ||||||
|     if (curr_stat && current_channel) { |     if (curr_stat && current_channel) { | ||||||
|         ulog_info(`[wlan%d] Current channel (from hostapd) = %d \n`, iface_num, current_channel); |         ulog_info(`[%s] Current channel (from hostapd) = %d \n`, iface, current_channel); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return current_channel; |     return current_channel; | ||||||
| } | } | ||||||
|  |  | ||||||
| function rrmd_switch_channel(msg) { | function hostapd_switch_channel(msg) { | ||||||
|     ulog_info(`[wlan%d] Start switch channel to %d (%s)\n`, msg.phy, msg.channel, msg.bssid); |     ulog_info(`[%s] Start switch channel to %d \n`, msg.iface, msg.channel); | ||||||
|  |  | ||||||
|     let chan_switch_status = 0; |     let chan_switch_status = 0; | ||||||
|  |     let sec_channel_offset = null; | ||||||
|  |  | ||||||
|     let mode = lc(replace(msg.htmode, /[^a-zA-Z]/g, '')); |     let mode = lc(replace(msg.htmode, /[^a-zA-Z]/g, '')); | ||||||
|     let bandwidth = replace(msg.htmode, /[^0-9]/g, ''); |     let bandwidth = replace(msg.htmode, /[^0-9]/g, ''); | ||||||
|  |  | ||||||
|     let target_freq = channel_to_freq(msg.band, msg.channel); |     let target_freq = channel_to_freq(msg.band, msg.channel); | ||||||
|     let center_freq = center_freq_calc(msg.band, target_freq, bandwidth); |     let center_freq = center_freq_calc(msg.band, target_freq, bandwidth); | ||||||
|     let sec_channel_offset = channel_offset_calc(msg.band, bandwidth); |     if (bandwidth > 20) | ||||||
|  |         sec_channel_offset = 1; | ||||||
|  |  | ||||||
|     // use hostadp_cli command |     // use hostadp_cli command | ||||||
|     if (target_freq != null) { |     if (target_freq != null) { | ||||||
|         ulog_info(`Sending to hostapd (Chan %d):: freq=%d, center_freq=%d, sec_channel_offset=%d, bandwidth=%d, mode=%s \n`, msg.channel, target_freq, center_freq, sec_channel_offset, bandwidth, mode); |         ulog_info(`Sending to hostapd (Chan %d):: freq=%d, center_freq=%d, sec_channel_offset=%d, bandwidth=%d, mode=%s \n`, msg.channel, target_freq, center_freq, sec_channel_offset, bandwidth, mode); | ||||||
|         // system(`/usr/sbin/hostapd_cli -i wlan${msg.phy} chan_switch 5 ${target_freq} center_freq1=${center_freq} sec_channel_offset=${sec_channel_offset} bandwidth=${bandwidth} ${mode}`); |  | ||||||
|  |  | ||||||
|         let command_hostapd = `/usr/sbin/hostapd_cli -i wlan${msg.phy} chan_switch 5 ${target_freq} center_freq1=${center_freq} sec_channel_offset=${sec_channel_offset} bandwidth=${bandwidth} ${mode}`; |         let command_hostapd = `/usr/sbin/hostapd_cli -i ${msg.iface} chan_switch 5 ${target_freq} center_freq1=${center_freq} sec_channel_offset=${sec_channel_offset} bandwidth=${bandwidth} ${mode}`; | ||||||
|         let res = fs.popen(command_hostapd); |         let res = fs.popen(command_hostapd); | ||||||
|         let res_check = trim(res.read('all')); |         let res_check = trim(res.read('all')); | ||||||
|         res.close(); |         res.close(); | ||||||
| @@ -193,10 +197,10 @@ function rrmd_switch_channel(msg) { | |||||||
|         if (res_check == "OK") { |         if (res_check == "OK") { | ||||||
|             ulog_info(`hostapd_cli chan_switch status: OK \n`); |             ulog_info(`hostapd_cli chan_switch status: OK \n`); | ||||||
|             chan_switch_status = 1; |             chan_switch_status = 1; | ||||||
|             update_channel_switch_time(msg.phy); |             update_channel_switch_time(msg.iface); | ||||||
|  |  | ||||||
|             // reset breach count back to 0 as we are calling the channel selection algo |             // reset breach count back to 0 as we are calling the channel selection algo | ||||||
|             update_breach_count(msg.phy, 0); |             update_breach_count(msg.iface, 0); | ||||||
|         } else { |         } else { | ||||||
|             ulog_info(`hostapd_cli chan_switch status: FAIL \n`); |             ulog_info(`hostapd_cli chan_switch status: FAIL \n`); | ||||||
|         } |         } | ||||||
| @@ -208,40 +212,43 @@ function rrmd_switch_channel(msg) { | |||||||
|     return chan_switch_status; |     return chan_switch_status; | ||||||
| } | } | ||||||
|  |  | ||||||
| function switch_status_check(iface_num, radio_5G_index, dfs_enabled_5g_index) { | function switch_status_check(iface, dfs_enabled_5g_index) { | ||||||
|     // need to wait for radio 5GHz interface to be UP, when DFS is enabled |     // need to wait for radio 5GHz interface to be UP, when DFS is enabled | ||||||
|     if (dfs_enabled_5g_index == 1) { |     if (dfs_enabled_5g_index == 1) { | ||||||
|         ulog_info(`[wlan%d] 5G radio might need some time to be UP (DFS enabled) \n`, radio_5G_index); |         ulog_info(`[%s] 5G radio might need some time to be UP (DFS enabled) \n`, iface); | ||||||
|  |  | ||||||
|         let p = 0; |         let p = 0; | ||||||
|         // Max 65 seconds wait for the DFS enabled interface to be UP |         // Max 65 seconds wait for the DFS enabled interface to be UP | ||||||
|         let timer = 70; |         let timer = 70; | ||||||
|  |  | ||||||
|         while (p < timer) { |         while (p < timer) { | ||||||
|             ulog_info(`[wlan%d] Check#%d \n `, iface_num, p); |             ulog_info(`[%s] Check#%d \n `, iface, p); | ||||||
|  |  | ||||||
|             if (interface_status_check(iface_num) == 1) { |             if (interface_status_check(iface) == 1) { | ||||||
|                 ulog_info(`[wlan%d] Interface not UP yet ... wait for 1 second \n`, iface_num); |                 ulog_info(`[%s] Interface not UP yet ... wait for 1 second \n`, iface); | ||||||
|                 sleep(1000); |                 sleep(1000); | ||||||
|                 p++; |                 p++; | ||||||
|  |  | ||||||
|                 if (p >= timer) { |                 if (p >= timer) { | ||||||
|                     ulog_info(`[wlan%d] Interface not UP yet ... cac_time is long \n`, iface_num); |                     ulog_info(`[%s] Interface not UP yet ... cac_time is long \n`, iface); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 ulog_info(`[wlan%d] Interface is UP! \n`, iface_num); |                 ulog_info(`[%s] Interface is UP! \n`, iface); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     let current_chan = check_current_channel(iface_num); |     let current_chan = check_current_channel(iface); | ||||||
|     return current_chan; |     return current_chan; | ||||||
| } | } | ||||||
|  |  | ||||||
| function dfs_chan_check(iface_num, rcs_channel) { | function dfs_chan_check(iface_num, rcs_channel) { | ||||||
|     let phy_id = "phy" + iface_num; |     let phy_id = 'phy' + iface_num; | ||||||
|  |     if (board_name == 'edgecore,eap105') { | ||||||
|  |         phy_id = 'phy00'; | ||||||
|  |     } | ||||||
|     let dfs_enabled_5g = 0; |     let dfs_enabled_5g = 0; | ||||||
|     let dfs_chan_list =  global.phy.phys[phy_id].dfs_channels; |     let dfs_chan_list =  global.phy.phys[phy_id].dfs_channels; | ||||||
|  |  | ||||||
| @@ -257,12 +264,12 @@ function dfs_chan_check(iface_num, rcs_channel) { | |||||||
|     return dfs_enabled_5g; |     return dfs_enabled_5g; | ||||||
| } | } | ||||||
|  |  | ||||||
| function fixed_channel_algo(iface_num, fixed_channel_f, auto_channel_f, fixed_chan_bkp, channel_config) { | function fixed_channel_config(iface, iface_num, fixed_channel_f, auto_channel_f, fixed_chan_bkp, channel_config) { | ||||||
|     // if fixed channel config is stored in the /tmp/fixed_channel_phyX file |     // if fixed channel config is stored in the /tmp/fixed_channel_phyX file | ||||||
|     if (fixed_channel_f == 1) { |     if (fixed_channel_f == 1) { | ||||||
|         if (auto_channel_f == 1) { |         if (auto_channel_f == 1) { | ||||||
|             // if current channel is auto => change to fixed |             // if current channel is auto => change to fixed | ||||||
|             ulog_info(`[wlan%d] Current channel is "auto"; Configured fixed channel was %d, reassigning fixed channel ...\n`, iface_num, fixed_chan_bkp); |             ulog_info(`[%s] Current channel is "auto"; Configured fixed channel was %d, reassigning fixed channel ...\n`, iface, fixed_chan_bkp); | ||||||
|  |  | ||||||
|             // Set channel to the fixed channel |             // Set channel to the fixed channel | ||||||
|             global.uci.set('wireless', 'radio' + iface_num, 'channel', fixed_chan_bkp); |             global.uci.set('wireless', 'radio' + iface_num, 'channel', fixed_chan_bkp); | ||||||
| @@ -270,7 +277,7 @@ function fixed_channel_algo(iface_num, fixed_channel_f, auto_channel_f, fixed_ch | |||||||
|             global.uci.apply; |             global.uci.apply; | ||||||
|         } else if (auto_channel_f == 0) { |         } else if (auto_channel_f == 0) { | ||||||
|             // if current channel is not auto => change to auto |             // if current channel is not auto => change to auto | ||||||
|             ulog_info(`[wlan%d] Current channel is fixed (=%d), changing it to "auto" (=0) to trigger ACS \n`, iface_num, channel_config); |             ulog_info(`[%s] Current channel is fixed (=%d), changing it to "auto" (=0) to trigger ACS \n`, iface, channel_config); | ||||||
|  |  | ||||||
|             // Set channel to "auto" |             // Set channel to "auto" | ||||||
|             global.uci.set('wireless', 'radio' + iface_num, 'channel', '0'); |             global.uci.set('wireless', 'radio' + iface_num, 'channel', '0'); | ||||||
| @@ -280,7 +287,7 @@ function fixed_channel_algo(iface_num, fixed_channel_f, auto_channel_f, fixed_ch | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| function get_chan_util(iface_num, sleep_time) { | function get_chan_util(radio_band, sleep_time) { | ||||||
| 	let pdev_stats = {}; | 	let pdev_stats = {}; | ||||||
| 	let chan_util = 0; | 	let chan_util = 0; | ||||||
|  |  | ||||||
| @@ -293,7 +300,7 @@ function get_chan_util(iface_num, sleep_time) { | |||||||
|  |  | ||||||
|     for (let c = 0; c < 2; c++) { |     for (let c = 0; c < 2; c++) { | ||||||
|         // Check tx and tx stats for wlanX interface |         // Check tx and tx stats for wlanX interface | ||||||
|         _pdev_stats[iface_num] = '/tmp/pdev_stats_phy' + iface_num; |         let pdev_stats_file = '/tmp/pdev_stats_phy' + radio_band; | ||||||
|  |  | ||||||
|         let curr_values = { |         let curr_values = { | ||||||
|             txFrameCount: null, |             txFrameCount: null, | ||||||
| @@ -302,7 +309,7 @@ function get_chan_util(iface_num, sleep_time) { | |||||||
|             cycleCount: null, |             cycleCount: null, | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         pdev_stats = split(stats_info_read(_pdev_stats[iface_num]), "\n"); |         pdev_stats = split(stats_info_read(pdev_stats_file), "\n"); | ||||||
|  |  | ||||||
|         if (pdev_stats != null) { |         if (pdev_stats != null) { | ||||||
|             for (let curr_value in pdev_stats) { |             for (let curr_value in pdev_stats) { | ||||||
| @@ -340,14 +347,8 @@ function get_chan_util(iface_num, sleep_time) { | |||||||
|  |  | ||||||
|             if (ignore != 1) { |             if (ignore != 1) { | ||||||
|                 let cycle_count_delta = curr_values.cycleCount - prev_values.cycleCount; |                 let cycle_count_delta = curr_values.cycleCount - prev_values.cycleCount; | ||||||
|                 /* let tx_count_delta = curr_values.txFrameCount - prev_values.txFrameCount; |  | ||||||
|                 let rx_count_delta = curr_values.rxFrameCount - prev_values.rxFrameCount; */ |  | ||||||
|                 let rx_clear_delta = curr_values.rxClearCount - prev_values.rxClearCount; |                 let rx_clear_delta = curr_values.rxClearCount - prev_values.rxClearCount; | ||||||
|  |  | ||||||
|                 let total_usage = (rx_clear_delta * 100) / cycle_count_delta; |                 let total_usage = (rx_clear_delta * 100) / cycle_count_delta; | ||||||
|                 /* let tx_usage = (tx_count_delta * 100) / cycle_count_delta; |  | ||||||
|                 let rx_usage = (rx_count_delta * 100) / cycle_count_delta; */ |  | ||||||
|  |  | ||||||
|                 chan_util = total_usage; |                 chan_util = total_usage; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -362,10 +363,13 @@ function get_chan_util(iface_num, sleep_time) { | |||||||
|     return chan_util; |     return chan_util; | ||||||
| } | } | ||||||
|  |  | ||||||
| function channel_selection(iface_num, band, htmode, chan_list_valid) { | function random_channel_selection(iface, iface_num, band, htmode, chan_list_valid) { | ||||||
|     let math = require('math'); |     let math = require('math'); | ||||||
|     let phy_id = "phy" + iface_num; |  | ||||||
|     let bw = replace(htmode, /[^0-9]/g, ''); |     let bw = replace(htmode, /[^0-9]/g, ''); | ||||||
|  |     let phy_id = 'phy' + iface_num; | ||||||
|  |     if (board_name == 'edgecore,eap105') { | ||||||
|  |         phy_id = 'phy00'; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // channel list from the driver based on the country code |     // channel list from the driver based on the country code | ||||||
|     let chan_list_cc = global.phy.phys[phy_id].channels; |     let chan_list_cc = global.phy.phys[phy_id].channels; | ||||||
| @@ -377,13 +381,62 @@ function channel_selection(iface_num, band, htmode, chan_list_valid) { | |||||||
|     let chan_list_init = []; |     let chan_list_init = []; | ||||||
|     let chan_list_legal = []; |     let chan_list_legal = []; | ||||||
|  |  | ||||||
|     ulog_info(`[wlan%d] Channel list from the driver = %s \n`, iface_num, chan_list_cc); |     ulog_info(`[%s] Channel list from the driver = %s \n`, iface, chan_list_cc); | ||||||
|     ulog_info(`[wlan%d] Selected channel list from config (default channel list shall be used in case channels haven't been selected) = %s \n`, iface_num, chan_list_valid); |     ulog_info(`[%s] Selected channel list from config (default channel list shall be used in case channels haven't been selected) = %s \n`, iface, chan_list_valid); | ||||||
|  |  | ||||||
|  |     if (band == '2g' && bw >= 40) { | ||||||
|  |         ulog_info(`[%s] It is highly recommended to NOT use %dMHz bandwidth for 2.4G radio \n`, iface, bw); | ||||||
|  |     } else if (band == '5g' && bw > 160) { | ||||||
|  |         ulog_info(`[%s] %dMHz bandwidth not supported for 5G radio. Please use a bandwidth of 160MHz or lower\n`, iface, bw); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // default channel list |     // default channel list | ||||||
|     if (band == '5g') { |     if (band == '6g') { | ||||||
|  |         chan_list_default = { | ||||||
|  |             "320": [ 33, 97, 161 ], | ||||||
|  |             "160": [ 1, 33, 65, 97, 129, 161, 193 ], | ||||||
|  |             "80": [ | ||||||
|  |                 1, 17, | ||||||
|  |                 33, 49, | ||||||
|  |                 65, 81, | ||||||
|  |                 97, 113, | ||||||
|  |                 129, 145, | ||||||
|  |                 161, 177, | ||||||
|  |                 193, 209 | ||||||
|  |             ], | ||||||
|  |             "40": [ | ||||||
|  |                 1, 9, 17, 25, | ||||||
|  |                 33, 41, 49, 57, | ||||||
|  |                 65, 73, 81, 89, | ||||||
|  |                 97, 105, 113, 121, | ||||||
|  |                 129, 137, | ||||||
|  |                 145, 153, | ||||||
|  |                 161, 169, | ||||||
|  |                 177, 185, | ||||||
|  |                 193, 201, | ||||||
|  |                 209, 217, | ||||||
|  |                 225 | ||||||
|  |             ], | ||||||
|  |             "20": [ | ||||||
|  |                 2, 1, 5, 9, 13, | ||||||
|  |                 17, 21, 25, 29, | ||||||
|  |                 33, 37, 41, 45, | ||||||
|  |                 49, 53, 57, 61, | ||||||
|  |                 65, 69, 73, 77, | ||||||
|  |                 81, 85, 89, 93, | ||||||
|  |                 97, 101, 105, 109, | ||||||
|  |                 113, 117, 121, 125, | ||||||
|  |                 129, 133, 137, 141, | ||||||
|  |                 145, 149, 153, 157, | ||||||
|  |                 161, 165, 169, 173, | ||||||
|  |                 177, 181, 185, 189, | ||||||
|  |                 193, 197, 201, 205, | ||||||
|  |                 209, 213, 217, 221, | ||||||
|  |                 225, 229, 233 | ||||||
|  |             ] | ||||||
|  |         }; | ||||||
|  |     } else if (band == '5g') { | ||||||
|         chan_list_default = { |         chan_list_default = { | ||||||
|             "320": [ 0 ], |  | ||||||
|             "160": [ 36, 100 ], |             "160": [ 36, 100 ], | ||||||
|             "80": [ |             "80": [ | ||||||
|                 36, |                 36, | ||||||
| @@ -415,6 +468,7 @@ function channel_selection(iface_num, band, htmode, chan_list_valid) { | |||||||
|         }; |         }; | ||||||
|     } else if (band == '2g') { |     } else if (band == '2g') { | ||||||
|         chan_list_default = { |         chan_list_default = { | ||||||
|  |             "40": [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], | ||||||
|             "20": [ |             "20": [ | ||||||
|                 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 |                 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 | ||||||
|             ] |             ] | ||||||
| @@ -422,15 +476,19 @@ function channel_selection(iface_num, band, htmode, chan_list_valid) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // initial channel list after comparing the default chan list based on current bw, and country code |     // initial channel list after comparing the default chan list based on current bw, and country code | ||||||
|     for (let default_chan in chan_list_default[bw]) { |     for (let cbw, default_chan in chan_list_default) { | ||||||
|  |         if (cbw == bw) { | ||||||
|  |             for (let q = 0; q < length(default_chan); q++) { | ||||||
|                 for (let cc_chan in chan_list_cc) { |                 for (let cc_chan in chan_list_cc) { | ||||||
|             if (default_chan == cc_chan){ |                     if (default_chan[q] == cc_chan) { | ||||||
|                 push(chan_list_init, default_chan); |                         push(chan_list_init, default_chan[q]); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (bw == "80" || bw == "40") { |     if (band == '5g' && (bw == "80" || bw == "40")) { | ||||||
|         // exclude last channels from the channel list when bw is 80MHz or 40MHz to avoid selecting a channel with a secondary channel that cannot be supported |         // exclude last channels from the channel list when bw is 80MHz or 40MHz to avoid selecting a channel with a secondary channel that cannot be supported | ||||||
|         chan_list_legal = slice(chan_list_init, 0, length(chan_list_init)-1) ; |         chan_list_legal = slice(chan_list_init, 0, length(chan_list_init)-1) ; | ||||||
|     } else { |     } else { | ||||||
| @@ -451,32 +509,32 @@ function channel_selection(iface_num, band, htmode, chan_list_valid) { | |||||||
|         chan_list_allowed = chan_list_legal; |         chan_list_allowed = chan_list_legal; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ulog_info(`[wlan%d] Allowed channel list = %s \n`, iface_num, chan_list_allowed); |     ulog_info(`[%s] Allowed channel list = %s \n`, iface, chan_list_allowed); | ||||||
|  |  | ||||||
|     // select random channel from chan_list_allowed |     // select random channel from chan_list_allowed | ||||||
|     let random_channel_idx = sprintf('%d', math.rand() % length(chan_list_allowed)); |     let random_channel_idx = sprintf('%d', math.rand() % length(chan_list_allowed)); | ||||||
|     let random_channel = chan_list_allowed[random_channel_idx]; |     let random_channel = chan_list_allowed[random_channel_idx]; | ||||||
|     ulog_info(`[wlan%d] Selected random channel = %d \n`, iface_num, random_channel); |     ulog_info(`[%s] Selected random channel = %d \n`, iface, random_channel); | ||||||
|  |  | ||||||
|     return random_channel; |     return random_channel; | ||||||
| } | } | ||||||
|  |  | ||||||
| function algo_rcs(iface_num, current_channel, band, htmode, selected_channels) { | function algo_rcs(iface, iface_num, current_channel, band, htmode, selected_channels) { | ||||||
|     let chosen_random_channel = 0; |     let chosen_random_channel = 0; | ||||||
|     let res = 0; |     let res = 0; | ||||||
|  |  | ||||||
|     // channel_selection script will help to select random channel |     // random_channel_selection script will help to select random channel | ||||||
|     chosen_random_channel = channel_selection(iface_num, band, htmode, selected_channels); |     chosen_random_channel = random_channel_selection(iface, iface_num, band, htmode, selected_channels); | ||||||
|     stats_info_write("/tmp/phy" + iface_num + "_rrmchan", chosen_random_channel); |     stats_info_write("/tmp/rrm_random_channel_" + iface, chosen_random_channel); | ||||||
|  |  | ||||||
|     if (chosen_random_channel == current_channel) { |     if (chosen_random_channel == current_channel) { | ||||||
|         ulog_info(`[wlan%d] RCS assigned the same channel = %d; Skip channel switch \n`, iface_num, chosen_random_channel); |         ulog_info(`[%s] RCS assigned the same channel = %d; Skip channel switch \n`, iface, chosen_random_channel); | ||||||
|         res = 0; |         res = 0; | ||||||
|     } else if (chosen_random_channel > 0) { |     } else if (chosen_random_channel > 0) { | ||||||
|         ulog_info(`[wlan%d] RCS done ... random channel found = %d\n`, iface_num, chosen_random_channel); |         ulog_info(`[%s] RCS done ... random channel found = %d\n`, iface, chosen_random_channel); | ||||||
|         res = 1; |         res = 1; | ||||||
|     } else { |     } else { | ||||||
|         ulog_info(`[wlan%d] RCS scan FAIL. Retry Channel optimization at next cycle \n`, iface_num); |         ulog_info(`[%s] RCS scan FAIL. Retry Channel optimization at next cycle \n`, iface); | ||||||
|         res = 0; |         res = 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -509,14 +567,14 @@ function channel_optimize() { | |||||||
|     let check_all_cool_down = 0; |     let check_all_cool_down = 0; | ||||||
|     let cool_down_period = config.interval * 10; |     let cool_down_period = config.interval * 10; | ||||||
|  |  | ||||||
|  |     let radio_iface = {}; | ||||||
|     let htmode = {}; |     let htmode = {}; | ||||||
|     let radio_band = {}; |     let radio_band = {}; | ||||||
|     let acs_exclude_dfs = {}; |     let acs_exclude_dfs = {}; | ||||||
|     let channel_config = {}; |     let channel_config = {}; | ||||||
|     let selected_channels = {}; |     let selected_channels = {}; | ||||||
|     let radio_5G_index = 0; |     let radio_5G_index = null; | ||||||
|     let dfs_enabled_5g = {}; |     let dfs_enabled_5g = {}; | ||||||
|     let bssid_mac = {}; |  | ||||||
|  |  | ||||||
|     // check the channel config used by the customer |     // check the channel config used by the customer | ||||||
|     let fixed_chan_bkp = {}; |     let fixed_chan_bkp = {}; | ||||||
| @@ -542,19 +600,26 @@ function channel_optimize() { | |||||||
|     for (let j = 0; j < num_radios; j++) { |     for (let j = 0; j < num_radios; j++) { | ||||||
|         let radio_id = "radio" + j; |         let radio_id = "radio" + j; | ||||||
|  |  | ||||||
|  |         // get wireless interface uci config from "ubus call network.wireless status" | ||||||
|  |         let wireless_status = global.ubus.conn.call('network.wireless', 'status'); | ||||||
|  |         radio_iface[j] = wireless_status[radio_id].interfaces[0].ifname; | ||||||
|  |         radio_band[j] = wireless_status[radio_id].config.band; | ||||||
|  |  | ||||||
|  |         if (radio_iface[j] == null) { | ||||||
|  |             radio_iface[j] = 'radio ' + radio_band[j]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // check wlan interface status |         // check wlan interface status | ||||||
|         current_rf_down[j] = interface_status_check(j); |         current_rf_down[j] = interface_status_check(radio_iface[j]); | ||||||
|         if (current_rf_down[j] == 0) { |         if (current_rf_down[j] == 0) { | ||||||
|             cool_down_f[j] = cool_down_check(j, cool_down_period); |             cool_down_f[j] = cool_down_check(radio_iface[j], cool_down_period); | ||||||
|  |  | ||||||
|             if (cool_down_f[j] != 1) { |             if (cool_down_f[j] != 1) { | ||||||
|                 // default HT mode = HT20 |                 // default HT mode = HT20 | ||||||
|                 htmode[j] = 'HT20'; |                 htmode[j] = 'HT20'; | ||||||
|  |  | ||||||
|                 // get wireless interface uci config from "ubus call network.wireless status" |                 // get radio's uci config | ||||||
|                 let wireless_status = global.ubus.conn.call('network.wireless', 'status'); |  | ||||||
|                 htmode[j] = wireless_status[radio_id].config.htmode; |                 htmode[j] = wireless_status[radio_id].config.htmode; | ||||||
|                 radio_band[j] = wireless_status[radio_id].config.band; |  | ||||||
|                 acs_exclude_dfs[j] = wireless_status[radio_id].config.acs_exclude_dfs; |                 acs_exclude_dfs[j] = wireless_status[radio_id].config.acs_exclude_dfs; | ||||||
|                 channel_config[j] = wireless_status[radio_id].config.channel; |                 channel_config[j] = wireless_status[radio_id].config.channel; | ||||||
|                 selected_channels[j] = wireless_status[radio_id].config.channels; |                 selected_channels[j] = wireless_status[radio_id].config.channels; | ||||||
| @@ -570,53 +635,53 @@ function channel_optimize() { | |||||||
|  |  | ||||||
|                 if (selected_algo == "RCS") { |                 if (selected_algo == "RCS") { | ||||||
|                     if (channel_config[j] == '0') { |                     if (channel_config[j] == '0') { | ||||||
|                         ulog_info(`[wlan%d] Configured channel is "auto" \n`, j); |                         ulog_info(`[%s] Configured channel is "auto" \n`, radio_iface[j]); | ||||||
|                     } else { |                     } else { | ||||||
|                         ulog_info(`[wlan%d] Configured channel is fixed at %d \n`, j, channel_config[j]); |                         ulog_info(`[%s] Configured channel is fixed at %d \n`, radio_iface[j], channel_config[j]); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     if (selected_channels[j]) { |                     if (selected_channels[j]) { | ||||||
|                         ulog_info(`[wlan%d] Selected channel list (please update the radio config, if not correct) = %s \n`, j, selected_channels[j]); |                         ulog_info(`[%s] Selected channel list (please update the radio config, if not correct) = %s \n`, radio_iface[j], selected_channels[j]); | ||||||
|                         // should I check the validity of the chan list selected by the user?? |                         // should I check the validity of the chan list selected by the user?? | ||||||
|                     } |                     } | ||||||
|                 } else if (selected_algo == "ACS") { |                 } else if (selected_algo == "ACS") { | ||||||
|                     if (channel_config[j] != '0') { |                     if (channel_config[j] != '0') { | ||||||
|                         ulog_info(`[wlan%d] Configured channel is fixed at %d \n`, j, channel_config[j]); |                         ulog_info(`[%s] Configured channel is fixed at %d \n`, radio_iface[j], channel_config[j]); | ||||||
|                         auto_channel_f[j] = 0; |                         auto_channel_f[j] = 0; | ||||||
|  |  | ||||||
|                         stats_info_write("/tmp/fixed_channel_phy" + j, channel_config[j]); |                         stats_info_write("/tmp/fixed_channel_" + radio_iface[j], channel_config[j]); | ||||||
|                         fixed_channel_f[j] = 1; |                         fixed_channel_f[j] = 1; | ||||||
|                     } else { |                     } else { | ||||||
|                         ulog_info(`[wlan%d] Configured channel is "auto" \n`, j); |                         ulog_info(`[%s] Configured channel is "auto" \n`, radio_iface[j]); | ||||||
|                         auto_channel_f[j] = 1; |                         auto_channel_f[j] = 1; | ||||||
|  |  | ||||||
|                         // check if fixed channel exists |                         // check if fixed channel exists | ||||||
|                         fixed_chan_bkp[j] = stats_info_read("/tmp/fixed_channel_phy" + j); |                         fixed_chan_bkp[j] = stats_info_read("/tmp/fixed_channel_" + radio_iface[j]); | ||||||
|                         if (fixed_chan_bkp[j] > 0) { |                         if (fixed_chan_bkp[j] > 0) { | ||||||
|                             ulog_info(`[wlan%d] Configured fixed channel was %d \n`, j, fixed_chan_bkp[j]); |                             ulog_info(`[%s] Configured fixed channel was %d \n`, radio_iface[j], fixed_chan_bkp[j]); | ||||||
|                             fixed_channel_f[j] = 1; |                             fixed_channel_f[j] = 1; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 // check current channel |                 // check current channel | ||||||
|                 current_channel[j] = check_current_channel(j); |                 current_channel[j] = check_current_channel(radio_iface[j]); | ||||||
|  |  | ||||||
|                 // check current breach_count |                 // check current breach_count | ||||||
|                 let current_threshold_breach_count = 0; |                 let current_threshold_breach_count = 0; | ||||||
|                 current_threshold_breach_count = stats_info_read("/tmp/threshold_breach_count_phy" + j); |                 current_threshold_breach_count = stats_info_read("/tmp/threshold_breach_count_" + radio_iface[j]); | ||||||
|                 ulog_info(`[wlan%d] Allowed consecutive Channel Utilization threshold breach count = %d \n`, j, config.consecutive_threshold_breach); |                 ulog_info(`[%s] Allowed consecutive Channel Utilization threshold breach count = %d \n`, radio_iface[j], config.consecutive_threshold_breach); | ||||||
|  |  | ||||||
|                 if (!current_threshold_breach_count || current_threshold_breach_count == null || current_threshold_breach_count == 'NaN') { |                 if (!current_threshold_breach_count || current_threshold_breach_count == null || current_threshold_breach_count == 'NaN') { | ||||||
|                     // /tmp/phyX_breachcount file doesn't exist yet or has invalid value |                     // /tmp/phyX_breachcount file doesn't exist yet or has invalid value | ||||||
|                     current_threshold_breach_count = 0; |                     current_threshold_breach_count = 0; | ||||||
|                 } |                 } | ||||||
|                 ulog_info(`[wlan%d] Previous consecutive Channel Utilization threshold breach count = %d \n`, j, current_threshold_breach_count); |                 ulog_info(`[%s] Previous consecutive Channel Utilization threshold breach count = %d \n`, radio_iface[j], current_threshold_breach_count); | ||||||
|  |  | ||||||
|                 // channel util at this channel (auto/fixed) |                 // channel util at this channel (auto/fixed) | ||||||
|                 chan_util_value[j] = get_chan_util(j, sleep_time); |                 chan_util_value[j] = get_chan_util(radio_band[j], sleep_time); | ||||||
|                 ulog_info(`[wlan%d] Allowed Channel Utilization threshold = %d \n`, j, config.threshold, current_channel[j]); |                 ulog_info(`[%s] Allowed Channel Utilization threshold = %d \n`, radio_iface[j], config.threshold); | ||||||
|                 ulog_info(`[wlan%d] Current Channel Utilization (Channel %d at %d) = %d \n`, j, current_channel[j], time(), chan_util_value[j]); |                 ulog_info(`[%s] Current Channel Utilization (Channel %d at %d) = %d \n`, radio_iface[j], current_channel[j], time(), chan_util_value[j]); | ||||||
|  |  | ||||||
|                 if (chan_util_value[j] >= config.threshold) { |                 if (chan_util_value[j] >= config.threshold) { | ||||||
|                     check_all_chan_util++; |                     check_all_chan_util++; | ||||||
| @@ -624,7 +689,7 @@ function channel_optimize() { | |||||||
|                     // Channel Utilization threshold exceeded, increase breach count |                     // Channel Utilization threshold exceeded, increase breach count | ||||||
|                     current_threshold_breach_count++; |                     current_threshold_breach_count++; | ||||||
|                     threshold_breach_count[j] = current_threshold_breach_count; |                     threshold_breach_count[j] = current_threshold_breach_count; | ||||||
|                     ulog_info(`[wlan%d] New consecutive Channel Utilization threshold breach count = %d \n`, j, threshold_breach_count[j]); |                     ulog_info(`[%s] New consecutive Channel Utilization threshold breach count = %d \n`, radio_iface[j], threshold_breach_count[j]); | ||||||
|  |  | ||||||
|                     if (threshold_breach_count[j] >= config.consecutive_threshold_breach) { |                     if (threshold_breach_count[j] >= config.consecutive_threshold_breach) { | ||||||
|                         // threshold breach flag up! |                         // threshold breach flag up! | ||||||
| @@ -635,93 +700,89 @@ function channel_optimize() { | |||||||
|                     } |                     } | ||||||
|                 } else { |                 } else { | ||||||
|                     // reset the threshold breach count |                     // reset the threshold breach count | ||||||
|                     ulog_info(`[wlan%d] Current Channel Utilization (%d) < Allowed Channel Utilization threshold (%d) \n`, j, chan_util_value[j], config.threshold); |                     ulog_info(`[%s] Current Channel Utilization (%d) < Allowed Channel Utilization threshold (%d) \n`, radio_iface[j], chan_util_value[j], config.threshold); | ||||||
|                     ulog_info(`[wlan%d] Reset consecutive Channel Utilization threshold breach count \n`, j); |                     ulog_info(`[%s] Reset consecutive Channel Utilization threshold breach count \n`, radio_iface[j]); | ||||||
|  |  | ||||||
|                     threshold_breach_count[j] = 0; |                     threshold_breach_count[j] = 0; | ||||||
|                     // threshold breach flag down! |                     // threshold breach flag down! | ||||||
|                     threshold_breach_f[j] = 0; |                     threshold_breach_f[j] = 0; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 update_breach_count(j, threshold_breach_count[j]); |                 update_breach_count(radio_iface[j], threshold_breach_count[j]); | ||||||
|             } else { |             } else { | ||||||
|                 check_all_cool_down++; |                 check_all_cool_down++; | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             ulog_info(`[wlan%d] Interface not UP, will be checked in the next interval \n`, j); |             ulog_info(`[%s] Interface not UP, will be checked in the next interval \n`, radio_iface[j]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     for (let l = 0; l < num_radios; l++) { |     for (let l = 0; l < num_radios; l++) { | ||||||
|         if (current_rf_down[l] == 0) { |         if (current_rf_down[l] == 0) { | ||||||
|             cool_down_f[l] = cool_down_check(l, cool_down_period); |             cool_down_f[l] = cool_down_check(radio_iface[l], cool_down_period); | ||||||
|  |  | ||||||
|             if (cool_down_f[l] != 1) { |             if (cool_down_f[l] != 1) { | ||||||
|                 // start algo only if threshold breach count, and chan util threshold exceeded from configured values |                 // start algo only if threshold breach count, and chan util threshold exceeded from configured values | ||||||
|                 if (threshold_breach_f[l] == 1 && chan_util_value[l] >= config.threshold) { |                 if (threshold_breach_f[l] == 1 && chan_util_value[l] >= config.threshold) { | ||||||
|                     ulog_info(`[wlan%d] Consecutive Channel Utilization threshold breached = %d; %s Algorithm STARTS \n`, l, threshold_breach_count[l], selected_algo); |                     ulog_info(`[%s] Consecutive Channel Utilization threshold breached = %d; %s Algorithm STARTS \n`, radio_iface[l], threshold_breach_count[l], selected_algo); | ||||||
|  |  | ||||||
|                     if (selected_algo == "RCS") { |                     if (selected_algo == "RCS") { | ||||||
|                         // no. of channel utils to be compared |                         // no. of channel utils to be compared | ||||||
|                         let max_chan = 2; |                         let max_chan = 2; | ||||||
|                         let curr_chan_list = {}; |                         let curr_chan_list = {}; | ||||||
|                         let chan_util_list = {}; |                         let chan_util_list = {}; | ||||||
|                         let test_payload = {}; |                         let init_payload = {}; | ||||||
|                         let final_payload = {}; |                         let final_payload = {}; | ||||||
|                         let long_cac_time = 0; |                         let long_cac_time = 0; | ||||||
|  |  | ||||||
|                         bssid_mac[l] = stats_info_read("/sys/class/ieee80211/phy" + l + "/addresses"); |  | ||||||
|  |  | ||||||
|                         sleep_time = 3000; |                         sleep_time = 3000; | ||||||
|  |  | ||||||
|                         ulog_info(`[wlan%d] Total of %d channel utils will be compared \n `, l, max_chan); |                         ulog_info(`[%s] Total of %d channel utils will be compared \n `, radio_iface[l], max_chan); | ||||||
|  |  | ||||||
|                         /* Collect the chan util info of #max_chan channels*/ |                         /* Collect the chan util info of #max_chan channels*/ | ||||||
|                         for (let num_chan = 0; num_chan < max_chan; num_chan++) { |                         for (let num_chan = 0; num_chan < max_chan; num_chan++) { | ||||||
|                             ulog_info(`[wlan%d] Channel utilization check ROUND#%d \n`, l, num_chan); |                             ulog_info(`[%s] Channel utilization check ROUND#%d \n`, radio_iface[l], num_chan); | ||||||
|  |  | ||||||
|                             if (num_chan == 0) { |                             if (num_chan == 0) { | ||||||
|                                 curr_chan_list[num_chan] = current_channel[l]; |                                 curr_chan_list[num_chan] = current_channel[l]; | ||||||
|                                 chan_util_list[num_chan] = chan_util_value[l]; |                                 chan_util_list[num_chan] = chan_util_value[l]; | ||||||
|  |  | ||||||
|                                 ulog_info(`[wlan%d] Current channel %d has Channel utilization = %d \n`, l, curr_chan_list[num_chan], chan_util_list[num_chan]); |                                 ulog_info(`[%s] Current channel %d has Channel utilization = %d \n`, radio_iface[l], curr_chan_list[num_chan], chan_util_list[num_chan]); | ||||||
|                             } else { |                             } else { | ||||||
|                                 // flag to assign max chan util value |                                 // flag to assign max chan util value | ||||||
|                                 let assign_max_chan_util = 0; |                                 let assign_max_chan_util = 0; | ||||||
|  |  | ||||||
|                                 // call RCS for multiple random chan |                                 // call RCS for multiple random chan | ||||||
|                                 let chan_scan = algo_rcs(l, curr_chan_list[num_chan-1], radio_band[l], htmode[l], selected_channels[l]); |                                 let chan_scan = algo_rcs(radio_iface[l], l, curr_chan_list[num_chan-1], radio_band[l], htmode[l], selected_channels[l]); | ||||||
|                                 curr_chan_list[num_chan] = stats_info_read("/tmp/phy" + l + "_rrmchan"); |                                 curr_chan_list[num_chan] = stats_info_read("/tmp/rrm_random_channel_" + radio_iface[l]); | ||||||
|  |  | ||||||
|                                 if (chan_scan == 1) { |                                 if (chan_scan == 1) { | ||||||
|                                     // assign channel from RCS to interface |                                     // assign channel from RCS to interface | ||||||
|                                     test_payload = { |                                     init_payload = { | ||||||
|                                         action: 'chan_switch', |  | ||||||
|                                         bssid: bssid_mac[l], |  | ||||||
|                                         channel: curr_chan_list[num_chan], |                                         channel: curr_chan_list[num_chan], | ||||||
|                                         phy: l, |                                         iface: radio_iface[l], | ||||||
|                                         band: radio_band[l], |                                         band: radio_band[l], | ||||||
|                                         htmode: htmode[l], |                                         htmode: htmode[l], | ||||||
|                                     }; |                                     }; | ||||||
|  |  | ||||||
|                                     if (l == radio_5G_index) { |                                     if (l == radio_5G_index) { | ||||||
|                                         dfs_enabled_5g[radio_5G_index] = dfs_chan_check(radio_5G_index, test_payload.channel); |                                         dfs_enabled_5g[l] = dfs_chan_check(radio_5G_index, init_payload.channel); | ||||||
|                                     } |                                     } | ||||||
|  |  | ||||||
|                                     ulog_info(`[wlan%d] Initiated channel switch to random channel %d for comparing Channel utilization \n`, l, test_payload.channel); |                                     ulog_info(`[%s] Initiated channel switch to random channel %d for comparing Channel utilization \n`, radio_iface[l], init_payload.channel); | ||||||
|                                     let test_switch_status = rrmd_switch_channel(test_payload); |                                     let init_chan_switch_status = hostapd_switch_channel(init_payload); | ||||||
|  |  | ||||||
|                                     if (test_switch_status != 0) { |                                     if (init_chan_switch_status != 0) { | ||||||
|                                         let actual_channel = switch_status_check(l, radio_5G_index, dfs_enabled_5g[radio_5G_index]); |                                         let actual_channel = switch_status_check(radio_iface[l], dfs_enabled_5g[l]); | ||||||
|  |  | ||||||
|                                         if (actual_channel == test_payload.channel) { |                                         if (actual_channel == init_payload.channel) { | ||||||
|                                             ulog_info(`[wlan%d] Channel Switch success; Checking Channel utilization ... \n`, l); |                                             ulog_info(`[%s] Channel Switch success; Checking Channel utilization ... \n`, radio_iface[l]); | ||||||
|                                             // get chan util for current assigned random channel |                                             // get chan util for current assigned random channel | ||||||
|                                             chan_util_list[num_chan] = get_chan_util(l, sleep_time); |                                             chan_util_list[num_chan] = get_chan_util(radio_band[l], sleep_time); | ||||||
|                                         } else { |                                         } else { | ||||||
|                                             if (dfs_enabled_5g[radio_5G_index] == 1 && interface_status_check(l) == 1) { |                                             if (dfs_enabled_5g[l] == 1 && interface_status_check(radio_iface[l]) == 1) { | ||||||
|                                                 // dfs channel not up yet |                                                 // dfs channel not up yet | ||||||
|                                                 ulog_info(`[wlan%d] DFS channel %d taking too long to be UP. Interface status/Channel utilization will be checked in the next interval\n`, l, test_payload.channel); |                                                 ulog_info(`[%s] DFS channel %d taking too long to be UP. Interface status/Channel utilization will be checked in the next interval\n`, radio_iface[l], init_payload.channel); | ||||||
|                                                 // jump back to original channel |                                                 // jump back to original channel | ||||||
|                                                 long_cac_time = 1; |                                                 long_cac_time = 1; | ||||||
|                                                 break; |                                                 break; | ||||||
| @@ -737,24 +798,24 @@ function channel_optimize() { | |||||||
|                                 } |                                 } | ||||||
|  |  | ||||||
|                                 if (assign_max_chan_util == 1) { |                                 if (assign_max_chan_util == 1) { | ||||||
|                                     ulog_info(`[wlan%d] Channel switch fail; assign Channel utilization = 100 \n`, l); |                                     ulog_info(`[%s] Channel switch fail; assign Channel utilization = 100 \n`, radio_iface[l]); | ||||||
|                                     // assign highest util value for invalid channel |                                     // assign highest util value for invalid channel | ||||||
|                                     chan_util_list[num_chan] = 100; |                                     chan_util_list[num_chan] = 100; | ||||||
|                                 } |                                 } | ||||||
|  |  | ||||||
|                                 ulog_info(`[wlan%d] Channel utilization of random channel#%d (%s) = %d \n`, l, num_chan, curr_chan_list[num_chan], chan_util_list[num_chan] ); |                                 ulog_info(`[%s] Channel utilization of random channel#%d (%s) = %d \n`, radio_iface[l], num_chan, curr_chan_list[num_chan], chan_util_list[num_chan] ); | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         /* Switch to the channel with the lowest chan util; if long_cac_time flag is up then switch back to the previous channel */ |                         /* Switch to the channel with the lowest chan util; if long_cac_time flag is up then switch back to the previous channel */ | ||||||
|                         if (long_cac_time != 1) { |                         if (long_cac_time != 1) { | ||||||
|                             ulog_info(`[wlan%d] Channel utilization of all %d channels checked \n`, l, max_chan); |                             ulog_info(`[%s] Channel utilization of all %d channels checked \n`, radio_iface[l], max_chan); | ||||||
|  |  | ||||||
|                             // find the minimum chan util and select that as the next channel |                             // find the minimum chan util and select that as the next channel | ||||||
|                             let min_util = chan_util_list[0]; |                             let min_util = chan_util_list[0]; | ||||||
|                             let index_min_util = 0; |                             let index_min_util = 0; | ||||||
|                             for (let x = 0; x < max_chan; x++) { |                             for (let x = 0; x < max_chan; x++) { | ||||||
|                                 ulog_info(`[wlan%d] Channel#%d = %s; Channel utilization#%d = %d \n`, l, x, curr_chan_list[x], x, chan_util_list[x]); |                                 ulog_info(`[%s] Channel#%d = %s; Channel utilization#%d = %d \n`, radio_iface[l], x, curr_chan_list[x], x, chan_util_list[x]); | ||||||
|  |  | ||||||
|                                 if (chan_util_list[x] < min_util) { |                                 if (chan_util_list[x] < min_util) { | ||||||
|                                     min_util = chan_util_list[x]; |                                     min_util = chan_util_list[x]; | ||||||
| @@ -762,53 +823,51 @@ function channel_optimize() { | |||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             ulog_info(`[wlan%d] Channel %d has the least Channel utilization of %d; switching to this channel \n`, l, curr_chan_list[index_min_util], min_util ); |                             ulog_info(`[%s] Channel %d has the least Channel utilization of %d; switching to this channel \n`, radio_iface[l], curr_chan_list[index_min_util], min_util ); | ||||||
|  |  | ||||||
|                             let _current_channel = check_current_channel(l); |                             let _current_channel = check_current_channel(radio_iface[l]); | ||||||
|  |  | ||||||
|                             if (_current_channel != curr_chan_list[index_min_util]) { |                             if (_current_channel != curr_chan_list[index_min_util]) { | ||||||
|                                 // switch channel to min_util |                                 // switch channel to min_util | ||||||
|                                 final_payload = { |                                 final_payload = { | ||||||
|                                     action: 'chan_switch', |  | ||||||
|                                     bssid: bssid_mac[l], |  | ||||||
|                                     channel: curr_chan_list[index_min_util], |                                     channel: curr_chan_list[index_min_util], | ||||||
|                                     phy: l, |                                     iface: radio_iface[l], | ||||||
|                                     band: radio_band[l], |                                     band: radio_band[l], | ||||||
|                                     htmode: htmode[l], |                                     htmode: htmode[l], | ||||||
|                                 }; |                                 }; | ||||||
|  |  | ||||||
|                                 if (l == radio_5G_index) { |                                 if (l == radio_5G_index) { | ||||||
|                                     dfs_enabled_5g[radio_5G_index] = dfs_chan_check(radio_5G_index, final_payload.channel); |                                     dfs_enabled_5g[l] = dfs_chan_check(radio_5G_index, final_payload.channel); | ||||||
|                                 } |                                 } | ||||||
|  |  | ||||||
|                                 if (final_payload.channel != curr_chan_list[max_chan-1] || min_util != chan_util_list[max_chan-1]) { |                                 if (final_payload.channel != curr_chan_list[max_chan-1] || min_util != chan_util_list[max_chan-1]) { | ||||||
|                                     ulog_info(`[wlan%d] Initiated final channel switch to Channel %d \n`, l, final_payload.channel); |                                     ulog_info(`[%s] Initiated final channel switch to Channel %d \n`, radio_iface[l], final_payload.channel); | ||||||
|                                     let final_switch_status = rrmd_switch_channel(final_payload); |                                     let final_switch_status = hostapd_switch_channel(final_payload); | ||||||
|  |  | ||||||
|                                     if (final_switch_status != 0) { |                                     if (final_switch_status != 0) { | ||||||
|                                         let final_channel = switch_status_check(l, radio_5G_index, dfs_enabled_5g[radio_5G_index]); |                                         let final_channel = switch_status_check(radio_iface[l], dfs_enabled_5g[l]); | ||||||
|  |  | ||||||
|                                         if (final_channel == final_payload.channel) { |                                         if (final_channel == final_payload.channel) { | ||||||
|                                             ulog_info(`[wlan%d] Final channel switch success \n`, l); |                                             ulog_info(`[%s] Final channel switch success \n`, radio_iface[l]); | ||||||
|                                         } else { |                                         } else { | ||||||
|                                             ulog_info(`[wlan%d] RCS algo fail (final channel switch failure), wait until next interval to retry\n`, l); |                                             ulog_info(`[%s] RCS algo fail (final channel switch failure), wait until next interval to retry\n`, radio_iface[l]); | ||||||
|                                         } |                                         } | ||||||
|                                     } else { |                                     } else { | ||||||
|                                         ulog_info(`[wlan%d] RCS algo fail (final channel switch failure at hostapd_cli), wait until next interval to retry\n`, l); |                                         ulog_info(`[%s] RCS algo fail (final channel switch failure at hostapd_cli), wait until next interval to retry\n`, radio_iface[l]); | ||||||
|                                     } |                                     } | ||||||
|                                 } else { |                                 } else { | ||||||
|                                     ulog_info(`[wlan%d] Channel switch not necessary, current channel %d has the least channel utilization value \n`, l, final_payload.channel); |                                     ulog_info(`[%s] Channel switch not necessary, current channel %d has the least channel utilization value \n`, radio_iface[l], final_payload.channel); | ||||||
|                                     // reset breach count |                                     // reset breach count | ||||||
|                                     update_breach_count(l, 0); |                                     update_breach_count(radio_iface[l], 0); | ||||||
|                                 } |                                 } | ||||||
|                             } else { |                             } else { | ||||||
|                                 ulog_info(`[wlan%d] Channel switch not necessary, current channel %d is already assigned to the interface \n`, l, _current_channel); |                                 ulog_info(`[%s] Channel switch not necessary, current channel %d is already assigned to the interface \n`, radio_iface[l], _current_channel); | ||||||
|                                 // reset breach count |                                 // reset breach count | ||||||
|                                 update_breach_count(l, 0); |                                 update_breach_count(radio_iface[l], 0); | ||||||
|                             } |                             } | ||||||
|                         } else { |                         } else { | ||||||
|                             // revert back to the original channel |                             // revert back to the original channel | ||||||
|                             ulog_info(`[wlan%d] Channel %d has a cac_time longer than 60 seconds, RRM failed for this interval (you might want to avoid selecting this channel) \n`, l, test_payload.channel); |                             ulog_info(`[%s] Channel %d has a cac_time longer than 60 seconds, RRM failed for this interval (you might want to avoid selecting this channel) \n`, radio_iface[l], init_payload.channel); | ||||||
|                         } |                         } | ||||||
|                     } else if (selected_algo == "ACS") { |                     } else if (selected_algo == "ACS") { | ||||||
|                         let random_wait_time = random_time_calc(); |                         let random_wait_time = random_time_calc(); | ||||||
| @@ -831,7 +890,7 @@ function channel_optimize() { | |||||||
|                             // Channel util high for all interfaces && cool down period over && threshold breach count exceeded for all interfaces: restart all interfaces |                             // Channel util high for all interfaces && cool down period over && threshold breach count exceeded for all interfaces: restart all interfaces | ||||||
|  |  | ||||||
|                             for (let m = 0; m < num_radios; m++) { |                             for (let m = 0; m < num_radios; m++) { | ||||||
|                                 fixed_channel_algo(m, fixed_channel_f[m], auto_channel_f[m], fixed_chan_bkp[m], channel_config[m]); |                                 fixed_channel_config(radio_iface[m], m, fixed_channel_f[m], auto_channel_f[m], fixed_chan_bkp[m], channel_config[m]); | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             ulog_info(`[all wlan interfaces] Initiating channel switch in %d seconds ... \n`, random_wait_time); |                             ulog_info(`[all wlan interfaces] Initiating channel switch in %d seconds ... \n`, random_wait_time); | ||||||
| @@ -842,12 +901,12 @@ function channel_optimize() { | |||||||
|                             radio_5g_restarted = 1; |                             radio_5g_restarted = 1; | ||||||
|  |  | ||||||
|                             for (let x = 0; x < num_radios; x++) { |                             for (let x = 0; x < num_radios; x++) { | ||||||
|                                 ulog_info(`[wlan%d] Channel will be switched \n`, x); |                                 ulog_info(`[%s] Channel will be switched \n`, radio_iface[x]); | ||||||
|                                 // timestamp for all interfaces must be saved |                                 // timestamp for all interfaces must be saved | ||||||
|                                 update_channel_switch_time(x); |                                 update_channel_switch_time(radio_iface[x]); | ||||||
|  |  | ||||||
|                                 // reset breach count back to 0 as we are calling the channel selection algo |                                 // reset breach count back to 0 as we are calling the channel selection algo | ||||||
|                                 update_breach_count(x, 0); |                                 update_breach_count(radio_iface[x], 0); | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             // restart all wlan interfaces |                             // restart all wlan interfaces | ||||||
| @@ -856,18 +915,18 @@ function channel_optimize() { | |||||||
|                         } else if (check_all_chan_util >= 1 && check_all_cool_down < num_radios && check_all_threshold_breach >= 1) { |                         } else if (check_all_chan_util >= 1 && check_all_cool_down < num_radios && check_all_threshold_breach >= 1) { | ||||||
|                             // Channel util high for one or more interfaces && cool down period over for one or more interfaces && threshold breach count exceeded for one or more interface: restart that interface |                             // Channel util high for one or more interfaces && cool down period over for one or more interfaces && threshold breach count exceeded for one or more interface: restart that interface | ||||||
|                             for (let high_util_iface in check_threshold_breach_idx) { |                             for (let high_util_iface in check_threshold_breach_idx) { | ||||||
|                                 fixed_channel_algo(high_util_iface, fixed_channel_f[high_util_iface], auto_channel_f[high_util_iface], fixed_chan_bkp[high_util_iface], channel_config[high_util_iface]); |                                 fixed_channel_config(radio_iface[high_util_iface], high_util_iface, fixed_channel_f[high_util_iface], auto_channel_f[high_util_iface], fixed_chan_bkp[high_util_iface], channel_config[high_util_iface]); | ||||||
|  |  | ||||||
|                                 ulog_info(`[wlan%d] Initiating channel switch in %d seconds ... \n`, high_util_iface, random_wait_time); |                                 ulog_info(`[%s] Initiating channel switch in %d seconds ... \n`, radio_iface[high_util_iface], random_wait_time); | ||||||
|                                 sleep(random_wait_time*1000); |                                 sleep(random_wait_time*1000); | ||||||
|                                 ulog_info(`[wlan%d] %s Algorithm will start; Turning DOWN/UP \n`, high_util_iface, selected_algo); |                                 ulog_info(`[%s] %s Algorithm will start; Turning DOWN/UP \n`, radio_iface[high_util_iface], selected_algo); | ||||||
|  |  | ||||||
|                                 ulog_info(`[wlan%d] Channel will be switched \n`, high_util_iface); |                                 ulog_info(`[%s] Channel will be switched \n`, radio_iface[high_util_iface]); | ||||||
|                                 // timestamp for wlanX interfaces must be saved |                                 // timestamp for wlanX interfaces must be saved | ||||||
|                                 update_channel_switch_time(high_util_iface); |                                 update_channel_switch_time(radio_iface[high_util_iface]); | ||||||
|  |  | ||||||
|                                 // reset breach count back to 0 as we are calling the channel selection algo |                                 // reset breach count back to 0 as we are calling the channel selection algo | ||||||
|                                 update_breach_count(high_util_iface, 0); |                                 update_breach_count(radio_iface[high_util_iface], 0); | ||||||
|  |  | ||||||
|                                 if (high_util_iface == radio_5G_index) { |                                 if (high_util_iface == radio_5G_index) { | ||||||
|                                     radio_5g_restarted = 1; |                                     radio_5g_restarted = 1; | ||||||
| @@ -882,20 +941,20 @@ function channel_optimize() { | |||||||
|  |  | ||||||
|                         // need to wait for radio 5GHz interface, when it is DFS enabled && restarted |                         // need to wait for radio 5GHz interface, when it is DFS enabled && restarted | ||||||
|                         if (radio_5g_restarted == 1 && dfs_enabled_5g[radio_5G_index] == 1) { |                         if (radio_5g_restarted == 1 && dfs_enabled_5g[radio_5G_index] == 1) { | ||||||
|                             ulog_info(`[wlan%d] 5G radio might need some time to be UP (DFS enabled) ... wait for 30 seconds \n`, radio_5G_index); |                             ulog_info(`[%s] 5G radio might need some time to be UP (DFS enabled) ... wait for 30 seconds \n`, radio_iface[radio_5G_index]); | ||||||
|                             // 30 sec delay for DFS scan to come finish |                             // 30 sec delay for DFS scan to come finish | ||||||
|                             sleep(30000); |                             sleep(30000); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } else { |                 } else { | ||||||
|                     if (threshold_breach_f[l] != 1) { |                     if (threshold_breach_f[l] != 1) { | ||||||
|                         ulog_info(`[wlan%d] Threshold breach count (=%d) < Allowed consecutive Channel Utilization threshold breach count (=%d), will be checked again in the next interval \n`, l, threshold_breach_count[l], config.consecutive_threshold_breach); |                         ulog_info(`[%s] Threshold breach count (=%d) < Allowed consecutive Channel Utilization threshold breach count (=%d), will be checked again in the next interval \n`, radio_iface[l], threshold_breach_count[l], config.consecutive_threshold_breach); | ||||||
|                     } else { |                     } else { | ||||||
|                         ulog_info(`[wlan%d] Channel utilization (=%d) within threshold (=%d), will be checked again in the next interval \n`, l, chan_util_value[l], config.threshold); |                         ulog_info(`[%s] Channel utilization (=%d) within threshold (=%d), will be checked again in the next interval \n`, radio_iface[l], chan_util_value[l], config.threshold); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 ulog_info(`[wlan%d] Need to cool down (%d seconds hasn't passed); will be checked again in the next interval \n`, l, cool_down_period/1000); |                 ulog_info(`[%s] Need to cool down (%d seconds hasn't passed); will be checked again in the next interval \n`, radio_iface[l], cool_down_period/1000); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user