blob: d16d2f9fed170a4c5dc9e03b6b7de46d3544650c [file] [log] [blame]
developer80101b02022-09-05 10:02:03 +08001From 7b736ee3ec6acebeb4fccef1a59afe6d87912935 Mon Sep 17 00:00:00 2001
developer1094dd62022-08-30 21:01:46 +08002From: "Allen.Ye" <allen.ye@mediatek.com>
developer80101b02022-09-05 10:02:03 +08003Date: Mon, 5 Sep 2022 09:55:10 +0800
developer1094dd62022-08-30 21:01:46 +08004Subject: [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
10diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
developer80101b02022-09-05 10:02:03 +080011index 9b7ac7e..05029a3 100644
developer1094dd62022-08-30 21:01:46 +080012--- 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"
developer80101b02022-09-05 10:02:03 +080022@@ -2264,7 +2265,7 @@ INT wifi_getRadioDfsSupport(INT radioIndex, BOOL *output_bool) //Tr181
developer1094dd62022-08-30 21:01:46 +080023 {
24 if (NULL == output_bool)
25 return RETURN_ERR;
26- *output_bool=FALSE;
27+ *output_bool=TRUE;
28 return RETURN_OK;
29 }
30
developer80101b02022-09-05 10:02:03 +080031@@ -2306,17 +2307,60 @@ INT wifi_setRadioDCSScanTime(INT radioIndex, INT interval_seconds, INT dwell_mil
developer1094dd62022-08-30 21:01:46 +080032 //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__);
developer80101b02022-09-05 10:02:03 +080040+
developer1094dd62022-08-30 21:01:46 +080041+ *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;
developer80101b02022-09-05 10:02:03 +080055+ fclose(f);
developer1094dd62022-08-30 21:01:46 +080056+ }
developer1094dd62022-08-30 21:01:46 +080057+ 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, &params, 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--
952.18.0
96