-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hostap: fix VHT channel center segment0 #82113
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2082,6 +2082,78 @@ | |
return ret; | ||
} | ||
|
||
static int hapd_config_chan_center_seg0(struct wifi_connect_req_params *params) | ||
{ | ||
int ret = 0; | ||
uint8_t center_freq_seg0_idx = 0; | ||
uint8_t oper_chwidth = CHANWIDTH_USE_HT; | ||
uint8_t *center_freq = NULL; | ||
uint8_t center_freq_40MHz[] = {38, 46, 54, 62, 102, 110, 118, 126, 134, 142, 151, 159}; | ||
uint8_t center_freq_80MHz[] = {42, 58, 106, 122, 138, 155}; | ||
uint8_t index, index_max, chan_idx, ch_offset = 0; | ||
|
||
/* Unless ACS is being used, both "channel" and "vht_oper_centr_freq_seg0_idx" | ||
* parameters must be set. */ | ||
switch (params->bandwidth) { | ||
case WIFI_FREQ_BANDWIDTH_20MHZ: | ||
oper_chwidth = CHANWIDTH_USE_HT; | ||
center_freq_seg0_idx = params->channel; | ||
break; | ||
case WIFI_FREQ_BANDWIDTH_40MHZ: | ||
if (!hostapd_cli_cmd_v("set ht_capab [HT40+][SHORT-GI-40]")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SHORT-GI should be set as per the underlying driver/chipset capablities There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the choice of HT40+/- should still be user configurable, no? 36-40MHz-HT40+ === 40-40MHz-HT40- == 38. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When starting soft AP, it cannot get the driver/chipset capabilities. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that should do. |
||
goto out; | ||
} | ||
oper_chwidth = CHANWIDTH_USE_HT; | ||
center_freq = center_freq_40MHz; | ||
index_max = ARRAY_SIZE(center_freq_40MHz); | ||
ch_offset = 2; | ||
break; | ||
case WIFI_FREQ_BANDWIDTH_80MHZ: | ||
if (!hostapd_cli_cmd_v("set ht_capab [HT40+][SHORT-GI-40]")) { | ||
goto out; | ||
} | ||
oper_chwidth = CHANWIDTH_80MHZ; | ||
center_freq = center_freq_80MHz; | ||
index_max = ARRAY_SIZE(center_freq_80MHz); | ||
ch_offset = 6; | ||
break; | ||
default: | ||
return -EINVAL; | ||
} | ||
|
||
if (params->bandwidth != WIFI_FREQ_BANDWIDTH_20MHZ) | ||
{ | ||
chan_idx = params->channel; | ||
for (index = 0; index < index_max; index++) | ||
{ | ||
if ((chan_idx >= (center_freq[index] - ch_offset)) && (chan_idx <= (center_freq[index] + ch_offset))) | ||
Check warning on line 2129 in modules/hostap/src/supp_api.c GitHub Actions / Run compliance checks on patch series (PR)LONG_LINE
Check failure on line 2129 in modules/hostap/src/supp_api.c GitHub Actions / Run compliance checks on patch series (PR)OPEN_BRACE
|
||
{ | ||
center_freq_seg0_idx = center_freq[index]; | ||
break; | ||
} | ||
} | ||
} | ||
Comment on lines
+2124
to
+2135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we just do below?
We don't even need the static array of frequencies? Of course There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will check it. |
||
|
||
if (!hostapd_cli_cmd_v("set vht_oper_chwidth %d", oper_chwidth)) { | ||
goto out; | ||
} | ||
if (!hostapd_cli_cmd_v("set vht_oper_centr_freq_seg0_idx %d", center_freq_seg0_idx)) { | ||
goto out; | ||
} | ||
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_11AX | ||
if (!hostapd_cli_cmd_v("set he_oper_chwidth %d", oper_chwidth)) { | ||
goto out; | ||
} | ||
if (!hostapd_cli_cmd_v("set he_oper_centr_freq_seg0_idx %d", center_freq_seg0_idx)) { | ||
goto out; | ||
} | ||
#endif | ||
|
||
return ret; | ||
out: | ||
return -EINVAL; | ||
} | ||
|
||
int hapd_config_network(struct hostapd_iface *iface, | ||
struct wifi_connect_req_params *params) | ||
{ | ||
|
@@ -2118,6 +2190,11 @@ | |
goto out; | ||
} | ||
|
||
ret = hapd_config_chan_center_seg0(params); | ||
if (ret) { | ||
goto out; | ||
} | ||
|
||
if (params->security != WIFI_SECURITY_TYPE_NONE) { | ||
if (params->security == WIFI_SECURITY_TYPE_WPA_PSK) { | ||
if (!hostapd_cli_cmd_v("set wpa 1")) { | ||
|
@@ -2470,6 +2547,21 @@ | |
} | ||
#endif | ||
|
||
static int set_ap_bandwidth(const struct device *dev, enum wifi_frequency_bandwidths bandwidth) | ||
{ | ||
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev); | ||
struct wifi_ap_config_params params = { 0 }; | ||
|
||
if (!wifi_mgmt_api || !wifi_mgmt_api->ap_bandwidth) { | ||
wpa_printf(MSG_ERROR, "ap_bandwidth not supported"); | ||
return -ENOTSUP; | ||
} | ||
|
||
params.bandwidth = bandwidth; | ||
params.oper = WIFI_MGMT_SET; | ||
return wifi_mgmt_api->ap_bandwidth(dev, ¶ms); | ||
} | ||
|
||
int supplicant_ap_enable(const struct device *dev, | ||
struct wifi_connect_req_params *params) | ||
{ | ||
|
@@ -2489,6 +2581,12 @@ | |
return -1; | ||
} | ||
|
||
ret = set_ap_bandwidth(dev, params->bandwidth); | ||
if (ret) { | ||
wpa_printf(MSG_ERROR, "Failed to set ap bandwidth"); | ||
return -EINVAL; | ||
} | ||
|
||
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER); | ||
|
||
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this commit should be the first one as VHT seg0 frequency relies on the this param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure