[dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF

Qi Zhang qi.z.zhang at intel.com
Thu Feb 23 19:27:01 CET 2017


The patch implements the dev_ops "stats_reset" for VF.

Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 34 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_pf.c        | 25 +++++++++++++++++++++++++
 drivers/net/i40e/i40e_pf.h        |  1 +
 3 files changed, 60 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 55fd344..5155b25 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -110,6 +110,7 @@ static int i40evf_dev_link_update(struct rte_eth_dev *dev,
 				  __rte_unused int wait_to_complete);
 static void i40evf_dev_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *stats);
+static void i40evf_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
 				 struct rte_eth_xstat *xstats, unsigned n);
 static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev,
@@ -199,6 +200,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.allmulticast_disable = i40evf_dev_allmulticast_disable,
 	.link_update          = i40evf_dev_link_update,
 	.stats_get            = i40evf_dev_stats_get,
+	.stats_reset          = i40evf_dev_stats_reset,
 	.xstats_get           = i40evf_dev_xstats_get,
 	.xstats_get_names     = i40evf_dev_xstats_get_names,
 	.xstats_reset         = i40evf_dev_xstats_reset,
@@ -988,6 +990,27 @@ i40evf_get_statistics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	return 0;
 }
 
+static int
+i40evf_reset_statistics(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	int err;
+	struct vf_cmd_info args;
+	u16 vsi_id = vf->vsi_res->vsi_id;
+
+	args.ops = (enum i40e_virtchnl_ops)I40E_VIRTCHNL_OP_RESET_STATS;
+	args.in_args = (uint8_t *)&vsi_id;
+	args.in_args_size = sizeof(vsi_id);
+	args.out_buffer = vf->aq_resp;
+	args.out_size = I40E_AQ_BUF_SZ;
+
+	err = i40evf_execute_vf_cmd(dev, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "fail to execute command CFG_VLAN_OFFLOAD");
+
+	return err;
+}
+
 static void
 i40evf_dev_xstats_reset(struct rte_eth_dev *dev)
 {
@@ -2310,6 +2333,17 @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 }
 
 static void
+i40evf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	/* only DPDK PF support this */
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
+		if (i40evf_reset_statistics(dev))
+			PMD_DRV_LOG(ERR, "Reset statistics failed");
+	}
+}
+
+static void
 i40evf_dev_close(struct rte_eth_dev *dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index f771dfb..62d2bfd 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1155,6 +1155,27 @@ i40e_pf_host_process_cmd_cfg_pvid(struct i40e_pf_vf *vf,
 	return ret;
 }
 
+static int
+i40e_pf_host_process_cmd_reset_stats(struct i40e_pf_vf *vf,
+					bool b_op)
+{
+	vf->vsi->offset_loaded = false;
+	i40e_update_vsi_stats(vf->vsi);
+
+	if (b_op)
+		i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS,
+					    I40E_SUCCESS,
+					    NULL,
+					    0);
+	else
+		i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS,
+					    I40E_NOT_SUPPORTED,
+					    NULL,
+					    0);
+
+	return I40E_SUCCESS;
+}
+
 void
 i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf)
 {
@@ -1300,6 +1321,10 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 		PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
 		i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op);
 		break;
+	case I40E_VIRTCHNL_OP_RESET_STATS:
+		PMD_DRV_LOG(INFO, "OP_RESET_STATS received");
+		i40e_pf_host_process_cmd_reset_stats(vf, b_op);
+		break;
 	/* Don't add command supported below, which will
 	 * return an error code.
 	 */
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index b4c2287..69ef873 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -58,6 +58,7 @@ enum i40e_virtchnl_ops_dpdk {
 						I40E_DPDK_OFFSET,
 	I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
 	I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+	I40E_VIRTCHNL_OP_RESET_STATS,
 };
 
 /* A structure to support extended info of a receive queue. */
-- 
2.7.4



More information about the dev mailing list