From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EACBDA0C4C for ; Mon, 12 Jul 2021 15:08:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D794E4069D; Mon, 12 Jul 2021 15:08:26 +0200 (CEST) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id 4092D4069D for ; Mon, 12 Jul 2021 15:08:25 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id v5so25547230wrt.3 for ; Mon, 12 Jul 2021 06:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+KmrvzcFT+Zq1q2g/RmM/nO9BK2oxyPLJ5+/4tSeTEo=; b=feX5icnfnlZhOXJGd42k4xxJKzx6shkNj0nmt4lmVRB8CfnXPYagcDdZXe+x0n7Da1 Ht3VzTBJ971Dm2yVlz1iqZpRIBRxXz1LdCqvQoKUU++YsXYRP1kwDR3f9foIP9dlt8vl NCZqhAj2wMpnq8LSuDxicf/Uav1UrRNUEJx+hQJxxHyNqLXKjA05T8emykTJY+oMzHdP ahjU2I0D7mynOlOgeGPaiAVUoN1GLXljXSR71vkHriizHUlD8e/gOdahW8ikungowSgd DJypFDpYj4XD3NnWJR3eb1X72rtGhqFkOz6FZLmTzoNlXav2xEFTikA5SmZ4Xq0tWXxp c2oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+KmrvzcFT+Zq1q2g/RmM/nO9BK2oxyPLJ5+/4tSeTEo=; b=e8IWp4T3MkF4Yjzvjlxn1Rdo4/CpCsVDBsvCnV0MmGl7fhHXEyuwOFJNPhkbjqviVt xUhyqrtOUPovfgkm77obaPPXiFJHBpD0/E0GlHSpGyKE9aiIDZPRWvIzDyto1W3CJdYL hlmUCuqUCoyQdbFZhxGdGySEd5JB0+XsXhKpK7jqjBXuqRe9uW3RwQw0VpUavZ3yNlxI IYBvPDAqOnRuiIm8t5Uiq3iAeMHB710CLuqALkKPk5+Nzlu9pakiP0ELd1VEJT1XWlyD jM3qtwIPmGvPtp/wKp/PMW54hnL7OMvgEQDHmJ/h7AVPBT5w7ZIlLQQI2f6xO9chK8Iu Ymjg== X-Gm-Message-State: AOAM5305MDBx044K45HIp/Joy351Aymg1XBwkNiqhY+YaQATq5zWxcRP edoBSSmL9OJLMBGYoWn3duM= X-Google-Smtp-Source: ABdhPJzjIAYeDeydryzFOHy22kEltrfD2OuDJL0/TfBQ0meuI+a+7ROljf2PjKkzmCwMPwnhhSSTpA== X-Received: by 2002:adf:ef05:: with SMTP id e5mr27513669wro.232.1626095305021; Mon, 12 Jul 2021 06:08:25 -0700 (PDT) Received: from localhost ([2a01:4b00:f41a:3600:360b:9754:2e3a:c344]) by smtp.gmail.com with ESMTPSA id p11sm13348609wro.78.2021.07.12.06.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 06:08:15 -0700 (PDT) From: luca.boccassi@gmail.com To: Somnath Kotur Cc: Lance Richardson , Kalesh AP , Ajit Khaparde , dpdk stable Date: Mon, 12 Jul 2021 14:04:02 +0100 Message-Id: <20210712130551.2462159-7-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210712130551.2462159-1-luca.boccassi@gmail.com> References: <20210712130551.2462159-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: workaround spurious zero stats in Thor' has been queued to stable release 20.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/14/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/47b40639d903f87fb2e71ec816898eb411e2c4e4 Thanks. Luca Boccassi --- >From 47b40639d903f87fb2e71ec816898eb411e2c4e4 Mon Sep 17 00:00:00 2001 From: Somnath Kotur Date: Mon, 31 May 2021 11:23:01 +0530 Subject: [PATCH] net/bnxt: workaround spurious zero stats in Thor [ upstream commit 219842b9990c2a3a426c14c7911a44d2cb9b6fdf ] There is a HW bug that can result in certain stats being reported as zero. Workaround this by ignoring stats with a value of zero based on the previously stored snapshot of the same stat. This bug mainly manifests in the output of func_qstats as FW aggregrates each ring's stat value to give the per function stat and if one of them is zero, the per function stat value ends up being lower than the previous snapshot which shows up as a zero PPS value in testpmd. Eliminate invocation of func_qstats and aggregate the per-ring stat values in the driver itself to derive the func_qstats output post accounting for the spurious zero stat value. Bugzilla ID: 641 Fixes: f8168ca0e690 ("net/bnxt: support thor controller") Signed-off-by: Somnath Kotur Reviewed-by: Lance Richardson Reviewed-by: Kalesh AP Acked-by: Ajit Khaparde --- drivers/net/bnxt/bnxt.h | 45 ++++++++++++ drivers/net/bnxt/bnxt_ethdev.c | 37 ++++++++++ drivers/net/bnxt/bnxt_hwrm.c | 108 +++++++++++++++++++++++---- drivers/net/bnxt/bnxt_hwrm.h | 5 +- drivers/net/bnxt/bnxt_stats.c | 129 ++++++++++++++++++++++++++++++--- 5 files changed, 294 insertions(+), 30 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 0fb195b656..f85409878c 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -605,6 +605,49 @@ struct bnxt_flow_stat_info { struct bnxt_ctx_mem_buf_info tx_fc_out_tbl; }; +struct bnxt_ring_stats { + /* Number of transmitted unicast packets */ + uint64_t tx_ucast_pkts; + /* Number of transmitted multicast packets */ + uint64_t tx_mcast_pkts; + /* Number of transmitted broadcast packets */ + uint64_t tx_bcast_pkts; + /* Number of packets discarded in transmit path */ + uint64_t tx_discard_pkts; + /* Number of packets in transmit path with error */ + uint64_t tx_error_pkts; + /* Number of transmitted bytes for unicast traffic */ + uint64_t tx_ucast_bytes; + /* Number of transmitted bytes for multicast traffic */ + uint64_t tx_mcast_bytes; + /* Number of transmitted bytes for broadcast traffic */ + uint64_t tx_bcast_bytes; + /* Number of received unicast packets */ + uint64_t rx_ucast_pkts; + /* Number of received multicast packets */ + uint64_t rx_mcast_pkts; + /* Number of received broadcast packets */ + uint64_t rx_bcast_pkts; + /* Number of packets discarded in receive path */ + uint64_t rx_discard_pkts; + /* Number of packets in receive path with errors */ + uint64_t rx_error_pkts; + /* Number of received bytes for unicast traffic */ + uint64_t rx_ucast_bytes; + /* Number of received bytes for multicast traffic */ + uint64_t rx_mcast_bytes; + /* Number of received bytes for broadcast traffic */ + uint64_t rx_bcast_bytes; + /* Number of aggregated unicast packets */ + uint64_t rx_agg_pkts; + /* Number of aggregated unicast bytes */ + uint64_t rx_agg_bytes; + /* Number of aggregation events */ + uint64_t rx_agg_events; + /* Number of aborted aggregations */ + uint64_t rx_agg_aborts; +}; + struct bnxt { void *bar0; @@ -808,6 +851,8 @@ struct bnxt { uint8_t flow_xstat; uint16_t max_num_kflows; uint16_t tx_cfa_action; + struct bnxt_ring_stats *prev_rx_ring_stats; + struct bnxt_ring_stats *prev_tx_ring_stats; }; static diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 1498f4a653..35753e33e7 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -696,6 +696,38 @@ static int bnxt_update_phy_setting(struct bnxt *bp) return rc; } +static void bnxt_free_prev_ring_stats(struct bnxt *bp) +{ + rte_free(bp->prev_rx_ring_stats); + rte_free(bp->prev_tx_ring_stats); + + bp->prev_rx_ring_stats = NULL; + bp->prev_tx_ring_stats = NULL; +} + +static int bnxt_alloc_prev_ring_stats(struct bnxt *bp) +{ + bp->prev_rx_ring_stats = rte_zmalloc("bnxt_prev_rx_ring_stats", + sizeof(struct bnxt_ring_stats) * + bp->rx_cp_nr_rings, + 0); + if (bp->prev_rx_ring_stats == NULL) + return -ENOMEM; + + bp->prev_tx_ring_stats = rte_zmalloc("bnxt_prev_tx_ring_stats", + sizeof(struct bnxt_ring_stats) * + bp->tx_cp_nr_rings, + 0); + if (bp->prev_tx_ring_stats == NULL) + goto error; + + return 0; + +error: + bnxt_free_prev_ring_stats(bp); + return -ENOMEM; +} + static int bnxt_start_nic(struct bnxt *bp) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev); @@ -1435,6 +1467,7 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) bnxt_shutdown_nic(bp); bnxt_hwrm_if_change(bp, false); + bnxt_free_prev_ring_stats(bp); rte_free(bp->mark_table); bp->mark_table = NULL; @@ -1489,6 +1522,10 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) if (rc) goto error; + rc = bnxt_alloc_prev_ring_stats(bp); + if (rc) + goto error; + eth_dev->data->dev_started = 1; bnxt_link_update_op(eth_dev, 1); diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 5ed38c9427..4b59c5bfa4 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -4145,8 +4145,20 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id, return rc; } -int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx, - struct rte_eth_stats *stats, uint8_t rx) +static void bnxt_update_prev_stat(uint64_t *cntr, uint64_t *prev_cntr) +{ + /* One of the HW stat values that make up this counter was zero as + * returned by HW in this iteration, so use the previous + * iteration's counter value + */ + if (*prev_cntr && *cntr == 0) + *cntr = *prev_cntr; + else + *prev_cntr = *cntr; +} + +int bnxt_hwrm_ring_stats(struct bnxt *bp, uint32_t cid, int idx, + struct bnxt_ring_stats *ring_stats, bool rx) { int rc = 0; struct hwrm_stat_ctx_query_input req = {.req_type = 0}; @@ -4161,21 +4173,85 @@ int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx, HWRM_CHECK_RESULT(); if (rx) { - stats->q_ipackets[idx] = rte_le_to_cpu_64(resp->rx_ucast_pkts); - stats->q_ipackets[idx] += rte_le_to_cpu_64(resp->rx_mcast_pkts); - stats->q_ipackets[idx] += rte_le_to_cpu_64(resp->rx_bcast_pkts); - stats->q_ibytes[idx] = rte_le_to_cpu_64(resp->rx_ucast_bytes); - stats->q_ibytes[idx] += rte_le_to_cpu_64(resp->rx_mcast_bytes); - stats->q_ibytes[idx] += rte_le_to_cpu_64(resp->rx_bcast_bytes); - stats->q_errors[idx] = rte_le_to_cpu_64(resp->rx_discard_pkts); - stats->q_errors[idx] += rte_le_to_cpu_64(resp->rx_error_pkts); + struct bnxt_ring_stats *prev_stats = &bp->prev_rx_ring_stats[idx]; + + ring_stats->rx_ucast_pkts = rte_le_to_cpu_64(resp->rx_ucast_pkts); + bnxt_update_prev_stat(&ring_stats->rx_ucast_pkts, + &prev_stats->rx_ucast_pkts); + + ring_stats->rx_mcast_pkts = rte_le_to_cpu_64(resp->rx_mcast_pkts); + bnxt_update_prev_stat(&ring_stats->rx_mcast_pkts, + &prev_stats->rx_mcast_pkts); + + ring_stats->rx_bcast_pkts = rte_le_to_cpu_64(resp->rx_bcast_pkts); + bnxt_update_prev_stat(&ring_stats->rx_bcast_pkts, + &prev_stats->rx_bcast_pkts); + + ring_stats->rx_ucast_bytes = rte_le_to_cpu_64(resp->rx_ucast_bytes); + bnxt_update_prev_stat(&ring_stats->rx_ucast_bytes, + &prev_stats->rx_ucast_bytes); + + ring_stats->rx_mcast_bytes = rte_le_to_cpu_64(resp->rx_mcast_bytes); + bnxt_update_prev_stat(&ring_stats->rx_mcast_bytes, + &prev_stats->rx_mcast_bytes); + + ring_stats->rx_bcast_bytes = rte_le_to_cpu_64(resp->rx_bcast_bytes); + bnxt_update_prev_stat(&ring_stats->rx_bcast_bytes, + &prev_stats->rx_bcast_bytes); + + ring_stats->rx_discard_pkts = rte_le_to_cpu_64(resp->rx_discard_pkts); + bnxt_update_prev_stat(&ring_stats->rx_discard_pkts, + &prev_stats->rx_discard_pkts); + + ring_stats->rx_error_pkts = rte_le_to_cpu_64(resp->rx_error_pkts); + bnxt_update_prev_stat(&ring_stats->rx_error_pkts, + &prev_stats->rx_error_pkts); + + ring_stats->rx_agg_pkts = rte_le_to_cpu_64(resp->rx_agg_pkts); + bnxt_update_prev_stat(&ring_stats->rx_agg_pkts, + &prev_stats->rx_agg_pkts); + + ring_stats->rx_agg_bytes = rte_le_to_cpu_64(resp->rx_agg_bytes); + bnxt_update_prev_stat(&ring_stats->rx_agg_bytes, + &prev_stats->rx_agg_bytes); + + ring_stats->rx_agg_events = rte_le_to_cpu_64(resp->rx_agg_events); + bnxt_update_prev_stat(&ring_stats->rx_agg_events, + &prev_stats->rx_agg_events); + + ring_stats->rx_agg_aborts = rte_le_to_cpu_64(resp->rx_agg_aborts); + bnxt_update_prev_stat(&ring_stats->rx_agg_aborts, + &prev_stats->rx_agg_aborts); } else { - stats->q_opackets[idx] = rte_le_to_cpu_64(resp->tx_ucast_pkts); - stats->q_opackets[idx] += rte_le_to_cpu_64(resp->tx_mcast_pkts); - stats->q_opackets[idx] += rte_le_to_cpu_64(resp->tx_bcast_pkts); - stats->q_obytes[idx] = rte_le_to_cpu_64(resp->tx_ucast_bytes); - stats->q_obytes[idx] += rte_le_to_cpu_64(resp->tx_mcast_bytes); - stats->q_obytes[idx] += rte_le_to_cpu_64(resp->tx_bcast_bytes); + struct bnxt_ring_stats *prev_stats = &bp->prev_tx_ring_stats[idx]; + + ring_stats->tx_ucast_pkts = rte_le_to_cpu_64(resp->tx_ucast_pkts); + bnxt_update_prev_stat(&ring_stats->tx_ucast_pkts, + &prev_stats->tx_ucast_pkts); + + ring_stats->tx_mcast_pkts = rte_le_to_cpu_64(resp->tx_mcast_pkts); + bnxt_update_prev_stat(&ring_stats->tx_mcast_pkts, + &prev_stats->tx_mcast_pkts); + + ring_stats->tx_bcast_pkts = rte_le_to_cpu_64(resp->tx_bcast_pkts); + bnxt_update_prev_stat(&ring_stats->tx_bcast_pkts, + &prev_stats->tx_bcast_pkts); + + ring_stats->tx_ucast_bytes = rte_le_to_cpu_64(resp->tx_ucast_bytes); + bnxt_update_prev_stat(&ring_stats->tx_ucast_bytes, + &prev_stats->tx_ucast_bytes); + + ring_stats->tx_mcast_bytes = rte_le_to_cpu_64(resp->tx_mcast_bytes); + bnxt_update_prev_stat(&ring_stats->tx_mcast_bytes, + &prev_stats->tx_mcast_bytes); + + ring_stats->tx_bcast_bytes = rte_le_to_cpu_64(resp->tx_bcast_bytes); + bnxt_update_prev_stat(&ring_stats->tx_bcast_bytes, + &prev_stats->tx_bcast_bytes); + + ring_stats->tx_discard_pkts = rte_le_to_cpu_64(resp->tx_discard_pkts); + bnxt_update_prev_stat(&ring_stats->tx_discard_pkts, + &prev_stats->tx_discard_pkts); } HWRM_UNLOCK(); diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index a67a17b3d4..6deae8faeb 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -165,9 +165,6 @@ int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); -int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx, - struct rte_eth_stats *stats, uint8_t rx); - int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); @@ -297,4 +294,6 @@ int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid, int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep); int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep); int bnxt_hwrm_poll_ver_get(struct bnxt *bp); +int bnxt_hwrm_ring_stats(struct bnxt *bp, uint32_t cid, int idx, + struct bnxt_ring_stats *stats, bool rx); #endif diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 0cf3ee77e3..4e67fdf9f2 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -506,8 +506,47 @@ void bnxt_free_stats(struct bnxt *bp) } } +static void bnxt_fill_rte_eth_stats(struct rte_eth_stats *stats, + struct bnxt_ring_stats *ring_stats, + unsigned int i, bool rx) +{ + if (rx) { + stats->q_ipackets[i] = ring_stats->rx_ucast_pkts; + stats->q_ipackets[i] += ring_stats->rx_mcast_pkts; + stats->q_ipackets[i] += ring_stats->rx_bcast_pkts; + + stats->ipackets += stats->q_ipackets[i]; + + stats->q_ibytes[i] = ring_stats->rx_ucast_bytes; + stats->q_ibytes[i] += ring_stats->rx_mcast_bytes; + stats->q_ibytes[i] += ring_stats->rx_bcast_bytes; + + stats->ibytes += stats->q_ibytes[i]; + + stats->q_errors[i] = ring_stats->rx_discard_pkts; + stats->q_errors[i] += ring_stats->rx_error_pkts; + + stats->imissed += ring_stats->rx_discard_pkts; + stats->ierrors += ring_stats->rx_error_pkts; + } else { + stats->q_opackets[i] = ring_stats->tx_ucast_pkts; + stats->q_opackets[i] += ring_stats->tx_mcast_pkts; + stats->q_opackets[i] += ring_stats->tx_bcast_pkts; + + stats->opackets += stats->q_opackets[i]; + + stats->q_obytes[i] = ring_stats->tx_ucast_bytes; + stats->q_obytes[i] += ring_stats->tx_mcast_bytes; + stats->q_obytes[i] += ring_stats->tx_bcast_bytes; + + stats->obytes += stats->q_obytes[i]; + + stats->oerrors += ring_stats->tx_discard_pkts; + } +} + int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, - struct rte_eth_stats *bnxt_stats) + struct rte_eth_stats *bnxt_stats) { int rc = 0; unsigned int i; @@ -527,11 +566,14 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, for (i = 0; i < num_q_stats; i++) { struct bnxt_rx_queue *rxq = bp->rx_queues[i]; struct bnxt_cp_ring_info *cpr = rxq->cp_ring; + struct bnxt_ring_stats ring_stats = {0}; - rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, - bnxt_stats, 1); + rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i, + &ring_stats, true); if (unlikely(rc)) return rc; + + bnxt_fill_rte_eth_stats(bnxt_stats, &ring_stats, i, true); bnxt_stats->rx_nombuf += rte_atomic64_read(&rxq->rx_mbuf_alloc_fail); } @@ -542,14 +584,16 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, for (i = 0; i < num_q_stats; i++) { struct bnxt_tx_queue *txq = bp->tx_queues[i]; struct bnxt_cp_ring_info *cpr = txq->cp_ring; + struct bnxt_ring_stats ring_stats = {0}; - rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, - bnxt_stats, 0); + rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i, + &ring_stats, false); if (unlikely(rc)) return rc; + + bnxt_fill_rte_eth_stats(bnxt_stats, &ring_stats, i, false); } - rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats, NULL); return rc; } @@ -578,6 +622,40 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) return ret; } +static void bnxt_fill_func_qstats(struct hwrm_func_qstats_output *func_qstats, + struct bnxt_ring_stats *ring_stats, + bool rx) +{ + if (rx) { + func_qstats->rx_ucast_pkts += ring_stats->rx_ucast_pkts; + func_qstats->rx_mcast_pkts += ring_stats->rx_mcast_pkts; + func_qstats->rx_bcast_pkts += ring_stats->rx_bcast_pkts; + + func_qstats->rx_ucast_bytes += ring_stats->rx_ucast_bytes; + func_qstats->rx_mcast_bytes += ring_stats->rx_mcast_bytes; + func_qstats->rx_bcast_bytes += ring_stats->rx_bcast_bytes; + + func_qstats->rx_discard_pkts += ring_stats->rx_discard_pkts; + func_qstats->rx_drop_pkts += ring_stats->rx_error_pkts; + + func_qstats->rx_agg_pkts += ring_stats->rx_agg_pkts; + func_qstats->rx_agg_bytes += ring_stats->rx_agg_bytes; + func_qstats->rx_agg_events += ring_stats->rx_agg_events; + func_qstats->rx_agg_aborts += ring_stats->rx_agg_aborts; + } else { + func_qstats->tx_ucast_pkts += ring_stats->tx_ucast_pkts; + func_qstats->tx_mcast_pkts += ring_stats->tx_mcast_pkts; + func_qstats->tx_bcast_pkts += ring_stats->tx_bcast_pkts; + + func_qstats->tx_ucast_bytes += ring_stats->tx_ucast_bytes; + func_qstats->tx_mcast_bytes += ring_stats->tx_mcast_bytes; + func_qstats->tx_bcast_bytes += ring_stats->tx_bcast_bytes; + + func_qstats->tx_drop_pkts += ring_stats->tx_error_pkts; + func_qstats->tx_discard_pkts += ring_stats->tx_discard_pkts; + } +} + int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, unsigned int n) { @@ -604,7 +682,38 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, if (n < stat_count || xstats == NULL) return stat_count; - bnxt_hwrm_func_qstats(bp, 0xffff, NULL, &func_qstats); + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + struct bnxt_rx_queue *rxq = bp->rx_queues[i]; + struct bnxt_cp_ring_info *cpr = rxq->cp_ring; + struct bnxt_ring_stats ring_stats = {0}; + + if (!rxq->rx_started) + continue; + + rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i, + &ring_stats, true); + if (unlikely(rc)) + return rc; + + bnxt_fill_func_qstats(&func_qstats, &ring_stats, true); + } + + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq = bp->tx_queues[i]; + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + struct bnxt_ring_stats ring_stats = {0}; + + if (!txq->tx_started) + continue; + + rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i, + &ring_stats, false); + if (unlikely(rc)) + return rc; + + bnxt_fill_func_qstats(&func_qstats, &ring_stats, false); + } + bnxt_hwrm_port_qstats(bp); bnxt_hwrm_ext_port_qstats(bp); rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings), @@ -637,13 +746,11 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { xstats[count].id = count; - xstats[count].value = - rte_le_to_cpu_64(*(uint64_t *)((char *)&func_qstats + - bnxt_func_stats_strings[i].offset)); + xstats[count].value = *(uint64_t *)((char *)&func_qstats + + bnxt_func_stats_strings[i].offset); count++; } - for (i = 0; i < rx_port_stats_ext_cnt; i++) { uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-07-12 13:41:37.246604757 +0100 +++ 0007-net-bnxt-workaround-spurious-zero-stats-in-Thor.patch 2021-07-12 13:41:36.178116111 +0100 @@ -1 +1 @@ -From 219842b9990c2a3a426c14c7911a44d2cb9b6fdf Mon Sep 17 00:00:00 2001 +From 47b40639d903f87fb2e71ec816898eb411e2c4e4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 219842b9990c2a3a426c14c7911a44d2cb9b6fdf ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -27 +28 @@ - drivers/net/bnxt/bnxt.h | 45 +++++++++++ + drivers/net/bnxt/bnxt.h | 45 ++++++++++++ @@ -31,2 +32,2 @@ - drivers/net/bnxt/bnxt_stats.c | 131 ++++++++++++++++++++++++++++++--- - 5 files changed, 296 insertions(+), 30 deletions(-) + drivers/net/bnxt/bnxt_stats.c | 129 ++++++++++++++++++++++++++++++--- + 5 files changed, 294 insertions(+), 30 deletions(-) @@ -35 +36 @@ -index db67bff127..e93a7eb933 100644 +index 0fb195b656..f85409878c 100644 @@ -38 +39 @@ -@@ -609,6 +609,49 @@ struct bnxt_flow_stat_info { +@@ -605,6 +605,49 @@ struct bnxt_flow_stat_info { @@ -88,2 +89,2 @@ -@@ -832,6 +875,8 @@ struct bnxt { - struct bnxt_flow_stat_info *flow_stat; +@@ -808,6 +851,8 @@ struct bnxt { + uint8_t flow_xstat; @@ -98 +99 @@ -index 96d2befd0f..c72a968ffa 100644 +index 1498f4a653..35753e33e7 100644 @@ -101 +102 @@ -@@ -686,6 +686,38 @@ static int bnxt_update_phy_setting(struct bnxt *bp) +@@ -696,6 +696,38 @@ static int bnxt_update_phy_setting(struct bnxt *bp) @@ -140 +141 @@ -@@ -1476,6 +1508,7 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev) +@@ -1435,6 +1467,7 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) @@ -148 +149 @@ -@@ -1547,6 +1580,10 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) +@@ -1489,6 +1522,10 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) @@ -160 +161 @@ -index 3d04b93d88..c6c0af28cb 100644 +index 5ed38c9427..4b59c5bfa4 100644 @@ -163 +164 @@ -@@ -4305,8 +4305,20 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id, +@@ -4145,8 +4145,20 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id, @@ -186 +187 @@ -@@ -4321,21 +4333,85 @@ int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx, +@@ -4161,21 +4173,85 @@ int bnxt_hwrm_ctx_qstats(struct bnxt *bp, uint32_t cid, int idx, @@ -287 +288 @@ -index a7271b7876..b60aa0cca8 100644 +index a67a17b3d4..6deae8faeb 100644 @@ -290 +291 @@ -@@ -168,9 +168,6 @@ int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx); +@@ -165,9 +165,6 @@ int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx); @@ -300,2 +301,3 @@ -@@ -302,4 +299,6 @@ int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1, - uint32_t echo_req_data2); +@@ -297,4 +294,6 @@ int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid, + int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep); + int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep); @@ -303 +304,0 @@ - int bnxt_hwrm_rx_ring_reset(struct bnxt *bp, int queue_index); @@ -308 +309 @@ -index 11767e06d0..c7b23f46a1 100644 +index 0cf3ee77e3..4e67fdf9f2 100644 @@ -360 +361 @@ -@@ -527,13 +566,17 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +@@ -527,11 +566,14 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, @@ -366,2 +366,0 @@ - if (!rxq->rx_started) - continue; @@ -370 +368,0 @@ -+ @@ -380 +378 @@ -@@ -544,16 +587,19 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +@@ -542,14 +584,16 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, @@ -386,2 +383,0 @@ - if (!txq->tx_started) - continue; @@ -390 +385,0 @@ -+ @@ -403 +398 @@ -@@ -582,6 +628,40 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) +@@ -578,6 +622,40 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) @@ -444 +439 @@ -@@ -608,7 +688,38 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, +@@ -604,7 +682,38 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, @@ -484 +479 @@ -@@ -641,13 +752,11 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, +@@ -637,13 +746,11 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,