[dpdk-dev] [PATCH v2 10/32] net/i40e: implement ops for VF stats get/reset
Wenzhuo Lu
wenzhuo.lu at intel.com
Wed Dec 7 04:31:53 CET 2016
This patch implement vf_stats_get and vf_stats_reset ops for i40e.
Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 88ff6aa..5c9d6d1 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -462,6 +462,13 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
static int i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+static int i40e_vf_stats_get(struct rte_eth_dev *dev,
+ uint16_t vf,
+ struct rte_eth_stats *stats);
+
+static int i40e_vf_stats_reset(struct rte_eth_dev *dev,
+ uint16_t vf);
+
static const struct rte_pci_id pci_id_i40e_map[] = {
{ RTE_PCI_DEVICE(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_XL710) },
{ RTE_PCI_DEVICE(I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QEMU) },
@@ -554,6 +561,8 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
.get_eeprom = i40e_get_eeprom,
.mac_addr_set = i40e_set_default_mac_addr,
.mtu_set = i40e_dev_mtu_set,
+ .vf_stats_get = i40e_vf_stats_get,
+ .vf_stats_reset = i40e_vf_stats_reset,
};
/* store statistics names and its offset in stats structure */
@@ -10229,3 +10238,58 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
return ret;
}
+
+static int
+i40e_vf_stats_get(struct rte_eth_dev *dev,
+ uint16_t vf,
+ struct rte_eth_stats *stats)
+{
+ struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+ struct i40e_vsi *vsi;
+
+ int ret = 0;
+
+ if (pf->vf_num <= vf) {
+ PMD_DRV_LOG(ERR, "Invalid VF id %d\n", vf);
+ return -EINVAL;
+ }
+
+ vsi = pf->vfs[vf].vsi;
+
+ i40e_update_vsi_stats(vsi);
+
+ stats->ipackets = vsi->eth_stats.rx_unicast +
+ vsi->eth_stats.rx_multicast +
+ vsi->eth_stats.rx_broadcast;
+ stats->opackets = vsi->eth_stats.tx_unicast +
+ vsi->eth_stats.tx_multicast +
+ vsi->eth_stats.tx_broadcast;
+ stats->ibytes = vsi->eth_stats.rx_bytes;
+ stats->obytes = vsi->eth_stats.tx_bytes;
+ stats->ierrors = vsi->eth_stats.rx_discards;
+ stats->oerrors = vsi->eth_stats.tx_errors + vsi->eth_stats.tx_discards;
+
+ return ret;
+}
+
+static int
+i40e_vf_stats_reset(struct rte_eth_dev *dev,
+ uint16_t vf)
+{
+ struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+ struct i40e_vsi *vsi;
+
+ int ret = 0;
+
+ if (pf->vf_num <= vf) {
+ PMD_DRV_LOG(ERR, "Invalid VF id %d\n", vf);
+ return -EINVAL;
+ }
+
+ vsi = pf->vfs[vf].vsi;
+
+ vsi->offset_loaded = false;
+ i40e_update_vsi_stats(vsi);
+
+ return ret;
+}
--
1.9.3
More information about the dev
mailing list