From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4F3772BC5 for ; Wed, 7 Dec 2016 04:32:28 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 06 Dec 2016 19:32:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="909513285" Received: from dpdk26.sh.intel.com ([10.239.128.228]) by orsmga003.jf.intel.com with ESMTP; 06 Dec 2016 19:32:27 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Qi Zhang Date: Wed, 7 Dec 2016 11:31:53 +0800 Message-Id: <1481081535-37448-11-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1481081535-37448-1-git-send-email-wenzhuo.lu@intel.com> References: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> <1481081535-37448-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v2 10/32] net/i40e: implement ops for VF stats get/reset 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: , X-List-Received-Date: Wed, 07 Dec 2016 03:32:28 -0000 This patch implement vf_stats_get and vf_stats_reset ops for i40e. Signed-off-by: Qi Zhang --- 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