Skip to content

Commit dd88711

Browse files
jyong2jukkar
authored andcommitted
net: eth: Vendor specific statistics
Allows ethernet drivers to provide vendor specific statistics and details in the form of key-value pairs with the name of the staticstic and its value. The new string tables will be behind a new config: NET_STATISTICS_ETHERNET_VENDOR Suggested-by: Jukka Rissanen <jukka.rissanen@intel.com> Signed-off-by: Jonathan Yong <jonathan.yong@intel.com>
1 parent 0272a53 commit dd88711

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

include/net/net_stats.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,13 @@ struct net_stats_eth_hw_timestamp {
341341
net_stats_t tx_hwtstamp_skipped;
342342
};
343343

344+
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
345+
struct net_stats_eth_vendor {
346+
const char * const key;
347+
u32_t value;
348+
};
349+
#endif
350+
344351
/* Ethernet specific statistics */
345352
struct net_stats_eth {
346353
struct net_stats_bytes bytes;
@@ -356,6 +363,10 @@ struct net_stats_eth {
356363
net_stats_t tx_dropped;
357364
net_stats_t tx_timeout_count;
358365
net_stats_t tx_restart_queue;
366+
#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
367+
/** Array is terminated with an entry containing a NULL key */
368+
struct net_stats_eth_vendor *vendor;
369+
#endif
359370
};
360371

361372
#if defined(CONFIG_NET_STATISTICS_USER_API)

subsys/net/ip/Kconfig.stats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,13 @@ config NET_STATISTICS_ETHERNET
9999
requires support from the ethernet driver. The driver needs
100100
to collect the statistics.
101101

102+
config NET_STATISTICS_ETHERNET_VENDOR
103+
bool "Vendor specific Ethernet statistics"
104+
depends on NET_STATISTICS_ETHERNET
105+
help
106+
Allows Ethernet drivers to provide statistics information
107+
from vendor specific hardware registers in a form of
108+
key-value pairs. Deciphering the information may require
109+
vendor documentation.
110+
102111
endif # NET_STATISTICS

subsys/net/ip/net_shell.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,20 @@ static void print_eth_stats(struct net_if *iface, struct net_stats_eth *data)
618618
printk("Bcast sent : %u\n", data->broadcast.tx);
619619
printk("Mcast received : %u\n", data->multicast.rx);
620620
printk("Mcast sent : %u\n", data->multicast.tx);
621+
622+
#if defined(CONFIG_NET_STATISTICS_ETHERNET_VENDOR)
623+
if (data->vendor) {
624+
printk("Vendor specific statistics for Ethernet interface %p [%d]:\n",
625+
iface, net_if_get_by_iface(iface));
626+
size_t i = 0;
627+
628+
do {
629+
printk("%s : %u\n", data->vendor[i].key,
630+
data->vendor[i].value);
631+
i++;
632+
} while (data->vendor[i].key);
633+
}
634+
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
621635
}
622636
#endif /* CONFIG_NET_STATISTICS_ETHERNET && CONFIG_NET_STATISTICS_USER_API */
623637

0 commit comments

Comments
 (0)