From 1977ab22ae4906381d51db18524b625e78841f8b Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Tue, 30 Sep 2025 20:17:28 +0530 Subject: [PATCH 1/3] Add support for nRF70 FW stats API Instead of just shell add support to send FW stats using net-mgmt API (net stats) this will be sent as part of vendor stats. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrf700x/inc/fmac_main.h | 9 ++++ drivers/wifi/nrf700x/src/net_if.c | 74 ++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/drivers/wifi/nrf700x/inc/fmac_main.h b/drivers/wifi/nrf700x/inc/fmac_main.h index 53b5f713fc06..31e86e99f406 100644 --- a/drivers/wifi/nrf700x/inc/fmac_main.h +++ b/drivers/wifi/nrf700x/inc/fmac_main.h @@ -33,6 +33,11 @@ #define NRF700X_DRIVER_VERSION "1."NCS_VERSION_STRING +/* Calculate compile-time maximum for vendor stats */ +#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR +#define MAX_VENDOR_STATS ((sizeof(struct rpu_fw_stats) / sizeof(uint32_t)) + 1) +#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */ + #ifndef CONFIG_NRF700X_RADIO_TEST struct nrf_wifi_vif_ctx_zep { const struct device *zep_dev_ctx; @@ -56,6 +61,10 @@ struct nrf_wifi_vif_ctx_zep { bool set_if_event_received; int set_if_status; #ifdef CONFIG_NET_STATISTICS_ETHERNET +#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR + struct net_stats_eth_vendor eth_stats_vendor_data[MAX_VENDOR_STATS]; + char vendor_key_strings[MAX_VENDOR_STATS][16]; +#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */ struct net_stats_eth eth_stats; #endif /* CONFIG_NET_STATISTICS_ETHERNET */ #ifdef CONFIG_NRF700X_STA_MODE diff --git a/drivers/wifi/nrf700x/src/net_if.c b/drivers/wifi/nrf700x/src/net_if.c index 44a463eb941b..434e98a7fb2d 100644 --- a/drivers/wifi/nrf700x/src/net_if.c +++ b/drivers/wifi/nrf700x/src/net_if.c @@ -1095,6 +1095,16 @@ int nrf_wifi_if_set_config_zep(const struct device *dev, struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev) { struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; + #ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR + struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; + struct rpu_op_stats stats; + enum nrf_wifi_status status; + size_t fw_stats_size; + size_t num_uint32; + const uint8_t *fw_stats_bytes; + size_t i; + int vendor_idx = 0; +#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */ if (!dev) { LOG_ERR("%s Device not found", __func__); @@ -1107,6 +1117,70 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev) goto out; } +#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR + rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep; + if (!rpu_ctx_zep || !rpu_ctx_zep->rpu_ctx) { + LOG_ERR("%s: rpu_ctx_zep or rpu_ctx is NULL", __func__); + goto out; + } + + memset(&stats, 0, sizeof(stats)); + status = nrf_wifi_fmac_stats_get(rpu_ctx_zep->rpu_ctx, + 0, + &stats); + if (status != NRF_WIFI_STATUS_SUCCESS) { + LOG_ERR("%s: Failed to get RPU stats", __func__); + goto ret; + } + + /* Treat stats.fw as a blob and divide into uint32_t chunks */ + fw_stats_size = sizeof(stats.fw); + num_uint32 = fw_stats_size / sizeof(uint32_t); + fw_stats_bytes = (const uint8_t *)&stats.fw; + + vendor_idx = 0; + + for (i = 0; i < num_uint32 && vendor_idx < MAX_VENDOR_STATS - 1; i++) { + uint32_t val; + const char **key_ptr; + uint32_t *val_ptr; + + /* Extract uint32_t value from blob */ + memcpy(&val, fw_stats_bytes + i * sizeof(uint32_t), sizeof(uint32_t)); + + /* Create key name */ + snprintk(vif_ctx_zep->vendor_key_strings[vendor_idx], 16, "fw_%zu", i); + + /* Assign key */ + key_ptr = (const char **) + &vif_ctx_zep->eth_stats_vendor_data[vendor_idx].key; + *key_ptr = vif_ctx_zep->vendor_key_strings[vendor_idx]; + + /* Assign value */ + val_ptr = (uint32_t *) + &vif_ctx_zep->eth_stats_vendor_data[vendor_idx].value; + *val_ptr = val; + + vendor_idx++; + } + + /* Null terminator entry */ + { + const char **key_ptr = (const char **) + &vif_ctx_zep->eth_stats_vendor_data[vendor_idx].key; + uint32_t *val_ptr = (uint32_t *) + &vif_ctx_zep->eth_stats_vendor_data[vendor_idx].value; + + *key_ptr = NULL; + *val_ptr = 0; + } + + /* Point to the static vendor data */ + vif_ctx_zep->eth_stats.vendor = vif_ctx_zep->eth_stats_vendor_data; + +ret: +#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */ + return &vif_ctx_zep->eth_stats; out: return NULL; From cc16555ff21af2b8b6fe99c2c4060b99db3546b6 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Tue, 30 Sep 2025 20:18:40 +0530 Subject: [PATCH 2/3] Enable Ethernet stats To fetch nRF70 FW stats using Ethernet vendor stats. Signed-off-by: Chaitanya Tata --- snippets/nrf70-debug/overlay-debug.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/nrf70-debug/overlay-debug.conf b/snippets/nrf70-debug/overlay-debug.conf index 0d14b1791c0e..1fbca2424111 100644 --- a/snippets/nrf70-debug/overlay-debug.conf +++ b/snippets/nrf70-debug/overlay-debug.conf @@ -15,6 +15,8 @@ CONFIG_NET_STATISTICS=y CONFIG_NET_STATISTICS_WIFI=y CONFIG_NET_STATISTICS_USER_API=y CONFIG_SYS_HEAP_RUNTIME_STATS=y +CONFIG_NET_STATISTICS_ETHERNET=y +CONFIG_NET_STATISTICS_ETHERNET_VENDOR=y CONFIG_LOG=y CONFIG_PRINTK=y CONFIG_LOG_MODE_IMMEDIATE=y From 2f33772f994c215665468f97ad8439de43d3bbd0 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Tue, 30 Sep 2025 20:25:57 +0530 Subject: [PATCH 3/3] manifest: sdk-zephyr: Pull vendor stats display improvs Improve shell dumping of vendor stats. Signed-off-by: Chaitanya Tata --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index db5ca6af4ccb..7ae82f1f5989 100644 --- a/west.yml +++ b/west.yml @@ -61,7 +61,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: v3.5.99-ncs1-4 + revision: pull/3337/head import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above