DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF
@ 2017-02-23 18:27 Qi Zhang
  2017-03-16 16:03 ` Thomas Monjalon
  2017-04-01  0:50 ` Zhang, Helin
  0 siblings, 2 replies; 15+ messages in thread
From: Qi Zhang @ 2017-02-23 18:27 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev, Qi Zhang

The patch implements the dev_ops "stats_reset" for VF.

Signed-off-by: Qi Zhang <qi.z.zhang@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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-04-12 11:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 18:27 [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF Qi Zhang
2017-03-16 16:03 ` Thomas Monjalon
2017-03-17  2:06   ` Zhang, Qi Z
2017-03-17  3:28   ` Zhang, Helin
2017-03-17  8:02     ` Thomas Monjalon
2017-03-17  9:45       ` Zhang, Helin
2017-03-17 10:15         ` Thomas Monjalon
2017-03-17 20:14           ` Vincent Jardin
2017-03-17 23:03             ` Thomas Monjalon
2017-03-18 10:34               ` Vincent Jardin
2017-03-20  2:47           ` Zhang, Helin
2017-03-20  9:14             ` Thomas Monjalon
2017-03-22  9:48               ` Zhang, Helin
2017-04-01  0:50 ` Zhang, Helin
     [not found]   ` <039ED4275CED7440929022BC67E706115307CC65@SHSMSX103.ccr.corp.intel.com>
2017-04-12 11:19     ` Zhang, Qi Z

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).