drivers, ixgbe: export vf statistics
Subsystems (3)
PATCH v3 1/1 drivers, ixgbe: export vf statistics
This change retrieves network metrics for virtual functions from the device and exports them via the iproute2 interface.
The code for retrieving the statistics from the device is taken from the out-of-tree driver. The feature was introduced with version 2.0.75.7, so the diff between this version and the previous version 2.0.72.4 was used to identify required changes. The export via ethtool is omitted in favor of using the standard ndo_get_vf_stats interface.
Per-VF statistics can now be printed, for instance, via
ip --statistics link show dev eth0
---
v2: implemented the ndo_get_vf_stats callback
v3: as per discussion, removed the ethtool changes
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 34 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 86 +++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 7 ++ 3 files changed, 127 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +34 -0
@@ -167,12 +167,46 @@ enum ixgbe_tx_flags {#define IXGBE_82599_VF_DEVICE_ID 0x10ED#define IXGBE_X540_VF_DEVICE_ID 0x1515 +#define UPDATE_VF_COUNTER_32bit (reg, last_counter, counter) \ + { \ + u32 current_counter = IXGBE_READ_REG(hw, reg); \ + if (current_counter < last_counter) \ + counter += 0x100000000LL; \ + last_counter = current_counter; \ + counter &= 0xFFFFFFFF00000000LL; \ + counter |= current_counter; \ + } + +#define UPDATE_VF_COUNTER_36bit (reg_lsb, reg_msb, last_counter, counter) \ + { \ + u64 current_counter_lsb = IXGBE_READ_REG(hw, reg_lsb); \ + u64 current_counter_msb = IXGBE_READ_REG(hw, reg_msb); \ + u64 current_counter = (current_counter_msb << 32) | \ + current_counter_lsb; \ + if (current_counter < last_counter) \ + counter += 0x1000000000LL; \ + last_counter = current_counter; \ + counter &= 0xFFFFFFF000000000LL; \ + counter |= current_counter; \ + } + +struct vf_stats { +u64 gprc; +u64 gorc; +u64 gptc; +u64 gotc; +u64 mprc; +}; +struct vf_data_storage {struct pci_dev *vfdev;unsigned char vf_mac_addresses[ETH_ALEN ];u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES ];u16 num_vf_mc_hashes;bool clear_to_send; +struct vf_stats vfstats; +struct vf_stats last_vfstats; +struct vf_stats saved_rst_vfstats;bool pf_set_mac;u16 pf_vlan;/* When set, guest VLAN config not allowed. */ u16 pf_qos;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +86 -0
116 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +7 -0
@@ -2533,6 +2533,13 @@ enum {#define IXGBE_PVFTXDCTL (P ) (0x06028 + (0x40 * (P)))#define IXGBE_PVFTDWBAL (P ) (0x06038 + (0x40 * (P)))#define IXGBE_PVFTDWBAH (P ) (0x0603C + (0x40 * (P))) +#define IXGBE_PVFGPRC (x) (0x0101C + (0x40 * (x))) +#define IXGBE_PVFGPTC (x) (0x08300 + (0x04 * (x))) +#define IXGBE_PVFGORC_LSB (x) (0x01020 + (0x40 * (x))) +#define IXGBE_PVFGORC_MSB (x) (0x0D020 + (0x40 * (x))) +#define IXGBE_PVFGOTC_LSB (x) (0x08400 + (0x08 * (x))) +#define IXGBE_PVFGOTC_MSB (x) (0x08404 + (0x08 * (x))) +#define IXGBE_PVFMPRC (x) (0x0D01C + (0x40 * (x)))#define IXGBE_PVFTDWBALn (q_per_pool, vf_number, vf_q_index) \ (IXGBE_PVFTDWBAL((q_per_pool)*(vf_number) + (vf_q_index)))
Signature · 12 lines
2.32.0 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
drivers/net/ethernet/intel/ixgbe/ixgbe.h
Quoted 42 lines
-----Original Message-----
From: Maximilian Heyne <[email protected]>
Sent: Monday, May 9, 2022 1:04 PM
Cc: Maximilian Heyne <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
Subject: [PATCH net-next v3] drivers, ixgbe: export vf statisticsThis change retrieves network metrics for virtual functions from the device and exports them via the iproute2 interface.
The code for retrieving the statistics from the device is taken from the out-of- tree driver. The feature was introduced with version 2.0.75.7, so the diff between this version and the previous version 2.0.72.4 was used to identify required changes. The export via ethtool is omitted in favor of using the standard
ndo_get_vf_statsinterface.Per-VF statistics can now be printed, for instance, via
ip --statistics link show dev eth0Signed-off-by Maximilian Heyne <[email protected]>---
v2: implemented thendo_get_vf_statscallback
v3: as per discussion, removed the ethtool changesdrivers/net/ethernet/intel/ixgbe/ixgbe.h | 34 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 86 +++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 7 ++ 3 files changed, 127 insertions(+)drivers/net/ethernet/intel/ixgbe/ixgbe.h +0
-0