eth: fbnic: add basic stats
Subsystems (3)
Jakub Kicinski
maintainerv2 cover eth: fbnic: add basic stats
Add basic interface stats to fbnic.
v2:
- drop duplicate check
v1: https://lore.kernel.org/[email protected]
Jakub Kicinski (1):
eth: fbnic: add basic rtnl stats
Stanislav Fomichev (1):
eth: fbnic: add support for basic qstats
.../net/ethernet/meta/fbnic/fbnic_netdev.c | 136 ++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_netdev.h | 3 + drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 50 ++++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 10 ++ 4 files changed, 198 insertions(+), 1 deletion(-)
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v2 1/2 eth: fbnic: add basic rtnl stats
Count packets, bytes and drop on the datapath, and report to the user. Since queues are completely freed when the device is down - accumulate the stats in the main netdev struct. This means that per-queue stats will only report values since last reset (per qstat recommendation).
---
v2:
- drop duplicated check
--- .../net/ethernet/meta/fbnic/fbnic_netdev.c | 69 +++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_netdev.h | 3 + drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 50 +++++++++++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 10 +++ 4 files changed, 131 insertions(+), 1 deletion(-)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +69 -0
@@ -316,6 +316,74 @@ void fbnic_clear_rx_mode(struct net_device *netdev)__dev_mc_unsync (netdev,NULL ); } +static void fbnic_get_stats64 (struct net_device *dev, +struct rtnl_link_stats64 *stats64) +{ +u64 tx_bytes, tx_packets, tx_dropped =0 ; +u64 rx_bytes, rx_packets, rx_dropped =0 ; +struct fbnic_net *fbn =netdev_priv (dev); +struct fbnic_queue_stats *stats; +unsigned int start, i; + + stats = &fbn->tx_stats; + + tx_bytes = stats->bytes; + tx_packets = stats->packets; + tx_dropped = stats->dropped; + + stats64->tx_bytes = tx_bytes; + stats64->tx_packets = tx_packets; + stats64->tx_dropped = tx_dropped; + +for (i =0 ; i < fbn->num_tx_queues; i++) { +struct fbnic_ring *txr = fbn->tx[i]; + +if (!txr) +continue ; + + stats = &txr->stats; +do { + start =u64_stats_fetch_begin (&stats->syncp); + tx_bytes = stats->bytes; + tx_packets = stats->packets; + tx_dropped = stats->dropped; + }while (u64_stats_fetch_retry (&stats->syncp, start)); + + stats64->tx_bytes += tx_bytes; + stats64->tx_packets += tx_packets; + stats64->tx_dropped += tx_dropped; + } + + stats = &fbn->rx_stats; + + rx_bytes = stats->bytes; + rx_packets = stats->packets; + rx_dropped = stats->dropped; + + stats64->rx_bytes = rx_bytes; + stats64->rx_packets = rx_packets; + stats64->rx_dropped = rx_dropped; + +for (i =0 ; i < fbn->num_rx_queues; i++) { +struct fbnic_ring *rxr = fbn->rx[i]; + +if (!rxr) +continue ; + + stats = &rxr->stats; +do { + start =u64_stats_fetch_begin (&stats->syncp); + rx_bytes = stats->bytes; + rx_packets = stats->packets; + rx_dropped = stats->dropped; + }while (u64_stats_fetch_retry (&stats->syncp, start)); + + stats64->rx_bytes += rx_bytes; + stats64->rx_packets += rx_packets; + stats64->rx_dropped += rx_dropped; + } +} +static const struct net_device_ops fbnic_netdev_ops = { .ndo_open = fbnic_open, .ndo_stop = fbnic_stop,
@@ -324,6 +392,7 @@ static const struct net_device_ops fbnic_netdev_ops = { .ndo_features_check = fbnic_features_check, .ndo_set_mac_address = fbnic_set_mac, .ndo_set_rx_mode = fbnic_set_rx_mode, + .ndo_get_stats64 = fbnic_get_stats64, }; void fbnic_reset_queues(struct fbnic_net *fbn,
drivers/net/ethernet/meta/fbnic/fbnic_netdev.h +3 -0
@@ -40,6 +40,9 @@ struct fbnic_net {u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN ];u32 rss_flow_hash[FBNIC_NUM_HASH_OPT ]; +/* Storage for stats after ring destruction */ +struct fbnic_queue_stats tx_stats; +struct fbnic_queue_stats rx_stats;u64 link_down_events;struct list_head napis;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +49 -1
110 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +10 -0
@@ -7,6 +7,7 @@#include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/types.h> +#include <linux/u64_stats_sync.h> #include <net/xdp.h> struct fbnic_net ;
@@ -51,6 +52,13 @@ struct fbnic_pkt_buff {u16 nr_frags; }; +struct fbnic_queue_stats { +u64 packets; +u64 bytes; +u64 dropped; +struct u64_stats_sync syncp; +}; +/* Pagecnt bias is long max to reserve the last bit to catch overflow * cases where if we overcharge the bias it will flip over to be negative. */
@@ -77,6 +85,8 @@ struct fbnic_ring {u32 head, tail;/* Head/Tail of ring */ +struct fbnic_queue_stats stats; +/* Slow path fields follow */ dma_addr_t dma;/* Phys addr of descriptor memory */ size_t size;/* Size of descriptor ring in memory */
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v2 2/2 eth: fbnic: add support for basic qstats
In reply to Jakub KicinskiFrom: Stanislav Fomichev <[email protected]>
Implement netdev_stat_ops and export the basic per-queue stats.
This interface expect users to set the values that are used either to zero or to some other preserved value (they are 0xff by default). So here we export bytes/packets/drops from tx and rx_stats plus set some of the values that are exposed by queue stats to zero.
$ cd tools/testing/selftests/drivers/net && ./stats.py [...] Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
--- .../net/ethernet/meta/fbnic/fbnic_netdev.c | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +67 -0
@@ -4,6 +4,7 @@#include <linux/etherdevice.h> #include <linux/ipv6.h> #include <linux/types.h> +#include <net/netdev_queues.h> #include "fbnic.h" #include "fbnic_netdev.h"
@@ -395,6 +396,71 @@ static const struct net_device_ops fbnic_netdev_ops = { .ndo_get_stats64 = fbnic_get_stats64, }; +static void fbnic_get_queue_stats_rx (struct net_device *dev,int idx, +struct netdev_queue_stats_rx *rx) +{ +struct fbnic_net *fbn =netdev_priv (dev); +struct fbnic_ring *rxr = fbn->rx[idx]; +struct fbnic_queue_stats *stats; +unsigned int start; +u64 bytes, packets; + +if (!rxr) +return ; + + stats = &rxr->stats; +do { + start =u64_stats_fetch_begin (&stats->syncp); + bytes = stats->bytes; + packets = stats->packets; + }while (u64_stats_fetch_retry (&stats->syncp, start)); + + rx->bytes = bytes; + rx->packets = packets; +} + +static void fbnic_get_queue_stats_tx (struct net_device *dev,int idx, +struct netdev_queue_stats_tx *tx) +{ +struct fbnic_net *fbn =netdev_priv (dev); +struct fbnic_ring *txr = fbn->tx[idx]; +struct fbnic_queue_stats *stats; +unsigned int start; +u64 bytes, packets; + +if (!txr) +return ; + + stats = &txr->stats; +do { + start =u64_stats_fetch_begin (&stats->syncp); + bytes = stats->bytes; + packets = stats->packets; + }while (u64_stats_fetch_retry (&stats->syncp, start)); + + tx->bytes = bytes; + tx->packets = packets; +} + +static void fbnic_get_base_stats (struct net_device *dev, +struct netdev_queue_stats_rx *rx, +struct netdev_queue_stats_tx *tx) +{ +struct fbnic_net *fbn =netdev_priv (dev); + + tx->bytes = fbn->tx_stats.bytes; + tx->packets = fbn->tx_stats.packets; + + rx->bytes = fbn->rx_stats.bytes; + rx->packets = fbn->rx_stats.packets; +} + +static const struct netdev_stat_ops fbnic_stat_ops = { + .get_queue_stats_rx = fbnic_get_queue_stats_rx, + .get_queue_stats_tx = fbnic_get_queue_stats_tx, + .get_base_stats = fbnic_get_base_stats, +}; +void fbnic_reset_queues (struct fbnic_net *fbn,unsigned int tx,unsigned int rx) {
@@ -453,6 +519,7 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd) fbd->netdev = netdev; netdev->netdev_ops = &fbnic_netdev_ops; + netdev->stat_ops = &fbnic_stat_ops; fbn =netdev_priv (netdev);
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerRe: [PATCH net-next v2 1/2] eth: fbnic: add basic rtnl stats
In reply to Jakub Kicinskidrivers/net/ethernet/meta/fbnic/fbnic_txrx.h struct fbnic_pkt_buff { · line 60
Quoted 6 lines · On Thu, 8 Aug 2024 10:09:14 -0700 Jakub Kicinski wrote:
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +6
-0+struct fbnic_queue_stats { +u64 packets; +u64 bytes; +u64 dropped; +struct u64_stats_sync syncp; +};
Ugh, I missed init for the syncp..
Signature · 1 line
pw-bot: cr
Re: [PATCH net-next v2 1/2] eth: fbnic: add basic rtnl stats
Quoted 9 lines · Jakub Kicinski
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h struct fbnic_pkt_buff { · line 60
Quoted 6 lines · On Thu, 8 Aug 2024 10:09:14 -0700 Jakub Kicinski wrote:
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +6
-0+struct fbnic_queue_stats { +u64 packets; +u64 bytes; +u64 dropped; +struct u64_stats_sync syncp; +};Ugh, I missed init for the syncp..
And... I apparently missed that in my review of the first version, as well :(