• Jakub Kicinski's avatar
    eth: bnxt: support per-queue statistics · af7b3b4a
    Jakub Kicinski authored
    Support per-queue statistics API in bnxt.
    
    $ ethtool -S eth0
    NIC statistics:
         [0]: rx_ucast_packets: 1418
         [0]: rx_mcast_packets: 178
         [0]: rx_bcast_packets: 0
         [0]: rx_discards: 0
         [0]: rx_errors: 0
         [0]: rx_ucast_bytes: 1141815
         [0]: rx_mcast_bytes: 16766
         [0]: rx_bcast_bytes: 0
         [0]: tx_ucast_packets: 1734
    ...
    
    $ ./cli.py --spec netlink/specs/netdev.yaml \
       --dump qstats-get --json '{"scope": "queue"}'
    [{'ifindex': 2,
      'queue-id': 0,
      'queue-type': 'rx',
      'rx-alloc-fail': 0,
      'rx-bytes': 1164931,
      'rx-packets': 1641},
    ...
     {'ifindex': 2,
      'queue-id': 0,
      'queue-type': 'tx',
      'tx-bytes': 631494,
      'tx-packets': 1771},
    ...
    
    Reset the per queue counters:
    $ ethtool -L eth0 combined 4
    
    Inspect again:
    
    $ ./cli.py --spec netlink/specs/netdev.yaml \
       --dump qstats-get --json '{"scope": "queue"}'
    [{'ifindex': 2,
      'queue-id': 0,
      'queue-type': 'rx',
      'rx-alloc-fail': 0,
      'rx-bytes': 32397,
      'rx-packets': 145},
    ...
     {'ifindex': 2,
      'queue-id': 0,
      'queue-type': 'tx',
      'tx-bytes': 37481,
      'tx-packets': 196},
    ...
    
    $ ethtool -S eth0 | head
    NIC statistics:
         [0]: rx_ucast_packets: 174
         [0]: rx_mcast_packets: 3
         [0]: rx_bcast_packets: 0
         [0]: rx_discards: 0
         [0]: rx_errors: 0
         [0]: rx_ucast_bytes: 37151
         [0]: rx_mcast_bytes: 267
         [0]: rx_bcast_bytes: 0
         [0]: tx_ucast_packets: 267
    ...
    
    Totals are still correct:
    
    $ ./cli.py --spec netlink/specs/netdev.yaml --dump qstats-get
    [{'ifindex': 2,
      'rx-alloc-fail': 0,
      'rx-bytes': 281949995,
      'rx-packets': 216524,
      'tx-bytes': 52694905,
      'tx-packets': 75546}]
    $ ip -s link show dev eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
        link/ether 14:23:f2:61:05:40 brd ff:ff:ff:ff:ff:ff
        RX:  bytes packets errors dropped  missed   mcast
         282519546  218100      0       0       0     516
        TX:  bytes packets errors dropped carrier collsns
          53323054   77674      0       0       0       0
    Acked-by: default avatarStanislav Fomichev <sdf@google.com>
    Reviewed-by: default avatarAmritha Nambiar <amritha.nambiar@intel.com>
    Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
    Reviewed-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20240306195509.1502746-4-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    af7b3b4a
bnxt.c 407 KB