hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
....@@ -1,5 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/* Copyright(c) 2013 - 2018 Intel Corporation. */
2
+/* Copyright(c) 2013 - 2019 Intel Corporation. */
33
44 #include "fm10k.h"
55 #include "fm10k_vf.h"
....@@ -244,7 +244,8 @@
244244 }
245245
246246 /* guarantee we have free space in the SM mailbox */
247
- if (!hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) {
247
+ if (hw->mbx.state == FM10K_STATE_OPEN &&
248
+ !hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) {
248249 /* keep track of how many times this occurs */
249250 interface->hw_sm_mbx_full++;
250251
....@@ -320,8 +321,6 @@
320321 pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, &err_mask);
321322 err_mask |= PCI_ERR_UNC_COMP_ABORT;
322323 pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, err_mask);
323
-
324
- mmiowb();
325324 }
326325
327326 int fm10k_iov_resume(struct pci_dev *pdev)
....@@ -427,7 +426,7 @@
427426 struct fm10k_iov_data *iov_data = interface->iov_data;
428427 struct fm10k_hw *hw = &interface->hw;
429428 size_t size;
430
- int i, err;
429
+ int i;
431430
432431 /* return error if iov_data is already populated */
433432 if (iov_data)
....@@ -453,6 +452,7 @@
453452 /* loop through vf_info structures initializing each entry */
454453 for (i = 0; i < num_vfs; i++) {
455454 struct fm10k_vf_info *vf_info = &iov_data->vf_info[i];
455
+ int err;
456456
457457 /* Record VF VSI value */
458458 vf_info->vsi = i + 1;
....@@ -518,6 +518,27 @@
518518 }
519519
520520 return num_vfs;
521
+}
522
+
523
+/**
524
+ * fm10k_iov_update_stats - Update stats for all VFs
525
+ * @interface: device private structure
526
+ *
527
+ * Updates the VF statistics for all enabled VFs. Expects to be called by
528
+ * fm10k_update_stats and assumes that locking via the __FM10K_UPDATING_STATS
529
+ * bit is already handled.
530
+ */
531
+void fm10k_iov_update_stats(struct fm10k_intfc *interface)
532
+{
533
+ struct fm10k_iov_data *iov_data = interface->iov_data;
534
+ struct fm10k_hw *hw = &interface->hw;
535
+ int i;
536
+
537
+ if (!iov_data)
538
+ return;
539
+
540
+ for (i = 0; i < iov_data->num_vfs; i++)
541
+ hw->iov.ops.update_stats(hw, iov_data->vf_info[i].stats, i);
521542 }
522543
523544 static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface,
....@@ -650,3 +671,30 @@
650671
651672 return 0;
652673 }
674
+
675
+int fm10k_ndo_get_vf_stats(struct net_device *netdev,
676
+ int vf_idx, struct ifla_vf_stats *stats)
677
+{
678
+ struct fm10k_intfc *interface = netdev_priv(netdev);
679
+ struct fm10k_iov_data *iov_data = interface->iov_data;
680
+ struct fm10k_hw *hw = &interface->hw;
681
+ struct fm10k_hw_stats_q *hw_stats;
682
+ u32 idx, qpp;
683
+
684
+ /* verify SR-IOV is active and that vf idx is valid */
685
+ if (!iov_data || vf_idx >= iov_data->num_vfs)
686
+ return -EINVAL;
687
+
688
+ qpp = fm10k_queues_per_pool(hw);
689
+ hw_stats = iov_data->vf_info[vf_idx].stats;
690
+
691
+ for (idx = 0; idx < qpp; idx++) {
692
+ stats->rx_packets += hw_stats[idx].rx_packets.count;
693
+ stats->tx_packets += hw_stats[idx].tx_packets.count;
694
+ stats->rx_bytes += hw_stats[idx].rx_bytes.count;
695
+ stats->tx_bytes += hw_stats[idx].tx_bytes.count;
696
+ stats->rx_dropped += hw_stats[idx].rx_drops.count;
697
+ }
698
+
699
+ return 0;
700
+}