blob: de76551ca7a6c467fdadc53591fda8f4d23420c1 [file] [log] [blame]
developer90379572024-05-29 17:23:20 +08001From 12d23aa04385369d86468d080b114a82ef8a3b38 Mon Sep 17 00:00:00 2001
2From: Rex Lu <rex.lu@mediatek.com>
3Date: Wed, 29 May 2024 14:08:06 +0800
4Subject: [PATCH] fix 5G and 6G connect fail
5
6---
7 src/wifi_hal_hostapd.c | 20 +++---------------
8 src/wifi_hal_nl80211.c | 39 +++++++++---------------------------
9 src/wifi_hal_nl80211_utils.c | 20 ++++++++++++++++--
10 3 files changed, 30 insertions(+), 49 deletions(-)
11
12diff --git a/src/wifi_hal_hostapd.c b/src/wifi_hal_hostapd.c
13index 7921406..96f1f56 100644
14--- a/src/wifi_hal_hostapd.c
15+++ b/src/wifi_hal_hostapd.c
16@@ -1397,7 +1397,6 @@ int update_hostap_iface(wifi_interface_info_t *interface)
17 */
18 #endif
19
20-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
21 iface->drv_flags = radio->driver_data.capa.flags;
22 //iface->drv_flags |= WPA_DRIVER_FLAGS_INACTIVITY_TIMER;
23 iface->drv_flags |= WPA_DRIVER_FLAGS_EAPOL_TX_STATUS;
24@@ -1435,20 +1434,7 @@ int update_hostap_iface(wifi_interface_info_t *interface)
25 iface->extended_capa = radio->driver_data.extended_capa;
26 iface->extended_capa_mask = radio->driver_data.extended_capa_mask;
27 iface->extended_capa_len = radio->driver_data.extended_capa_len;
28-#else
29- iface->drv_flags = WPA_DRIVER_FLAGS_INACTIVITY_TIMER;
30- iface->drv_flags |= WPA_DRIVER_FLAGS_EAPOL_TX_STATUS;
31- iface->drv_flags |= WPA_DRIVER_FLAGS_AP_MLME;
32- iface->drv_flags |= WPA_DRIVER_FLAGS_AP_CSA;
33- // XXX: Such ability should be retrieved during NL80211_CMD_GET_WIPHY
34- if (g_wifi_hal.platform_flags & PLATFORM_FLAGS_PROBE_RESP_OFFLOAD) {
35- iface->drv_flags |= WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD;
36- }
37
38- if (iface->current_mode->vht_capab & VHT_CAP_SUPP_CHAN_WIDTH_160MHZ) {
39- iface->conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
40- }
41-#endif // CMXB7_PORT && VNTXER5_PORT
42 if(preassoc_supp_rates) {
43 os_free(preassoc_supp_rates);
44 preassoc_supp_rates = NULL;
45@@ -1669,14 +1655,14 @@ int update_hostap_config_params(wifi_radio_info_t *radio)
46 }
47
48 if (param->variant & WIFI_80211_VARIANT_AX) {
49- if (param->band == WIFI_FREQUENCY_5_BAND) {
50+ if (param->band == WIFI_FREQUENCY_5_BAND || param->band == WIFI_FREQUENCY_6_BAND) {
51 iconf->hw_mode = HOSTAPD_MODE_IEEE80211A;
52 iconf->ieee80211ac = 1;
53 } else {
54 iconf->hw_mode = HOSTAPD_MODE_IEEE80211G;
55 }
56 iconf->ieee80211ax = 1;
57- //iconf->ieee80211n = 1;
58+ iconf->ieee80211n = 1;
59 //iconf->require_ht = 1;
60 //iconf->require_vht = 1;
61 }
62@@ -1733,7 +1719,7 @@ int update_hostap_config_params(wifi_radio_info_t *radio)
63 }
64 #endif
65 iconf->vht_oper_chwidth = bandwidth;
66-
67+ iconf->op_class = param->op_class;
68 //validate_config_params
69 if (hostapd_config_check(iconf, 1) < 0) {
70 pthread_mutex_unlock(&g_wifi_hal.hapd_lock);
71diff --git a/src/wifi_hal_nl80211.c b/src/wifi_hal_nl80211.c
72index dd5da8b..4d27e45 100644
73--- a/src/wifi_hal_nl80211.c
74+++ b/src/wifi_hal_nl80211.c
75@@ -57,7 +57,6 @@ struct family_data {
76 int id;
77 };
78
79-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
80 struct phy_info_arg {
81 u16 *num_modes;
82 struct hostapd_hw_modes *modes;
83@@ -65,7 +64,6 @@ struct phy_info_arg {
84 int failed;
85 u8 dfs_domain;
86 };
87-#endif
88
89 void prepare_interface_fdset(wifi_hal_priv_t *priv)
90 {
91@@ -2540,7 +2538,6 @@ skip: found = 0;
92 return mode;
93 }
94
95-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
96 static void phy_info_iftype_copy(struct hostapd_hw_modes *mode,
97 enum ieee80211_op_mode opmode,
98 struct nlattr **tb, struct nlattr **tb_flags)
99@@ -2548,9 +2545,7 @@ static void phy_info_iftype_copy(struct hostapd_hw_modes *mode,
100 enum nl80211_iftype iftype;
101 size_t len;
102 struct he_capabilities *he_capab = &mode->he_capab[opmode];
103-#ifdef CMXB7_PORT
104 struct eht_capabilities *eht_capab = &mode->eht_capab[opmode];
105-#endif // CMXB7_PORT
106
107 switch (opmode) {
108 case IEEE80211_MODE_INFRA:
109@@ -2623,7 +2618,6 @@ static void phy_info_iftype_copy(struct hostapd_hw_modes *mode,
110 len);
111 }
112
113-#ifdef CMXB7_PORT
114 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA]) {
115 u16 capa;
116
117@@ -2676,7 +2670,6 @@ static void phy_info_iftype_copy(struct hostapd_hw_modes *mode,
118 nla_data(tb[NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE]),
119 len);
120 }
121-#endif // CMXB7_PORT
122 }
123
124 static int wiphy_info_iface_comb_process(wifi_radio_info_t *radio,
125@@ -2835,7 +2828,6 @@ static unsigned int get_akm_suites_info(struct nlattr *tb)
126 return key_mgmt;
127 }
128
129-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
130 static void get_iface_akm_suites_info(wifi_radio_info_t *radio,
131 struct nlattr *nl_akms)
132 {
133@@ -2900,7 +2892,6 @@ static void get_iface_akm_suites_info(wifi_radio_info_t *radio,
134 key_mgmt);
135 }
136 }
137-#endif // CMXB7_PORT && VNTXER5_PORT
138
139 static void wiphy_info_feature_flags(wifi_radio_info_t *radio,
140 struct nlattr *tb)
141@@ -3038,12 +3029,12 @@ static void wiphy_info_ext_feature_flags(wifi_radio_info_t *radio,
142 NL80211_EXT_FEATURE_BEACON_RATE_VHT)) {
143 capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_VHT;
144 }
145-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
146+
147 if (ext_feature_isset(ext_features, len,
148 NL80211_EXT_FEATURE_BEACON_RATE_HE)) {
149 capa->flags2 |= WPA_DRIVER_FLAGS2_BEACON_RATE_HE;
150 }
151-#endif // CMXB7_PORT
152+
153 if (ext_feature_isset(ext_features, len,
154 NL80211_EXT_FEATURE_SET_SCAN_DWELL)) {
155 capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_SET_SCAN_DWELL;
156@@ -3106,7 +3097,7 @@ static void wiphy_info_ext_feature_flags(wifi_radio_info_t *radio,
157 capa->flags |= WPA_DRIVER_FLAGS_OCE_STA;
158 }
159 #endif /* CONFIG_MBO */
160-#if defined CMXB7_PORT || defined(VNTXER5_PORT)
161+
162 if (ext_feature_isset(ext_features, len,
163 NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER)) {
164 capa->flags |= WPA_DRIVER_FLAGS_FTM_RESPONDER;
165@@ -3172,7 +3163,7 @@ static void wiphy_info_ext_feature_flags(wifi_radio_info_t *radio,
166 NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION)) {
167 capa->flags2 |= WPA_DRIVER_FLAGS2_OCV;
168 }
169-#endif // CMXB7_PORT
170+
171 /* XXX: is not present in nl80211_copy.h, maybe needs to be fixed
172 if (ext_feature_isset(ext_features, len,
173 NL80211_EXT_FEATURE_RADAR_BACKGROUND)) {
174@@ -3348,7 +3339,6 @@ static int phy_info_iftype(struct hostapd_hw_modes *mode,
175
176 return NL_OK;
177 }
178-#endif
179
180 static int phy_info_band(wifi_radio_info_t *radio, struct nlattr *nl_band)
181 {
182@@ -3460,9 +3450,7 @@ static int regulatory_domain_set_info_handler(struct nl_msg *msg, void *arg)
183 static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
184 {
185 wifi_radio_info_t *radio;
186-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
187 struct wpa_driver_capa *capa;
188-#endif // CMXB7_PORT && VNTXER5_PORT
189 struct nlattr *tb[NL80211_ATTR_MAX + 1];
190 struct genlmsghdr *gnlh;
191 //unsigned int *cmd;
192@@ -3479,14 +3467,12 @@ static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
193
194 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL);
195
196-#if !defined(VNTXER5_PORT)
197 for (j = 0; j < g_wifi_hal.num_radios; j++)
198 {
199 if (strcmp(g_wifi_hal.radio_info[j].name, nla_get_string(tb[NL80211_ATTR_WIPHY_NAME])) == 0) {
200 return NL_SKIP;
201 }
202 }
203-#endif
204
205 phy_index = nla_get_u32(tb[NL80211_ATTR_WIPHY]);
206 rdk_radio_index = get_rdk_radio_index(phy_index);
207@@ -3525,7 +3511,7 @@ static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
208 if (tb[NL80211_ATTR_WIPHY_NAME]) {
209 strcpy(radio->name, nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
210 }
211-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
212+
213 capa = &radio->driver_data.capa;
214
215 if (tb[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]) {
216@@ -3691,7 +3677,7 @@ static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
217 wifi_hal_info_print("%s:%d: nl80211: wiphy supported key_mgmt 0x%x\n", __func__, __LINE__,
218 capa->key_mgmt);
219 }
220-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
221+
222 if (tb[NL80211_ATTR_IFTYPE_AKM_SUITES]) {
223 struct nlattr *nl_if;
224 int rem_if;
225@@ -3699,7 +3685,7 @@ static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
226 nla_for_each_nested(nl_if, tb[NL80211_ATTR_IFTYPE_AKM_SUITES], rem_if)
227 get_iface_akm_suites_info(radio, nl_if);
228 }
229-#endif // CMXB7_PORT && VNTXER5_PORT
230+
231 if (tb[NL80211_ATTR_OFFCHANNEL_TX_OK]) {
232 wifi_hal_info_print("%s:%d: nl80211: Using driver-based off-channel TX\n", __func__, __LINE__);
233 capa->flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_TX;
234@@ -3787,7 +3773,7 @@ static int wiphy_dump_handler(struct nl_msg *msg, void *arg)
235 if (tb[NL80211_ATTR_WIPHY_SELF_MANAGED_REG]) {
236 capa->flags |= WPA_DRIVER_FLAGS_SELF_MANAGED_REGULATORY;
237 }
238-#endif // CMXB7_PORT && VNTXER5_PORT
239+
240 if (tb[NL80211_ATTR_WDEV]) {
241 radio->dev_id = nla_get_u64(tb[NL80211_ATTR_WDEV]);
242 }
243@@ -4024,7 +4010,6 @@ static int interface_info_handler(struct nl_msg *msg, void *arg)
244 return NL_SKIP;
245 }
246
247-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
248 static int phy_info_rates_get_hw_features(struct hostapd_hw_modes *mode, struct nlattr *tb)
249 {
250 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
251@@ -4067,7 +4052,6 @@ static int phy_info_rates_get_hw_features(struct hostapd_hw_modes *mode, struct
252
253 return NL_OK;
254 }
255-#endif
256
257 static int phy_info_handler(struct nl_msg *msg, void *arg)
258 {
259@@ -4470,7 +4454,6 @@ int init_nl80211()
260 for (i = 0; i < g_wifi_hal.num_radios; i++) {
261 radio = &g_wifi_hal.radio_info[i];
262
263-#ifdef CMXB7_PORT
264 if (radio->driver_data.auth_supported) {
265 radio->driver_data.capa.flags |= WPA_DRIVER_FLAGS_SME;
266 }
267@@ -4518,7 +4501,7 @@ int init_nl80211()
268 if (radio->driver_data.update_ft_ies_supported) {
269 radio->driver_data.capa.flags |= WPA_DRIVER_FLAGS_UPDATE_FT_IES;
270 }
271-#endif
272+
273 // initialize the interface map
274 radio->interface_map = hash_map_create();
275
276@@ -8513,7 +8496,6 @@ fail:
277 return ret;
278 }
279
280-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
281 static int cw2ecw(unsigned int cw)
282 {
283 int bit;
284@@ -9366,12 +9348,10 @@ static int nl80211_set_regulatory_flags(struct phy_info_arg *results)
285
286 return nl80211_send_and_recv(msg, nl80211_get_reg, results, NULL, NULL);
287 }
288-#endif
289
290 struct hostapd_hw_modes *
291 wifi_drv_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags, u8 *dfs_domain)
292 {
293-#if defined(CMXB7_PORT) || defined(VNTXER5_PORT)
294 struct nl_msg *msg;
295 struct phy_info_arg result = {
296 .num_modes = num_modes,
297@@ -9426,7 +9406,6 @@ wifi_drv_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags, u8 *dfs_dom
298 nl80211_dump_chan_list(modes, *num_modes);
299 return modes;
300 }
301-#endif
302 return NULL;
303 }
304
305diff --git a/src/wifi_hal_nl80211_utils.c b/src/wifi_hal_nl80211_utils.c
306index da9dc33..b524ecd 100644
307--- a/src/wifi_hal_nl80211_utils.c
308+++ b/src/wifi_hal_nl80211_utils.c
309@@ -1825,11 +1825,27 @@ int get_op_class_from_radio_params(wifi_radio_operationParam_t *param)
310
311 #if HOSTAPD_VERSION >= 210 //2.10
312 if (param->band == WIFI_FREQUENCY_6_BAND) {
313- int freq, global_op_class = -1;
314+ int freq, idx, global_op_class = -1;
315
316 freq = (param->channel == 2) ? 5935 : (5950 + (param->channel * 5));
317 if (is_6ghz_freq(freq)) {
318- global_op_class = 131 + center_idx_to_bw_6ghz(param->channel);
319+ switch (param->channelWidth) {
320+ case WIFI_CHANNELBANDWIDTH_40MHZ:
321+ idx = 1;
322+ break;
323+ case WIFI_CHANNELBANDWIDTH_80MHZ:
324+ idx = 2;
325+ break;
326+ case WIFI_CHANNELBANDWIDTH_160MHZ:
327+ idx = 3;
328+ break;
329+ case WIFI_CHANNELBANDWIDTH_20MHZ:
330+ default:
331+ idx = 0;
332+ break;
333+ }
334+
335+ global_op_class = 131 + idx;
336 }
337 return global_op_class;
338 }
339--
3402.18.0
341