From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 123922C0A for ; Fri, 2 Dec 2016 09:21:23 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 02 Dec 2016 00:21:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,285,1477983600"; d="scan'208";a="1067004033" Received: from dpdk26.sh.intel.com ([10.239.128.228]) by orsmga001.jf.intel.com with ESMTP; 02 Dec 2016 00:21:22 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Qi Zhang Date: Thu, 1 Dec 2016 19:11:51 -0500 Message-Id: <1480637533-37425-10-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> References: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH 09/31] rte: add APIs 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: Fri, 02 Dec 2016 08:21:24 -0000 This patch add below two APIs so that VF statistics can be get/clear from PF side. rte_eth_vf_stats_get. rte_eth_vf_stats_reset. Signed-off-by: Qi Zhang --- lib/librte_ether/rte_ethdev.c | 47 +++++++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 47 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fde8112..03b4edf 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3270,3 +3270,50 @@ int rte_eth_dev_bypass_init(uint8_t port_id) -ENOTSUP); return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en); } + +int +rte_eth_vf_stats_get(uint8_t port_id, + uint16_t vf, + struct rte_eth_stats *stats) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vf_stats_get, -ENOTSUP); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("Get VF Stats:port %d: " + "invalid vf id=%d\n", port_id, vf); + return -EINVAL; + } + + return (*dev->dev_ops->vf_stats_get)(dev, vf, stats); +} + +int +rte_eth_vf_stats_reset(uint8_t port_id, + uint16_t vf) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vf_stats_reset, -ENOTSUP); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("Reset VF Stats:port %d: " + "invalid vf id=%d\n", port_id, vf); + return -EINVAL; + } + + return (*dev->dev_ops->vf_stats_reset)(dev, vf); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 9678179..8b564ee 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1271,6 +1271,15 @@ typedef int (*eth_set_vf_vlan_filter_t)(struct rte_eth_dev *dev, uint8_t vlan_on); /**< @internal Set VF VLAN pool filter */ +typedef int (*eth_vf_stats_get)(struct rte_eth_dev *dev, + uint16_t vf, + struct rte_eth_stats *stats); +/**< @internal Get VF statistics */ + +typedef int (*eth_vf_stats_reset)(struct rte_eth_dev *dev, + uint16_t vf); +/**< @internal Clear VF statistics */ + typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); @@ -1483,6 +1492,8 @@ struct eth_dev_ops { eth_set_vf_rx_t set_vf_rx; /**< enable/disable a VF receive */ eth_set_vf_tx_t set_vf_tx; /**< enable/disable a VF transmit */ eth_set_vf_vlan_filter_t set_vf_vlan_filter; /**< Set VF VLAN filter */ + eth_vf_stats_get vf_stats_get; /**< Get VF's statistics */ + eth_vf_stats_reset vf_stats_reset; /**< Reset VF's statistics */ /** Add UDP tunnel port. */ eth_udp_tunnel_port_add_t udp_tunnel_port_add; /** Del UDP tunnel port. */ @@ -4379,6 +4390,42 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, */ int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev); +/** + * Get VF's statistics + * + * @param port_id + * pointer to port identifier of the device + * @param vf + * VF id + * @param stats + * A pointer to a structure of type *rte_eth_stats* to be filled with + * the values of device counters for the following set of statistics: + * - *ipackets* with the total of successfully received packets. + * - *opackets* with the total of successfully transmitted packets. + * - *ibytes* with the total of successfully received bytes. + * - *obytes* with the total of successfully transmitted bytes. + * - *ierrors* with the total of erroneous received packets. + * - *oerrors* with the total of failed transmitted packets. + * @return + * Zero if successful. Non-zero otherwise. + */ +int rte_eth_vf_stats_get(uint8_t port_id, + uint16_t vf, + struct rte_eth_stats *stats); + +/** + * Clear VF's statistics + * + * @param port_id + * pointer to port identifier of the device + * @param vf + * vf id + * @return + * Zero if successful. Non-zero otherwise. + */ +int rte_eth_vf_stats_reset(uint8_t port_id, + uint16_t vf); + #ifdef __cplusplus } #endif -- 1.9.3