Skip to content

Commit f14fb74

Browse files
ajayparidarlubos
authored andcommitted
[nrf fromtree] net: wifi_mgmt: Support to configure AP parameter max_num_sta
Support to set BSS parameter "max_num_sta" at compile and run time Added support to configure `max_num_sta` BSS parameter. Maximum number of stations allowed in station table. New stations will be rejected after the station table is full. Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no> (cherry picked from commit d4b22cd)
1 parent 46eb559 commit f14fb74

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

include/zephyr/net/wifi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no)
498498
enum wifi_ap_config_param {
499499
/** Used for AP mode configuration parameter ap_max_inactivity */
500500
WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY = BIT(0),
501+
/** Used for AP mode configuration parameter max_num_sta */
502+
WIFI_AP_CONFIG_PARAM_MAX_NUM_STA = BIT(1),
501503
};
502504

503505
#ifdef __cplusplus

include/zephyr/net/wifi_mgmt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ struct wifi_ap_config_params {
764764
enum wifi_ap_config_param type;
765765
/** Parameter used for setting maximum inactivity duration for stations */
766766
uint32_t max_inactivity;
767+
/** Parameter used for setting maximum number of stations */
768+
uint32_t max_num_sta;
767769
};
768770

769771
#include <zephyr/net/net_if.h>

subsys/net/l2/wifi/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ config WIFI_MGMT_AP_STA_SKIP_INACTIVITY_POLL
111111
the inactivity timeout. This is useful to disconnect idle stations even
112112
if they are within the range of the AP.
113113
Note: This is only build time parameter, runtime configuration not supported.
114+
115+
config WIFI_MGMT_AP_MAX_NUM_STA
116+
int "Maximum number of stations allowed in station table"
117+
range 1 2007
118+
default 4
119+
help
120+
Maximum number of stations allowed in station table. New stations will be
121+
rejected after the station table is full.

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,15 @@ static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface,
455455
return -EINVAL;
456456
}
457457

458+
if (params->type & WIFI_AP_CONFIG_PARAM_MAX_NUM_STA) {
459+
if (params->max_num_sta > CONFIG_WIFI_MGMT_AP_MAX_NUM_STA) {
460+
LOG_INF("Maximum number of stations(%d) "
461+
"exceeded default configured value = %d.",
462+
params->max_num_sta, CONFIG_WIFI_MGMT_AP_MAX_NUM_STA);
463+
return -EINVAL;
464+
}
465+
}
466+
458467
return wifi_mgmt_api->ap_config_params(dev, params);
459468
}
460469

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,12 +1376,13 @@ static int wifi_ap_config_args_to_params(const struct shell *sh, size_t argc, ch
13761376
struct getopt_state *state;
13771377
int opt;
13781378
static struct option long_options[] = {{"max_inactivity", required_argument, 0, 'i'},
1379+
{"max_num_sta", required_argument, 0, 's'},
13791380
{"help", no_argument, 0, 'h'},
13801381
{0, 0, 0, 0}};
13811382
int opt_index = 0;
13821383
long val;
13831384

1384-
while ((opt = getopt_long(argc, argv, "i:h", long_options, &opt_index)) != -1) {
1385+
while ((opt = getopt_long(argc, argv, "i:s:h", long_options, &opt_index)) != -1) {
13851386
state = getopt_state_get();
13861387
switch (opt) {
13871388
case 'i':
@@ -1392,6 +1393,14 @@ static int wifi_ap_config_args_to_params(const struct shell *sh, size_t argc, ch
13921393
params->max_inactivity = (uint32_t)val;
13931394
params->type |= WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY;
13941395
break;
1396+
case 's':
1397+
if (!parse_number(sh, &val, optarg, "max_num_sta",
1398+
0, CONFIG_WIFI_MGMT_AP_MAX_NUM_STA)) {
1399+
return -EINVAL;
1400+
}
1401+
params->max_num_sta = (uint32_t)val;
1402+
params->type |= WIFI_AP_CONFIG_PARAM_MAX_NUM_STA;
1403+
break;
13951404
case 'h':
13961405
shell_help(sh);
13971406
return SHELL_CMD_HELP_PRINTED;
@@ -1955,9 +1964,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap,
19551964
SHELL_CMD_ARG(config, NULL,
19561965
"Configure AP parameters.\n"
19571966
"-i --max_inactivity=<time duration (in seconds)>\n"
1967+
"-s --max_num_sta=<maximum number of stations>\n"
19581968
"-h --help (prints help)",
19591969
cmd_wifi_ap_config_params,
1960-
2, 3),
1970+
2, 5),
19611971
SHELL_SUBCMD_SET_END
19621972
);
19631973

0 commit comments

Comments
 (0)