Commit 4c5dd738 authored by Nitin Pandey's avatar Nitin Pandey Committed by Benjamin Cabé
Browse files

driver: wifi: siwx91x: Add support for BG Scan

- Added support for background scan
  and configured the default values
  of BG scan configuration

Signed-off-by: default avatarNitin Pandey <nitin.pandey@silabs.com>
parent 8cec9f7c
Loading
Loading
Loading
Loading
+64 −0
Changes for drivers/wifi/siwx91x/Kconfig.siwx91x: 64 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,70 @@ config NET_MGMT_EVENT_STACK_SIZE
config NET_MGMT_EVENT_QUEUE_SIZE
	default 10


config WIFI_SILABS_SIWX91X_ADV_SCAN_THRESHOLD
	int "Advanced scan threshold (in dBm)"
	default -40
	help
	  Configure the default advanced scan threshold for WiFi scanning.
	  This value determines the signal strength (in dBm) below which
	  the advanced scan mechanism will be triggered. Adjust this value
	  to optimize scanning behavior based on your network environment.

config WIFI_SILABS_SIWX91X_ADV_RSSI_TOLERANCE_THRESHOLD
	int "Advanced RSSI tolerance threshold (in dBm)"
	default 5
	help
	  Configure the default RSSI tolerance threshold for advanced WiFi scanning.
	  This value determines the acceptable variation in signal strength (in dBm)
	  during advanced scanning. Adjust this value to fine-tune the sensitivity
	  of the scanning mechanism to signal fluctuations.

config WIFI_SILABS_SIWX91X_ADV_ACTIVE_SCAN_DURATION
	int "Advanced active scan duration (in ms)"
	default 15
	help
	  Configure the default advanced active scan duration for WiFi scanning.
	  This value determines the time (in milliseconds) spent on each
	  channel during an advanced active scan. Adjust this value to optimize
	  scanning speed and accuracy based on your network environment.

config WIFI_SILABS_SIWX91X_ADV_PASSIVE_SCAN_DURATION
	int "Advanced passive scan duration (in ms)"
	default 20
	help
	  Configure the default advanced passive scan duration for WiFi scanning.
	  This value determines the time (in milliseconds) spent on each
	  channel during an advanced passive scan. Adjust this value to optimize
	  scanning speed and accuracy based on your network environment.

config WIFI_SILABS_SIWX91X_ADV_MULTIPROBE
	int "Advanced multiprobe setting"
	default 0
	help
	  Configure the advanced multiprobe setting for WiFi scanning.
	  When set to 1, multiple probe requests will be sent to all access
	  points in addition to the connected SSID during scanning. Adjust
	  this value to fine-tune scanning behavior based on your network
	  requirements.

config WIFI_SILABS_SIWX91X_ADV_SCAN_PERIODICITY
	int "Advanced scan periodicity (in ms)"
	default 10
	help
	  Configure the default advanced scan periodicity for WiFi scanning.
	  This value determines the interval (in milliseconds) between consecutive
	  advanced scans. Adjust this value to balance scanning frequency
	  and power consumption based on your network environment.

config WIFI_SILABS_SIWX91X_ENABLE_INSTANT_SCAN
	int "Instant scan support"
	default 1
	help
	  Enable support to start an advanced scan immediately. When enabled, the device
	  can perform an advanced scan without waiting for the periodic
	  scan interval, enabling quicker detection of available networks.

# Override the WIFI_MGMT_SCAN_SSID_FILT_MAX parameter for the Wi-Fi subsystem.
# This device supports filtering scan results for only one SSID.
config WIFI_MGMT_SCAN_SSID_FILT_MAX
+17 −6
Changes for drivers/wifi/siwx91x/siwx91x_wifi.c: 17 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -479,6 +479,12 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
			scan_result_cb_t cb)
{
	sl_wifi_scan_configuration_t sl_scan_config = { };
	sl_wifi_advanced_scan_configuration_t advanced_scan_config = {
		.trigger_level = CONFIG_WIFI_SILABS_SIWX91X_ADV_SCAN_THRESHOLD,
		.trigger_level_change = CONFIG_WIFI_SILABS_SIWX91X_ADV_RSSI_TOLERANCE_THRESHOLD,
		.enable_multi_probe = CONFIG_WIFI_SILABS_SIWX91X_ADV_MULTIPROBE,
		.enable_instant_scan = CONFIG_WIFI_SILABS_SIWX91X_ENABLE_INSTANT_SCAN,
	};
	struct siwx91x_dev *sidev = dev->data;
	sl_wifi_interface_t interface;
	sl_wifi_ssid_t ssid = { };
@@ -503,17 +509,22 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
		return -EINVAL;
	}

	if (sidev->state == WIFI_STATE_COMPLETED) {
		ret = sl_wifi_set_advanced_scan_configuration(&advanced_scan_config);
		if (ret != SL_STATUS_OK) {
			LOG_ERR("advanced scan configuration failed with status %x", ret);
			return -EINVAL;
		}

		sl_scan_config.type = SL_WIFI_SCAN_TYPE_ADV_SCAN;
		sl_scan_config.periodic_scan_interval =
			CONFIG_WIFI_SILABS_SIWX91X_ADV_SCAN_PERIODICITY;
	} else {
		if (z_scan_config->scan_type == WIFI_SCAN_TYPE_ACTIVE) {
			sl_scan_config.type = SL_WIFI_SCAN_TYPE_ACTIVE;
		ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT,
						 z_scan_config->dwell_time_active);
		} else {
			sl_scan_config.type = SL_WIFI_SCAN_TYPE_PASSIVE;
		ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_PASSIVE_SCAN_TIMEOUT,
						 z_scan_config->dwell_time_passive);
		}
	if (ret) {
		return -EINVAL;
	}

	for (int i = 0; i < ARRAY_SIZE(z_scan_config->band_chan); i++) {