From f24975fe27205f62255701502b875fdf14a3f233 Mon Sep 17 00:00:00 2001 From: Cla Mattia Galliard Date: Thu, 30 Jan 2025 16:29:04 +0100 Subject: [PATCH] net: ethernet: cleanup net-stats calls There is no need to if-def away the net-stats function since there is a shim available now. Signed-off-by: Cla Mattia Galliard --- subsys/net/l2/ethernet/ethernet.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index fd1fcb0cd666..dcd62f6ff4b3 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -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); @@ -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) @@ -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); @@ -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) {