-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: wifi: siwx917: Add support for advanced scan options #86
drivers: wifi: siwx917: Add support for advanced scan options #86
Conversation
@jhedberg @jerome-pouiller Please help to review. |
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
LOG_INF("No APs detected"); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not declare variables after statements.
BTW, I don't think we need to log anything if scan_count == 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, calling this function with index >= scan_count
is a bug.
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
.band = (result->scan_info[item].rf_channel > 0 && | ||
result->scan_info[item].rf_channel <= 14) ? | ||
WIFI_FREQ_BAND_2_4_GHZ | ||
: WIFI_FREQ_BAND_UNKNOWN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't abuse of the trinary operator. I suggest:
.band = WIFI_FREQ_BAND_2_4_GHZ,
[...]
if (result->scan_info[item].rf_channel <= 0 || result->scan_info[item].rf_channel > 14)) {
LOG_WARN("Unexpected scan result");
tmp.band = WIFI_FREQ_BAND_UNKNOWN;
}
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
|
||
if (sidev->max_bss_cnt) { | ||
result->scan_count = (sidev->max_bss_cnt > result->scan_count) ? | ||
result->scan_count : sidev->max_bss_cnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIN(result->scan_count, sidev->max_bss_cnt);
BTW, I suggest to avoid change the input argument. Rather use a local variable to store this value.
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
@@ -185,6 +194,17 @@ static unsigned int siwx917_on_scan(sl_wifi_event_t event, sl_wifi_scan_result_t | |||
if (!sidev->scan_res_cb) { | |||
return -EFAULT; | |||
} | |||
|
|||
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SL_WIFI_CHECK_IF_EVENT_FAILED()
looks useless. event & SL_WIFI_EVENT_FAIL_INDICATION
is simpler and clearer for anyone.
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
|
||
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) { | ||
memset(result, 0, sizeof(*result)); | ||
siwx917_report_scan_res(sidev, result, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is purpose of this call?
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
#ifdef CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL | ||
for (int i = 0; i < WIFI_MGMT_SCAN_CHAN_MAX_MANUAL; i++) { | ||
sl_scan_config.channel_bitmap_2g4 |= (1 << | ||
(z_scan_config->band_chan[i].channel - 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use BIT()
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
strncpy(ssid.value, z_scan_config->ssids[0], WIFI_SSID_MAX_LEN); | ||
ssid.length = strlen(z_scan_config->ssids[0]); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather use IF_ENABLED()
when possible.
drivers/wifi/siwx917/siwx917_wifi.h
Outdated
@@ -17,6 +17,7 @@ | |||
struct siwx917_dev { | |||
struct net_if *iface; | |||
sl_mac_address_t macaddr; | |||
uint16_t max_bss_cnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this variable does not allow to understand what it does. Rename to scan_max_bss_cnt
and place it beside scan_res_cb
.
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
if (ret != SL_STATUS_IN_PROGRESS) { | ||
LOG_ERR("Failed to start scan: %d", ret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error will appear in the user interface even if the case is properly handled by the upper layers. I suggest tot drop it.
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
sidev->scan_res_cb = cb; | ||
ret = sl_wifi_start_scan(SL_WIFI_CLIENT_INTERFACE, NULL, &sl_scan_config); | ||
ret = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, | ||
(ssid.length > 0) ? &ssid : NULL, &sl_scan_config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align with opening parenthese.
It would have been easier to review if the features would been introduced in separated commits. |
ee819b1
to
0b2f3b3
Compare
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
@@ -211,9 +212,16 @@ static int siwx917_scan(const struct device *dev, struct wifi_scan_params *z_sca | |||
|
|||
sl_scan_config.channel_bitmap_2g4 = 0xFFFF; | |||
memset(sl_scan_config.channel_bitmap_5g, 0xFF, sizeof(sl_scan_config.channel_bitmap_5g)); | |||
IF_ENABLED(CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX, ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I meant IS_ENABLED()
:
if (IS_ENABLED(CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX)) {
[....]
} else { | ||
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT, | ||
SL_WIFI_DEFAULT_ACTIVE_CHANNEL_SCAN_TIME); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... It seems the condition is useless. You can unconditionally run:
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT,
z_scan_config>dwell_time_active);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have realized you probably wanted to write:
if (!z_scan_config>dwell_time_active) {
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT,
SL_WIFI_DEFAULT_ACTIVE_CHANNEL_SCAN_TIME);
} else {
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT,
z_scan_config>dwell_time_active);
}
drivers/wifi/siwx917/siwx917_wifi.c
Outdated
} else { | ||
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_PASSIVE_SCAN_TIMEOUT, | ||
SL_WIFI_DEFAULT_PASSIVE_CHANNEL_SCAN_TIME); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
This commit introduces support for direct SSID scans The feature allows the device to send the probe requests and listen the beacon frame on the specified SSID. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
This commit introduces support for limiting the number of BSS scan results returned by the siwx917 Wi-Fi driver. If scan_max_bss_cnt is specified, the driver will return up to the specified count of BSS results. If not specified, the driver defaults to returning all available results. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
This commit introduces support for single and multi-channel Wi-Fi scans. The device can now scan one specific channel or multiple specified channels. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
0b2f3b3
to
90b614b
Compare
@jerome-pouiller Changes have been made, please revisit |
This commit adds support for configuring dwell times for both active and passive Wi-Fi scans. The dwell time specifies the duration the device spends on each channel during a scan. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
90b614b
to
fcf438d
Compare
@jerome-pouiller @jhedberg Gentle ping! |
This commit adds support for the following scan functionalities
Since the device operates solely on the 2.4 GHz frequency band, this enhancement enables it to send probe requests and listen for beacon frames on specified channels, improving scan efficiency and customization.