hostap: Add build support for Zephyr
Only adds basic build support using Zephyr. Crypto support is disabled
till the MbedTLS integration is complete.
Signed-off-by: Sridhar Nuvusetty <sridhar.nuvusetty@nordicsemi.no>
Signed-off-by: Sachin Kulkarni <sachin.kulkarni@nordicsemi.no>
Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
diff --git a/modules/hostap/CMakeLists.txt b/modules/hostap/CMakeLists.txt
new file mode 100644
index 0000000..ed6b818
--- /dev/null
+++ b/modules/hostap/CMakeLists.txt
@@ -0,0 +1,84 @@
+#
+# Copyright (c) 2023 Nordic Semiconductor ASA
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+if(CONFIG_WIFI_NM_WPA_SUPPLICANT)
+
+zephyr_library()
+
+set(HOSTAP_BASE ${ZEPHYR_HOSTAP_MODULE_DIR})
+set(WIFI_NM_WPA_SUPPLICANT_BASE ${HOSTAP_BASE}/wpa_supplicant)
+set(HOSTAP_SRC_BASE ${HOSTAP_BASE}/src)
+
+set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs -lnosys")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMISSING_SYSCALL_NAMES")
+
+zephyr_compile_definitions(
+ CONFIG_ZEPHYR
+)
+
+zephyr_include_directories(
+ ${HOSTAP_BASE}/
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/
+ ${HOSTAP_SRC_BASE}/
+)
+
+zephyr_library_compile_definitions(
+ TLS_DEFAULT_CIPHERS=\""DEFAULT:!EXP:!LOW"\"
+ CONFIG_SME
+ CONFIG_NO_CONFIG_WRITE
+ CONFIG_NO_CONFIG_BLOBS
+ CONFIG_CTRL_IFACE
+ CONFIG_NO_RANDOM_POOL
+ CONFIG_NO_WPA
+ CONFIG_NO_PBKDF2
+ )
+
+zephyr_library_include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ ${HOSTAP_BASE}/
+ ${HOSTAP_SRC_BASE}/utils
+ ${HOSTAP_SRC_BASE}/drivers
+ ${HOSTAP_BASE}/src
+ ${ZEPHYR_BASE}/include
+ ${ZEPHYR_BASE}/include/net
+)
+
+zephyr_library_sources(
+ ${HOSTAP_SRC_BASE}/common/wpa_common.c
+ ${HOSTAP_SRC_BASE}/common/ieee802_11_common.c
+ ${HOSTAP_SRC_BASE}/common/hw_features_common.c
+ ${HOSTAP_SRC_BASE}/common/wpa_ctrl.c
+ ${HOSTAP_SRC_BASE}/common/cli.c
+
+ ${HOSTAP_SRC_BASE}/drivers/driver_common.c
+ ${HOSTAP_SRC_BASE}/drivers/drivers.c
+ ${HOSTAP_SRC_BASE}/utils/base64.c
+ ${HOSTAP_SRC_BASE}/utils/common.c
+ ${HOSTAP_SRC_BASE}/utils/wpabuf.c
+ ${HOSTAP_SRC_BASE}/utils/bitfield.c
+ ${HOSTAP_SRC_BASE}/utils/eloop.c
+ ${HOSTAP_SRC_BASE}/utils/os_zephyr.c
+ ${HOSTAP_SRC_BASE}/utils/wpa_debug_zephyr.c
+ ${HOSTAP_SRC_BASE}/crypto/crypto_none.c
+ ${HOSTAP_SRC_BASE}/crypto/tls_none.c
+
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/config.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/notify.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/eap_register.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/op_classes.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/rrm.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/wmm_ac.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/config_none.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/bssid_ignore.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/wpas_glue.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/scan.c
+ ${WIFI_NM_WPA_SUPPLICANT_BASE}/ctrl_iface.c
+
+ # Zephyr specific files (glue code)
+ # TBD
+)
+
+endif()
diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig
new file mode 100644
index 0000000..ae340be
--- /dev/null
+++ b/modules/hostap/Kconfig
@@ -0,0 +1,104 @@
+# WPA Supplicant configuration options
+#
+# Copyright (c) 2023 Nordic Semiconductor
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+config WIFI_NM_WPA_SUPPLICANT
+ bool "WPA Suplicant from hostap project [EXPERIMENTAL]"
+ select POSIX_CLOCK
+ select NET_SOCKETS
+ select NET_SOCKETS_PACKET
+ select NET_SOCKETPAIR
+ select NET_L2_WIFI_MGMT
+ select WIFI_NM
+ select EXPERIMENTAL
+ help
+ WPA supplicant as a network management backend for WIFI_NM.
+
+config WIFI_NM_WPA_SUPPLICANT_THREAD_STACK_SIZE
+ int "Stack size for wpa_supplicant thread"
+ default 8192
+
+config NET_SOCKETPAIR_BUFFER_SIZE
+ default 4096
+
+config POSIX_MAX_FDS
+ # l2_packet - 1
+ # ctrl_iface - 2 * socketpairs = 4(local and global)
+ # z_wpa_event_sock - 1 socketpair = 2
+ # Remaining left for the applications running in default configuration
+ default 16 if !POSIX_API
+
+# Control interface is stack heavy (buffers + snprintfs)
+# Making calls to RPU from net_mgmt callbacks (status - RSSI)
+config NET_MGMT_EVENT_STACK_SIZE
+ default 4096
+
+config NET_SOCKETS_POLL_MAX
+ default 6
+
+
+# Supplicant API is stack heavy (buffers + snprintfs) and control interface
+# uses socketpair which pushes the stack usage causing overflow for 2048 bytes.
+config SYSTEM_WORKQUEUE_STACK_SIZE
+ default 2560
+
+module = WIFI_NM_WPA_SUPPLICANT
+module-str = WPA supplicant
+source "subsys/logging/Kconfig.template.log_config"
+
+config WIFI_NM_WPA_SUPPLICANT_DEBUG_LEVEL
+ int "Min compiled-in debug message level for WPA supplicant"
+ default 0 if WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_DBG # MSG_EXCESSIVE
+ default 3 if WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_INF # MSG_INFO
+ default 4 if WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_WRN # MSG_WARNING
+ default 5 if WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_ERR # MSG_ERROR
+ default 6
+ help
+ Minimum priority level of a debug message emitted by WPA supplicant that
+ is compiled-in the firmware. See wpa_debug.h file of the supplicant for
+ available levels and functions for emitting the messages. Note that
+ runtime filtering can also be configured in addition to the compile-time
+ filtering.
+
+if WIFI_NM_WPA_SUPPLICANT
+
+# Create hidden config options that are used in hostap. This way we do not need
+# to mark them as allowed for CI checks, and also someone else cannot use the
+# same name options.
+
+config SME
+ bool
+ default y
+
+config NO_CONFIG_WRITE
+ bool
+ default y
+
+config NO_CONFIG_BLOBS
+ bool
+ default y
+
+config CTRL_IFACE
+ bool
+ default y
+
+config NO_RANDOM_POOL
+ bool
+ default y
+
+config NO_WPA
+ bool
+ default y
+
+config NO_PBKDF2
+ bool
+ default y
+
+config ZEPHYR
+ bool
+ default y
+
+endif # WIFI_NM_WPA_SUPPLICANT