drivers: wifi: siwx91x: Enable AP configuration support

- Adds support for configuring client maximum inactivity timeout.
- Adds support for bandwidth, It supports 20MHZ only.
- Adds support for setting the maximum number of clients and
  hidden SSID mode by rebooting the NWP device.

Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
This commit is contained in:
Arunmani Alagarsamy 2025-04-10 16:33:12 +05:30 committed by Benjamin Cabé
commit 4c1a91fa63
4 changed files with 125 additions and 11 deletions

View file

@ -20,13 +20,16 @@
#include "rsi_ble_common_config.h"
#endif
#define AP_MAX_NUM_STA 4
LOG_MODULE_REGISTER(siwx91x_nwp);
BUILD_ASSERT(DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(195) ||
DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(255) ||
DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(319));
int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t wifi_oper_mode)
int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t wifi_oper_mode,
bool hidden_ssid, uint8_t max_num_sta)
{
sl_wifi_device_configuration_t default_config = {
.band = SL_SI91X_WIFI_BAND_2_4GHZ,
@ -48,6 +51,13 @@ int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t w
sl_si91x_boot_configuration_t *boot_config = &default_config.boot_config;
__ASSERT(get_config, "get_config cannot be NULL");
__ASSERT((hidden_ssid == true || max_num_sta != 0) && wifi_oper_mode != WIFI_SOFTAP_MODE,
"hidden_ssid or max_num_sta requires SOFTAP mode");
if (wifi_oper_mode == WIFI_SOFTAP_MODE && max_num_sta > AP_MAX_NUM_STA) {
LOG_ERR("Exceeded maximum supported stations (%d)", AP_MAX_NUM_STA);
return -EINVAL;
}
/* The size does not match exactly because 1 KB is reserved at the start of the RAM */
if (DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(195)) {
@ -110,6 +120,15 @@ int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t w
} else if (wifi_oper_mode == WIFI_SOFTAP_MODE) {
boot_config->oper_mode = SL_SI91X_ACCESS_POINT_MODE;
boot_config->coex_mode = SL_SI91X_WLAN_ONLY_MODE;
boot_config->custom_feature_bit_map |= SL_SI91X_CUSTOM_FEAT_LIMIT_PACKETS_PER_STA;
if (hidden_ssid) {
boot_config->custom_feature_bit_map |=
SL_SI91X_CUSTOM_FEAT_AP_IN_HIDDEN_MODE;
}
boot_config->custom_feature_bit_map |=
SL_WIFI_CUSTOM_FEAT_MAX_NUM_OF_CLIENTS(max_num_sta);
if (IS_ENABLED(CONFIG_BT_SILABS_SIWX91X)) {
LOG_WRN("Bluetooth is not supported in AP mode");
@ -166,12 +185,12 @@ int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t w
return 0;
}
int siwx91x_nwp_mode_switch(uint8_t oper_mode)
int siwx91x_nwp_mode_switch(uint8_t oper_mode, bool hidden_ssid, uint8_t max_num_sta)
{
sl_wifi_device_configuration_t nwp_config;
int status;
status = siwx91x_get_nwp_config(&nwp_config, oper_mode);
status = siwx91x_get_nwp_config(&nwp_config, oper_mode, hidden_ssid, max_num_sta);
if (status < 0) {
return status;
}
@ -195,7 +214,7 @@ static int siwg917_nwp_init(void)
sl_wifi_device_configuration_t network_config;
sl_status_t status;
siwx91x_get_nwp_config(&network_config, WIFI_STA_MODE);
siwx91x_get_nwp_config(&network_config, WIFI_STA_MODE, false, 0);
/* TODO: If sl_net_*_profile() functions will be needed for WiFi then call
* sl_net_set_profile() here. Currently these are unused.
*/

View file

@ -17,9 +17,11 @@
* of the NWP to apply the new mode along with the updated features.
*
* @param[in] oper_mode Wi-Fi operating mode to switch to.
* @param[in] hidden_ssid SSID and its length (used only in WIFI_AP_MODE).
* @param[in] max_num_sta Maximum number of supported stations (only for WIFI_AP_MODE).
*
* @return 0 on success, negative error code on failure.
*/
int siwx91x_nwp_mode_switch(uint8_t oper_mode);
int siwx91x_nwp_mode_switch(uint8_t oper_mode, bool hidden_ssid, uint8_t max_num_sta);
#endif