drivers, ixgbe: show VF statistics
Subsystems (3)
PATCH v2 1/1 drivers, ixgbe: show VF statistics
This change exports network statistics for individual virtual functions via ethtool and iproute2.
The code for retrieving the statistics from the device and printing via ethtool 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. I took commit c8d4725e985d ("intel: Update drivers to use ethtool_sprintf") into account and fixed a few style issues.
Apart from that, ndo_get_vf_stats is implemented so that iproute2 also prints the statistics.
---
v2: implemented the ndo_get_vf_stats callback
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 34 ++++++++ .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 26 +++++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 86 +++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 7 ++ 4 files changed, 152 insertions(+), 1 deletion(-)
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_ethtool.c +25 -1
@@ -122,9 +122,13 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = { sizeof(((struct ixgbe_adapter *)0)->stats.pxoffrxc) + \ sizeof(((struct ixgbe_adapter *)0)->stats.pxofftxc)) \ / sizeof(u64)) +#define IXGBE_VF_STATS_LEN \ + ((((struct ixgbe_adapter *)netdev_priv(netdev))->num_vfs) * \ + (sizeof(struct vf_stats) / sizeof(u64)))#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + \ IXGBE_PB_STATS_LEN + \ - IXGBE_QUEUE_STATS_LEN) + IXGBE_QUEUE_STATS_LEN + \ + IXGBE_VF_STATS_LEN)static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN ] = {"Register test (offline)" ,"Eeprom test (offline)" ,
@@ -1302,6 +1306,8 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,struct ixgbe_adapter *adapter =netdev_priv (netdev);struct rtnl_link_stats64 temp;const struct rtnl_link_stats64 *net_stats; +u64 *queue_stat; +int stat_count, k;unsigned int start;struct ixgbe_ring *ring;int i, j;
@@ -1368,11 +1374,22 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, data[i++] = adapter->stats.pxonrxc[j]; data[i++] = adapter->stats.pxoffrxc[j]; } + stat_count =sizeof (struct vf_stats ) /sizeof (u64); +for (j =0 ; j < adapter->num_vfs; j++) { + queue_stat = (u64 *)&adapter->vfinfo[j].vfstats; +for (k =0 ; k < stat_count; k++) + data[i + k] = queue_stat[k]; + queue_stat = (u64 *)&adapter->vfinfo[j].saved_rst_vfstats; +for (k =0 ; k < stat_count; k++) + data[i + k] += queue_stat[k]; + i += k; + } }static void ixgbe_get_strings (struct net_device *netdev,u32 stringset,u8 *data) { +struct ixgbe_adapter *adapter =netdev_priv (netdev);unsigned int i;u8 *p = data;
@@ -1401,6 +1418,13 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,ethtool_sprintf (&p,"rx_pb_%u_pxon" , i);ethtool_sprintf (&p,"rx_pb_%u_pxoff" , i); } +for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }/* BUG_ON(p - data != IXGBE_STATS_LEN * ETH_GSTRING_LEN); */ break ;case ETH_SS_PRIV_FLAGS :
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
Jakub Kicinski
maintainerdrivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, · line 1427
Quoted 7 lines · On Tue, 3 May 2022 15:00:17 +0000 Maximilian Heyne wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +7
-0+for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }
Please drop the ethtool stats. We've been trying to avoid duplicating the same stats in ethtool and iproute2 for a while now.
Quoted 12 lines · On 2022-05-04T20:16:32-07:00 Jakub Kicinski <[email protected]> wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, · line 1427
Quoted 7 lines · On Tue, 3 May 2022 15:00:17 +0000 Maximilian Heyne wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +7
-0+for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }Please drop the ethtool stats. We've been trying to avoid duplicating the same stats in ethtool and iproute2 for a while now.
I can see the point that standard metrics should only be reported via the iproute2 interface. However, in this special case this patch was intended to converge the out-of-tree driver with the in-tree version. These missing stats were breaking our userspace. If we now switch solely to iproute2 based statistics both driver versions would diverge even more. So depending on where a user gets the ixgbe driver from, they have to work-around.
I can change the patch as requested, but it will contradict the inital intention. At least Intel should then port this change to the external driver as well. Let's get a statement from them.
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
Jakub Kicinski
maintainerQuoted 22 lines · On Fri, 6 May 2022 06:44:40 +0000 Maximilian Heyne wrote:
Quoted 11 lines · On 2022-05-04T20:16:32-07:00 Jakub Kicinski <[email protected]> wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, · line 1427
Quoted 7 lines · On Tue, 3 May 2022 15:00:17 +0000 Maximilian Heyne wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +7
-0+for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }Please drop the ethtool stats. We've been trying to avoid duplicating the same stats in ethtool and iproute2 for a while now.
I can see the point that standard metrics should only be reported via the iproute2 interface. However, in this special case this patch was intended to converge the out-of-tree driver with the in-tree version. These missing stats were breaking our userspace. If we now switch solely to iproute2 based statistics both driver versions would diverge even more. So depending on where a user gets the ixgbe driver from, they have to work-around.
Quoted 3 lines
I can change the patch as requested, but it will contradict the inital intention. At least Intel should then port this change to the external driver as well. Let's get a statement from them.
Ack, but we really want people to move towards using standard stats.
Can you change the user space to first try reading the stats via iproute2/rtnetlink? And fallback to random ethtool strings if not available? That way it will work with any driver implementing the standard API. Long term that'll make everyone's life easier.
Out-of-tree code cannot be an argument upstream, otherwise we'd completely lose control over our APIs. Vendors could ship whatever in their out of tree repo and then force us to accept it upstream.
It's disappointing to see the vendor letting the uAPI of the out of tree driver diverge from upstream, especially a driver this mature.
Tony Nguyen
maintainerQuoted 23 lines · Jakub Kicinski
Quoted 22 lines · On Fri, 6 May 2022 06:44:40 +0000 Maximilian Heyne wrote:
Quoted 11 lines · On 2022-05-04T20:16:32-07:00 Jakub Kicinski <[email protected]> wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, · line 1427
Quoted 7 lines · On Tue, 3 May 2022 15:00:17 +0000 Maximilian Heyne wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +7
-0+for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }Please drop the ethtool stats. We've been trying to avoid duplicating the same stats in ethtool and iproute2 for a while now.
I can see the point that standard metrics should only be reported via the iproute2 interface. However, in this special case this patch was intended to converge the out-of-tree driver with the in-tree version. These missing stats were breaking our userspace. If we now switch solely to iproute2 based statistics both driver versions would diverge even more. So depending on where a user gets the ixgbe driver from, they have to work-around.
Quoted 3 lines
Quoted 3 lines
I can change the patch as requested, but it will contradict the inital intention. At least Intel should then port this change to the external driver as well. Let's get a statement from them.
We discussed this patch internally and concluded the correct approach would be to not have the ethtool stats and use the VF info. Jakub beat us to the comment. We would plan to port the iproute implementation to OOT as well.
Quoted 13 lines
Ack, but we really want people to move towards using standard stats.
Can you change the user space to first try reading the stats via iproute2/rtnetlink? And fallback to random ethtool strings if not available? That way it will work with any driver implementing the standard API. Long term that'll make everyone's life easier.
Out-of-tree code cannot be an argument upstream, otherwise we'd completely lose control over our APIs. Vendors could ship whatever in their out of tree repo and then force us to accept it upstream.
It's disappointing to see the vendor letting the uAPI of the out of tree driver diverge from upstream, especially a driver this mature.
Quoted 24 lines · On 2022-05-06T09:20:14-07:00 Tony Nguyen <[email protected]> wrote:
Quoted 23 lines · Jakub Kicinski
Quoted 22 lines · On Fri, 6 May 2022 06:44:40 +0000 Maximilian Heyne wrote:
Quoted 11 lines · On 2022-05-04T20:16:32-07:00 Jakub Kicinski <[email protected]> wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, · line 1427
Quoted 7 lines · On Tue, 3 May 2022 15:00:17 +0000 Maximilian Heyne wrote:
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +7
-0+for (i =0 ; i < adapter->num_vfs; i++) { +ethtool_sprintf (&p,"VF %u Rx Packets" , i); +ethtool_sprintf (&p,"VF %u Rx Bytes" , i); +ethtool_sprintf (&p,"VF %u Tx Packets" , i); +ethtool_sprintf (&p,"VF %u Tx Bytes" , i); +ethtool_sprintf (&p,"VF %u MC Packets" , i); + }Please drop the ethtool stats. We've been trying to avoid duplicating the same stats in ethtool and iproute2 for a while now.
I can see the point that standard metrics should only be reported via the iproute2 interface. However, in this special case this patch was intended to converge the out-of-tree driver with the in-tree version. These missing stats were breaking our userspace. If we now switch solely to iproute2 based statistics both driver versions would diverge even more. So depending on where a user gets the ixgbe driver from, they have to work-around.
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
I can change the patch as requested, but it will contradict the inital intention. At least Intel should then port this change to the external driver as well. Let's get a statement from them.
We discussed this patch internally and concluded the correct approach would be to not have the ethtool stats and use the VF info. Jakub beat us to the comment. We would plan to port the iproute implementation to OOT as well.
Ok, then I'll send a follow-up patch without the ethtool changes. I'm happy to get some kind of convergence between the out-of-tree driver and upstream.
While at it, I wonder whether other drivers need similar changes as well and what other features are missing in the upstream driver. There should be no surprises when switching between these drivers.
Quoted 7 lines
Quoted 7 lines
Ack, but we really want people to move towards using standard stats.
Can you change the user space to first try reading the stats via iproute2/rtnetlink? And fallback to random ethtool strings if not available? That way it will work with any driver implementing the standard API. Long term that'll make everyone's life easier.
Yes, in this case we are in control of user space and can work around.
Quoted 8 lines
Quoted 7 lines
Out-of-tree code cannot be an argument upstream, otherwise we'd completely lose control over our APIs. Vendors could ship whatever in their out of tree repo and then force us to accept it upstream.
It's disappointing to see the vendor letting the uAPI of the out of tree driver diverge from upstream, especially a driver this mature.
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