Skip to content
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

Set BSS config parameters max-inactivity, skip_inactivity_poll and max num_sta #1710

Merged
merged 7 commits into from
May 31, 2024
13 changes: 13 additions & 0 deletions doc/releases/release-notes-3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ Drivers and Sensors
* Added support for configuring RTS threshold. With this, users can set the RTS threshold value or
disable the RTS mechanism.

* Added support for configuring AP parameters. With this, users can set AP parameters at
build and run time.

* Added support to configure "max_inactivity" BSS parameter. Users can set this both build and runtime
duration to control the maximum time duration after which AP may disconnect a STA due to inactivity
from STA.

* Added support to configure "inactivity_poll" BSS parameter. Users can set build only AP parameter
to control whether AP may poll the STA before throwing away STA due to inactivity.

* Added support to configure "max_num_sta" BSS parameter. Users can set this both build and run time
parameter to control the maximum numuber of STA entries.

Networking
**********

Expand Down
8 changes: 8 additions & 0 deletions include/zephyr/net/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no)
return "<unknown>";
}

/** @brief Wi-Fi AP mode configuration parameter */
enum wifi_ap_config_param {
/** Used for AP mode configuration parameter ap_max_inactivity */
WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY = BIT(0),
/** Used for AP mode configuration parameter max_num_sta */
WIFI_AP_CONFIG_PARAM_MAX_NUM_STA = BIT(1),
};

#ifdef __cplusplus
}
#endif
Expand Down
35 changes: 32 additions & 3 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extern "C" {
#define WIFI_MGMT_BAND_STR_SIZE_MAX 8
#define WIFI_MGMT_SCAN_MAX_BSS_CNT 65535

#define WIFI_MGMT_SKIP_INACTIVITY_POLL IS_ENABLED(CONFIG_WIFI_MGMT_AP_STA_SKIP_INACTIVITY_POLL)
/** @endcond */

/** @brief Wi-Fi management commands */
Expand Down Expand Up @@ -88,7 +89,8 @@ enum net_request_wifi_cmd {
NET_REQUEST_WIFI_CMD_VERSION,
/** Set RTS threshold */
NET_REQUEST_WIFI_CMD_RTS_THRESHOLD,

/** Configure AP parameter */
NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM,
/** @cond INTERNAL_HIDDEN */
NET_REQUEST_WIFI_CMD_MAX
/** @endcond */
Expand Down Expand Up @@ -184,12 +186,18 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT);

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION);

/** Request a Wi-Fi RTS threashold */
/** Request a Wi-Fi RTS threshold */
#define NET_REQUEST_WIFI_RTS_THRESHOLD \
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD)

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD);

/** Request a Wi-Fi AP parameters configuration */
#define NET_REQUEST_WIFI_AP_CONFIG_PARAM \
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM)

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM);

/** @brief Wi-Fi management events */
enum net_event_wifi_cmd {
/** Scan results available */
Expand Down Expand Up @@ -746,6 +754,20 @@ struct wifi_channel_info {
enum wifi_mgmt_op oper;
};

/** @cond INTERNAL_HIDDEN */
#define WIFI_AP_STA_MAX_INACTIVITY (LONG_MAX - 1)
/** @endcond */

/** @brief Wi-Fi AP configuration parameter */
struct wifi_ap_config_params {
/** Parameter used to identify the different AP parameters */
enum wifi_ap_config_param type;
/** Parameter used for setting maximum inactivity duration for stations */
uint32_t max_inactivity;
/** Parameter used for setting maximum number of stations */
uint32_t max_num_sta;
};

#include <zephyr/net/net_if.h>

/** Scan result callback
Expand Down Expand Up @@ -919,7 +941,14 @@ struct wifi_mgmt_ops {
* @return 0 if ok, < 0 if error
*/
int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold);

/** Configure AP parameter
*
* @param dev Pointer to the device structure for the driver instance.
* @param params AP mode parameter configuration parameter info
*
* @return 0 if ok, < 0 if error
*/
int (*ap_config_params)(const struct device *dev, struct wifi_ap_config_params *params);
};

/** Wi-Fi management offload API */
Expand Down
26 changes: 26 additions & 0 deletions subsys/net/l2/wifi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,29 @@ module-str = Log level for Wi-Fi Network manager module
module-help = Enables using the Wi-Fi Network managers to manage the Wi-Fi network interfaces.
source "subsys/net/Kconfig.template.log_config.net"
endif # WIFI_NM

config WIFI_MGMT_AP_STA_INACTIVITY_TIMEOUT
int "Station inactivity timeout in seconds"
default 300
help
Station inactivity timeout is the period for which AP may keep a client
in associated state while there is no traffic from that particular
client. If a non-zero value is set, AP may choose to disassociate the
client after the timeout.

config WIFI_MGMT_AP_STA_SKIP_INACTIVITY_POLL
bool "Skip inactivity poll for stations after the inactivity timeout"
help
Skip inactivity poll for stations after the inactivity timeout. This
will prevent the AP from sending null data frames to the stations after
the inactivity timeout. This is useful to disconnect idle stations even
if they are within the range of the AP.
Note: This is only build time parameter, runtime configuration not supported.

config WIFI_MGMT_AP_MAX_NUM_STA
int "Maximum number of stations allowed in station table"
range 1 2007
default 4
help
Maximum number of stations allowed in station table. New stations will be
rejected after the station table is full.
34 changes: 34 additions & 0 deletions subsys/net/l2/wifi/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,40 @@ static int wifi_ap_sta_disconnect(uint32_t mgmt_request, struct net_if *iface,

NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT, wifi_ap_sta_disconnect);

static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
const struct device *dev = net_if_get_device(iface);
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
struct wifi_ap_config_params *params = data;

if (dev == NULL) {
return -ENODEV;
}

if (wifi_mgmt_api == NULL ||
wifi_mgmt_api->ap_config_params == NULL) {
return -ENOTSUP;
}

if (!data || len != sizeof(*params)) {
return -EINVAL;
}

if (params->type & WIFI_AP_CONFIG_PARAM_MAX_NUM_STA) {
if (params->max_num_sta > CONFIG_WIFI_MGMT_AP_MAX_NUM_STA) {
LOG_INF("Maximum number of stations(%d) "
"exceeded default configured value = %d.",
params->max_num_sta, CONFIG_WIFI_MGMT_AP_MAX_NUM_STA);
return -EINVAL;
}
}

return wifi_mgmt_api->ap_config_params(dev, params);
}

NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM, wifi_ap_config_params);

static int wifi_iface_status(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
Expand Down
Loading
Loading