Skip to content

Commit b0331c4

Browse files
ajayparidanordicjm
authored andcommitted
[nrf noup] net: l2: wifi: Configure BSS max idle period
Support to configure BSS max idle period at runtime. To avoid big churn (net_mgmt 64bit), this commit should be reverted on the next upmerge. Signed-off-by: Ajay Parida <[email protected]>
1 parent efdaa0e commit b0331c4

File tree

12 files changed

+176
-2
lines changed

12 files changed

+176
-2
lines changed

drivers/wifi/nrf_wifi/inc/fmac_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct nrf_wifi_vif_ctx_zep {
9191
struct k_work_delayable nrf_wifi_rpu_recovery_bringup_work;
9292
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
9393
int rts_threshold_value;
94+
unsigned short bss_max_idle_period;
9495
};
9596

9697
struct nrf_wifi_vif_ctx_map {

drivers/wifi/nrf_wifi/inc/wifi_mgmt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@ int nrf_wifi_set_rts_threshold(const struct device *dev,
7777

7878
int nrf_wifi_get_rts_threshold(const struct device *dev,
7979
unsigned int *rts_threshold);
80+
81+
int nrf_wifi_set_bss_max_idle_period(const struct device *dev,
82+
unsigned short bss_max_idle_period);
8083
#endif /* __ZEPHYR_WIFI_MGMT_H__ */

drivers/wifi/nrf_wifi/src/fmac_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,9 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
858858
#endif /* CONFIG_NRF70_RADIO_TEST */
859859

860860
k_mutex_init(&rpu_drv_priv_zep.rpu_ctx_zep.rpu_lock);
861+
#ifndef CONFIG_NRF70_RADIO_TEST
862+
vif_ctx_zep->bss_max_idle_period = USHRT_MAX;
863+
#endif /* !CONFIG_NRF70_RADIO_TEST */
861864
return 0;
862865
#ifdef CONFIG_NRF70_RADIO_TEST
863866
fmac_deinit:
@@ -885,6 +888,7 @@ static const struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
885888
.get_power_save_config = nrf_wifi_get_power_save_config,
886889
.set_rts_threshold = nrf_wifi_set_rts_threshold,
887890
.get_rts_threshold = nrf_wifi_get_rts_threshold,
891+
.set_bss_max_idle_period = nrf_wifi_set_bss_max_idle_period,
888892
#endif
889893
#ifdef CONFIG_NRF70_SYSTEM_WITH_RAW_MODES
890894
.mode = nrf_wifi_mode,

drivers/wifi/nrf_wifi/src/wifi_mgmt.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,3 +1077,56 @@ int nrf_wifi_get_rts_threshold(const struct device *dev,
10771077

10781078
return ret;
10791079
}
1080+
1081+
int nrf_wifi_set_bss_max_idle_period(const struct device *dev,
1082+
unsigned short bss_max_idle_period)
1083+
{
1084+
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
1085+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
1086+
int ret = -1;
1087+
1088+
if (!dev) {
1089+
LOG_ERR("%s: dev is NULL", __func__);
1090+
return ret;
1091+
}
1092+
1093+
vif_ctx_zep = dev->data;
1094+
1095+
if (!vif_ctx_zep) {
1096+
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
1097+
return ret;
1098+
}
1099+
1100+
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
1101+
1102+
if (!rpu_ctx_zep) {
1103+
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
1104+
return ret;
1105+
}
1106+
1107+
1108+
if (!rpu_ctx_zep->rpu_ctx) {
1109+
LOG_ERR("%s: RPU context not initialized", __func__);
1110+
return ret;
1111+
}
1112+
1113+
if (((int)bss_max_idle_period < 0) ||
1114+
(bss_max_idle_period > 64000)) {
1115+
/* 0 or value less than 64000 is passed to f/w.
1116+
* All other values considered as invalid.
1117+
*/
1118+
LOG_ERR("%s: Invalid max_idle_period value : %d",
1119+
__func__, (int)bss_max_idle_period);
1120+
return ret;
1121+
}
1122+
1123+
k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
1124+
1125+
vif_ctx_zep->bss_max_idle_period = bss_max_idle_period;
1126+
1127+
ret = 0;
1128+
1129+
k_mutex_unlock(&vif_ctx_zep->vif_lock);
1130+
1131+
return ret;
1132+
}

drivers/wifi/nrf_wifi/src/wpa_supp_if.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,10 @@ int nrf_wifi_wpa_supp_associate(void *if_priv, struct wpa_driver_associate_param
931931
assoc_info.use_mfp = NRF_WIFI_MFP_REQUIRED;
932932
}
933933

934-
if (params->bss_max_idle_period) {
935-
assoc_info.bss_max_idle_time = params->bss_max_idle_period;
934+
if (vif_ctx_zep->bss_max_idle_period == USHRT_MAX) {
935+
assoc_info.bss_max_idle_time = CONFIG_WIFI_MGMT_BSS_MAX_IDLE_TIME;
936+
} else {
937+
assoc_info.bss_max_idle_time = vif_ctx_zep->bss_max_idle_period;
936938
}
937939

938940
assoc_info.conn_type = NRF_WIFI_CONN_TYPE_OPEN;

include/zephyr/net/wifi_mgmt.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ enum net_request_wifi_cmd {
133133
NET_REQUEST_WIFI_CMD_CANDIDATE_SCAN,
134134
/** AP WPS config */
135135
NET_REQUEST_WIFI_CMD_AP_WPS_CONFIG,
136+
/** Configure BSS maximum idle period */
137+
NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD,
136138
/** @cond INTERNAL_HIDDEN */
137139
NET_REQUEST_WIFI_CMD_MAX
138140
/** @endcond */
@@ -317,6 +319,11 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_START_ROAMING);
317319

318320
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_NEIGHBOR_REP_COMPLETE);
319321

322+
#define NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD \
323+
(NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD)
324+
325+
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD);
326+
320327
/** @brief Wi-Fi management events */
321328
enum net_event_wifi_cmd {
322329
/** Scan results available */
@@ -1559,6 +1566,15 @@ struct wifi_mgmt_ops {
15591566
* @return 0 if ok, < 0 if error
15601567
*/
15611568
int (*start_11r_roaming)(const struct device *dev);
1569+
/** Set BSS max idle period
1570+
*
1571+
* @param dev Pointer to the device structure for the driver instance.
1572+
* @param BSS max idle period value
1573+
*
1574+
* @return 0 if ok, < 0 if error
1575+
*/
1576+
int (*set_bss_max_idle_period)(const struct device *dev,
1577+
unsigned short bss_max_idle_period);
15621578
};
15631579

15641580
/** Wi-Fi management offload API */

modules/hostap/src/supp_api.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,19 @@ int supplicant_legacy_roam(const struct device *dev)
18111811
return ret;
18121812
}
18131813

1814+
int supplicant_set_bss_max_idle_period(const struct device *dev,
1815+
unsigned short bss_max_idle_period)
1816+
{
1817+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);
1818+
1819+
if (!wifi_mgmt_api || !wifi_mgmt_api->set_bss_max_idle_period) {
1820+
wpa_printf(MSG_ERROR, "set_bss_max_idle_period is not supported");
1821+
return -ENOTSUP;
1822+
}
1823+
1824+
return wifi_mgmt_api->set_bss_max_idle_period(dev, bss_max_idle_period);
1825+
}
1826+
18141827
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM
18151828
int supplicant_btm_query(const struct device *dev, uint8_t reason)
18161829
{

modules/hostap/src/supp_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ int supplicant_get_wifi_conn_params(const struct device *dev,
305305
*/
306306
int supplicant_wps_config(const struct device *dev, struct wifi_wps_config_params *params);
307307

308+
/** @ Set Wi-Fi max idle period
309+
*
310+
* @param dev Wi-Fi interface handle to use
311+
* @param bss_max_idle_period Maximum idle period to set
312+
* @return 0 for OK; -1 for ERROR
313+
*/
314+
int supplicant_set_bss_max_idle_period(const struct device *dev,
315+
unsigned short bss_max_idle_period);
308316
#ifdef CONFIG_AP
309317
int set_ap_bandwidth(const struct device *dev, enum wifi_frequency_bandwidths bandwidth);
310318

modules/hostap/src/supp_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static const struct wifi_mgmt_ops mgmt_ops = {
8383
#endif
8484
.get_conn_params = supplicant_get_wifi_conn_params,
8585
.wps_config = supplicant_wps_config,
86+
.set_bss_max_idle_period = supplicant_set_bss_max_idle_period,
8687
#ifdef CONFIG_AP
8788
.ap_enable = supplicant_ap_enable,
8889
.ap_disable = supplicant_ap_disable,

subsys/net/l2/wifi/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,19 @@ config HEAP_MEM_POOL_ADD_SIZE_WIFI_CERT
154154
endif # WIFI_SHELL_RUNTIME_CERTIFICATES
155155

156156
endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
157+
158+
config WIFI_MGMT_BSS_MAX_IDLE_TIME
159+
int "BSS max idle timeout in seconds"
160+
range 0 64000
161+
default 30
162+
help
163+
As per 802.11-2020: 11.21.13 BSS max idle period management
164+
If dot11WirelessManagementImplemented is true, dot11BSSMaxIdlePeriod is
165+
nonzero and dot11BSSMaxIdlePeriodIndicationByNonAPSTA is true, then a
166+
non-S1G non-AP STA shall include a BSS Max Idle Period element
167+
in the (Re)Association Request frame. If the BSS Max Idle Period
168+
element is present in the (Re)Association Request frame received
169+
by a non-S1G AP that has dot11BSSMaxIdlePeriodIndicationByNonAPSTA
170+
equal to true, then the non-S1G AP may choose the non-AP STA’s
171+
preferred maximum idle period. The non-S1G AP indicates its chosen
172+
value to the non-S1G STA in the (Re)Association Response frame.

0 commit comments

Comments
 (0)