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

Generated by: LCOV version 1.14