From 64e13e8f2e67b504cfa44e9777825365a2625997 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sun, 29 Jun 2025 19:59:44 +1000 Subject: [PATCH 1/2] conn_mgr: make internal state static Make the interface interface state array static, ensuring that the array is zeroed at boot. This enables interfaces which initialise earlier than the CONN_MGR module to set flags in their init functions. Signed-off-by: Jordan Yates --- subsys/net/conn_mgr/conn_mgr_monitor.c | 13 ++++++------- subsys/net/conn_mgr/conn_mgr_private.h | 3 +++ subsys/net/conn_mgr/events_handler.c | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/subsys/net/conn_mgr/conn_mgr_monitor.c b/subsys/net/conn_mgr/conn_mgr_monitor.c index 765d51f4e2a4..8fbd21881d05 100644 --- a/subsys/net/conn_mgr/conn_mgr_monitor.c +++ b/subsys/net/conn_mgr/conn_mgr_monitor.c @@ -32,7 +32,7 @@ static struct k_thread conn_mgr_mon_thread; * conn_mgr_mon_get_if_by_index and conn_mgr_get_index_for_if are used to go back and forth between * iface_states indices and Zephyr iface pointers. */ -uint16_t iface_states[CONN_MGR_IFACE_MAX]; +static uint16_t iface_states[CONN_MGR_IFACE_MAX]; /* Tracks the most recent total quantity of L4-ready ifaces (any, IPv4, IPv6) */ static uint16_t last_ready_count; @@ -50,6 +50,11 @@ K_SEM_DEFINE(conn_mgr_mon_updated, 1, 1); /* Used to protect conn_mgr_monitor state */ K_MUTEX_DEFINE(conn_mgr_mon_lock); +uint16_t *conn_mgr_if_state_internal(void) +{ + return iface_states; +} + /** * @brief Retrieves pointer to an iface by the index that corresponds to it in iface_states * @@ -400,12 +405,6 @@ void conn_mgr_watch_l2(const struct net_l2 *l2) static int conn_mgr_mon_init(void) { - int i; - - for (i = 0; i < ARRAY_SIZE(iface_states); i++) { - iface_states[i] = 0; - } - k_thread_create(&conn_mgr_mon_thread, conn_mgr_mon_stack, CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE, conn_mgr_mon_thread_fn, diff --git a/subsys/net/conn_mgr/conn_mgr_private.h b/subsys/net/conn_mgr/conn_mgr_private.h index 364eb268ff1a..05dc28b4b4fe 100644 --- a/subsys/net/conn_mgr/conn_mgr_private.h +++ b/subsys/net/conn_mgr/conn_mgr_private.h @@ -63,6 +63,9 @@ void conn_mgr_init_events_handler(void); /* Cause conn_mgr_connectivity to Initialize all connectivity implementation bindings */ void conn_mgr_conn_init(void); +/* Retrieve the raw pointer to the state array of size CONN_MGR_IFACE_MAX */ +uint16_t *conn_mgr_if_state_internal(void); + /* Internal helper function to allow the shell net cm command to safely read conn_mgr state. */ uint16_t conn_mgr_if_state(struct net_if *iface); diff --git a/subsys/net/conn_mgr/events_handler.c b/subsys/net/conn_mgr/events_handler.c index 2a0c6fefc28e..9d88036db509 100644 --- a/subsys/net/conn_mgr/events_handler.c +++ b/subsys/net/conn_mgr/events_handler.c @@ -12,8 +12,6 @@ LOG_MODULE_DECLARE(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL); #include #include "conn_mgr_private.h" -extern uint16_t iface_states[CONN_MGR_IFACE_MAX]; - static struct net_mgmt_event_callback iface_events_cb; static struct net_mgmt_event_callback ipv6_events_cb; static struct net_mgmt_event_callback ipv4_events_cb; @@ -22,6 +20,7 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { + uint16_t *iface_states = conn_mgr_if_state_internal(); int idx; NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "Iface", mgmt_event, @@ -58,6 +57,7 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { + uint16_t *iface_states = conn_mgr_if_state_internal(); int idx; NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "IPv6", mgmt_event, @@ -115,6 +115,7 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { + uint16_t *iface_states = conn_mgr_if_state_internal(); int idx; NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "IPv4", mgmt_event, From ac37248ddb9264a4421ebec296d9d4c48cec0888 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sun, 29 Jun 2025 20:01:59 +1000 Subject: [PATCH 2/2] wifi: nrf_wifi: ignore interface if TX disabled Automatically hide the nRF7x interface from the connection manager if the TX path is disabled (scan only mode). This prevents function calls like `conn_mgr_all_if_up(true)` from bringing up the interface which can never result in a connection. Signed-off-by: Jordan Yates --- drivers/wifi/nrf_wifi/src/net_if.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/wifi/nrf_wifi/src/net_if.c b/drivers/wifi/nrf_wifi/src/net_if.c index 19101fab442e..84c858fd8afa 100644 --- a/drivers/wifi/nrf_wifi/src/net_if.c +++ b/drivers/wifi/nrf_wifi/src/net_if.c @@ -18,6 +18,7 @@ #include LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL); +#include #include #include "net_private.h" @@ -678,6 +679,11 @@ void nrf_wifi_if_init_zep(struct net_if *iface) nrf_wifi_net_iface_work_handler); #endif /* CONFIG_NRF70_DATA_TX */ +#ifdef CONFIG_NRF70_SCAN_ONLY + /* In scan only mode this interface should be ignored by the connectivity manager */ + conn_mgr_ignore_iface(iface); +#endif /* CONFIG_NRF70_SCAN_ONLY */ + #ifdef CONFIG_NRF_WIFI_RPU_RECOVERY k_work_init(&vif_ctx_zep->nrf_wifi_rpu_recovery_work, nrf_wifi_rpu_recovery_work_handler);