From: Ajit Khaparde Date: Thu, 2 Apr 2020 05:26:29 +0000 (-0700) Subject: net/bnxt: add PCI function stats to extended stats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5f9374de2a3ae61662765583db95585c012a0086;p=dpdk.git net/bnxt: add PCI function stats to extended stats HWRM API allows drivers to query stats per PCI function. These stats can provide some useful information in certain circumstances. Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index 0252113aee..ae0f66bba9 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -148,6 +148,7 @@ New Features Updated Broadcom bnxt driver with new features and improvements, including: * Added support for host based flow table management + * Added PCI function stats to extended stats * **Added handling of mixed crypto algorithms in QAT PMD for GEN2.** diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 0eaf9171cb..d435f65700 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -2261,7 +2261,8 @@ int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid, } int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid, - struct rte_eth_stats *stats) + struct rte_eth_stats *stats, + struct hwrm_func_qstats_output *func_qstats) { int rc = 0; struct hwrm_func_qstats_input req = {.req_type = 0}; @@ -2274,6 +2275,12 @@ int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid, rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); HWRM_CHECK_RESULT(); + if (func_qstats) + memcpy(func_qstats, resp, + sizeof(struct hwrm_func_qstats_output)); + + if (!stats) + goto exit; stats->ipackets = rte_le_to_cpu_64(resp->rx_ucast_pkts); stats->ipackets += rte_le_to_cpu_64(resp->rx_mcast_pkts); @@ -2293,6 +2300,7 @@ int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid, stats->ierrors = rte_le_to_cpu_64(resp->rx_drop_pkts); stats->oerrors = rte_le_to_cpu_64(resp->tx_discard_pkts); +exit: HWRM_UNLOCK(); return rc; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 0079d8a978..1b7e353060 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -12,6 +12,7 @@ struct bnxt; struct bnxt_filter_info; struct bnxt_cp_ring_info; +struct hwrm_func_qstats_output; #define HWRM_SEQ_ID_INVALID -1U /* Convert Bit field location to value */ @@ -112,7 +113,8 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp); int bnxt_hwrm_func_reset(struct bnxt *bp); int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags); int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid, - struct rte_eth_stats *stats); + struct rte_eth_stats *stats, + struct hwrm_func_qstats_output *func_qstats); int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid, uint64_t *dropped); int bnxt_hwrm_func_clr_stats(struct bnxt *bp, uint16_t fid); diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 29628bd64f..6afd11adb2 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -547,7 +547,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, return rc; } - rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); + rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats, NULL); return rc; } @@ -581,10 +581,10 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, { struct bnxt *bp = eth_dev->data->dev_private; unsigned int count, i; - uint64_t tx_drop_pkts; unsigned int rx_port_stats_ext_cnt; unsigned int tx_port_stats_ext_cnt; unsigned int stat_size = sizeof(uint64_t); + struct hwrm_func_qstats_output func_qstats = {0}; unsigned int stat_count; int rc; @@ -597,8 +597,8 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, memset(xstats, 0, sizeof(*xstats)); + bnxt_hwrm_func_qstats(bp, 0xffff, NULL, &func_qstats); bnxt_hwrm_port_qstats(bp); - bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts); bnxt_hwrm_ext_port_qstats(bp); rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings), (bp->fw_rx_port_stats_ext_size / @@ -608,7 +608,8 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, stat_size)); count = RTE_DIM(bnxt_rx_stats_strings) + - RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ + + RTE_DIM(bnxt_tx_stats_strings) + + RTE_DIM(bnxt_func_stats_strings) + RTE_DIM(bnxt_rx_ext_stats_strings) + RTE_DIM(bnxt_tx_ext_stats_strings); stat_count = count; @@ -635,10 +636,13 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, count++; } - /* The Tx drop pkts aka the Anti spoof coounter */ - xstats[count].id = count; - xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts); - count++; + 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 *)&func_qstats)[i]); + count++; + } + for (i = 0; i < rx_port_stats_ext_cnt; i++) { uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; @@ -667,9 +671,9 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { - /* Account for the Tx drop pkts aka the Anti spoof counter */ const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + - RTE_DIM(bnxt_tx_stats_strings) + 1 + + RTE_DIM(bnxt_tx_stats_strings) + + RTE_DIM(bnxt_func_stats_strings) + RTE_DIM(bnxt_rx_ext_stats_strings) + RTE_DIM(bnxt_tx_ext_stats_strings); struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; @@ -697,10 +701,12 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, count++; } - strlcpy(xstats_names[count].name, - bnxt_func_stats_strings[4].name, - sizeof(xstats_names[count].name)); - count++; + for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_func_stats_strings[i].name, + sizeof(xstats_names[count].name)); + count++; + } for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) { strlcpy(xstats_names[count].name, @@ -748,9 +754,9 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int limit) { - /* Account for the Tx drop pkts aka the Anti spoof counter */ const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + - RTE_DIM(bnxt_tx_stats_strings) + 1 + + RTE_DIM(bnxt_tx_stats_strings) + + RTE_DIM(bnxt_func_stats_strings) + RTE_DIM(bnxt_rx_ext_stats_strings) + RTE_DIM(bnxt_tx_ext_stats_strings); struct bnxt *bp = dev->data->dev_private; @@ -781,9 +787,9 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, const uint64_t *ids, unsigned int limit) { - /* Account for the Tx drop pkts aka the Anti spoof counter */ const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + - RTE_DIM(bnxt_tx_stats_strings) + 1 + + RTE_DIM(bnxt_tx_stats_strings) + + RTE_DIM(bnxt_func_stats_strings) + RTE_DIM(bnxt_rx_ext_stats_strings) + RTE_DIM(bnxt_tx_ext_stats_strings); struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index 4374034c33..2df4865927 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt.c +++ b/drivers/net/bnxt/rte_pmd_bnxt.c @@ -614,7 +614,8 @@ int rte_pmd_bnxt_get_vf_stats(uint16_t port, return -ENOTSUP; } - return bnxt_hwrm_func_qstats(bp, bp->pf.first_vf_id + vf_id, stats); + return bnxt_hwrm_func_qstats(bp, bp->pf.first_vf_id + vf_id, stats, + NULL); } int rte_pmd_bnxt_reset_vf_stats(uint16_t port,