Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/wifi/nrf_wifi/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct nrf_wifi_vif_ctx_zep {
struct k_work_delayable nrf_wifi_rpu_recovery_bringup_work;
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
int rts_threshold_value;
unsigned short bss_max_idle_period;
};

struct nrf_wifi_vif_ctx_map {
Expand Down
3 changes: 3 additions & 0 deletions drivers/wifi/nrf_wifi/inc/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@

int nrf_wifi_get_rts_threshold(const struct device *dev,
unsigned int *rts_threshold);

int nrf_wifi_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period);
#endif /* __ZEPHYR_WIFI_MGMT_H__ */

Check notice on line 83 in drivers/wifi/nrf_wifi/inc/wifi_mgmt.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/inc/wifi_mgmt.h:83 -int nrf_wifi_set_bss_max_idle_period(const struct device *dev, - unsigned short bss_max_idle_period); +int nrf_wifi_set_bss_max_idle_period(const struct device *dev, unsigned short bss_max_idle_period);
4 changes: 4 additions & 0 deletions drivers/wifi/nrf_wifi/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
#endif /* CONFIG_NRF70_RADIO_TEST */

k_mutex_init(&rpu_drv_priv_zep.rpu_ctx_zep.rpu_lock);
#ifndef CONFIG_NRF70_RADIO_TEST
vif_ctx_zep->bss_max_idle_period = USHRT_MAX;
#endif /* !CONFIG_NRF70_RADIO_TEST */
return 0;
#ifdef CONFIG_NRF70_RADIO_TEST
fmac_deinit:
Expand Down Expand Up @@ -885,6 +888,7 @@ static const struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
.get_power_save_config = nrf_wifi_get_power_save_config,
.set_rts_threshold = nrf_wifi_set_rts_threshold,
.get_rts_threshold = nrf_wifi_get_rts_threshold,
.set_bss_max_idle_period = nrf_wifi_set_bss_max_idle_period,
#endif
#ifdef CONFIG_NRF70_SYSTEM_WITH_RAW_MODES
.mode = nrf_wifi_mode,
Expand Down
53 changes: 53 additions & 0 deletions drivers/wifi/nrf_wifi/src/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,3 +1077,56 @@

return ret;
}

int nrf_wifi_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period)
{

Check notice on line 1083 in drivers/wifi/nrf_wifi/src/wifi_mgmt.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_mgmt.c:1083 -int nrf_wifi_set_bss_max_idle_period(const struct device *dev, - unsigned short bss_max_idle_period) +int nrf_wifi_set_bss_max_idle_period(const struct device *dev, unsigned short bss_max_idle_period)
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
int ret = -1;

if (!dev) {
LOG_ERR("%s: dev is NULL", __func__);
return ret;
}

vif_ctx_zep = dev->data;

if (!vif_ctx_zep) {
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
return ret;
}

rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;

if (!rpu_ctx_zep) {
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
return ret;
}


if (!rpu_ctx_zep->rpu_ctx) {
LOG_ERR("%s: RPU context not initialized", __func__);
return ret;
}

if (((int)bss_max_idle_period < 0) ||
(bss_max_idle_period > 64000)) {
/* 0 or value less than 64000 is passed to f/w.
* All other values considered as invalid.
*/
LOG_ERR("%s: Invalid max_idle_period value : %d",
__func__, (int)bss_max_idle_period);
return ret;

Check notice on line 1120 in drivers/wifi/nrf_wifi/src/wifi_mgmt.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_mgmt.c:1120 - if (!rpu_ctx_zep->rpu_ctx) { LOG_ERR("%s: RPU context not initialized", __func__); return ret; } - if (((int)bss_max_idle_period < 0) || - (bss_max_idle_period > 64000)) { + if (((int)bss_max_idle_period < 0) || (bss_max_idle_period > 64000)) { /* 0 or value less than 64000 is passed to f/w. * All other values considered as invalid. */ - LOG_ERR("%s: Invalid max_idle_period value : %d", - __func__, (int)bss_max_idle_period); + LOG_ERR("%s: Invalid max_idle_period value : %d", __func__, + (int)bss_max_idle_period);
}

k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);

vif_ctx_zep->bss_max_idle_period = bss_max_idle_period;

ret = 0;

k_mutex_unlock(&vif_ctx_zep->vif_lock);

return ret;
}
11 changes: 9 additions & 2 deletions drivers/wifi/nrf_wifi/src/wpa_supp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,15 @@ int nrf_wifi_wpa_supp_associate(void *if_priv, struct wpa_driver_associate_param
assoc_info.use_mfp = NRF_WIFI_MFP_REQUIRED;
}

if (params->bss_max_idle_period) {
assoc_info.bss_max_idle_time = params->bss_max_idle_period;
if (vif_ctx_zep->bss_max_idle_period == USHRT_MAX) {
assoc_info.bss_max_idle_time = CONFIG_WIFI_MGMT_BSS_MAX_IDLE_TIME;
} else {
assoc_info.bss_max_idle_time = vif_ctx_zep->bss_max_idle_period;
}

assoc_info.conn_type = NRF_WIFI_CONN_TYPE_OPEN;
if (!(params->key_mgmt_suite & WPA_KEY_MGMT_NONE)) {
assoc_info.conn_type = NRF_WIFI_CONN_TYPE_SECURE;
}

status = nrf_wifi_sys_fmac_assoc(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &assoc_info);
Expand Down
38 changes: 38 additions & 0 deletions include/zephyr/net/wifi_certs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef WIFI_CERTS_H__
#define WIFI_CERTS_H__

#include <stdbool.h>
#include <zephyr/kernel.h>
#include <zephyr/net/wifi_mgmt.h>

/**
* Set Wi-Fi Enterprise credentials.
*
* Sets up the required credentials for Enterprise mode in both
* Access Point and Station modes.
*
* Certificates typically used:
* - CA certificate
* - Client certificate
* - Client private key
* - Server certificate and server key (for AP mode)
*
* @param iface Network interface
* @param is_ap AP or Station mode
*
* @return 0 if ok, < 0 if error
*/
int wifi_set_enterprise_credentials(struct net_if *iface, bool is_ap);

/**
* Clear Wi-Fi enterprise credentials
*/
void wifi_clear_enterprise_credentials(void);

#endif /* WIFI_CERTS_H__ */
18 changes: 17 additions & 1 deletion include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
NET_REQUEST_WIFI_CMD_CANDIDATE_SCAN,
/** AP WPS config */
NET_REQUEST_WIFI_CMD_AP_WPS_CONFIG,
/** Configure BSS maximum idle period */
NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD,
/** @cond INTERNAL_HIDDEN */
NET_REQUEST_WIFI_CMD_MAX
/** @endcond */
Expand Down Expand Up @@ -317,6 +319,11 @@

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_NEIGHBOR_REP_COMPLETE);

#define NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD \
(NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD)

Check notice on line 323 in include/zephyr/net/wifi_mgmt.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/wifi_mgmt.h:323 -#define NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD \ +#define NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD \

NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD);

/** @brief Wi-Fi management events */
enum net_event_wifi_cmd {
/** Scan results available */
Expand Down Expand Up @@ -672,7 +679,7 @@
/** is TWT capable? */
bool twt_capable;
/** The current 802.11 PHY TX data rate (in Mbps) */
int current_phy_tx_rate;
float current_phy_tx_rate;
};

/** @brief Wi-Fi power save parameters */
Expand Down Expand Up @@ -1559,7 +1566,16 @@
* @return 0 if ok, < 0 if error
*/
int (*start_11r_roaming)(const struct device *dev);
/** Set BSS max idle period
*
* @param dev Pointer to the device structure for the driver instance.
* @param BSS max idle period value
*
* @return 0 if ok, < 0 if error
*/
int (*set_bss_max_idle_period)(const struct device *dev,
unsigned short bss_max_idle_period);
};

Check notice on line 1578 in include/zephyr/net/wifi_mgmt.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/wifi_mgmt.h:1578 - unsigned short bss_max_idle_period); + unsigned short bss_max_idle_period);

/** Wi-Fi management offload API */
struct net_wifi_mgmt_offload {
Expand Down
25 changes: 25 additions & 0 deletions modules/hostap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,33 @@ config WIFI_NM_WPA_SUPPLICANT

if WIFI_NM_WPA_SUPPLICANT

config WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP
bool "Use Zephyr kernel heap for Wi-Fi driver"
default y
help
Enable this option to use K_HEAP for memory allocations in supplicant.

if !WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP
config WIFI_NM_WPA_SUPPLICANT_HEAP
int "Dedicated memory pool for wpa_supplicant"
def_int 66560 if WIFI_NM_HOSTAPD_AP
def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE && WIFI_CREDENTIALS
def_int 48000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
def_int 41808 if WIFI_NM_WPA_SUPPLICANT_AP
# 30K is mandatory, but might need more for long duration use cases
def_int 30000
endif # !WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP

if WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP
config HEAP_MEM_POOL_ADD_SIZE_HOSTAP
def_int 66560 if WIFI_NM_HOSTAPD_AP
def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE && WIFI_CREDENTIALS
def_int 48000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
def_int 41808 if WIFI_NM_WPA_SUPPLICANT_AP
# 30K is mandatory, but might need more for long duration use cases
def_int 30000
endif # WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP


config WIFI_NM_WPA_SUPPLICANT_THREAD_STACK_SIZE
int "Stack size for wpa_supplicant thread"
Expand Down Expand Up @@ -201,6 +221,7 @@ config WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
select MBEDTLS_X509_CRL_PARSE_C
select MBEDTLS_TLS_VERSION_1_2
select NOT_SECURE
select WIFI_CERTIFICATE_LIB
depends on !WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE
help
Enable Enterprise Crypto support for WiFi. This feature
Expand Down Expand Up @@ -309,6 +330,7 @@ config WIFI_NM_HOSTAPD_AP

config WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE
bool "Hostapd crypto enterprise support"
select WIFI_CERTIFICATE_LIB
depends on WIFI_NM_HOSTAPD_AP

if WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE
Expand Down Expand Up @@ -564,6 +586,9 @@ config ACS
config IEEE80211AC
bool

config HS20
bool

config IEEE80211R
bool
depends on !WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE
Expand Down
13 changes: 13 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,19 @@
return ret;
}

int supplicant_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period)
{

Check notice on line 1816 in modules/hostap/src/supp_api.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

modules/hostap/src/supp_api.c:1816 -int supplicant_set_bss_max_idle_period(const struct device *dev, - unsigned short bss_max_idle_period) +int supplicant_set_bss_max_idle_period(const struct device *dev, unsigned short bss_max_idle_period)
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);

if (!wifi_mgmt_api || !wifi_mgmt_api->set_bss_max_idle_period) {
wpa_printf(MSG_ERROR, "set_bss_max_idle_period is not supported");
return -ENOTSUP;
}

return wifi_mgmt_api->set_bss_max_idle_period(dev, bss_max_idle_period);
}

#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM
int supplicant_btm_query(const struct device *dev, uint8_t reason)
{
Expand Down
9 changes: 9 additions & 0 deletions modules/hostap/src/supp_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@ int supplicant_get_wifi_conn_params(const struct device *dev,
*/
int supplicant_wps_config(const struct device *dev, struct wifi_wps_config_params *params);

/** @ Set Wi-Fi max idle period
*
* @param dev Wi-Fi interface handle to use
* @param bss_max_idle_period Maximum idle period to set
* @return 0 for OK; -1 for ERROR
*/
int supplicant_set_bss_max_idle_period(const struct device *dev,
unsigned short bss_max_idle_period);

#ifdef CONFIG_AP
int set_ap_bandwidth(const struct device *dev, enum wifi_frequency_bandwidths bandwidth);

Expand Down
1 change: 1 addition & 0 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static const struct wifi_mgmt_ops mgmt_ops = {
#endif
.get_conn_params = supplicant_get_wifi_conn_params,
.wps_config = supplicant_wps_config,
.set_bss_max_idle_period = supplicant_set_bss_max_idle_period,
#ifdef CONFIG_AP
.ap_enable = supplicant_ap_enable,
.ap_disable = supplicant_ap_disable,
Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ zephyr_library_include_directories_ifdef(
)

zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT wifi_mgmt.c)
zephyr_library_sources_ifdef(CONFIG_WIFI_CERTIFICATE_LIB wifi_certs.c)
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_SHELL wifi_shell.c)
zephyr_library_sources_ifdef(CONFIG_WIFI_NM wifi_nm.c)
zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_UTILS wifi_utils.c)
Expand Down
22 changes: 22 additions & 0 deletions subsys/net/l2/wifi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ config WIFI_ENT_IDENTITY_MAX_USERS
help
This option defines the maximum number of identity users allowed connection.

config WIFI_CERTIFICATE_LIB
bool
help
Enable this option to process certificates in enterprise mode.

if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE

config WIFI_SHELL_RUNTIME_CERTIFICATES
Expand All @@ -149,3 +154,20 @@ config HEAP_MEM_POOL_ADD_SIZE_WIFI_CERT
endif # WIFI_SHELL_RUNTIME_CERTIFICATES

endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE


config WIFI_MGMT_BSS_MAX_IDLE_TIME
int "BSS max idle timeout in seconds"
range 0 64000
default 300
help
As per 802.11-2020: 11.21.13 BSS max idle period management
If dot11WirelessManagementImplemented is true, dot11BSSMaxIdlePeriod is
nonzero and dot11BSSMaxIdlePeriodIndicationByNonAPSTA is true, then a
non-S1G non-AP STA shall include a BSS Max Idle Period element
in the (Re)Association Request frame. If the BSS Max Idle Period
element is present in the (Re)Association Request frame received
by a non-S1G AP that has dot11BSSMaxIdlePeriodIndicationByNonAPSTA
equal to true, then the non-S1G AP may choose the non-AP STA’s
preferred maximum idle period. The non-S1G AP indicates its chosen
value to the non-S1G STA in the (Re)Association Response frame.
Loading
Loading