Skip to content

Commit 2b0991d

Browse files
jacob-kellerSomasundaram Krishnasamy
authored andcommitted
fm10k: add support for ndo_get_vf_stats operation
Support capturing and reporting statistics for all of the VFs associated with a given PF device via the ndo_get_vf_stats callback. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]> (cherry picked from commit 0e10044) Orabug: 31268827 Signed-off-by: Jack Vogel <[email protected]> Reviewed-by: John Donnelly <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent d068bfa commit 2b0991d

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

drivers/net/ethernet/intel/fm10k/fm10k.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ void fm10k_iov_suspend(struct pci_dev *pdev);
534534
int fm10k_iov_resume(struct pci_dev *pdev);
535535
void fm10k_iov_disable(struct pci_dev *pdev);
536536
int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs);
537+
void fm10k_iov_update_stats(struct fm10k_intfc *interface);
537538
s32 fm10k_iov_update_pvid(struct fm10k_intfc *interface, u16 glort, u16 pvid);
538539
int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac);
539540
int fm10k_ndo_set_vf_vlan(struct net_device *netdev,
@@ -542,6 +543,8 @@ int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx,
542543
int __always_unused min_rate, int max_rate);
543544
int fm10k_ndo_get_vf_config(struct net_device *netdev,
544545
int vf_idx, struct ifla_vf_info *ivi);
546+
int fm10k_ndo_get_vf_stats(struct net_device *netdev,
547+
int vf_idx, struct ifla_vf_stats *stats);
545548

546549
/* DebugFS */
547550
#ifdef CONFIG_DEBUG_FS

drivers/net/ethernet/intel/fm10k/fm10k_iov.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,27 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs)
514514
return num_vfs;
515515
}
516516

517+
/**
518+
* fm10k_iov_update_stats - Update stats for all VFs
519+
* @interface: device private structure
520+
*
521+
* Updates the VF statistics for all enabled VFs. Expects to be called by
522+
* fm10k_update_stats and assumes that locking via the __FM10K_UPDATING_STATS
523+
* bit is already handled.
524+
*/
525+
void fm10k_iov_update_stats(struct fm10k_intfc *interface)
526+
{
527+
struct fm10k_iov_data *iov_data = interface->iov_data;
528+
struct fm10k_hw *hw = &interface->hw;
529+
int i;
530+
531+
if (!iov_data)
532+
return;
533+
534+
for (i = 0; i < iov_data->num_vfs; i++)
535+
hw->iov.ops.update_stats(hw, iov_data->vf_info[i].stats, i);
536+
}
537+
517538
static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface,
518539
struct fm10k_vf_info *vf_info)
519540
{
@@ -644,3 +665,29 @@ int fm10k_ndo_get_vf_config(struct net_device *netdev,
644665

645666
return 0;
646667
}
668+
669+
int fm10k_ndo_get_vf_stats(struct net_device *netdev,
670+
int vf_idx, struct ifla_vf_stats *stats)
671+
{
672+
struct fm10k_intfc *interface = netdev_priv(netdev);
673+
struct fm10k_iov_data *iov_data = interface->iov_data;
674+
struct fm10k_hw *hw = &interface->hw;
675+
struct fm10k_hw_stats_q *hw_stats;
676+
u32 idx, qpp;
677+
678+
/* verify SR-IOV is active and that vf idx is valid */
679+
if (!iov_data || vf_idx >= iov_data->num_vfs)
680+
return -EINVAL;
681+
682+
qpp = fm10k_queues_per_pool(hw);
683+
hw_stats = iov_data->vf_info[vf_idx].stats;
684+
685+
for (idx = 0; idx < qpp; idx++) {
686+
stats->rx_packets += hw_stats[idx].rx_packets.count;
687+
stats->tx_packets += hw_stats[idx].tx_packets.count;
688+
stats->rx_bytes += hw_stats[idx].rx_bytes.count;
689+
stats->tx_bytes += hw_stats[idx].tx_bytes.count;
690+
}
691+
692+
return 0;
693+
}

drivers/net/ethernet/intel/fm10k/fm10k_netdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ static const struct net_device_ops fm10k_netdev_ops = {
16361636
.ndo_set_vf_vlan = fm10k_ndo_set_vf_vlan,
16371637
.ndo_set_vf_rate = fm10k_ndo_set_vf_bw,
16381638
.ndo_get_vf_config = fm10k_ndo_get_vf_config,
1639+
.ndo_get_vf_stats = fm10k_ndo_get_vf_stats,
16391640
.ndo_udp_tunnel_add = fm10k_udp_tunnel_add,
16401641
.ndo_udp_tunnel_del = fm10k_udp_tunnel_del,
16411642
.ndo_dfwd_add_station = fm10k_dfwd_add_station,

drivers/net/ethernet/intel/fm10k/fm10k_pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ void fm10k_update_stats(struct fm10k_intfc *interface)
629629
net_stats->rx_errors = rx_errors;
630630
net_stats->rx_dropped = interface->stats.nodesc_drop.count;
631631

632+
/* Update VF statistics */
633+
fm10k_iov_update_stats(interface);
634+
632635
clear_bit(__FM10K_UPDATING_STATS, interface->state);
633636
}
634637

drivers/net/ethernet/intel/fm10k/fm10k_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ struct fm10k_vf_info {
581581
* at the same offset as the mailbox
582582
*/
583583
struct fm10k_mbx_info mbx; /* PF side of VF mailbox */
584+
struct fm10k_hw_stats_q stats[FM10K_MAX_QUEUES_POOL];
584585
int rate; /* Tx BW cap as defined by OS */
585586
u16 glort; /* resource tag for this VF */
586587
u16 sw_vid; /* Switch API assigned VLAN */

0 commit comments

Comments
 (0)