X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Fbnxt_stats.c;h=40b496ac005d5ebd490dc03a3ad74d89bd58a13d;hb=e0b7e8205cfc3f53210e68bd47feb4da9cec0628;hp=470c6438d57585e2e7e977cedd7bf04eef3e6b64;hpb=ed2ced6fe92706bfcbc7e64f553955c3951aa223;p=dpdk.git diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 470c6438d5..40b496ac00 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -1,38 +1,11 @@ -/*- - * BSD LICENSE - * - * Copyright(c) Broadcom Limited. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Broadcom Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2018 Broadcom + * All rights reserved. */ #include +#include #include #include "bnxt.h" @@ -54,8 +27,8 @@ static const struct bnxt_xstats_name_off bnxt_rx_stats_strings[] = { rx_256b_511b_frames)}, {"rx_512b_1023b_frames", offsetof(struct rx_port_stats, rx_512b_1023b_frames)}, - {"rx_1024b_1518_frames", offsetof(struct rx_port_stats, - rx_1024b_1518_frames)}, + {"rx_1024b_1518b_frames", offsetof(struct rx_port_stats, + rx_1024b_1518b_frames)}, {"rx_good_vlan_frames", offsetof(struct rx_port_stats, rx_good_vlan_frames)}, {"rx_1519b_2047b_frames", offsetof(struct rx_port_stats, @@ -108,6 +81,22 @@ static const struct bnxt_xstats_name_off bnxt_rx_stats_strings[] = { rx_runt_bytes)}, {"rx_runt_frames", offsetof(struct rx_port_stats, rx_runt_frames)}, + {"rx_pfc_ena_frames_pri0", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri0)}, + {"rx_pfc_ena_frames_pri1", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri1)}, + {"rx_pfc_ena_frames_pri2", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri2)}, + {"rx_pfc_ena_frames_pri3", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri3)}, + {"rx_pfc_ena_frames_pri4", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri4)}, + {"rx_pfc_ena_frames_pri5", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri5)}, + {"rx_pfc_ena_frames_pri6", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri6)}, + {"rx_pfc_ena_frames_pri7", offsetof(struct rx_port_stats, + rx_pfc_ena_frames_pri7)}, }; static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = { @@ -121,12 +110,12 @@ static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = { tx_256b_511b_frames)}, {"tx_512b_1023b_frames", offsetof(struct tx_port_stats, tx_512b_1023b_frames)}, - {"tx_1024b_1518_frames", offsetof(struct tx_port_stats, - tx_1024b_1518_frames)}, + {"tx_1024b_1518b_frames", offsetof(struct tx_port_stats, + tx_1024b_1518b_frames)}, {"tx_good_vlan_frames", offsetof(struct tx_port_stats, tx_good_vlan_frames)}, - {"tx_1519b_2047_frames", offsetof(struct tx_port_stats, - tx_1519b_2047_frames)}, + {"tx_1519b_2047b_frames", offsetof(struct tx_port_stats, + tx_1519b_2047b_frames)}, {"tx_2048b_4095b_frames", offsetof(struct tx_port_stats, tx_2048b_4095b_frames)}, {"tx_4096b_9216b_frames", offsetof(struct tx_port_stats, @@ -163,6 +152,22 @@ static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = { tx_total_collisions)}, {"tx_bytes", offsetof(struct tx_port_stats, tx_bytes)}, + {"tx_pfc_ena_frames_pri0", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri0)}, + {"tx_pfc_ena_frames_pri1", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri1)}, + {"tx_pfc_ena_frames_pri2", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri2)}, + {"tx_pfc_ena_frames_pri3", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri3)}, + {"tx_pfc_ena_frames_pri4", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri4)}, + {"tx_pfc_ena_frames_pri5", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri5)}, + {"tx_pfc_ena_frames_pri6", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri6)}, + {"tx_pfc_ena_frames_pri7", offsetof(struct tx_port_stats, + tx_pfc_ena_frames_pri7)}, }; static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = { @@ -172,8 +177,8 @@ static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = { tx_mcast_pkts)}, {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_output, tx_bcast_pkts)}, - {"tx_err_pkts", offsetof(struct hwrm_func_qstats_output, - tx_err_pkts)}, + {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_output, + tx_discard_pkts)}, {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_output, tx_drop_pkts)}, {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_output, @@ -188,8 +193,8 @@ static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = { rx_mcast_pkts)}, {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_output, rx_bcast_pkts)}, - {"rx_err_pkts", offsetof(struct hwrm_func_qstats_output, - rx_err_pkts)}, + {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_output, + rx_discard_pkts)}, {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_output, rx_drop_pkts)}, {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_output, @@ -208,6 +213,150 @@ static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = { rx_agg_aborts)}, }; +static const struct bnxt_xstats_name_off bnxt_rx_ext_stats_strings[] = { + {"link_down_events", offsetof(struct rx_port_stats_ext, + link_down_events)}, + {"continuous_pause_events", offsetof(struct rx_port_stats_ext, + continuous_pause_events)}, + {"resume_pause_events", offsetof(struct rx_port_stats_ext, + resume_pause_events)}, + {"continuous_roce_pause_events", offsetof(struct rx_port_stats_ext, + continuous_roce_pause_events)}, + {"resume_roce_pause_events", offsetof(struct rx_port_stats_ext, + resume_roce_pause_events)}, + {"rx_bytes_cos0", offsetof(struct rx_port_stats_ext, + rx_bytes_cos0)}, + {"rx_bytes_cos1", offsetof(struct rx_port_stats_ext, + rx_bytes_cos1)}, + {"rx_bytes_cos2", offsetof(struct rx_port_stats_ext, + rx_bytes_cos2)}, + {"rx_bytes_cos3", offsetof(struct rx_port_stats_ext, + rx_bytes_cos3)}, + {"rx_bytes_cos4", offsetof(struct rx_port_stats_ext, + rx_bytes_cos4)}, + {"rx_bytes_cos5", offsetof(struct rx_port_stats_ext, + rx_bytes_cos5)}, + {"rx_bytes_cos6", offsetof(struct rx_port_stats_ext, + rx_bytes_cos6)}, + {"rx_bytes_cos7", offsetof(struct rx_port_stats_ext, + rx_bytes_cos7)}, + {"rx_packets_cos0", offsetof(struct rx_port_stats_ext, + rx_packets_cos0)}, + {"rx_packets_cos1", offsetof(struct rx_port_stats_ext, + rx_packets_cos1)}, + {"rx_packets_cos2", offsetof(struct rx_port_stats_ext, + rx_packets_cos2)}, + {"rx_packets_cos3", offsetof(struct rx_port_stats_ext, + rx_packets_cos3)}, + {"rx_packets_cos4", offsetof(struct rx_port_stats_ext, + rx_packets_cos4)}, + {"rx_packets_cos5", offsetof(struct rx_port_stats_ext, + rx_packets_cos5)}, + {"rx_packets_cos6", offsetof(struct rx_port_stats_ext, + rx_packets_cos6)}, + {"rx_packets_cos7", offsetof(struct rx_port_stats_ext, + rx_packets_cos7)}, + {"pfc_pri0_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri0_rx_duration_us)}, + {"pfc_pri0_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri0_rx_transitions)}, + {"pfc_pri1_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri1_rx_duration_us)}, + {"pfc_pri1_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri1_rx_transitions)}, + {"pfc_pri2_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri2_rx_duration_us)}, + {"pfc_pri2_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri2_rx_transitions)}, + {"pfc_pri3_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri3_rx_duration_us)}, + {"pfc_pri3_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri3_rx_transitions)}, + {"pfc_pri4_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri4_rx_duration_us)}, + {"pfc_pri4_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri4_rx_transitions)}, + {"pfc_pri5_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri5_rx_duration_us)}, + {"pfc_pri5_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri5_rx_transitions)}, + {"pfc_pri6_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri6_rx_duration_us)}, + {"pfc_pri6_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri6_rx_transitions)}, + {"pfc_pri7_rx_duration_us", offsetof(struct rx_port_stats_ext, + pfc_pri7_rx_duration_us)}, + {"pfc_pri7_rx_transitions", offsetof(struct rx_port_stats_ext, + pfc_pri7_rx_transitions)}, +}; + +static const struct bnxt_xstats_name_off bnxt_tx_ext_stats_strings[] = { + {"tx_bytes_cos0", offsetof(struct tx_port_stats_ext, + tx_bytes_cos0)}, + {"tx_bytes_cos1", offsetof(struct tx_port_stats_ext, + tx_bytes_cos1)}, + {"tx_bytes_cos2", offsetof(struct tx_port_stats_ext, + tx_bytes_cos2)}, + {"tx_bytes_cos3", offsetof(struct tx_port_stats_ext, + tx_bytes_cos3)}, + {"tx_bytes_cos4", offsetof(struct tx_port_stats_ext, + tx_bytes_cos4)}, + {"tx_bytes_cos5", offsetof(struct tx_port_stats_ext, + tx_bytes_cos5)}, + {"tx_bytes_cos6", offsetof(struct tx_port_stats_ext, + tx_bytes_cos6)}, + {"tx_bytes_cos7", offsetof(struct tx_port_stats_ext, + tx_bytes_cos7)}, + {"tx_packets_cos0", offsetof(struct tx_port_stats_ext, + tx_packets_cos0)}, + {"tx_packets_cos1", offsetof(struct tx_port_stats_ext, + tx_packets_cos1)}, + {"tx_packets_cos2", offsetof(struct tx_port_stats_ext, + tx_packets_cos2)}, + {"tx_packets_cos3", offsetof(struct tx_port_stats_ext, + tx_packets_cos3)}, + {"tx_packets_cos4", offsetof(struct tx_port_stats_ext, + tx_packets_cos4)}, + {"tx_packets_cos5", offsetof(struct tx_port_stats_ext, + tx_packets_cos5)}, + {"tx_packets_cos6", offsetof(struct tx_port_stats_ext, + tx_packets_cos6)}, + {"tx_packets_cos7", offsetof(struct tx_port_stats_ext, + tx_packets_cos7)}, + {"pfc_pri0_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri0_tx_duration_us)}, + {"pfc_pri0_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri0_tx_transitions)}, + {"pfc_pri1_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri1_tx_duration_us)}, + {"pfc_pri1_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri1_tx_transitions)}, + {"pfc_pri2_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri2_tx_duration_us)}, + {"pfc_pri2_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri2_tx_transitions)}, + {"pfc_pri3_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri3_tx_duration_us)}, + {"pfc_pri3_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri3_tx_transitions)}, + {"pfc_pri4_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri4_tx_duration_us)}, + {"pfc_pri4_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri4_tx_transitions)}, + {"pfc_pri5_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri5_tx_duration_us)}, + {"pfc_pri5_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri5_tx_transitions)}, + {"pfc_pri6_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri6_tx_duration_us)}, + {"pfc_pri6_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri6_tx_transitions)}, + {"pfc_pri7_tx_duration_us", offsetof(struct tx_port_stats_ext, + pfc_pri7_tx_duration_us)}, + {"pfc_pri7_tx_transitions", offsetof(struct tx_port_stats_ext, + pfc_pri7_tx_transitions)}, +}; + /* * Statistics functions */ @@ -234,14 +383,22 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, int rc = 0; unsigned int i; struct bnxt *bp = eth_dev->data->dev_private; + unsigned int num_q_stats; + + rc = is_bnxt_in_error(bp); + if (rc) + return rc; memset(bnxt_stats, 0, sizeof(*bnxt_stats)); if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { - RTE_LOG(ERR, PMD, "Device Initialization not complete!\n"); - return 0; + PMD_DRV_LOG(ERR, "Device Initialization not complete!\n"); + return -EIO; } - for (i = 0; i < bp->rx_cp_nr_rings; i++) { + num_q_stats = RTE_MIN(bp->rx_cp_nr_rings, + (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); + + 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; @@ -249,9 +406,14 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, bnxt_stats, 1); if (unlikely(rc)) return rc; + bnxt_stats->rx_nombuf += + rte_atomic64_read(&rxq->rx_mbuf_alloc_fail); } - for (i = 0; i < bp->tx_cp_nr_rings; i++) { + num_q_stats = RTE_MIN(bp->tx_cp_nr_rings, + (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); + + 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; @@ -260,44 +422,69 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, if (unlikely(rc)) return rc; } + rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); - if (unlikely(rc)) - return rc; - bnxt_stats->rx_nombuf = rte_atomic64_read(&bp->rx_mbuf_alloc_fail); return rc; } -void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) +int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) { - struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt *bp = eth_dev->data->dev_private; + unsigned int i; + int ret; + + ret = is_bnxt_in_error(bp); + if (ret) + return ret; if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { - RTE_LOG(ERR, PMD, "Device Initialization not complete!\n"); - return; + PMD_DRV_LOG(ERR, "Device Initialization not complete!\n"); + return -EINVAL; } - bnxt_clear_all_hwrm_stat_ctxs(bp); - rte_atomic64_clear(&bp->rx_mbuf_alloc_fail); + ret = bnxt_clear_all_hwrm_stat_ctxs(bp); + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + struct bnxt_rx_queue *rxq = bp->rx_queues[i]; + + rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail); + } + + return ret; } int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, unsigned int n) { - struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; - + 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); + unsigned int stat_count; + int rc; + + rc = is_bnxt_in_error(bp); + if (rc) + return rc; - if (!(bp->flags & BNXT_FLAG_PORT_STATS)) { - RTE_LOG(ERR, PMD, "xstats not supported for VF\n"); - return 0; - } + memset(xstats, 0, sizeof(*xstats)); 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 / + stat_size)); + tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings), + (bp->fw_tx_port_stats_ext_size / + 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) + 1/* For tx_drop_pkts */ + + RTE_DIM(bnxt_rx_ext_stats_strings) + + RTE_DIM(bnxt_tx_ext_stats_strings); + stat_count = count; if (n < count) return count; @@ -305,6 +492,7 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, count = 0; for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { uint64_t *rx_stats = (uint64_t *)bp->hw_rx_port_stats; + xstats[count].id = count; xstats[count].value = rte_le_to_cpu_64( *(uint64_t *)((char *)rx_stats + bnxt_rx_stats_strings[i].offset)); @@ -313,6 +501,7 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { uint64_t *tx_stats = (uint64_t *)bp->hw_tx_port_stats; + xstats[count].id = count; xstats[count].value = rte_le_to_cpu_64( *(uint64_t *)((char *)tx_stats + bnxt_tx_stats_strings[i].offset)); @@ -320,10 +509,31 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, } /* 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++; - return count; + for (i = 0; i < rx_port_stats_ext_cnt; i++) { + uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; + + xstats[count].value = rte_le_to_cpu_64 + (*(uint64_t *)((char *)rx_stats_ext + + bnxt_rx_ext_stats_strings[i].offset)); + + count++; + } + + for (i = 0; i < tx_port_stats_ext_cnt; i++) { + uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext; + + xstats[count].value = rte_le_to_cpu_64 + (*(uint64_t *)((char *)tx_stats_ext + + bnxt_tx_ext_stats_strings[i].offset)); + + count++; + } + + return stat_count; } int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev, @@ -332,50 +542,80 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev, { /* 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) + 1 + + RTE_DIM(bnxt_rx_ext_stats_strings) + + RTE_DIM(bnxt_tx_ext_stats_strings); + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; unsigned int i, count; + int rc; + + rc = is_bnxt_in_error(bp); + if (rc) + return rc; if (xstats_names != NULL) { count = 0; for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", - bnxt_rx_stats_strings[i].name); + strlcpy(xstats_names[count].name, + bnxt_rx_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", - bnxt_tx_stats_strings[i].name); + strlcpy(xstats_names[count].name, + bnxt_tx_stats_strings[i].name, + sizeof(xstats_names[count].name)); count++; } - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "%s", - bnxt_func_stats_strings[4].name); + strlcpy(xstats_names[count].name, + bnxt_func_stats_strings[4].name, + sizeof(xstats_names[count].name)); count++; + + for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_rx_ext_stats_strings[i].name, + sizeof(xstats_names[count].name)); + + count++; + } + + for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_tx_ext_stats_strings[i].name, + sizeof(xstats_names[count].name)); + + count++; + } + } return stat_cnt; } -void bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) +int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) { - struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt *bp = eth_dev->data->dev_private; + int ret; - if (bp->flags & BNXT_FLAG_PORT_STATS && BNXT_SINGLE_PF(bp)) - bnxt_hwrm_port_clr_stats(bp); + ret = is_bnxt_in_error(bp); + if (ret) + return ret; - if (BNXT_VF(bp)) - RTE_LOG(ERR, PMD, "Operation not supported on a VF device\n"); - if (!BNXT_SINGLE_PF(bp)) - RTE_LOG(ERR, PMD, "Operation not supported on a MF device\n"); - if (!(bp->flags & BNXT_FLAG_PORT_STATS)) - RTE_LOG(ERR, PMD, "Operation not supported\n"); + if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) || + !(bp->flags & BNXT_FLAG_PORT_STATS)) { + PMD_DRV_LOG(ERR, "Operation not supported\n"); + return -ENOTSUP; + } + + ret = bnxt_hwrm_port_clr_stats(bp); + if (ret != 0) + PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n", + strerror(-ret)); + + return ret; } int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, @@ -383,10 +623,18 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, { /* 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) + 1 + + RTE_DIM(bnxt_rx_ext_stats_strings) + + RTE_DIM(bnxt_tx_ext_stats_strings); + struct bnxt *bp = dev->data->dev_private; struct rte_eth_xstat xstats[stat_cnt]; uint64_t values_copy[stat_cnt]; uint16_t i; + int rc; + + rc = is_bnxt_in_error(bp); + if (rc) + return rc; if (!ids) return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt); @@ -394,8 +642,8 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, bnxt_dev_xstats_get_by_id_op(dev, NULL, values_copy, stat_cnt); for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { - RTE_LOG(ERR, PMD, "id value isn't valid"); - return -1; + PMD_DRV_LOG(ERR, "id value isn't valid"); + return -EINVAL; } values[i] = values_copy[ids[i]]; } @@ -408,9 +656,17 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev, { /* 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) + 1 + + RTE_DIM(bnxt_rx_ext_stats_strings) + + RTE_DIM(bnxt_tx_ext_stats_strings); struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; + struct bnxt *bp = dev->data->dev_private; uint16_t i; + int rc; + + rc = is_bnxt_in_error(bp); + if (rc) + return rc; if (!ids) return bnxt_dev_xstats_get_names_op(dev, xstats_names, @@ -420,8 +676,8 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev, for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { - RTE_LOG(ERR, PMD, "id value isn't valid"); - return -1; + PMD_DRV_LOG(ERR, "id value isn't valid"); + return -EINVAL; } strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);