Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions drivers/wifi/nrf700x/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
74 changes: 74 additions & 0 deletions drivers/wifi/nrf700x/src/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions snippets/nrf70-debug/overlay-debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading