Skip to content

net: ethernet: cleanup net-stats calls #84928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
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
14 changes: 8 additions & 6 deletions subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ static inline void ethernet_update_length(struct net_if *iface,
static void ethernet_update_rx_stats(struct net_if *iface,
struct net_eth_hdr *hdr, size_t length)
{
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
if (!IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
return;
}

eth_stats_update_bytes_rx(iface, length);
eth_stats_update_pkts_rx(iface);

Expand All @@ -161,7 +164,6 @@ static void ethernet_update_rx_stats(struct net_if *iface,
} else if (net_eth_is_addr_multicast(&hdr->dst)) {
eth_stats_update_multicast_rx(iface);
}
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
}

static inline bool eth_is_vlan_tag_stripped(struct net_if *iface)
Expand Down Expand Up @@ -653,11 +655,14 @@ static struct net_buf *ethernet_fill_header(struct ethernet_context *ctx,
return hdr_frag;
}

#if defined(CONFIG_NET_STATISTICS_ETHERNET)
static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
{
struct net_eth_hdr *hdr = NET_ETH_HDR(pkt);

if (!IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
return;
}

eth_stats_update_bytes_tx(iface, net_pkt_get_len(pkt));
eth_stats_update_pkts_tx(iface);

Expand All @@ -667,9 +672,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
eth_stats_update_broadcast_tx(iface);
}
}
#else
#define ethernet_update_tx_stats(...)
#endif /* CONFIG_NET_STATISTICS_ETHERNET */

static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
{
Expand Down
Loading