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