drivers: wifi: siwx91x: Replace opermode flags

Replaced SL_SI91X_CLIENT_MODE and SL_SI91X_ACCESS_POINT_MODE with
WIFI_STA_MODE and WIFI_SOFTAP_MODE, respectively, for AP configuration
command intergration.

Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
This commit is contained in:
Arunmani Alagarsamy 2025-04-10 16:22:27 +05:30 committed by Benjamin Cabé
commit 0459bd8638
3 changed files with 23 additions and 25 deletions

View file

@ -40,7 +40,7 @@ static int siwx91x_sl_to_z_mode(sl_wifi_interface_t interface)
case SL_WIFI_CLIENT_INTERFACE: case SL_WIFI_CLIENT_INTERFACE:
return WIFI_STA_MODE; return WIFI_STA_MODE;
case SL_WIFI_AP_INTERFACE: case SL_WIFI_AP_INTERFACE:
return WIFI_AP_MODE; return WIFI_SOFTAP_MODE;
default: default:
return -EIO; return -EIO;
} }

View file

@ -26,7 +26,7 @@ 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(255) ||
DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(319)); DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(319));
int siwg91x_get_nwp_config(int wifi_oper_mode, sl_wifi_device_configuration_t *get_config) int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t wifi_oper_mode)
{ {
sl_wifi_device_configuration_t default_config = { sl_wifi_device_configuration_t default_config = {
.band = SL_SI91X_WIFI_BAND_2_4GHZ, .band = SL_SI91X_WIFI_BAND_2_4GHZ,
@ -60,7 +60,7 @@ int siwg91x_get_nwp_config(int wifi_oper_mode, sl_wifi_device_configuration_t *g
k_panic(); k_panic();
} }
if (wifi_oper_mode == SL_SI91X_CLIENT_MODE) { if (wifi_oper_mode == WIFI_STA_MODE) {
boot_config->oper_mode = SL_SI91X_CLIENT_MODE; boot_config->oper_mode = SL_SI91X_CLIENT_MODE;
if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ROAMING_USE_DEAUTH)) { if (IS_ENABLED(CONFIG_WIFI_SILABS_SIWX91X_ROAMING_USE_DEAUTH)) {
@ -107,7 +107,7 @@ int siwg91x_get_nwp_config(int wifi_oper_mode, sl_wifi_device_configuration_t *g
SL_SI91X_BLE_ENABLE_ADV_EXTN | SL_SI91X_BLE_ENABLE_ADV_EXTN |
SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS); SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS);
#endif #endif
} else if (wifi_oper_mode == SL_SI91X_ACCESS_POINT_MODE) { } else if (wifi_oper_mode == WIFI_SOFTAP_MODE) {
boot_config->oper_mode = SL_SI91X_ACCESS_POINT_MODE; boot_config->oper_mode = SL_SI91X_ACCESS_POINT_MODE;
boot_config->coex_mode = SL_SI91X_WLAN_ONLY_MODE; boot_config->coex_mode = SL_SI91X_WLAN_ONLY_MODE;
@ -136,22 +136,26 @@ int siwg91x_get_nwp_config(int wifi_oper_mode, sl_wifi_device_configuration_t *g
if (IS_ENABLED(CONFIG_NET_IPV6)) { if (IS_ENABLED(CONFIG_NET_IPV6)) {
boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_IPV6; boot_config->tcp_ip_feature_bit_map |= SL_SI91X_TCP_IP_FEAT_IPV6;
if (wifi_oper_mode == SL_SI91X_CLIENT_MODE) { if (wifi_oper_mode == WIFI_STA_MODE) {
boot_config->tcp_ip_feature_bit_map |= boot_config->tcp_ip_feature_bit_map |=
SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT; SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT;
} else if (wifi_oper_mode == SL_SI91X_ACCESS_POINT_MODE) { } else if (wifi_oper_mode == WIFI_SOFTAP_MODE) {
boot_config->tcp_ip_feature_bit_map |= boot_config->tcp_ip_feature_bit_map |=
SL_SI91X_TCP_IP_FEAT_DHCPV6_SERVER; SL_SI91X_TCP_IP_FEAT_DHCPV6_SERVER;
} else {
/* No DHCPv6 configuration needed for other modes */
} }
} }
if (IS_ENABLED(CONFIG_NET_IPV4)) { if (IS_ENABLED(CONFIG_NET_IPV4)) {
if (wifi_oper_mode == SL_SI91X_CLIENT_MODE) { if (wifi_oper_mode == WIFI_STA_MODE) {
boot_config->tcp_ip_feature_bit_map |= boot_config->tcp_ip_feature_bit_map |=
SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT; SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT;
} else if (wifi_oper_mode == SL_SI91X_ACCESS_POINT_MODE) { } else if (wifi_oper_mode == WIFI_SOFTAP_MODE) {
boot_config->tcp_ip_feature_bit_map |= boot_config->tcp_ip_feature_bit_map |=
SL_SI91X_TCP_IP_FEAT_DHCPV4_SERVER; SL_SI91X_TCP_IP_FEAT_DHCPV4_SERVER;
} else {
/* No DHCPv4 configuration needed for other modes */
} }
} }
} else { } else {
@ -165,17 +169,11 @@ int siwg91x_get_nwp_config(int wifi_oper_mode, sl_wifi_device_configuration_t *g
int siwx91x_nwp_mode_switch(uint8_t oper_mode) int siwx91x_nwp_mode_switch(uint8_t oper_mode)
{ {
sl_wifi_device_configuration_t nwp_config; sl_wifi_device_configuration_t nwp_config;
sl_status_t status; int status;
switch (oper_mode) { status = siwx91x_get_nwp_config(&nwp_config, oper_mode);
case WIFI_STA_MODE: if (status < 0) {
siwg91x_get_nwp_config(SL_SI91X_CLIENT_MODE, &nwp_config); return status;
break;
case WIFI_AP_MODE:
siwg91x_get_nwp_config(SL_SI91X_ACCESS_POINT_MODE, &nwp_config);
break;
default:
return -EINVAL;
} }
/* FIXME: Calling sl_wifi_deinit() impacts Bluetooth if coexistence is enabled */ /* FIXME: Calling sl_wifi_deinit() impacts Bluetooth if coexistence is enabled */
@ -197,7 +195,7 @@ static int siwg917_nwp_init(void)
sl_wifi_device_configuration_t network_config; sl_wifi_device_configuration_t network_config;
sl_status_t status; sl_status_t status;
siwg91x_get_nwp_config(SL_SI91X_CLIENT_MODE, &network_config); siwx91x_get_nwp_config(&network_config, WIFI_STA_MODE);
/* TODO: If sl_net_*_profile() functions will be needed for WiFi then call /* TODO: If sl_net_*_profile() functions will be needed for WiFi then call
* sl_net_set_profile() here. Currently these are unused. * sl_net_set_profile() here. Currently these are unused.
*/ */

View file

@ -10,15 +10,15 @@
#define SIWX91X_INTERFACE_MASK (0x03) #define SIWX91X_INTERFACE_MASK (0x03)
/** /**
* @brief Switch the Wi-Fi operating modes. * @brief Switch the Wi-Fi operating mode.
* *
* This function switches the mode. If the requested mode is already active, * This function switches the Network Processor (NWP) to the specified Wi-Fi
* no action is performed. Otherwise, it reinitializes the Wi-Fi subsystem to * operating mode based on the provided features. It performs a soft reboot
* apply the new mode. * of the NWP to apply the new mode along with the updated features.
* *
* @param[in] oper_mode Desired Wi-Fi operating mode: * @param[in] oper_mode Wi-Fi operating mode to switch to.
* *
* @return 0 on success, or a negative error code on failure: * @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);