From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rnd-relay.smtp.broadcom.com (lpdvrndsmtp01.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 932127D0B for ; Thu, 1 Jun 2017 05:02:55 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.224.233]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 550A930C018; Wed, 31 May 2017 20:02:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 550A930C018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1496286174; bh=LWdnYW2E+S7mbBVPxuVLB2xPXhf8Bz69cHh/H3qs1a4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dkuS1XavlQsok9SBUeRr0jY0CQ2oiCmrooXlQR2F+nh/6NzUu6buY8p2BNSdV4qV4 OCajxYfbJiB9/9FxG62OOiR2RSTzUN8xiguaG5EhpXAiHbngAR4G4IMJWEhyob5cvl QMXAz8JyXuGTZ5pA2UbEaSkJrUGm4pFO4/lnnZzk= Received: from C02PT1RBG8WP.vpn.broadcom.net (unknown [10.10.118.254]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id DA1AF82061; Wed, 31 May 2017 20:02:52 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Stephen Hurd Date: Wed, 31 May 2017 22:02:28 -0500 Message-Id: <20170601030232.38677-23-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170601030232.38677-1-ajit.khaparde@broadcom.com> References: <5d0e287f-dfe9-3a41-695e-9af0d57d37c1@intel.com> <20170601030232.38677-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH v3 22/26] net/bnxt: add code to determine the Rx status of 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: , X-List-Received-Date: Thu, 01 Jun 2017 03:02:56 -0000 This patch adds code to determine the Rx status of a VF. It adds the rte_pmd_bnxt_get_vf_rx_status call, which calculates the VNIC count of the function to get the Rx status. Signed-off-by: Stephen Hurd Signed-off-by: Ajit Khaparde -- v1->v2: regroup related patches and incorporate other review comments v2->v3: - Rebasing to next-net tree - Use net/bnxt instead of just bnxt in patch subject - Add a protection against application calling the API for different vendor's port_id --- drivers/net/bnxt/bnxt_hwrm.c | 24 ++++++++++++++++++ drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/rte_pmd_bnxt.c | 42 +++++++++++++++++++++++++++++++ drivers/net/bnxt/rte_pmd_bnxt.h | 17 +++++++++++++ drivers/net/bnxt/rte_pmd_bnxt_version.map | 1 + 5 files changed, 85 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 6ea31ca..721e652 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -2626,6 +2626,30 @@ int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on) return rc; } +static void bnxt_vnic_count(struct bnxt_vnic_info *vnic, void *cbdata) +{ + uint32_t *count = cbdata; + + if (vnic->func_default) + *count = *count + 1; +} + +static int bnxt_vnic_count_hwrm_stub(struct bnxt *bp __rte_unused, + struct bnxt_vnic_info *vnic __rte_unused) +{ + return 0; +} + +int bnxt_vf_default_vnic_count(struct bnxt *bp, uint16_t vf) +{ + uint32_t count = 0; + + bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf, bnxt_vnic_count, + &count, bnxt_vnic_count_hwrm_stub); + + return count; +} + static int bnxt_hwrm_func_vf_vnic_query(struct bnxt *bp, uint16_t vf, uint16_t *vnic_ids) { diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 5aaf947..01e72fa 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -141,6 +141,7 @@ int bnxt_hwrm_port_clr_stats(struct bnxt *bp); int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on); int bnxt_hwrm_port_led_qcaps(struct bnxt *bp); int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf); +int bnxt_vf_default_vnic_count(struct bnxt *bp, uint16_t vf); int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf, void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata, int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic)); diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index d9e97ab..a4bae26 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt.c +++ b/drivers/net/bnxt/rte_pmd_bnxt.c @@ -510,6 +510,48 @@ int rte_pmd_bnxt_reset_vf_stats(uint8_t port, return bnxt_hwrm_func_clr_stats(bp, bp->pf.first_vf_id + vf_id); } +int rte_pmd_bnxt_get_vf_rx_status(uint8_t port, uint16_t vf_id) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + struct bnxt *bp; + + dev = &rte_eth_devices[port]; + if (!is_bnxt_supported(dev)) + return -ENOTSUP; + + rte_eth_dev_info_get(port, &dev_info); + bp = (struct bnxt *)dev->data->dev_private; + + if (vf_id >= dev_info.max_vfs) + return -EINVAL; + + if (!BNXT_PF(bp)) { + RTE_LOG(ERR, PMD, + "Attempt to query VF %d RX stats on non-PF port %d!\n", + vf_id, port); + return -ENOTSUP; + } + + return bnxt_vf_default_vnic_count(bp, vf_id); +} + +int rte_pmd_bnxt_get_tx_drop_count(uint8_t port, uint64_t *count) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + struct bnxt *bp; + + dev = &rte_eth_devices[port]; + if (!is_bnxt_supported(dev)) + return -ENOTSUP; + + rte_eth_dev_info_get(port, &dev_info); + bp = (struct bnxt *)dev->data->dev_private; + + return bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, count); +} + int rte_pmd_bnxt_get_vf_tx_drop_count(uint8_t port, uint16_t vf_id, uint64_t *count) { diff --git a/drivers/net/bnxt/rte_pmd_bnxt.h b/drivers/net/bnxt/rte_pmd_bnxt.h index eef5212..e69910e 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt.h +++ b/drivers/net/bnxt/rte_pmd_bnxt.h @@ -217,6 +217,23 @@ int rte_pmd_bnxt_reset_vf_stats(uint8_t port, */ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on); + +/** + * Returns the number of default RX queues on a VF + * + * @param port + * The port identifier of the Ethernet device. + * @param vf + * VF id. + * @return + * - Non-negative value - Number of default RX queues + * - (-EINVAL) if bad parameter. + * - (-ENOTSUP) if on a function without VFs + * - (-ENOMEM) on an allocation failure + * - (-1) firmware interface error + */ +int rte_pmd_bnxt_get_vf_rx_status(uint8_t port, uint16_t vf_id); + /** * Queries the TX drop counter for the function * diff --git a/drivers/net/bnxt/rte_pmd_bnxt_version.map b/drivers/net/bnxt/rte_pmd_bnxt_version.map index f0eda7b..c68c125 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt_version.map +++ b/drivers/net/bnxt/rte_pmd_bnxt_version.map @@ -3,6 +3,7 @@ DPDK_17.08 { rte_pmd_bnxt_set_tx_loopback; rte_pmd_bnxt_set_all_queues_drop_en; + rte_pmd_bnxt_get_vf_rx_status; rte_pmd_bnxt_set_vf_mac_addr; rte_pmd_bnxt_set_vf_mac_anti_spoof; rte_pmd_bnxt_set_vf_rate_limit; -- 2.10.1 (Apple Git-78)