LCOV - code coverage report
Current view: top level - drivers/net/bnx2x - bnx2x_stats.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 756 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 27 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 883 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2007-2013 Broadcom Corporation.
       3                 :            :  *
       4                 :            :  * Eric Davis        <edavis@broadcom.com>
       5                 :            :  * David Christensen <davidch@broadcom.com>
       6                 :            :  * Gary Zambrano     <zambrano@broadcom.com>
       7                 :            :  *
       8                 :            :  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
       9                 :            :  * Copyright (c) 2015-2018 Cavium Inc.
      10                 :            :  * All rights reserved.
      11                 :            :  * www.cavium.com
      12                 :            :  */
      13                 :            : 
      14                 :            : #include "bnx2x.h"
      15                 :            : #include "bnx2x_stats.h"
      16                 :            : 
      17                 :            : #ifdef __i386__
      18                 :            : #define BITS_PER_LONG 32
      19                 :            : #else
      20                 :            : #define BITS_PER_LONG 64
      21                 :            : #endif
      22                 :            : 
      23                 :            : static inline uint16_t
      24                 :          0 : bnx2x_get_port_stats_dma_len(struct bnx2x_softc *sc)
      25                 :            : {
      26                 :            :         uint16_t res = 0;
      27                 :            :         uint32_t size;
      28                 :            : 
      29                 :            :         /* 'newest' convention - shmem2 contains the size of the port stats */
      30   [ #  #  #  # ]:          0 :         if (SHMEM2_HAS(sc, sizeof_port_stats)) {
      31                 :          0 :                 size = SHMEM2_RD(sc, sizeof_port_stats);
      32         [ #  # ]:          0 :                 if (size)
      33                 :          0 :                         res = size;
      34                 :            : 
      35                 :            :                 /* prevent newer BC from causing buffer overflow */
      36         [ #  # ]:          0 :                 if (res > sizeof(struct host_port_stats))
      37                 :            :                         res = sizeof(struct host_port_stats);
      38                 :            :         }
      39                 :            : 
      40                 :            :         /*
      41                 :            :          * Older convention - all BCs support the port stats fields up until
      42                 :            :          * the 'not_used' field
      43                 :            :          */
      44         [ #  # ]:          0 :         if (!res) {
      45                 :            :                 res = offsetof(struct host_port_stats, not_used) + 4;
      46                 :            : 
      47                 :            :                 /* if PFC stats are supported by the MFW, DMA them as well */
      48         [ #  # ]:          0 :                 if (sc->devinfo.bc_ver >= REQ_BC_VER_4_PFC_STATS_SUPPORTED) {
      49                 :            :                         res += (offsetof(struct host_port_stats, pfc_frames_rx_lo) -
      50                 :            :                                 offsetof(struct host_port_stats, pfc_frames_tx_hi) + 4);
      51                 :            :                 }
      52                 :            :         }
      53                 :            : 
      54                 :          0 :         res >>= 2;
      55                 :            : 
      56                 :          0 :         return res;
      57                 :            : }
      58                 :            : 
      59                 :            : /*
      60                 :            :  * Init service functions
      61                 :            :  */
      62                 :            : 
      63                 :            : /*
      64                 :            :  * Post the next statistics ramrod. Protect it with the lock in
      65                 :            :  * order to ensure the strict order between statistics ramrods
      66                 :            :  * (each ramrod has a sequence number passed in a
      67                 :            :  * sc->fw_stats_req->hdr.drv_stats_counter and ramrods must be
      68                 :            :  * sent in order).
      69                 :            :  */
      70                 :            : static void
      71                 :          0 : bnx2x_storm_stats_post(struct bnx2x_softc *sc)
      72                 :            : {
      73                 :            :         int rc;
      74                 :            : 
      75         [ #  # ]:          0 :         if (!sc->stats_pending) {
      76                 :          0 :                 sc->fw_stats_req->hdr.drv_stats_counter =
      77                 :          0 :                         htole16(sc->stats_counter++);
      78                 :            : 
      79                 :            :                 PMD_DEBUG_PERIODIC_LOG(DEBUG, sc,
      80                 :            :                                 "sending statistics ramrod %d",
      81                 :            :                                 le16toh(sc->fw_stats_req->hdr.drv_stats_counter));
      82                 :            : 
      83                 :            :                 /* adjust the ramrod to include VF queues statistics */
      84                 :            : 
      85                 :            :                 /* send FW stats ramrod */
      86                 :          0 :                 rc = bnx2x_sp_post(sc, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0,
      87                 :          0 :                                 U64_HI(sc->fw_stats_req_mapping),
      88                 :          0 :                                 U64_LO(sc->fw_stats_req_mapping),
      89                 :            :                                 NONE_CONNECTION_TYPE);
      90         [ #  # ]:          0 :                 if (rc == 0)
      91                 :          0 :                         sc->stats_pending = 1;
      92                 :            :         }
      93                 :          0 : }
      94                 :            : 
      95                 :            : static void
      96                 :          0 : bnx2x_hw_stats_post(struct bnx2x_softc *sc)
      97                 :            : {
      98                 :          0 :         struct dmae_command *dmae = &sc->stats_dmae;
      99                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
     100                 :            :         int loader_idx;
     101                 :            :         uint32_t opcode;
     102                 :            : 
     103                 :          0 :         *stats_comp = DMAE_COMP_VAL;
     104         [ #  # ]:          0 :         if (CHIP_REV_IS_SLOW(sc))
     105                 :            :                 return;
     106                 :            : 
     107                 :            :         /* Update MCP's statistics if possible */
     108         [ #  # ]:          0 :         if (sc->func_stx)
     109                 :          0 :                 memcpy(BNX2X_SP(sc, func_stats), &sc->func_stats,
     110                 :            :                                 sizeof(sc->func_stats));
     111                 :            : 
     112                 :            :         /* loader */
     113         [ #  # ]:          0 :         if (sc->executer_idx) {
     114                 :          0 :                 loader_idx = PMF_DMAE_C(sc);
     115                 :          0 :                 opcode =  bnx2x_dmae_opcode(sc, DMAE_SRC_PCI, DMAE_DST_GRC,
     116                 :            :                                 TRUE, DMAE_COMP_GRC);
     117                 :          0 :                 opcode = bnx2x_dmae_opcode_clr_src_reset(opcode);
     118                 :            : 
     119                 :            :                 memset(dmae, 0, sizeof(struct dmae_command));
     120                 :          0 :                 dmae->opcode = opcode;
     121                 :          0 :                 dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, dmae[0]));
     122                 :          0 :                 dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, dmae[0]));
     123                 :          0 :                 dmae->dst_addr_lo = ((DMAE_REG_CMD_MEM +
     124                 :          0 :                                         sizeof(struct dmae_command) *
     125                 :          0 :                                         (loader_idx + 1)) >> 2);
     126                 :          0 :                 dmae->dst_addr_hi = 0;
     127                 :          0 :                 dmae->len = sizeof(struct dmae_command) >> 2;
     128                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx + 1] >> 2);
     129                 :          0 :                 dmae->comp_addr_hi = 0;
     130                 :          0 :                 dmae->comp_val = 1;
     131                 :            : 
     132                 :          0 :                 *stats_comp = 0;
     133                 :          0 :                 bnx2x_post_dmae(sc, dmae, loader_idx);
     134         [ #  # ]:          0 :         } else if (sc->func_stx) {
     135                 :          0 :                 *stats_comp = 0;
     136                 :          0 :                 bnx2x_post_dmae(sc, dmae, INIT_DMAE_C(sc));
     137                 :            :         }
     138                 :            : }
     139                 :            : 
     140                 :            : static int
     141                 :          0 : bnx2x_stats_comp(struct bnx2x_softc *sc)
     142                 :            : {
     143                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
     144                 :            :         int cnt = 10;
     145                 :            : 
     146         [ #  # ]:          0 :         while (*stats_comp != DMAE_COMP_VAL) {
     147         [ #  # ]:          0 :                 if (!cnt) {
     148                 :          0 :                         PMD_DRV_LOG(ERR, sc, "Timeout waiting for stats finished");
     149                 :          0 :                         break;
     150                 :            :                 }
     151                 :            : 
     152                 :          0 :                 cnt--;
     153                 :          0 :                 DELAY(1000);
     154                 :            :         }
     155                 :            : 
     156                 :          0 :         return 1;
     157                 :            : }
     158                 :            : 
     159                 :            : /*
     160                 :            :  * Statistics service functions
     161                 :            :  */
     162                 :            : 
     163                 :            : static void
     164                 :          0 : bnx2x_stats_pmf_update(struct bnx2x_softc *sc)
     165                 :            : {
     166                 :            :         struct dmae_command *dmae;
     167                 :            :         uint32_t opcode;
     168                 :          0 :         int loader_idx = PMF_DMAE_C(sc);
     169                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
     170                 :            : 
     171         [ #  # ]:          0 :         if (sc->devinfo.bc_ver <= 0x06001400) {
     172                 :            :                 /*
     173                 :            :                  * Bootcode v6.0.21 fixed a GRC timeout that occurs when accessing
     174                 :            :                  * BRB registers while the BRB block is in reset. The DMA transfer
     175                 :            :                  * below triggers this issue resulting in the DMAE to stop
     176                 :            :                  * functioning. Skip this initial stats transfer for old bootcode
     177                 :            :                  * versions <= 6.0.20.
     178                 :            :                  */
     179                 :            :                 return;
     180                 :            :         }
     181                 :            :         /* sanity */
     182   [ #  #  #  # ]:          0 :         if (!sc->port.pmf || !sc->port.port_stx) {
     183                 :          0 :                 PMD_DRV_LOG(ERR, sc, "BUG!");
     184                 :          0 :                 return;
     185                 :            :         }
     186                 :            : 
     187                 :          0 :         sc->executer_idx = 0;
     188                 :            : 
     189                 :          0 :         opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_GRC, DMAE_DST_PCI, FALSE, 0);
     190                 :            : 
     191                 :          0 :         dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     192                 :          0 :         dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_GRC);
     193                 :          0 :         dmae->src_addr_lo = (sc->port.port_stx >> 2);
     194                 :          0 :         dmae->src_addr_hi = 0;
     195                 :          0 :         dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, port_stats));
     196                 :          0 :         dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, port_stats));
     197                 :          0 :         dmae->len = DMAE_LEN32_RD_MAX;
     198                 :          0 :         dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     199                 :          0 :         dmae->comp_addr_hi = 0;
     200                 :          0 :         dmae->comp_val = 1;
     201                 :            : 
     202                 :          0 :         dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     203                 :          0 :         dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_PCI);
     204                 :          0 :         dmae->src_addr_lo = ((sc->port.port_stx >> 2) + DMAE_LEN32_RD_MAX);
     205                 :          0 :         dmae->src_addr_hi = 0;
     206                 :          0 :         dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, port_stats) +
     207                 :            :                         DMAE_LEN32_RD_MAX * 4);
     208                 :          0 :         dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, port_stats) +
     209                 :            :                         DMAE_LEN32_RD_MAX * 4);
     210                 :          0 :         dmae->len = (bnx2x_get_port_stats_dma_len(sc) - DMAE_LEN32_RD_MAX);
     211                 :            : 
     212                 :          0 :         dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
     213                 :          0 :         dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
     214                 :          0 :         dmae->comp_val = DMAE_COMP_VAL;
     215                 :            : 
     216                 :          0 :         *stats_comp = 0;
     217                 :          0 :         bnx2x_hw_stats_post(sc);
     218                 :          0 :         bnx2x_stats_comp(sc);
     219                 :            : }
     220                 :            : 
     221                 :            : static void
     222                 :          0 : bnx2x_port_stats_init(struct bnx2x_softc *sc)
     223                 :            : {
     224                 :            :         struct dmae_command *dmae;
     225                 :          0 :         int port = SC_PORT(sc);
     226                 :            :         uint32_t opcode;
     227                 :          0 :         int loader_idx = PMF_DMAE_C(sc);
     228                 :            :         uint32_t mac_addr;
     229                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
     230                 :            : 
     231                 :            :         /* sanity */
     232   [ #  #  #  # ]:          0 :         if (!sc->link_vars.link_up || !sc->port.pmf) {
     233                 :          0 :                 PMD_DRV_LOG(ERR, sc, "BUG!");
     234                 :          0 :                 return;
     235                 :            :         }
     236                 :            : 
     237                 :          0 :         sc->executer_idx = 0;
     238                 :            : 
     239                 :            :         /* MCP */
     240                 :          0 :         opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_PCI, DMAE_DST_GRC,
     241                 :            :                                    TRUE, DMAE_COMP_GRC);
     242                 :            : 
     243         [ #  # ]:          0 :         if (sc->port.port_stx) {
     244                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     245                 :          0 :                 dmae->opcode = opcode;
     246                 :          0 :                 dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, port_stats));
     247                 :          0 :                 dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, port_stats));
     248                 :          0 :                 dmae->dst_addr_lo = sc->port.port_stx >> 2;
     249                 :          0 :                 dmae->dst_addr_hi = 0;
     250                 :          0 :                 dmae->len = bnx2x_get_port_stats_dma_len(sc);
     251                 :          0 :                 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
     252                 :          0 :                 dmae->comp_addr_hi = 0;
     253                 :          0 :                 dmae->comp_val = 1;
     254                 :            :         }
     255                 :            : 
     256         [ #  # ]:          0 :         if (sc->func_stx) {
     257                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     258                 :          0 :                 dmae->opcode = opcode;
     259                 :          0 :                 dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, func_stats));
     260                 :          0 :                 dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, func_stats));
     261                 :          0 :                 dmae->dst_addr_lo = (sc->func_stx >> 2);
     262                 :          0 :                 dmae->dst_addr_hi = 0;
     263                 :          0 :                 dmae->len = (sizeof(struct host_func_stats) >> 2);
     264                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     265                 :          0 :                 dmae->comp_addr_hi = 0;
     266                 :          0 :                 dmae->comp_val = 1;
     267                 :            :         }
     268                 :            : 
     269                 :            :         /* MAC */
     270                 :          0 :         opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_GRC, DMAE_DST_PCI,
     271                 :            :                                    TRUE, DMAE_COMP_GRC);
     272                 :            : 
     273                 :            :         /* EMAC is special */
     274         [ #  # ]:          0 :         if (sc->link_vars.mac_type == ELINK_MAC_TYPE_EMAC) {
     275         [ #  # ]:          0 :                 mac_addr = (port ? GRCBASE_EMAC1 : GRCBASE_EMAC0);
     276                 :            : 
     277                 :            :                 /* EMAC_REG_EMAC_RX_STAT_AC (EMAC_REG_EMAC_RX_STAT_AC_COUNT)*/
     278                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     279                 :          0 :                 dmae->opcode = opcode;
     280                 :          0 :                 dmae->src_addr_lo = (mac_addr + EMAC_REG_EMAC_RX_STAT_AC) >> 2;
     281                 :          0 :                 dmae->src_addr_hi = 0;
     282                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, mac_stats));
     283                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, mac_stats));
     284                 :          0 :                 dmae->len = EMAC_REG_EMAC_RX_STAT_AC_COUNT;
     285                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     286                 :          0 :                 dmae->comp_addr_hi = 0;
     287                 :          0 :                 dmae->comp_val = 1;
     288                 :            : 
     289                 :            :                 /* EMAC_REG_EMAC_RX_STAT_AC_28 */
     290                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     291                 :          0 :                 dmae->opcode = opcode;
     292                 :          0 :                 dmae->src_addr_lo = ((mac_addr + EMAC_REG_EMAC_RX_STAT_AC_28) >> 2);
     293                 :          0 :                 dmae->src_addr_hi = 0;
     294                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, mac_stats) +
     295                 :            :                                            offsetof(struct emac_stats,
     296                 :            :                                                     rx_stat_falsecarriererrors));
     297                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, mac_stats) +
     298                 :            :                                            offsetof(struct emac_stats,
     299                 :            :                                                     rx_stat_falsecarriererrors));
     300                 :          0 :                 dmae->len = 1;
     301                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     302                 :          0 :                 dmae->comp_addr_hi = 0;
     303                 :          0 :                 dmae->comp_val = 1;
     304                 :            : 
     305                 :            :                 /* EMAC_REG_EMAC_TX_STAT_AC (EMAC_REG_EMAC_TX_STAT_AC_COUNT)*/
     306                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     307                 :          0 :                 dmae->opcode = opcode;
     308                 :          0 :                 dmae->src_addr_lo = ((mac_addr + EMAC_REG_EMAC_TX_STAT_AC) >> 2);
     309                 :          0 :                 dmae->src_addr_hi = 0;
     310                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, mac_stats) +
     311                 :            :                                            offsetof(struct emac_stats,
     312                 :            :                                                     tx_stat_ifhcoutoctets));
     313                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, mac_stats) +
     314                 :            :                                            offsetof(struct emac_stats,
     315                 :            :                                                     tx_stat_ifhcoutoctets));
     316                 :          0 :                 dmae->len = EMAC_REG_EMAC_TX_STAT_AC_COUNT;
     317                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     318                 :          0 :                 dmae->comp_addr_hi = 0;
     319                 :          0 :                 dmae->comp_val = 1;
     320                 :            :         } else {
     321                 :            :                 uint32_t tx_src_addr_lo, rx_src_addr_lo;
     322                 :            :                 uint16_t rx_len, tx_len;
     323                 :            : 
     324                 :            :                 /* configure the params according to MAC type */
     325         [ #  # ]:          0 :                 switch (sc->link_vars.mac_type) {
     326                 :          0 :                 case ELINK_MAC_TYPE_BMAC:
     327         [ #  # ]:          0 :                         mac_addr = (port) ? NIG_REG_INGRESS_BMAC1_MEM :
     328                 :            :                         NIG_REG_INGRESS_BMAC0_MEM;
     329                 :            : 
     330                 :            :                         /*
     331                 :            :                          * BIGMAC_REGISTER_TX_STAT_GTPKT ..
     332                 :            :                          * BIGMAC_REGISTER_TX_STAT_GTBYT
     333                 :            :                          */
     334         [ #  # ]:          0 :                         if (CHIP_IS_E1x(sc)) {
     335                 :          0 :                                 tx_src_addr_lo =
     336                 :          0 :                                         ((mac_addr + BIGMAC_REGISTER_TX_STAT_GTPKT) >> 2);
     337                 :            :                                 tx_len = ((8 + BIGMAC_REGISTER_TX_STAT_GTBYT -
     338                 :            :                                            BIGMAC_REGISTER_TX_STAT_GTPKT) >> 2);
     339                 :          0 :                                 rx_src_addr_lo =
     340                 :          0 :                                         ((mac_addr + BIGMAC_REGISTER_RX_STAT_GR64) >> 2);
     341                 :            :                                 rx_len = ((8 + BIGMAC_REGISTER_RX_STAT_GRIPJ -
     342                 :            :                                            BIGMAC_REGISTER_RX_STAT_GR64) >> 2);
     343                 :            :                         } else {
     344                 :          0 :                                 tx_src_addr_lo =
     345                 :          0 :                                         ((mac_addr + BIGMAC2_REGISTER_TX_STAT_GTPOK) >> 2);
     346                 :            :                                 tx_len = ((8 + BIGMAC2_REGISTER_TX_STAT_GTBYT -
     347                 :            :                                            BIGMAC2_REGISTER_TX_STAT_GTPOK) >> 2);
     348                 :          0 :                                 rx_src_addr_lo =
     349                 :          0 :                                         ((mac_addr + BIGMAC2_REGISTER_RX_STAT_GR64) >> 2);
     350                 :            :                                 rx_len = ((8 + BIGMAC2_REGISTER_RX_STAT_GRIPJ -
     351                 :            :                                            BIGMAC2_REGISTER_RX_STAT_GR64) >> 2);
     352                 :            :                         }
     353                 :            : 
     354                 :            :                         break;
     355                 :            : 
     356                 :          0 :                 case ELINK_MAC_TYPE_UMAC: /* handled by MSTAT */
     357                 :            :                 case ELINK_MAC_TYPE_XMAC: /* handled by MSTAT */
     358                 :            :                 default:
     359         [ #  # ]:          0 :                         mac_addr = (port) ? GRCBASE_MSTAT1 : GRCBASE_MSTAT0;
     360                 :          0 :                         tx_src_addr_lo = ((mac_addr + MSTAT_REG_TX_STAT_GTXPOK_LO) >> 2);
     361                 :          0 :                         rx_src_addr_lo = ((mac_addr + MSTAT_REG_RX_STAT_GR64_LO) >> 2);
     362                 :            :                         tx_len =
     363                 :            :                                 (sizeof(sc->sp->mac_stats.mstat_stats.stats_tx) >> 2);
     364                 :            :                         rx_len =
     365                 :            :                                 (sizeof(sc->sp->mac_stats.mstat_stats.stats_rx) >> 2);
     366                 :          0 :                         break;
     367                 :            :                 }
     368                 :            : 
     369                 :            :                 /* TX stats */
     370                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     371                 :          0 :                 dmae->opcode = opcode;
     372                 :          0 :                 dmae->src_addr_lo = tx_src_addr_lo;
     373                 :          0 :                 dmae->src_addr_hi = 0;
     374                 :          0 :                 dmae->len = tx_len;
     375                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, mac_stats));
     376                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, mac_stats));
     377                 :          0 :                 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
     378                 :          0 :                 dmae->comp_addr_hi = 0;
     379                 :          0 :                 dmae->comp_val = 1;
     380                 :            : 
     381                 :            :                 /* RX stats */
     382                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     383                 :          0 :                 dmae->opcode = opcode;
     384                 :          0 :                 dmae->src_addr_hi = 0;
     385                 :          0 :                 dmae->src_addr_lo = rx_src_addr_lo;
     386                 :          0 :                 dmae->dst_addr_lo =
     387                 :          0 :                         U64_LO(BNX2X_SP_MAPPING(sc, mac_stats) + (tx_len << 2));
     388                 :          0 :                 dmae->dst_addr_hi =
     389                 :          0 :                         U64_HI(BNX2X_SP_MAPPING(sc, mac_stats) + (tx_len << 2));
     390                 :          0 :                 dmae->len = rx_len;
     391                 :          0 :                 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
     392                 :          0 :                 dmae->comp_addr_hi = 0;
     393                 :          0 :                 dmae->comp_val = 1;
     394                 :            :         }
     395                 :            : 
     396                 :            :         /* NIG */
     397   [ #  #  #  #  :          0 :         if (!CHIP_IS_E3(sc)) {
          #  #  #  #  #  
                      # ]
     398                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     399                 :          0 :                 dmae->opcode = opcode;
     400                 :          0 :                 dmae->src_addr_lo =
     401                 :            :                         (port ? NIG_REG_STAT1_EGRESS_MAC_PKT0 :
     402         [ #  # ]:          0 :                          NIG_REG_STAT0_EGRESS_MAC_PKT0) >> 2;
     403                 :          0 :                 dmae->src_addr_hi = 0;
     404                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, nig_stats) +
     405                 :            :                                            offsetof(struct nig_stats,
     406                 :            :                                                     egress_mac_pkt0_lo));
     407                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, nig_stats) +
     408                 :            :                                            offsetof(struct nig_stats,
     409                 :            :                                                     egress_mac_pkt0_lo));
     410                 :          0 :                 dmae->len = ((2 * sizeof(uint32_t)) >> 2);
     411                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     412                 :          0 :                 dmae->comp_addr_hi = 0;
     413                 :          0 :                 dmae->comp_val = 1;
     414                 :            : 
     415                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     416                 :          0 :                 dmae->opcode = opcode;
     417                 :          0 :                 dmae->src_addr_lo =
     418                 :            :                         (port ? NIG_REG_STAT1_EGRESS_MAC_PKT1 :
     419         [ #  # ]:          0 :                          NIG_REG_STAT0_EGRESS_MAC_PKT1) >> 2;
     420                 :          0 :                 dmae->src_addr_hi = 0;
     421                 :          0 :                 dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, nig_stats) +
     422                 :            :                                            offsetof(struct nig_stats,
     423                 :            :                                                     egress_mac_pkt1_lo));
     424                 :          0 :                 dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, nig_stats) +
     425                 :            :                                            offsetof(struct nig_stats,
     426                 :            :                                                     egress_mac_pkt1_lo));
     427                 :          0 :                 dmae->len = ((2 * sizeof(uint32_t)) >> 2);
     428                 :          0 :                 dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
     429                 :          0 :                 dmae->comp_addr_hi = 0;
     430                 :          0 :                 dmae->comp_val = 1;
     431                 :            :         }
     432                 :            : 
     433                 :          0 :         dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
     434                 :          0 :         dmae->opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_GRC, DMAE_DST_PCI,
     435                 :            :                                          TRUE, DMAE_COMP_PCI);
     436                 :          0 :         dmae->src_addr_lo =
     437                 :            :                 (port ? NIG_REG_STAT1_BRB_DISCARD :
     438         [ #  # ]:          0 :                  NIG_REG_STAT0_BRB_DISCARD) >> 2;
     439                 :          0 :         dmae->src_addr_hi = 0;
     440                 :          0 :         dmae->dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, nig_stats));
     441                 :          0 :         dmae->dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, nig_stats));
     442                 :          0 :         dmae->len = (sizeof(struct nig_stats) - 4 * sizeof(uint32_t)) >> 2;
     443                 :            : 
     444                 :          0 :         dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
     445                 :          0 :         dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
     446                 :          0 :         dmae->comp_val = DMAE_COMP_VAL;
     447                 :            : 
     448                 :          0 :         *stats_comp = 0;
     449                 :            : }
     450                 :            : 
     451                 :            : static void
     452                 :          0 : bnx2x_func_stats_init(struct bnx2x_softc *sc)
     453                 :            : {
     454                 :          0 :         struct dmae_command *dmae = &sc->stats_dmae;
     455                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
     456                 :            : 
     457                 :            :         /* sanity */
     458         [ #  # ]:          0 :         if (!sc->func_stx) {
     459                 :          0 :                 PMD_DRV_LOG(ERR, sc, "BUG!");
     460                 :          0 :                 return;
     461                 :            :         }
     462                 :            : 
     463                 :          0 :         sc->executer_idx = 0;
     464                 :            :         memset(dmae, 0, sizeof(struct dmae_command));
     465                 :            : 
     466                 :          0 :         dmae->opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_PCI, DMAE_DST_GRC,
     467                 :            :                                          TRUE, DMAE_COMP_PCI);
     468                 :          0 :         dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, func_stats));
     469                 :          0 :         dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, func_stats));
     470                 :          0 :         dmae->dst_addr_lo = (sc->func_stx >> 2);
     471                 :          0 :         dmae->dst_addr_hi = 0;
     472                 :          0 :         dmae->len = (sizeof(struct host_func_stats) >> 2);
     473                 :          0 :         dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
     474                 :          0 :         dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
     475                 :          0 :         dmae->comp_val = DMAE_COMP_VAL;
     476                 :            : 
     477                 :          0 :         *stats_comp = 0;
     478                 :            : }
     479                 :            : 
     480                 :            : static void
     481                 :          0 : bnx2x_stats_start(struct bnx2x_softc *sc)
     482                 :            : {
     483                 :            :         /*
     484                 :            :          * VFs travel through here as part of the statistics FSM, but no action
     485                 :            :          * is required
     486                 :            :          */
     487         [ #  # ]:          0 :         if (IS_VF(sc))
     488                 :            :                 return;
     489                 :            : 
     490         [ #  # ]:          0 :         if (sc->port.pmf)
     491                 :          0 :                 bnx2x_port_stats_init(sc);
     492         [ #  # ]:          0 :         else if (sc->func_stx)
     493                 :          0 :                 bnx2x_func_stats_init(sc);
     494                 :            : 
     495                 :          0 :         bnx2x_hw_stats_post(sc);
     496                 :          0 :         bnx2x_storm_stats_post(sc);
     497                 :            : }
     498                 :            : 
     499                 :            : static void
     500                 :          0 : bnx2x_stats_pmf_start(struct bnx2x_softc *sc)
     501                 :            : {
     502                 :          0 :         bnx2x_stats_comp(sc);
     503                 :          0 :         bnx2x_stats_pmf_update(sc);
     504                 :          0 :         bnx2x_stats_start(sc);
     505                 :          0 : }
     506                 :            : 
     507                 :            : static void
     508                 :          0 : bnx2x_stats_restart(struct bnx2x_softc *sc)
     509                 :            : {
     510                 :            :         /*
     511                 :            :          * VFs travel through here as part of the statistics FSM, but no action
     512                 :            :          * is required
     513                 :            :          */
     514         [ #  # ]:          0 :         if (IS_VF(sc))
     515                 :            :                 return;
     516                 :            : 
     517                 :          0 :         bnx2x_stats_comp(sc);
     518                 :          0 :         bnx2x_stats_start(sc);
     519                 :            : }
     520                 :            : 
     521                 :            : static void
     522                 :          0 : bnx2x_bmac_stats_update(struct bnx2x_softc *sc)
     523                 :            : {
     524                 :          0 :         struct host_port_stats *pstats = BNX2X_SP(sc, port_stats);
     525                 :            :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
     526                 :            :         struct {
     527                 :            :                 uint32_t lo;
     528                 :            :                 uint32_t hi;
     529                 :            :         } diff;
     530                 :            : 
     531         [ #  # ]:          0 :         if (CHIP_IS_E1x(sc)) {
     532                 :            :                 struct bmac1_stats *new = BNX2X_SP(sc, mac_stats.bmac1_stats);
     533                 :            : 
     534                 :            :                 /* the macros below will use "bmac1_stats" type */
     535   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grerb, rx_stat_ifhcinbadoctets);
             #  #  #  # ]
     536   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grfcs, rx_stat_dot3statsfcserrors);
             #  #  #  # ]
     537   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grund, rx_stat_etherstatsundersizepkts);
             #  #  #  # ]
     538   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong);
             #  #  #  # ]
     539   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments);
             #  #  #  # ]
     540   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers);
             #  #  #  # ]
     541   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxcf, rx_stat_maccontrolframesreceived);
             #  #  #  # ]
     542   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered);
             #  #  #  # ]
     543   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxpf, rx_stat_mac_xpf);
             #  #  #  # ]
     544                 :            : 
     545   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent);
             #  #  #  # ]
     546   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_flowcontroldone);
             #  #  #  # ]
     547   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt64, tx_stat_etherstatspkts64octets);
             #  #  #  # ]
     548   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt127,
             #  #  #  # ]
     549                 :            :                               tx_stat_etherstatspkts65octetsto127octets);
     550   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt255,
             #  #  #  # ]
     551                 :            :                               tx_stat_etherstatspkts128octetsto255octets);
     552   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt511,
             #  #  #  # ]
     553                 :            :                               tx_stat_etherstatspkts256octetsto511octets);
     554   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt1023,
             #  #  #  # ]
     555                 :            :                               tx_stat_etherstatspkts512octetsto1023octets);
     556   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt1518,
             #  #  #  # ]
     557                 :            :                               tx_stat_etherstatspkts1024octetsto1522octets);
     558   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt2047, tx_stat_mac_2047);
             #  #  #  # ]
     559   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt4095, tx_stat_mac_4095);
             #  #  #  # ]
     560   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt9216, tx_stat_mac_9216);
             #  #  #  # ]
     561   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt16383, tx_stat_mac_16383);
             #  #  #  # ]
     562   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gterr,
             #  #  #  # ]
     563                 :            :                               tx_stat_dot3statsinternalmactransmiterrors);
     564   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
             #  #  #  # ]
     565                 :            :         } else {
     566                 :            :                 struct bmac2_stats *new = BNX2X_SP(sc, mac_stats.bmac2_stats);
     567                 :            :                 struct bnx2x_fw_port_stats_old *fwstats = &sc->fw_stats_old;
     568                 :            : 
     569                 :            :                 /* the macros below will use "bmac2_stats" type */
     570   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grerb, rx_stat_ifhcinbadoctets);
             #  #  #  # ]
     571   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grfcs, rx_stat_dot3statsfcserrors);
             #  #  #  # ]
     572   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grund, rx_stat_etherstatsundersizepkts);
             #  #  #  # ]
     573   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong);
             #  #  #  # ]
     574   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments);
             #  #  #  # ]
     575   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers);
             #  #  #  # ]
     576   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxcf, rx_stat_maccontrolframesreceived);
             #  #  #  # ]
     577   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered);
             #  #  #  # ]
     578   [ #  #  #  #  :          0 :                 UPDATE_STAT64(rx_stat_grxpf, rx_stat_mac_xpf);
             #  #  #  # ]
     579   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent);
             #  #  #  # ]
     580   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_flowcontroldone);
             #  #  #  # ]
     581   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt64, tx_stat_etherstatspkts64octets);
             #  #  #  # ]
     582   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt127,
             #  #  #  # ]
     583                 :            :                               tx_stat_etherstatspkts65octetsto127octets);
     584   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt255,
             #  #  #  # ]
     585                 :            :                               tx_stat_etherstatspkts128octetsto255octets);
     586   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt511,
             #  #  #  # ]
     587                 :            :                               tx_stat_etherstatspkts256octetsto511octets);
     588   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt1023,
             #  #  #  # ]
     589                 :            :                               tx_stat_etherstatspkts512octetsto1023octets);
     590   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt1518,
             #  #  #  # ]
     591                 :            :                               tx_stat_etherstatspkts1024octetsto1522octets);
     592   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt2047, tx_stat_mac_2047);
             #  #  #  # ]
     593   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt4095, tx_stat_mac_4095);
             #  #  #  # ]
     594   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt9216, tx_stat_mac_9216);
             #  #  #  # ]
     595   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gt16383, tx_stat_mac_16383);
             #  #  #  # ]
     596   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gterr,
             #  #  #  # ]
     597                 :            :                               tx_stat_dot3statsinternalmactransmiterrors);
     598   [ #  #  #  #  :          0 :                 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
             #  #  #  # ]
     599                 :            : 
     600                 :            :                 /* collect PFC stats */
     601                 :          0 :                 pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi;
     602                 :          0 :                 pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo;
     603         [ #  # ]:          0 :                 ADD_64(pstats->pfc_frames_tx_hi, fwstats->pfc_frames_tx_hi,
     604                 :            :                        pstats->pfc_frames_tx_lo, fwstats->pfc_frames_tx_lo);
     605                 :            : 
     606                 :          0 :                 pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi;
     607                 :          0 :                 pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo;
     608         [ #  # ]:          0 :                 ADD_64(pstats->pfc_frames_rx_hi, fwstats->pfc_frames_rx_hi,
     609                 :            :                        pstats->pfc_frames_rx_lo, fwstats->pfc_frames_rx_lo);
     610                 :            :         }
     611                 :            : 
     612                 :          0 :         estats->pause_frames_received_hi = pstats->mac_stx[1].rx_stat_mac_xpf_hi;
     613                 :          0 :         estats->pause_frames_received_lo = pstats->mac_stx[1].rx_stat_mac_xpf_lo;
     614                 :            : 
     615                 :          0 :         estats->pause_frames_sent_hi = pstats->mac_stx[1].tx_stat_outxoffsent_hi;
     616                 :          0 :         estats->pause_frames_sent_lo = pstats->mac_stx[1].tx_stat_outxoffsent_lo;
     617                 :            : 
     618                 :          0 :         estats->pfc_frames_received_hi = pstats->pfc_frames_rx_hi;
     619                 :          0 :         estats->pfc_frames_received_lo = pstats->pfc_frames_rx_lo;
     620                 :          0 :         estats->pfc_frames_sent_hi = pstats->pfc_frames_tx_hi;
     621                 :          0 :         estats->pfc_frames_sent_lo = pstats->pfc_frames_tx_lo;
     622                 :          0 : }
     623                 :            : 
     624                 :            : static void
     625                 :          0 : bnx2x_mstat_stats_update(struct bnx2x_softc *sc)
     626                 :            : {
     627                 :          0 :         struct host_port_stats *pstats = BNX2X_SP(sc, port_stats);
     628                 :            :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
     629                 :            :         struct mstat_stats *new = BNX2X_SP(sc, mac_stats.mstat_stats);
     630                 :            : 
     631         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grerb, rx_stat_ifhcinbadoctets);
     632         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grfcs, rx_stat_dot3statsfcserrors);
     633         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grund, rx_stat_etherstatsundersizepkts);
     634         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grovr, rx_stat_dot3statsframestoolong);
     635         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grfrg, rx_stat_etherstatsfragments);
     636         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grxcf, rx_stat_maccontrolframesreceived);
     637         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grxpf, rx_stat_xoffstateentered);
     638         [ #  # ]:          0 :         ADD_STAT64(stats_rx.rx_grxpf, rx_stat_mac_xpf);
     639         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_outxoffsent);
     640         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_flowcontroldone);
     641                 :            : 
     642                 :            :         /* collect pfc stats */
     643         [ #  # ]:          0 :         ADD_64(pstats->pfc_frames_tx_hi, new->stats_tx.tx_gtxpp_hi,
     644                 :            :                pstats->pfc_frames_tx_lo, new->stats_tx.tx_gtxpp_lo);
     645         [ #  # ]:          0 :         ADD_64(pstats->pfc_frames_rx_hi, new->stats_rx.rx_grxpp_hi,
     646                 :            :                pstats->pfc_frames_rx_lo, new->stats_rx.rx_grxpp_lo);
     647                 :            : 
     648         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt64, tx_stat_etherstatspkts64octets);
     649         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt127, tx_stat_etherstatspkts65octetsto127octets);
     650         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt255, tx_stat_etherstatspkts128octetsto255octets);
     651         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt511, tx_stat_etherstatspkts256octetsto511octets);
     652         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt1023,
     653                 :            :                    tx_stat_etherstatspkts512octetsto1023octets);
     654         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt1518,
     655                 :            :                    tx_stat_etherstatspkts1024octetsto1522octets);
     656         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt2047, tx_stat_mac_2047);
     657                 :            : 
     658         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt4095, tx_stat_mac_4095);
     659         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt9216, tx_stat_mac_9216);
     660         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gt16383, tx_stat_mac_16383);
     661                 :            : 
     662         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gterr, tx_stat_dot3statsinternalmactransmiterrors);
     663         [ #  # ]:          0 :         ADD_STAT64(stats_tx.tx_gtufl, tx_stat_mac_ufl);
     664                 :            : 
     665                 :          0 :         estats->etherstatspkts1024octetsto1522octets_hi =
     666                 :            :                 pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_hi;
     667                 :          0 :         estats->etherstatspkts1024octetsto1522octets_lo =
     668                 :            :                 pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_lo;
     669                 :            : 
     670                 :            :         estats->etherstatspktsover1522octets_hi =
     671                 :            :                 pstats->mac_stx[1].tx_stat_mac_2047_hi;
     672                 :            :         estats->etherstatspktsover1522octets_lo =
     673                 :            :                 pstats->mac_stx[1].tx_stat_mac_2047_lo;
     674                 :            : 
     675         [ #  # ]:          0 :         ADD_64(estats->etherstatspktsover1522octets_hi,
     676                 :            :                pstats->mac_stx[1].tx_stat_mac_4095_hi,
     677                 :            :                estats->etherstatspktsover1522octets_lo,
     678                 :            :                pstats->mac_stx[1].tx_stat_mac_4095_lo);
     679                 :            : 
     680         [ #  # ]:          0 :         ADD_64(estats->etherstatspktsover1522octets_hi,
     681                 :            :                pstats->mac_stx[1].tx_stat_mac_9216_hi,
     682                 :            :                estats->etherstatspktsover1522octets_lo,
     683                 :            :                pstats->mac_stx[1].tx_stat_mac_9216_lo);
     684                 :            : 
     685         [ #  # ]:          0 :         ADD_64(estats->etherstatspktsover1522octets_hi,
     686                 :            :                pstats->mac_stx[1].tx_stat_mac_16383_hi,
     687                 :            :                estats->etherstatspktsover1522octets_lo,
     688                 :            :                pstats->mac_stx[1].tx_stat_mac_16383_lo);
     689                 :            : 
     690                 :          0 :         estats->pause_frames_received_hi = pstats->mac_stx[1].rx_stat_mac_xpf_hi;
     691                 :          0 :         estats->pause_frames_received_lo = pstats->mac_stx[1].rx_stat_mac_xpf_lo;
     692                 :            : 
     693                 :          0 :         estats->pause_frames_sent_hi = pstats->mac_stx[1].tx_stat_outxoffsent_hi;
     694                 :          0 :         estats->pause_frames_sent_lo = pstats->mac_stx[1].tx_stat_outxoffsent_lo;
     695                 :            : 
     696                 :          0 :         estats->pfc_frames_received_hi = pstats->pfc_frames_rx_hi;
     697                 :          0 :         estats->pfc_frames_received_lo = pstats->pfc_frames_rx_lo;
     698                 :          0 :         estats->pfc_frames_sent_hi = pstats->pfc_frames_tx_hi;
     699                 :          0 :         estats->pfc_frames_sent_lo = pstats->pfc_frames_tx_lo;
     700                 :          0 : }
     701                 :            : 
     702                 :            : static void
     703                 :          0 : bnx2x_emac_stats_update(struct bnx2x_softc *sc)
     704                 :            : {
     705                 :          0 :         struct emac_stats *new = BNX2X_SP(sc, mac_stats.emac_stats);
     706                 :            :         struct host_port_stats *pstats = BNX2X_SP(sc, port_stats);
     707                 :            :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
     708                 :            : 
     709         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_ifhcinbadoctets);
     710         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_ifhcoutbadoctets);
     711         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_dot3statsfcserrors);
     712         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_dot3statsalignmenterrors);
     713         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_dot3statscarriersenseerrors);
     714         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_falsecarriererrors);
     715         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_etherstatsundersizepkts);
     716         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_dot3statsframestoolong);
     717         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_etherstatsfragments);
     718         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_etherstatsjabbers);
     719         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_maccontrolframesreceived);
     720         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_xoffstateentered);
     721         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_xonpauseframesreceived);
     722         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(rx_stat_xoffpauseframesreceived);
     723         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_outxonsent);
     724         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_outxoffsent);
     725         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_flowcontroldone);
     726         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatscollisions);
     727         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statssinglecollisionframes);
     728         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statsmultiplecollisionframes);
     729         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statsdeferredtransmissions);
     730         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statsexcessivecollisions);
     731         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statslatecollisions);
     732         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts64octets);
     733         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts65octetsto127octets);
     734         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts128octetsto255octets);
     735         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts256octetsto511octets);
     736         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts512octetsto1023octets);
     737         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspkts1024octetsto1522octets);
     738         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_etherstatspktsover1522octets);
     739         [ #  # ]:          0 :         UPDATE_EXTEND_STAT(tx_stat_dot3statsinternalmactransmiterrors);
     740                 :            : 
     741                 :            :         estats->pause_frames_received_hi =
     742                 :            :                 pstats->mac_stx[1].rx_stat_xonpauseframesreceived_hi;
     743                 :            :         estats->pause_frames_received_lo =
     744                 :            :                 pstats->mac_stx[1].rx_stat_xonpauseframesreceived_lo;
     745         [ #  # ]:          0 :         ADD_64(estats->pause_frames_received_hi,
     746                 :            :                pstats->mac_stx[1].rx_stat_xoffpauseframesreceived_hi,
     747                 :            :                estats->pause_frames_received_lo,
     748                 :            :                pstats->mac_stx[1].rx_stat_xoffpauseframesreceived_lo);
     749                 :            : 
     750                 :            :         estats->pause_frames_sent_hi =
     751                 :            :                 pstats->mac_stx[1].tx_stat_outxonsent_hi;
     752                 :            :         estats->pause_frames_sent_lo =
     753                 :            :                 pstats->mac_stx[1].tx_stat_outxonsent_lo;
     754         [ #  # ]:          0 :         ADD_64(estats->pause_frames_sent_hi,
     755                 :            :                pstats->mac_stx[1].tx_stat_outxoffsent_hi,
     756                 :            :                estats->pause_frames_sent_lo,
     757                 :            :                pstats->mac_stx[1].tx_stat_outxoffsent_lo);
     758                 :          0 : }
     759                 :            : 
     760                 :            : static int
     761                 :          0 : bnx2x_hw_stats_update(struct bnx2x_softc *sc)
     762                 :            : {
     763                 :          0 :         struct nig_stats *new = BNX2X_SP(sc, nig_stats);
     764                 :          0 :         struct nig_stats *old = &sc->port.old_nig_stats;
     765                 :            :         struct host_port_stats *pstats = BNX2X_SP(sc, port_stats);
     766                 :          0 :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
     767                 :            :         uint32_t lpi_reg, nig_timer_max;
     768                 :            :         struct {
     769                 :            :                 uint32_t lo;
     770                 :            :                 uint32_t hi;
     771                 :            :         } diff;
     772                 :            : 
     773   [ #  #  #  #  :          0 :         switch (sc->link_vars.mac_type) {
                      # ]
     774                 :          0 :         case ELINK_MAC_TYPE_BMAC:
     775                 :          0 :                 bnx2x_bmac_stats_update(sc);
     776                 :          0 :                 break;
     777                 :            : 
     778                 :          0 :         case ELINK_MAC_TYPE_EMAC:
     779                 :          0 :                 bnx2x_emac_stats_update(sc);
     780                 :          0 :                 break;
     781                 :            : 
     782                 :          0 :         case ELINK_MAC_TYPE_UMAC:
     783                 :            :         case ELINK_MAC_TYPE_XMAC:
     784                 :          0 :                 bnx2x_mstat_stats_update(sc);
     785                 :          0 :                 break;
     786                 :            : 
     787                 :          0 :         case ELINK_MAC_TYPE_NONE: /* unreached */
     788                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
     789                 :            :                             "stats updated by DMAE but no MAC active");
     790                 :          0 :                 return -1;
     791                 :            : 
     792                 :          0 :         default: /* unreached */
     793                 :          0 :                 PMD_DRV_LOG(ERR, sc, "stats update failed, unknown MAC type");
     794                 :            :         }
     795                 :            : 
     796         [ #  # ]:          0 :         ADD_EXTEND_64(pstats->brb_drop_hi, pstats->brb_drop_lo,
     797                 :            :                       new->brb_discard - old->brb_discard);
     798         [ #  # ]:          0 :         ADD_EXTEND_64(estats->brb_truncate_hi, estats->brb_truncate_lo,
     799                 :            :                       new->brb_truncate - old->brb_truncate);
     800                 :            : 
     801   [ #  #  #  #  :          0 :         if (!CHIP_IS_E3(sc)) {
          #  #  #  #  #  
                      # ]
     802   [ #  #  #  #  :          0 :                 UPDATE_STAT64_NIG(egress_mac_pkt0,
             #  #  #  # ]
     803                 :            :                                   etherstatspkts1024octetsto1522octets);
     804   [ #  #  #  #  :          0 :                 UPDATE_STAT64_NIG(egress_mac_pkt1,
             #  #  #  # ]
     805                 :            :                                   etherstatspktsover1522octets);
     806                 :            :         }
     807                 :            : 
     808                 :            :         memcpy(old, new, sizeof(struct nig_stats));
     809                 :            : 
     810                 :          0 :         memcpy(RTE_PTR_ADD(estats, offsetof(struct bnx2x_eth_stats, rx_stat_ifhcinbadoctets_hi)),
     811                 :          0 :                &pstats->mac_stx[1], sizeof(struct mac_stx));
     812                 :          0 :         estats->brb_drop_hi = pstats->brb_drop_hi;
     813                 :          0 :         estats->brb_drop_lo = pstats->brb_drop_lo;
     814                 :            : 
     815                 :          0 :         pstats->host_port_stats_counter++;
     816                 :            : 
     817         [ #  # ]:          0 :         if (CHIP_IS_E3(sc)) {
     818                 :          0 :                 lpi_reg = (SC_PORT(sc)) ?
     819         [ #  # ]:          0 :                         MISC_REG_CPMU_LP_SM_ENT_CNT_P1 :
     820                 :            :                         MISC_REG_CPMU_LP_SM_ENT_CNT_P0;
     821                 :          0 :                 estats->eee_tx_lpi += REG_RD(sc, lpi_reg);
     822                 :            :         }
     823                 :            : 
     824         [ #  # ]:          0 :         if (!BNX2X_NOMCP(sc)) {
     825                 :          0 :                 nig_timer_max = SHMEM_RD(sc, port_mb[SC_PORT(sc)].stat_nig_timer);
     826         [ #  # ]:          0 :                 if (nig_timer_max != estats->nig_timer_max) {
     827                 :          0 :                         estats->nig_timer_max = nig_timer_max;
     828                 :          0 :                         PMD_DRV_LOG(ERR, sc, "invalid NIG timer max (%u)",
     829                 :            :                                     estats->nig_timer_max);
     830                 :            :                 }
     831                 :            :         }
     832                 :            : 
     833                 :            :         return 0;
     834                 :            : }
     835                 :            : 
     836                 :            : static int
     837                 :          0 : bnx2x_storm_stats_validate_counters(struct bnx2x_softc *sc)
     838                 :            : {
     839                 :          0 :         struct stats_counter *counters = &sc->fw_stats_data->storm_counters;
     840                 :            :         uint16_t cur_stats_counter;
     841                 :            : 
     842                 :            :         /*
     843                 :            :          * Make sure we use the value of the counter
     844                 :            :          * used for sending the last stats ramrod.
     845                 :            :          */
     846                 :          0 :         cur_stats_counter = sc->stats_counter - 1;
     847                 :            : 
     848                 :            :         /* are storm stats valid? */
     849         [ #  # ]:          0 :         if (le16toh(counters->xstats_counter) != cur_stats_counter) {
     850                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
     851                 :            :                             "stats not updated by xstorm, "
     852                 :            :                             "counter 0x%x != stats_counter 0x%x",
     853                 :            :                             le16toh(counters->xstats_counter), sc->stats_counter);
     854                 :          0 :                 return -EAGAIN;
     855                 :            :         }
     856                 :            : 
     857         [ #  # ]:          0 :         if (le16toh(counters->ustats_counter) != cur_stats_counter) {
     858                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
     859                 :            :                             "stats not updated by ustorm, "
     860                 :            :                             "counter 0x%x != stats_counter 0x%x",
     861                 :            :                             le16toh(counters->ustats_counter), sc->stats_counter);
     862                 :          0 :                 return -EAGAIN;
     863                 :            :         }
     864                 :            : 
     865         [ #  # ]:          0 :         if (le16toh(counters->cstats_counter) != cur_stats_counter) {
     866                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
     867                 :            :                             "stats not updated by cstorm, "
     868                 :            :                             "counter 0x%x != stats_counter 0x%x",
     869                 :            :                             le16toh(counters->cstats_counter), sc->stats_counter);
     870                 :          0 :                 return -EAGAIN;
     871                 :            :         }
     872                 :            : 
     873         [ #  # ]:          0 :         if (le16toh(counters->tstats_counter) != cur_stats_counter) {
     874                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
     875                 :            :                             "stats not updated by tstorm, "
     876                 :            :                             "counter 0x%x != stats_counter 0x%x",
     877                 :            :                             le16toh(counters->tstats_counter), sc->stats_counter);
     878                 :          0 :                 return -EAGAIN;
     879                 :            :         }
     880                 :            : 
     881                 :            :         return 0;
     882                 :            : }
     883                 :            : 
     884                 :            : static int
     885                 :          0 : bnx2x_storm_stats_update(struct bnx2x_softc *sc)
     886                 :            : {
     887                 :            :         struct tstorm_per_port_stats *tport =
     888                 :          0 :                 &sc->fw_stats_data->port.tstorm_port_statistics;
     889                 :            :         struct tstorm_per_pf_stats *tfunc =
     890                 :            :                 &sc->fw_stats_data->pf.tstorm_pf_statistics;
     891                 :            :         struct host_func_stats *fstats = &sc->func_stats;
     892                 :            :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
     893                 :            :         struct bnx2x_eth_stats_old *estats_old = &sc->eth_stats_old;
     894                 :            :         int i;
     895                 :            : 
     896                 :            :         /* vfs stat counter is managed by pf */
     897   [ #  #  #  # ]:          0 :         if (IS_PF(sc) && bnx2x_storm_stats_validate_counters(sc))
     898                 :            :                 return -EAGAIN;
     899                 :            : 
     900                 :          0 :         estats->error_bytes_received_hi = 0;
     901                 :          0 :         estats->error_bytes_received_lo = 0;
     902                 :            : 
     903         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
     904                 :            :                 struct bnx2x_fastpath *fp = &sc->fp[i];
     905                 :            :                 struct tstorm_per_queue_stats *tclient =
     906                 :          0 :                         &sc->fw_stats_data->queue_stats[i].tstorm_queue_statistics;
     907                 :            :                 struct tstorm_per_queue_stats *old_tclient = &fp->old_tclient;
     908                 :            :                 struct ustorm_per_queue_stats *uclient =
     909                 :            :                         &sc->fw_stats_data->queue_stats[i].ustorm_queue_statistics;
     910                 :            :                 struct ustorm_per_queue_stats *old_uclient = &fp->old_uclient;
     911                 :            :                 struct xstorm_per_queue_stats *xclient =
     912                 :            :                         &sc->fw_stats_data->queue_stats[i].xstorm_queue_statistics;
     913                 :            :                 struct xstorm_per_queue_stats *old_xclient = &fp->old_xclient;
     914                 :            :                 struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
     915                 :            :                 struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old;
     916                 :            : 
     917                 :            :                 uint32_t diff;
     918                 :            : 
     919                 :            :                 /* PMD_DRV_LOG(DEBUG, sc,
     920                 :            :                                 "queue[%d]: ucast_sent 0x%x bcast_sent 0x%x mcast_sent 0x%x",
     921                 :            :                                 i, xclient->ucast_pkts_sent, xclient->bcast_pkts_sent,
     922                 :            :                                 xclient->mcast_pkts_sent);
     923                 :            : 
     924                 :            :                 PMD_DRV_LOG(DEBUG, sc, "---------------");
     925                 :            :                  */
     926                 :            : 
     927                 :          0 :                 UPDATE_QSTAT(tclient->rcv_bcast_bytes,
     928                 :            :                                 total_broadcast_bytes_received);
     929                 :          0 :                 UPDATE_QSTAT(tclient->rcv_mcast_bytes,
     930                 :            :                                 total_multicast_bytes_received);
     931                 :          0 :                 UPDATE_QSTAT(tclient->rcv_ucast_bytes,
     932                 :            :                                 total_unicast_bytes_received);
     933                 :            : 
     934                 :            :                 /*
     935                 :            :                  * sum to total_bytes_received all
     936                 :            :                  * unicast/multicast/broadcast
     937                 :            :                  */
     938                 :            :                 qstats->total_bytes_received_hi =
     939                 :            :                         qstats->total_broadcast_bytes_received_hi;
     940                 :            :                 qstats->total_bytes_received_lo =
     941                 :            :                         qstats->total_broadcast_bytes_received_lo;
     942                 :            : 
     943         [ #  # ]:          0 :                 ADD_64(qstats->total_bytes_received_hi,
     944                 :            :                                 qstats->total_multicast_bytes_received_hi,
     945                 :            :                                 qstats->total_bytes_received_lo,
     946                 :            :                                 qstats->total_multicast_bytes_received_lo);
     947                 :            : 
     948         [ #  # ]:          0 :                 ADD_64(qstats->total_bytes_received_hi,
     949                 :            :                                 qstats->total_unicast_bytes_received_hi,
     950                 :            :                                 qstats->total_bytes_received_lo,
     951                 :            :                                 qstats->total_unicast_bytes_received_lo);
     952                 :            : 
     953                 :          0 :                 qstats->valid_bytes_received_hi = qstats->total_bytes_received_hi;
     954                 :          0 :                 qstats->valid_bytes_received_lo = qstats->total_bytes_received_lo;
     955                 :            : 
     956         [ #  # ]:          0 :                 UPDATE_EXTEND_TSTAT(rcv_ucast_pkts, total_unicast_packets_received);
     957         [ #  # ]:          0 :                 UPDATE_EXTEND_TSTAT(rcv_mcast_pkts, total_multicast_packets_received);
     958         [ #  # ]:          0 :                 UPDATE_EXTEND_TSTAT(rcv_bcast_pkts, total_broadcast_packets_received);
     959   [ #  #  #  # ]:          0 :                 UPDATE_EXTEND_E_TSTAT(pkts_too_big_discard,
     960                 :            :                                 etherstatsoverrsizepkts, 32);
     961   [ #  #  #  # ]:          0 :                 UPDATE_EXTEND_E_TSTAT(no_buff_discard, no_buff_discard, 16);
     962                 :            : 
     963   [ #  #  #  # ]:          0 :                 SUB_EXTEND_USTAT(ucast_no_buff_pkts, total_unicast_packets_received);
     964   [ #  #  #  # ]:          0 :                 SUB_EXTEND_USTAT(mcast_no_buff_pkts,
     965                 :            :                                 total_multicast_packets_received);
     966   [ #  #  #  # ]:          0 :                 SUB_EXTEND_USTAT(bcast_no_buff_pkts,
     967                 :            :                                 total_broadcast_packets_received);
     968   [ #  #  #  # ]:          0 :                 UPDATE_EXTEND_E_USTAT(ucast_no_buff_pkts, no_buff_discard);
     969   [ #  #  #  # ]:          0 :                 UPDATE_EXTEND_E_USTAT(mcast_no_buff_pkts, no_buff_discard);
     970   [ #  #  #  # ]:          0 :                 UPDATE_EXTEND_E_USTAT(bcast_no_buff_pkts, no_buff_discard);
     971                 :            : 
     972                 :          0 :                 UPDATE_QSTAT(xclient->bcast_bytes_sent,
     973                 :            :                                 total_broadcast_bytes_transmitted);
     974                 :          0 :                 UPDATE_QSTAT(xclient->mcast_bytes_sent,
     975                 :            :                                 total_multicast_bytes_transmitted);
     976                 :          0 :                 UPDATE_QSTAT(xclient->ucast_bytes_sent,
     977                 :            :                                 total_unicast_bytes_transmitted);
     978                 :            : 
     979                 :            :                 /*
     980                 :            :                  * sum to total_bytes_transmitted all
     981                 :            :                  * unicast/multicast/broadcast
     982                 :            :                  */
     983                 :            :                 qstats->total_bytes_transmitted_hi =
     984                 :            :                         qstats->total_unicast_bytes_transmitted_hi;
     985                 :            :                 qstats->total_bytes_transmitted_lo =
     986                 :            :                         qstats->total_unicast_bytes_transmitted_lo;
     987                 :            : 
     988         [ #  # ]:          0 :                 ADD_64(qstats->total_bytes_transmitted_hi,
     989                 :            :                                 qstats->total_broadcast_bytes_transmitted_hi,
     990                 :            :                                 qstats->total_bytes_transmitted_lo,
     991                 :            :                                 qstats->total_broadcast_bytes_transmitted_lo);
     992                 :            : 
     993         [ #  # ]:          0 :                 ADD_64(qstats->total_bytes_transmitted_hi,
     994                 :            :                                 qstats->total_multicast_bytes_transmitted_hi,
     995                 :            :                                 qstats->total_bytes_transmitted_lo,
     996                 :            :                                 qstats->total_multicast_bytes_transmitted_lo);
     997                 :            : 
     998         [ #  # ]:          0 :                 UPDATE_EXTEND_XSTAT(ucast_pkts_sent,
     999                 :            :                                 total_unicast_packets_transmitted);
    1000         [ #  # ]:          0 :                 UPDATE_EXTEND_XSTAT(mcast_pkts_sent,
    1001                 :            :                                 total_multicast_packets_transmitted);
    1002         [ #  # ]:          0 :                 UPDATE_EXTEND_XSTAT(bcast_pkts_sent,
    1003                 :            :                                 total_broadcast_packets_transmitted);
    1004                 :            : 
    1005         [ #  # ]:          0 :                 UPDATE_EXTEND_TSTAT(checksum_discard,
    1006                 :            :                                 total_packets_received_checksum_discarded);
    1007         [ #  # ]:          0 :                 UPDATE_EXTEND_TSTAT(ttl0_discard,
    1008                 :            :                                 total_packets_received_ttl0_discarded);
    1009                 :            : 
    1010         [ #  # ]:          0 :                 UPDATE_EXTEND_XSTAT(error_drop_pkts,
    1011                 :            :                                 total_transmitted_dropped_packets_error);
    1012                 :            : 
    1013   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_bytes_received);
             #  #  #  # ]
    1014   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_bytes_transmitted);
             #  #  #  # ]
    1015   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_unicast_packets_received);
             #  #  #  # ]
    1016   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_multicast_packets_received);
             #  #  #  # ]
    1017   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_broadcast_packets_received);
             #  #  #  # ]
    1018   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_unicast_packets_transmitted);
             #  #  #  # ]
    1019   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_multicast_packets_transmitted);
             #  #  #  # ]
    1020   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(total_broadcast_packets_transmitted);
             #  #  #  # ]
    1021   [ #  #  #  #  :          0 :                 UPDATE_FSTAT_QSTAT(valid_bytes_received);
             #  #  #  # ]
    1022                 :            :         }
    1023                 :            : 
    1024         [ #  # ]:          0 :         ADD_64(estats->total_bytes_received_hi,
    1025                 :            :                         estats->rx_stat_ifhcinbadoctets_hi,
    1026                 :            :                         estats->total_bytes_received_lo,
    1027                 :            :                         estats->rx_stat_ifhcinbadoctets_lo);
    1028                 :            : 
    1029         [ #  # ]:          0 :         ADD_64_LE(estats->total_bytes_received_hi,
    1030                 :            :                         tfunc->rcv_error_bytes.hi,
    1031                 :            :                         estats->total_bytes_received_lo,
    1032                 :            :                         tfunc->rcv_error_bytes.lo);
    1033                 :            : 
    1034                 :          0 :         ADD_64_LE(estats->error_bytes_received_hi,
    1035                 :            :                         tfunc->rcv_error_bytes.hi,
    1036                 :            :                         estats->error_bytes_received_lo,
    1037                 :            :                         tfunc->rcv_error_bytes.lo);
    1038                 :            : 
    1039   [ #  #  #  #  :          0 :         UPDATE_ESTAT(etherstatsoverrsizepkts, rx_stat_dot3statsframestoolong);
             #  #  #  # ]
    1040                 :            : 
    1041         [ #  # ]:          0 :         ADD_64(estats->error_bytes_received_hi,
    1042                 :            :                         estats->rx_stat_ifhcinbadoctets_hi,
    1043                 :            :                         estats->error_bytes_received_lo,
    1044                 :            :                         estats->rx_stat_ifhcinbadoctets_lo);
    1045                 :            : 
    1046         [ #  # ]:          0 :         if (sc->port.pmf) {
    1047                 :            :                 struct bnx2x_fw_port_stats_old *fwstats = &sc->fw_stats_old;
    1048                 :          0 :                 UPDATE_FW_STAT(mac_filter_discard);
    1049                 :          0 :                 UPDATE_FW_STAT(mf_tag_discard);
    1050                 :          0 :                 UPDATE_FW_STAT(brb_truncate_discard);
    1051                 :          0 :                 UPDATE_FW_STAT(mac_discard);
    1052                 :            :         }
    1053                 :            : 
    1054                 :          0 :         fstats->host_func_stats_start = ++fstats->host_func_stats_end;
    1055                 :            : 
    1056                 :          0 :         sc->stats_pending = 0;
    1057                 :            : 
    1058                 :          0 :         return 0;
    1059                 :            : }
    1060                 :            : 
    1061                 :            : static void
    1062                 :          0 : bnx2x_drv_stats_update(struct bnx2x_softc *sc)
    1063                 :            : {
    1064                 :            :         struct bnx2x_eth_stats *estats = &sc->eth_stats;
    1065                 :            :         int i;
    1066                 :            : 
    1067         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
    1068                 :            :                 struct bnx2x_eth_q_stats *qstats = &sc->fp[i].eth_q_stats;
    1069                 :            :                 struct bnx2x_eth_q_stats_old *qstats_old = &sc->fp[i].eth_q_stats_old;
    1070                 :            : 
    1071                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_calls);
    1072                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_pkts);
    1073                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_soft_errors);
    1074                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_hw_csum_errors);
    1075                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_ofld_frames_csum_ip);
    1076                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_ofld_frames_csum_tcp_udp);
    1077                 :          0 :                 UPDATE_ESTAT_QSTAT(rx_budget_reached);
    1078                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_pkts);
    1079                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_soft_errors);
    1080                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_ofld_frames_csum_ip);
    1081                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_ofld_frames_csum_tcp);
    1082                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_ofld_frames_csum_udp);
    1083                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_encap_failures);
    1084                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_hw_queue_full);
    1085                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_hw_max_queue_depth);
    1086                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_dma_mapping_failure);
    1087                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_max_drbr_queue_depth);
    1088                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_window_violation_std);
    1089                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_chain_lost_mbuf);
    1090                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_frames_deferred);
    1091                 :          0 :                 UPDATE_ESTAT_QSTAT(tx_queue_xoff);
    1092                 :            : 
    1093                 :            :                 /* mbuf driver statistics */
    1094                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_defrag_attempts);
    1095                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_defrag_failures);
    1096                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_rx_bd_alloc_failed);
    1097                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_rx_bd_mapping_failed);
    1098                 :            : 
    1099                 :            :                 /* track the number of allocated mbufs */
    1100                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_alloc_tx);
    1101                 :          0 :                 UPDATE_ESTAT_QSTAT(mbuf_alloc_rx);
    1102                 :            :         }
    1103                 :          0 : }
    1104                 :            : 
    1105                 :            : static uint8_t
    1106                 :            : bnx2x_edebug_stats_stopped(struct bnx2x_softc *sc)
    1107                 :            : {
    1108                 :            :         uint32_t val;
    1109                 :            : 
    1110         [ #  # ]:          0 :         if (SHMEM2_HAS(sc, edebug_driver_if[1])) {
    1111                 :          0 :                 val = SHMEM2_RD(sc, edebug_driver_if[1]);
    1112                 :            : 
    1113         [ #  # ]:          0 :                 if (val == EDEBUG_DRIVER_IF_OP_CODE_DISABLE_STAT)
    1114                 :            :                         return TRUE;
    1115                 :            :         }
    1116                 :            : 
    1117                 :            :         return FALSE;
    1118                 :            : }
    1119                 :            : 
    1120                 :            : static void
    1121                 :          0 : bnx2x_stats_update(struct bnx2x_softc *sc)
    1122                 :            : {
    1123         [ #  # ]:          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
    1124                 :            : 
    1125                 :            :         if (bnx2x_edebug_stats_stopped(sc))
    1126                 :            :                 return;
    1127                 :            : 
    1128         [ #  # ]:          0 :         if (IS_PF(sc)) {
    1129                 :            : 
    1130                 :          0 :                 bnx2x_storm_stats_update(sc);
    1131                 :          0 :                 bnx2x_hw_stats_post(sc);
    1132                 :          0 :                 bnx2x_storm_stats_post(sc);
    1133                 :            :                 DELAY_MS(5);
    1134                 :            : 
    1135         [ #  # ]:          0 :                 if (*stats_comp != DMAE_COMP_VAL)
    1136                 :            :                         return;
    1137                 :            : 
    1138         [ #  # ]:          0 :                 if (sc->port.pmf)
    1139                 :          0 :                         bnx2x_hw_stats_update(sc);
    1140                 :            : 
    1141         [ #  # ]:          0 :                 if (bnx2x_storm_stats_update(sc)) {
    1142         [ #  # ]:          0 :                         if (sc->stats_pending++ == 3)
    1143                 :          0 :                                 rte_panic("storm stats not updated for 3 times");
    1144                 :            :                         return;
    1145                 :            :                 }
    1146                 :            :         } else {
    1147                 :            :                 /*
    1148                 :            :                  * VF doesn't collect HW statistics, and doesn't get completions,
    1149                 :            :                  * performs only update.
    1150                 :            :                  */
    1151                 :          0 :                 bnx2x_storm_stats_update(sc);
    1152                 :            :         }
    1153                 :            : 
    1154                 :          0 :         bnx2x_drv_stats_update(sc);
    1155                 :            : }
    1156                 :            : 
    1157                 :            : static void
    1158                 :          0 : bnx2x_port_stats_stop(struct bnx2x_softc *sc)
    1159                 :            : {
    1160                 :            :         struct dmae_command *dmae;
    1161                 :            :         uint32_t opcode;
    1162                 :          0 :         int loader_idx = PMF_DMAE_C(sc);
    1163                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
    1164                 :            : 
    1165                 :          0 :         sc->executer_idx = 0;
    1166                 :            : 
    1167                 :          0 :         opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_PCI, DMAE_DST_GRC, FALSE, 0);
    1168                 :            : 
    1169         [ #  # ]:          0 :         if (sc->port.port_stx) {
    1170                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
    1171                 :            : 
    1172         [ #  # ]:          0 :                 if (sc->func_stx)
    1173                 :          0 :                         dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_GRC);
    1174                 :            :                 else
    1175                 :          0 :                         dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_PCI);
    1176                 :            : 
    1177                 :          0 :                 dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, port_stats));
    1178                 :          0 :                 dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, port_stats));
    1179                 :          0 :                 dmae->dst_addr_lo = sc->port.port_stx >> 2;
    1180                 :          0 :                 dmae->dst_addr_hi = 0;
    1181                 :          0 :                 dmae->len = bnx2x_get_port_stats_dma_len(sc);
    1182         [ #  # ]:          0 :                 if (sc->func_stx) {
    1183                 :          0 :                         dmae->comp_addr_lo = (dmae_reg_go_c[loader_idx] >> 2);
    1184                 :          0 :                         dmae->comp_addr_hi = 0;
    1185                 :          0 :                         dmae->comp_val = 1;
    1186                 :            :                 } else {
    1187                 :          0 :                         dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
    1188                 :          0 :                         dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
    1189                 :          0 :                         dmae->comp_val = DMAE_COMP_VAL;
    1190                 :            : 
    1191                 :          0 :                         *stats_comp = 0;
    1192                 :            :                 }
    1193                 :            :         }
    1194                 :            : 
    1195         [ #  # ]:          0 :         if (sc->func_stx) {
    1196                 :          0 :                 dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
    1197                 :          0 :                 dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_PCI);
    1198                 :          0 :                 dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, func_stats));
    1199                 :          0 :                 dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, func_stats));
    1200                 :          0 :                 dmae->dst_addr_lo = (sc->func_stx >> 2);
    1201                 :          0 :                 dmae->dst_addr_hi = 0;
    1202                 :          0 :                 dmae->len = (sizeof(struct host_func_stats) >> 2);
    1203                 :          0 :                 dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
    1204                 :          0 :                 dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
    1205                 :          0 :                 dmae->comp_val = DMAE_COMP_VAL;
    1206                 :            : 
    1207                 :          0 :                 *stats_comp = 0;
    1208                 :            :         }
    1209                 :          0 : }
    1210                 :            : 
    1211                 :            : static void
    1212                 :          0 : bnx2x_stats_stop(struct bnx2x_softc *sc)
    1213                 :            : {
    1214                 :            :         uint8_t update = FALSE;
    1215                 :            : 
    1216                 :          0 :         bnx2x_stats_comp(sc);
    1217                 :            : 
    1218         [ #  # ]:          0 :         if (sc->port.pmf)
    1219                 :          0 :                 update = bnx2x_hw_stats_update(sc) == 0;
    1220                 :            : 
    1221                 :          0 :         update |= bnx2x_storm_stats_update(sc) == 0;
    1222                 :            : 
    1223         [ #  # ]:          0 :         if (update) {
    1224         [ #  # ]:          0 :                 if (sc->port.pmf)
    1225                 :          0 :                         bnx2x_port_stats_stop(sc);
    1226                 :            : 
    1227                 :          0 :                 bnx2x_hw_stats_post(sc);
    1228                 :          0 :                 bnx2x_stats_comp(sc);
    1229                 :            :         }
    1230                 :          0 : }
    1231                 :            : 
    1232                 :            : static void
    1233                 :          0 : bnx2x_stats_do_nothing(__rte_unused struct bnx2x_softc *sc)
    1234                 :            : {
    1235                 :          0 : }
    1236                 :            : 
    1237                 :            : static const struct {
    1238                 :            :         void (*action)(struct bnx2x_softc *sc);
    1239                 :            :         enum bnx2x_stats_state next_state;
    1240                 :            : } bnx2x_stats_stm[STATS_STATE_MAX][STATS_EVENT_MAX] = {
    1241                 :            :         {
    1242                 :            :         /* DISABLED PMF */ { bnx2x_stats_pmf_update, STATS_STATE_DISABLED },
    1243                 :            :         /*      LINK_UP */ { bnx2x_stats_start,      STATS_STATE_ENABLED },
    1244                 :            :         /*      UPDATE  */ { bnx2x_stats_do_nothing, STATS_STATE_DISABLED },
    1245                 :            :         /*      STOP    */ { bnx2x_stats_do_nothing, STATS_STATE_DISABLED }
    1246                 :            :         },
    1247                 :            :         {
    1248                 :            :         /* ENABLED  PMF */ { bnx2x_stats_pmf_start,  STATS_STATE_ENABLED },
    1249                 :            :         /*      LINK_UP */ { bnx2x_stats_restart,    STATS_STATE_ENABLED },
    1250                 :            :         /*      UPDATE  */ { bnx2x_stats_update,     STATS_STATE_ENABLED },
    1251                 :            :         /*      STOP    */ { bnx2x_stats_stop,       STATS_STATE_DISABLED }
    1252                 :            :         }
    1253                 :            : };
    1254                 :            : 
    1255                 :          0 : void bnx2x_stats_handle(struct bnx2x_softc *sc, enum bnx2x_stats_event event)
    1256                 :            : {
    1257                 :            :         enum bnx2x_stats_state state;
    1258                 :            : 
    1259         [ #  # ]:          0 :         if (unlikely(sc->panic))
    1260                 :            :                 return;
    1261                 :            : 
    1262                 :          0 :         state = sc->stats_state;
    1263                 :          0 :         sc->stats_state = bnx2x_stats_stm[state][event].next_state;
    1264                 :            : 
    1265                 :          0 :         bnx2x_stats_stm[state][event].action(sc);
    1266                 :            : 
    1267         [ #  # ]:          0 :         if (event != STATS_EVENT_UPDATE) {
    1268                 :          0 :                 PMD_DRV_LOG(DEBUG, sc,
    1269                 :            :                                 "state %d -> event %d -> state %d",
    1270                 :            :                                 state, event, sc->stats_state);
    1271                 :            :         }
    1272                 :            : }
    1273                 :            : 
    1274                 :            : static void
    1275                 :          0 : bnx2x_port_stats_base_init(struct bnx2x_softc *sc)
    1276                 :            : {
    1277                 :            :         struct dmae_command *dmae;
    1278                 :          0 :         uint32_t *stats_comp = BNX2X_SP(sc, stats_comp);
    1279                 :            : 
    1280                 :            :         /* sanity */
    1281   [ #  #  #  # ]:          0 :         if (!sc->port.pmf || !sc->port.port_stx) {
    1282                 :          0 :                 PMD_DRV_LOG(ERR, sc, "BUG!");
    1283                 :          0 :                 return;
    1284                 :            :         }
    1285                 :            : 
    1286                 :            :         sc->executer_idx = 0;
    1287                 :            : 
    1288                 :          0 :         dmae = BNX2X_SP(sc, dmae[sc->executer_idx++]);
    1289                 :          0 :         dmae->opcode = bnx2x_dmae_opcode(sc, DMAE_SRC_PCI, DMAE_DST_GRC,
    1290                 :            :                                          TRUE, DMAE_COMP_PCI);
    1291                 :          0 :         dmae->src_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, port_stats));
    1292                 :          0 :         dmae->src_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, port_stats));
    1293                 :          0 :         dmae->dst_addr_lo = (sc->port.port_stx >> 2);
    1294                 :          0 :         dmae->dst_addr_hi = 0;
    1295                 :          0 :         dmae->len = bnx2x_get_port_stats_dma_len(sc);
    1296                 :          0 :         dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, stats_comp));
    1297                 :          0 :         dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, stats_comp));
    1298                 :          0 :         dmae->comp_val = DMAE_COMP_VAL;
    1299                 :            : 
    1300                 :          0 :         *stats_comp = 0;
    1301                 :          0 :         bnx2x_hw_stats_post(sc);
    1302                 :          0 :         bnx2x_stats_comp(sc);
    1303                 :            : }
    1304                 :            : 
    1305                 :            : /*
    1306                 :            :  * This function will prepare the statistics ramrod data the way
    1307                 :            :  * we will only have to increment the statistics counter and
    1308                 :            :  * send the ramrod each time we have to.
    1309                 :            :  */
    1310                 :            : static void
    1311                 :          0 : bnx2x_prep_fw_stats_req(struct bnx2x_softc *sc)
    1312                 :            : {
    1313                 :            :         int i;
    1314                 :            :         int first_queue_query_index;
    1315                 :          0 :         struct stats_query_header *stats_hdr = &sc->fw_stats_req->hdr;
    1316                 :            :         rte_iova_t cur_data_offset;
    1317                 :            :         struct stats_query_entry *cur_query_entry;
    1318                 :            : 
    1319                 :          0 :         stats_hdr->cmd_num = sc->fw_stats_num;
    1320                 :          0 :         stats_hdr->drv_stats_counter = 0;
    1321                 :            : 
    1322                 :            :         /*
    1323                 :            :          * The storm_counters struct contains the counters of completed
    1324                 :            :          * statistics requests per storm which are incremented by FW
    1325                 :            :          * each time it completes hadning a statistics ramrod. We will
    1326                 :            :          * check these counters in the timer handler and discard a
    1327                 :            :          * (statistics) ramrod completion.
    1328                 :            :          */
    1329                 :          0 :         cur_data_offset = (sc->fw_stats_data_mapping +
    1330                 :            :                            offsetof(struct bnx2x_fw_stats_data, storm_counters));
    1331                 :            : 
    1332                 :          0 :         stats_hdr->stats_counters_addrs.hi = htole32(U64_HI(cur_data_offset));
    1333                 :          0 :         stats_hdr->stats_counters_addrs.lo = htole32(U64_LO(cur_data_offset));
    1334                 :            : 
    1335                 :            :         /*
    1336                 :            :          * Prepare the first stats ramrod (will be completed with
    1337                 :            :          * the counters equal to zero) - init counters to something different.
    1338                 :            :          */
    1339                 :          0 :         memset(&sc->fw_stats_data->storm_counters, 0xff,
    1340                 :            :                sizeof(struct stats_counter));
    1341                 :            : 
    1342                 :            :         /**** Port FW statistics data ****/
    1343                 :          0 :         cur_data_offset = (sc->fw_stats_data_mapping +
    1344                 :            :                            offsetof(struct bnx2x_fw_stats_data, port));
    1345                 :            : 
    1346                 :          0 :         cur_query_entry = &sc->fw_stats_req->query[BNX2X_PORT_QUERY_IDX];
    1347                 :            : 
    1348                 :          0 :         cur_query_entry->kind = STATS_TYPE_PORT;
    1349                 :            :         /* For port query index is a DON'T CARE */
    1350                 :          0 :         cur_query_entry->index = SC_PORT(sc);
    1351                 :            :         /* For port query funcID is a DON'T CARE */
    1352                 :          0 :         cur_query_entry->funcID = htole16(SC_FUNC(sc));
    1353                 :          0 :         cur_query_entry->address.hi = htole32(U64_HI(cur_data_offset));
    1354                 :          0 :         cur_query_entry->address.lo = htole32(U64_LO(cur_data_offset));
    1355                 :            : 
    1356                 :            :         /**** PF FW statistics data ****/
    1357                 :          0 :         cur_data_offset = (sc->fw_stats_data_mapping +
    1358                 :            :                            offsetof(struct bnx2x_fw_stats_data, pf));
    1359                 :            : 
    1360                 :            :         cur_query_entry = &sc->fw_stats_req->query[BNX2X_PF_QUERY_IDX];
    1361                 :            : 
    1362                 :          0 :         cur_query_entry->kind = STATS_TYPE_PF;
    1363                 :            :         /* For PF query index is a DON'T CARE */
    1364                 :          0 :         cur_query_entry->index = SC_PORT(sc);
    1365                 :          0 :         cur_query_entry->funcID = htole16(SC_FUNC(sc));
    1366                 :          0 :         cur_query_entry->address.hi = htole32(U64_HI(cur_data_offset));
    1367                 :          0 :         cur_query_entry->address.lo = htole32(U64_LO(cur_data_offset));
    1368                 :            : 
    1369                 :            :         /**** Clients' queries ****/
    1370                 :          0 :         cur_data_offset = (sc->fw_stats_data_mapping +
    1371                 :            :                            offsetof(struct bnx2x_fw_stats_data, queue_stats));
    1372                 :            : 
    1373                 :            :         /*
    1374                 :            :          * First queue query index depends whether FCoE offloaded request will
    1375                 :            :          * be included in the ramrod
    1376                 :            :          */
    1377                 :            :         first_queue_query_index = (BNX2X_FIRST_QUEUE_QUERY_IDX - 1);
    1378                 :            : 
    1379         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
    1380                 :            :                 cur_query_entry =
    1381                 :          0 :                         &sc->fw_stats_req->query[first_queue_query_index + i];
    1382                 :            : 
    1383         [ #  # ]:          0 :                 cur_query_entry->kind = STATS_TYPE_QUEUE;
    1384                 :          0 :                 cur_query_entry->index = bnx2x_stats_id(&sc->fp[i]);
    1385                 :          0 :                 cur_query_entry->funcID = htole16(SC_FUNC(sc));
    1386                 :          0 :                 cur_query_entry->address.hi = htole32(U64_HI(cur_data_offset));
    1387                 :          0 :                 cur_query_entry->address.lo = htole32(U64_LO(cur_data_offset));
    1388                 :            : 
    1389                 :          0 :                 cur_data_offset += sizeof(struct per_queue_stats);
    1390                 :            :         }
    1391                 :          0 : }
    1392                 :            : 
    1393                 :          0 : void bnx2x_memset_stats(struct bnx2x_softc *sc)
    1394                 :            : {
    1395                 :            :         int i;
    1396                 :            : 
    1397                 :            :         /* function stats */
    1398         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
    1399                 :            :                 struct bnx2x_fastpath *fp = &sc->fp[i];
    1400                 :            : 
    1401         [ #  # ]:          0 :                 memset(&fp->old_tclient, 0,
    1402                 :            :                                 sizeof(fp->old_tclient));
    1403                 :          0 :                 memset(&fp->old_uclient, 0,
    1404                 :            :                                 sizeof(fp->old_uclient));
    1405                 :          0 :                 memset(&fp->old_xclient, 0,
    1406                 :            :                                 sizeof(fp->old_xclient));
    1407         [ #  # ]:          0 :                 if (sc->stats_init) {
    1408                 :          0 :                         memset(&fp->eth_q_stats, 0,
    1409                 :            :                                         sizeof(fp->eth_q_stats));
    1410                 :          0 :                         memset(&fp->eth_q_stats_old, 0,
    1411                 :            :                                         sizeof(fp->eth_q_stats_old));
    1412                 :            :                 }
    1413                 :            :         }
    1414                 :            : 
    1415         [ #  # ]:          0 :         if (sc->stats_init) {
    1416                 :          0 :                 memset(&sc->net_stats_old, 0, sizeof(sc->net_stats_old));
    1417                 :          0 :                 memset(&sc->fw_stats_old, 0, sizeof(sc->fw_stats_old));
    1418                 :          0 :                 memset(&sc->eth_stats_old, 0, sizeof(sc->eth_stats_old));
    1419                 :          0 :                 memset(&sc->eth_stats, 0, sizeof(sc->eth_stats));
    1420                 :          0 :                 memset(&sc->func_stats, 0, sizeof(sc->func_stats));
    1421                 :            :         }
    1422                 :            : 
    1423                 :          0 :         sc->stats_state = STATS_STATE_DISABLED;
    1424                 :            : 
    1425   [ #  #  #  # ]:          0 :         if (sc->port.pmf && sc->port.port_stx)
    1426                 :          0 :                 bnx2x_port_stats_base_init(sc);
    1427                 :            : 
    1428                 :            :         /* mark the end of statistics initialization */
    1429                 :          0 :         sc->stats_init = false;
    1430                 :          0 : }
    1431                 :            : 
    1432                 :            : void
    1433                 :          0 : bnx2x_stats_init(struct bnx2x_softc *sc)
    1434                 :            : {
    1435                 :          0 :         int /*abs*/port = SC_PORT(sc);
    1436   [ #  #  #  # ]:          0 :         int mb_idx = SC_FW_MB_IDX(sc);
    1437                 :            :         int i;
    1438                 :            : 
    1439                 :          0 :         sc->stats_pending = 0;
    1440                 :          0 :         sc->executer_idx = 0;
    1441                 :          0 :         sc->stats_counter = 0;
    1442                 :            : 
    1443                 :          0 :         sc->stats_init = TRUE;
    1444                 :            : 
    1445                 :            :         /* port and func stats for management */
    1446         [ #  # ]:          0 :         if (!BNX2X_NOMCP(sc)) {
    1447                 :          0 :                 sc->port.port_stx = SHMEM_RD(sc, port_mb[port].port_stx);
    1448                 :          0 :                 sc->func_stx = SHMEM_RD(sc, func_mb[mb_idx].fw_mb_param);
    1449                 :            :         } else {
    1450                 :          0 :                 sc->port.port_stx = 0;
    1451                 :          0 :                 sc->func_stx = 0;
    1452                 :            :         }
    1453                 :            : 
    1454                 :          0 :         PMD_DRV_LOG(DEBUG, sc, "port_stx 0x%x func_stx 0x%x",
    1455                 :            :                         sc->port.port_stx, sc->func_stx);
    1456                 :            : 
    1457                 :            :         /* pmf should retrieve port statistics from SP on a non-init*/
    1458   [ #  #  #  #  :          0 :         if (!sc->stats_init && sc->port.pmf && sc->port.port_stx)
                   #  # ]
    1459                 :          0 :                 bnx2x_stats_handle(sc, STATS_EVENT_PMF);
    1460                 :            : 
    1461                 :          0 :         port = SC_PORT(sc);
    1462                 :            :         /* port stats */
    1463                 :          0 :         memset(&(sc->port.old_nig_stats), 0, sizeof(struct nig_stats));
    1464                 :          0 :         sc->port.old_nig_stats.brb_discard =
    1465                 :          0 :                 REG_RD(sc, NIG_REG_STAT0_BRB_DISCARD + port*0x38);
    1466                 :          0 :         sc->port.old_nig_stats.brb_truncate =
    1467                 :          0 :                 REG_RD(sc, NIG_REG_STAT0_BRB_TRUNCATE + port*0x38);
    1468   [ #  #  #  #  :          0 :         if (!CHIP_IS_E3(sc)) {
          #  #  #  #  #  
                      # ]
    1469         [ #  # ]:          0 :                 REG_RD_DMAE(sc, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50,
    1470                 :            :                                 RTE_PTR_ADD(&sc->port.old_nig_stats,
    1471                 :            :                                 offsetof(struct nig_stats, egress_mac_pkt0_lo)), 2);
    1472         [ #  # ]:          0 :                 REG_RD_DMAE(sc, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50,
    1473                 :            :                                 RTE_PTR_ADD(&sc->port.old_nig_stats,
    1474                 :            :                                 offsetof(struct nig_stats, egress_mac_pkt1_lo)), 2);
    1475                 :            :         }
    1476                 :            : 
    1477                 :            :         /* function stats */
    1478         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
    1479         [ #  # ]:          0 :                 memset(&sc->fp[i].old_tclient, 0, sizeof(sc->fp[i].old_tclient));
    1480                 :          0 :                 memset(&sc->fp[i].old_uclient, 0, sizeof(sc->fp[i].old_uclient));
    1481                 :          0 :                 memset(&sc->fp[i].old_xclient, 0, sizeof(sc->fp[i].old_xclient));
    1482         [ #  # ]:          0 :                 if (sc->stats_init) {
    1483                 :          0 :                         memset(&sc->fp[i].eth_q_stats, 0,
    1484                 :            :                                         sizeof(sc->fp[i].eth_q_stats));
    1485                 :          0 :                         memset(&sc->fp[i].eth_q_stats_old, 0,
    1486                 :            :                                         sizeof(sc->fp[i].eth_q_stats_old));
    1487                 :            :                 }
    1488                 :            :         }
    1489                 :            : 
    1490                 :            :         /* prepare statistics ramrod data */
    1491                 :          0 :         bnx2x_prep_fw_stats_req(sc);
    1492                 :            : 
    1493         [ #  # ]:          0 :         if (sc->stats_init) {
    1494         [ #  # ]:          0 :                 memset(&sc->net_stats_old, 0, sizeof(sc->net_stats_old));
    1495                 :          0 :                 memset(&sc->fw_stats_old, 0, sizeof(sc->fw_stats_old));
    1496                 :          0 :                 memset(&sc->eth_stats_old, 0, sizeof(sc->eth_stats_old));
    1497                 :          0 :                 memset(&sc->eth_stats, 0, sizeof(sc->eth_stats));
    1498                 :          0 :                 memset(&sc->func_stats, 0, sizeof(sc->func_stats));
    1499                 :            : 
    1500                 :            :                 /* Clean SP from previous statistics */
    1501         [ #  # ]:          0 :                 if (sc->func_stx) {
    1502                 :          0 :                         memset(BNX2X_SP(sc, func_stats), 0, sizeof(struct host_func_stats));
    1503                 :          0 :                         bnx2x_func_stats_init(sc);
    1504                 :          0 :                         bnx2x_hw_stats_post(sc);
    1505                 :          0 :                         bnx2x_stats_comp(sc);
    1506                 :            :                 }
    1507                 :            :         }
    1508                 :            : 
    1509                 :          0 :         sc->stats_state = STATS_STATE_DISABLED;
    1510                 :            : 
    1511   [ #  #  #  # ]:          0 :         if (sc->port.pmf && sc->port.port_stx)
    1512                 :          0 :                 bnx2x_port_stats_base_init(sc);
    1513                 :            : 
    1514                 :            :         /* mark the end of statistics initialization */
    1515                 :          0 :         sc->stats_init = FALSE;
    1516                 :          0 : }
    1517                 :            : 
    1518                 :            : void
    1519                 :          0 : bnx2x_save_statistics(struct bnx2x_softc *sc)
    1520                 :            : {
    1521                 :            :         int i;
    1522                 :            : 
    1523                 :            :         /* save queue statistics */
    1524         [ #  # ]:          0 :         for (i = 0; i < sc->num_queues; i++) {
    1525                 :            :                 struct bnx2x_fastpath *fp = &sc->fp[i];
    1526                 :            :                 struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
    1527                 :            :                 struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old;
    1528                 :            : 
    1529                 :          0 :                 UPDATE_QSTAT_OLD(total_unicast_bytes_received_hi);
    1530                 :          0 :                 UPDATE_QSTAT_OLD(total_unicast_bytes_received_lo);
    1531                 :          0 :                 UPDATE_QSTAT_OLD(total_broadcast_bytes_received_hi);
    1532                 :          0 :                 UPDATE_QSTAT_OLD(total_broadcast_bytes_received_lo);
    1533                 :          0 :                 UPDATE_QSTAT_OLD(total_multicast_bytes_received_hi);
    1534                 :          0 :                 UPDATE_QSTAT_OLD(total_multicast_bytes_received_lo);
    1535                 :          0 :                 UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_hi);
    1536                 :          0 :                 UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_lo);
    1537                 :          0 :                 UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_hi);
    1538                 :          0 :                 UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_lo);
    1539                 :          0 :                 UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_hi);
    1540                 :          0 :                 UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_lo);
    1541                 :            :         }
    1542                 :            : 
    1543                 :            :         /* store port firmware statistics */
    1544         [ #  # ]:          0 :         if (sc->port.pmf) {
    1545                 :            :                 struct bnx2x_eth_stats *estats = &sc->eth_stats;
    1546                 :            :                 struct bnx2x_fw_port_stats_old *fwstats = &sc->fw_stats_old;
    1547                 :          0 :                 struct host_port_stats *pstats = BNX2X_SP(sc, port_stats);
    1548                 :            : 
    1549                 :          0 :                 fwstats->pfc_frames_rx_hi = pstats->pfc_frames_rx_hi;
    1550                 :          0 :                 fwstats->pfc_frames_rx_lo = pstats->pfc_frames_rx_lo;
    1551                 :          0 :                 fwstats->pfc_frames_tx_hi = pstats->pfc_frames_tx_hi;
    1552                 :          0 :                 fwstats->pfc_frames_tx_lo = pstats->pfc_frames_tx_lo;
    1553                 :            : 
    1554   [ #  #  #  # ]:          0 :                 if (IS_MF(sc)) {
    1555                 :          0 :                         UPDATE_FW_STAT_OLD(mac_filter_discard);
    1556                 :          0 :                         UPDATE_FW_STAT_OLD(mf_tag_discard);
    1557                 :          0 :                         UPDATE_FW_STAT_OLD(brb_truncate_discard);
    1558                 :          0 :                         UPDATE_FW_STAT_OLD(mac_discard);
    1559                 :            :                 }
    1560                 :            :         }
    1561                 :          0 : }

Generated by: LCOV version 1.14