Skip to content

Commit c3ce29e

Browse files
jerome-pouillerArunmaniAlagarsamy2710
authored andcommitted
drivers: wifi: siwx91x: Add support for get_power_save_config()
We can now implement the get_power_save_config() callback. Co-authored-by: Arunmani Alagarsamy <arunmani.a@silabs.com> Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com> Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
1 parent adae168 commit c3ce29e

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

drivers/wifi/siwx91x/siwx91x_wifi.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,68 @@ static int siwx91x_set_power_save(const struct device *dev, struct wifi_ps_param
386386
return 0;
387387
}
388388

389+
static int siwx91x_get_power_save_config(const struct device *dev, struct wifi_ps_config *config)
390+
{
391+
sl_wifi_performance_profile_t sl_ps_profile;
392+
struct siwx91x_dev *sidev = dev->data;
393+
sl_wifi_interface_t interface;
394+
uint16_t beacon_interval;
395+
sl_status_t status;
396+
397+
__ASSERT(config, "config cannot be NULL");
398+
399+
interface = sl_wifi_get_default_interface();
400+
if (FIELD_GET(SIWX91X_INTERFACE_MASK, interface) != SL_WIFI_CLIENT_INTERFACE) {
401+
LOG_ERR("Wi-Fi not in station mode");
402+
return -EINVAL;
403+
}
404+
405+
if (sidev->state == WIFI_STATE_INTERFACE_DISABLED) {
406+
LOG_ERR("Command given in invalid state");
407+
return -EINVAL;
408+
}
409+
410+
status = sl_wifi_get_performance_profile(&sl_ps_profile);
411+
if (status != SL_STATUS_OK) {
412+
LOG_ERR("Failed to get power save profile: 0x%x", status);
413+
return -EIO;
414+
}
415+
416+
switch (sl_ps_profile.profile) {
417+
case HIGH_PERFORMANCE:
418+
config->ps_params.enabled = WIFI_PS_DISABLED;
419+
break;
420+
case ASSOCIATED_POWER_SAVE_LOW_LATENCY:
421+
config->ps_params.enabled = WIFI_PS_ENABLED;
422+
config->ps_params.exit_strategy = WIFI_PS_EXIT_EVERY_TIM;
423+
break;
424+
case ASSOCIATED_POWER_SAVE:
425+
config->ps_params.enabled = WIFI_PS_ENABLED;
426+
config->ps_params.exit_strategy = WIFI_PS_EXIT_CUSTOM_ALGO;
427+
break;
428+
default:
429+
break;
430+
}
431+
432+
if (sl_ps_profile.dtim_aligned_type) {
433+
config->ps_params.wakeup_mode = WIFI_PS_WAKEUP_MODE_DTIM;
434+
} else {
435+
config->ps_params.wakeup_mode = WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL;
436+
437+
beacon_interval = siwx91x_get_connected_ap_beacon_interval_ms();
438+
if (beacon_interval > 0) {
439+
config->ps_params.listen_interval =
440+
sl_ps_profile.listen_interval / beacon_interval;
441+
}
442+
}
443+
444+
/* Device supports only legacy power-save mode */
445+
config->ps_params.mode = WIFI_PS_MODE_LEGACY;
446+
config->ps_params.timeout_ms = sl_ps_profile.monitor_interval;
447+
448+
return 0;
449+
}
450+
389451
static unsigned int siwx91x_on_join(sl_wifi_event_t event,
390452
char *result, uint32_t result_size, void *arg)
391453
{
@@ -1575,6 +1637,7 @@ static const struct wifi_mgmt_ops siwx91x_mgmt = {
15751637
#endif
15761638
.get_version = siwx91x_get_version,
15771639
.set_power_save = siwx91x_set_power_save,
1640+
.get_power_save_config = siwx91x_get_power_save_config,
15781641
};
15791642

15801643
static const struct net_wifi_mgmt_offload siwx91x_api = {

0 commit comments

Comments
 (0)