LCOV - code coverage report
Current view: top level - drivers/net/bnxt - bnxt_stats.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 412 0.0 %
Date: 2025-11-01 17:50:34 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 208 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2014-2023 Broadcom
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <inttypes.h>
       7                 :            : 
       8                 :            : #include <rte_string_fns.h>
       9                 :            : #include <rte_byteorder.h>
      10                 :            : 
      11                 :            : #include "bnxt.h"
      12                 :            : #include "bnxt_cpr.h"
      13                 :            : #include "bnxt_filter.h"
      14                 :            : #include "bnxt_hwrm.h"
      15                 :            : #include "bnxt_rxq.h"
      16                 :            : #include "bnxt_stats.h"
      17                 :            : #include "bnxt_txq.h"
      18                 :            : #include "bnxt_vnic.h"
      19                 :            : #include "hsi_struct_def_dpdk.h"
      20                 :            : 
      21                 :            : static const struct bnxt_xstats_name_off bnxt_rx_stats_strings[] = {
      22                 :            :         {"rx_64b_frames", offsetof(struct rx_port_stats,
      23                 :            :                                 rx_64b_frames)},
      24                 :            :         {"rx_65b_127b_frames", offsetof(struct rx_port_stats,
      25                 :            :                                 rx_65b_127b_frames)},
      26                 :            :         {"rx_128b_255b_frames", offsetof(struct rx_port_stats,
      27                 :            :                                 rx_128b_255b_frames)},
      28                 :            :         {"rx_256b_511b_frames", offsetof(struct rx_port_stats,
      29                 :            :                                 rx_256b_511b_frames)},
      30                 :            :         {"rx_512b_1023b_frames", offsetof(struct rx_port_stats,
      31                 :            :                                 rx_512b_1023b_frames)},
      32                 :            :         {"rx_1024b_1518b_frames", offsetof(struct rx_port_stats,
      33                 :            :                                 rx_1024b_1518b_frames)},
      34                 :            :         {"rx_good_vlan_frames", offsetof(struct rx_port_stats,
      35                 :            :                                 rx_good_vlan_frames)},
      36                 :            :         {"rx_1519b_2047b_frames", offsetof(struct rx_port_stats,
      37                 :            :                                 rx_1519b_2047b_frames)},
      38                 :            :         {"rx_2048b_4095b_frames", offsetof(struct rx_port_stats,
      39                 :            :                                 rx_2048b_4095b_frames)},
      40                 :            :         {"rx_4096b_9216b_frames", offsetof(struct rx_port_stats,
      41                 :            :                                 rx_4096b_9216b_frames)},
      42                 :            :         {"rx_9217b_16383b_frames", offsetof(struct rx_port_stats,
      43                 :            :                                 rx_9217b_16383b_frames)},
      44                 :            :         {"rx_total_frames", offsetof(struct rx_port_stats,
      45                 :            :                                 rx_total_frames)},
      46                 :            :         {"rx_ucast_frames", offsetof(struct rx_port_stats,
      47                 :            :                                 rx_ucast_frames)},
      48                 :            :         {"rx_mcast_frames", offsetof(struct rx_port_stats,
      49                 :            :                                 rx_mcast_frames)},
      50                 :            :         {"rx_bcast_frames", offsetof(struct rx_port_stats,
      51                 :            :                                 rx_bcast_frames)},
      52                 :            :         {"rx_fcs_err_frames", offsetof(struct rx_port_stats,
      53                 :            :                                 rx_fcs_err_frames)},
      54                 :            :         {"rx_ctrl_frames", offsetof(struct rx_port_stats,
      55                 :            :                                 rx_ctrl_frames)},
      56                 :            :         {"rx_pause_frames", offsetof(struct rx_port_stats,
      57                 :            :                                 rx_pause_frames)},
      58                 :            :         {"rx_pfc_frames", offsetof(struct rx_port_stats,
      59                 :            :                                 rx_pfc_frames)},
      60                 :            :         {"rx_unsupported_opcode_frames", offsetof(struct rx_port_stats,
      61                 :            :                                 rx_unsupported_opcode_frames)},
      62                 :            :         {"rx_unsupported_da_pausepfc_frames", offsetof(struct rx_port_stats,
      63                 :            :                                 rx_unsupported_da_pausepfc_frames)},
      64                 :            :         {"rx_wrong_sa_frames", offsetof(struct rx_port_stats,
      65                 :            :                                 rx_wrong_sa_frames)},
      66                 :            :         {"rx_align_err_frames", offsetof(struct rx_port_stats,
      67                 :            :                                 rx_align_err_frames)},
      68                 :            :         {"rx_oor_len_frames", offsetof(struct rx_port_stats,
      69                 :            :                                 rx_oor_len_frames)},
      70                 :            :         {"rx_code_err_frames", offsetof(struct rx_port_stats,
      71                 :            :                                 rx_code_err_frames)},
      72                 :            :         {"rx_false_carrier_frames", offsetof(struct rx_port_stats,
      73                 :            :                                 rx_false_carrier_frames)},
      74                 :            :         {"rx_ovrsz_frames", offsetof(struct rx_port_stats,
      75                 :            :                                 rx_ovrsz_frames)},
      76                 :            :         {"rx_jbr_frames", offsetof(struct rx_port_stats,
      77                 :            :                                 rx_jbr_frames)},
      78                 :            :         {"rx_mtu_err_frames", offsetof(struct rx_port_stats,
      79                 :            :                                 rx_mtu_err_frames)},
      80                 :            :         {"rx_match_crc_frames", offsetof(struct rx_port_stats,
      81                 :            :                                 rx_match_crc_frames)},
      82                 :            :         {"rx_promiscuous_frames", offsetof(struct rx_port_stats,
      83                 :            :                                 rx_promiscuous_frames)},
      84                 :            :         {"rx_tagged_frames", offsetof(struct rx_port_stats,
      85                 :            :                                 rx_tagged_frames)},
      86                 :            :         {"rx_double_tagged_frames", offsetof(struct rx_port_stats,
      87                 :            :                                 rx_double_tagged_frames)},
      88                 :            :         {"rx_trunc_frames", offsetof(struct rx_port_stats,
      89                 :            :                                 rx_trunc_frames)},
      90                 :            :         {"rx_good_frames", offsetof(struct rx_port_stats,
      91                 :            :                                 rx_good_frames)},
      92                 :            :         {"rx_sch_crc_err_frames", offsetof(struct rx_port_stats,
      93                 :            :                                 rx_sch_crc_err_frames)},
      94                 :            :         {"rx_undrsz_frames", offsetof(struct rx_port_stats,
      95                 :            :                                 rx_undrsz_frames)},
      96                 :            :         {"rx_frag_frames", offsetof(struct rx_port_stats,
      97                 :            :                                 rx_frag_frames)},
      98                 :            :         {"rx_eee_lpi_events", offsetof(struct rx_port_stats,
      99                 :            :                                 rx_eee_lpi_events)},
     100                 :            :         {"rx_eee_lpi_duration", offsetof(struct rx_port_stats,
     101                 :            :                                 rx_eee_lpi_duration)},
     102                 :            :         {"rx_llfc_physical_msgs", offsetof(struct rx_port_stats,
     103                 :            :                                 rx_llfc_physical_msgs)},
     104                 :            :         {"rx_llfc_logical_msgs", offsetof(struct rx_port_stats,
     105                 :            :                                 rx_llfc_logical_msgs)},
     106                 :            :         {"rx_llfc_msgs_with_crc_err", offsetof(struct rx_port_stats,
     107                 :            :                                 rx_llfc_msgs_with_crc_err)},
     108                 :            :         {"rx_hcfc_msgs", offsetof(struct rx_port_stats,
     109                 :            :                                 rx_hcfc_msgs)},
     110                 :            :         {"rx_hcfc_msgs_with_crc_err", offsetof(struct rx_port_stats,
     111                 :            :                                 rx_hcfc_msgs_with_crc_err)},
     112                 :            :         {"rx_bytes", offsetof(struct rx_port_stats,
     113                 :            :                                 rx_bytes)},
     114                 :            :         {"rx_runt_bytes", offsetof(struct rx_port_stats,
     115                 :            :                                 rx_runt_bytes)},
     116                 :            :         {"rx_runt_frames", offsetof(struct rx_port_stats,
     117                 :            :                                 rx_runt_frames)},
     118                 :            :         {"rx_pfc_xon2xoff_frames_pri0", offsetof(struct rx_port_stats,
     119                 :            :                                 rx_pfc_xon2xoff_frames_pri0)},
     120                 :            :         {"rx_pfc_xon2xoff_frames_pri1", offsetof(struct rx_port_stats,
     121                 :            :                                 rx_pfc_xon2xoff_frames_pri1)},
     122                 :            :         {"rx_pfc_xon2xoff_frames_pri2", offsetof(struct rx_port_stats,
     123                 :            :                                 rx_pfc_xon2xoff_frames_pri2)},
     124                 :            :         {"rx_pfc_xon2xoff_frames_pri3", offsetof(struct rx_port_stats,
     125                 :            :                                 rx_pfc_xon2xoff_frames_pri3)},
     126                 :            :         {"rx_pfc_xon2xoff_frames_pri4", offsetof(struct rx_port_stats,
     127                 :            :                                 rx_pfc_xon2xoff_frames_pri4)},
     128                 :            :         {"rx_pfc_xon2xoff_frames_pri5", offsetof(struct rx_port_stats,
     129                 :            :                                 rx_pfc_xon2xoff_frames_pri5)},
     130                 :            :         {"rx_pfc_xon2xoff_frames_pri6", offsetof(struct rx_port_stats,
     131                 :            :                                 rx_pfc_xon2xoff_frames_pri6)},
     132                 :            :         {"rx_pfc_xon2xoff_frames_pri7", offsetof(struct rx_port_stats,
     133                 :            :                                 rx_pfc_xon2xoff_frames_pri7)},
     134                 :            :         {"rx_pfc_ena_frames_pri0", offsetof(struct rx_port_stats,
     135                 :            :                                 rx_pfc_ena_frames_pri0)},
     136                 :            :         {"rx_pfc_ena_frames_pri1", offsetof(struct rx_port_stats,
     137                 :            :                                 rx_pfc_ena_frames_pri1)},
     138                 :            :         {"rx_pfc_ena_frames_pri2", offsetof(struct rx_port_stats,
     139                 :            :                                 rx_pfc_ena_frames_pri2)},
     140                 :            :         {"rx_pfc_ena_frames_pri3", offsetof(struct rx_port_stats,
     141                 :            :                                 rx_pfc_ena_frames_pri3)},
     142                 :            :         {"rx_pfc_ena_frames_pri4", offsetof(struct rx_port_stats,
     143                 :            :                                 rx_pfc_ena_frames_pri4)},
     144                 :            :         {"rx_pfc_ena_frames_pri5", offsetof(struct rx_port_stats,
     145                 :            :                                 rx_pfc_ena_frames_pri5)},
     146                 :            :         {"rx_pfc_ena_frames_pri6", offsetof(struct rx_port_stats,
     147                 :            :                                 rx_pfc_ena_frames_pri6)},
     148                 :            :         {"rx_pfc_ena_frames_pri7", offsetof(struct rx_port_stats,
     149                 :            :                                 rx_pfc_ena_frames_pri7)},
     150                 :            :         {"rx_stat_discard", offsetof(struct rx_port_stats,
     151                 :            :                                 rx_stat_discard)},
     152                 :            :         {"rx_stat_err", offsetof(struct rx_port_stats,
     153                 :            :                                 rx_stat_err)},
     154                 :            : };
     155                 :            : 
     156                 :            : static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = {
     157                 :            :         {"tx_64b_frames", offsetof(struct tx_port_stats,
     158                 :            :                                 tx_64b_frames)},
     159                 :            :         {"tx_65b_127b_frames", offsetof(struct tx_port_stats,
     160                 :            :                                 tx_65b_127b_frames)},
     161                 :            :         {"tx_128b_255b_frames", offsetof(struct tx_port_stats,
     162                 :            :                                 tx_128b_255b_frames)},
     163                 :            :         {"tx_256b_511b_frames", offsetof(struct tx_port_stats,
     164                 :            :                                 tx_256b_511b_frames)},
     165                 :            :         {"tx_512b_1023b_frames", offsetof(struct tx_port_stats,
     166                 :            :                                 tx_512b_1023b_frames)},
     167                 :            :         {"tx_1024b_1518b_frames", offsetof(struct tx_port_stats,
     168                 :            :                                 tx_1024b_1518b_frames)},
     169                 :            :         {"tx_good_vlan_frames", offsetof(struct tx_port_stats,
     170                 :            :                                 tx_good_vlan_frames)},
     171                 :            :         {"tx_1519b_2047b_frames", offsetof(struct tx_port_stats,
     172                 :            :                                 tx_1519b_2047b_frames)},
     173                 :            :         {"tx_2048b_4095b_frames", offsetof(struct tx_port_stats,
     174                 :            :                                 tx_2048b_4095b_frames)},
     175                 :            :         {"tx_4096b_9216b_frames", offsetof(struct tx_port_stats,
     176                 :            :                                 tx_4096b_9216b_frames)},
     177                 :            :         {"tx_9217b_16383b_frames", offsetof(struct tx_port_stats,
     178                 :            :                                 tx_9217b_16383b_frames)},
     179                 :            :         {"tx_good_frames", offsetof(struct tx_port_stats,
     180                 :            :                                 tx_good_frames)},
     181                 :            :         {"tx_total_frames", offsetof(struct tx_port_stats,
     182                 :            :                                 tx_total_frames)},
     183                 :            :         {"tx_ucast_frames", offsetof(struct tx_port_stats,
     184                 :            :                                 tx_ucast_frames)},
     185                 :            :         {"tx_mcast_frames", offsetof(struct tx_port_stats,
     186                 :            :                                 tx_mcast_frames)},
     187                 :            :         {"tx_bcast_frames", offsetof(struct tx_port_stats,
     188                 :            :                                 tx_bcast_frames)},
     189                 :            :         {"tx_pause_frames", offsetof(struct tx_port_stats,
     190                 :            :                                 tx_pause_frames)},
     191                 :            :         {"tx_pfc_frames", offsetof(struct tx_port_stats,
     192                 :            :                                 tx_pfc_frames)},
     193                 :            :         {"tx_jabber_frames", offsetof(struct tx_port_stats,
     194                 :            :                                 tx_jabber_frames)},
     195                 :            :         {"tx_fcs_err_frames", offsetof(struct tx_port_stats,
     196                 :            :                                 tx_fcs_err_frames)},
     197                 :            :         {"tx_control_frames", offsetof(struct tx_port_stats,
     198                 :            :                                 tx_control_frames)},
     199                 :            :         {"tx_oversz_frames", offsetof(struct tx_port_stats,
     200                 :            :                                 tx_oversz_frames)},
     201                 :            :         {"tx_single_dfrl_frames", offsetof(struct tx_port_stats,
     202                 :            :                                 tx_single_dfrl_frames)},
     203                 :            :         {"tx_multi_dfrl_frames", offsetof(struct tx_port_stats,
     204                 :            :                                 tx_multi_dfrl_frames)},
     205                 :            :         {"tx_single_coll_frames", offsetof(struct tx_port_stats,
     206                 :            :                                 tx_single_coll_frames)},
     207                 :            :         {"tx_multi_coll_frames", offsetof(struct tx_port_stats,
     208                 :            :                                 tx_multi_coll_frames)},
     209                 :            :         {"tx_late_coll_frames", offsetof(struct tx_port_stats,
     210                 :            :                                 tx_late_coll_frames)},
     211                 :            :         {"tx_excessive_coll_frames", offsetof(struct tx_port_stats,
     212                 :            :                                 tx_excessive_coll_frames)},
     213                 :            :         {"tx_frag_frames", offsetof(struct tx_port_stats,
     214                 :            :                                 tx_frag_frames)},
     215                 :            :         {"tx_err", offsetof(struct tx_port_stats,
     216                 :            :                                 tx_err)},
     217                 :            :         {"tx_tagged_frames", offsetof(struct tx_port_stats,
     218                 :            :                                 tx_tagged_frames)},
     219                 :            :         {"tx_dbl_tagged_frames", offsetof(struct tx_port_stats,
     220                 :            :                                 tx_dbl_tagged_frames)},
     221                 :            :         {"tx_runt_frames", offsetof(struct tx_port_stats,
     222                 :            :                                 tx_runt_frames)},
     223                 :            :         {"tx_fifo_underruns", offsetof(struct tx_port_stats,
     224                 :            :                                 tx_fifo_underruns)},
     225                 :            :         {"tx_eee_lpi_events", offsetof(struct tx_port_stats,
     226                 :            :                                 tx_eee_lpi_events)},
     227                 :            :         {"tx_eee_lpi_duration", offsetof(struct tx_port_stats,
     228                 :            :                                 tx_eee_lpi_duration)},
     229                 :            :         {"tx_total_collisions", offsetof(struct tx_port_stats,
     230                 :            :                                 tx_total_collisions)},
     231                 :            :         {"tx_bytes", offsetof(struct tx_port_stats,
     232                 :            :                                 tx_bytes)},
     233                 :            :         {"tx_pfc_ena_frames_pri0", offsetof(struct tx_port_stats,
     234                 :            :                                 tx_pfc_ena_frames_pri0)},
     235                 :            :         {"tx_pfc_ena_frames_pri1", offsetof(struct tx_port_stats,
     236                 :            :                                 tx_pfc_ena_frames_pri1)},
     237                 :            :         {"tx_pfc_ena_frames_pri2", offsetof(struct tx_port_stats,
     238                 :            :                                 tx_pfc_ena_frames_pri2)},
     239                 :            :         {"tx_pfc_ena_frames_pri3", offsetof(struct tx_port_stats,
     240                 :            :                                 tx_pfc_ena_frames_pri3)},
     241                 :            :         {"tx_pfc_ena_frames_pri4", offsetof(struct tx_port_stats,
     242                 :            :                                 tx_pfc_ena_frames_pri4)},
     243                 :            :         {"tx_pfc_ena_frames_pri5", offsetof(struct tx_port_stats,
     244                 :            :                                 tx_pfc_ena_frames_pri5)},
     245                 :            :         {"tx_pfc_ena_frames_pri6", offsetof(struct tx_port_stats,
     246                 :            :                                 tx_pfc_ena_frames_pri6)},
     247                 :            :         {"tx_pfc_ena_frames_pri7", offsetof(struct tx_port_stats,
     248                 :            :                                 tx_pfc_ena_frames_pri7)},
     249                 :            :         {"tx_llfc_logical_msgs", offsetof(struct tx_port_stats,
     250                 :            :                                 tx_llfc_logical_msgs)},
     251                 :            :         {"tx_hcfc_msgs", offsetof(struct tx_port_stats,
     252                 :            :                                 tx_hcfc_msgs)},
     253                 :            :         {"tx_xthol_frames", offsetof(struct tx_port_stats,
     254                 :            :                                 tx_xthol_frames)},
     255                 :            :         {"tx_stat_discard", offsetof(struct tx_port_stats,
     256                 :            :                                 tx_stat_discard)},
     257                 :            :         {"tx_stat_error", offsetof(struct tx_port_stats,
     258                 :            :                                 tx_stat_error)},
     259                 :            : };
     260                 :            : 
     261                 :            : static const struct bnxt_xstats_name_off bnxt_func_stats_ext_strings[] = {
     262                 :            :         {"tx_ucast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     263                 :            :                                 tx_ucast_pkts)},
     264                 :            :         {"tx_mcast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     265                 :            :                                 tx_mcast_pkts)},
     266                 :            :         {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     267                 :            :                                 tx_bcast_pkts)},
     268                 :            :         {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     269                 :            :                                 tx_discard_pkts)},
     270                 :            :         {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     271                 :            :                                 tx_error_pkts)},
     272                 :            :         {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     273                 :            :                                 tx_ucast_bytes)},
     274                 :            :         {"tx_mcast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     275                 :            :                                 tx_mcast_bytes)},
     276                 :            :         {"tx_bcast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     277                 :            :                                 tx_bcast_bytes)},
     278                 :            :         {"rx_ucast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     279                 :            :                                 rx_ucast_pkts)},
     280                 :            :         {"rx_mcast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     281                 :            :                                 rx_mcast_pkts)},
     282                 :            :         {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     283                 :            :                                 rx_bcast_pkts)},
     284                 :            :         {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     285                 :            :                                 rx_discard_pkts)},
     286                 :            :         {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_ext_output,
     287                 :            :                                 rx_error_pkts)},
     288                 :            :         {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     289                 :            :                                 rx_ucast_bytes)},
     290                 :            :         {"rx_mcast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     291                 :            :                                 rx_mcast_bytes)},
     292                 :            :         {"rx_bcast_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     293                 :            :                                 rx_bcast_bytes)},
     294                 :            :         {"rx_tpa_eligible_pkt", offsetof(struct hwrm_func_qstats_ext_output,
     295                 :            :                                 rx_tpa_eligible_pkt)},
     296                 :            :         {"rx_tpa_eligible_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     297                 :            :                                 rx_tpa_eligible_bytes)},
     298                 :            :         {"rx_tpa_pkt", offsetof(struct hwrm_func_qstats_ext_output,
     299                 :            :                                 rx_tpa_pkt)},
     300                 :            :         {"rx_tpa_bytes", offsetof(struct hwrm_func_qstats_ext_output,
     301                 :            :                                 rx_tpa_bytes)},
     302                 :            :         {"rx_tpa_errors", offsetof(struct hwrm_func_qstats_ext_output,
     303                 :            :                                 rx_tpa_errors)},
     304                 :            :         {"rx_tpa_events", offsetof(struct hwrm_func_qstats_ext_output,
     305                 :            :                                 rx_tpa_events)},
     306                 :            : };
     307                 :            : 
     308                 :            : static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = {
     309                 :            :         {"tx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
     310                 :            :                                 tx_ucast_pkts)},
     311                 :            :         {"tx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
     312                 :            :                                 tx_mcast_pkts)},
     313                 :            :         {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
     314                 :            :                                 tx_bcast_pkts)},
     315                 :            :         {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
     316                 :            :                                 tx_discard_pkts)},
     317                 :            :         {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
     318                 :            :                                 tx_drop_pkts)},
     319                 :            :         {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
     320                 :            :                                 tx_ucast_bytes)},
     321                 :            :         {"tx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
     322                 :            :                                 tx_mcast_bytes)},
     323                 :            :         {"tx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
     324                 :            :                                 tx_bcast_bytes)},
     325                 :            :         {"rx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
     326                 :            :                                 rx_ucast_pkts)},
     327                 :            :         {"rx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
     328                 :            :                                 rx_mcast_pkts)},
     329                 :            :         {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
     330                 :            :                                 rx_bcast_pkts)},
     331                 :            :         {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
     332                 :            :                                 rx_discard_pkts)},
     333                 :            :         {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
     334                 :            :                                 rx_drop_pkts)},
     335                 :            :         {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
     336                 :            :                                 rx_ucast_bytes)},
     337                 :            :         {"rx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
     338                 :            :                                 rx_mcast_bytes)},
     339                 :            :         {"rx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
     340                 :            :                                 rx_bcast_bytes)},
     341                 :            :         {"rx_agg_pkts", offsetof(struct hwrm_func_qstats_output,
     342                 :            :                                 rx_agg_pkts)},
     343                 :            :         {"rx_agg_bytes", offsetof(struct hwrm_func_qstats_output,
     344                 :            :                                 rx_agg_bytes)},
     345                 :            :         {"rx_agg_events", offsetof(struct hwrm_func_qstats_output,
     346                 :            :                                 rx_agg_events)},
     347                 :            :         {"rx_agg_aborts", offsetof(struct hwrm_func_qstats_output,
     348                 :            :                                 rx_agg_aborts)},
     349                 :            : };
     350                 :            : 
     351                 :            : 
     352                 :            : static const struct bnxt_xstats_name_off bnxt_rx_ext_stats_strings[] = {
     353                 :            :         {"link_down_events", offsetof(struct rx_port_stats_ext,
     354                 :            :                                 link_down_events)},
     355                 :            :         {"continuous_pause_events", offsetof(struct rx_port_stats_ext,
     356                 :            :                                 continuous_pause_events)},
     357                 :            :         {"resume_pause_events", offsetof(struct rx_port_stats_ext,
     358                 :            :                                 resume_pause_events)},
     359                 :            :         {"continuous_roce_pause_events", offsetof(struct rx_port_stats_ext,
     360                 :            :                                 continuous_roce_pause_events)},
     361                 :            :         {"resume_roce_pause_events", offsetof(struct rx_port_stats_ext,
     362                 :            :                                 resume_roce_pause_events)},
     363                 :            :         {"rx_bytes_cos0", offsetof(struct rx_port_stats_ext,
     364                 :            :                                 rx_bytes_cos0)},
     365                 :            :         {"rx_bytes_cos1", offsetof(struct rx_port_stats_ext,
     366                 :            :                                 rx_bytes_cos1)},
     367                 :            :         {"rx_bytes_cos2", offsetof(struct rx_port_stats_ext,
     368                 :            :                                 rx_bytes_cos2)},
     369                 :            :         {"rx_bytes_cos3", offsetof(struct rx_port_stats_ext,
     370                 :            :                                 rx_bytes_cos3)},
     371                 :            :         {"rx_bytes_cos4", offsetof(struct rx_port_stats_ext,
     372                 :            :                                 rx_bytes_cos4)},
     373                 :            :         {"rx_bytes_cos5", offsetof(struct rx_port_stats_ext,
     374                 :            :                                 rx_bytes_cos5)},
     375                 :            :         {"rx_bytes_cos6", offsetof(struct rx_port_stats_ext,
     376                 :            :                                 rx_bytes_cos6)},
     377                 :            :         {"rx_bytes_cos7", offsetof(struct rx_port_stats_ext,
     378                 :            :                                 rx_bytes_cos7)},
     379                 :            :         {"rx_packets_cos0", offsetof(struct rx_port_stats_ext,
     380                 :            :                                 rx_packets_cos0)},
     381                 :            :         {"rx_packets_cos1", offsetof(struct rx_port_stats_ext,
     382                 :            :                                 rx_packets_cos1)},
     383                 :            :         {"rx_packets_cos2", offsetof(struct rx_port_stats_ext,
     384                 :            :                                 rx_packets_cos2)},
     385                 :            :         {"rx_packets_cos3", offsetof(struct rx_port_stats_ext,
     386                 :            :                                 rx_packets_cos3)},
     387                 :            :         {"rx_packets_cos4", offsetof(struct rx_port_stats_ext,
     388                 :            :                                 rx_packets_cos4)},
     389                 :            :         {"rx_packets_cos5", offsetof(struct rx_port_stats_ext,
     390                 :            :                                 rx_packets_cos5)},
     391                 :            :         {"rx_packets_cos6", offsetof(struct rx_port_stats_ext,
     392                 :            :                                 rx_packets_cos6)},
     393                 :            :         {"rx_packets_cos7", offsetof(struct rx_port_stats_ext,
     394                 :            :                                 rx_packets_cos7)},
     395                 :            :         {"pfc_pri0_rx_duration_us", offsetof(struct rx_port_stats_ext,
     396                 :            :                                 pfc_pri0_rx_duration_us)},
     397                 :            :         {"pfc_pri0_rx_transitions", offsetof(struct rx_port_stats_ext,
     398                 :            :                                 pfc_pri0_rx_transitions)},
     399                 :            :         {"pfc_pri1_rx_duration_us", offsetof(struct rx_port_stats_ext,
     400                 :            :                                 pfc_pri1_rx_duration_us)},
     401                 :            :         {"pfc_pri1_rx_transitions", offsetof(struct rx_port_stats_ext,
     402                 :            :                                 pfc_pri1_rx_transitions)},
     403                 :            :         {"pfc_pri2_rx_duration_us", offsetof(struct rx_port_stats_ext,
     404                 :            :                                 pfc_pri2_rx_duration_us)},
     405                 :            :         {"pfc_pri2_rx_transitions", offsetof(struct rx_port_stats_ext,
     406                 :            :                                 pfc_pri2_rx_transitions)},
     407                 :            :         {"pfc_pri3_rx_duration_us", offsetof(struct rx_port_stats_ext,
     408                 :            :                                 pfc_pri3_rx_duration_us)},
     409                 :            :         {"pfc_pri3_rx_transitions", offsetof(struct rx_port_stats_ext,
     410                 :            :                                 pfc_pri3_rx_transitions)},
     411                 :            :         {"pfc_pri4_rx_duration_us", offsetof(struct rx_port_stats_ext,
     412                 :            :                                 pfc_pri4_rx_duration_us)},
     413                 :            :         {"pfc_pri4_rx_transitions", offsetof(struct rx_port_stats_ext,
     414                 :            :                                 pfc_pri4_rx_transitions)},
     415                 :            :         {"pfc_pri5_rx_duration_us", offsetof(struct rx_port_stats_ext,
     416                 :            :                                 pfc_pri5_rx_duration_us)},
     417                 :            :         {"pfc_pri5_rx_transitions", offsetof(struct rx_port_stats_ext,
     418                 :            :                                 pfc_pri5_rx_transitions)},
     419                 :            :         {"pfc_pri6_rx_duration_us", offsetof(struct rx_port_stats_ext,
     420                 :            :                                 pfc_pri6_rx_duration_us)},
     421                 :            :         {"pfc_pri6_rx_transitions", offsetof(struct rx_port_stats_ext,
     422                 :            :                                 pfc_pri6_rx_transitions)},
     423                 :            :         {"pfc_pri7_rx_duration_us", offsetof(struct rx_port_stats_ext,
     424                 :            :                                 pfc_pri7_rx_duration_us)},
     425                 :            :         {"pfc_pri7_rx_transitions", offsetof(struct rx_port_stats_ext,
     426                 :            :                                 pfc_pri7_rx_transitions)},
     427                 :            :         {"rx_bits",           offsetof(struct rx_port_stats_ext,
     428                 :            :                                 rx_bits)},
     429                 :            :         {"rx_buffer_passed_threshold", offsetof(struct rx_port_stats_ext,
     430                 :            :                                 rx_buffer_passed_threshold)},
     431                 :            :         {"rx_pcs_symbol_err", offsetof(struct rx_port_stats_ext,
     432                 :            :                                 rx_pcs_symbol_err)},
     433                 :            :         {"rx_corrected_bits", offsetof(struct rx_port_stats_ext,
     434                 :            :                                 rx_corrected_bits)},
     435                 :            :         {"rx_discard_bytes_cos0", offsetof(struct rx_port_stats_ext,
     436                 :            :                                 rx_discard_bytes_cos0)},
     437                 :            :         {"rx_discard_bytes_cos1", offsetof(struct rx_port_stats_ext,
     438                 :            :                                 rx_discard_bytes_cos1)},
     439                 :            :         {"rx_discard_bytes_cos2", offsetof(struct rx_port_stats_ext,
     440                 :            :                                 rx_discard_bytes_cos2)},
     441                 :            :         {"rx_discard_bytes_cos3", offsetof(struct rx_port_stats_ext,
     442                 :            :                                 rx_discard_bytes_cos3)},
     443                 :            :         {"rx_discard_bytes_cos4", offsetof(struct rx_port_stats_ext,
     444                 :            :                                 rx_discard_bytes_cos4)},
     445                 :            :         {"rx_discard_bytes_cos5", offsetof(struct rx_port_stats_ext,
     446                 :            :                                 rx_discard_bytes_cos5)},
     447                 :            :         {"rx_discard_bytes_cos6", offsetof(struct rx_port_stats_ext,
     448                 :            :                                 rx_discard_bytes_cos6)},
     449                 :            :         {"rx_discard_bytes_cos7", offsetof(struct rx_port_stats_ext,
     450                 :            :                                 rx_discard_bytes_cos7)},
     451                 :            :         {"rx_discard_packets_cos0", offsetof(struct rx_port_stats_ext,
     452                 :            :                                 rx_discard_packets_cos0)},
     453                 :            :         {"rx_discard_packets_cos1", offsetof(struct rx_port_stats_ext,
     454                 :            :                                 rx_discard_packets_cos1)},
     455                 :            :         {"rx_discard_packets_cos2", offsetof(struct rx_port_stats_ext,
     456                 :            :                                 rx_discard_packets_cos2)},
     457                 :            :         {"rx_discard_packets_cos3", offsetof(struct rx_port_stats_ext,
     458                 :            :                                 rx_discard_packets_cos3)},
     459                 :            :         {"rx_discard_packets_cos4", offsetof(struct rx_port_stats_ext,
     460                 :            :                                 rx_discard_packets_cos4)},
     461                 :            :         {"rx_discard_packets_cos5", offsetof(struct rx_port_stats_ext,
     462                 :            :                                 rx_discard_packets_cos5)},
     463                 :            :         {"rx_discard_packets_cos6", offsetof(struct rx_port_stats_ext,
     464                 :            :                                 rx_discard_packets_cos6)},
     465                 :            :         {"rx_discard_packets_cos7", offsetof(struct rx_port_stats_ext,
     466                 :            :                                 rx_discard_packets_cos7)},
     467                 :            :         {"rx_fec_corrected_blocks", offsetof(struct rx_port_stats_ext,
     468                 :            :                                 rx_fec_corrected_blocks)},
     469                 :            :         {"rx_fec_uncorrectable_blocks", offsetof(struct rx_port_stats_ext,
     470                 :            :                                 rx_fec_uncorrectable_blocks)},
     471                 :            :         {"rx_filter_miss", offsetof(struct rx_port_stats_ext,
     472                 :            :                                 rx_filter_miss)},
     473                 :            : };
     474                 :            : 
     475                 :            : static const struct bnxt_xstats_name_off bnxt_tx_ext_stats_strings[] = {
     476                 :            :         {"tx_bytes_cos0", offsetof(struct tx_port_stats_ext,
     477                 :            :                                 tx_bytes_cos0)},
     478                 :            :         {"tx_bytes_cos1", offsetof(struct tx_port_stats_ext,
     479                 :            :                                 tx_bytes_cos1)},
     480                 :            :         {"tx_bytes_cos2", offsetof(struct tx_port_stats_ext,
     481                 :            :                                 tx_bytes_cos2)},
     482                 :            :         {"tx_bytes_cos3", offsetof(struct tx_port_stats_ext,
     483                 :            :                                 tx_bytes_cos3)},
     484                 :            :         {"tx_bytes_cos4", offsetof(struct tx_port_stats_ext,
     485                 :            :                                 tx_bytes_cos4)},
     486                 :            :         {"tx_bytes_cos5", offsetof(struct tx_port_stats_ext,
     487                 :            :                                 tx_bytes_cos5)},
     488                 :            :         {"tx_bytes_cos6", offsetof(struct tx_port_stats_ext,
     489                 :            :                                 tx_bytes_cos6)},
     490                 :            :         {"tx_bytes_cos7", offsetof(struct tx_port_stats_ext,
     491                 :            :                                 tx_bytes_cos7)},
     492                 :            :         {"tx_packets_cos0", offsetof(struct tx_port_stats_ext,
     493                 :            :                                 tx_packets_cos0)},
     494                 :            :         {"tx_packets_cos1", offsetof(struct tx_port_stats_ext,
     495                 :            :                                 tx_packets_cos1)},
     496                 :            :         {"tx_packets_cos2", offsetof(struct tx_port_stats_ext,
     497                 :            :                                 tx_packets_cos2)},
     498                 :            :         {"tx_packets_cos3", offsetof(struct tx_port_stats_ext,
     499                 :            :                                 tx_packets_cos3)},
     500                 :            :         {"tx_packets_cos4", offsetof(struct tx_port_stats_ext,
     501                 :            :                                 tx_packets_cos4)},
     502                 :            :         {"tx_packets_cos5", offsetof(struct tx_port_stats_ext,
     503                 :            :                                 tx_packets_cos5)},
     504                 :            :         {"tx_packets_cos6", offsetof(struct tx_port_stats_ext,
     505                 :            :                                 tx_packets_cos6)},
     506                 :            :         {"tx_packets_cos7", offsetof(struct tx_port_stats_ext,
     507                 :            :                                 tx_packets_cos7)},
     508                 :            :         {"pfc_pri0_tx_duration_us", offsetof(struct tx_port_stats_ext,
     509                 :            :                                 pfc_pri0_tx_duration_us)},
     510                 :            :         {"pfc_pri0_tx_transitions", offsetof(struct tx_port_stats_ext,
     511                 :            :                                 pfc_pri0_tx_transitions)},
     512                 :            :         {"pfc_pri1_tx_duration_us", offsetof(struct tx_port_stats_ext,
     513                 :            :                                 pfc_pri1_tx_duration_us)},
     514                 :            :         {"pfc_pri1_tx_transitions", offsetof(struct tx_port_stats_ext,
     515                 :            :                                 pfc_pri1_tx_transitions)},
     516                 :            :         {"pfc_pri2_tx_duration_us", offsetof(struct tx_port_stats_ext,
     517                 :            :                                 pfc_pri2_tx_duration_us)},
     518                 :            :         {"pfc_pri2_tx_transitions", offsetof(struct tx_port_stats_ext,
     519                 :            :                                 pfc_pri2_tx_transitions)},
     520                 :            :         {"pfc_pri3_tx_duration_us", offsetof(struct tx_port_stats_ext,
     521                 :            :                                 pfc_pri3_tx_duration_us)},
     522                 :            :         {"pfc_pri3_tx_transitions", offsetof(struct tx_port_stats_ext,
     523                 :            :                                 pfc_pri3_tx_transitions)},
     524                 :            :         {"pfc_pri4_tx_duration_us", offsetof(struct tx_port_stats_ext,
     525                 :            :                                 pfc_pri4_tx_duration_us)},
     526                 :            :         {"pfc_pri4_tx_transitions", offsetof(struct tx_port_stats_ext,
     527                 :            :                                 pfc_pri4_tx_transitions)},
     528                 :            :         {"pfc_pri5_tx_duration_us", offsetof(struct tx_port_stats_ext,
     529                 :            :                                 pfc_pri5_tx_duration_us)},
     530                 :            :         {"pfc_pri5_tx_transitions", offsetof(struct tx_port_stats_ext,
     531                 :            :                                 pfc_pri5_tx_transitions)},
     532                 :            :         {"pfc_pri6_tx_duration_us", offsetof(struct tx_port_stats_ext,
     533                 :            :                                 pfc_pri6_tx_duration_us)},
     534                 :            :         {"pfc_pri6_tx_transitions", offsetof(struct tx_port_stats_ext,
     535                 :            :                                 pfc_pri6_tx_transitions)},
     536                 :            :         {"pfc_pri7_tx_duration_us", offsetof(struct tx_port_stats_ext,
     537                 :            :                                 pfc_pri7_tx_duration_us)},
     538                 :            :         {"pfc_pri7_tx_transitions", offsetof(struct tx_port_stats_ext,
     539                 :            :                                 pfc_pri7_tx_transitions)},
     540                 :            : };
     541                 :            : 
     542                 :            : /*
     543                 :            :  * Statistics functions
     544                 :            :  */
     545                 :            : 
     546                 :          0 : void bnxt_free_stats(struct bnxt *bp)
     547                 :            : {
     548                 :            :         int i;
     549                 :            : 
     550         [ #  # ]:          0 :         for (i = 0; i < (int)bp->tx_cp_nr_rings; i++) {
     551                 :          0 :                 struct bnxt_tx_queue *txq = bp->tx_queues[i];
     552                 :            : 
     553                 :          0 :                 bnxt_free_txq_stats(txq);
     554                 :            :         }
     555         [ #  # ]:          0 :         for (i = 0; i < (int)bp->rx_cp_nr_rings; i++) {
     556                 :          0 :                 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
     557                 :            : 
     558                 :          0 :                 bnxt_free_rxq_stats(rxq);
     559                 :            :         }
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : static void bnxt_fill_rte_eth_stats_ext(struct rte_eth_stats *stats,
     563                 :            :                                         struct bnxt_ring_stats_ext *ring_stats,
     564                 :            :                                         struct eth_queue_stats *qstats,
     565                 :            :                                         unsigned int i, bool rx)
     566                 :            : {
     567         [ #  # ]:          0 :         if (rx) {
     568                 :          0 :                 uint64_t ipackets = ring_stats->rx_ucast_pkts +
     569                 :          0 :                                 ring_stats->rx_mcast_pkts +
     570                 :          0 :                                 ring_stats->rx_bcast_pkts;
     571                 :          0 :                 uint64_t ibytes = ring_stats->rx_ucast_bytes +
     572                 :          0 :                                 ring_stats->rx_mcast_bytes +
     573                 :          0 :                                 ring_stats->rx_bcast_bytes;
     574                 :          0 :                 uint64_t ierrors = ring_stats->rx_discard_pkts +
     575                 :          0 :                                 ring_stats->rx_error_pkts;
     576                 :            : 
     577                 :          0 :                 stats->ipackets += ipackets;
     578                 :          0 :                 stats->ibytes += ibytes;
     579                 :          0 :                 stats->imissed += ring_stats->rx_discard_pkts;
     580                 :          0 :                 stats->ierrors += ring_stats->rx_error_pkts;
     581                 :            : 
     582         [ #  # ]:          0 :                 if (qstats) {
     583                 :          0 :                         qstats->q_ipackets[i] = ipackets;
     584                 :          0 :                         qstats->q_ibytes[i] = ibytes;
     585                 :          0 :                         qstats->q_errors[i] = ierrors;
     586                 :            :                 }
     587                 :            :         } else {
     588                 :          0 :                 uint64_t opackets = ring_stats->tx_ucast_pkts +
     589                 :          0 :                                 ring_stats->tx_mcast_pkts +
     590                 :          0 :                                 ring_stats->tx_bcast_pkts;
     591                 :          0 :                 uint64_t obytes = ring_stats->tx_ucast_bytes +
     592                 :          0 :                                 ring_stats->tx_mcast_bytes +
     593                 :          0 :                                 ring_stats->tx_bcast_bytes;
     594                 :            : 
     595                 :          0 :                 stats->opackets += opackets;
     596                 :          0 :                 stats->obytes += obytes;
     597                 :          0 :                 stats->oerrors += ring_stats->tx_discard_pkts;
     598                 :            : 
     599         [ #  # ]:          0 :                 if (qstats) {
     600                 :          0 :                         qstats->q_opackets[i] = opackets;
     601                 :          0 :                         qstats->q_obytes[i] = obytes;
     602                 :            :                 }
     603                 :            :         }
     604                 :          0 : }
     605                 :            : 
     606                 :          0 : static void bnxt_fill_rte_eth_stats(struct rte_eth_stats *stats,
     607                 :            :                                     struct bnxt_ring_stats *ring_stats,
     608                 :            :                                     struct eth_queue_stats *qstats,
     609                 :            :                                     unsigned int i, bool rx)
     610                 :            : {
     611         [ #  # ]:          0 :         if (rx) {
     612                 :          0 :                 uint64_t ipackets = ring_stats->rx_ucast_pkts +
     613                 :          0 :                                 ring_stats->rx_mcast_pkts +
     614                 :          0 :                                 ring_stats->rx_bcast_pkts;
     615                 :          0 :                 uint64_t ibytes = ring_stats->rx_ucast_bytes +
     616                 :          0 :                                 ring_stats->rx_mcast_bytes +
     617                 :          0 :                                 ring_stats->rx_bcast_bytes;
     618                 :          0 :                 uint64_t ierrors = ring_stats->rx_discard_pkts +
     619                 :          0 :                                 ring_stats->rx_error_pkts;
     620                 :            : 
     621                 :          0 :                 stats->ipackets += ipackets;
     622                 :          0 :                 stats->ibytes += ibytes;
     623                 :          0 :                 stats->imissed += ring_stats->rx_discard_pkts;
     624                 :          0 :                 stats->ierrors += ring_stats->rx_error_pkts;
     625                 :            : 
     626         [ #  # ]:          0 :                 if (qstats) {
     627                 :          0 :                         qstats->q_ipackets[i] = ipackets;
     628                 :          0 :                         qstats->q_ibytes[i] = ibytes;
     629                 :          0 :                         qstats->q_errors[i] = ierrors;
     630                 :            :                 }
     631                 :            :         } else {
     632                 :          0 :                 uint64_t opackets = ring_stats->tx_ucast_pkts +
     633                 :          0 :                                 ring_stats->tx_mcast_pkts +
     634                 :          0 :                                 ring_stats->tx_bcast_pkts;
     635                 :          0 :                 uint64_t obytes = ring_stats->tx_ucast_bytes +
     636                 :          0 :                                 ring_stats->tx_mcast_bytes +
     637                 :          0 :                                 ring_stats->tx_bcast_bytes;
     638                 :            : 
     639                 :          0 :                 stats->opackets += opackets;
     640                 :          0 :                 stats->obytes += obytes;
     641                 :          0 :                 stats->oerrors += ring_stats->tx_discard_pkts;
     642                 :            : 
     643         [ #  # ]:          0 :                 if (qstats) {
     644                 :          0 :                         qstats->q_opackets[i] = opackets;
     645                 :          0 :                         qstats->q_obytes[i] = obytes;
     646                 :            :                 }
     647                 :            :         }
     648                 :          0 : }
     649                 :            : 
     650                 :          0 : static int bnxt_stats_get_ext(struct rte_eth_dev *eth_dev,
     651                 :            :                                  struct rte_eth_stats *bnxt_stats,
     652                 :            :                                  struct eth_queue_stats *qstats)
     653                 :            : {
     654                 :            :         int rc = 0;
     655                 :            :         unsigned int i;
     656                 :          0 :         struct bnxt *bp = eth_dev->data->dev_private;
     657                 :            :         unsigned int num_q_stats;
     658                 :            : 
     659                 :          0 :         num_q_stats = RTE_MIN(bp->rx_cp_nr_rings,
     660                 :            :                               (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
     661                 :            : 
     662         [ #  # ]:          0 :         for (i = 0; i < num_q_stats; i++) {
     663                 :          0 :                 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
     664                 :          0 :                 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
     665                 :          0 :                 struct bnxt_ring_stats_ext ring_stats = {0};
     666                 :            : 
     667         [ #  # ]:          0 :                 if (!rxq->rx_started)
     668                 :          0 :                         continue;
     669                 :            : 
     670                 :          0 :                 rc = bnxt_hwrm_ring_stats_ext(bp, cpr->hw_stats_ctx_id, i,
     671                 :            :                                               &ring_stats, true);
     672         [ #  # ]:          0 :                 if (unlikely(rc))
     673                 :          0 :                         return rc;
     674                 :            : 
     675                 :          0 :                 bnxt_fill_rte_eth_stats_ext(bnxt_stats, &ring_stats, qstats, i, true);
     676                 :          0 :                 bnxt_stats->rx_nombuf +=
     677                 :          0 :                                 rte_atomic_load_explicit(&rxq->rx_mbuf_alloc_fail,
     678                 :            :                                                          rte_memory_order_relaxed);
     679                 :            :         }
     680                 :            : 
     681                 :          0 :         num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
     682                 :            :                               (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
     683                 :            : 
     684         [ #  # ]:          0 :         for (i = 0; i < num_q_stats; i++) {
     685                 :          0 :                 struct bnxt_tx_queue *txq = bp->tx_queues[i];
     686                 :          0 :                 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
     687                 :          0 :                 struct bnxt_ring_stats_ext ring_stats = {0};
     688                 :            : 
     689         [ #  # ]:          0 :                 if (!txq->tx_started)
     690                 :          0 :                         continue;
     691                 :            : 
     692                 :          0 :                 rc = bnxt_hwrm_ring_stats_ext(bp, cpr->hw_stats_ctx_id, i,
     693                 :            :                                               &ring_stats, false);
     694         [ #  # ]:          0 :                 if (unlikely(rc))
     695                 :          0 :                         return rc;
     696                 :            : 
     697                 :          0 :                 bnxt_fill_rte_eth_stats_ext(bnxt_stats, &ring_stats, qstats, i, false);
     698                 :            :         }
     699                 :            : 
     700                 :            :         return rc;
     701                 :            : }
     702                 :            : 
     703                 :          0 : int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
     704                 :            :                       struct rte_eth_stats *bnxt_stats, struct eth_queue_stats *qstats)
     705                 :            : {
     706                 :            :         int rc = 0;
     707                 :            :         unsigned int i;
     708                 :          0 :         struct bnxt *bp = eth_dev->data->dev_private;
     709                 :            :         unsigned int num_q_stats;
     710                 :            : 
     711                 :          0 :         rc = is_bnxt_in_error(bp);
     712         [ #  # ]:          0 :         if (rc)
     713                 :            :                 return rc;
     714                 :            : 
     715         [ #  # ]:          0 :         if (!eth_dev->data->dev_started)
     716                 :            :                 return -EIO;
     717                 :            : 
     718   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp))
     719                 :          0 :                 return bnxt_stats_get_ext(eth_dev, bnxt_stats, qstats);
     720                 :            : 
     721                 :          0 :         num_q_stats = RTE_MIN(bp->rx_cp_nr_rings,
     722                 :            :                               (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
     723                 :            : 
     724         [ #  # ]:          0 :         for (i = 0; i < num_q_stats; i++) {
     725                 :          0 :                 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
     726                 :          0 :                 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
     727                 :          0 :                 struct bnxt_ring_stats ring_stats = {0};
     728                 :            : 
     729         [ #  # ]:          0 :                 if (!rxq->rx_started)
     730                 :          0 :                         continue;
     731                 :            : 
     732                 :          0 :                 rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i,
     733                 :            :                                           &ring_stats, true);
     734         [ #  # ]:          0 :                 if (unlikely(rc))
     735                 :          0 :                         return rc;
     736                 :            : 
     737                 :          0 :                 bnxt_fill_rte_eth_stats(bnxt_stats, &ring_stats, qstats, i, true);
     738                 :          0 :                 bnxt_stats->rx_nombuf +=
     739                 :          0 :                                 rte_atomic_load_explicit(&rxq->rx_mbuf_alloc_fail,
     740                 :            :                                                          rte_memory_order_relaxed);
     741                 :            :         }
     742                 :            : 
     743                 :          0 :         num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
     744                 :            :                               (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
     745                 :            : 
     746         [ #  # ]:          0 :         for (i = 0; i < num_q_stats; i++) {
     747                 :          0 :                 struct bnxt_tx_queue *txq = bp->tx_queues[i];
     748                 :          0 :                 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
     749                 :          0 :                 struct bnxt_ring_stats ring_stats = {0};
     750                 :            : 
     751         [ #  # ]:          0 :                 if (!txq->tx_started)
     752                 :          0 :                         continue;
     753                 :            : 
     754                 :          0 :                 rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i,
     755                 :            :                                           &ring_stats, false);
     756         [ #  # ]:          0 :                 if (unlikely(rc))
     757                 :          0 :                         return rc;
     758                 :            : 
     759                 :          0 :                 bnxt_fill_rte_eth_stats(bnxt_stats, &ring_stats, qstats, i, false);
     760                 :          0 :                 bnxt_stats->oerrors +=
     761                 :          0 :                                 rte_atomic_load_explicit(&txq->tx_mbuf_drop,
     762                 :            :                                                          rte_memory_order_relaxed);
     763                 :            :         }
     764                 :            : 
     765                 :            :         return rc;
     766                 :            : }
     767                 :            : 
     768                 :          0 : static void bnxt_clear_prev_stat(struct bnxt *bp)
     769                 :            : {
     770                 :            :         /*
     771                 :            :          * Clear the cached values of stats returned by HW in the previous
     772                 :            :          * get operation.
     773                 :            :          */
     774   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp)) {
     775                 :          0 :                 memset(bp->prev_rx_ring_stats_ext, 0,
     776                 :          0 :                        sizeof(struct bnxt_ring_stats_ext) * bp->rx_cp_nr_rings);
     777                 :          0 :                 memset(bp->prev_tx_ring_stats_ext, 0,
     778                 :          0 :                        sizeof(struct bnxt_ring_stats_ext) * bp->tx_cp_nr_rings);
     779                 :            :         } else {
     780                 :          0 :                 memset(bp->prev_rx_ring_stats, 0,
     781                 :          0 :                        sizeof(struct bnxt_ring_stats) * bp->rx_cp_nr_rings);
     782                 :          0 :                 memset(bp->prev_tx_ring_stats, 0,
     783                 :          0 :                        sizeof(struct bnxt_ring_stats) * bp->tx_cp_nr_rings);
     784                 :            :         }
     785                 :          0 : }
     786                 :            : 
     787                 :          0 : int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
     788                 :            : {
     789                 :          0 :         struct bnxt *bp = eth_dev->data->dev_private;
     790                 :            :         unsigned int i;
     791                 :            :         int ret;
     792                 :            : 
     793                 :          0 :         ret = is_bnxt_in_error(bp);
     794         [ #  # ]:          0 :         if (ret)
     795                 :            :                 return ret;
     796                 :            : 
     797         [ #  # ]:          0 :         if (!eth_dev->data->dev_started) {
     798                 :          0 :                 PMD_DRV_LOG_LINE(ERR, "Device Initialization not complete!");
     799                 :          0 :                 return -EINVAL;
     800                 :            :         }
     801                 :            : 
     802                 :          0 :         ret = bnxt_clear_all_hwrm_stat_ctxs(bp);
     803         [ #  # ]:          0 :         for (i = 0; i < bp->rx_cp_nr_rings; i++) {
     804                 :          0 :                 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
     805                 :            : 
     806                 :          0 :                 rxq->rx_mbuf_alloc_fail = 0;
     807                 :            :         }
     808                 :            : 
     809         [ #  # ]:          0 :         for (i = 0; i < bp->tx_cp_nr_rings; i++) {
     810                 :          0 :                 struct bnxt_tx_queue *txq = bp->tx_queues[i];
     811                 :            : 
     812                 :          0 :                 txq->tx_mbuf_drop = 0;
     813                 :            :         }
     814                 :            : 
     815                 :          0 :         bnxt_clear_prev_stat(bp);
     816                 :            : 
     817                 :          0 :         return ret;
     818                 :            : }
     819                 :            : 
     820                 :          0 : static void bnxt_fill_func_qstats_ext(struct hwrm_func_qstats_ext_output *func_qstats,
     821                 :            :                                       struct bnxt_ring_stats_ext *ring_stats,
     822                 :            :                                       bool rx)
     823                 :            : {
     824         [ #  # ]:          0 :         if (rx) {
     825                 :          0 :                 func_qstats->rx_ucast_pkts += ring_stats->rx_ucast_pkts;
     826                 :          0 :                 func_qstats->rx_mcast_pkts += ring_stats->rx_mcast_pkts;
     827                 :          0 :                 func_qstats->rx_bcast_pkts += ring_stats->rx_bcast_pkts;
     828                 :            : 
     829                 :          0 :                 func_qstats->rx_ucast_bytes += ring_stats->rx_ucast_bytes;
     830                 :          0 :                 func_qstats->rx_mcast_bytes += ring_stats->rx_mcast_bytes;
     831                 :          0 :                 func_qstats->rx_bcast_bytes += ring_stats->rx_bcast_bytes;
     832                 :            : 
     833                 :          0 :                 func_qstats->rx_discard_pkts += ring_stats->rx_discard_pkts;
     834                 :          0 :                 func_qstats->rx_error_pkts += ring_stats->rx_error_pkts;
     835                 :            : 
     836                 :          0 :                 func_qstats->rx_tpa_eligible_pkt += ring_stats->rx_tpa_eligible_pkt;
     837                 :          0 :                 func_qstats->rx_tpa_eligible_bytes += ring_stats->rx_tpa_eligible_bytes;
     838                 :          0 :                 func_qstats->rx_tpa_pkt += ring_stats->rx_tpa_pkt;
     839                 :          0 :                 func_qstats->rx_tpa_bytes += ring_stats->rx_tpa_bytes;
     840                 :          0 :                 func_qstats->rx_tpa_errors += ring_stats->rx_tpa_errors;
     841                 :          0 :                 func_qstats->rx_tpa_events += ring_stats->rx_tpa_events;
     842                 :            :         } else {
     843                 :          0 :                 func_qstats->tx_ucast_pkts += ring_stats->tx_ucast_pkts;
     844                 :          0 :                 func_qstats->tx_mcast_pkts += ring_stats->tx_mcast_pkts;
     845                 :          0 :                 func_qstats->tx_bcast_pkts += ring_stats->tx_bcast_pkts;
     846                 :            : 
     847                 :          0 :                 func_qstats->tx_ucast_bytes += ring_stats->tx_ucast_bytes;
     848                 :          0 :                 func_qstats->tx_mcast_bytes += ring_stats->tx_mcast_bytes;
     849                 :          0 :                 func_qstats->tx_bcast_bytes += ring_stats->tx_bcast_bytes;
     850                 :            : 
     851                 :          0 :                 func_qstats->tx_error_pkts += ring_stats->tx_error_pkts;
     852                 :          0 :                 func_qstats->tx_discard_pkts += ring_stats->tx_discard_pkts;
     853                 :            :         }
     854                 :          0 : }
     855                 :            : 
     856                 :          0 : static void bnxt_fill_func_qstats(struct hwrm_func_qstats_output *func_qstats,
     857                 :            :                                   struct bnxt_ring_stats *ring_stats,
     858                 :            :                                   bool rx)
     859                 :            : {
     860         [ #  # ]:          0 :         if (rx) {
     861                 :          0 :                 func_qstats->rx_ucast_pkts += ring_stats->rx_ucast_pkts;
     862                 :          0 :                 func_qstats->rx_mcast_pkts += ring_stats->rx_mcast_pkts;
     863                 :          0 :                 func_qstats->rx_bcast_pkts += ring_stats->rx_bcast_pkts;
     864                 :            : 
     865                 :          0 :                 func_qstats->rx_ucast_bytes += ring_stats->rx_ucast_bytes;
     866                 :          0 :                 func_qstats->rx_mcast_bytes += ring_stats->rx_mcast_bytes;
     867                 :          0 :                 func_qstats->rx_bcast_bytes += ring_stats->rx_bcast_bytes;
     868                 :            : 
     869                 :          0 :                 func_qstats->rx_discard_pkts += ring_stats->rx_discard_pkts;
     870                 :          0 :                 func_qstats->rx_drop_pkts += ring_stats->rx_error_pkts;
     871                 :            : 
     872                 :          0 :                 func_qstats->rx_agg_pkts += ring_stats->rx_agg_pkts;
     873                 :          0 :                 func_qstats->rx_agg_bytes += ring_stats->rx_agg_bytes;
     874                 :          0 :                 func_qstats->rx_agg_events += ring_stats->rx_agg_events;
     875                 :          0 :                 func_qstats->rx_agg_aborts += ring_stats->rx_agg_aborts;
     876                 :            :         } else {
     877                 :          0 :                 func_qstats->tx_ucast_pkts += ring_stats->tx_ucast_pkts;
     878                 :          0 :                 func_qstats->tx_mcast_pkts += ring_stats->tx_mcast_pkts;
     879                 :          0 :                 func_qstats->tx_bcast_pkts += ring_stats->tx_bcast_pkts;
     880                 :            : 
     881                 :          0 :                 func_qstats->tx_ucast_bytes += ring_stats->tx_ucast_bytes;
     882                 :          0 :                 func_qstats->tx_mcast_bytes += ring_stats->tx_mcast_bytes;
     883                 :          0 :                 func_qstats->tx_bcast_bytes += ring_stats->tx_bcast_bytes;
     884                 :            : 
     885                 :          0 :                 func_qstats->tx_drop_pkts += ring_stats->tx_error_pkts;
     886                 :          0 :                 func_qstats->tx_discard_pkts += ring_stats->tx_discard_pkts;
     887                 :            :         }
     888                 :          0 : }
     889                 :            : 
     890                 :          0 : int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
     891                 :            :                            struct rte_eth_xstat *xstats, unsigned int n)
     892                 :            : {
     893                 :          0 :         struct bnxt *bp = eth_dev->data->dev_private;
     894                 :            :         unsigned int count, i;
     895                 :            :         unsigned int rx_port_stats_ext_cnt;
     896                 :            :         unsigned int tx_port_stats_ext_cnt;
     897                 :            :         unsigned int stat_size = sizeof(uint64_t);
     898                 :          0 :         struct hwrm_func_qstats_output func_qstats = {0};
     899                 :          0 :         struct hwrm_func_qstats_ext_output func_qstats_ext = {0};
     900                 :            :         unsigned int stat_count, sz;
     901                 :            :         int rc;
     902                 :            : 
     903                 :          0 :         rc = is_bnxt_in_error(bp);
     904         [ #  # ]:          0 :         if (rc)
     905                 :            :                 return rc;
     906                 :            : 
     907   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp))
     908                 :            :                 sz = RTE_DIM(bnxt_func_stats_ext_strings);
     909                 :            :         else
     910                 :            :                 sz = RTE_DIM(bnxt_func_stats_strings);
     911                 :            : 
     912                 :          0 :         stat_count = RTE_DIM(bnxt_rx_stats_strings) +
     913                 :            :                 RTE_DIM(bnxt_tx_stats_strings) + sz +
     914                 :            :                 RTE_DIM(bnxt_rx_ext_stats_strings) +
     915                 :          0 :                 RTE_DIM(bnxt_tx_ext_stats_strings) +
     916                 :          0 :                 bnxt_flow_stats_cnt(bp);
     917                 :            : 
     918         [ #  # ]:          0 :         if (n < stat_count || xstats == NULL)
     919                 :          0 :                 return stat_count;
     920                 :            : 
     921         [ #  # ]:          0 :         for (i = 0; i < bp->rx_cp_nr_rings; i++) {
     922                 :          0 :                 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
     923                 :          0 :                 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
     924                 :          0 :                 struct bnxt_ring_stats ring_stats = {0};
     925                 :          0 :                 struct bnxt_ring_stats_ext ring_stats_ext = {0};
     926                 :            : 
     927         [ #  # ]:          0 :                 if (!rxq->rx_started)
     928                 :          0 :                         continue;
     929                 :            : 
     930   [ #  #  #  # ]:          0 :                 if (BNXT_TPA_V2_P7(bp))
     931                 :          0 :                         rc = bnxt_hwrm_ring_stats_ext(bp, cpr->hw_stats_ctx_id, i,
     932                 :            :                                                       &ring_stats_ext, true);
     933                 :            :                 else
     934                 :          0 :                         rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i,
     935                 :            :                                                   &ring_stats, true);
     936                 :            : 
     937         [ #  # ]:          0 :                 if (unlikely(rc))
     938                 :          0 :                         return rc;
     939                 :            : 
     940   [ #  #  #  # ]:          0 :                 if (BNXT_TPA_V2_P7(bp))
     941                 :          0 :                         bnxt_fill_func_qstats_ext(&func_qstats_ext,
     942                 :            :                                                   &ring_stats_ext, true);
     943                 :            :                 else
     944                 :          0 :                         bnxt_fill_func_qstats(&func_qstats, &ring_stats, true);
     945                 :            :         }
     946                 :            : 
     947         [ #  # ]:          0 :         for (i = 0; i < bp->tx_cp_nr_rings; i++) {
     948                 :          0 :                 struct bnxt_tx_queue *txq = bp->tx_queues[i];
     949                 :          0 :                 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
     950                 :          0 :                 struct bnxt_ring_stats ring_stats = {0};
     951                 :          0 :                 struct bnxt_ring_stats_ext ring_stats_ext = {0};
     952                 :            : 
     953         [ #  # ]:          0 :                 if (!txq->tx_started)
     954                 :          0 :                         continue;
     955                 :            : 
     956   [ #  #  #  # ]:          0 :                 if (BNXT_TPA_V2_P7(bp))
     957                 :          0 :                         rc = bnxt_hwrm_ring_stats_ext(bp, cpr->hw_stats_ctx_id, i,
     958                 :            :                                                       &ring_stats_ext, false);
     959                 :            :                 else
     960                 :          0 :                         rc = bnxt_hwrm_ring_stats(bp, cpr->hw_stats_ctx_id, i,
     961                 :            :                                                   &ring_stats, false);
     962         [ #  # ]:          0 :                 if (unlikely(rc))
     963                 :          0 :                         return rc;
     964                 :            : 
     965   [ #  #  #  # ]:          0 :                 if (BNXT_TPA_V2_P7(bp))
     966                 :          0 :                         bnxt_fill_func_qstats_ext(&func_qstats_ext,
     967                 :            :                                                   &ring_stats_ext, false);
     968                 :            :                 else
     969                 :          0 :                         bnxt_fill_func_qstats(&func_qstats, &ring_stats, false);
     970                 :            :         }
     971                 :            : 
     972                 :          0 :         bnxt_hwrm_port_qstats(bp);
     973                 :          0 :         bnxt_hwrm_ext_port_qstats(bp);
     974                 :          0 :         rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings),
     975                 :            :                                         (bp->fw_rx_port_stats_ext_size /
     976                 :            :                                          stat_size));
     977                 :          0 :         tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings),
     978                 :            :                                         (bp->fw_tx_port_stats_ext_size /
     979                 :            :                                          stat_size));
     980                 :            : 
     981                 :          0 :         memset(xstats, 0, sizeof(*xstats) * n);
     982                 :            : 
     983                 :            :         count = 0;
     984         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
     985                 :          0 :                 uint64_t *rx_stats = (uint64_t *)bp->hw_rx_port_stats;
     986                 :          0 :                 xstats[count].id = count;
     987                 :          0 :                 xstats[count].value = rte_le_to_cpu_64(
     988                 :            :                                 *(uint64_t *)((char *)rx_stats +
     989                 :            :                                 bnxt_rx_stats_strings[i].offset));
     990                 :          0 :                 count++;
     991                 :            :         }
     992                 :            : 
     993         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
     994                 :          0 :                 uint64_t *tx_stats = (uint64_t *)bp->hw_tx_port_stats;
     995                 :          0 :                 xstats[count].id = count;
     996                 :          0 :                 xstats[count].value = rte_le_to_cpu_64(
     997                 :            :                                  *(uint64_t *)((char *)tx_stats +
     998                 :            :                                 bnxt_tx_stats_strings[i].offset));
     999                 :          0 :                 count++;
    1000                 :            :         }
    1001                 :            : 
    1002   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp)) {
    1003         [ #  # ]:          0 :                 for (i = 0; i < RTE_DIM(bnxt_func_stats_ext_strings); i++) {
    1004                 :          0 :                         xstats[count].id = count;
    1005                 :          0 :                         xstats[count].value = *(uint64_t *)((char *)&func_qstats_ext +
    1006                 :          0 :                                                             bnxt_func_stats_ext_strings[i].offset);
    1007                 :          0 :                         count++;
    1008                 :            :                 }
    1009                 :          0 :                 goto skip_func_stats;
    1010                 :            :         }
    1011         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
    1012                 :          0 :                 xstats[count].id = count;
    1013                 :          0 :                 xstats[count].value = *(uint64_t *)((char *)&func_qstats +
    1014                 :          0 :                                          bnxt_func_stats_strings[i].offset);
    1015                 :          0 :                 count++;
    1016                 :            :         }
    1017                 :            : 
    1018                 :          0 : skip_func_stats:
    1019         [ #  # ]:          0 :         for (i = 0; i < rx_port_stats_ext_cnt; i++) {
    1020                 :          0 :                 uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext;
    1021                 :            : 
    1022                 :          0 :                 xstats[count].value = rte_le_to_cpu_64
    1023                 :            :                                         (*(uint64_t *)((char *)rx_stats_ext +
    1024                 :            :                                          bnxt_rx_ext_stats_strings[i].offset));
    1025                 :            : 
    1026                 :          0 :                 count++;
    1027                 :            :         }
    1028                 :            : 
    1029         [ #  # ]:          0 :         for (i = 0; i < tx_port_stats_ext_cnt; i++) {
    1030                 :          0 :                 uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext;
    1031                 :            : 
    1032                 :          0 :                 xstats[count].value = rte_le_to_cpu_64
    1033                 :            :                                         (*(uint64_t *)((char *)tx_stats_ext +
    1034                 :            :                                          bnxt_tx_ext_stats_strings[i].offset));
    1035                 :          0 :                 count++;
    1036                 :            :         }
    1037                 :            : 
    1038         [ #  # ]:          0 :         if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS &&
    1039                 :          0 :             bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT &&
    1040         [ #  # ]:          0 :             BNXT_FLOW_XSTATS_EN(bp)) {
    1041                 :            :                 int j;
    1042                 :            : 
    1043                 :            :                 i = 0;
    1044         [ #  # ]:          0 :                 for (j = 0; j < bp->max_vnics; j++) {
    1045                 :            :                         struct bnxt_filter_info *filter;
    1046                 :            :                         struct bnxt_vnic_info *vnic;
    1047                 :            :                         struct rte_flow *flow;
    1048                 :            : 
    1049                 :          0 :                         vnic = &bp->vnic_info[j];
    1050   [ #  #  #  # ]:          0 :                         if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID)
    1051                 :          0 :                                 continue;
    1052                 :            : 
    1053         [ #  # ]:          0 :                         if (STAILQ_EMPTY(&vnic->flow_list))
    1054                 :          0 :                                 continue;
    1055                 :            : 
    1056         [ #  # ]:          0 :                         STAILQ_FOREACH(flow, &vnic->flow_list, next) {
    1057         [ #  # ]:          0 :                                 if (!flow || !flow->filter)
    1058                 :          0 :                                         continue;
    1059                 :            : 
    1060                 :            :                                 filter = flow->filter;
    1061                 :          0 :                                 xstats[count].id = count;
    1062                 :          0 :                                 xstats[count].value =
    1063                 :          0 :                                         filter->hw_stats.bytes;
    1064                 :          0 :                                 count++;
    1065                 :          0 :                                 xstats[count].id = count;
    1066                 :          0 :                                 xstats[count].value =
    1067                 :          0 :                                         filter->hw_stats.packets;
    1068                 :          0 :                                 count++;
    1069         [ #  # ]:          0 :                                 if (++i > bp->max_l2_ctx)
    1070                 :            :                                         break;
    1071                 :            :                         }
    1072         [ #  # ]:          0 :                         if (i > bp->max_l2_ctx)
    1073                 :            :                                 break;
    1074                 :            :                 }
    1075                 :            :         }
    1076                 :            : 
    1077                 :          0 :         return stat_count;
    1078                 :            : }
    1079                 :            : 
    1080                 :          0 : int bnxt_flow_stats_cnt(struct bnxt *bp)
    1081                 :            : {
    1082         [ #  # ]:          0 :         if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS &&
    1083                 :          0 :             bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT &&
    1084         [ #  # ]:          0 :             BNXT_FLOW_XSTATS_EN(bp)) {
    1085                 :          0 :                 struct bnxt_xstats_name_off flow_bytes[bp->max_l2_ctx];
    1086                 :            :                 struct bnxt_xstats_name_off flow_pkts[bp->max_l2_ctx];
    1087                 :            : 
    1088                 :          0 :                 return RTE_DIM(flow_bytes) + RTE_DIM(flow_pkts);
    1089                 :            :         }
    1090                 :            : 
    1091                 :            :         return 0;
    1092                 :            : }
    1093                 :            : 
    1094                 :          0 : int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev,
    1095                 :            :                 struct rte_eth_xstat_name *xstats_names,
    1096                 :            :                 unsigned int size)
    1097                 :            : {
    1098                 :          0 :         struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
    1099                 :            :         unsigned int stat_cnt;
    1100                 :            :         unsigned int i, count = 0, sz;
    1101                 :            :         int rc;
    1102                 :            : 
    1103                 :          0 :         rc = is_bnxt_in_error(bp);
    1104         [ #  # ]:          0 :         if (rc)
    1105                 :            :                 return rc;
    1106                 :            : 
    1107   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp))
    1108                 :            :                 sz = RTE_DIM(bnxt_func_stats_ext_strings);
    1109                 :            :         else
    1110                 :            :                 sz = RTE_DIM(bnxt_func_stats_strings);
    1111                 :            : 
    1112                 :          0 :         stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
    1113                 :            :                                 RTE_DIM(bnxt_tx_stats_strings) +
    1114                 :            :                                 sz +
    1115                 :            :                                 RTE_DIM(bnxt_rx_ext_stats_strings) +
    1116                 :          0 :                                 RTE_DIM(bnxt_tx_ext_stats_strings) +
    1117                 :          0 :                                 bnxt_flow_stats_cnt(bp);
    1118                 :            : 
    1119         [ #  # ]:          0 :         if (xstats_names == NULL || size < stat_cnt)
    1120                 :          0 :                 return stat_cnt;
    1121                 :            : 
    1122         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
    1123                 :          0 :                 strlcpy(xstats_names[count].name,
    1124                 :            :                         bnxt_rx_stats_strings[i].name,
    1125                 :            :                         sizeof(xstats_names[count].name));
    1126                 :          0 :                 count++;
    1127                 :            :         }
    1128                 :            : 
    1129         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
    1130                 :          0 :                 strlcpy(xstats_names[count].name,
    1131                 :            :                         bnxt_tx_stats_strings[i].name,
    1132                 :            :                         sizeof(xstats_names[count].name));
    1133                 :          0 :                 count++;
    1134                 :            :         }
    1135                 :            : 
    1136   [ #  #  #  # ]:          0 :         if (BNXT_TPA_V2_P7(bp)) {
    1137         [ #  # ]:          0 :                 for (i = 0; i < RTE_DIM(bnxt_func_stats_ext_strings); i++) {
    1138                 :          0 :                         strlcpy(xstats_names[count].name,
    1139                 :            :                                 bnxt_func_stats_ext_strings[i].name,
    1140                 :            :                                 sizeof(xstats_names[count].name));
    1141                 :          0 :                         count++;
    1142                 :            :                 }
    1143                 :          0 :                 goto skip_func_stats;
    1144                 :            :         }
    1145                 :            : 
    1146         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
    1147                 :          0 :                 strlcpy(xstats_names[count].name,
    1148                 :            :                         bnxt_func_stats_strings[i].name,
    1149                 :            :                         sizeof(xstats_names[count].name));
    1150                 :          0 :                 count++;
    1151                 :            :         }
    1152                 :            : 
    1153                 :          0 : skip_func_stats:
    1154         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) {
    1155                 :          0 :                 strlcpy(xstats_names[count].name,
    1156                 :            :                         bnxt_rx_ext_stats_strings[i].name,
    1157                 :            :                         sizeof(xstats_names[count].name));
    1158                 :            : 
    1159                 :          0 :                 count++;
    1160                 :            :         }
    1161                 :            : 
    1162         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) {
    1163                 :          0 :                 strlcpy(xstats_names[count].name,
    1164                 :            :                         bnxt_tx_ext_stats_strings[i].name,
    1165                 :            :                         sizeof(xstats_names[count].name));
    1166                 :            : 
    1167                 :          0 :                 count++;
    1168                 :            :         }
    1169                 :            : 
    1170         [ #  # ]:          0 :         if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS &&
    1171                 :          0 :             bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT &&
    1172         [ #  # ]:          0 :             BNXT_FLOW_XSTATS_EN(bp)) {
    1173         [ #  # ]:          0 :                 for (i = 0; i < bp->max_l2_ctx; i++) {
    1174                 :            :                         char buf[RTE_ETH_XSTATS_NAME_SIZE];
    1175                 :            : 
    1176                 :            :                         sprintf(buf, "flow_%d_bytes", i);
    1177                 :          0 :                         strlcpy(xstats_names[count].name, buf,
    1178                 :            :                                 sizeof(xstats_names[count].name));
    1179                 :          0 :                         count++;
    1180                 :            : 
    1181                 :            :                         sprintf(buf, "flow_%d_packets", i);
    1182                 :          0 :                         strlcpy(xstats_names[count].name, buf,
    1183                 :            :                                 sizeof(xstats_names[count].name));
    1184                 :            : 
    1185                 :          0 :                         count++;
    1186                 :            :                 }
    1187                 :            :         }
    1188                 :            : 
    1189                 :          0 :         return stat_cnt;
    1190                 :            : }
    1191                 :            : 
    1192                 :          0 : int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
    1193                 :            : {
    1194                 :          0 :         struct bnxt *bp = eth_dev->data->dev_private;
    1195                 :            :         int ret;
    1196                 :            : 
    1197                 :          0 :         ret = is_bnxt_in_error(bp);
    1198         [ #  # ]:          0 :         if (ret)
    1199                 :            :                 return ret;
    1200                 :            : 
    1201         [ #  # ]:          0 :         if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) ||
    1202                 :            :             !(bp->flags & BNXT_FLAG_PORT_STATS)) {
    1203                 :          0 :                 PMD_DRV_LOG_LINE(ERR, "Operation not supported");
    1204                 :          0 :                 return -ENOTSUP;
    1205                 :            :         }
    1206                 :            : 
    1207                 :          0 :         ret = bnxt_hwrm_port_clr_stats(bp);
    1208         [ #  # ]:          0 :         if (ret != 0)
    1209                 :          0 :                 PMD_DRV_LOG_LINE(ERR, "Failed to reset xstats: %s",
    1210                 :            :                             strerror(-ret));
    1211                 :            : 
    1212                 :          0 :         bnxt_clear_prev_stat(bp);
    1213                 :            : 
    1214                 :          0 :         return ret;
    1215                 :            : }
    1216                 :            : 
    1217                 :            : /* Update the input context memory with the flow counter IDs
    1218                 :            :  * of the flows that we are interested in.
    1219                 :            :  * Also, update the output tables with the current local values
    1220                 :            :  * since that is what will be used by FW to accumulate
    1221                 :            :  */
    1222                 :            : static void bnxt_update_fc_pre_qstat(uint32_t *in_tbl,
    1223                 :            :                                      uint64_t *out_tbl,
    1224                 :            :                                      struct bnxt_filter_info *filter,
    1225                 :            :                                      uint32_t *ptbl_cnt)
    1226                 :            : {
    1227                 :            :         uint32_t in_tbl_cnt = *ptbl_cnt;
    1228                 :            : 
    1229                 :          0 :         in_tbl[in_tbl_cnt] = filter->flow_id;
    1230                 :          0 :         out_tbl[2 * in_tbl_cnt] = filter->hw_stats.packets;
    1231                 :          0 :         out_tbl[2 * in_tbl_cnt + 1] = filter->hw_stats.bytes;
    1232                 :          0 :         in_tbl_cnt++;
    1233                 :            :         *ptbl_cnt = in_tbl_cnt;
    1234                 :          0 : }
    1235                 :            : 
    1236                 :            : /* Post issuing counter_qstats cmd, update the driver's local stat
    1237                 :            :  * entries with the values DMA-ed by FW in the output table
    1238                 :            :  */
    1239                 :            : static void bnxt_update_fc_post_qstat(struct bnxt_filter_info *filter,
    1240                 :            :                                       uint64_t *out_tbl,
    1241                 :            :                                       uint32_t out_tbl_idx)
    1242                 :            : {
    1243                 :          0 :         filter->hw_stats.packets = out_tbl[2 * out_tbl_idx];
    1244                 :          0 :         filter->hw_stats.bytes = out_tbl[(2 * out_tbl_idx) + 1];
    1245                 :            : }
    1246                 :            : 
    1247                 :          0 : static int bnxt_update_fc_tbl(struct bnxt *bp, uint16_t ctr,
    1248                 :            :                               struct bnxt_filter_info *en_tbl[],
    1249                 :            :                               uint16_t in_flow_cnt)
    1250                 :            : {
    1251                 :            :         uint32_t *in_rx_tbl;
    1252                 :            :         uint64_t *out_rx_tbl;
    1253                 :            :         uint32_t in_rx_tbl_cnt = 0;
    1254                 :            :         uint32_t out_rx_tbl_cnt = 0;
    1255                 :            :         int i, rc = 0;
    1256                 :            : 
    1257                 :          0 :         in_rx_tbl = (uint32_t *)bp->flow_stat->rx_fc_in_tbl.va;
    1258                 :          0 :         out_rx_tbl = (uint64_t *)bp->flow_stat->rx_fc_out_tbl.va;
    1259                 :            : 
    1260         [ #  # ]:          0 :         for (i = 0; i < in_flow_cnt; i++) {
    1261         [ #  # ]:          0 :                 if (!en_tbl[i])
    1262                 :          0 :                         continue;
    1263                 :            : 
    1264                 :            :                 /* Currently only ingress/Rx flows are supported anyway. */
    1265                 :            :                 bnxt_update_fc_pre_qstat(in_rx_tbl, out_rx_tbl,
    1266                 :            :                                          en_tbl[i], &in_rx_tbl_cnt);
    1267                 :            :         }
    1268                 :            : 
    1269                 :            :         /* Currently only ingress/Rx flows are supported */
    1270         [ #  # ]:          0 :         if (in_rx_tbl_cnt) {
    1271                 :          0 :                 rc = bnxt_hwrm_cfa_counter_qstats(bp, BNXT_DIR_RX, ctr,
    1272                 :            :                                                   in_rx_tbl_cnt);
    1273         [ #  # ]:          0 :                 if (rc)
    1274                 :            :                         return rc;
    1275                 :            :         }
    1276                 :            : 
    1277         [ #  # ]:          0 :         for (i = 0; i < in_flow_cnt; i++) {
    1278         [ #  # ]:          0 :                 if (!en_tbl[i])
    1279                 :          0 :                         continue;
    1280                 :            : 
    1281                 :            :                 /* Currently only ingress/Rx flows are supported */
    1282                 :            :                 bnxt_update_fc_post_qstat(en_tbl[i], out_rx_tbl,
    1283                 :            :                                           out_rx_tbl_cnt);
    1284                 :          0 :                 out_rx_tbl_cnt++;
    1285                 :            :         }
    1286                 :            : 
    1287                 :            :         return rc;
    1288                 :            : }
    1289                 :            : 
    1290                 :            : /* Walks through the list which has all the flows
    1291                 :            :  * requesting for explicit flow counters.
    1292                 :            :  */
    1293                 :          0 : int bnxt_flow_stats_req(struct bnxt *bp)
    1294                 :          0 : {
    1295                 :            :         int i;
    1296                 :            :         int rc = 0;
    1297                 :            :         struct rte_flow *flow;
    1298                 :            :         uint16_t in_flow_tbl_cnt = 0;
    1299                 :            :         struct bnxt_vnic_info *vnic = NULL;
    1300                 :          0 :         struct bnxt_filter_info *valid_en_tbl[bp->flow_stat->max_fc];
    1301                 :            :         uint16_t counter_type = CFA_COUNTER_CFG_IN_COUNTER_TYPE_FC;
    1302                 :            : 
    1303                 :          0 :         bnxt_acquire_flow_lock(bp);
    1304         [ #  # ]:          0 :         for (i = 0; i < bp->max_vnics; i++) {
    1305                 :          0 :                 vnic = &bp->vnic_info[i];
    1306   [ #  #  #  # ]:          0 :                 if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID)
    1307                 :          0 :                         continue;
    1308                 :            : 
    1309         [ #  # ]:          0 :                 if (STAILQ_EMPTY(&vnic->flow_list))
    1310                 :          0 :                         continue;
    1311                 :            : 
    1312         [ #  # ]:          0 :                 STAILQ_FOREACH(flow, &vnic->flow_list, next) {
    1313         [ #  # ]:          0 :                         if (!flow || !flow->filter)
    1314                 :          0 :                                 continue;
    1315                 :            : 
    1316                 :          0 :                         valid_en_tbl[in_flow_tbl_cnt++] = flow->filter;
    1317         [ #  # ]:          0 :                         if (in_flow_tbl_cnt >= bp->flow_stat->max_fc) {
    1318                 :          0 :                                 rc = bnxt_update_fc_tbl(bp, counter_type,
    1319                 :            :                                                         valid_en_tbl,
    1320                 :            :                                                         in_flow_tbl_cnt);
    1321         [ #  # ]:          0 :                                 if (rc)
    1322                 :          0 :                                         goto err;
    1323                 :            :                                 in_flow_tbl_cnt = 0;
    1324                 :          0 :                                 continue;
    1325                 :            :                         }
    1326                 :            :                 }
    1327                 :            :         }
    1328                 :            : 
    1329         [ #  # ]:          0 :         if (!in_flow_tbl_cnt) {
    1330                 :          0 :                 bnxt_release_flow_lock(bp);
    1331                 :          0 :                 goto out;
    1332                 :            :         }
    1333                 :            : 
    1334                 :          0 :         rc = bnxt_update_fc_tbl(bp, counter_type, valid_en_tbl,
    1335                 :            :                                 in_flow_tbl_cnt);
    1336         [ #  # ]:          0 :         if (!rc) {
    1337                 :          0 :                 bnxt_release_flow_lock(bp);
    1338                 :          0 :                 return 0;
    1339                 :            :         }
    1340                 :            : 
    1341                 :          0 : err:
    1342                 :            :         /* If cmd fails once, no need of
    1343                 :            :          * invoking again every second
    1344                 :            :          */
    1345                 :          0 :         bnxt_release_flow_lock(bp);
    1346                 :          0 :         bnxt_cancel_fc_thread(bp);
    1347                 :            : out:
    1348                 :            :         return rc;
    1349                 :            : }

Generated by: LCOV version 1.14