Skip to content

Commit f3cd029

Browse files
jukkarkartben
authored andcommitted
drivers: eth: e1000: Add Ethernet statistics support
Support e1000 driver Ethernet statistics if relevant config options are enabled. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 0e5df7a commit f3cd029

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/ethernet/eth_e1000.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,22 @@ static void e1000_iface_init(struct net_if *iface)
270270
LOG_DBG("done");
271271
}
272272

273+
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
274+
static struct net_stats_eth *get_stats(const struct device *dev)
275+
{
276+
struct e1000_dev *ctx = dev->data;
277+
278+
return &ctx->stats;
279+
}
280+
#endif
281+
273282
static const struct ethernet_api e1000_api = {
274283
.iface_api.init = e1000_iface_init,
275284
#if defined(CONFIG_ETH_E1000_PTP_CLOCK)
276285
.get_ptp_clock = e1000_get_ptp_clock,
286+
#endif
287+
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
288+
.get_stats = get_stats,
277289
#endif
278290
.get_capabilities = e1000_caps,
279291
.send = e1000_send,

drivers/ethernet/eth_e1000_priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ struct e1000_dev {
9494
const struct device *ptp_clock;
9595
double clk_ratio;
9696
#endif
97+
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
98+
struct net_stats_eth stats;
99+
#endif
97100
};
98101

99102
struct e1000_config {

0 commit comments

Comments
 (0)