Skip to content

Commit f6fbc56

Browse files
committed
net: wifi_mgmt: Configure BSS max idle period
Support to configure BSS max idle period at runtime. Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
1 parent b9bfff2 commit f6fbc56

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

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
/** @cond INTERNAL_HIDDEN */
321328

322329
enum {
@@ -1598,6 +1605,15 @@ struct wifi_mgmt_ops {
15981605
* @return 0 if ok, < 0 if error
15991606
*/
16001607
int (*start_11r_roaming)(const struct device *dev);
1608+
/** Set BSS max idle period
1609+
*
1610+
* @param dev Pointer to the device structure for the driver instance.
1611+
* @param BSS max idle period value
1612+
*
1613+
* @return 0 if ok, < 0 if error
1614+
*/
1615+
int (*set_bss_max_idle_period)(const struct device *dev,
1616+
unsigned short bss_max_idle_period);
16011617
};
16021618

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

subsys/net/l2/wifi/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,16 @@ config HEAP_MEM_POOL_ADD_SIZE_WIFI_CERT
149149
endif # WIFI_SHELL_RUNTIME_CERTIFICATES
150150

151151
endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
152+
153+
config WIFI_MGMT_BSS_MAX_IDLE_TIME
154+
int "BSS max idle timeout in seconds"
155+
range 0 64000
156+
default 300
157+
help
158+
BSS max idle timeout is the period for which AP may keep a client
159+
in associated state while there is no traffic from that particular
160+
client. Set 0 to disable inclusion of BSS max idle time tag in
161+
association request. If a non-zero value is set, STA can suggest a
162+
timeout by including BSS max idle period in the association request.
163+
AP may choose to consider or ignore the STA's preferred value.
164+
Ref: Sec 11.21.13 of IEEE Std 802.11™-2020

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,27 @@ static int wifi_set_enterprise_creds(uint64_t mgmt_request, struct net_if *iface
14031403
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_ENTERPRISE_CREDS, wifi_set_enterprise_creds);
14041404
#endif
14051405

1406+
static int wifi_set_bss_max_idle_period(uint32_t mgmt_request, struct net_if *iface,
1407+
void *data, size_t len)
1408+
{
1409+
const struct device *dev = net_if_get_device(iface);
1410+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
1411+
unsigned short *bss_max_idle_period = data;
1412+
1413+
if (wifi_mgmt_api == NULL || wifi_mgmt_api->set_bss_max_idle_period == NULL) {
1414+
return -ENOTSUP;
1415+
}
1416+
1417+
if (!data || len != sizeof(*bss_max_idle_period)) {
1418+
return -EINVAL;
1419+
}
1420+
1421+
return wifi_mgmt_api->set_bss_max_idle_period(dev, *bss_max_idle_period);
1422+
}
1423+
1424+
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD,
1425+
wifi_set_bss_max_idle_period);
1426+
14061427
#ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
14071428
void wifi_mgmt_raise_raw_scan_result_event(struct net_if *iface,
14081429
struct wifi_raw_scan_result *raw_scan_result)

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,32 @@ static int cmd_wifi_pmksa_flush(const struct shell *sh, size_t argc, char *argv[
38073807

38083808
return 0;
38093809
}
3810+
3811+
static int cmd_wifi_set_bss_max_idle_period(const struct shell *sh, size_t argc, char *argv[])
3812+
{
3813+
struct net_if *iface = net_if_get_first_wifi();
3814+
unsigned short bss_max_idle_period = 0;
3815+
int idx = 1;
3816+
unsigned long val = 0;
3817+
3818+
if (!parse_number(sh, &val, argv[idx++], "bss_max_idle_period", 0, USHRT_MAX)) {
3819+
return -EINVAL;
3820+
}
3821+
3822+
bss_max_idle_period = (unsigned short)val;
3823+
3824+
if (net_mgmt(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD, iface,
3825+
&bss_max_idle_period, sizeof(bss_max_idle_period))) {
3826+
shell_fprintf(sh, SHELL_WARNING,
3827+
"Setting BSS maximum idle period failed.\n");
3828+
return -ENOEXEC;
3829+
}
3830+
3831+
shell_fprintf(sh, SHELL_NORMAL, "BSS max idle period: %hu\n", bss_max_idle_period);
3832+
3833+
return 0;
3834+
}
3835+
38103836
SHELL_STATIC_SUBCMD_SET_CREATE(
38113837
wifi_cmd_ap,
38123838
SHELL_CMD_ARG(disable, NULL, "Disable Access Point mode.\n"
@@ -4285,6 +4311,12 @@ SHELL_SUBCMD_ADD((wifi), ps_exit_strategy, NULL,
42854311
cmd_wifi_ps_exit_strategy,
42864312
2, 2);
42874313

4314+
SHELL_SUBCMD_ADD((wifi), bss_max_idle_period, NULL,
4315+
"<bss_max_idle: timer(in TUs)>.\n"
4316+
"[-i, --iface=<interface index>] : Interface index.\n",
4317+
cmd_wifi_set_bss_max_idle_period,
4318+
2, 0);
4319+
42884320
SHELL_CMD_REGISTER(wifi, &wifi_commands, "Wi-Fi commands", NULL);
42894321

42904322
static int wifi_shell_init(void)

0 commit comments

Comments
 (0)