net: Add statistics how long packets have spent in TX path

Calculate how long on average net_pkt has spent on its way from
application to the network device driver. The data is calculated
for all network packets and not just for UDP or TCP ones like in
RX statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2019-10-08 16:00:37 +03:00
commit d03cb7367c
7 changed files with 98 additions and 68 deletions

View file

@ -97,10 +97,21 @@ struct net_pkt {
struct net_if *orig_iface; /* Original network interface */
#endif
/* We do not support combination of TXTIME and TXTIME_STATS as the
* same variable is shared in net_pkt.h
*/
#if defined(CONFIG_NET_PKT_TXTIME) && defined(CONFIG_NET_PKT_TXTIME_STATS)
#error \
"Cannot define both CONFIG_NET_PKT_TXTIME and CONFIG_NET_PKT_TXTIME_STATS"
#endif
#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_TXTIME) || \
defined(CONFIG_NET_PKT_RXTIME_STATS)
defined(CONFIG_NET_PKT_RXTIME_STATS) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)
union {
#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_RXTIME_STATS)
#if defined(CONFIG_NET_PKT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_RXTIME_STATS) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)
/** Timestamp if available. */
struct net_ptp_time timestamp;
#endif /* CONFIG_NET_PKT_TIMESTAMP */

View file

@ -203,11 +203,11 @@ struct net_stats_ipv6_mld {
};
/**
* @brief Network packet transfer times
* @brief Network packet transfer times for calculating average TX time
*/
struct net_stats_tx_time {
u64_t time_sum;
net_stats_t time_count;
u64_t sum;
net_stats_t count;
};
/**
@ -223,10 +223,10 @@ struct net_stats_rx_time {
*/
struct net_stats_tc {
struct {
struct net_stats_tx_time tx_time;
net_stats_t pkts;
net_stats_t bytes;
u8_t priority;
struct net_stats_tx_time tx_time;
} sent[NET_TC_TX_COUNT];
struct {
@ -293,7 +293,13 @@ struct net_stats {
struct net_stats_tc tc;
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && \
defined(CONFIG_NET_PKT_TXTIME_STATS)
#error \
"Cannot define both CONFIG_NET_CONTEXT_TIMESTAMP and CONFIG_NET_PKT_TXTIME_STATS"
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)
/** Network packet TX time statistics */
struct net_stats_tx_time tx_time;
#endif