Skip to content

Commit

Permalink
Merge branch 'SiliconLabsSoftware:main' into driver/access_point
Browse files Browse the repository at this point in the history
  • Loading branch information
ArunmaniAlagarsamy2710 authored Feb 7, 2025
2 parents ef3b648 + d61c3f3 commit d885219
Show file tree
Hide file tree
Showing 26 changed files with 1,088 additions and 34 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ jobs:
-x DTC_OVERLAY_FILE=$(pwd)/tests/drivers/dma/chan_blen_transfer/boards/siwx917_rb4338a.overlay \
-x EXTRA_CONF_FILE=$(pwd)/tests/drivers/dma/chan_blen_transfer/boards/siwx917_rb4338a.conf
- name: Build Crypto tests
working-directory: zephyr-silabs
shell: bash
run: |
west twister -v --inline-logs \
-p xg24_rb4187c \
-p xg27_dk2602a \
-p xg29_rb4412a \
-T tests/crypto/
- name: Build Bluetooth samples
working-directory: zephyr-silabs
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion drivers/clock_control/clock_control_silabs_siwx917.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static int siwx917_clock_on(const struct device *dev, clock_control_subsys_t sys
case SIWX917_CLK_ULP_UART:
RSI_PS_UlpssPeriPowerUp(ULPSS_PWRGATE_ULP_UART);
RSI_ULPSS_UlpUartClkConfig(ULPCLK, ENABLE_STATIC_CLK,
false, ULP_UART_ULP_32MHZ_RC_CLK, 1);
false, ULP_UART_ULP_MHZ_RC_CLK, 1);
break;
case SIWX917_CLK_ULP_I2C:
RSI_PS_UlpssPeriPowerUp(ULPSS_PWRGATE_ULP_I2C);
Expand Down
5 changes: 5 additions & 0 deletions drivers/wifi/siwx917/Kconfig.siwx917
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ config NET_MGMT_EVENT_STACK_SIZE
config NET_MGMT_EVENT_QUEUE_SIZE
default 10

# 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
default 1

endif
70 changes: 63 additions & 7 deletions drivers/wifi/siwx917/siwx917_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,41 +183,66 @@ static void siwx917_report_scan_res(struct siwx917_dev *sidev, sl_wifi_scan_resu
{ SL_WIFI_WPA_ENTERPRISE, WIFI_SECURITY_TYPE_EAP },
{ SL_WIFI_WPA2_ENTERPRISE, WIFI_SECURITY_TYPE_EAP },
};

struct wifi_scan_result tmp = {
.channel = result->scan_info[item].rf_channel,
.rssi = result->scan_info[item].rssi_val,
.ssid_length = strlen(result->scan_info[item].ssid),
.mac_length = sizeof(result->scan_info[item].bssid),
.security = WIFI_SECURITY_TYPE_UNKNOWN,
.mfp = WIFI_MFP_UNKNOWN,
/* FIXME: fill .mfp, .band and .channel */
.band = WIFI_FREQ_BAND_2_4_GHZ,
};
int i;

if (result->scan_count == 0) {
return;
}

if (result->scan_info[item].rf_channel <= 0 || result->scan_info[item].rf_channel > 14) {
LOG_WRN("Unexpected scan result");
tmp.band = WIFI_FREQ_BAND_UNKNOWN;
}

memcpy(tmp.ssid, result->scan_info[item].ssid, tmp.ssid_length);
memcpy(tmp.mac, result->scan_info[item].bssid, tmp.mac_length);

for (i = 0; i < ARRAY_SIZE(security_convert); i++) {
if (security_convert[i].sl_val == result->scan_info[item].security_mode) {
tmp.security = security_convert[i].z_val;
}
}

sidev->scan_res_cb(sidev->iface, 0, &tmp);
}

static unsigned int siwx917_on_scan(sl_wifi_event_t event, sl_wifi_scan_result_t *result,
uint32_t result_size, void *arg)
{
struct siwx917_dev *sidev = arg;
int i;
int i, scan_count;

if (!sidev->scan_res_cb) {
return -EFAULT;
}
for (i = 0; i < result->scan_count; i++) {

if (event & SL_WIFI_EVENT_FAIL_INDICATION) {
memset(result, 0, sizeof(*result));
}

if (sidev->scan_max_bss_cnt) {
scan_count = MIN(result->scan_count, sidev->scan_max_bss_cnt);
} else {
scan_count = result->scan_count;
}

for (i = 0; i < scan_count; i++) {
siwx917_report_scan_res(sidev, result, i);
}

sidev->scan_res_cb(sidev->iface, 0, NULL);
sidev->state = WIFI_STATE_INACTIVE;

return 0;
}

Expand All @@ -226,6 +251,7 @@ static int siwx917_scan(const struct device *dev, struct wifi_scan_params *z_sca
{
sl_wifi_scan_configuration_t sl_scan_config = { };
struct siwx917_dev *sidev = dev->data;
sl_wifi_ssid_t ssid = {};
int ret;

__ASSERT(z_scan_config, "z_scan_config cannot be NULL");
Expand All @@ -234,14 +260,44 @@ static int siwx917_scan(const struct device *dev, struct wifi_scan_params *z_sca
return -EBUSY;
}

/* The enum values are same, no conversion needed */
sl_scan_config.type = z_scan_config->scan_type;
if (z_scan_config->scan_type == WIFI_SCAN_TYPE_ACTIVE) {
sl_scan_config.type = SL_WIFI_SCAN_TYPE_ACTIVE;
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);
}

if (ret) {
return -EINVAL;
}
} 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 < WIFI_MGMT_SCAN_CHAN_MAX_MANUAL; i++) {
sl_scan_config.channel_bitmap_2g4 |= BIT(z_scan_config->band_chan[i].channel - 1);
}

sl_scan_config.channel_bitmap_2g4 = 0xFFFF;
memset(sl_scan_config.channel_bitmap_5g, 0xFF, sizeof(sl_scan_config.channel_bitmap_5g));
if (IS_ENABLED(CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX)) {
if (z_scan_config->ssids[0]) {
strncpy(ssid.value, z_scan_config->ssids[0], WIFI_SSID_MAX_LEN);
ssid.length = strlen(z_scan_config->ssids[0]);
}
}

sidev->scan_max_bss_cnt = z_scan_config->max_bss_cnt;
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);
if (ret != SL_STATUS_IN_PROGRESS) {
return ERROR_CODE_CHECK(ret);
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/wifi/siwx917/siwx917_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct siwx917_dev {
sl_wifi_interface_t interface;
enum wifi_iface_state state;
scan_result_cb_t scan_res_cb;
uint16_t scan_max_bss_cnt;

#ifdef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
struct k_event fds_recv_event;
Expand All @@ -41,7 +42,7 @@ struct siwx917_dev {
net_context_recv_cb_t cb;
void *user_data;
struct net_context *context;
} fds_cb[NUMBER_OF_BSD_SOCKETS];
} fds_cb[NUMBER_OF_SOCKETS];
#endif
};

Expand Down
16 changes: 8 additions & 8 deletions drivers/wifi/siwx917/siwx917_wifi_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

LOG_MODULE_DECLARE(siwx917_wifi);

BUILD_ASSERT(NUMBER_OF_BSD_SOCKETS < sizeof(uint32_t) * 8);
BUILD_ASSERT(NUMBER_OF_BSD_SOCKETS < SIZEOF_FIELD(sl_si91x_fd_set, __fds_bits) * 8);
BUILD_ASSERT(NUMBER_OF_SOCKETS < sizeof(uint32_t) * 8);
BUILD_ASSERT(NUMBER_OF_SOCKETS < SIZEOF_FIELD(sl_si91x_fd_set, __fds_bits) * 8);

NET_BUF_POOL_FIXED_DEFINE(siwx917_tx_pool, 1, NET_ETH_MTU, 0, NULL);
NET_BUF_POOL_FIXED_DEFINE(siwx917_rx_pool, 10, NET_ETH_MTU, 0, NULL);
Expand Down Expand Up @@ -163,7 +163,7 @@ static void siwx917_sock_on_recv(sl_si91x_fd_set *read_fd, sl_si91x_fd_set *writ
}
}

sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
}

Expand All @@ -190,7 +190,7 @@ static int siwx917_sock_put(struct net_context *context)

SL_SI91X_FD_CLR(sockfd, &sidev->fds_watch);
memset(&sidev->fds_cb[sockfd], 0, sizeof(sidev->fds_cb[sockfd]));
sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
ret = sl_si91x_shutdown(sockfd, 0);
if (ret < 0) {
Expand Down Expand Up @@ -222,7 +222,7 @@ static int siwx917_sock_bind(struct net_context *context,
/* WiseConnect refuses to run select on TCP listening sockets */
if (net_context_get_proto(context) == IPPROTO_UDP) {
SL_SI91X_FD_SET(sockfd, &sidev->fds_watch);
sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
}
return 0;
Expand All @@ -244,7 +244,7 @@ static int siwx917_sock_connect(struct net_context *context,
ret = -errno;
}
SL_SI91X_FD_SET(sockfd, &sidev->fds_watch);
sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
net_context_set_state(context, NET_CONTEXT_CONNECTED);
if (cb) {
Expand Down Expand Up @@ -302,7 +302,7 @@ static int siwx917_sock_accept(struct net_context *context,
siwx917_sockaddr_swap_bytes(&newcontext->remote, &addr_le, sizeof(addr_le));

SL_SI91X_FD_SET(ret, &sidev->fds_watch);
sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
if (cb) {
cb(newcontext, &addr_le, sizeof(addr_le), 0, user_data);
Expand Down Expand Up @@ -389,7 +389,7 @@ static int siwx917_sock_recv(struct net_context *context,
SL_SI91X_FD_SET(sockfd, &sidev->fds_watch);
}

sl_si91x_select(NUMBER_OF_BSD_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
sl_si91x_select(NUMBER_OF_SOCKETS, &sidev->fds_watch, NULL, NULL, NULL,
siwx917_sock_on_recv);
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions modules/hal_silabs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2024 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory_ifdef(CONFIG_SOC_FAMILY_SILABS_S2 simplicity_sdk)
add_subdirectory_ifdef(CONFIG_HAS_SILABS_WISECONNECT wiseconnect)
76 changes: 76 additions & 0 deletions modules/hal_silabs/simplicity_sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

set(SECURITY_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/security)

# Get SoC series number, i.e. translate e.g. efr32bg22 -> 22
string(SUBSTRING ${CONFIG_SOC_SERIES} 7 2 SILABS_DEVICE_FAMILY_NUMBER)

zephyr_include_directories(
inc
)

zephyr_compile_definitions_ifdef(CONFIG_SOC_GECKO_SE
SL_SE_MANAGER_THREADING
)

set(vse_device_families 22 27)
if(NOT (SILABS_DEVICE_FAMILY_NUMBER IN_LIST vse_device_families))
zephyr_compile_definitions_ifdef(CONFIG_SOC_GECKO_SE
SL_SE_MANAGER_YIELD_WHILE_WAITING_FOR_COMMAND_COMPLETION
)
endif()

# PSA Crypto
if(CONFIG_PSA_CRYPTO_DRIVER_SILABS_HSE OR CONFIG_PSA_CRYPTO_DRIVER_SILABS_VSE)

zephyr_library_named(hal_silabs_crypto)

zephyr_include_directories(
${SECURITY_DIR}/sl_component/sl_psa_driver/inc
${SECURITY_DIR}/sl_component/sl_mbedtls_support/config
${SECURITY_DIR}/sl_component/sl_mbedtls_support/inc
)
zephyr_compile_definitions(
MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE="sl_psa_crypto_config_zephyr.h"
)
zephyr_library_sources(
# ${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_psa_driver_common.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_psa_driver_ghash.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_psa_driver_init.c
# ${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_psa_trng.c
)
zephyr_library_link_libraries(mbedTLSBase)

# HSE
zephyr_library_sources_ifdef(CONFIG_PSA_CRYPTO_DRIVER_SILABS_HSE
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_cipher.c
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_hash.c
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_key_derivation.c
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_key_handling.c
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_signature.c
${SECURITY_DIR}/sl_component/se_manager/src/sl_se_manager_attestation.c

${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_aead.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_builtin_keys.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_cipher.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_key_derivation.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_key_management.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_mac.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_driver_signature.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_opaque_driver_aead.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_opaque_driver_cipher.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_opaque_driver_mac.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_opaque_key_derivation.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_transparent_driver_aead.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_transparent_driver_cipher.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_transparent_driver_hash.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_transparent_driver_mac.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_transparent_key_derivation.c
${SECURITY_DIR}/sl_component/sl_psa_driver/src/sli_se_version_dependencies.c
)

# VSE
# TODO

endif() # PSA Crypto
19 changes: 19 additions & 0 deletions modules/hal_silabs/simplicity_sdk/inc/sl_mbedtls_config_zephyr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2025 Silicon Laboratories Inc.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef SL_MBEDTLS_CONFIG_ZEPHYR_H
#define SL_MBEDTLS_CONFIG_ZEPHYR_H

#include "sli_mbedtls_omnipresent.h"

/* Legacy mbed TLS ALT APIs are not accelerated in Zephyr
* #include "sli_mbedtls_acceleration.h"
*/

/* From sl_mbedtls_device_config.h */
#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0
#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1
#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2025 Silicon Laboratories Inc.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef SL_PSA_CRYPTO_CONFIG_ZEPHYR_H
#define SL_PSA_CRYPTO_CONFIG_ZEPHYR_H

#if defined(CONFIG_PSA_CRYPTO_DRIVER_SILABS_HSE)
#define PSA_CRYPTO_DRIVER_SILABS_HSE
#endif

#if defined(CONFIG_PSA_CRYPTO_DRIVER_SILABS_VSE)
#define PSA_CRYPTO_DRIVER_SILABS_VSE
#endif

/* Should be exposed as Kconfig in the future */
#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR)
#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128)
#define SL_VSE_BUFFER_TRNG_DATA_DURING_SLEEP (0)
#define SL_VSE_MAX_TRNG_WORDS_BUFFERED_DURING_SLEEP (63)

#include "sli_psa_acceleration.h"

#endif
Loading

0 comments on commit d885219

Please sign in to comment.