Skip to content

Commit 2153e34

Browse files
clamattiakartben
authored andcommitted
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 <[email protected]>
1 parent dc7d8bb commit 2153e34

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

subsys/net/l2/ethernet/ethernet.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,17 @@ static inline void ethernet_update_length(struct net_if *iface,
153153
static void ethernet_update_rx_stats(struct net_if *iface, size_t length,
154154
bool dst_broadcast, bool dst_eth_multicast)
155155
{
156-
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
156+
if (!IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
157+
return;
158+
}
159+
157160
eth_stats_update_bytes_rx(iface, length);
158161
eth_stats_update_pkts_rx(iface);
159162
if (dst_broadcast) {
160163
eth_stats_update_broadcast_rx(iface);
161164
} else if (dst_eth_multicast) {
162165
eth_stats_update_multicast_rx(iface);
163166
}
164-
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
165167
}
166168

167169
static inline bool eth_is_vlan_tag_stripped(struct net_if *iface)
@@ -662,11 +664,14 @@ static struct net_buf *ethernet_fill_header(struct ethernet_context *ctx,
662664
return hdr_frag;
663665
}
664666

665-
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
666667
static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
667668
{
668669
struct net_eth_hdr *hdr = NET_ETH_HDR(pkt);
669670

671+
if (!IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
672+
return;
673+
}
674+
670675
eth_stats_update_bytes_tx(iface, net_pkt_get_len(pkt));
671676
eth_stats_update_pkts_tx(iface);
672677

@@ -676,9 +681,6 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
676681
eth_stats_update_broadcast_tx(iface);
677682
}
678683
}
679-
#else
680-
#define ethernet_update_tx_stats(...)
681-
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
682684

683685
static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
684686
{

0 commit comments

Comments
 (0)