Skip to content
Merged
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
7 changes: 7 additions & 0 deletions doc/releases/release-notes-4.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ New APIs and options
* :c:struct:`net_eth_mac_config`
* :c:macro:`NET_ETH_MAC_DT_CONFIG_INIT` and :c:macro:`NET_ETH_MAC_DT_INST_CONFIG_INIT`

* Added :c:enum:`ethernet_stats_type` and optional ``get_stats_type`` callback in
:c:struct:`ethernet_api` to allow filtering of ethernet statistics by type
(common, vendor, or all). Drivers that support vendor-specific statistics can
implement ``get_stats_type`` to skip expensive FW queries when only common stats
are requested. The existing ``get_stats`` API remains unchanged for backward
compatibility.

* Flash

* :dtcompatible:`jedec,mspi-nor` now allows MSPI configuration of read, write and
Expand Down
5 changes: 4 additions & 1 deletion drivers/wifi/nrf_wifi/inc/net_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ enum nrf_wifi_status nrf_wifi_if_carr_state_chg(void *os_vif_ctx,
int nrf_wifi_stats_get(const struct device *dev,
struct net_stats_wifi *stats);

struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev);
#ifdef CONFIG_NET_STATISTICS_ETHERNET
struct net_stats_eth *nrf_wifi_eth_stats_get_type(const struct device *dev,
uint32_t type);
#endif /* CONFIG_NET_STATISTICS_ETHERNET */

void nrf_wifi_set_iface_event_handler(void *os_vif_ctx,
struct nrf_wifi_umac_event_set_interface *event,
Expand Down
2 changes: 1 addition & 1 deletion drivers/wifi/nrf_wifi/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ static const struct net_wifi_mgmt_offload wifi_offload_ops = {
.wifi_iface.get_capabilities = nrf_wifi_if_caps_get,
.wifi_iface.send = nrf_wifi_if_send,
#ifdef CONFIG_NET_STATISTICS_ETHERNET
.wifi_iface.get_stats = nrf_wifi_eth_stats_get,
.wifi_iface.get_stats_type = nrf_wifi_eth_stats_get_type,
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
#ifdef CONFIG_NET_L2_WIFI_MGMT
.wifi_mgmt_api = &nrf_wifi_mgmt_ops,
Expand Down
66 changes: 31 additions & 35 deletions drivers/wifi/nrf_wifi/src/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,8 @@ int nrf_wifi_if_set_config_zep(const struct device *dev,
}

#ifdef CONFIG_NET_STATISTICS_ETHERNET
struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
struct net_stats_eth *nrf_wifi_eth_stats_get_type(const struct device *dev,
uint32_t type)
{
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
Expand All @@ -1222,24 +1223,34 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
const uint8_t *fw_stats_bytes;
size_t i;
int vendor_idx = 0;
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
const char **key_ptr;
uint32_t *val_ptr;
uint32_t val;
#endif

if (!dev) {
LOG_ERR("%s Device not found", __func__);
goto out;
goto err;
}

vif_ctx_zep = dev->data;
if (!vif_ctx_zep) {
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
goto out;
goto err;
}

if (!(type & ETHERNET_STATS_TYPE_VENDOR)) {
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
vif_ctx_zep->eth_stats.vendor = NULL;
#endif
goto done;
}

#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;
goto err;
}

memset(&stats, 0, sizeof(stats));
Expand All @@ -1248,7 +1259,7 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
&stats);
if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: Failed to get RPU stats", __func__);
goto ret;
goto done;
}

/* Treat stats.fw as a blob and divide into uint32_t chunks */
Expand All @@ -1257,49 +1268,34 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
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));
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);
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 = (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 = (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;
}
key_ptr = (const char **) &vif_ctx_zep->eth_stats_vendor_data[vendor_idx].key;
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;
#endif

ret:
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
done:
return &vif_ctx_zep->eth_stats;
out:

err:
return NULL;
}
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
Expand Down
18 changes: 18 additions & 0 deletions include/zephyr/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ struct ethernet_config {

/** @endcond */

/** Ethernet statistics type (bitmap) */
enum ethernet_stats_type {
/** Common statistics only (excludes vendor statistics) */
ETHERNET_STATS_TYPE_COMMON = BIT(0),
/** Vendor statistics only */
ETHERNET_STATS_TYPE_VENDOR = BIT(1),
/** All statistics */
ETHERNET_STATS_TYPE_ALL = 0xFFFFFFFFU,
};

/** Ethernet L2 API operations. */
struct ethernet_api {
/**
Expand All @@ -543,6 +553,14 @@ struct ethernet_api {
*/
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
struct net_stats_eth *(*get_stats)(const struct device *dev);

/** Optional function to collect ethernet specific statistics with
* type filter. If NULL, get_stats() will be called instead, which
* is equivalent to calling this with ETHERNET_STATS_TYPE_ALL.
* @param type Bitmask of ethernet_stats_type values.
*/
struct net_stats_eth *(*get_stats_type)(const struct device *dev,
uint32_t type);
#endif

/** Start the device */
Expand Down
Loading