developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 1 | From 7b736ee3ec6acebeb4fccef1a59afe6d87912935 Mon Sep 17 00:00:00 2001 |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 2 | From: "Allen.Ye" <allen.ye@mediatek.com> |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 3 | Date: Mon, 5 Sep 2022 09:55:10 +0800 |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 4 | Subject: [PATCH] HAL: add get and set dfs enable and refactor dfs support |
| 5 | |
| 6 | --- |
| 7 | source/wifi/wifi_hal.c | 50 +++++++++++++++++++++++++++++++++++++++--- |
| 8 | 1 file changed, 47 insertions(+), 3 deletions(-) |
| 9 | |
| 10 | diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 11 | index 9b7ac7e..05029a3 100644 |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 12 | --- a/source/wifi/wifi_hal.c |
| 13 | +++ b/source/wifi/wifi_hal.c |
| 14 | @@ -76,6 +76,7 @@ Licensed under the ISC license |
| 15 | #define ESSID_FILE "/tmp/essid" |
| 16 | #define GUARD_INTERVAL_FILE "/tmp/guard-interval" |
| 17 | #define CHANNEL_STATS_FILE "/tmp/channel_stats" |
| 18 | +#define DFS_ENABLE_FILE "/tmp/dfs_enable.txt" |
| 19 | |
| 20 | #ifdef MTK_IMPL |
| 21 | #define DRIVER_2GHZ "mt7915e" |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 22 | @@ -2264,7 +2265,7 @@ INT wifi_getRadioDfsSupport(INT radioIndex, BOOL *output_bool) //Tr181 |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 23 | { |
| 24 | if (NULL == output_bool) |
| 25 | return RETURN_ERR; |
| 26 | - *output_bool=FALSE; |
| 27 | + *output_bool=TRUE; |
| 28 | return RETURN_OK; |
| 29 | } |
| 30 | |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 31 | @@ -2306,17 +2307,60 @@ INT wifi_setRadioDCSScanTime(INT radioIndex, INT interval_seconds, INT dwell_mil |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 32 | //Get the Dfs enable status |
| 33 | INT wifi_getRadioDfsEnable(INT radioIndex, BOOL *output_bool) //Tr181 |
| 34 | { |
| 35 | + char buf[16] = {0}; |
| 36 | + FILE *f = NULL; |
| 37 | + wifi_band band; |
| 38 | + |
| 39 | + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 40 | + |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 41 | + *output_bool = TRUE; // default |
| 42 | if (NULL == output_bool) |
| 43 | return RETURN_ERR; |
| 44 | - *output_bool = FALSE; |
| 45 | |
| 46 | + band = wifi_index_to_band(radioIndex); |
| 47 | + if (band != band_5) |
| 48 | + return RETURN_OK; |
| 49 | + |
| 50 | + f = fopen(DFS_ENABLE_FILE, "r"); |
| 51 | + if (f != NULL) { |
| 52 | + fgets(buf, 2, f); |
| 53 | + if (strncmp(buf, "0", 0) == 0) |
| 54 | + *output_bool = FALSE; |
developer | 80101b0 | 2022-09-05 10:02:03 +0800 | [diff] [blame] | 55 | + fclose(f); |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 56 | + } |
developer | 1094dd6 | 2022-08-30 21:01:46 +0800 | [diff] [blame] | 57 | + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| 58 | return RETURN_OK; |
| 59 | } |
| 60 | |
| 61 | //Set the Dfs enable status |
| 62 | INT wifi_setRadioDfsEnable(INT radioIndex, BOOL enable) //Tr181 |
| 63 | { |
| 64 | - return RETURN_ERR; |
| 65 | + char buf[128] = {0}; |
| 66 | + char config_file[128] = {0}; |
| 67 | + FILE *f = NULL; |
| 68 | + struct params params={0}; |
| 69 | + wifi_band band; |
| 70 | + |
| 71 | + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
| 72 | + |
| 73 | + band = wifi_index_to_band(radioIndex); |
| 74 | + if (band != band_5) |
| 75 | + return RETURN_OK; |
| 76 | + |
| 77 | + f = fopen(DFS_ENABLE_FILE, "w"); |
| 78 | + if (f == NULL) |
| 79 | + return RETURN_ERR; |
| 80 | + fprintf(f, "%d", enable); |
| 81 | + fclose(f); |
| 82 | + |
| 83 | + params.name = "acs_exclude_dfs"; |
| 84 | + sprintf(buf, "%d", enable?"1":"0"); |
| 85 | + params.value = buf; |
| 86 | + sprintf(config_file, "%s%d.conf", CONFIG_PREFIX, radioIndex); |
| 87 | + wifi_hostapdWrite(config_file, ¶ms, 1); |
| 88 | + wifi_reloadAp(radioIndex); |
| 89 | + |
| 90 | + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| 91 | } |
| 92 | |
| 93 | //Check if the driver support the AutoChannelRefreshPeriod |
| 94 | -- |
| 95 | 2.18.0 |
| 96 | |