From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E018C76192 for ; Tue, 16 Jul 2019 09:29:09 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 868D921721 for ; Tue, 16 Jul 2019 09:29:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QESL/BRt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 868D921721 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB4191B957; Tue, 16 Jul 2019 11:28:49 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 56AFD2BF4 for ; Tue, 16 Jul 2019 11:28:38 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 58C0830C04A; Tue, 16 Jul 2019 02:28:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 58C0830C04A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563269313; bh=V9KKnXbE4u6iyoGIcOowjel6T63Qd6ltE0WcNJ1jx5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QESL/BRt57tKH2vgGt4M8X4pCRSKz0a6vLVHCT+Dbdzpf2HSy13GiQBCgwkwcs6d4 adlDFTxl81yqhXTbX8rmb5r7IfRob9GIXPhMFXgaufyZhaV43qD/sXFHcegFu0EnEC vYtkKZnBjdjGe1AMSWtVPJmZojrN/iop3DY1NpxE= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 8C9DDAC0749; Tue, 16 Jul 2019 02:28:31 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , Ajit Kumar Khaparde Date: Tue, 16 Jul 2019 14:58:12 +0530 Message-Id: <20190716092826.54276-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190716092826.54276-1-ajit.khaparde@broadcom.com> References: <20190712060622.76975-1-ajit.khaparde@broadcom.com> <20190716092826.54276-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 01/15] net/bnxt: fix extended port counter statistics 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" From: Kalesh AP 1. refactor stats allocation code to new routine 2. check for extended statistics support depends on "hwrm_spec_code" which is set in bnxt_hwrm_ver_get called later. Hence we were never querying extended port stats as flags field was not updated. Fixed this by moving the stats allocation after the call to bnxt_hwrm_ver_get. 3. we were incorrectly passing the host address used for port statistics to PORT_QSTATS_EXT command. Fixed this by passing the correct extended stats address. Fixes: f55e12f33416 ("net/bnxt: support extended port counters") Signed-off-by: Kalesh AP Reviewed-by: Ajit Kumar Khaparde -- v1->v2: Use PCI_PRI_FMT to format PCI address. --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 226 +++++++++++++++++---------------- drivers/net/bnxt/bnxt_hwrm.c | 7 +- 3 files changed, 125 insertions(+), 109 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 942da7ff0..45e7359b2 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -350,6 +350,7 @@ struct bnxt { #define BNXT_FLAG_TRUSTED_VF_EN (1 << 11) #define BNXT_FLAG_DFLT_VNIC_SET (1 << 12) #define BNXT_FLAG_THOR_CHIP (1 << 13) +#define BNXT_FLAG_EXT_STATS_SUPPORTED (1 << 29) #define BNXT_FLAG_NEW_RM (1 << 30) #define BNXT_FLAG_INIT_DONE (1U << 31) #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF)) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 14b69a480..cb50572a6 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3639,6 +3639,120 @@ int bnxt_alloc_ctx_mem(struct bnxt *bp) return 0; } +static int bnxt_alloc_stats_mem(struct bnxt *bp) +{ + struct rte_pci_device *pci_dev = bp->pdev; + char mz_name[RTE_MEMZONE_NAMESIZE]; + const struct rte_memzone *mz = NULL; + uint32_t total_alloc_len; + rte_iova_t mz_phys_addr; + + if (pci_dev->id.device_id == BROADCOM_DEV_ID_NS2) + return 0; + + snprintf(mz_name, RTE_MEMZONE_NAMESIZE, + "bnxt_"PCI_PRI_FMT"-%s", pci_dev->addr.domain, + pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function, "rx_port_stats"); + mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; + mz = rte_memzone_lookup(mz_name); + total_alloc_len = + RTE_CACHE_LINE_ROUNDUP(sizeof(struct rx_port_stats) + + sizeof(struct rx_port_stats_ext) + 512); + if (!mz) { + mz = rte_memzone_reserve(mz_name, total_alloc_len, + SOCKET_ID_ANY, + RTE_MEMZONE_2MB | + RTE_MEMZONE_SIZE_HINT_ONLY | + RTE_MEMZONE_IOVA_CONTIG); + if (mz == NULL) + return -ENOMEM; + } + memset(mz->addr, 0, mz->len); + mz_phys_addr = mz->iova; + if ((unsigned long)mz->addr == mz_phys_addr) { + PMD_DRV_LOG(WARNING, + "Memzone physical address same as virtual.\n"); + PMD_DRV_LOG(WARNING, + "Using rte_mem_virt2iova()\n"); + mz_phys_addr = rte_mem_virt2iova(mz->addr); + if (mz_phys_addr == 0) { + PMD_DRV_LOG(ERR, + "Can't map address to physical memory\n"); + return -ENOMEM; + } + } + + bp->rx_mem_zone = (const void *)mz; + bp->hw_rx_port_stats = mz->addr; + bp->hw_rx_port_stats_map = mz_phys_addr; + + snprintf(mz_name, RTE_MEMZONE_NAMESIZE, + "bnxt_"PCI_PRI_FMT"-%s", pci_dev->addr.domain, + pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function, "tx_port_stats"); + mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; + mz = rte_memzone_lookup(mz_name); + total_alloc_len = + RTE_CACHE_LINE_ROUNDUP(sizeof(struct tx_port_stats) + + sizeof(struct tx_port_stats_ext) + 512); + if (!mz) { + mz = rte_memzone_reserve(mz_name, + total_alloc_len, + SOCKET_ID_ANY, + RTE_MEMZONE_2MB | + RTE_MEMZONE_SIZE_HINT_ONLY | + RTE_MEMZONE_IOVA_CONTIG); + if (mz == NULL) + return -ENOMEM; + } + memset(mz->addr, 0, mz->len); + mz_phys_addr = mz->iova; + if ((unsigned long)mz->addr == mz_phys_addr) { + PMD_DRV_LOG(WARNING, + "Memzone physical address same as virtual\n"); + PMD_DRV_LOG(WARNING, + "Using rte_mem_virt2iova()\n"); + mz_phys_addr = rte_mem_virt2iova(mz->addr); + if (mz_phys_addr == 0) { + PMD_DRV_LOG(ERR, + "Can't map address to physical memory\n"); + return -ENOMEM; + } + } + + bp->tx_mem_zone = (const void *)mz; + bp->hw_tx_port_stats = mz->addr; + bp->hw_tx_port_stats_map = mz_phys_addr; + bp->flags |= BNXT_FLAG_PORT_STATS; + + /* Display extended statistics if FW supports it */ + if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_8_4 || + bp->hwrm_spec_code == HWRM_SPEC_CODE_1_9_0 || + !(bp->flags & BNXT_FLAG_EXT_STATS_SUPPORTED)) + return 0; + + bp->hw_rx_port_stats_ext = (void *) + ((uint8_t *)bp->hw_rx_port_stats + + sizeof(struct rx_port_stats)); + bp->hw_rx_port_stats_ext_map = bp->hw_rx_port_stats_map + + sizeof(struct rx_port_stats); + bp->flags |= BNXT_FLAG_EXT_RX_PORT_STATS; + + if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_9_2 || + bp->flags & BNXT_FLAG_EXT_STATS_SUPPORTED) { + bp->hw_tx_port_stats_ext = (void *) + ((uint8_t *)bp->hw_tx_port_stats + + sizeof(struct tx_port_stats)); + bp->hw_tx_port_stats_ext_map = + bp->hw_tx_port_stats_map + + sizeof(struct tx_port_stats); + bp->flags |= BNXT_FLAG_EXT_TX_PORT_STATS; + } + + return 0; +} + #define ALLOW_FUNC(x) \ { \ uint32_t arg = (x); \ @@ -3649,11 +3763,7 @@ static int bnxt_dev_init(struct rte_eth_dev *eth_dev) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - char mz_name[RTE_MEMZONE_NAMESIZE]; - const struct rte_memzone *mz = NULL; static int version_printed; - uint32_t total_alloc_len; - rte_iova_t mz_phys_addr; struct bnxt *bp; uint16_t mtu; int rc; @@ -3692,109 +3802,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - if (pci_dev->id.device_id != BROADCOM_DEV_ID_NS2) { - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, - "bnxt_%04x:%02x:%02x:%02x-%s", pci_dev->addr.domain, - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function, "rx_port_stats"); - mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; - mz = rte_memzone_lookup(mz_name); - total_alloc_len = RTE_CACHE_LINE_ROUNDUP( - sizeof(struct rx_port_stats) + - sizeof(struct rx_port_stats_ext) + - 512); - if (!mz) { - mz = rte_memzone_reserve(mz_name, total_alloc_len, - SOCKET_ID_ANY, - RTE_MEMZONE_2MB | - RTE_MEMZONE_SIZE_HINT_ONLY | - RTE_MEMZONE_IOVA_CONTIG); - if (mz == NULL) - return -ENOMEM; - } - memset(mz->addr, 0, mz->len); - mz_phys_addr = mz->iova; - if ((unsigned long)mz->addr == mz_phys_addr) { - PMD_DRV_LOG(INFO, - "Memzone physical address same as virtual using rte_mem_virt2iova()\n"); - mz_phys_addr = rte_mem_virt2iova(mz->addr); - if (mz_phys_addr == 0) { - PMD_DRV_LOG(ERR, - "unable to map address to physical memory\n"); - return -ENOMEM; - } - } - - bp->rx_mem_zone = (const void *)mz; - bp->hw_rx_port_stats = mz->addr; - bp->hw_rx_port_stats_map = mz_phys_addr; - - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, - "bnxt_%04x:%02x:%02x:%02x-%s", pci_dev->addr.domain, - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function, "tx_port_stats"); - mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; - mz = rte_memzone_lookup(mz_name); - total_alloc_len = RTE_CACHE_LINE_ROUNDUP( - sizeof(struct tx_port_stats) + - sizeof(struct tx_port_stats_ext) + - 512); - if (!mz) { - mz = rte_memzone_reserve(mz_name, - total_alloc_len, - SOCKET_ID_ANY, - RTE_MEMZONE_2MB | - RTE_MEMZONE_SIZE_HINT_ONLY | - RTE_MEMZONE_IOVA_CONTIG); - if (mz == NULL) - return -ENOMEM; - } - memset(mz->addr, 0, mz->len); - mz_phys_addr = mz->iova; - if ((unsigned long)mz->addr == mz_phys_addr) { - PMD_DRV_LOG(WARNING, - "Memzone physical address same as virtual.\n"); - PMD_DRV_LOG(WARNING, - "Using rte_mem_virt2iova()\n"); - mz_phys_addr = rte_mem_virt2iova(mz->addr); - if (mz_phys_addr == 0) { - PMD_DRV_LOG(ERR, - "unable to map address to physical memory\n"); - return -ENOMEM; - } - } - - bp->tx_mem_zone = (const void *)mz; - bp->hw_tx_port_stats = mz->addr; - bp->hw_tx_port_stats_map = mz_phys_addr; - - bp->flags |= BNXT_FLAG_PORT_STATS; - - /* Display extended statistics if FW supports it */ - if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_8_4 || - bp->hwrm_spec_code == HWRM_SPEC_CODE_1_9_0) - goto skip_ext_stats; - - bp->hw_rx_port_stats_ext = (void *) - ((uint8_t *)bp->hw_rx_port_stats + - sizeof(struct rx_port_stats)); - bp->hw_rx_port_stats_ext_map = bp->hw_rx_port_stats_map + - sizeof(struct rx_port_stats); - bp->flags |= BNXT_FLAG_EXT_RX_PORT_STATS; - - - if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_9_2) { - bp->hw_tx_port_stats_ext = (void *) - ((uint8_t *)bp->hw_tx_port_stats + - sizeof(struct tx_port_stats)); - bp->hw_tx_port_stats_ext_map = - bp->hw_tx_port_stats_map + - sizeof(struct tx_port_stats); - bp->flags |= BNXT_FLAG_EXT_TX_PORT_STATS; - } - } - -skip_ext_stats: rc = bnxt_alloc_hwrm_resources(bp); if (rc) { PMD_DRV_LOG(ERR, @@ -3823,6 +3830,11 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) PMD_DRV_LOG(ERR, "hwrm query capability failure rc: %x\n", rc); goto error_free; } + + rc = bnxt_alloc_stats_mem(bp); + if (rc) + goto error_free; + if (bp->max_tx_rings == 0) { PMD_DRV_LOG(ERR, "No TX rings available!\n"); rc = -EBUSY; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 8f0d33dca..f691922bd 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -611,6 +611,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) } } + if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED) + bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED; + HWRM_UNLOCK(); return rc; @@ -4495,13 +4498,13 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp) req.port_id = rte_cpu_to_le_16(pf->port_id); if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) { req.tx_stat_host_addr = - rte_cpu_to_le_64(bp->hw_tx_port_stats_map); + rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map); req.tx_stat_size = rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext)); } if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) { req.rx_stat_host_addr = - rte_cpu_to_le_64(bp->hw_rx_port_stats_map); + rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map); req.rx_stat_size = rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext)); } -- 2.20.1 (Apple Git-117)