From patchwork Thu Feb 23 18:27:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 20714 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 5B76C2BB2; Fri, 24 Feb 2017 02:31:44 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 7C2DE2BAA for ; Fri, 24 Feb 2017 02:31:42 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2017 17:31:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,199,1484035200"; d="scan'208"; a="1114916230" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.129.189]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2017 17:31:40 -0800 From: Qi Zhang To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org, Qi Zhang Date: Thu, 23 Feb 2017 13:27:01 -0500 Message-Id: <1487874421-11934-1-git-send-email-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The patch implements the dev_ops "stats_reset" for VF. Signed-off-by: Qi Zhang Nacked-by: Qi Zhang --- 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. */