Skip to content
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

Add Access Point (AP) mode support to siwx91x wifi driver #85906

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ArunmaniAlagarsamy2710
Copy link
Contributor

  • Implemented support for Wi-Fi Access Point (AP) mode.
  • Added support for AP-related Wi-Fi commands.
    Basic functionalities are included; further enhancements will be added in future PR.

return SL_WIFI_BANDWIDTH_80MHz;
default:
LOG_ERR("Invalid bandwidth");
return -EAGAIN;
Copy link
Contributor

@jerome-pouiller jerome-pouiller Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably -EINVAL is better suited.

I am not sure LOG_ERR() is useful (in fact, I don't know what policy we should have for the the logs).

@@ -14,6 +14,8 @@
#include "sl_si91x_types.h"
#include "sl_si91x_protocol_types.h"

#define SIWX91X_INTERFACE_MASK (0x03)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, SIWX91X_INTERFACE_MASK is only used in siwx91x_wifi.c. I am not sure it make sense to expose it in the header file.

status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &sidev->macaddr);
interface = sl_wifi_get_default_interface();
status = sl_wifi_get_mac_address(FIELD_GET(SIWX91X_INTERFACE_MASK, interface),
&sidev->macaddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what case the original code didn't work?

}
}

ret = sl_wifi_start_ap(SL_WIFI_AP_2_4GHZ_INTERFACE, &configuration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reader, it difficult to understand SL_WIFI_AP_2_4GHZ_INTERFACE == SL_WIFI_AP_INTERFACE | SL_WIFI_2_4GHZ_INTERFACE. I suggest either:

  • Replace references to SL_WIFI_AP_INTERFACE by FIELD_GET(SIWX91X_INTERFACE_MASK, SL_WIFI_AP_2_4GHZ_INTERFACE)
  • Replace reference to SL_WIFI_AP_2_4GHZ_INTERFACE by SL_WIFI_AP_INTERFACE | SL_WIFI_2_4GHZ_INTERFACE


if (params->security != WIFI_SECURITY_TYPE_NONE) {
ret = sl_net_set_credential(configuration.credential_id, SL_NET_WIFI_PSK,
params->psk, params->psk_length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_wifi_ap_credential.type == SL_NET_WIFI_PSK and credentials seems ignored when configuration.security == SL_WIFI_OPEN. So I think you can call this function unconditionally.

}

sl_si91x_set_join_configuration(SL_WIFI_AP_INTERFACE,
SL_SI91X_JOIN_FEAT_MFP_CAPABLE_REQUIRED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MFP is orthogonal to the authentication scheme. Probably this configuration should done outside of this switch case.

BTW, WPA2-PSK w/o MFP seems legit. Is it a limitation of Wiseconnect?

I also assume configuration.security = SL_WIFI_WPA3 automatically enables MFP? If ye, we could check params->mfp == WIFI_MFP_REQUIRED.

#include "sl_wifi.h"
#include "sl_net.h"

#define SIWX91X_INTERFACE_MASK (0x03)

LOG_MODULE_REGISTER(siwx91x_wifi);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep LOG_MODULE_REGISTER() just after the includes list.

strncpy(status->ssid, wlan_info.ssid, WIFI_SSID_MAX_LEN);
status->ssid_len = strlen(status->ssid);
memcpy(status->bssid, wlan_info.mac_address, WIFI_MAC_ADDR_LEN);
status->mfp = WIFI_MFP_REQUIRED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you be sure?

memcpy(status->bssid, wlan_info.mac_address, WIFI_MAC_ADDR_LEN);
status->mfp = WIFI_MFP_REQUIRED;

if (FIELD_GET(SL_WIFI_2_4GHZ_INTERFACE, interface)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SL_WIFI_2_4GHZ_INTERFACE is not a mask. I would either write:

  • FIELD_GET(SIWX91X_BAND_MASK, interface) == 1
  • interface & SL_WIFI_2_4GHZ_INTERFACE

status->band = WIFI_FREQ_BAND_2_4_GHZ;
}

if (FIELD_GET(SL_WIFI_CLIENT_INTERFACE, interface)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SL_WIFI_CLIENT_INTERFACE is not a mask. I suggest FIELD_GET(SIWX91X_INTERFACE_MASK, interface) == SL_WIFI_CLIENT_INTERFACE.


sl_wifi_get_listen_interval(SL_WIFI_CLIENT_INTERFACE, &listen_interval);
status->beacon_interval = listen_interval.listen_interval;
} else if (FIELD_GET(SL_WIFI_AP_INTERFACE, interface)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this condition be true? oper_mode is always SL_SI91X_CLIENT_MODE. So, I think interface never set SL_WIFI_AP_INTERFACE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have added the support to change oper_mode at runtime #85919

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe #85919 should be a part of this current PR.

sl_wifi_get_listen_interval(SL_WIFI_CLIENT_INTERFACE, &listen_interval);
status->beacon_interval = listen_interval.listen_interval;
} else if (FIELD_GET(SL_WIFI_AP_INTERFACE, interface)) {
sl_wifi_ap_configuration_t conf = { };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap_cfg or sl_ap_cfg or siwx91x_ap_cfg.

This commit introduces Access Point (AP) mode support
It enables the following AP-related commands:
- ap enable: Enable the AP mode.
- ap disable: Disable the AP mode.

Signed-off-by: Arunmani Alagarsamy <[email protected]>
This commit adds support the following wifi commands:
- wifi ap disconnect: Disconnect a specific station from the AP.
- wifi ap stations: List connected devices.

Signed-off-by: Arunmani Alagarsamy <[email protected]>
This commit adds support for Wi-Fi status and statistics
functionalities:
- wifi status	  : Displays the current mode status.
- wifi statistics : Provides details on the transmitted and
                    received packet counts.

Signed-off-by: Arunmani Alagarsamy <[email protected]>
This commit enables the device to change its operating mode
at runtime by using the wifi command.

Signed-off-by: Arunmani Alagarsamy <[email protected]>
Copy link
Contributor

@jerome-pouiller jerome-pouiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3 first commits depend on drivers: wifi: siwx91x: Add run time opermode, so you have place it first.

SL_SI91X_TCP_IP_FEAT_BYPASS),
.custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID,
.feature_bit_map = SL_SI91X_FEAT_SECURITY_OPEN,
.coex_mode = SL_SI91X_WLAN_ONLY_MODE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you deal with BLE?

I feel this function is in fact shared with Bluetooth and event with Flash driver. Probably it should be located in soc/silabs/silabs_siwx91x/siwg917/nwp_init.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants