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 : : #define BNX2X_DRIVER_VERSION "1.78.18"
15 : :
16 : : #include "bnx2x.h"
17 : : #include "bnx2x_vfpf.h"
18 : : #include "ecore_sp.h"
19 : : #include "ecore_init.h"
20 : : #include "ecore_init_ops.h"
21 : :
22 : : #include "rte_version.h"
23 : :
24 : : #include <sys/types.h>
25 : : #include <sys/stat.h>
26 : : #include <arpa/inet.h>
27 : : #include <fcntl.h>
28 : : #include <zlib.h>
29 : :
30 : : #include <rte_bitops.h>
31 : : #include <rte_string_fns.h>
32 : :
33 : : #include "eal_firmware.h"
34 : :
35 : : #define BNX2X_PMD_VER_PREFIX "BNX2X PMD"
36 : : #define BNX2X_PMD_VERSION_MAJOR 1
37 : : #define BNX2X_PMD_VERSION_MINOR 1
38 : : #define BNX2X_PMD_VERSION_REVISION 0
39 : : #define BNX2X_PMD_VERSION_PATCH 1
40 : :
41 : : static inline const char *
42 : 0 : bnx2x_pmd_version(void)
43 : : {
44 : : static char version[32];
45 : :
46 : : snprintf(version, sizeof(version), "%s %s_%d.%d.%d.%d",
47 : : BNX2X_PMD_VER_PREFIX,
48 : : BNX2X_DRIVER_VERSION,
49 : : BNX2X_PMD_VERSION_MAJOR,
50 : : BNX2X_PMD_VERSION_MINOR,
51 : : BNX2X_PMD_VERSION_REVISION,
52 : : BNX2X_PMD_VERSION_PATCH);
53 : :
54 : 0 : return version;
55 : : }
56 : :
57 : : static z_stream zlib_stream;
58 : :
59 : : #define EVL_VLID_MASK 0x0FFF
60 : :
61 : : #define BNX2X_DEF_SB_ATT_IDX 0x0001
62 : : #define BNX2X_DEF_SB_IDX 0x0002
63 : :
64 : : /*
65 : : * FLR Support - bnx2x_pf_flr_clnup() is called during nic_load in the per
66 : : * function HW initialization.
67 : : */
68 : : #define FLR_WAIT_USEC 10000 /* 10 msecs */
69 : : #define FLR_WAIT_INTERVAL 50 /* usecs */
70 : : #define FLR_POLL_CNT (FLR_WAIT_USEC / FLR_WAIT_INTERVAL) /* 200 */
71 : :
72 : : struct pbf_pN_buf_regs {
73 : : int pN;
74 : : uint32_t init_crd;
75 : : uint32_t crd;
76 : : uint32_t crd_freed;
77 : : };
78 : :
79 : : struct pbf_pN_cmd_regs {
80 : : int pN;
81 : : uint32_t lines_occup;
82 : : uint32_t lines_freed;
83 : : };
84 : :
85 : : /* resources needed for unloading a previously loaded device */
86 : :
87 : : #define BNX2X_PREV_WAIT_NEEDED 1
88 : : rte_spinlock_t bnx2x_prev_mtx;
89 : : struct bnx2x_prev_list_node {
90 : : LIST_ENTRY(bnx2x_prev_list_node) node;
91 : : uint8_t bus;
92 : : uint8_t slot;
93 : : uint8_t path;
94 : : uint8_t aer;
95 : : uint8_t undi;
96 : : };
97 : :
98 : : static LIST_HEAD(, bnx2x_prev_list_node) bnx2x_prev_list
99 : : = LIST_HEAD_INITIALIZER(bnx2x_prev_list);
100 : :
101 : : static int load_count[2][3] = { { 0 } };
102 : : /* per-path: 0-common, 1-port0, 2-port1 */
103 : :
104 : : static void bnx2x_cmng_fns_init(struct bnx2x_softc *sc, uint8_t read_cfg,
105 : : uint8_t cmng_type);
106 : : static int bnx2x_get_cmng_fns_mode(struct bnx2x_softc *sc);
107 : : static void storm_memset_cmng(struct bnx2x_softc *sc, struct cmng_init *cmng,
108 : : uint8_t port);
109 : : static void bnx2x_set_reset_global(struct bnx2x_softc *sc);
110 : : static void bnx2x_set_reset_in_progress(struct bnx2x_softc *sc);
111 : : static uint8_t bnx2x_reset_is_done(struct bnx2x_softc *sc, int engine);
112 : : static uint8_t bnx2x_clear_pf_load(struct bnx2x_softc *sc);
113 : : static uint8_t bnx2x_chk_parity_attn(struct bnx2x_softc *sc, uint8_t * global,
114 : : uint8_t print);
115 : : static void bnx2x_int_disable(struct bnx2x_softc *sc);
116 : : static int bnx2x_release_leader_lock(struct bnx2x_softc *sc);
117 : : static void bnx2x_pf_disable(struct bnx2x_softc *sc);
118 : : static void bnx2x_update_rx_prod(struct bnx2x_softc *sc,
119 : : struct bnx2x_fastpath *fp,
120 : : uint16_t rx_bd_prod, uint16_t rx_cq_prod);
121 : : static void bnx2x_link_report_locked(struct bnx2x_softc *sc);
122 : : static void bnx2x_link_report(struct bnx2x_softc *sc);
123 : : void bnx2x_link_status_update(struct bnx2x_softc *sc);
124 : : static int bnx2x_alloc_mem(struct bnx2x_softc *sc);
125 : : static void bnx2x_free_mem(struct bnx2x_softc *sc);
126 : : static int bnx2x_alloc_fw_stats_mem(struct bnx2x_softc *sc);
127 : : static void bnx2x_free_fw_stats_mem(struct bnx2x_softc *sc);
128 : : static __rte_noinline
129 : : int bnx2x_nic_load(struct bnx2x_softc *sc);
130 : :
131 : : static int bnx2x_handle_sp_tq(struct bnx2x_softc *sc);
132 : : static void bnx2x_handle_fp_tq(struct bnx2x_fastpath *fp);
133 : : static void bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id,
134 : : uint8_t storm, uint16_t index, uint8_t op,
135 : : uint8_t update);
136 : :
137 : 0 : int bnx2x_cmpxchg(volatile int *addr, int old, int new)
138 : : {
139 : 0 : return __sync_val_compare_and_swap(addr, old, new);
140 : : }
141 : :
142 : : int
143 : 0 : bnx2x_dma_alloc(struct bnx2x_softc *sc, size_t size, struct bnx2x_dma *dma,
144 : : const char *msg, uint32_t align)
145 : : {
146 : : char mz_name[RTE_MEMZONE_NAMESIZE];
147 : : const struct rte_memzone *z;
148 : :
149 : 0 : dma->sc = sc;
150 [ # # ]: 0 : if (IS_PF(sc))
151 : 0 : snprintf(mz_name, sizeof(mz_name), "bnx2x%d_%s_%" PRIx64, SC_ABS_FUNC(sc), msg,
152 : : rte_get_timer_cycles());
153 : : else
154 : 0 : snprintf(mz_name, sizeof(mz_name), "bnx2x%d_%s_%" PRIx64, sc->pcie_device, msg,
155 : : rte_get_timer_cycles());
156 : :
157 : : /* Caller must take care that strlen(mz_name) < RTE_MEMZONE_NAMESIZE */
158 : 0 : z = rte_memzone_reserve_aligned(mz_name, (uint64_t)size,
159 : : SOCKET_ID_ANY,
160 : : RTE_MEMZONE_IOVA_CONTIG, align);
161 [ # # ]: 0 : if (z == NULL) {
162 : 0 : PMD_DRV_LOG(ERR, sc, "DMA alloc failed for %s", msg);
163 : 0 : return -ENOMEM;
164 : : }
165 : 0 : dma->paddr = (uint64_t) z->iova;
166 : 0 : dma->vaddr = z->addr;
167 : 0 : dma->mzone = (const void *)z;
168 : :
169 : 0 : PMD_DRV_LOG(DEBUG, sc,
170 : : "%s: virt=%p phys=%" PRIx64, msg, dma->vaddr, dma->paddr);
171 : :
172 : 0 : return 0;
173 : : }
174 : :
175 : 0 : void bnx2x_dma_free(struct bnx2x_dma *dma)
176 : : {
177 [ # # ]: 0 : if (dma->mzone == NULL)
178 : : return;
179 : :
180 : 0 : rte_memzone_free((const struct rte_memzone *)dma->mzone);
181 : 0 : dma->sc = NULL;
182 : 0 : dma->paddr = 0;
183 : 0 : dma->vaddr = NULL;
184 : 0 : dma->nseg = 0;
185 : 0 : dma->mzone = NULL;
186 : : }
187 : :
188 : 0 : static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
189 : : {
190 : : uint32_t lock_status;
191 : 0 : uint32_t resource_bit = (1 << resource);
192 : 0 : int func = SC_FUNC(sc);
193 : : uint32_t hw_lock_control_reg;
194 : : int cnt;
195 : :
196 : : #ifndef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
197 [ # # ]: 0 : if (resource)
198 : 0 : PMD_INIT_FUNC_TRACE(sc);
199 : : #else
200 : : PMD_INIT_FUNC_TRACE(sc);
201 : : #endif
202 : :
203 : : /* validate the resource is within range */
204 [ # # ]: 0 : if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
205 : 0 : PMD_DRV_LOG(NOTICE, sc,
206 : : "resource 0x%x > HW_LOCK_MAX_RESOURCE_VALUE",
207 : : resource);
208 : 0 : return -1;
209 : : }
210 : :
211 [ # # ]: 0 : if (func <= 5) {
212 : 0 : hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + (func * 8));
213 : : } else {
214 : 0 : hw_lock_control_reg =
215 : 0 : (MISC_REG_DRIVER_CONTROL_7 + ((func - 6) * 8));
216 : : }
217 : :
218 : : /* validate the resource is not already taken */
219 : 0 : lock_status = REG_RD(sc, hw_lock_control_reg);
220 [ # # ]: 0 : if (lock_status & resource_bit) {
221 : 0 : PMD_DRV_LOG(NOTICE, sc,
222 : : "resource in use (status 0x%x bit 0x%x)",
223 : : lock_status, resource_bit);
224 : 0 : return -1;
225 : : }
226 : :
227 : : /* try every 5ms for 5 seconds */
228 [ # # ]: 0 : for (cnt = 0; cnt < 1000; cnt++) {
229 : 0 : REG_WR(sc, (hw_lock_control_reg + 4), resource_bit);
230 : : lock_status = REG_RD(sc, hw_lock_control_reg);
231 [ # # ]: 0 : if (lock_status & resource_bit) {
232 : : return 0;
233 : : }
234 : 0 : DELAY(5000);
235 : : }
236 : :
237 : 0 : PMD_DRV_LOG(NOTICE, sc, "Resource 0x%x resource_bit 0x%x lock timeout!",
238 : : resource, resource_bit);
239 : 0 : return -1;
240 : : }
241 : :
242 : 0 : static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
243 : : {
244 : : uint32_t lock_status;
245 : 0 : uint32_t resource_bit = (1 << resource);
246 : 0 : int func = SC_FUNC(sc);
247 : : uint32_t hw_lock_control_reg;
248 : :
249 : : #ifndef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
250 [ # # ]: 0 : if (resource)
251 : 0 : PMD_INIT_FUNC_TRACE(sc);
252 : : #else
253 : : PMD_INIT_FUNC_TRACE(sc);
254 : : #endif
255 : :
256 : : /* validate the resource is within range */
257 [ # # ]: 0 : if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
258 : 0 : PMD_DRV_LOG(NOTICE, sc,
259 : : "(resource 0x%x > HW_LOCK_MAX_RESOURCE_VALUE)"
260 : : " resource_bit 0x%x", resource, resource_bit);
261 : 0 : return -1;
262 : : }
263 : :
264 [ # # ]: 0 : if (func <= 5) {
265 : 0 : hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + (func * 8));
266 : : } else {
267 : 0 : hw_lock_control_reg =
268 : 0 : (MISC_REG_DRIVER_CONTROL_7 + ((func - 6) * 8));
269 : : }
270 : :
271 : : /* validate the resource is currently taken */
272 : 0 : lock_status = REG_RD(sc, hw_lock_control_reg);
273 [ # # ]: 0 : if (!(lock_status & resource_bit)) {
274 : 0 : PMD_DRV_LOG(NOTICE, sc,
275 : : "resource not in use (status 0x%x bit 0x%x)",
276 : : lock_status, resource_bit);
277 : 0 : return -1;
278 : : }
279 : :
280 : : REG_WR(sc, hw_lock_control_reg, resource_bit);
281 : 0 : return 0;
282 : : }
283 : :
284 : 0 : static void bnx2x_acquire_phy_lock(struct bnx2x_softc *sc)
285 : : {
286 : 0 : BNX2X_PHY_LOCK(sc);
287 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_MDIO);
288 : 0 : }
289 : :
290 : : static void bnx2x_release_phy_lock(struct bnx2x_softc *sc)
291 : : {
292 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_MDIO);
293 : 0 : BNX2X_PHY_UNLOCK(sc);
294 : 0 : }
295 : :
296 : : /* copy command into DMAE command memory and set DMAE command Go */
297 : 0 : void bnx2x_post_dmae(struct bnx2x_softc *sc, struct dmae_command *dmae, int idx)
298 : : {
299 : : uint32_t cmd_offset;
300 : : uint32_t i;
301 : :
302 : 0 : cmd_offset = (DMAE_REG_CMD_MEM + (sizeof(struct dmae_command) * idx));
303 [ # # ]: 0 : for (i = 0; i < ((sizeof(struct dmae_command) / 4)); i++) {
304 : 0 : REG_WR(sc, (cmd_offset + (i * 4)), *(((uint32_t *) dmae) + i));
305 : : }
306 : :
307 : 0 : REG_WR(sc, dmae_reg_go_c[idx], 1);
308 : 0 : }
309 : :
310 : 0 : uint32_t bnx2x_dmae_opcode_add_comp(uint32_t opcode, uint8_t comp_type)
311 : : {
312 : 0 : return opcode | ((comp_type << DMAE_COMMAND_C_DST_SHIFT) |
313 : : DMAE_COMMAND_C_TYPE_ENABLE);
314 : : }
315 : :
316 : 0 : uint32_t bnx2x_dmae_opcode_clr_src_reset(uint32_t opcode)
317 : : {
318 : 0 : return opcode & ~DMAE_COMMAND_SRC_RESET;
319 : : }
320 : :
321 : : uint32_t
322 : 0 : bnx2x_dmae_opcode(struct bnx2x_softc * sc, uint8_t src_type, uint8_t dst_type,
323 : : uint8_t with_comp, uint8_t comp_type)
324 : : {
325 : : uint32_t opcode = 0;
326 : :
327 : 0 : opcode |= ((src_type << DMAE_COMMAND_SRC_SHIFT) |
328 : 0 : (dst_type << DMAE_COMMAND_DST_SHIFT));
329 : :
330 : 0 : opcode |= (DMAE_COMMAND_SRC_RESET | DMAE_COMMAND_DST_RESET);
331 : :
332 : 0 : opcode |= (SC_PORT(sc) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0);
333 : :
334 : 0 : opcode |= ((SC_VN(sc) << DMAE_COMMAND_E1HVN_SHIFT) |
335 : 0 : (SC_VN(sc) << DMAE_COMMAND_DST_VN_SHIFT));
336 : :
337 : : opcode |= (DMAE_COM_SET_ERR << DMAE_COMMAND_ERR_POLICY_SHIFT);
338 : :
339 : : #ifdef __BIG_ENDIAN
340 : : opcode |= DMAE_CMD_ENDIANITY_B_DW_SWAP;
341 : : #else
342 : 0 : opcode |= DMAE_CMD_ENDIANITY_DW_SWAP;
343 : : #endif
344 : :
345 [ # # ]: 0 : if (with_comp) {
346 : 0 : opcode = bnx2x_dmae_opcode_add_comp(opcode, comp_type);
347 : : }
348 : :
349 : 0 : return opcode;
350 : : }
351 : :
352 : : static void
353 : 0 : bnx2x_prep_dmae_with_comp(struct bnx2x_softc *sc, struct dmae_command *dmae,
354 : : uint8_t src_type, uint8_t dst_type)
355 : : {
356 : : memset(dmae, 0, sizeof(struct dmae_command));
357 : :
358 : : /* set the opcode */
359 : 0 : dmae->opcode = bnx2x_dmae_opcode(sc, src_type, dst_type,
360 : : TRUE, DMAE_COMP_PCI);
361 : :
362 : : /* fill in the completion parameters */
363 : 0 : dmae->comp_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, wb_comp));
364 : 0 : dmae->comp_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, wb_comp));
365 : 0 : dmae->comp_val = DMAE_COMP_VAL;
366 : 0 : }
367 : :
368 : : /* issue a DMAE command over the init channel and wait for completion */
369 : : static int
370 : 0 : bnx2x_issue_dmae_with_comp(struct bnx2x_softc *sc, struct dmae_command *dmae)
371 : : {
372 : 0 : uint32_t *wb_comp = BNX2X_SP(sc, wb_comp);
373 [ # # ]: 0 : int timeout = CHIP_REV_IS_SLOW(sc) ? 400000 : 4000;
374 : :
375 : : /* reset completion */
376 : 0 : *wb_comp = 0;
377 : :
378 : : /* post the command on the channel used for initializations */
379 : 0 : bnx2x_post_dmae(sc, dmae, INIT_DMAE_C(sc));
380 : :
381 : : /* wait for completion */
382 : 0 : DELAY(500);
383 : :
384 [ # # ]: 0 : while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) {
385 [ # # ]: 0 : if (!timeout ||
386 [ # # ]: 0 : (sc->recovery_state != BNX2X_RECOVERY_DONE &&
387 : : sc->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) {
388 : 0 : PMD_DRV_LOG(INFO, sc, "DMAE timeout!");
389 : 0 : return DMAE_TIMEOUT;
390 : : }
391 : :
392 : 0 : timeout--;
393 : 0 : DELAY(50);
394 : : }
395 : :
396 [ # # ]: 0 : if (*wb_comp & DMAE_PCI_ERR_FLAG) {
397 : 0 : PMD_DRV_LOG(INFO, sc, "DMAE PCI error!");
398 : 0 : return DMAE_PCI_ERROR;
399 : : }
400 : :
401 : : return 0;
402 : : }
403 : :
404 : 0 : void bnx2x_read_dmae(struct bnx2x_softc *sc, uint32_t src_addr, uint32_t len32)
405 : : {
406 : : struct dmae_command dmae;
407 : : uint32_t *data;
408 : : uint32_t i;
409 : : int rc;
410 : :
411 [ # # ]: 0 : if (!sc->dmae_ready) {
412 : 0 : data = BNX2X_SP(sc, wb_data[0]);
413 : :
414 [ # # ]: 0 : for (i = 0; i < len32; i++) {
415 : 0 : data[i] = REG_RD(sc, (src_addr + (i * 4)));
416 : : }
417 : :
418 : 0 : return;
419 : : }
420 : :
421 : : /* set opcode and fixed command fields */
422 : 0 : bnx2x_prep_dmae_with_comp(sc, &dmae, DMAE_SRC_GRC, DMAE_DST_PCI);
423 : :
424 : : /* fill in addresses and len */
425 : 0 : dmae.src_addr_lo = (src_addr >> 2); /* GRC addr has dword resolution */
426 : 0 : dmae.src_addr_hi = 0;
427 : 0 : dmae.dst_addr_lo = U64_LO(BNX2X_SP_MAPPING(sc, wb_data));
428 : 0 : dmae.dst_addr_hi = U64_HI(BNX2X_SP_MAPPING(sc, wb_data));
429 : 0 : dmae.len = len32;
430 : :
431 : : /* issue the command and wait for completion */
432 [ # # ]: 0 : if ((rc = bnx2x_issue_dmae_with_comp(sc, &dmae)) != 0) {
433 : 0 : rte_panic("DMAE failed (%d)", rc);
434 : : };
435 : : }
436 : :
437 : : void
438 : 0 : bnx2x_write_dmae(struct bnx2x_softc *sc, rte_iova_t dma_addr, uint32_t dst_addr,
439 : : uint32_t len32)
440 : : {
441 : : struct dmae_command dmae;
442 : : int rc;
443 : :
444 [ # # ]: 0 : if (!sc->dmae_ready) {
445 : 0 : ecore_init_str_wr(sc, dst_addr, BNX2X_SP(sc, wb_data[0]), len32);
446 : 0 : return;
447 : : }
448 : :
449 : : /* set opcode and fixed command fields */
450 : 0 : bnx2x_prep_dmae_with_comp(sc, &dmae, DMAE_SRC_PCI, DMAE_DST_GRC);
451 : :
452 : : /* fill in addresses and len */
453 : 0 : dmae.src_addr_lo = U64_LO(dma_addr);
454 : 0 : dmae.src_addr_hi = U64_HI(dma_addr);
455 : 0 : dmae.dst_addr_lo = (dst_addr >> 2); /* GRC addr has dword resolution */
456 : 0 : dmae.dst_addr_hi = 0;
457 : 0 : dmae.len = len32;
458 : :
459 : : /* issue the command and wait for completion */
460 [ # # ]: 0 : if ((rc = bnx2x_issue_dmae_with_comp(sc, &dmae)) != 0) {
461 : 0 : rte_panic("DMAE failed (%d)", rc);
462 : : }
463 : : }
464 : :
465 : : static void
466 : 0 : bnx2x_write_dmae_phys_len(struct bnx2x_softc *sc, rte_iova_t phys_addr,
467 : : uint32_t addr, uint32_t len)
468 : : {
469 : : uint32_t dmae_wr_max = DMAE_LEN32_WR_MAX(sc);
470 : : uint32_t offset = 0;
471 : :
472 [ # # ]: 0 : while (len > dmae_wr_max) {
473 : 0 : bnx2x_write_dmae(sc, (phys_addr + offset), /* src DMA address */
474 : : (addr + offset), /* dst GRC address */
475 : : dmae_wr_max);
476 : 0 : offset += (dmae_wr_max * 4);
477 : 0 : len -= dmae_wr_max;
478 : : }
479 : :
480 : 0 : bnx2x_write_dmae(sc, (phys_addr + offset), /* src DMA address */
481 : : (addr + offset), /* dst GRC address */
482 : : len);
483 : 0 : }
484 : :
485 : : void
486 : 0 : bnx2x_set_ctx_validation(struct bnx2x_softc *sc, struct eth_context *cxt,
487 : : uint32_t cid)
488 : : {
489 : : /* ustorm cxt validation */
490 : 0 : cxt->ustorm_ag_context.cdu_usage =
491 : 0 : CDU_RSRVD_VALUE_TYPE_A(HW_CID(sc, cid),
492 : : CDU_REGION_NUMBER_UCM_AG,
493 : : ETH_CONNECTION_TYPE);
494 : : /* xcontext validation */
495 : 0 : cxt->xstorm_ag_context.cdu_reserved =
496 : 0 : CDU_RSRVD_VALUE_TYPE_A(HW_CID(sc, cid),
497 : : CDU_REGION_NUMBER_XCM_AG,
498 : : ETH_CONNECTION_TYPE);
499 : 0 : }
500 : :
501 : : static void
502 : : bnx2x_storm_memset_hc_timeout(struct bnx2x_softc *sc, uint8_t fw_sb_id,
503 : : uint8_t sb_index, uint8_t ticks)
504 : : {
505 : 0 : uint32_t addr =
506 : : (BAR_CSTRORM_INTMEM +
507 : 0 : CSTORM_STATUS_BLOCK_DATA_TIMEOUT_OFFSET(fw_sb_id, sb_index));
508 : :
509 : 0 : REG_WR8(sc, addr, ticks);
510 : : }
511 : :
512 : : static void
513 : 0 : bnx2x_storm_memset_hc_disable(struct bnx2x_softc *sc, uint16_t fw_sb_id,
514 : : uint8_t sb_index, uint8_t disable)
515 : : {
516 : : uint32_t enable_flag =
517 [ # # ]: 0 : (disable) ? 0 : (1 << HC_INDEX_DATA_HC_ENABLED_SHIFT);
518 : 0 : uint32_t addr =
519 : : (BAR_CSTRORM_INTMEM +
520 : 0 : CSTORM_STATUS_BLOCK_DATA_FLAGS_OFFSET(fw_sb_id, sb_index));
521 : : uint8_t flags;
522 : :
523 : : /* clear and set */
524 : 0 : flags = REG_RD8(sc, addr);
525 : 0 : flags &= ~HC_INDEX_DATA_HC_ENABLED;
526 : 0 : flags |= enable_flag;
527 : : REG_WR8(sc, addr, flags);
528 : 0 : }
529 : :
530 : : void
531 : 0 : bnx2x_update_coalesce_sb_index(struct bnx2x_softc *sc, uint8_t fw_sb_id,
532 : : uint8_t sb_index, uint8_t disable, uint16_t usec)
533 : : {
534 : 0 : uint8_t ticks = (usec / 4);
535 : :
536 : 0 : bnx2x_storm_memset_hc_timeout(sc, fw_sb_id, sb_index, ticks);
537 : :
538 : 0 : disable = (disable) ? 1 : ((usec) ? 0 : 1);
539 : 0 : bnx2x_storm_memset_hc_disable(sc, fw_sb_id, sb_index, disable);
540 : 0 : }
541 : :
542 : 0 : uint32_t elink_cb_reg_read(struct bnx2x_softc *sc, uint32_t reg_addr)
543 : : {
544 : 0 : return REG_RD(sc, reg_addr);
545 : : }
546 : :
547 : 0 : void elink_cb_reg_write(struct bnx2x_softc *sc, uint32_t reg_addr, uint32_t val)
548 : : {
549 : 0 : REG_WR(sc, reg_addr, val);
550 : 0 : }
551 : :
552 : : void
553 : 0 : elink_cb_event_log(__rte_unused struct bnx2x_softc *sc,
554 : : __rte_unused const elink_log_id_t elink_log_id, ...)
555 : : {
556 : 0 : PMD_DRV_LOG(DEBUG, sc, "ELINK EVENT LOG (%d)", elink_log_id);
557 : 0 : }
558 : :
559 : 0 : static int bnx2x_set_spio(struct bnx2x_softc *sc, int spio, uint32_t mode)
560 : : {
561 : : uint32_t spio_reg;
562 : :
563 : : /* Only 2 SPIOs are configurable */
564 [ # # ]: 0 : if ((spio != MISC_SPIO_SPIO4) && (spio != MISC_SPIO_SPIO5)) {
565 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid SPIO 0x%x", spio);
566 : 0 : return -1;
567 : : }
568 : :
569 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_SPIO);
570 : :
571 : : /* read SPIO and mask except the float bits */
572 : 0 : spio_reg = (REG_RD(sc, MISC_REG_SPIO) & MISC_SPIO_FLOAT);
573 : :
574 [ # # # # ]: 0 : switch (mode) {
575 : 0 : case MISC_SPIO_OUTPUT_LOW:
576 : : /* clear FLOAT and set CLR */
577 : 0 : spio_reg &= ~(spio << MISC_SPIO_FLOAT_POS);
578 : 0 : spio_reg |= (spio << MISC_SPIO_CLR_POS);
579 : 0 : break;
580 : :
581 : 0 : case MISC_SPIO_OUTPUT_HIGH:
582 : : /* clear FLOAT and set SET */
583 : 0 : spio_reg &= ~(spio << MISC_SPIO_FLOAT_POS);
584 : 0 : spio_reg |= (spio << MISC_SPIO_SET_POS);
585 : 0 : break;
586 : :
587 : 0 : case MISC_SPIO_INPUT_HI_Z:
588 : : /* set FLOAT */
589 : 0 : spio_reg |= (spio << MISC_SPIO_FLOAT_POS);
590 : 0 : break;
591 : :
592 : : default:
593 : : break;
594 : : }
595 : :
596 : : REG_WR(sc, MISC_REG_SPIO, spio_reg);
597 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_SPIO);
598 : :
599 : 0 : return 0;
600 : : }
601 : :
602 : 0 : static int bnx2x_gpio_read(struct bnx2x_softc *sc, int gpio_num, uint8_t port)
603 : : {
604 : : /* The GPIO should be swapped if swap register is set and active */
605 [ # # # # ]: 0 : int gpio_port = ((REG_RD(sc, NIG_REG_PORT_SWAP) &&
606 : 0 : REG_RD(sc, NIG_REG_STRAP_OVERRIDE)) ^ port);
607 : : int gpio_shift = gpio_num;
608 [ # # ]: 0 : if (gpio_port)
609 : 0 : gpio_shift += MISC_REGISTERS_GPIO_PORT_SHIFT;
610 : :
611 : 0 : uint32_t gpio_mask = (1 << gpio_shift);
612 : : uint32_t gpio_reg;
613 : :
614 [ # # ]: 0 : if (gpio_num > MISC_REGISTERS_GPIO_3) {
615 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid GPIO %d", gpio_num);
616 : 0 : return -1;
617 : : }
618 : :
619 : : /* read GPIO value */
620 : : gpio_reg = REG_RD(sc, MISC_REG_GPIO);
621 : :
622 : : /* get the requested pin value */
623 : 0 : return ((gpio_reg & gpio_mask) == gpio_mask) ? 1 : 0;
624 : : }
625 : :
626 : : static int
627 : 0 : bnx2x_gpio_write(struct bnx2x_softc *sc, int gpio_num, uint32_t mode, uint8_t port)
628 : : {
629 : : /* The GPIO should be swapped if swap register is set and active */
630 [ # # # # ]: 0 : int gpio_port = ((REG_RD(sc, NIG_REG_PORT_SWAP) &&
631 : 0 : REG_RD(sc, NIG_REG_STRAP_OVERRIDE)) ^ port);
632 : : int gpio_shift = gpio_num;
633 [ # # ]: 0 : if (gpio_port)
634 : 0 : gpio_shift += MISC_REGISTERS_GPIO_PORT_SHIFT;
635 : :
636 : 0 : uint32_t gpio_mask = (1 << gpio_shift);
637 : : uint32_t gpio_reg;
638 : :
639 [ # # ]: 0 : if (gpio_num > MISC_REGISTERS_GPIO_3) {
640 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid GPIO %d", gpio_num);
641 : 0 : return -1;
642 : : }
643 : :
644 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
645 : :
646 : : /* read GPIO and mask except the float bits */
647 : 0 : gpio_reg = (REG_RD(sc, MISC_REG_GPIO) & MISC_REGISTERS_GPIO_FLOAT);
648 : :
649 [ # # # # ]: 0 : switch (mode) {
650 : 0 : case MISC_REGISTERS_GPIO_OUTPUT_LOW:
651 : : /* clear FLOAT and set CLR */
652 : 0 : gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
653 : 0 : gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_CLR_POS);
654 : 0 : break;
655 : :
656 : 0 : case MISC_REGISTERS_GPIO_OUTPUT_HIGH:
657 : : /* clear FLOAT and set SET */
658 : 0 : gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
659 : 0 : gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_SET_POS);
660 : 0 : break;
661 : :
662 : 0 : case MISC_REGISTERS_GPIO_INPUT_HI_Z:
663 : : /* set FLOAT */
664 : 0 : gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
665 : 0 : break;
666 : :
667 : : default:
668 : : break;
669 : : }
670 : :
671 : : REG_WR(sc, MISC_REG_GPIO, gpio_reg);
672 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
673 : :
674 : 0 : return 0;
675 : : }
676 : :
677 : : static int
678 : 0 : bnx2x_gpio_mult_write(struct bnx2x_softc *sc, uint8_t pins, uint32_t mode)
679 : : {
680 : : uint32_t gpio_reg;
681 : :
682 : : /* any port swapping should be handled by caller */
683 : :
684 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
685 : :
686 : : /* read GPIO and mask except the float bits */
687 : : gpio_reg = REG_RD(sc, MISC_REG_GPIO);
688 : 0 : gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_FLOAT_POS);
689 : 0 : gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_CLR_POS);
690 : 0 : gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_SET_POS);
691 : :
692 [ # # # # ]: 0 : switch (mode) {
693 : 0 : case MISC_REGISTERS_GPIO_OUTPUT_LOW:
694 : : /* set CLR */
695 : 0 : gpio_reg |= (pins << MISC_REGISTERS_GPIO_CLR_POS);
696 : 0 : break;
697 : :
698 : 0 : case MISC_REGISTERS_GPIO_OUTPUT_HIGH:
699 : : /* set SET */
700 : 0 : gpio_reg |= (pins << MISC_REGISTERS_GPIO_SET_POS);
701 : 0 : break;
702 : :
703 : 0 : case MISC_REGISTERS_GPIO_INPUT_HI_Z:
704 : : /* set FLOAT */
705 : 0 : gpio_reg |= (pins << MISC_REGISTERS_GPIO_FLOAT_POS);
706 : 0 : break;
707 : :
708 : 0 : default:
709 : 0 : PMD_DRV_LOG(NOTICE, sc,
710 : : "Invalid GPIO mode assignment %d", mode);
711 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
712 : 0 : return -1;
713 : : }
714 : :
715 : : REG_WR(sc, MISC_REG_GPIO, gpio_reg);
716 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
717 : :
718 : 0 : return 0;
719 : : }
720 : :
721 : : static int
722 : 0 : bnx2x_gpio_int_write(struct bnx2x_softc *sc, int gpio_num, uint32_t mode,
723 : : uint8_t port)
724 : : {
725 : : /* The GPIO should be swapped if swap register is set and active */
726 [ # # # # ]: 0 : int gpio_port = ((REG_RD(sc, NIG_REG_PORT_SWAP) &&
727 : 0 : REG_RD(sc, NIG_REG_STRAP_OVERRIDE)) ^ port);
728 : : int gpio_shift = gpio_num;
729 [ # # ]: 0 : if (gpio_port)
730 : 0 : gpio_shift += MISC_REGISTERS_GPIO_PORT_SHIFT;
731 : :
732 : 0 : uint32_t gpio_mask = (1 << gpio_shift);
733 : : uint32_t gpio_reg;
734 : :
735 [ # # ]: 0 : if (gpio_num > MISC_REGISTERS_GPIO_3) {
736 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid GPIO %d", gpio_num);
737 : 0 : return -1;
738 : : }
739 : :
740 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
741 : :
742 : : /* read GPIO int */
743 : : gpio_reg = REG_RD(sc, MISC_REG_GPIO_INT);
744 : :
745 [ # # # ]: 0 : switch (mode) {
746 : 0 : case MISC_REGISTERS_GPIO_INT_OUTPUT_CLR:
747 : : /* clear SET and set CLR */
748 : 0 : gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS);
749 : 0 : gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS);
750 : 0 : break;
751 : :
752 : 0 : case MISC_REGISTERS_GPIO_INT_OUTPUT_SET:
753 : : /* clear CLR and set SET */
754 : 0 : gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS);
755 : 0 : gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS);
756 : 0 : break;
757 : :
758 : : default:
759 : : break;
760 : : }
761 : :
762 : : REG_WR(sc, MISC_REG_GPIO_INT, gpio_reg);
763 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_GPIO);
764 : :
765 : 0 : return 0;
766 : : }
767 : :
768 : : uint32_t
769 : 0 : elink_cb_gpio_read(struct bnx2x_softc * sc, uint16_t gpio_num, uint8_t port)
770 : : {
771 : 0 : return bnx2x_gpio_read(sc, gpio_num, port);
772 : : }
773 : :
774 : 0 : uint8_t elink_cb_gpio_write(struct bnx2x_softc * sc, uint16_t gpio_num, uint8_t mode, /* 0=low 1=high */
775 : : uint8_t port)
776 : : {
777 : 0 : return bnx2x_gpio_write(sc, gpio_num, mode, port);
778 : : }
779 : :
780 : : uint8_t
781 : 0 : elink_cb_gpio_mult_write(struct bnx2x_softc * sc, uint8_t pins,
782 : : uint8_t mode /* 0=low 1=high */ )
783 : : {
784 : 0 : return bnx2x_gpio_mult_write(sc, pins, mode);
785 : : }
786 : :
787 : 0 : uint8_t elink_cb_gpio_int_write(struct bnx2x_softc * sc, uint16_t gpio_num, uint8_t mode, /* 0=low 1=high */
788 : : uint8_t port)
789 : : {
790 : 0 : return bnx2x_gpio_int_write(sc, gpio_num, mode, port);
791 : : }
792 : :
793 : 0 : void elink_cb_notify_link_changed(struct bnx2x_softc *sc)
794 : : {
795 : 0 : REG_WR(sc, (MISC_REG_AEU_GENERAL_ATTN_12 +
796 : : (SC_FUNC(sc) * sizeof(uint32_t))), 1);
797 : 0 : }
798 : :
799 : : /* send the MCP a request, block until there is a reply */
800 : : uint32_t
801 : 0 : elink_cb_fw_command(struct bnx2x_softc *sc, uint32_t command, uint32_t param)
802 : : {
803 [ # # # # ]: 0 : int mb_idx = SC_FW_MB_IDX(sc);
804 : : uint32_t seq;
805 : : uint32_t rc = 0;
806 : : uint32_t cnt = 1;
807 [ # # ]: 0 : uint8_t delay = CHIP_REV_IS_SLOW(sc) ? 100 : 10;
808 : :
809 : 0 : seq = ++sc->fw_seq;
810 : 0 : SHMEM_WR(sc, func_mb[mb_idx].drv_mb_param, param);
811 : 0 : SHMEM_WR(sc, func_mb[mb_idx].drv_mb_header, (command | seq));
812 : :
813 : 0 : PMD_DRV_LOG(DEBUG, sc,
814 : : "wrote command 0x%08x to FW MB param 0x%08x",
815 : : (command | seq), param);
816 : :
817 : : /* Let the FW do it's magic. GIve it up to 5 seconds... */
818 : : do {
819 : 0 : DELAY(delay * 1000);
820 : 0 : rc = SHMEM_RD(sc, func_mb[mb_idx].fw_mb_header);
821 [ # # # # ]: 0 : } while ((seq != (rc & FW_MSG_SEQ_NUMBER_MASK)) && (cnt++ < 500));
822 : :
823 : : /* is this a reply to our command? */
824 [ # # ]: 0 : if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK)) {
825 : 0 : rc &= FW_MSG_CODE_MASK;
826 : : } else {
827 : : /* Ruh-roh! */
828 : 0 : PMD_DRV_LOG(NOTICE, sc, "FW failed to respond!");
829 : : rc = 0;
830 : : }
831 : :
832 : 0 : return rc;
833 : : }
834 : :
835 : : static uint32_t
836 : : bnx2x_fw_command(struct bnx2x_softc *sc, uint32_t command, uint32_t param)
837 : : {
838 : 0 : return elink_cb_fw_command(sc, command, param);
839 : : }
840 : :
841 : : static void
842 : : __storm_memset_dma_mapping(struct bnx2x_softc *sc, uint32_t addr,
843 : : rte_iova_t mapping)
844 : : {
845 : 0 : REG_WR(sc, addr, U64_LO(mapping));
846 : 0 : REG_WR(sc, (addr + 4), U64_HI(mapping));
847 : : }
848 : :
849 : : static void
850 : : storm_memset_spq_addr(struct bnx2x_softc *sc, rte_iova_t mapping,
851 : : uint16_t abs_fid)
852 : : {
853 : 0 : uint32_t addr = (XSEM_REG_FAST_MEMORY +
854 : 0 : XSTORM_SPQ_PAGE_BASE_OFFSET(abs_fid));
855 : : __storm_memset_dma_mapping(sc, addr, mapping);
856 : : }
857 : :
858 : : static void
859 : 0 : storm_memset_vf_to_pf(struct bnx2x_softc *sc, uint16_t abs_fid, uint16_t pf_id)
860 : : {
861 : 0 : REG_WR8(sc, (BAR_XSTRORM_INTMEM + XSTORM_VF_TO_PF_OFFSET(abs_fid)),
862 : : pf_id);
863 : 0 : REG_WR8(sc, (BAR_CSTRORM_INTMEM + CSTORM_VF_TO_PF_OFFSET(abs_fid)),
864 : : pf_id);
865 : 0 : REG_WR8(sc, (BAR_TSTRORM_INTMEM + TSTORM_VF_TO_PF_OFFSET(abs_fid)),
866 : : pf_id);
867 : 0 : REG_WR8(sc, (BAR_USTRORM_INTMEM + USTORM_VF_TO_PF_OFFSET(abs_fid)),
868 : : pf_id);
869 : 0 : }
870 : :
871 : : static void
872 : 0 : storm_memset_func_en(struct bnx2x_softc *sc, uint16_t abs_fid, uint8_t enable)
873 : : {
874 : 0 : REG_WR8(sc, (BAR_XSTRORM_INTMEM + XSTORM_FUNC_EN_OFFSET(abs_fid)),
875 : : enable);
876 : 0 : REG_WR8(sc, (BAR_CSTRORM_INTMEM + CSTORM_FUNC_EN_OFFSET(abs_fid)),
877 : : enable);
878 : 0 : REG_WR8(sc, (BAR_TSTRORM_INTMEM + TSTORM_FUNC_EN_OFFSET(abs_fid)),
879 : : enable);
880 : 0 : REG_WR8(sc, (BAR_USTRORM_INTMEM + USTORM_FUNC_EN_OFFSET(abs_fid)),
881 : : enable);
882 : 0 : }
883 : :
884 : : static void
885 : 0 : storm_memset_eq_data(struct bnx2x_softc *sc, struct event_ring_data *eq_data,
886 : : uint16_t pfid)
887 : : {
888 : : uint32_t addr;
889 : : size_t size;
890 : :
891 : 0 : addr = (BAR_CSTRORM_INTMEM + CSTORM_EVENT_RING_DATA_OFFSET(pfid));
892 : : size = sizeof(struct event_ring_data);
893 : 0 : ecore_storm_memset_struct(sc, addr, size, (uint32_t *) eq_data);
894 : 0 : }
895 : :
896 : : static void
897 : : storm_memset_eq_prod(struct bnx2x_softc *sc, uint16_t eq_prod, uint16_t pfid)
898 : : {
899 : 0 : uint32_t addr = (BAR_CSTRORM_INTMEM +
900 : 0 : CSTORM_EVENT_RING_PROD_OFFSET(pfid));
901 : 0 : REG_WR16(sc, addr, eq_prod);
902 : : }
903 : :
904 : : /*
905 : : * Post a slowpath command.
906 : : *
907 : : * A slowpath command is used to propagate a configuration change through
908 : : * the controller in a controlled manner, allowing each STORM processor and
909 : : * other H/W blocks to phase in the change. The commands sent on the
910 : : * slowpath are referred to as ramrods. Depending on the ramrod used the
911 : : * completion of the ramrod will occur in different ways. Here's a
912 : : * breakdown of ramrods and how they complete:
913 : : *
914 : : * RAMROD_CMD_ID_ETH_PORT_SETUP
915 : : * Used to setup the leading connection on a port. Completes on the
916 : : * Receive Completion Queue (RCQ) of that port (typically fp[0]).
917 : : *
918 : : * RAMROD_CMD_ID_ETH_CLIENT_SETUP
919 : : * Used to setup an additional connection on a port. Completes on the
920 : : * RCQ of the multi-queue/RSS connection being initialized.
921 : : *
922 : : * RAMROD_CMD_ID_ETH_STAT_QUERY
923 : : * Used to force the storm processors to update the statistics database
924 : : * in host memory. This ramrod is send on the leading connection CID and
925 : : * completes as an index increment of the CSTORM on the default status
926 : : * block.
927 : : *
928 : : * RAMROD_CMD_ID_ETH_UPDATE
929 : : * Used to update the state of the leading connection, usually to update
930 : : * the RSS indirection table. Completes on the RCQ of the leading
931 : : * connection. (Not currently used under FreeBSD until OS support becomes
932 : : * available.)
933 : : *
934 : : * RAMROD_CMD_ID_ETH_HALT
935 : : * Used when tearing down a connection prior to driver unload. Completes
936 : : * on the RCQ of the multi-queue/RSS connection being torn down. Don't
937 : : * use this on the leading connection.
938 : : *
939 : : * RAMROD_CMD_ID_ETH_SET_MAC
940 : : * Sets the Unicast/Broadcast/Multicast used by the port. Completes on
941 : : * the RCQ of the leading connection.
942 : : *
943 : : * RAMROD_CMD_ID_ETH_CFC_DEL
944 : : * Used when tearing down a connection prior to driver unload. Completes
945 : : * on the RCQ of the leading connection (since the current connection
946 : : * has been completely removed from controller memory).
947 : : *
948 : : * RAMROD_CMD_ID_ETH_PORT_DEL
949 : : * Used to tear down the leading connection prior to driver unload,
950 : : * typically fp[0]. Completes as an index increment of the CSTORM on the
951 : : * default status block.
952 : : *
953 : : * RAMROD_CMD_ID_ETH_FORWARD_SETUP
954 : : * Used for connection offload. Completes on the RCQ of the multi-queue
955 : : * RSS connection that is being offloaded. (Not currently used under
956 : : * FreeBSD.)
957 : : *
958 : : * There can only be one command pending per function.
959 : : *
960 : : * Returns:
961 : : * 0 = Success, !0 = Failure.
962 : : */
963 : :
964 : : /* must be called under the spq lock */
965 : : static inline struct eth_spe *bnx2x_sp_get_next(struct bnx2x_softc *sc)
966 : : {
967 : 0 : struct eth_spe *next_spe = sc->spq_prod_bd;
968 : :
969 [ # # ]: 0 : if (sc->spq_prod_bd == sc->spq_last_bd) {
970 : : /* wrap back to the first eth_spq */
971 : 0 : sc->spq_prod_bd = sc->spq;
972 : 0 : sc->spq_prod_idx = 0;
973 : : } else {
974 : 0 : sc->spq_prod_bd++;
975 : 0 : sc->spq_prod_idx++;
976 : : }
977 : :
978 : : return next_spe;
979 : : }
980 : :
981 : : /* must be called under the spq lock */
982 : : static void bnx2x_sp_prod_update(struct bnx2x_softc *sc)
983 : : {
984 : 0 : int func = SC_FUNC(sc);
985 : :
986 : : /*
987 : : * Make sure that BD data is updated before writing the producer.
988 : : * BD data is written to the memory, the producer is read from the
989 : : * memory, thus we need a full memory barrier to ensure the ordering.
990 : : */
991 : : mb();
992 : :
993 : 0 : REG_WR16(sc, (BAR_XSTRORM_INTMEM + XSTORM_SPQ_PROD_OFFSET(func)),
994 : : sc->spq_prod_idx);
995 : :
996 : : mb();
997 : : }
998 : :
999 : : /**
1000 : : * bnx2x_is_contextless_ramrod - check if the current command ends on EQ
1001 : : *
1002 : : * @cmd: command to check
1003 : : * @cmd_type: command type
1004 : : */
1005 : : static int bnx2x_is_contextless_ramrod(int cmd, int cmd_type)
1006 : : {
1007 : 0 : if ((cmd_type == NONE_CONNECTION_TYPE) ||
1008 : 0 : (cmd == RAMROD_CMD_ID_ETH_FORWARD_SETUP) ||
1009 [ # # ]: 0 : (cmd == RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES) ||
1010 : : (cmd == RAMROD_CMD_ID_ETH_FILTER_RULES) ||
1011 : 0 : (cmd == RAMROD_CMD_ID_ETH_MULTICAST_RULES) ||
1012 [ # # # # ]: 0 : (cmd == RAMROD_CMD_ID_ETH_SET_MAC) ||
1013 : : (cmd == RAMROD_CMD_ID_ETH_RSS_UPDATE)) {
1014 : : return TRUE;
1015 : : } else {
1016 : : return FALSE;
1017 : : }
1018 : : }
1019 : :
1020 : : /**
1021 : : * bnx2x_sp_post - place a single command on an SP ring
1022 : : *
1023 : : * @sc: driver handle
1024 : : * @command: command to place (e.g. SETUP, FILTER_RULES, etc.)
1025 : : * @cid: SW CID the command is related to
1026 : : * @data_hi: command private data address (high 32 bits)
1027 : : * @data_lo: command private data address (low 32 bits)
1028 : : * @cmd_type: command type (e.g. NONE, ETH)
1029 : : *
1030 : : * SP data is handled as if it's always an address pair, thus data fields are
1031 : : * not swapped to little endian in upper functions. Instead this function swaps
1032 : : * data as if it's two uint32 fields.
1033 : : */
1034 : : int
1035 [ # # ]: 0 : bnx2x_sp_post(struct bnx2x_softc *sc, int command, int cid, uint32_t data_hi,
1036 : : uint32_t data_lo, int cmd_type)
1037 : : {
1038 : : struct eth_spe *spe;
1039 : : uint16_t type;
1040 : : int common;
1041 : :
1042 : : common = bnx2x_is_contextless_ramrod(command, cmd_type);
1043 : :
1044 : : if (common) {
1045 [ # # ]: 0 : if (!atomic_load_acq_long(&sc->eq_spq_left)) {
1046 : 0 : PMD_DRV_LOG(INFO, sc, "EQ ring is full!");
1047 : 0 : return -1;
1048 : : }
1049 : : } else {
1050 [ # # ]: 0 : if (!atomic_load_acq_long(&sc->cq_spq_left)) {
1051 : 0 : PMD_DRV_LOG(INFO, sc, "SPQ ring is full!");
1052 : 0 : return -1;
1053 : : }
1054 : : }
1055 : :
1056 : : spe = bnx2x_sp_get_next(sc);
1057 : :
1058 : : /* CID needs port number to be encoded int it */
1059 : 0 : spe->hdr.conn_and_cmd_data =
1060 : 0 : htole32((command << SPE_HDR_CMD_ID_SHIFT) | HW_CID(sc, cid));
1061 : :
1062 : 0 : type = (cmd_type << SPE_HDR_CONN_TYPE_SHIFT) & SPE_HDR_CONN_TYPE;
1063 : :
1064 : : /* TBD: Check if it works for VFs */
1065 : 0 : type |= ((SC_FUNC(sc) << SPE_HDR_FUNCTION_ID_SHIFT) &
1066 : : SPE_HDR_FUNCTION_ID);
1067 : :
1068 : 0 : spe->hdr.type = htole16(type);
1069 : :
1070 : 0 : spe->data.update_data_addr.hi = htole32(data_hi);
1071 : 0 : spe->data.update_data_addr.lo = htole32(data_lo);
1072 : :
1073 : : /*
1074 : : * It's ok if the actual decrement is issued towards the memory
1075 : : * somewhere between the lock and unlock. Thus no more explicit
1076 : : * memory barrier is needed.
1077 : : */
1078 [ # # ]: 0 : if (common) {
1079 : 0 : atomic_subtract_acq_long(&sc->eq_spq_left, 1);
1080 : : } else {
1081 : 0 : atomic_subtract_acq_long(&sc->cq_spq_left, 1);
1082 : : }
1083 : :
1084 : 0 : PMD_DRV_LOG(DEBUG, sc,
1085 : : "SPQE[%x] (%x:%x) (cmd, common?) (%d,%d) hw_cid %x"
1086 : : "data (%x:%x) type(0x%x) left (CQ, EQ) (%lx,%lx)",
1087 : : sc->spq_prod_idx,
1088 : : (uint32_t) U64_HI(sc->spq_dma.paddr),
1089 : : (uint32_t) (U64_LO(sc->spq_dma.paddr) +
1090 : : (uint8_t *) sc->spq_prod_bd -
1091 : : (uint8_t *) sc->spq), command, common,
1092 : : HW_CID(sc, cid), data_hi, data_lo, type,
1093 : : atomic_load_acq_long(&sc->cq_spq_left),
1094 : : atomic_load_acq_long(&sc->eq_spq_left));
1095 : :
1096 : : /* RAMROD completion is processed in bnx2x_intr_legacy()
1097 : : * which can run from different contexts.
1098 : : * Ask bnx2x_intr_intr() to process RAMROD
1099 : : * completion whenever it gets scheduled.
1100 : : */
1101 : : rte_atomic32_set(&sc->scan_fp, 1);
1102 : : bnx2x_sp_prod_update(sc);
1103 : :
1104 : 0 : return 0;
1105 : : }
1106 : :
1107 : 0 : static void bnx2x_drv_pulse(struct bnx2x_softc *sc)
1108 : : {
1109 [ # # # # ]: 0 : SHMEM_WR(sc, func_mb[SC_FW_MB_IDX(sc)].drv_pulse_mb,
1110 : : sc->fw_drv_pulse_wr_seq);
1111 : 0 : }
1112 : :
1113 : : static int bnx2x_tx_queue_has_work(const struct bnx2x_fastpath *fp)
1114 : : {
1115 : : uint16_t hw_cons;
1116 : 0 : struct bnx2x_tx_queue *txq = fp->sc->tx_queues[fp->index];
1117 : :
1118 [ # # ]: 0 : if (unlikely(!txq)) {
1119 : : PMD_TX_LOG(ERR, "ERROR: TX queue is NULL");
1120 : : return 0;
1121 : : }
1122 : :
1123 : : mb(); /* status block fields can change */
1124 : 0 : hw_cons = le16toh(*fp->tx_cons_sb);
1125 : 0 : return hw_cons != txq->tx_pkt_head;
1126 : : }
1127 : :
1128 : : static uint8_t bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
1129 : : {
1130 : : /* expand this for multi-cos if ever supported */
1131 : 0 : return bnx2x_tx_queue_has_work(fp);
1132 : : }
1133 : :
1134 : 0 : static int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
1135 : : {
1136 : : uint16_t rx_cq_cons_sb;
1137 : : struct bnx2x_rx_queue *rxq;
1138 : 0 : rxq = fp->sc->rx_queues[fp->index];
1139 [ # # ]: 0 : if (unlikely(!rxq)) {
1140 : : PMD_RX_LOG(ERR, "ERROR: RX queue is NULL");
1141 : : return 0;
1142 : : }
1143 : :
1144 : : mb(); /* status block fields can change */
1145 : 0 : rx_cq_cons_sb = le16toh(*fp->rx_cq_cons_sb);
1146 [ # # ]: 0 : if (unlikely((rx_cq_cons_sb & MAX_RCQ_ENTRIES(rxq)) ==
1147 : : MAX_RCQ_ENTRIES(rxq)))
1148 : 0 : rx_cq_cons_sb++;
1149 : :
1150 : : PMD_RX_LOG(DEBUG, "hw CQ cons = %d, sw CQ cons = %d",
1151 : : rx_cq_cons_sb, rxq->rx_cq_head);
1152 : :
1153 : 0 : return rxq->rx_cq_head != rx_cq_cons_sb;
1154 : : }
1155 : :
1156 : : static void
1157 : 0 : bnx2x_sp_event(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
1158 : : union eth_rx_cqe *rr_cqe)
1159 : : {
1160 : 0 : int cid = SW_CID(rr_cqe->ramrod_cqe.conn_and_cmd_data);
1161 : 0 : int command = CQE_CMD(rr_cqe->ramrod_cqe.conn_and_cmd_data);
1162 : : enum ecore_queue_cmd drv_cmd = ECORE_Q_CMD_MAX;
1163 : 0 : struct ecore_queue_sp_obj *q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
1164 : :
1165 : 0 : PMD_DRV_LOG(DEBUG, sc,
1166 : : "fp=%d cid=%d got ramrod #%d state is %x type is %d",
1167 : : fp->index, cid, command, sc->state,
1168 : : rr_cqe->ramrod_cqe.ramrod_type);
1169 : :
1170 [ # # # # : 0 : switch (command) {
# # # ]
1171 : : case (RAMROD_CMD_ID_ETH_CLIENT_UPDATE):
1172 : 0 : PMD_DRV_LOG(DEBUG, sc, "got UPDATE ramrod. CID %d", cid);
1173 : : drv_cmd = ECORE_Q_CMD_UPDATE;
1174 : : break;
1175 : :
1176 : : case (RAMROD_CMD_ID_ETH_CLIENT_SETUP):
1177 : 0 : PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] setup ramrod", cid);
1178 : : drv_cmd = ECORE_Q_CMD_SETUP;
1179 : : break;
1180 : :
1181 : : case (RAMROD_CMD_ID_ETH_TX_QUEUE_SETUP):
1182 : 0 : PMD_DRV_LOG(DEBUG, sc,
1183 : : "got MULTI[%d] tx-only setup ramrod", cid);
1184 : : drv_cmd = ECORE_Q_CMD_SETUP_TX_ONLY;
1185 : : break;
1186 : :
1187 : : case (RAMROD_CMD_ID_ETH_HALT):
1188 : 0 : PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] halt ramrod", cid);
1189 : : drv_cmd = ECORE_Q_CMD_HALT;
1190 : : break;
1191 : :
1192 : : case (RAMROD_CMD_ID_ETH_TERMINATE):
1193 : 0 : PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] terminate ramrod", cid);
1194 : : drv_cmd = ECORE_Q_CMD_TERMINATE;
1195 : : break;
1196 : :
1197 : : case (RAMROD_CMD_ID_ETH_EMPTY):
1198 : 0 : PMD_DRV_LOG(DEBUG, sc, "got MULTI[%d] empty ramrod", cid);
1199 : : drv_cmd = ECORE_Q_CMD_EMPTY;
1200 : : break;
1201 : :
1202 : 0 : default:
1203 : 0 : PMD_DRV_LOG(DEBUG, sc,
1204 : : "ERROR: unexpected MC reply (%d)"
1205 : : "on fp[%d]", command, fp->index);
1206 : 0 : return;
1207 : : }
1208 : :
1209 [ # # ]: 0 : if ((drv_cmd != ECORE_Q_CMD_MAX) &&
1210 : 0 : q_obj->complete_cmd(sc, q_obj, drv_cmd)) {
1211 : : /*
1212 : : * q_obj->complete_cmd() failure means that this was
1213 : : * an unexpected completion.
1214 : : *
1215 : : * In this case we don't want to increase the sc->spq_left
1216 : : * because apparently we haven't sent this command the first
1217 : : * place.
1218 : : */
1219 : : // rte_panic("Unexpected SP completion");
1220 : : return;
1221 : : }
1222 : :
1223 : 0 : atomic_add_acq_long(&sc->cq_spq_left, 1);
1224 : :
1225 : 0 : PMD_DRV_LOG(DEBUG, sc, "sc->cq_spq_left 0x%lx",
1226 : : atomic_load_acq_long(&sc->cq_spq_left));
1227 : : }
1228 : :
1229 : 0 : static uint8_t bnx2x_rxeof(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp)
1230 : : {
1231 : : struct bnx2x_rx_queue *rxq;
1232 : : uint16_t bd_cons, bd_prod, bd_prod_fw, comp_ring_cons;
1233 : : uint16_t hw_cq_cons, sw_cq_cons, sw_cq_prod;
1234 : :
1235 : 0 : rte_spinlock_lock(&(fp)->rx_mtx);
1236 : :
1237 : 0 : rxq = sc->rx_queues[fp->index];
1238 [ # # ]: 0 : if (!rxq) {
1239 : : PMD_RX_LOG(ERR, "RX queue %d is NULL", fp->index);
1240 : : rte_spinlock_unlock(&(fp)->rx_mtx);
1241 : 0 : return 0;
1242 : : }
1243 : :
1244 : : /* CQ "next element" is of the size of the regular element */
1245 : 0 : hw_cq_cons = le16toh(*fp->rx_cq_cons_sb);
1246 [ # # ]: 0 : if (unlikely((hw_cq_cons & USABLE_RCQ_ENTRIES_PER_PAGE) ==
1247 : : USABLE_RCQ_ENTRIES_PER_PAGE)) {
1248 : 0 : hw_cq_cons++;
1249 : : }
1250 : :
1251 : 0 : bd_cons = rxq->rx_bd_head;
1252 : 0 : bd_prod = rxq->rx_bd_tail;
1253 : : bd_prod_fw = bd_prod;
1254 : 0 : sw_cq_cons = rxq->rx_cq_head;
1255 : 0 : sw_cq_prod = rxq->rx_cq_tail;
1256 : :
1257 : : /*
1258 : : * Memory barrier necessary as speculative reads of the rx
1259 : : * buffer can be ahead of the index in the status block
1260 : : */
1261 : : rmb();
1262 : :
1263 [ # # ]: 0 : while (sw_cq_cons != hw_cq_cons) {
1264 : : union eth_rx_cqe *cqe;
1265 : : struct eth_fast_path_rx_cqe *cqe_fp;
1266 : : uint8_t cqe_fp_flags;
1267 : : enum eth_rx_cqe_type cqe_fp_type;
1268 : :
1269 : 0 : comp_ring_cons = RCQ_ENTRY(sw_cq_cons, rxq);
1270 : 0 : bd_prod = RX_BD(bd_prod, rxq);
1271 : 0 : bd_cons = RX_BD(bd_cons, rxq);
1272 : :
1273 : 0 : cqe = &rxq->cq_ring[comp_ring_cons];
1274 : : cqe_fp = &cqe->fast_path_cqe;
1275 : 0 : cqe_fp_flags = cqe_fp->type_error_flags;
1276 : : cqe_fp_type = cqe_fp_flags & ETH_FAST_PATH_RX_CQE_TYPE;
1277 : :
1278 : : /* is this a slowpath msg? */
1279 [ # # ]: 0 : if (CQE_TYPE_SLOW(cqe_fp_type)) {
1280 : 0 : bnx2x_sp_event(sc, fp, cqe);
1281 : 0 : goto next_cqe;
1282 : : }
1283 : :
1284 : : /* is this an error packet? */
1285 : : if (unlikely(cqe_fp_flags &
1286 : : ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG)) {
1287 : : PMD_RX_LOG(DEBUG, "flags 0x%x rx packet %u",
1288 : : cqe_fp_flags, sw_cq_cons);
1289 : : goto next_rx;
1290 : : }
1291 : :
1292 : : PMD_RX_LOG(DEBUG, "Dropping fastpath called from attn poller!");
1293 : :
1294 : 0 : next_rx:
1295 [ # # ]: 0 : bd_cons = NEXT_RX_BD(bd_cons);
1296 : : bd_prod = NEXT_RX_BD(bd_prod);
1297 [ # # ]: 0 : bd_prod_fw = NEXT_RX_BD(bd_prod_fw);
1298 : :
1299 : 0 : next_cqe:
1300 [ # # ]: 0 : sw_cq_prod = NEXT_RCQ_IDX(sw_cq_prod);
1301 [ # # ]: 0 : sw_cq_cons = NEXT_RCQ_IDX(sw_cq_cons);
1302 : :
1303 : : } /* while work to do */
1304 : :
1305 : 0 : rxq->rx_bd_head = bd_cons;
1306 : 0 : rxq->rx_bd_tail = bd_prod_fw;
1307 : 0 : rxq->rx_cq_head = sw_cq_cons;
1308 : 0 : rxq->rx_cq_tail = sw_cq_prod;
1309 : :
1310 : : PMD_RX_LOG(DEBUG, "BD prod = %d, sw CQ prod = %d",
1311 : : bd_prod_fw, sw_cq_prod);
1312 : :
1313 : : /* Update producers */
1314 : 0 : bnx2x_update_rx_prod(sc, fp, bd_prod_fw, sw_cq_prod);
1315 : :
1316 : : rte_spinlock_unlock(&(fp)->rx_mtx);
1317 : :
1318 : 0 : return sw_cq_cons != hw_cq_cons;
1319 : : }
1320 : :
1321 : : static uint16_t
1322 : 0 : bnx2x_free_tx_pkt(__rte_unused struct bnx2x_fastpath *fp, struct bnx2x_tx_queue *txq,
1323 : : uint16_t pkt_idx, uint16_t bd_idx)
1324 : : {
1325 : : struct eth_tx_start_bd *tx_start_bd =
1326 : 0 : &txq->tx_ring[TX_BD(bd_idx, txq)].start_bd;
1327 : 0 : uint16_t nbd = rte_le_to_cpu_16(tx_start_bd->nbd);
1328 : 0 : struct rte_mbuf *tx_mbuf = txq->sw_ring[TX_BD(pkt_idx, txq)];
1329 : :
1330 [ # # ]: 0 : if (likely(tx_mbuf != NULL)) {
1331 : : rte_pktmbuf_free_seg(tx_mbuf);
1332 : : } else {
1333 : : PMD_RX_LOG(ERR, "fp[%02d] lost mbuf %lu",
1334 : : fp->index, (unsigned long)TX_BD(pkt_idx, txq));
1335 : : }
1336 : :
1337 : 0 : txq->sw_ring[TX_BD(pkt_idx, txq)] = NULL;
1338 : 0 : txq->nb_tx_avail += nbd;
1339 : :
1340 [ # # ]: 0 : while (nbd--)
1341 [ # # ]: 0 : bd_idx = NEXT_TX_BD(bd_idx);
1342 : :
1343 : 0 : return bd_idx;
1344 : : }
1345 : :
1346 : : /* processes transmit completions */
1347 : 0 : uint8_t bnx2x_txeof(__rte_unused struct bnx2x_softc * sc, struct bnx2x_fastpath * fp)
1348 : : {
1349 : : uint16_t bd_cons, hw_cons, sw_cons;
1350 : : __rte_unused uint16_t tx_bd_avail;
1351 : :
1352 : 0 : struct bnx2x_tx_queue *txq = fp->sc->tx_queues[fp->index];
1353 : :
1354 [ # # ]: 0 : if (unlikely(!txq)) {
1355 : : PMD_TX_LOG(ERR, "ERROR: TX queue is NULL");
1356 : : return 0;
1357 : : }
1358 : :
1359 : 0 : bd_cons = txq->tx_bd_head;
1360 : 0 : hw_cons = rte_le_to_cpu_16(*fp->tx_cons_sb);
1361 : 0 : sw_cons = txq->tx_pkt_head;
1362 : :
1363 [ # # ]: 0 : while (sw_cons != hw_cons) {
1364 : 0 : bd_cons = bnx2x_free_tx_pkt(fp, txq, sw_cons, bd_cons);
1365 : 0 : sw_cons++;
1366 : : }
1367 : :
1368 : 0 : txq->tx_pkt_head = sw_cons;
1369 : 0 : txq->tx_bd_head = bd_cons;
1370 : :
1371 : : tx_bd_avail = txq->nb_tx_avail;
1372 : :
1373 : : PMD_TX_LOG(DEBUG, "fp[%02d] avail=%u cons_sb=%u, "
1374 : : "pkt_head=%u pkt_tail=%u bd_head=%u bd_tail=%u",
1375 : : fp->index, tx_bd_avail, hw_cons,
1376 : : txq->tx_pkt_head, txq->tx_pkt_tail,
1377 : : txq->tx_bd_head, txq->tx_bd_tail);
1378 : 0 : return TRUE;
1379 : : }
1380 : :
1381 : 0 : static void bnx2x_drain_tx_queues(struct bnx2x_softc *sc)
1382 : : {
1383 : : struct bnx2x_fastpath *fp;
1384 : : int i, count;
1385 : :
1386 : : /* wait until all TX fastpath tasks have completed */
1387 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
1388 : 0 : fp = &sc->fp[i];
1389 : :
1390 : : count = 1000;
1391 : :
1392 [ # # ]: 0 : while (bnx2x_has_tx_work(fp)) {
1393 : 0 : bnx2x_txeof(sc, fp);
1394 : :
1395 [ # # ]: 0 : if (count == 0) {
1396 : : PMD_TX_LOG(ERR,
1397 : : "Timeout waiting for fp[%d] "
1398 : : "transmits to complete!", i);
1399 : 0 : rte_panic("tx drain failure");
1400 : : return;
1401 : : }
1402 : :
1403 : 0 : count--;
1404 : 0 : DELAY(1000);
1405 : : rmb();
1406 : : }
1407 : : }
1408 : :
1409 : : return;
1410 : : }
1411 : :
1412 : : static int
1413 : 0 : bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
1414 : : int mac_type, uint8_t wait_for_comp)
1415 : : {
1416 : 0 : uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
1417 : : int rc;
1418 : :
1419 : : /* wait for completion of requested */
1420 [ # # ]: 0 : if (wait_for_comp) {
1421 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
1422 : : }
1423 : :
1424 : : /* Set the mac type of addresses we want to clear */
1425 : 0 : rte_bit_relaxed_set32(mac_type, &vlan_mac_flags);
1426 : :
1427 : 0 : rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
1428 [ # # ]: 0 : if (rc < 0)
1429 : 0 : PMD_DRV_LOG(ERR, sc, "Failed to delete MACs (%d)", rc);
1430 : :
1431 : 0 : return rc;
1432 : : }
1433 : :
1434 : : static int
1435 : 0 : bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
1436 : : uint32_t *rx_accept_flags, uint32_t *tx_accept_flags)
1437 : : {
1438 : : /* Clear the flags first */
1439 : 0 : *rx_accept_flags = 0;
1440 : 0 : *tx_accept_flags = 0;
1441 : :
1442 [ # # # # : 0 : switch (rx_mode) {
# ]
1443 : : case BNX2X_RX_MODE_NONE:
1444 : : /*
1445 : : * 'drop all' supersedes any accept flags that may have been
1446 : : * passed to the function.
1447 : : */
1448 : : break;
1449 : :
1450 : : case BNX2X_RX_MODE_NORMAL:
1451 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
1452 : : rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, rx_accept_flags);
1453 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
1454 : :
1455 : : /* internal switching mode */
1456 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
1457 : : rte_bit_relaxed_set32(ECORE_ACCEPT_MULTICAST, tx_accept_flags);
1458 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
1459 : :
1460 : : break;
1461 : :
1462 : : case BNX2X_RX_MODE_ALLMULTI:
1463 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
1464 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
1465 : : rx_accept_flags);
1466 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
1467 : :
1468 : : /* internal switching mode */
1469 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, tx_accept_flags);
1470 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
1471 : : tx_accept_flags);
1472 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
1473 : :
1474 : : break;
1475 : :
1476 : : case BNX2X_RX_MODE_ALLMULTI_PROMISC:
1477 : : case BNX2X_RX_MODE_PROMISC:
1478 : : /*
1479 : : * According to definition of SI mode, iface in promisc mode
1480 : : * should receive matched and unmatched (in resolution of port)
1481 : : * unicast packets.
1482 : : */
1483 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNMATCHED, rx_accept_flags);
1484 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST, rx_accept_flags);
1485 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
1486 : : rx_accept_flags);
1487 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, rx_accept_flags);
1488 : :
1489 : : /* internal switching mode */
1490 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_MULTICAST,
1491 : : tx_accept_flags);
1492 : : rte_bit_relaxed_set32(ECORE_ACCEPT_BROADCAST, tx_accept_flags);
1493 : :
1494 [ # # # # ]: 0 : if (IS_MF_SI(sc)) {
1495 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ALL_UNICAST,
1496 : : tx_accept_flags);
1497 : : } else {
1498 : : rte_bit_relaxed_set32(ECORE_ACCEPT_UNICAST,
1499 : : tx_accept_flags);
1500 : : }
1501 : :
1502 : : break;
1503 : :
1504 : : default:
1505 : : PMD_RX_LOG(ERR, "Unknown rx_mode (%d)", rx_mode);
1506 : : return -1;
1507 : : }
1508 : :
1509 : : /* Set ACCEPT_ANY_VLAN as we do not enable filtering by VLAN */
1510 [ # # ]: 0 : if (rx_mode != BNX2X_RX_MODE_NONE) {
1511 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, rx_accept_flags);
1512 : : rte_bit_relaxed_set32(ECORE_ACCEPT_ANY_VLAN, tx_accept_flags);
1513 : : }
1514 : :
1515 : : return 0;
1516 : : }
1517 : :
1518 : : static int
1519 : 0 : bnx2x_set_q_rx_mode(struct bnx2x_softc *sc, uint8_t cl_id,
1520 : : unsigned long rx_mode_flags,
1521 : : unsigned long rx_accept_flags,
1522 : : unsigned long tx_accept_flags, unsigned long ramrod_flags)
1523 : : {
1524 : : struct ecore_rx_mode_ramrod_params ramrod_param;
1525 : : int rc;
1526 : :
1527 : : memset(&ramrod_param, 0, sizeof(ramrod_param));
1528 : :
1529 : : /* Prepare ramrod parameters */
1530 : : ramrod_param.cid = 0;
1531 : 0 : ramrod_param.cl_id = cl_id;
1532 : 0 : ramrod_param.rx_mode_obj = &sc->rx_mode_obj;
1533 : 0 : ramrod_param.func_id = SC_FUNC(sc);
1534 : :
1535 : 0 : ramrod_param.pstate = &sc->sp_state;
1536 : 0 : ramrod_param.state = ECORE_FILTER_RX_MODE_PENDING;
1537 : :
1538 : 0 : ramrod_param.rdata = BNX2X_SP(sc, rx_mode_rdata);
1539 : 0 : ramrod_param.rdata_mapping =
1540 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, rx_mode_rdata),
1541 : : rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
1542 : :
1543 : 0 : ramrod_param.ramrod_flags = ramrod_flags;
1544 : 0 : ramrod_param.rx_mode_flags = rx_mode_flags;
1545 : :
1546 : 0 : ramrod_param.rx_accept_flags = rx_accept_flags;
1547 : 0 : ramrod_param.tx_accept_flags = tx_accept_flags;
1548 : :
1549 : 0 : rc = ecore_config_rx_mode(sc, &ramrod_param);
1550 : : if (rc < 0) {
1551 : : PMD_RX_LOG(ERR, "Set rx_mode %d failed", sc->rx_mode);
1552 : : return rc;
1553 : : }
1554 : :
1555 : : return 0;
1556 : : }
1557 : :
1558 : 0 : int bnx2x_set_storm_rx_mode(struct bnx2x_softc *sc)
1559 : : {
1560 : 0 : uint32_t rx_mode_flags = 0, ramrod_flags = 0;
1561 : 0 : uint32_t rx_accept_flags = 0, tx_accept_flags = 0;
1562 : : int rc;
1563 : :
1564 : 0 : rc = bnx2x_fill_accept_flags(sc, sc->rx_mode, &rx_accept_flags,
1565 : : &tx_accept_flags);
1566 [ # # ]: 0 : if (rc) {
1567 : : return rc;
1568 : : }
1569 : :
1570 : : rte_bit_relaxed_set32(RAMROD_RX, &ramrod_flags);
1571 : : rte_bit_relaxed_set32(RAMROD_TX, &ramrod_flags);
1572 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
1573 : :
1574 : 0 : return bnx2x_set_q_rx_mode(sc, sc->fp[0].cl_id, rx_mode_flags,
1575 : : rx_accept_flags, tx_accept_flags,
1576 : : ramrod_flags);
1577 : : }
1578 : :
1579 : : /* returns the "mcp load_code" according to global load_count array */
1580 : 0 : static int bnx2x_nic_load_no_mcp(struct bnx2x_softc *sc)
1581 : : {
1582 : 0 : int path = SC_PATH(sc);
1583 : 0 : int port = SC_PORT(sc);
1584 : :
1585 : 0 : PMD_DRV_LOG(INFO, sc, "NO MCP - load counts[%d] %d, %d, %d",
1586 : : path, load_count[path][0], load_count[path][1],
1587 : : load_count[path][2]);
1588 : :
1589 : 0 : load_count[path][0]++;
1590 : 0 : load_count[path][1 + port]++;
1591 : 0 : PMD_DRV_LOG(INFO, sc, "NO MCP - new load counts[%d] %d, %d, %d",
1592 : : path, load_count[path][0], load_count[path][1],
1593 : : load_count[path][2]);
1594 [ # # ]: 0 : if (load_count[path][0] == 1)
1595 : : return FW_MSG_CODE_DRV_LOAD_COMMON;
1596 [ # # ]: 0 : else if (load_count[path][1 + port] == 1)
1597 : : return FW_MSG_CODE_DRV_LOAD_PORT;
1598 : : else
1599 : 0 : return FW_MSG_CODE_DRV_LOAD_FUNCTION;
1600 : : }
1601 : :
1602 : : /* returns the "mcp load_code" according to global load_count array */
1603 : 0 : static int bnx2x_nic_unload_no_mcp(struct bnx2x_softc *sc)
1604 : : {
1605 : 0 : int port = SC_PORT(sc);
1606 : 0 : int path = SC_PATH(sc);
1607 : :
1608 : 0 : PMD_DRV_LOG(INFO, sc, "NO MCP - load counts[%d] %d, %d, %d",
1609 : : path, load_count[path][0], load_count[path][1],
1610 : : load_count[path][2]);
1611 : 0 : load_count[path][0]--;
1612 : 0 : load_count[path][1 + port]--;
1613 : 0 : PMD_DRV_LOG(INFO, sc, "NO MCP - new load counts[%d] %d, %d, %d",
1614 : : path, load_count[path][0], load_count[path][1],
1615 : : load_count[path][2]);
1616 [ # # ]: 0 : if (load_count[path][0] == 0) {
1617 : : return FW_MSG_CODE_DRV_UNLOAD_COMMON;
1618 [ # # ]: 0 : } else if (load_count[path][1 + port] == 0) {
1619 : : return FW_MSG_CODE_DRV_UNLOAD_PORT;
1620 : : } else {
1621 : 0 : return FW_MSG_CODE_DRV_UNLOAD_FUNCTION;
1622 : : }
1623 : : }
1624 : :
1625 : : /* request unload mode from the MCP: COMMON, PORT or FUNCTION */
1626 : 0 : static uint32_t bnx2x_send_unload_req(struct bnx2x_softc *sc, int unload_mode)
1627 : : {
1628 : : uint32_t reset_code = 0;
1629 : :
1630 : : /* Select the UNLOAD request mode */
1631 : : if (unload_mode == UNLOAD_NORMAL) {
1632 : : reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS;
1633 : : } else {
1634 : : reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS;
1635 : : }
1636 : :
1637 : : /* Send the request to the MCP */
1638 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
1639 : : reset_code = bnx2x_fw_command(sc, reset_code, 0);
1640 : : } else {
1641 : 0 : reset_code = bnx2x_nic_unload_no_mcp(sc);
1642 : : }
1643 : :
1644 : 0 : return reset_code;
1645 : : }
1646 : :
1647 : : /* send UNLOAD_DONE command to the MCP */
1648 : : static void bnx2x_send_unload_done(struct bnx2x_softc *sc, uint8_t keep_link)
1649 : : {
1650 : : uint32_t reset_param =
1651 [ # # ]: 0 : keep_link ? DRV_MSG_CODE_UNLOAD_SKIP_LINK_RESET : 0;
1652 : :
1653 : : /* Report UNLOAD_DONE to MCP */
1654 [ # # # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
1655 : : bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_DONE, reset_param);
1656 : : }
1657 : : }
1658 : :
1659 : 0 : static int bnx2x_func_wait_started(struct bnx2x_softc *sc)
1660 : : {
1661 : : int tout = 50;
1662 : :
1663 [ # # ]: 0 : if (!sc->port.pmf) {
1664 : : return 0;
1665 : : }
1666 : :
1667 : : /*
1668 : : * (assumption: No Attention from MCP at this stage)
1669 : : * PMF probably in the middle of TX disable/enable transaction
1670 : : * 1. Sync IRS for default SB
1671 : : * 2. Sync SP queue - this guarantees us that attention handling started
1672 : : * 3. Wait, that TX disable/enable transaction completes
1673 : : *
1674 : : * 1+2 guarantee that if DCBX attention was scheduled it already changed
1675 : : * pending bit of transaction from STARTED-->TX_STOPPED, if we already
1676 : : * received completion for the transaction the state is TX_STOPPED.
1677 : : * State will return to STARTED after completion of TX_STOPPED-->STARTED
1678 : : * transaction.
1679 : : */
1680 : :
1681 : 0 : while (ecore_func_get_state(sc, &sc->func_obj) !=
1682 [ # # # # ]: 0 : ECORE_F_STATE_STARTED && tout--) {
1683 : 0 : DELAY(20000);
1684 : : }
1685 : :
1686 [ # # ]: 0 : if (ecore_func_get_state(sc, &sc->func_obj) != ECORE_F_STATE_STARTED) {
1687 : : /*
1688 : : * Failed to complete the transaction in a "good way"
1689 : : * Force both transactions with CLR bit.
1690 : : */
1691 : 0 : struct ecore_func_state_params func_params = { NULL };
1692 : :
1693 : 0 : PMD_DRV_LOG(NOTICE, sc, "Unexpected function state! "
1694 : : "Forcing STARTED-->TX_STOPPED-->STARTED");
1695 : :
1696 : 0 : func_params.f_obj = &sc->func_obj;
1697 : : rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
1698 : : &func_params.ramrod_flags);
1699 : :
1700 : : /* STARTED-->TX_STOPPED */
1701 : 0 : func_params.cmd = ECORE_F_CMD_TX_STOP;
1702 : 0 : ecore_func_state_change(sc, &func_params);
1703 : :
1704 : : /* TX_STOPPED-->STARTED */
1705 : 0 : func_params.cmd = ECORE_F_CMD_TX_START;
1706 : 0 : return ecore_func_state_change(sc, &func_params);
1707 : : }
1708 : :
1709 : : return 0;
1710 : : }
1711 : :
1712 : 0 : static int bnx2x_stop_queue(struct bnx2x_softc *sc, int index)
1713 : : {
1714 : : struct bnx2x_fastpath *fp = &sc->fp[index];
1715 : 0 : struct ecore_queue_state_params q_params = { NULL };
1716 : : int rc;
1717 : :
1718 : 0 : PMD_DRV_LOG(DEBUG, sc, "stopping queue %d cid %d", index, fp->index);
1719 : :
1720 : 0 : q_params.q_obj = &sc->sp_objs[fp->index].q_obj;
1721 : : /* We want to wait for completion in this context */
1722 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
1723 : :
1724 : : /* Stop the primary connection: */
1725 : :
1726 : : /* ...halt the connection */
1727 : 0 : q_params.cmd = ECORE_Q_CMD_HALT;
1728 : 0 : rc = ecore_queue_state_change(sc, &q_params);
1729 [ # # ]: 0 : if (rc) {
1730 : : return rc;
1731 : : }
1732 : :
1733 : : /* ...terminate the connection */
1734 : 0 : q_params.cmd = ECORE_Q_CMD_TERMINATE;
1735 : : memset(&q_params.params.terminate, 0,
1736 : : sizeof(q_params.params.terminate));
1737 : : q_params.params.terminate.cid_index = FIRST_TX_COS_INDEX;
1738 : 0 : rc = ecore_queue_state_change(sc, &q_params);
1739 [ # # ]: 0 : if (rc) {
1740 : : return rc;
1741 : : }
1742 : :
1743 : : /* ...delete cfc entry */
1744 : 0 : q_params.cmd = ECORE_Q_CMD_CFC_DEL;
1745 : : memset(&q_params.params.cfc_del, 0, sizeof(q_params.params.cfc_del));
1746 : : q_params.params.cfc_del.cid_index = FIRST_TX_COS_INDEX;
1747 : 0 : return ecore_queue_state_change(sc, &q_params);
1748 : : }
1749 : :
1750 : : /* wait for the outstanding SP commands */
1751 : 0 : static uint8_t bnx2x_wait_sp_comp(struct bnx2x_softc *sc, uint32_t mask)
1752 : : {
1753 : : uint32_t tmp;
1754 : : int tout = 5000; /* wait for 5 secs tops */
1755 : :
1756 [ # # ]: 0 : while (tout--) {
1757 : : mb();
1758 [ # # ]: 0 : if (!(atomic_load_acq_int(&sc->sp_state) & mask))
1759 : : return TRUE;
1760 : :
1761 : 0 : DELAY(1000);
1762 : : }
1763 : :
1764 : : mb();
1765 : :
1766 : 0 : tmp = atomic_load_acq_int(&sc->sp_state);
1767 [ # # ]: 0 : if (tmp & mask) {
1768 : 0 : PMD_DRV_LOG(INFO, sc, "Filtering completion timed out: "
1769 : : "sp_state 0x%x, mask 0x%x", tmp, mask);
1770 : 0 : return FALSE;
1771 : : }
1772 : :
1773 : : return FALSE;
1774 : : }
1775 : :
1776 : 0 : static int bnx2x_func_stop(struct bnx2x_softc *sc)
1777 : : {
1778 : 0 : struct ecore_func_state_params func_params = { NULL };
1779 : : int rc;
1780 : :
1781 : : /* prepare parameters for function state transitions */
1782 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
1783 : 0 : func_params.f_obj = &sc->func_obj;
1784 : 0 : func_params.cmd = ECORE_F_CMD_STOP;
1785 : :
1786 : : /*
1787 : : * Try to stop the function the 'good way'. If it fails (in case
1788 : : * of a parity error during bnx2x_chip_cleanup()) and we are
1789 : : * not in a debug mode, perform a state transaction in order to
1790 : : * enable further HW_RESET transaction.
1791 : : */
1792 : 0 : rc = ecore_func_state_change(sc, &func_params);
1793 [ # # ]: 0 : if (rc) {
1794 : 0 : PMD_DRV_LOG(NOTICE, sc, "FUNC_STOP ramrod failed. "
1795 : : "Running a dry transaction");
1796 : : rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY,
1797 : : &func_params.ramrod_flags);
1798 : 0 : return ecore_func_state_change(sc, &func_params);
1799 : : }
1800 : :
1801 : : return 0;
1802 : : }
1803 : :
1804 : 0 : static int bnx2x_reset_hw(struct bnx2x_softc *sc, uint32_t load_code)
1805 : : {
1806 : 0 : struct ecore_func_state_params func_params = { NULL };
1807 : :
1808 : : /* Prepare parameters for function state transitions */
1809 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
1810 : :
1811 : 0 : func_params.f_obj = &sc->func_obj;
1812 : 0 : func_params.cmd = ECORE_F_CMD_HW_RESET;
1813 : :
1814 : 0 : func_params.params.hw_init.load_phase = load_code;
1815 : :
1816 : 0 : return ecore_func_state_change(sc, &func_params);
1817 : : }
1818 : :
1819 : : static void bnx2x_int_disable_sync(struct bnx2x_softc *sc, int disable_hw)
1820 : : {
1821 : : if (disable_hw) {
1822 : : /* prevent the HW from sending interrupts */
1823 : 0 : bnx2x_int_disable(sc);
1824 : : }
1825 : : }
1826 : :
1827 : : static void
1828 : 0 : bnx2x_chip_cleanup(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link)
1829 : : {
1830 : 0 : int port = SC_PORT(sc);
1831 : 0 : struct ecore_mcast_ramrod_params rparam = { NULL };
1832 : : uint32_t reset_code;
1833 : : int i, rc = 0;
1834 : :
1835 : 0 : bnx2x_drain_tx_queues(sc);
1836 : :
1837 : : /* give HW time to discard old tx messages */
1838 : 0 : DELAY(1000);
1839 : :
1840 : : /* Clean all ETH MACs */
1841 : 0 : rc = bnx2x_del_all_macs(sc, &sc->sp_objs[0].mac_obj, ECORE_ETH_MAC,
1842 : : FALSE);
1843 [ # # ]: 0 : if (rc < 0) {
1844 : 0 : PMD_DRV_LOG(NOTICE, sc,
1845 : : "Failed to delete all ETH MACs (%d)", rc);
1846 : : }
1847 : :
1848 : : /* Clean up UC list */
1849 : 0 : rc = bnx2x_del_all_macs(sc, &sc->sp_objs[0].mac_obj, ECORE_UC_LIST_MAC,
1850 : : TRUE);
1851 [ # # ]: 0 : if (rc < 0) {
1852 : 0 : PMD_DRV_LOG(NOTICE, sc,
1853 : : "Failed to delete UC MACs list (%d)", rc);
1854 : : }
1855 : :
1856 : : /* Disable LLH */
1857 : 0 : REG_WR(sc, NIG_REG_LLH0_FUNC_EN + port * 8, 0);
1858 : :
1859 : : /* Set "drop all" to stop Rx */
1860 : :
1861 : : /*
1862 : : * We need to take the if_maddr_lock() here in order to prevent
1863 : : * a race between the completion code and this code.
1864 : : */
1865 : :
1866 [ # # ]: 0 : if (rte_bit_relaxed_get32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state))
1867 : : rte_bit_relaxed_set32(ECORE_FILTER_RX_MODE_SCHED,
1868 : : &sc->sp_state);
1869 : : else
1870 : 0 : bnx2x_set_storm_rx_mode(sc);
1871 : :
1872 : : /* Clean up multicast configuration */
1873 : 0 : rparam.mcast_obj = &sc->mcast_obj;
1874 : 0 : rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
1875 [ # # ]: 0 : if (rc < 0) {
1876 : 0 : PMD_DRV_LOG(NOTICE, sc,
1877 : : "Failed to send DEL MCAST command (%d)", rc);
1878 : : }
1879 : :
1880 : : /*
1881 : : * Send the UNLOAD_REQUEST to the MCP. This will return if
1882 : : * this function should perform FUNCTION, PORT, or COMMON HW
1883 : : * reset.
1884 : : */
1885 : 0 : reset_code = bnx2x_send_unload_req(sc, unload_mode);
1886 : :
1887 : : /*
1888 : : * (assumption: No Attention from MCP at this stage)
1889 : : * PMF probably in the middle of TX disable/enable transaction
1890 : : */
1891 : 0 : rc = bnx2x_func_wait_started(sc);
1892 [ # # ]: 0 : if (rc) {
1893 : 0 : PMD_DRV_LOG(NOTICE, sc, "bnx2x_func_wait_started failed");
1894 : : }
1895 : :
1896 : : /*
1897 : : * Close multi and leading connections
1898 : : * Completions for ramrods are collected in a synchronous way
1899 : : */
1900 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
1901 [ # # ]: 0 : if (bnx2x_stop_queue(sc, i)) {
1902 : 0 : goto unload_error;
1903 : : }
1904 : : }
1905 : :
1906 : : /*
1907 : : * If SP settings didn't get completed so far - something
1908 : : * very wrong has happen.
1909 : : */
1910 [ # # ]: 0 : if (!bnx2x_wait_sp_comp(sc, ~0x0U))
1911 : 0 : PMD_DRV_LOG(NOTICE, sc, "Common slow path ramrods got stuck!");
1912 : :
1913 : 0 : unload_error:
1914 : :
1915 : 0 : rc = bnx2x_func_stop(sc);
1916 [ # # ]: 0 : if (rc) {
1917 : 0 : PMD_DRV_LOG(NOTICE, sc, "Function stop failed!");
1918 : : }
1919 : :
1920 : : /* disable HW interrupts */
1921 : : bnx2x_int_disable_sync(sc, TRUE);
1922 : :
1923 : : /* Reset the chip */
1924 : 0 : rc = bnx2x_reset_hw(sc, reset_code);
1925 [ # # ]: 0 : if (rc) {
1926 : 0 : PMD_DRV_LOG(NOTICE, sc, "Hardware reset failed");
1927 : : }
1928 : :
1929 : : /* Report UNLOAD_DONE to MCP */
1930 : : bnx2x_send_unload_done(sc, keep_link);
1931 : 0 : }
1932 : :
1933 : 0 : static void bnx2x_disable_close_the_gate(struct bnx2x_softc *sc)
1934 : : {
1935 : : uint32_t val;
1936 : :
1937 : 0 : PMD_DRV_LOG(DEBUG, sc, "Disabling 'close the gates'");
1938 : :
1939 : : val = REG_RD(sc, MISC_REG_AEU_GENERAL_MASK);
1940 : 0 : val &= ~(MISC_AEU_GENERAL_MASK_REG_AEU_PXP_CLOSE_MASK |
1941 : : MISC_AEU_GENERAL_MASK_REG_AEU_NIG_CLOSE_MASK);
1942 : : REG_WR(sc, MISC_REG_AEU_GENERAL_MASK, val);
1943 : 0 : }
1944 : :
1945 : : /*
1946 : : * Cleans the object that have internal lists without sending
1947 : : * ramrods. Should be run when interrupts are disabled.
1948 : : */
1949 : 0 : static void bnx2x_squeeze_objects(struct bnx2x_softc *sc)
1950 : : {
1951 : 0 : uint32_t ramrod_flags = 0, vlan_mac_flags = 0;
1952 : 0 : struct ecore_mcast_ramrod_params rparam = { NULL };
1953 : 0 : struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
1954 : : int rc;
1955 : :
1956 : : /* Cleanup MACs' object first... */
1957 : :
1958 : : /* Wait for completion of requested */
1959 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
1960 : : /* Perform a dry cleanup */
1961 : : rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &ramrod_flags);
1962 : :
1963 : : /* Clean ETH primary MAC */
1964 : : rte_bit_relaxed_set32(ECORE_ETH_MAC, &vlan_mac_flags);
1965 : 0 : rc = mac_obj->delete_all(sc, &sc->sp_objs->mac_obj, &vlan_mac_flags,
1966 : : &ramrod_flags);
1967 [ # # ]: 0 : if (rc != 0) {
1968 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to clean ETH MACs (%d)", rc);
1969 : : }
1970 : :
1971 : : /* Cleanup UC list */
1972 : 0 : vlan_mac_flags = 0;
1973 : : rte_bit_relaxed_set32(ECORE_UC_LIST_MAC, &vlan_mac_flags);
1974 : 0 : rc = mac_obj->delete_all(sc, mac_obj, &vlan_mac_flags, &ramrod_flags);
1975 [ # # ]: 0 : if (rc != 0) {
1976 : 0 : PMD_DRV_LOG(NOTICE, sc,
1977 : : "Failed to clean UC list MACs (%d)", rc);
1978 : : }
1979 : :
1980 : : /* Now clean mcast object... */
1981 : :
1982 : 0 : rparam.mcast_obj = &sc->mcast_obj;
1983 : : rte_bit_relaxed_set32(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
1984 : :
1985 : : /* Add a DEL command... */
1986 : 0 : rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
1987 [ # # ]: 0 : if (rc < 0) {
1988 : 0 : PMD_DRV_LOG(NOTICE, sc,
1989 : : "Failed to send DEL MCAST command (%d)", rc);
1990 : : }
1991 : :
1992 : : /* now wait until all pending commands are cleared */
1993 : :
1994 : 0 : rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_CONT);
1995 [ # # ]: 0 : while (rc != 0) {
1996 [ # # ]: 0 : if (rc < 0) {
1997 : 0 : PMD_DRV_LOG(NOTICE, sc,
1998 : : "Failed to clean MCAST object (%d)", rc);
1999 : 0 : return;
2000 : : }
2001 : :
2002 : 0 : rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_CONT);
2003 : : }
2004 : : }
2005 : :
2006 : : /* stop the controller */
2007 : : __rte_noinline
2008 : : int
2009 : 0 : bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link)
2010 : : {
2011 : 0 : uint8_t global = FALSE;
2012 : : uint32_t val;
2013 : :
2014 : 0 : PMD_INIT_FUNC_TRACE(sc);
2015 : :
2016 : 0 : PMD_DRV_LOG(DEBUG, sc, "Starting NIC unload...");
2017 : :
2018 : : /* mark driver as unloaded in shmem2 */
2019 [ # # # # : 0 : if (IS_PF(sc) && SHMEM2_HAS(sc, drv_capabilities_flag)) {
# # ]
2020 [ # # # # ]: 0 : val = SHMEM2_RD(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)]);
2021 [ # # # # ]: 0 : SHMEM2_WR(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)],
2022 : : val & ~DRV_FLAGS_CAPABILITIES_LOADED_L2);
2023 : : }
2024 : :
2025 [ # # # # ]: 0 : if (IS_PF(sc) && sc->recovery_state != BNX2X_RECOVERY_DONE &&
2026 [ # # ]: 0 : (sc->state == BNX2X_STATE_CLOSED || sc->state == BNX2X_STATE_ERROR)) {
2027 : : /*
2028 : : * We can get here if the driver has been unloaded
2029 : : * during parity error recovery and is either waiting for a
2030 : : * leader to complete or for other functions to unload and
2031 : : * then ifconfig down has been issued. In this case we want to
2032 : : * unload and let other functions to complete a recovery
2033 : : * process.
2034 : : */
2035 : 0 : sc->recovery_state = BNX2X_RECOVERY_DONE;
2036 : 0 : sc->is_leader = 0;
2037 : : bnx2x_release_leader_lock(sc);
2038 : : mb();
2039 : :
2040 : 0 : PMD_DRV_LOG(NOTICE, sc, "Can't unload in closed or error state");
2041 : 0 : return -1;
2042 : : }
2043 : :
2044 : : /*
2045 : : * Nothing to do during unload if previous bnx2x_nic_load()
2046 : : * did not complete successfully - all resources are released.
2047 : : */
2048 [ # # ]: 0 : if ((sc->state == BNX2X_STATE_CLOSED) || (sc->state == BNX2X_STATE_ERROR)) {
2049 : : return 0;
2050 : : }
2051 : :
2052 : 0 : sc->state = BNX2X_STATE_CLOSING_WAITING_HALT;
2053 : : mb();
2054 : :
2055 : 0 : sc->rx_mode = BNX2X_RX_MODE_NONE;
2056 : 0 : bnx2x_set_rx_mode(sc);
2057 : : mb();
2058 : :
2059 [ # # ]: 0 : if (IS_PF(sc)) {
2060 : : /* set ALWAYS_ALIVE bit in shmem */
2061 : 0 : sc->fw_drv_pulse_wr_seq |= DRV_PULSE_ALWAYS_ALIVE;
2062 : :
2063 : 0 : bnx2x_drv_pulse(sc);
2064 : :
2065 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_STOP);
2066 : 0 : bnx2x_save_statistics(sc);
2067 : : }
2068 : :
2069 : : /* wait till consumers catch up with producers in all queues */
2070 : 0 : bnx2x_drain_tx_queues(sc);
2071 : :
2072 : : /* if VF indicate to PF this function is going down (PF will delete sp
2073 : : * elements and clear initializations
2074 : : */
2075 [ # # ]: 0 : if (IS_VF(sc)) {
2076 : 0 : bnx2x_vf_unload(sc);
2077 [ # # ]: 0 : } else if (unload_mode != UNLOAD_RECOVERY) {
2078 : : /* if this is a normal/close unload need to clean up chip */
2079 : 0 : bnx2x_chip_cleanup(sc, unload_mode, keep_link);
2080 : : } else {
2081 : : /* Send the UNLOAD_REQUEST to the MCP */
2082 : 0 : bnx2x_send_unload_req(sc, unload_mode);
2083 : :
2084 : : /*
2085 : : * Prevent transactions to host from the functions on the
2086 : : * engine that doesn't reset global blocks in case of global
2087 : : * attention once global blocks are reset and gates are opened
2088 : : * (the engine which leader will perform the recovery
2089 : : * last).
2090 : : */
2091 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
2092 : : bnx2x_pf_disable(sc);
2093 : : }
2094 : :
2095 : : /* disable HW interrupts */
2096 : : bnx2x_int_disable_sync(sc, TRUE);
2097 : :
2098 : : /* Report UNLOAD_DONE to MCP */
2099 : : bnx2x_send_unload_done(sc, FALSE);
2100 : : }
2101 : :
2102 : : /*
2103 : : * At this stage no more interrupts will arrive so we may safely clean
2104 : : * the queueable objects here in case they failed to get cleaned so far.
2105 : : */
2106 [ # # ]: 0 : if (IS_PF(sc)) {
2107 : 0 : bnx2x_squeeze_objects(sc);
2108 : : }
2109 : :
2110 : : /* There should be no more pending SP commands at this stage */
2111 : 0 : sc->sp_state = 0;
2112 : :
2113 : 0 : sc->port.pmf = 0;
2114 : :
2115 [ # # ]: 0 : if (IS_PF(sc)) {
2116 : 0 : bnx2x_free_mem(sc);
2117 : : }
2118 : :
2119 : : /* free the host hardware/software hsi structures */
2120 : 0 : bnx2x_free_hsi_mem(sc);
2121 : :
2122 : : bnx2x_free_fw_stats_mem(sc);
2123 : :
2124 : 0 : sc->state = BNX2X_STATE_CLOSED;
2125 : :
2126 : : /*
2127 : : * Check if there are pending parity attentions. If there are - set
2128 : : * RECOVERY_IN_PROGRESS.
2129 : : */
2130 [ # # ]: 0 : if (IS_PF(sc) && bnx2x_chk_parity_attn(sc, &global, FALSE)) {
2131 : 0 : bnx2x_set_reset_in_progress(sc);
2132 : :
2133 : : /* Set RESET_IS_GLOBAL if needed */
2134 [ # # ]: 0 : if (global) {
2135 : 0 : bnx2x_set_reset_global(sc);
2136 : : }
2137 : : }
2138 : :
2139 : : /*
2140 : : * The last driver must disable a "close the gate" if there is no
2141 : : * parity attention or "process kill" pending.
2142 : : */
2143 [ # # # # ]: 0 : if (IS_PF(sc) && !bnx2x_clear_pf_load(sc) &&
2144 : 0 : bnx2x_reset_is_done(sc, SC_PATH(sc))) {
2145 : 0 : bnx2x_disable_close_the_gate(sc);
2146 : : }
2147 : :
2148 : 0 : PMD_DRV_LOG(DEBUG, sc, "Ended NIC unload");
2149 : :
2150 : 0 : return 0;
2151 : : }
2152 : :
2153 : : /*
2154 : : * Encapsulate an mbuf cluster into the Tx BD chain and makes the memory
2155 : : * visible to the controller.
2156 : : *
2157 : : * If an mbuf is submitted to this routine and cannot be given to the
2158 : : * controller (e.g. it has too many fragments) then the function may free
2159 : : * the mbuf and return to the caller.
2160 : : *
2161 : : * Returns:
2162 : : * int: Number of TX BDs used for the mbuf
2163 : : *
2164 : : * Note the side effect that an mbuf may be freed if it causes a problem.
2165 : : */
2166 : 0 : int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf *m0)
2167 : : {
2168 : : struct eth_tx_start_bd *tx_start_bd;
2169 : : uint16_t bd_prod, pkt_prod;
2170 : : struct bnx2x_softc *sc;
2171 : : uint32_t nbds = 0;
2172 : :
2173 : 0 : sc = txq->sc;
2174 : 0 : bd_prod = txq->tx_bd_tail;
2175 : 0 : pkt_prod = txq->tx_pkt_tail;
2176 : :
2177 : 0 : txq->sw_ring[TX_BD(pkt_prod, txq)] = m0;
2178 : :
2179 [ # # ]: 0 : tx_start_bd = &txq->tx_ring[TX_BD(bd_prod, txq)].start_bd;
2180 : :
2181 : 0 : tx_start_bd->addr_lo =
2182 : 0 : rte_cpu_to_le_32(U64_LO(rte_mbuf_data_iova(m0)));
2183 : 0 : tx_start_bd->addr_hi =
2184 : 0 : rte_cpu_to_le_32(U64_HI(rte_mbuf_data_iova(m0)));
2185 : 0 : tx_start_bd->nbytes = rte_cpu_to_le_16(m0->data_len);
2186 : 0 : tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
2187 : 0 : tx_start_bd->general_data =
2188 : : (1 << ETH_TX_START_BD_HDR_NBDS_SHIFT);
2189 : :
2190 : 0 : tx_start_bd->nbd = rte_cpu_to_le_16(2);
2191 : :
2192 [ # # ]: 0 : if (m0->ol_flags & RTE_MBUF_F_TX_VLAN) {
2193 : 0 : tx_start_bd->vlan_or_ethertype =
2194 : 0 : rte_cpu_to_le_16(m0->vlan_tci);
2195 : 0 : tx_start_bd->bd_flags.as_bitfield |=
2196 : : (X_ETH_OUTBAND_VLAN <<
2197 : : ETH_TX_BD_FLAGS_VLAN_MODE_SHIFT);
2198 : : } else {
2199 [ # # ]: 0 : if (IS_PF(sc))
2200 : 0 : tx_start_bd->vlan_or_ethertype =
2201 : : rte_cpu_to_le_16(pkt_prod);
2202 : : else {
2203 : : /* when transmitting in a vf, start bd
2204 : : * must hold the ethertype for fw to enforce it
2205 : : */
2206 : 0 : struct rte_ether_hdr *eh =
2207 : 0 : rte_pktmbuf_mtod(m0, struct rte_ether_hdr *);
2208 : :
2209 : : /* Still need to consider inband vlan for enforced */
2210 [ # # ]: 0 : if (eh->ether_type ==
2211 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
2212 : : struct rte_vlan_hdr *vh =
2213 : : (struct rte_vlan_hdr *)(eh + 1);
2214 : 0 : tx_start_bd->bd_flags.as_bitfield |=
2215 : : (X_ETH_INBAND_VLAN <<
2216 : : ETH_TX_BD_FLAGS_VLAN_MODE_SHIFT);
2217 : 0 : tx_start_bd->vlan_or_ethertype =
2218 : 0 : rte_cpu_to_le_16(ntohs(vh->vlan_tci));
2219 : : } else {
2220 : 0 : tx_start_bd->vlan_or_ethertype =
2221 [ # # ]: 0 : (rte_cpu_to_le_16
2222 : : (rte_be_to_cpu_16(eh->ether_type)));
2223 : : }
2224 : : }
2225 : : }
2226 : :
2227 [ # # ]: 0 : bd_prod = NEXT_TX_BD(bd_prod);
2228 [ # # ]: 0 : if (IS_VF(sc)) {
2229 : : struct eth_tx_parse_bd_e2 *tx_parse_bd;
2230 : 0 : const struct rte_ether_hdr *eh =
2231 : 0 : rte_pktmbuf_mtod(m0, struct rte_ether_hdr *);
2232 : : uint8_t mac_type = UNICAST_ADDRESS;
2233 : :
2234 : : tx_parse_bd =
2235 [ # # ]: 0 : &txq->tx_ring[TX_BD(bd_prod, txq)].parse_bd_e2;
2236 [ # # ]: 0 : if (rte_is_multicast_ether_addr(&eh->dst_addr)) {
2237 [ # # ]: 0 : if (rte_is_broadcast_ether_addr(&eh->dst_addr))
2238 : : mac_type = BROADCAST_ADDRESS;
2239 : : else
2240 : : mac_type = MULTICAST_ADDRESS;
2241 : : }
2242 : 0 : tx_parse_bd->parsing_data =
2243 : 0 : (mac_type << ETH_TX_PARSE_BD_E2_ETH_ADDR_TYPE_SHIFT);
2244 : :
2245 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.dst_hi,
2246 [ # # ]: 0 : &eh->dst_addr.addr_bytes[0], 2);
2247 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.dst_mid,
2248 [ # # ]: 0 : &eh->dst_addr.addr_bytes[2], 2);
2249 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.dst_lo,
2250 [ # # ]: 0 : &eh->dst_addr.addr_bytes[4], 2);
2251 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.src_hi,
2252 [ # # ]: 0 : &eh->src_addr.addr_bytes[0], 2);
2253 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.src_mid,
2254 [ # # ]: 0 : &eh->src_addr.addr_bytes[2], 2);
2255 : 0 : rte_memcpy(&tx_parse_bd->data.mac_addr.src_lo,
2256 [ # # ]: 0 : &eh->src_addr.addr_bytes[4], 2);
2257 : :
2258 : 0 : tx_parse_bd->data.mac_addr.dst_hi =
2259 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.dst_hi);
2260 : 0 : tx_parse_bd->data.mac_addr.dst_mid =
2261 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.
2262 : : mac_addr.dst_mid);
2263 : 0 : tx_parse_bd->data.mac_addr.dst_lo =
2264 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.dst_lo);
2265 : 0 : tx_parse_bd->data.mac_addr.src_hi =
2266 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.src_hi);
2267 : 0 : tx_parse_bd->data.mac_addr.src_mid =
2268 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.
2269 : : mac_addr.src_mid);
2270 : 0 : tx_parse_bd->data.mac_addr.src_lo =
2271 [ # # ]: 0 : rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.src_lo);
2272 : :
2273 : : PMD_TX_LOG(DEBUG,
2274 : : "PBD dst %x %x %x src %x %x %x p_data %x",
2275 : : tx_parse_bd->data.mac_addr.dst_hi,
2276 : : tx_parse_bd->data.mac_addr.dst_mid,
2277 : : tx_parse_bd->data.mac_addr.dst_lo,
2278 : : tx_parse_bd->data.mac_addr.src_hi,
2279 : : tx_parse_bd->data.mac_addr.src_mid,
2280 : : tx_parse_bd->data.mac_addr.src_lo,
2281 : : tx_parse_bd->parsing_data);
2282 : : }
2283 : :
2284 : : PMD_TX_LOG(DEBUG,
2285 : : "start bd: nbytes %d flags %x vlan %x",
2286 : : tx_start_bd->nbytes,
2287 : : tx_start_bd->bd_flags.as_bitfield,
2288 : : tx_start_bd->vlan_or_ethertype);
2289 : :
2290 [ # # ]: 0 : bd_prod = NEXT_TX_BD(bd_prod);
2291 : 0 : pkt_prod++;
2292 : :
2293 [ # # ]: 0 : if (TX_IDX(bd_prod) < 2)
2294 : : nbds++;
2295 : :
2296 : 0 : txq->nb_tx_avail -= 2;
2297 : 0 : txq->tx_bd_tail = bd_prod;
2298 : 0 : txq->tx_pkt_tail = pkt_prod;
2299 : :
2300 : 0 : return nbds + 2;
2301 : : }
2302 : :
2303 : : static uint16_t bnx2x_cid_ilt_lines(struct bnx2x_softc *sc)
2304 : : {
2305 : 0 : return L2_ILT_LINES(sc);
2306 : : }
2307 : :
2308 : 0 : static void bnx2x_ilt_set_info(struct bnx2x_softc *sc)
2309 : : {
2310 : : struct ilt_client_info *ilt_client;
2311 : 0 : struct ecore_ilt *ilt = sc->ilt;
2312 : : uint16_t line = 0;
2313 : :
2314 : 0 : PMD_INIT_FUNC_TRACE(sc);
2315 : :
2316 : 0 : ilt->start_line = FUNC_ILT_BASE(SC_FUNC(sc));
2317 : :
2318 : : /* CDU */
2319 : : ilt_client = &ilt->clients[ILT_CLIENT_CDU];
2320 : 0 : ilt_client->client_num = ILT_CLIENT_CDU;
2321 : 0 : ilt_client->page_size = CDU_ILT_PAGE_SZ;
2322 : 0 : ilt_client->flags = ILT_CLIENT_SKIP_MEM;
2323 : 0 : ilt_client->start = line;
2324 : : line += bnx2x_cid_ilt_lines(sc);
2325 : :
2326 : : if (CNIC_SUPPORT(sc)) {
2327 : : line += CNIC_ILT_LINES;
2328 : : }
2329 : :
2330 : 0 : ilt_client->end = (line - 1);
2331 : :
2332 : : /* QM */
2333 [ # # ]: 0 : if (QM_INIT(sc->qm_cid_count)) {
2334 : : ilt_client = &ilt->clients[ILT_CLIENT_QM];
2335 : 0 : ilt_client->client_num = ILT_CLIENT_QM;
2336 : 0 : ilt_client->page_size = QM_ILT_PAGE_SZ;
2337 : 0 : ilt_client->flags = 0;
2338 : 0 : ilt_client->start = line;
2339 : :
2340 : : /* 4 bytes for each cid */
2341 : 0 : line += DIV_ROUND_UP(sc->qm_cid_count * QM_QUEUES_PER_FUNC * 4,
2342 : : QM_ILT_PAGE_SZ);
2343 : :
2344 : 0 : ilt_client->end = (line - 1);
2345 : : }
2346 : :
2347 : : if (CNIC_SUPPORT(sc)) {
2348 : : /* SRC */
2349 : : ilt_client = &ilt->clients[ILT_CLIENT_SRC];
2350 : : ilt_client->client_num = ILT_CLIENT_SRC;
2351 : : ilt_client->page_size = SRC_ILT_PAGE_SZ;
2352 : : ilt_client->flags = 0;
2353 : : ilt_client->start = line;
2354 : : line += SRC_ILT_LINES;
2355 : : ilt_client->end = (line - 1);
2356 : :
2357 : : /* TM */
2358 : : ilt_client = &ilt->clients[ILT_CLIENT_TM];
2359 : : ilt_client->client_num = ILT_CLIENT_TM;
2360 : : ilt_client->page_size = TM_ILT_PAGE_SZ;
2361 : : ilt_client->flags = 0;
2362 : : ilt_client->start = line;
2363 : : line += TM_ILT_LINES;
2364 : : ilt_client->end = (line - 1);
2365 : : }
2366 : :
2367 [ # # ]: 0 : assert((line <= ILT_MAX_LINES));
2368 : 0 : }
2369 : :
2370 : : static void bnx2x_set_fp_rx_buf_size(struct bnx2x_softc *sc)
2371 : : {
2372 : : int i;
2373 : :
2374 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
2375 : : /* get the Rx buffer size for RX frames */
2376 : 0 : sc->fp[i].rx_buf_size =
2377 : 0 : (IP_HEADER_ALIGNMENT_PADDING + ETH_OVERHEAD + sc->mtu);
2378 : : }
2379 : : }
2380 : :
2381 : 0 : int bnx2x_alloc_ilt_mem(struct bnx2x_softc *sc)
2382 : : {
2383 : :
2384 : 0 : sc->ilt = rte_malloc("", sizeof(struct ecore_ilt), RTE_CACHE_LINE_SIZE);
2385 : :
2386 : 0 : return sc->ilt == NULL;
2387 : : }
2388 : :
2389 : 0 : static int bnx2x_alloc_ilt_lines_mem(struct bnx2x_softc *sc)
2390 : : {
2391 : 0 : sc->ilt->lines = rte_calloc("",
2392 : : ILT_MAX_LINES, sizeof(struct ilt_line),
2393 : : RTE_CACHE_LINE_SIZE);
2394 : 0 : return sc->ilt->lines == NULL;
2395 : : }
2396 : :
2397 : 0 : void bnx2x_free_ilt_mem(struct bnx2x_softc *sc)
2398 : : {
2399 : 0 : rte_free(sc->ilt);
2400 : 0 : sc->ilt = NULL;
2401 : 0 : }
2402 : :
2403 : : static void bnx2x_free_ilt_lines_mem(struct bnx2x_softc *sc)
2404 : : {
2405 [ # # ]: 0 : if (sc->ilt->lines != NULL) {
2406 : 0 : rte_free(sc->ilt->lines);
2407 : 0 : sc->ilt->lines = NULL;
2408 : : }
2409 : : }
2410 : :
2411 : 0 : static void bnx2x_free_mem(struct bnx2x_softc *sc)
2412 : : {
2413 : : uint32_t i;
2414 : :
2415 [ # # ]: 0 : for (i = 0; i < L2_ILT_LINES(sc); i++) {
2416 : 0 : sc->context[i].vcxt = NULL;
2417 : 0 : sc->context[i].size = 0;
2418 : : }
2419 : :
2420 : 0 : ecore_ilt_mem_op(sc, ILT_MEMOP_FREE);
2421 : :
2422 : : bnx2x_free_ilt_lines_mem(sc);
2423 : 0 : }
2424 : :
2425 : 0 : static int bnx2x_alloc_mem(struct bnx2x_softc *sc)
2426 : : {
2427 : : int context_size;
2428 : : int allocated;
2429 : : int i;
2430 : : char cdu_name[RTE_MEMZONE_NAMESIZE];
2431 : :
2432 : : /*
2433 : : * Allocate memory for CDU context:
2434 : : * This memory is allocated separately and not in the generic ILT
2435 : : * functions because CDU differs in few aspects:
2436 : : * 1. There can be multiple entities allocating memory for context -
2437 : : * regular L2, CNIC, and SRIOV drivers. Each separately controls
2438 : : * its own ILT lines.
2439 : : * 2. Since CDU page-size is not a single 4KB page (which is the case
2440 : : * for the other ILT clients), to be efficient we want to support
2441 : : * allocation of sub-page-size in the last entry.
2442 : : * 3. Context pointers are used by the driver to pass to FW / update
2443 : : * the context (for the other ILT clients the pointers are used just to
2444 : : * free the memory during unload).
2445 : : */
2446 : 0 : context_size = (sizeof(union cdu_context) * BNX2X_L2_CID_COUNT(sc));
2447 [ # # ]: 0 : for (i = 0, allocated = 0; allocated < context_size; i++) {
2448 : 0 : sc->context[i].size = min(CDU_ILT_PAGE_SZ,
2449 : : (context_size - allocated));
2450 : :
2451 : : snprintf(cdu_name, sizeof(cdu_name), "cdu_%d", i);
2452 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, sc->context[i].size,
2453 : : &sc->context[i].vcxt_dma,
2454 : : cdu_name, BNX2X_PAGE_SIZE) != 0) {
2455 : 0 : bnx2x_free_mem(sc);
2456 : 0 : return -1;
2457 : : }
2458 : :
2459 : 0 : sc->context[i].vcxt =
2460 : 0 : (union cdu_context *)sc->context[i].vcxt_dma.vaddr;
2461 : :
2462 : 0 : allocated += sc->context[i].size;
2463 : : }
2464 : :
2465 : 0 : bnx2x_alloc_ilt_lines_mem(sc);
2466 : :
2467 [ # # ]: 0 : if (ecore_ilt_mem_op(sc, ILT_MEMOP_ALLOC)) {
2468 : 0 : PMD_DRV_LOG(NOTICE, sc, "ecore_ilt_mem_op ILT_MEMOP_ALLOC failed");
2469 : 0 : bnx2x_free_mem(sc);
2470 : 0 : return -1;
2471 : : }
2472 : :
2473 : : return 0;
2474 : : }
2475 : :
2476 : : static void bnx2x_free_fw_stats_mem(struct bnx2x_softc *sc)
2477 : : {
2478 : 0 : bnx2x_dma_free(&sc->fw_stats_dma);
2479 : 0 : sc->fw_stats_num = 0;
2480 : :
2481 : 0 : sc->fw_stats_req_size = 0;
2482 : 0 : sc->fw_stats_req = NULL;
2483 : 0 : sc->fw_stats_req_mapping = 0;
2484 : :
2485 : 0 : sc->fw_stats_data_size = 0;
2486 : 0 : sc->fw_stats_data = NULL;
2487 [ # # ]: 0 : sc->fw_stats_data_mapping = 0;
2488 : : }
2489 : :
2490 : 0 : static int bnx2x_alloc_fw_stats_mem(struct bnx2x_softc *sc)
2491 : : {
2492 : : uint8_t num_queue_stats;
2493 : : int num_groups, vf_headroom = 0;
2494 : :
2495 : : /* number of queues for statistics is number of eth queues */
2496 : 0 : num_queue_stats = BNX2X_NUM_ETH_QUEUES(sc);
2497 : :
2498 : : /*
2499 : : * Total number of FW statistics requests =
2500 : : * 1 for port stats + 1 for PF stats + num of queues
2501 : : */
2502 : 0 : sc->fw_stats_num = (2 + num_queue_stats);
2503 : :
2504 : : /*
2505 : : * Request is built from stats_query_header and an array of
2506 : : * stats_query_cmd_group each of which contains STATS_QUERY_CMD_COUNT
2507 : : * rules. The real number or requests is configured in the
2508 : : * stats_query_header.
2509 : : */
2510 : 0 : num_groups = (sc->fw_stats_num + vf_headroom) / STATS_QUERY_CMD_COUNT;
2511 [ # # ]: 0 : if ((sc->fw_stats_num + vf_headroom) % STATS_QUERY_CMD_COUNT)
2512 : 0 : num_groups++;
2513 : :
2514 : 0 : sc->fw_stats_req_size =
2515 : 0 : (sizeof(struct stats_query_header) +
2516 : : (num_groups * sizeof(struct stats_query_cmd_group)));
2517 : :
2518 : : /*
2519 : : * Data for statistics requests + stats_counter.
2520 : : * stats_counter holds per-STORM counters that are incremented when
2521 : : * STORM has finished with the current request. Memory for FCoE
2522 : : * offloaded statistics are counted anyway, even if they will not be sent.
2523 : : * VF stats are not accounted for here as the data of VF stats is stored
2524 : : * in memory allocated by the VF, not here.
2525 : : */
2526 : 0 : sc->fw_stats_data_size =
2527 : : (sizeof(struct stats_counter) +
2528 : 0 : sizeof(struct per_port_stats) + sizeof(struct per_pf_stats) +
2529 : : /* sizeof(struct fcoe_statistics_params) + */
2530 : 0 : (sizeof(struct per_queue_stats) * num_queue_stats));
2531 : :
2532 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, (sc->fw_stats_req_size + sc->fw_stats_data_size),
2533 : : &sc->fw_stats_dma, "fw_stats",
2534 : : RTE_CACHE_LINE_SIZE) != 0) {
2535 : : bnx2x_free_fw_stats_mem(sc);
2536 : 0 : return -1;
2537 : : }
2538 : :
2539 : : /* set up the shortcuts */
2540 : :
2541 : 0 : sc->fw_stats_req = (struct bnx2x_fw_stats_req *)sc->fw_stats_dma.vaddr;
2542 : 0 : sc->fw_stats_req_mapping = sc->fw_stats_dma.paddr;
2543 : :
2544 : 0 : sc->fw_stats_data =
2545 : 0 : (struct bnx2x_fw_stats_data *)((uint8_t *) sc->fw_stats_dma.vaddr +
2546 : 0 : sc->fw_stats_req_size);
2547 : 0 : sc->fw_stats_data_mapping = (sc->fw_stats_dma.paddr +
2548 : : sc->fw_stats_req_size);
2549 : :
2550 : 0 : return 0;
2551 : : }
2552 : :
2553 : : /*
2554 : : * Bits map:
2555 : : * 0-7 - Engine0 load counter.
2556 : : * 8-15 - Engine1 load counter.
2557 : : * 16 - Engine0 RESET_IN_PROGRESS bit.
2558 : : * 17 - Engine1 RESET_IN_PROGRESS bit.
2559 : : * 18 - Engine0 ONE_IS_LOADED. Set when there is at least one active
2560 : : * function on the engine
2561 : : * 19 - Engine1 ONE_IS_LOADED.
2562 : : * 20 - Chip reset flow bit. When set none-leader must wait for both engines
2563 : : * leader to complete (check for both RESET_IN_PROGRESS bits and not
2564 : : * for just the one belonging to its engine).
2565 : : */
2566 : : #define BNX2X_RECOVERY_GLOB_REG MISC_REG_GENERIC_POR_1
2567 : : #define BNX2X_PATH0_LOAD_CNT_MASK 0x000000ff
2568 : : #define BNX2X_PATH0_LOAD_CNT_SHIFT 0
2569 : : #define BNX2X_PATH1_LOAD_CNT_MASK 0x0000ff00
2570 : : #define BNX2X_PATH1_LOAD_CNT_SHIFT 8
2571 : : #define BNX2X_PATH0_RST_IN_PROG_BIT 0x00010000
2572 : : #define BNX2X_PATH1_RST_IN_PROG_BIT 0x00020000
2573 : : #define BNX2X_GLOBAL_RESET_BIT 0x00040000
2574 : :
2575 : : /* set the GLOBAL_RESET bit, should be run under rtnl lock */
2576 : 0 : static void bnx2x_set_reset_global(struct bnx2x_softc *sc)
2577 : : {
2578 : : uint32_t val;
2579 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2580 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2581 : 0 : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val | BNX2X_GLOBAL_RESET_BIT);
2582 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2583 : 0 : }
2584 : :
2585 : : /* clear the GLOBAL_RESET bit, should be run under rtnl lock */
2586 : : static void bnx2x_clear_reset_global(struct bnx2x_softc *sc)
2587 : : {
2588 : : uint32_t val;
2589 : : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2590 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2591 : : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val & (~BNX2X_GLOBAL_RESET_BIT));
2592 : : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2593 : : }
2594 : :
2595 : : /* checks the GLOBAL_RESET bit, should be run under rtnl lock */
2596 : : static uint8_t bnx2x_reset_is_global(struct bnx2x_softc *sc)
2597 : : {
2598 : : return REG_RD(sc, BNX2X_RECOVERY_GLOB_REG) & BNX2X_GLOBAL_RESET_BIT;
2599 : : }
2600 : :
2601 : : /* clear RESET_IN_PROGRESS bit for the engine, should be run under rtnl lock */
2602 : 0 : static void bnx2x_set_reset_done(struct bnx2x_softc *sc)
2603 : : {
2604 : : uint32_t val;
2605 [ # # ]: 0 : uint32_t bit = SC_PATH(sc) ? BNX2X_PATH1_RST_IN_PROG_BIT :
2606 : : BNX2X_PATH0_RST_IN_PROG_BIT;
2607 : :
2608 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2609 : :
2610 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2611 : : /* Clear the bit */
2612 : 0 : val &= ~bit;
2613 : : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val);
2614 : :
2615 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2616 : 0 : }
2617 : :
2618 : : /* set RESET_IN_PROGRESS for the engine, should be run under rtnl lock */
2619 : 0 : static void bnx2x_set_reset_in_progress(struct bnx2x_softc *sc)
2620 : : {
2621 : : uint32_t val;
2622 [ # # ]: 0 : uint32_t bit = SC_PATH(sc) ? BNX2X_PATH1_RST_IN_PROG_BIT :
2623 : : BNX2X_PATH0_RST_IN_PROG_BIT;
2624 : :
2625 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2626 : :
2627 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2628 : : /* Set the bit */
2629 : 0 : val |= bit;
2630 : : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val);
2631 : :
2632 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2633 : 0 : }
2634 : :
2635 : : /* check RESET_IN_PROGRESS bit for an engine, should be run under rtnl lock */
2636 : : static uint8_t bnx2x_reset_is_done(struct bnx2x_softc *sc, int engine)
2637 : : {
2638 : : uint32_t val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2639 [ # # # # ]: 0 : uint32_t bit = engine ? BNX2X_PATH1_RST_IN_PROG_BIT :
2640 : : BNX2X_PATH0_RST_IN_PROG_BIT;
2641 : :
2642 : : /* return false if bit is set */
2643 [ # # ]: 0 : return (val & bit) ? FALSE : TRUE;
2644 : : }
2645 : :
2646 : : /* get the load status for an engine, should be run under rtnl lock */
2647 : : static uint8_t bnx2x_get_load_status(struct bnx2x_softc *sc, int engine)
2648 : : {
2649 [ # # ]: 0 : uint32_t mask = engine ? BNX2X_PATH1_LOAD_CNT_MASK :
2650 : : BNX2X_PATH0_LOAD_CNT_MASK;
2651 [ # # # # ]: 0 : uint32_t shift = engine ? BNX2X_PATH1_LOAD_CNT_SHIFT :
2652 : : BNX2X_PATH0_LOAD_CNT_SHIFT;
2653 : : uint32_t val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2654 : :
2655 : 0 : val = ((val & mask) >> shift);
2656 : :
2657 : : return val != 0;
2658 : : }
2659 : :
2660 : : /* set pf load mark */
2661 : 0 : static void bnx2x_set_pf_load(struct bnx2x_softc *sc)
2662 : : {
2663 : : uint32_t val;
2664 : : uint32_t val1;
2665 [ # # ]: 0 : uint32_t mask = SC_PATH(sc) ? BNX2X_PATH1_LOAD_CNT_MASK :
2666 : : BNX2X_PATH0_LOAD_CNT_MASK;
2667 [ # # ]: 0 : uint32_t shift = SC_PATH(sc) ? BNX2X_PATH1_LOAD_CNT_SHIFT :
2668 : : BNX2X_PATH0_LOAD_CNT_SHIFT;
2669 : :
2670 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2671 : :
2672 : 0 : PMD_INIT_FUNC_TRACE(sc);
2673 : :
2674 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2675 : :
2676 : : /* get the current counter value */
2677 : 0 : val1 = ((val & mask) >> shift);
2678 : :
2679 : : /* set bit of this PF */
2680 : 0 : val1 |= (1 << SC_ABS_FUNC(sc));
2681 : :
2682 : : /* clear the old value */
2683 : : val &= ~mask;
2684 : :
2685 : : /* set the new one */
2686 : 0 : val |= ((val1 << shift) & mask);
2687 : :
2688 : : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val);
2689 : :
2690 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2691 : 0 : }
2692 : :
2693 : : /* clear pf load mark */
2694 : 0 : static uint8_t bnx2x_clear_pf_load(struct bnx2x_softc *sc)
2695 : : {
2696 : : uint32_t val1, val;
2697 [ # # ]: 0 : uint32_t mask = SC_PATH(sc) ? BNX2X_PATH1_LOAD_CNT_MASK :
2698 : : BNX2X_PATH0_LOAD_CNT_MASK;
2699 [ # # ]: 0 : uint32_t shift = SC_PATH(sc) ? BNX2X_PATH1_LOAD_CNT_SHIFT :
2700 : : BNX2X_PATH0_LOAD_CNT_SHIFT;
2701 : :
2702 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2703 : : val = REG_RD(sc, BNX2X_RECOVERY_GLOB_REG);
2704 : :
2705 : : /* get the current counter value */
2706 : 0 : val1 = (val & mask) >> shift;
2707 : :
2708 : : /* clear bit of that PF */
2709 : 0 : val1 &= ~(1 << SC_ABS_FUNC(sc));
2710 : :
2711 : : /* clear the old value */
2712 : : val &= ~mask;
2713 : :
2714 : : /* set the new one */
2715 : 0 : val |= ((val1 << shift) & mask);
2716 : :
2717 : : REG_WR(sc, BNX2X_RECOVERY_GLOB_REG, val);
2718 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RECOVERY_REG);
2719 : 0 : return val1 != 0;
2720 : : }
2721 : :
2722 : : /* send load request to MCP and analyze response */
2723 : 0 : static int bnx2x_nic_load_request(struct bnx2x_softc *sc, uint32_t * load_code)
2724 : : {
2725 : 0 : PMD_INIT_FUNC_TRACE(sc);
2726 : :
2727 : : /* init fw_seq */
2728 : 0 : sc->fw_seq =
2729 [ # # # # ]: 0 : (SHMEM_RD(sc, func_mb[SC_FW_MB_IDX(sc)].drv_mb_header) &
2730 : : DRV_MSG_SEQ_NUMBER_MASK);
2731 : :
2732 : 0 : PMD_DRV_LOG(DEBUG, sc, "initial fw_seq 0x%04x", sc->fw_seq);
2733 : :
2734 : : #ifdef BNX2X_PULSE
2735 : : /* get the current FW pulse sequence */
2736 : : sc->fw_drv_pulse_wr_seq =
2737 : : (SHMEM_RD(sc, func_mb[SC_FW_MB_IDX(sc)].drv_pulse_mb) &
2738 : : DRV_PULSE_SEQ_MASK);
2739 : : #else
2740 : : /* set ALWAYS_ALIVE bit in shmem */
2741 : 0 : sc->fw_drv_pulse_wr_seq |= DRV_PULSE_ALWAYS_ALIVE;
2742 : 0 : bnx2x_drv_pulse(sc);
2743 : : #endif
2744 : :
2745 : : /* load request */
2746 : 0 : (*load_code) = bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_REQ,
2747 : : DRV_MSG_CODE_LOAD_REQ_WITH_LFA);
2748 : :
2749 : : /* if the MCP fails to respond we must abort */
2750 [ # # ]: 0 : if (!(*load_code)) {
2751 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP response failure!");
2752 : 0 : return -1;
2753 : : }
2754 : :
2755 : : /* if MCP refused then must abort */
2756 [ # # ]: 0 : if ((*load_code) == FW_MSG_CODE_DRV_LOAD_REFUSED) {
2757 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP refused load request");
2758 : 0 : return -1;
2759 : : }
2760 : :
2761 : : return 0;
2762 : : }
2763 : :
2764 : : /*
2765 : : * Check whether another PF has already loaded FW to chip. In virtualized
2766 : : * environments a pf from anoth VM may have already initialized the device
2767 : : * including loading FW.
2768 : : */
2769 : 0 : static int bnx2x_nic_load_analyze_req(struct bnx2x_softc *sc, uint32_t load_code)
2770 : : {
2771 : : uint32_t my_fw, loaded_fw;
2772 : :
2773 : : /* is another pf loaded on this engine? */
2774 : 0 : if ((load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) &&
2775 [ # # ]: 0 : (load_code != FW_MSG_CODE_DRV_LOAD_COMMON)) {
2776 : : /* build my FW version dword */
2777 : : my_fw = (BNX2X_5710_FW_MAJOR_VERSION +
2778 : : (BNX2X_5710_FW_MINOR_VERSION << 8) +
2779 : : (BNX2X_5710_FW_REVISION_VERSION << 16) +
2780 : : (BNX2X_5710_FW_ENGINEERING_VERSION << 24));
2781 : :
2782 : : /* read loaded FW from chip */
2783 : : loaded_fw = REG_RD(sc, XSEM_REG_PRAM);
2784 : 0 : PMD_DRV_LOG(DEBUG, sc, "loaded FW 0x%08x / my FW 0x%08x",
2785 : : loaded_fw, my_fw);
2786 : :
2787 : : /* abort nic load if version mismatch */
2788 [ # # ]: 0 : if (my_fw != loaded_fw) {
2789 : 0 : PMD_DRV_LOG(NOTICE, sc,
2790 : : "FW 0x%08x already loaded (mine is 0x%08x)",
2791 : : loaded_fw, my_fw);
2792 : 0 : return -1;
2793 : : }
2794 : : }
2795 : :
2796 : : return 0;
2797 : : }
2798 : :
2799 : : /* mark PMF if applicable */
2800 : 0 : static void bnx2x_nic_load_pmf(struct bnx2x_softc *sc, uint32_t load_code)
2801 : : {
2802 : : uint32_t ncsi_oem_data_addr;
2803 : :
2804 : 0 : PMD_INIT_FUNC_TRACE(sc);
2805 : :
2806 : 0 : if ((load_code == FW_MSG_CODE_DRV_LOAD_COMMON) ||
2807 [ # # # # ]: 0 : (load_code == FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) ||
2808 : : (load_code == FW_MSG_CODE_DRV_LOAD_PORT)) {
2809 : : /*
2810 : : * Barrier here for ordering between the writing to sc->port.pmf here
2811 : : * and reading it from the periodic task.
2812 : : */
2813 : 0 : sc->port.pmf = 1;
2814 : : mb();
2815 : : } else {
2816 : 0 : sc->port.pmf = 0;
2817 : : }
2818 : :
2819 : 0 : PMD_DRV_LOG(DEBUG, sc, "pmf %d", sc->port.pmf);
2820 : :
2821 [ # # ]: 0 : if (load_code == FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) {
2822 [ # # # # ]: 0 : if (SHMEM2_HAS(sc, ncsi_oem_data_addr)) {
2823 : 0 : ncsi_oem_data_addr = SHMEM2_RD(sc, ncsi_oem_data_addr);
2824 [ # # ]: 0 : if (ncsi_oem_data_addr) {
2825 : 0 : REG_WR(sc,
2826 : : (ncsi_oem_data_addr +
2827 : : offsetof(struct glob_ncsi_oem_data,
2828 : : driver_version)), 0);
2829 : : }
2830 : : }
2831 : : }
2832 : 0 : }
2833 : :
2834 : 0 : static void bnx2x_read_mf_cfg(struct bnx2x_softc *sc)
2835 : : {
2836 [ # # ]: 0 : int n = (CHIP_IS_MODE_4_PORT(sc) ? 2 : 1);
2837 : : int abs_func;
2838 : : int vn;
2839 : :
2840 [ # # ]: 0 : if (BNX2X_NOMCP(sc)) {
2841 : : return; /* what should be the default bvalue in this case */
2842 : : }
2843 : :
2844 : : /*
2845 : : * The formula for computing the absolute function number is...
2846 : : * For 2 port configuration (4 functions per port):
2847 : : * abs_func = 2 * vn + SC_PORT + SC_PATH
2848 : : * For 4 port configuration (2 functions per port):
2849 : : * abs_func = 4 * vn + 2 * SC_PORT + SC_PATH
2850 : : */
2851 [ # # # # ]: 0 : for (vn = VN_0; vn < SC_MAX_VN_NUM(sc); vn++) {
2852 : 0 : abs_func = (n * (2 * vn + SC_PORT(sc)) + SC_PATH(sc));
2853 [ # # ]: 0 : if (abs_func >= E1H_FUNC_MAX) {
2854 : : break;
2855 : : }
2856 : 0 : sc->devinfo.mf_info.mf_config[vn] =
2857 : 0 : MFCFG_RD(sc, func_mf_config[abs_func].config);
2858 : : }
2859 : :
2860 [ # # ]: 0 : if (sc->devinfo.mf_info.mf_config[SC_VN(sc)] &
2861 : : FUNC_MF_CFG_FUNC_DISABLED) {
2862 : 0 : PMD_DRV_LOG(DEBUG, sc, "mf_cfg function disabled");
2863 : 0 : sc->flags |= BNX2X_MF_FUNC_DIS;
2864 : : } else {
2865 : 0 : PMD_DRV_LOG(DEBUG, sc, "mf_cfg function enabled");
2866 : 0 : sc->flags &= ~BNX2X_MF_FUNC_DIS;
2867 : : }
2868 : : }
2869 : :
2870 : : /* acquire split MCP access lock register */
2871 : 0 : static int bnx2x_acquire_alr(struct bnx2x_softc *sc)
2872 : : {
2873 : : uint32_t j, val;
2874 : :
2875 [ # # ]: 0 : for (j = 0; j < 1000; j++) {
2876 : : val = (1UL << 31);
2877 : : REG_WR(sc, GRCBASE_MCP + 0x9c, val);
2878 : : val = REG_RD(sc, GRCBASE_MCP + 0x9c);
2879 [ # # ]: 0 : if (val & (1L << 31))
2880 : : break;
2881 : :
2882 : 0 : DELAY(5000);
2883 : : }
2884 : :
2885 [ # # ]: 0 : if (!(val & (1L << 31))) {
2886 : 0 : PMD_DRV_LOG(NOTICE, sc, "Cannot acquire MCP access lock register");
2887 : 0 : return -1;
2888 : : }
2889 : :
2890 : : return 0;
2891 : : }
2892 : :
2893 : : /* release split MCP access lock register */
2894 : : static void bnx2x_release_alr(struct bnx2x_softc *sc)
2895 : : {
2896 : : REG_WR(sc, GRCBASE_MCP + 0x9c, 0);
2897 : : }
2898 : :
2899 : 0 : static void bnx2x_fan_failure(struct bnx2x_softc *sc)
2900 : : {
2901 : 0 : int port = SC_PORT(sc);
2902 : : uint32_t ext_phy_config;
2903 : :
2904 : : /* mark the failure */
2905 : : ext_phy_config =
2906 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].external_phy_config);
2907 : :
2908 : 0 : ext_phy_config &= ~PORT_HW_CFG_XGXS_EXT_PHY_TYPE_MASK;
2909 : 0 : ext_phy_config |= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE;
2910 : 0 : SHMEM_WR(sc, dev_info.port_hw_config[port].external_phy_config,
2911 : : ext_phy_config);
2912 : :
2913 : : /* log the failure */
2914 : 0 : PMD_DRV_LOG(INFO, sc,
2915 : : "Fan Failure has caused the driver to shutdown "
2916 : : "the card to prevent permanent damage. "
2917 : : "Please contact OEM Support for assistance");
2918 : :
2919 : 0 : rte_panic("Schedule task to handle fan failure");
2920 : : }
2921 : :
2922 : : /* this function is called upon a link interrupt */
2923 : 0 : static void bnx2x_link_attn(struct bnx2x_softc *sc)
2924 : : {
2925 : : uint32_t pause_enabled = 0;
2926 : : struct host_port_stats *pstats;
2927 : : int cmng_fns;
2928 : :
2929 : : /* Make sure that we are synced with the current statistics */
2930 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_STOP);
2931 : :
2932 : 0 : elink_link_update(&sc->link_params, &sc->link_vars);
2933 : :
2934 [ # # ]: 0 : if (sc->link_vars.link_up) {
2935 : :
2936 : : /* dropless flow control */
2937 [ # # ]: 0 : if (sc->dropless_fc) {
2938 : : pause_enabled = 0;
2939 : :
2940 [ # # ]: 0 : if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
2941 : : pause_enabled = 1;
2942 : : }
2943 : :
2944 : 0 : REG_WR(sc,
2945 : : (BAR_USTRORM_INTMEM +
2946 : : USTORM_ETH_PAUSE_ENABLED_OFFSET(SC_PORT(sc))),
2947 : : pause_enabled);
2948 : : }
2949 : :
2950 [ # # ]: 0 : if (sc->link_vars.mac_type != ELINK_MAC_TYPE_EMAC) {
2951 : 0 : pstats = BNX2X_SP(sc, port_stats);
2952 : : /* reset old mac stats */
2953 : 0 : memset(&(pstats->mac_stx[0]), 0,
2954 : : sizeof(struct mac_stx));
2955 : : }
2956 : :
2957 [ # # ]: 0 : if (sc->state == BNX2X_STATE_OPEN) {
2958 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_LINK_UP);
2959 : : }
2960 : : }
2961 : :
2962 [ # # # # ]: 0 : if (sc->link_vars.link_up && sc->link_vars.line_speed) {
2963 : : cmng_fns = bnx2x_get_cmng_fns_mode(sc);
2964 : :
2965 : : if (cmng_fns != CMNG_FNS_NONE) {
2966 : 0 : bnx2x_cmng_fns_init(sc, FALSE, cmng_fns);
2967 : 0 : storm_memset_cmng(sc, &sc->cmng, SC_PORT(sc));
2968 : : }
2969 : : }
2970 : :
2971 : 0 : bnx2x_link_report_locked(sc);
2972 : :
2973 [ # # # # ]: 0 : if (IS_MF(sc)) {
2974 : 0 : bnx2x_link_sync_notify(sc);
2975 : : }
2976 : 0 : }
2977 : :
2978 : 0 : static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
2979 : : {
2980 : 0 : int port = SC_PORT(sc);
2981 [ # # ]: 0 : uint32_t aeu_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 :
2982 : : MISC_REG_AEU_MASK_ATTN_FUNC_0;
2983 [ # # ]: 0 : uint32_t nig_int_mask_addr = port ? NIG_REG_MASK_INTERRUPT_PORT1 :
2984 : : NIG_REG_MASK_INTERRUPT_PORT0;
2985 : : uint32_t aeu_mask;
2986 : : uint32_t nig_mask = 0;
2987 : : uint32_t reg_addr;
2988 : : uint32_t igu_acked;
2989 : : uint32_t cnt;
2990 : :
2991 [ # # ]: 0 : if (sc->attn_state & asserted) {
2992 : 0 : PMD_DRV_LOG(ERR, sc, "IGU ERROR attn=0x%08x", asserted);
2993 : : }
2994 : :
2995 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port);
2996 : :
2997 : 0 : aeu_mask = REG_RD(sc, aeu_addr);
2998 : :
2999 : 0 : aeu_mask &= ~(asserted & 0x3ff);
3000 : :
3001 : : REG_WR(sc, aeu_addr, aeu_mask);
3002 : :
3003 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port);
3004 : :
3005 : 0 : sc->attn_state |= asserted;
3006 : :
3007 [ # # ]: 0 : if (asserted & ATTN_HARD_WIRED_MASK) {
3008 [ # # ]: 0 : if (asserted & ATTN_NIG_FOR_FUNC) {
3009 : :
3010 : 0 : bnx2x_acquire_phy_lock(sc);
3011 : : /* save nig interrupt mask */
3012 : 0 : nig_mask = REG_RD(sc, nig_int_mask_addr);
3013 : :
3014 : : /* If nig_mask is not set, no need to call the update function */
3015 [ # # ]: 0 : if (nig_mask) {
3016 : : REG_WR(sc, nig_int_mask_addr, 0);
3017 : :
3018 : 0 : bnx2x_link_attn(sc);
3019 : : }
3020 : :
3021 : : /* handle unicore attn? */
3022 : : }
3023 : :
3024 [ # # ]: 0 : if (asserted & ATTN_SW_TIMER_4_FUNC) {
3025 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_SW_TIMER_4_FUNC!");
3026 : : }
3027 : :
3028 [ # # ]: 0 : if (asserted & GPIO_2_FUNC) {
3029 : 0 : PMD_DRV_LOG(DEBUG, sc, "GPIO_2_FUNC!");
3030 : : }
3031 : :
3032 [ # # ]: 0 : if (asserted & GPIO_3_FUNC) {
3033 : 0 : PMD_DRV_LOG(DEBUG, sc, "GPIO_3_FUNC!");
3034 : : }
3035 : :
3036 [ # # ]: 0 : if (asserted & GPIO_4_FUNC) {
3037 : 0 : PMD_DRV_LOG(DEBUG, sc, "GPIO_4_FUNC!");
3038 : : }
3039 : :
3040 [ # # ]: 0 : if (port == 0) {
3041 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_1) {
3042 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_1!");
3043 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_1, 0x0);
3044 : : }
3045 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_2) {
3046 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_2!");
3047 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_2, 0x0);
3048 : : }
3049 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_3) {
3050 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_3!");
3051 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_3, 0x0);
3052 : : }
3053 : : } else {
3054 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_4) {
3055 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_4!");
3056 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_4, 0x0);
3057 : : }
3058 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_5) {
3059 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_5!");
3060 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_5, 0x0);
3061 : : }
3062 [ # # ]: 0 : if (asserted & ATTN_GENERAL_ATTN_6) {
3063 : 0 : PMD_DRV_LOG(DEBUG, sc, "ATTN_GENERAL_ATTN_6!");
3064 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_6, 0x0);
3065 : : }
3066 : : }
3067 : : }
3068 : : /* hardwired */
3069 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
3070 : 0 : reg_addr =
3071 : 0 : (HC_REG_COMMAND_REG + port * 32 +
3072 : : COMMAND_REG_ATTN_BITS_SET);
3073 : : } else {
3074 : : reg_addr = (BAR_IGU_INTMEM + IGU_CMD_ATTN_BIT_SET_UPPER * 8);
3075 : : }
3076 : :
3077 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, sc, "about to mask 0x%08x at %s addr 0x%08x",
3078 : : asserted,
3079 : : (sc->devinfo.int_block == INT_BLOCK_HC) ? "HC" : "IGU",
3080 : : reg_addr);
3081 : 0 : REG_WR(sc, reg_addr, asserted);
3082 : :
3083 : : /* now set back the mask */
3084 [ # # ]: 0 : if (asserted & ATTN_NIG_FOR_FUNC) {
3085 : : /*
3086 : : * Verify that IGU ack through BAR was written before restoring
3087 : : * NIG mask. This loop should exit after 2-3 iterations max.
3088 : : */
3089 [ # # ]: 0 : if (sc->devinfo.int_block != INT_BLOCK_HC) {
3090 : : cnt = 0;
3091 : :
3092 : : do {
3093 : : igu_acked =
3094 : : REG_RD(sc, IGU_REG_ATTENTION_ACK_BITS);
3095 : : } while (((igu_acked & ATTN_NIG_FOR_FUNC) == 0)
3096 [ # # # # ]: 0 : && (++cnt < MAX_IGU_ATTN_ACK_TO));
3097 : :
3098 [ # # ]: 0 : if (!igu_acked) {
3099 : 0 : PMD_DRV_LOG(ERR, sc,
3100 : : "Failed to verify IGU ack on time");
3101 : : }
3102 : :
3103 : : mb();
3104 : : }
3105 : :
3106 : 0 : REG_WR(sc, nig_int_mask_addr, nig_mask);
3107 : :
3108 : : bnx2x_release_phy_lock(sc);
3109 : : }
3110 : 0 : }
3111 : :
3112 : : static void
3113 : 0 : bnx2x_print_next_block(__rte_unused struct bnx2x_softc *sc, __rte_unused int idx,
3114 : : __rte_unused const char *blk)
3115 : : {
3116 [ # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%s%s", idx ? ", " : "", blk);
3117 : 0 : }
3118 : :
3119 : : static int
3120 : 0 : bnx2x_check_blocks_with_parity0(struct bnx2x_softc *sc, uint32_t sig, int par_num,
3121 : : uint8_t print)
3122 : : {
3123 : : uint32_t cur_bit = 0;
3124 : : int i = 0;
3125 : :
3126 [ # # ]: 0 : for (i = 0; sig; i++) {
3127 : 0 : cur_bit = ((uint32_t) 0x1 << i);
3128 [ # # ]: 0 : if (sig & cur_bit) {
3129 [ # # # # : 0 : switch (cur_bit) {
# # # # ]
3130 : 0 : case AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR:
3131 [ # # ]: 0 : if (print)
3132 : 0 : bnx2x_print_next_block(sc, par_num++,
3133 : : "BRB");
3134 : : break;
3135 : 0 : case AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR:
3136 [ # # ]: 0 : if (print)
3137 : 0 : bnx2x_print_next_block(sc, par_num++,
3138 : : "PARSER");
3139 : : break;
3140 : 0 : case AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR:
3141 [ # # ]: 0 : if (print)
3142 : 0 : bnx2x_print_next_block(sc, par_num++,
3143 : : "TSDM");
3144 : : break;
3145 : 0 : case AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR:
3146 [ # # ]: 0 : if (print)
3147 : 0 : bnx2x_print_next_block(sc, par_num++,
3148 : : "SEARCHER");
3149 : : break;
3150 : 0 : case AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR:
3151 [ # # ]: 0 : if (print)
3152 : 0 : bnx2x_print_next_block(sc, par_num++,
3153 : : "TCM");
3154 : : break;
3155 : 0 : case AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR:
3156 [ # # ]: 0 : if (print)
3157 : 0 : bnx2x_print_next_block(sc, par_num++,
3158 : : "TSEMI");
3159 : : break;
3160 : 0 : case AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR:
3161 [ # # ]: 0 : if (print)
3162 : 0 : bnx2x_print_next_block(sc, par_num++,
3163 : : "XPB");
3164 : : break;
3165 : : }
3166 : :
3167 : : /* Clear the bit */
3168 : 0 : sig &= ~cur_bit;
3169 : : }
3170 : : }
3171 : :
3172 : 0 : return par_num;
3173 : : }
3174 : :
3175 : : static int
3176 : 0 : bnx2x_check_blocks_with_parity1(struct bnx2x_softc *sc, uint32_t sig, int par_num,
3177 : : uint8_t * global, uint8_t print)
3178 : : {
3179 : : int i = 0;
3180 : : uint32_t cur_bit = 0;
3181 [ # # ]: 0 : for (i = 0; sig; i++) {
3182 : 0 : cur_bit = ((uint32_t) 0x1 << i);
3183 [ # # ]: 0 : if (sig & cur_bit) {
3184 [ # # # # : 0 : switch (cur_bit) {
# # # # #
# # # # #
# # # ]
3185 : 0 : case AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR:
3186 [ # # ]: 0 : if (print)
3187 : 0 : bnx2x_print_next_block(sc, par_num++,
3188 : : "PBF");
3189 : : break;
3190 : 0 : case AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR:
3191 [ # # ]: 0 : if (print)
3192 : 0 : bnx2x_print_next_block(sc, par_num++,
3193 : : "QM");
3194 : : break;
3195 : 0 : case AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR:
3196 [ # # ]: 0 : if (print)
3197 : 0 : bnx2x_print_next_block(sc, par_num++,
3198 : : "TM");
3199 : : break;
3200 : 0 : case AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR:
3201 [ # # ]: 0 : if (print)
3202 : 0 : bnx2x_print_next_block(sc, par_num++,
3203 : : "XSDM");
3204 : : break;
3205 : 0 : case AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR:
3206 [ # # ]: 0 : if (print)
3207 : 0 : bnx2x_print_next_block(sc, par_num++,
3208 : : "XCM");
3209 : : break;
3210 : 0 : case AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR:
3211 [ # # ]: 0 : if (print)
3212 : 0 : bnx2x_print_next_block(sc, par_num++,
3213 : : "XSEMI");
3214 : : break;
3215 : 0 : case AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR:
3216 [ # # ]: 0 : if (print)
3217 : 0 : bnx2x_print_next_block(sc, par_num++,
3218 : : "DOORBELLQ");
3219 : : break;
3220 : 0 : case AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR:
3221 [ # # ]: 0 : if (print)
3222 : 0 : bnx2x_print_next_block(sc, par_num++,
3223 : : "NIG");
3224 : : break;
3225 : 0 : case AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR:
3226 [ # # ]: 0 : if (print)
3227 : 0 : bnx2x_print_next_block(sc, par_num++,
3228 : : "VAUX PCI CORE");
3229 : 0 : *global = TRUE;
3230 : 0 : break;
3231 : 0 : case AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR:
3232 [ # # ]: 0 : if (print)
3233 : 0 : bnx2x_print_next_block(sc, par_num++,
3234 : : "DEBUG");
3235 : : break;
3236 : 0 : case AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR:
3237 [ # # ]: 0 : if (print)
3238 : 0 : bnx2x_print_next_block(sc, par_num++,
3239 : : "USDM");
3240 : : break;
3241 : 0 : case AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR:
3242 [ # # ]: 0 : if (print)
3243 : 0 : bnx2x_print_next_block(sc, par_num++,
3244 : : "UCM");
3245 : : break;
3246 : 0 : case AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR:
3247 [ # # ]: 0 : if (print)
3248 : 0 : bnx2x_print_next_block(sc, par_num++,
3249 : : "USEMI");
3250 : : break;
3251 : 0 : case AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR:
3252 [ # # ]: 0 : if (print)
3253 : 0 : bnx2x_print_next_block(sc, par_num++,
3254 : : "UPB");
3255 : : break;
3256 : 0 : case AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR:
3257 [ # # ]: 0 : if (print)
3258 : 0 : bnx2x_print_next_block(sc, par_num++,
3259 : : "CSDM");
3260 : : break;
3261 : 0 : case AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR:
3262 [ # # ]: 0 : if (print)
3263 : 0 : bnx2x_print_next_block(sc, par_num++,
3264 : : "CCM");
3265 : : break;
3266 : : }
3267 : :
3268 : : /* Clear the bit */
3269 : 0 : sig &= ~cur_bit;
3270 : : }
3271 : : }
3272 : :
3273 : 0 : return par_num;
3274 : : }
3275 : :
3276 : : static int
3277 : 0 : bnx2x_check_blocks_with_parity2(struct bnx2x_softc *sc, uint32_t sig, int par_num,
3278 : : uint8_t print)
3279 : : {
3280 : : uint32_t cur_bit = 0;
3281 : : int i = 0;
3282 : :
3283 [ # # ]: 0 : for (i = 0; sig; i++) {
3284 : 0 : cur_bit = ((uint32_t) 0x1 << i);
3285 [ # # ]: 0 : if (sig & cur_bit) {
3286 [ # # # # : 0 : switch (cur_bit) {
# # # #
# ]
3287 : 0 : case AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR:
3288 [ # # ]: 0 : if (print)
3289 : 0 : bnx2x_print_next_block(sc, par_num++,
3290 : : "CSEMI");
3291 : : break;
3292 : 0 : case AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR:
3293 [ # # ]: 0 : if (print)
3294 : 0 : bnx2x_print_next_block(sc, par_num++,
3295 : : "PXP");
3296 : : break;
3297 : 0 : case AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR:
3298 [ # # ]: 0 : if (print)
3299 : 0 : bnx2x_print_next_block(sc, par_num++,
3300 : : "PXPPCICLOCKCLIENT");
3301 : : break;
3302 : 0 : case AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR:
3303 [ # # ]: 0 : if (print)
3304 : 0 : bnx2x_print_next_block(sc, par_num++,
3305 : : "CFC");
3306 : : break;
3307 : 0 : case AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR:
3308 [ # # ]: 0 : if (print)
3309 : 0 : bnx2x_print_next_block(sc, par_num++,
3310 : : "CDU");
3311 : : break;
3312 : 0 : case AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR:
3313 [ # # ]: 0 : if (print)
3314 : 0 : bnx2x_print_next_block(sc, par_num++,
3315 : : "DMAE");
3316 : : break;
3317 : 0 : case AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR:
3318 [ # # ]: 0 : if (print)
3319 : 0 : bnx2x_print_next_block(sc, par_num++,
3320 : : "IGU");
3321 : : break;
3322 : 0 : case AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR:
3323 [ # # ]: 0 : if (print)
3324 : 0 : bnx2x_print_next_block(sc, par_num++,
3325 : : "MISC");
3326 : : break;
3327 : : }
3328 : :
3329 : : /* Clear the bit */
3330 : 0 : sig &= ~cur_bit;
3331 : : }
3332 : : }
3333 : :
3334 : 0 : return par_num;
3335 : : }
3336 : :
3337 : : static int
3338 : 0 : bnx2x_check_blocks_with_parity3(struct bnx2x_softc *sc, uint32_t sig, int par_num,
3339 : : uint8_t * global, uint8_t print)
3340 : : {
3341 : : uint32_t cur_bit = 0;
3342 : : int i = 0;
3343 : :
3344 [ # # ]: 0 : for (i = 0; sig; i++) {
3345 : 0 : cur_bit = ((uint32_t) 0x1 << i);
3346 [ # # ]: 0 : if (sig & cur_bit) {
3347 [ # # # # : 0 : switch (cur_bit) {
# ]
3348 : 0 : case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY:
3349 [ # # ]: 0 : if (print)
3350 : 0 : bnx2x_print_next_block(sc, par_num++,
3351 : : "MCP ROM");
3352 : 0 : *global = TRUE;
3353 : 0 : break;
3354 : 0 : case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY:
3355 [ # # ]: 0 : if (print)
3356 : 0 : bnx2x_print_next_block(sc, par_num++,
3357 : : "MCP UMP RX");
3358 : 0 : *global = TRUE;
3359 : 0 : break;
3360 : 0 : case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY:
3361 [ # # ]: 0 : if (print)
3362 : 0 : bnx2x_print_next_block(sc, par_num++,
3363 : : "MCP UMP TX");
3364 : 0 : *global = TRUE;
3365 : 0 : break;
3366 : 0 : case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY:
3367 [ # # ]: 0 : if (print)
3368 : 0 : bnx2x_print_next_block(sc, par_num++,
3369 : : "MCP SCPAD");
3370 : 0 : *global = TRUE;
3371 : 0 : break;
3372 : : }
3373 : :
3374 : : /* Clear the bit */
3375 : 0 : sig &= ~cur_bit;
3376 : : }
3377 : : }
3378 : :
3379 : 0 : return par_num;
3380 : : }
3381 : :
3382 : : static int
3383 : 0 : bnx2x_check_blocks_with_parity4(struct bnx2x_softc *sc, uint32_t sig, int par_num,
3384 : : uint8_t print)
3385 : : {
3386 : : uint32_t cur_bit = 0;
3387 : : int i = 0;
3388 : :
3389 [ # # ]: 0 : for (i = 0; sig; i++) {
3390 : 0 : cur_bit = ((uint32_t) 0x1 << i);
3391 [ # # ]: 0 : if (sig & cur_bit) {
3392 [ # # # ]: 0 : switch (cur_bit) {
3393 : 0 : case AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR:
3394 [ # # ]: 0 : if (print)
3395 : 0 : bnx2x_print_next_block(sc, par_num++,
3396 : : "PGLUE_B");
3397 : : break;
3398 : 0 : case AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR:
3399 [ # # ]: 0 : if (print)
3400 : 0 : bnx2x_print_next_block(sc, par_num++,
3401 : : "ATC");
3402 : : break;
3403 : : }
3404 : :
3405 : : /* Clear the bit */
3406 : 0 : sig &= ~cur_bit;
3407 : : }
3408 : : }
3409 : :
3410 : 0 : return par_num;
3411 : : }
3412 : :
3413 : : static uint8_t
3414 : 0 : bnx2x_parity_attn(struct bnx2x_softc *sc, uint8_t * global, uint8_t print,
3415 : : uint32_t * sig)
3416 : : {
3417 : : int par_num = 0;
3418 : :
3419 [ # # ]: 0 : if ((sig[0] & HW_PRTY_ASSERT_SET_0) ||
3420 [ # # ]: 0 : (sig[1] & HW_PRTY_ASSERT_SET_1) ||
3421 [ # # ]: 0 : (sig[2] & HW_PRTY_ASSERT_SET_2) ||
3422 [ # # ]: 0 : (sig[3] & HW_PRTY_ASSERT_SET_3) ||
3423 [ # # ]: 0 : (sig[4] & HW_PRTY_ASSERT_SET_4)) {
3424 : 0 : PMD_DRV_LOG(ERR, sc,
3425 : : "Parity error: HW block parity attention:"
3426 : : "[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x [4]:0x%08x",
3427 : : (uint32_t) (sig[0] & HW_PRTY_ASSERT_SET_0),
3428 : : (uint32_t) (sig[1] & HW_PRTY_ASSERT_SET_1),
3429 : : (uint32_t) (sig[2] & HW_PRTY_ASSERT_SET_2),
3430 : : (uint32_t) (sig[3] & HW_PRTY_ASSERT_SET_3),
3431 : : (uint32_t) (sig[4] & HW_PRTY_ASSERT_SET_4));
3432 : :
3433 [ # # ]: 0 : if (print)
3434 : 0 : PMD_DRV_LOG(INFO, sc, "Parity errors detected in blocks: ");
3435 : :
3436 : : par_num =
3437 : 0 : bnx2x_check_blocks_with_parity0(sc, sig[0] &
3438 : : HW_PRTY_ASSERT_SET_0,
3439 : : par_num, print);
3440 : : par_num =
3441 : 0 : bnx2x_check_blocks_with_parity1(sc, sig[1] &
3442 : : HW_PRTY_ASSERT_SET_1,
3443 : : par_num, global, print);
3444 : : par_num =
3445 : 0 : bnx2x_check_blocks_with_parity2(sc, sig[2] &
3446 : : HW_PRTY_ASSERT_SET_2,
3447 : : par_num, print);
3448 : : par_num =
3449 : 0 : bnx2x_check_blocks_with_parity3(sc, sig[3] &
3450 : : HW_PRTY_ASSERT_SET_3,
3451 : : par_num, global, print);
3452 : : par_num =
3453 : 0 : bnx2x_check_blocks_with_parity4(sc, sig[4] &
3454 : : HW_PRTY_ASSERT_SET_4,
3455 : : par_num, print);
3456 : :
3457 [ # # ]: 0 : if (print)
3458 : 0 : PMD_DRV_LOG(INFO, sc, "");
3459 : :
3460 : 0 : return TRUE;
3461 : : }
3462 : :
3463 : : return FALSE;
3464 : : }
3465 : :
3466 : : static uint8_t
3467 : 0 : bnx2x_chk_parity_attn(struct bnx2x_softc *sc, uint8_t * global, uint8_t print)
3468 : : {
3469 : 0 : struct attn_route attn = { {0} };
3470 : 0 : int port = SC_PORT(sc);
3471 : :
3472 : 0 : attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port * 4);
3473 : 0 : attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port * 4);
3474 : 0 : attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port * 4);
3475 : 0 : attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port * 4);
3476 : :
3477 [ # # ]: 0 : if (!CHIP_IS_E1x(sc))
3478 : 0 : attn.sig[4] =
3479 : 0 : REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_5_FUNC_0 + port * 4);
3480 : :
3481 : 0 : return bnx2x_parity_attn(sc, global, print, attn.sig);
3482 : : }
3483 : :
3484 : 0 : static void bnx2x_attn_int_deasserted4(struct bnx2x_softc *sc, uint32_t attn)
3485 : : {
3486 : : uint32_t val;
3487 : :
3488 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT) {
3489 : : val = REG_RD(sc, PGLUE_B_REG_PGLUE_B_INT_STS_CLR);
3490 : 0 : PMD_DRV_LOG(INFO, sc, "ERROR: PGLUE hw attention 0x%08x", val);
3491 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR)
3492 : 0 : PMD_DRV_LOG(INFO, sc,
3493 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR");
3494 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR)
3495 : 0 : PMD_DRV_LOG(INFO, sc,
3496 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR");
3497 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN)
3498 : 0 : PMD_DRV_LOG(INFO, sc,
3499 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN");
3500 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN)
3501 : 0 : PMD_DRV_LOG(INFO, sc,
3502 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN");
3503 [ # # ]: 0 : if (val &
3504 : : PGLUE_B_PGLUE_B_INT_STS_REG_VF_GRC_SPACE_VIOLATION_ATTN)
3505 : 0 : PMD_DRV_LOG(INFO, sc,
3506 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_VF_GRC_SPACE_VIOLATION_ATTN");
3507 [ # # ]: 0 : if (val &
3508 : : PGLUE_B_PGLUE_B_INT_STS_REG_VF_MSIX_BAR_VIOLATION_ATTN)
3509 : 0 : PMD_DRV_LOG(INFO, sc,
3510 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_VF_MSIX_BAR_VIOLATION_ATTN");
3511 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_ERROR_ATTN)
3512 : 0 : PMD_DRV_LOG(INFO, sc,
3513 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_ERROR_ATTN");
3514 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN)
3515 : 0 : PMD_DRV_LOG(INFO, sc,
3516 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN");
3517 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW)
3518 : 0 : PMD_DRV_LOG(INFO, sc,
3519 : : "ERROR: PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW");
3520 : : }
3521 : :
3522 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT) {
3523 : : val = REG_RD(sc, ATC_REG_ATC_INT_STS_CLR);
3524 : 0 : PMD_DRV_LOG(INFO, sc, "ERROR: ATC hw attention 0x%08x", val);
3525 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ADDRESS_ERROR)
3526 : 0 : PMD_DRV_LOG(INFO, sc,
3527 : : "ERROR: ATC_ATC_INT_STS_REG_ADDRESS_ERROR");
3528 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND)
3529 : 0 : PMD_DRV_LOG(INFO, sc,
3530 : : "ERROR: ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND");
3531 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS)
3532 : 0 : PMD_DRV_LOG(INFO, sc,
3533 : : "ERROR: ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS");
3534 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT)
3535 : 0 : PMD_DRV_LOG(INFO, sc,
3536 : : "ERROR: ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT");
3537 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR)
3538 : 0 : PMD_DRV_LOG(INFO, sc,
3539 : : "ERROR: ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR");
3540 [ # # ]: 0 : if (val & ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU)
3541 : 0 : PMD_DRV_LOG(INFO, sc,
3542 : : "ERROR: ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU");
3543 : : }
3544 : :
3545 [ # # ]: 0 : if (attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR |
3546 : : AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)) {
3547 : 0 : PMD_DRV_LOG(INFO, sc,
3548 : : "ERROR: FATAL parity attention set4 0x%08x",
3549 : : (uint32_t) (attn &
3550 : : (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR
3551 : : |
3552 : : AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)));
3553 : : }
3554 : 0 : }
3555 : :
3556 : : static void bnx2x_e1h_disable(struct bnx2x_softc *sc)
3557 : : {
3558 : 0 : int port = SC_PORT(sc);
3559 : :
3560 : 0 : REG_WR(sc, NIG_REG_LLH0_FUNC_EN + port * 8, 0);
3561 : 0 : }
3562 : :
3563 : : static void bnx2x_e1h_enable(struct bnx2x_softc *sc)
3564 : : {
3565 : 0 : int port = SC_PORT(sc);
3566 : :
3567 : 0 : REG_WR(sc, NIG_REG_LLH0_FUNC_EN + port * 8, 1);
3568 : 0 : }
3569 : :
3570 : : /*
3571 : : * called due to MCP event (on pmf):
3572 : : * reread new bandwidth configuration
3573 : : * configure FW
3574 : : * notify others function about the change
3575 : : */
3576 : 0 : static void bnx2x_config_mf_bw(struct bnx2x_softc *sc)
3577 : : {
3578 [ # # ]: 0 : if (sc->link_vars.link_up) {
3579 : 0 : bnx2x_cmng_fns_init(sc, TRUE, CMNG_FNS_MINMAX);
3580 : 0 : bnx2x_link_sync_notify(sc);
3581 : : }
3582 : :
3583 : 0 : storm_memset_cmng(sc, &sc->cmng, SC_PORT(sc));
3584 : 0 : }
3585 : :
3586 : : static void bnx2x_set_mf_bw(struct bnx2x_softc *sc)
3587 : : {
3588 : 0 : bnx2x_config_mf_bw(sc);
3589 : : bnx2x_fw_command(sc, DRV_MSG_CODE_SET_MF_BW_ACK, 0);
3590 : 0 : }
3591 : :
3592 : : static void bnx2x_handle_eee_event(struct bnx2x_softc *sc)
3593 : : {
3594 : : bnx2x_fw_command(sc, DRV_MSG_CODE_EEE_RESULTS_ACK, 0);
3595 : 0 : }
3596 : :
3597 : : #define DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED 3
3598 : :
3599 : 0 : static void bnx2x_drv_info_ether_stat(struct bnx2x_softc *sc)
3600 : : {
3601 : 0 : struct eth_stats_info *ether_stat = &sc->sp->drv_info_to_mcp.ether_stat;
3602 : :
3603 : 0 : strncpy(ether_stat->version, BNX2X_DRIVER_VERSION,
3604 : : ETH_STAT_INFO_VERSION_LEN);
3605 : :
3606 : 0 : sc->sp_objs[0].mac_obj.get_n_elements(sc, &sc->sp_objs[0].mac_obj,
3607 : : DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
3608 : : ether_stat->mac_local + MAC_PAD,
3609 : : MAC_PAD, ETH_ALEN);
3610 : :
3611 : 0 : ether_stat->mtu_size = sc->mtu;
3612 : :
3613 : 0 : ether_stat->feature_flags |= FEATURE_ETH_CHKSUM_OFFLOAD_MASK;
3614 : 0 : ether_stat->promiscuous_mode = 0; // (flags & PROMISC) ? 1 : 0;
3615 : :
3616 : 0 : ether_stat->txq_size = sc->tx_ring_size;
3617 : 0 : ether_stat->rxq_size = sc->rx_ring_size;
3618 : 0 : }
3619 : :
3620 : 0 : static void bnx2x_handle_drv_info_req(struct bnx2x_softc *sc)
3621 : : {
3622 : : enum drv_info_opcode op_code;
3623 : 0 : uint32_t drv_info_ctl = SHMEM2_RD(sc, drv_info_control);
3624 : :
3625 : : /* if drv_info version supported by MFW doesn't match - send NACK */
3626 [ # # ]: 0 : if ((drv_info_ctl & DRV_INFO_CONTROL_VER_MASK) != DRV_INFO_CUR_VER) {
3627 : : bnx2x_fw_command(sc, DRV_MSG_CODE_DRV_INFO_NACK, 0);
3628 : 0 : return;
3629 : : }
3630 : :
3631 : 0 : op_code = ((drv_info_ctl & DRV_INFO_CONTROL_OP_CODE_MASK) >>
3632 : : DRV_INFO_CONTROL_OP_CODE_SHIFT);
3633 : :
3634 [ # # ]: 0 : memset(&sc->sp->drv_info_to_mcp, 0, sizeof(union drv_info_to_mcp));
3635 : :
3636 [ # # ]: 0 : switch (op_code) {
3637 : 0 : case ETH_STATS_OPCODE:
3638 : 0 : bnx2x_drv_info_ether_stat(sc);
3639 : : break;
3640 : : case FCOE_STATS_OPCODE:
3641 : : case ISCSI_STATS_OPCODE:
3642 : : default:
3643 : : /* if op code isn't supported - send NACK */
3644 : : bnx2x_fw_command(sc, DRV_MSG_CODE_DRV_INFO_NACK, 0);
3645 : : return;
3646 : : }
3647 : :
3648 : : /*
3649 : : * If we got drv_info attn from MFW then these fields are defined in
3650 : : * shmem2 for sure
3651 : : */
3652 : 0 : SHMEM2_WR(sc, drv_info_host_addr_lo,
3653 : : U64_LO(BNX2X_SP_MAPPING(sc, drv_info_to_mcp)));
3654 : 0 : SHMEM2_WR(sc, drv_info_host_addr_hi,
3655 : : U64_HI(BNX2X_SP_MAPPING(sc, drv_info_to_mcp)));
3656 : :
3657 : : bnx2x_fw_command(sc, DRV_MSG_CODE_DRV_INFO_ACK, 0);
3658 : : }
3659 : :
3660 : 0 : static void bnx2x_dcc_event(struct bnx2x_softc *sc, uint32_t dcc_event)
3661 : : {
3662 [ # # ]: 0 : if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) {
3663 : : /*
3664 : : * This is the only place besides the function initialization
3665 : : * where the sc->flags can change so it is done without any
3666 : : * locks
3667 : : */
3668 : 0 : if (sc->devinfo.
3669 [ # # ]: 0 : mf_info.mf_config[SC_VN(sc)] & FUNC_MF_CFG_FUNC_DISABLED) {
3670 : 0 : PMD_DRV_LOG(DEBUG, sc, "mf_cfg function disabled");
3671 : 0 : sc->flags |= BNX2X_MF_FUNC_DIS;
3672 : : bnx2x_e1h_disable(sc);
3673 : : } else {
3674 : 0 : PMD_DRV_LOG(DEBUG, sc, "mf_cfg function enabled");
3675 : 0 : sc->flags &= ~BNX2X_MF_FUNC_DIS;
3676 : : bnx2x_e1h_enable(sc);
3677 : : }
3678 : 0 : dcc_event &= ~DRV_STATUS_DCC_DISABLE_ENABLE_PF;
3679 : : }
3680 : :
3681 [ # # ]: 0 : if (dcc_event & DRV_STATUS_DCC_BANDWIDTH_ALLOCATION) {
3682 : 0 : bnx2x_config_mf_bw(sc);
3683 : 0 : dcc_event &= ~DRV_STATUS_DCC_BANDWIDTH_ALLOCATION;
3684 : : }
3685 : :
3686 : : /* Report results to MCP */
3687 [ # # ]: 0 : if (dcc_event)
3688 : : bnx2x_fw_command(sc, DRV_MSG_CODE_DCC_FAILURE, 0);
3689 : : else
3690 : : bnx2x_fw_command(sc, DRV_MSG_CODE_DCC_OK, 0);
3691 : 0 : }
3692 : :
3693 : 0 : static void bnx2x_pmf_update(struct bnx2x_softc *sc)
3694 : : {
3695 : 0 : int port = SC_PORT(sc);
3696 : : uint32_t val;
3697 : :
3698 : 0 : sc->port.pmf = 1;
3699 : :
3700 : : /*
3701 : : * We need the mb() to ensure the ordering between the writing to
3702 : : * sc->port.pmf here and reading it from the bnx2x_periodic_task().
3703 : : */
3704 : : mb();
3705 : :
3706 : : /* enable nig attention */
3707 : 0 : val = (0xff0f | (1 << (SC_VN(sc) + 4)));
3708 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
3709 : 0 : REG_WR(sc, HC_REG_TRAILING_EDGE_0 + port * 8, val);
3710 : 0 : REG_WR(sc, HC_REG_LEADING_EDGE_0 + port * 8, val);
3711 [ # # ]: 0 : } else if (!CHIP_IS_E1x(sc)) {
3712 : : REG_WR(sc, IGU_REG_TRAILING_EDGE_LATCH, val);
3713 : : REG_WR(sc, IGU_REG_LEADING_EDGE_LATCH, val);
3714 : : }
3715 : :
3716 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_PMF);
3717 : 0 : }
3718 : :
3719 : 0 : static int bnx2x_mc_assert(struct bnx2x_softc *sc)
3720 : : {
3721 : : char last_idx;
3722 : : int i, rc = 0;
3723 : : __rte_unused uint32_t row0, row1, row2, row3;
3724 : :
3725 : : /* XSTORM */
3726 : 0 : last_idx =
3727 : 0 : REG_RD8(sc, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_INDEX_OFFSET);
3728 [ # # ]: 0 : if (last_idx)
3729 : 0 : PMD_DRV_LOG(ERR, sc, "XSTORM_ASSERT_LIST_INDEX 0x%x", last_idx);
3730 : :
3731 : : /* print the asserts */
3732 [ # # ]: 0 : for (i = 0; i < STORM_ASSERT_ARRAY_SIZE; i++) {
3733 : :
3734 : : row0 =
3735 : 0 : REG_RD(sc,
3736 : : BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i));
3737 : : row1 =
3738 : 0 : REG_RD(sc,
3739 : : BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) +
3740 : : 4);
3741 : : row2 =
3742 : 0 : REG_RD(sc,
3743 : : BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) +
3744 : : 8);
3745 : : row3 =
3746 : 0 : REG_RD(sc,
3747 : : BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) +
3748 : : 12);
3749 : :
3750 [ # # ]: 0 : if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) {
3751 : 0 : PMD_DRV_LOG(ERR, sc,
3752 : : "XSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x",
3753 : : i, row3, row2, row1, row0);
3754 : 0 : rc++;
3755 : : } else {
3756 : : break;
3757 : : }
3758 : : }
3759 : :
3760 : : /* TSTORM */
3761 : 0 : last_idx =
3762 : 0 : REG_RD8(sc, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_INDEX_OFFSET);
3763 [ # # ]: 0 : if (last_idx) {
3764 : 0 : PMD_DRV_LOG(ERR, sc, "TSTORM_ASSERT_LIST_INDEX 0x%x", last_idx);
3765 : : }
3766 : :
3767 : : /* print the asserts */
3768 [ # # ]: 0 : for (i = 0; i < STORM_ASSERT_ARRAY_SIZE; i++) {
3769 : :
3770 : : row0 =
3771 : 0 : REG_RD(sc,
3772 : : BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i));
3773 : : row1 =
3774 : 0 : REG_RD(sc,
3775 : : BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) +
3776 : : 4);
3777 : : row2 =
3778 : 0 : REG_RD(sc,
3779 : : BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) +
3780 : : 8);
3781 : : row3 =
3782 : 0 : REG_RD(sc,
3783 : : BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) +
3784 : : 12);
3785 : :
3786 [ # # ]: 0 : if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) {
3787 : 0 : PMD_DRV_LOG(ERR, sc,
3788 : : "TSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x",
3789 : : i, row3, row2, row1, row0);
3790 : 0 : rc++;
3791 : : } else {
3792 : : break;
3793 : : }
3794 : : }
3795 : :
3796 : : /* CSTORM */
3797 : 0 : last_idx =
3798 : 0 : REG_RD8(sc, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_INDEX_OFFSET);
3799 [ # # ]: 0 : if (last_idx) {
3800 : 0 : PMD_DRV_LOG(ERR, sc, "CSTORM_ASSERT_LIST_INDEX 0x%x", last_idx);
3801 : : }
3802 : :
3803 : : /* print the asserts */
3804 [ # # ]: 0 : for (i = 0; i < STORM_ASSERT_ARRAY_SIZE; i++) {
3805 : :
3806 : : row0 =
3807 : 0 : REG_RD(sc,
3808 : : BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i));
3809 : : row1 =
3810 : 0 : REG_RD(sc,
3811 : : BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) +
3812 : : 4);
3813 : : row2 =
3814 : 0 : REG_RD(sc,
3815 : : BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) +
3816 : : 8);
3817 : : row3 =
3818 : 0 : REG_RD(sc,
3819 : : BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) +
3820 : : 12);
3821 : :
3822 [ # # ]: 0 : if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) {
3823 : 0 : PMD_DRV_LOG(ERR, sc,
3824 : : "CSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x",
3825 : : i, row3, row2, row1, row0);
3826 : 0 : rc++;
3827 : : } else {
3828 : : break;
3829 : : }
3830 : : }
3831 : :
3832 : : /* USTORM */
3833 : 0 : last_idx =
3834 : 0 : REG_RD8(sc, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_INDEX_OFFSET);
3835 [ # # ]: 0 : if (last_idx) {
3836 : 0 : PMD_DRV_LOG(ERR, sc, "USTORM_ASSERT_LIST_INDEX 0x%x", last_idx);
3837 : : }
3838 : :
3839 : : /* print the asserts */
3840 [ # # ]: 0 : for (i = 0; i < STORM_ASSERT_ARRAY_SIZE; i++) {
3841 : :
3842 : : row0 =
3843 : 0 : REG_RD(sc,
3844 : : BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i));
3845 : : row1 =
3846 : 0 : REG_RD(sc,
3847 : : BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) +
3848 : : 4);
3849 : : row2 =
3850 : 0 : REG_RD(sc,
3851 : : BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) +
3852 : : 8);
3853 : : row3 =
3854 : 0 : REG_RD(sc,
3855 : : BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) +
3856 : : 12);
3857 : :
3858 [ # # ]: 0 : if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) {
3859 : 0 : PMD_DRV_LOG(ERR, sc,
3860 : : "USTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x",
3861 : : i, row3, row2, row1, row0);
3862 : 0 : rc++;
3863 : : } else {
3864 : : break;
3865 : : }
3866 : : }
3867 : :
3868 : 0 : return rc;
3869 : : }
3870 : :
3871 : 0 : static void bnx2x_attn_int_deasserted3(struct bnx2x_softc *sc, uint32_t attn)
3872 : : {
3873 : 0 : int func = SC_FUNC(sc);
3874 : : uint32_t val;
3875 : :
3876 [ # # ]: 0 : if (attn & EVEREST_GEN_ATTN_IN_USE_MASK) {
3877 : :
3878 [ # # ]: 0 : if (attn & BNX2X_PMF_LINK_ASSERT(sc)) {
3879 : :
3880 : 0 : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_12 + func * 4, 0);
3881 : 0 : bnx2x_read_mf_cfg(sc);
3882 : 0 : sc->devinfo.mf_info.mf_config[SC_VN(sc)] =
3883 : 0 : MFCFG_RD(sc,
3884 : : func_mf_config[SC_ABS_FUNC(sc)].config);
3885 : : val =
3886 [ # # # # ]: 0 : SHMEM_RD(sc, func_mb[SC_FW_MB_IDX(sc)].drv_status);
3887 : :
3888 [ # # ]: 0 : if (val & DRV_STATUS_DCC_EVENT_MASK)
3889 : 0 : bnx2x_dcc_event(sc,
3890 : : (val &
3891 : : DRV_STATUS_DCC_EVENT_MASK));
3892 : :
3893 [ # # ]: 0 : if (val & DRV_STATUS_SET_MF_BW)
3894 : : bnx2x_set_mf_bw(sc);
3895 : :
3896 [ # # ]: 0 : if (val & DRV_STATUS_DRV_INFO_REQ)
3897 : 0 : bnx2x_handle_drv_info_req(sc);
3898 : :
3899 [ # # # # ]: 0 : if ((sc->port.pmf == 0) && (val & DRV_STATUS_PMF))
3900 : 0 : bnx2x_pmf_update(sc);
3901 : :
3902 [ # # ]: 0 : if (val & DRV_STATUS_EEE_NEGOTIATION_RESULTS)
3903 : : bnx2x_handle_eee_event(sc);
3904 : :
3905 [ # # ]: 0 : if (sc->link_vars.periodic_flags &
3906 : : ELINK_PERIODIC_FLAGS_LINK_EVENT) {
3907 : : /* sync with link */
3908 : 0 : bnx2x_acquire_phy_lock(sc);
3909 : 0 : sc->link_vars.periodic_flags &=
3910 : : ~ELINK_PERIODIC_FLAGS_LINK_EVENT;
3911 : : bnx2x_release_phy_lock(sc);
3912 [ # # # # ]: 0 : if (IS_MF(sc)) {
3913 : 0 : bnx2x_link_sync_notify(sc);
3914 : : }
3915 : 0 : bnx2x_link_report(sc);
3916 : : }
3917 : :
3918 : : /*
3919 : : * Always call it here: bnx2x_link_report() will
3920 : : * prevent the link indication duplication.
3921 : : */
3922 : 0 : bnx2x_link_status_update(sc);
3923 : :
3924 [ # # ]: 0 : } else if (attn & BNX2X_MC_ASSERT_BITS) {
3925 : :
3926 : 0 : PMD_DRV_LOG(ERR, sc, "MC assert!");
3927 : 0 : bnx2x_mc_assert(sc);
3928 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_10, 0);
3929 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_9, 0);
3930 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_8, 0);
3931 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_7, 0);
3932 : 0 : rte_panic("MC assert!");
3933 : :
3934 [ # # ]: 0 : } else if (attn & BNX2X_MCP_ASSERT) {
3935 : :
3936 : 0 : PMD_DRV_LOG(ERR, sc, "MCP assert!");
3937 : : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_11, 0);
3938 : :
3939 : : } else {
3940 : 0 : PMD_DRV_LOG(ERR, sc,
3941 : : "Unknown HW assert! (attn 0x%08x)", attn);
3942 : : }
3943 : : }
3944 : :
3945 [ # # ]: 0 : if (attn & EVEREST_LATCHED_ATTN_IN_USE_MASK) {
3946 : 0 : PMD_DRV_LOG(ERR, sc, "LATCHED attention 0x%08x (masked)", attn);
3947 [ # # ]: 0 : if (attn & BNX2X_GRC_TIMEOUT) {
3948 : : val = REG_RD(sc, MISC_REG_GRC_TIMEOUT_ATTN);
3949 : 0 : PMD_DRV_LOG(ERR, sc, "GRC time-out 0x%08x", val);
3950 : : }
3951 [ # # ]: 0 : if (attn & BNX2X_GRC_RSV) {
3952 : : val = REG_RD(sc, MISC_REG_GRC_RSV_ATTN);
3953 : 0 : PMD_DRV_LOG(ERR, sc, "GRC reserved 0x%08x", val);
3954 : : }
3955 : : REG_WR(sc, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0x7ff);
3956 : : }
3957 : 0 : }
3958 : :
3959 : 0 : static void bnx2x_attn_int_deasserted2(struct bnx2x_softc *sc, uint32_t attn)
3960 : : {
3961 : 0 : int port = SC_PORT(sc);
3962 : : int reg_offset;
3963 : : uint32_t val0, mask0, val1, mask1;
3964 : : uint32_t val;
3965 : :
3966 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) {
3967 : : val = REG_RD(sc, CFC_REG_CFC_INT_STS_CLR);
3968 : 0 : PMD_DRV_LOG(ERR, sc, "CFC hw attention 0x%08x", val);
3969 : : /* CFC error attention */
3970 [ # # ]: 0 : if (val & 0x2) {
3971 : 0 : PMD_DRV_LOG(ERR, sc, "FATAL error from CFC");
3972 : : }
3973 : : }
3974 : :
3975 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) {
3976 : : val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_0);
3977 : 0 : PMD_DRV_LOG(ERR, sc, "PXP hw attention-0 0x%08x", val);
3978 : : /* RQ_USDMDP_FIFO_OVERFLOW */
3979 [ # # ]: 0 : if (val & 0x18000) {
3980 : 0 : PMD_DRV_LOG(ERR, sc, "FATAL error from PXP");
3981 : : }
3982 : :
3983 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
3984 : : val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_1);
3985 : 0 : PMD_DRV_LOG(ERR, sc, "PXP hw attention-1 0x%08x", val);
3986 : : }
3987 : : }
3988 : : #define PXP2_EOP_ERROR_BIT PXP2_PXP2_INT_STS_CLR_0_REG_WR_PGLUE_EOP_ERROR
3989 : : #define AEU_PXP2_HW_INT_BIT AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT
3990 : :
3991 [ # # ]: 0 : if (attn & AEU_PXP2_HW_INT_BIT) {
3992 : : /* CQ47854 workaround do not panic on
3993 : : * PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR
3994 : : */
3995 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
3996 : : mask0 = REG_RD(sc, PXP2_REG_PXP2_INT_MASK_0);
3997 : : val1 = REG_RD(sc, PXP2_REG_PXP2_INT_STS_1);
3998 : : mask1 = REG_RD(sc, PXP2_REG_PXP2_INT_MASK_1);
3999 : : val0 = REG_RD(sc, PXP2_REG_PXP2_INT_STS_0);
4000 : : /*
4001 : : * If the only PXP2_EOP_ERROR_BIT is set in
4002 : : * STS0 and STS1 - clear it
4003 : : *
4004 : : * probably we lose additional attentions between
4005 : : * STS0 and STS_CLR0, in this case user will not
4006 : : * be notified about them
4007 : : */
4008 [ # # ]: 0 : if (val0 & mask0 & PXP2_EOP_ERROR_BIT &&
4009 [ # # ]: 0 : !(val1 & mask1))
4010 : : val0 = REG_RD(sc, PXP2_REG_PXP2_INT_STS_CLR_0);
4011 : :
4012 : : /* print the register, since no one can restore it */
4013 : 0 : PMD_DRV_LOG(ERR, sc,
4014 : : "PXP2_REG_PXP2_INT_STS_CLR_0 0x%08x", val0);
4015 : :
4016 : : /*
4017 : : * if PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR
4018 : : * then notify
4019 : : */
4020 [ # # ]: 0 : if (val0 & PXP2_EOP_ERROR_BIT) {
4021 : 0 : PMD_DRV_LOG(ERR, sc, "PXP2_WR_PGLUE_EOP_ERROR");
4022 : :
4023 : : /*
4024 : : * if only PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR is
4025 : : * set then clear attention from PXP2 block without panic
4026 : : */
4027 [ # # ]: 0 : if (((val0 & mask0) == PXP2_EOP_ERROR_BIT) &&
4028 [ # # ]: 0 : ((val1 & mask1) == 0))
4029 : 0 : attn &= ~AEU_PXP2_HW_INT_BIT;
4030 : : }
4031 : : }
4032 : : }
4033 : :
4034 [ # # ]: 0 : if (attn & HW_INTERRUT_ASSERT_SET_2) {
4035 [ # # ]: 0 : reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_2 :
4036 : : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2);
4037 : :
4038 : 0 : val = REG_RD(sc, reg_offset);
4039 : 0 : val &= ~(attn & HW_INTERRUT_ASSERT_SET_2);
4040 : : REG_WR(sc, reg_offset, val);
4041 : :
4042 : 0 : PMD_DRV_LOG(ERR, sc,
4043 : : "FATAL HW block attention set2 0x%x",
4044 : : (uint32_t) (attn & HW_INTERRUT_ASSERT_SET_2));
4045 : 0 : rte_panic("HW block attention set2");
4046 : : }
4047 : 0 : }
4048 : :
4049 : 0 : static void bnx2x_attn_int_deasserted1(struct bnx2x_softc *sc, uint32_t attn)
4050 : : {
4051 : 0 : int port = SC_PORT(sc);
4052 : : int reg_offset;
4053 : : uint32_t val;
4054 : :
4055 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT) {
4056 : : val = REG_RD(sc, DORQ_REG_DORQ_INT_STS_CLR);
4057 : 0 : PMD_DRV_LOG(ERR, sc, "DB hw attention 0x%08x", val);
4058 : : /* DORQ discard attention */
4059 [ # # ]: 0 : if (val & 0x2) {
4060 : 0 : PMD_DRV_LOG(ERR, sc, "FATAL error from DORQ");
4061 : : }
4062 : : }
4063 : :
4064 [ # # ]: 0 : if (attn & HW_INTERRUT_ASSERT_SET_1) {
4065 [ # # ]: 0 : reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_1 :
4066 : : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1);
4067 : :
4068 : 0 : val = REG_RD(sc, reg_offset);
4069 : 0 : val &= ~(attn & HW_INTERRUT_ASSERT_SET_1);
4070 : : REG_WR(sc, reg_offset, val);
4071 : :
4072 : 0 : PMD_DRV_LOG(ERR, sc,
4073 : : "FATAL HW block attention set1 0x%08x",
4074 : : (uint32_t) (attn & HW_INTERRUT_ASSERT_SET_1));
4075 : 0 : rte_panic("HW block attention set1");
4076 : : }
4077 : 0 : }
4078 : :
4079 : 0 : static void bnx2x_attn_int_deasserted0(struct bnx2x_softc *sc, uint32_t attn)
4080 : : {
4081 : 0 : int port = SC_PORT(sc);
4082 : : int reg_offset;
4083 : : uint32_t val;
4084 : :
4085 [ # # ]: 0 : reg_offset = (port) ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
4086 : : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0;
4087 : :
4088 [ # # ]: 0 : if (attn & AEU_INPUTS_ATTN_BITS_SPIO5) {
4089 : 0 : val = REG_RD(sc, reg_offset);
4090 : 0 : val &= ~AEU_INPUTS_ATTN_BITS_SPIO5;
4091 : : REG_WR(sc, reg_offset, val);
4092 : :
4093 : 0 : PMD_DRV_LOG(WARNING, sc, "SPIO5 hw attention");
4094 : :
4095 : : /* Fan failure attention */
4096 : 0 : elink_hw_reset_phy(&sc->link_params);
4097 : 0 : bnx2x_fan_failure(sc);
4098 : : }
4099 : :
4100 [ # # # # ]: 0 : if ((attn & sc->link_vars.aeu_int_mask) && sc->port.pmf) {
4101 : 0 : bnx2x_acquire_phy_lock(sc);
4102 : 0 : elink_handle_module_detect_int(&sc->link_params);
4103 : : bnx2x_release_phy_lock(sc);
4104 : : }
4105 : :
4106 [ # # ]: 0 : if (attn & HW_INTERRUT_ASSERT_SET_0) {
4107 : 0 : val = REG_RD(sc, reg_offset);
4108 : 0 : val &= ~(attn & HW_INTERRUT_ASSERT_SET_0);
4109 : : REG_WR(sc, reg_offset, val);
4110 : :
4111 : 0 : rte_panic("FATAL HW block attention set0 0x%lx",
4112 : : (attn & (unsigned long)HW_INTERRUT_ASSERT_SET_0));
4113 : : }
4114 : 0 : }
4115 : :
4116 : 0 : static void bnx2x_attn_int_deasserted(struct bnx2x_softc *sc, uint32_t deasserted)
4117 : : {
4118 : : struct attn_route attn;
4119 : : struct attn_route *group_mask;
4120 : 0 : int port = SC_PORT(sc);
4121 : : int index;
4122 : : uint32_t reg_addr;
4123 : : uint32_t val;
4124 : : uint32_t aeu_mask;
4125 : 0 : uint8_t global = FALSE;
4126 : :
4127 : : /*
4128 : : * Need to take HW lock because MCP or other port might also
4129 : : * try to handle this event.
4130 : : */
4131 : 0 : bnx2x_acquire_alr(sc);
4132 : :
4133 [ # # ]: 0 : if (bnx2x_chk_parity_attn(sc, &global, TRUE)) {
4134 : 0 : sc->recovery_state = BNX2X_RECOVERY_INIT;
4135 : :
4136 : : /* disable HW interrupts */
4137 : 0 : bnx2x_int_disable(sc);
4138 : : bnx2x_release_alr(sc);
4139 : 0 : return;
4140 : : }
4141 : :
4142 : 0 : attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port * 4);
4143 : 0 : attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port * 4);
4144 : 0 : attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port * 4);
4145 : 0 : attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port * 4);
4146 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
4147 : : attn.sig[4] =
4148 : 0 : REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_5_FUNC_0 + port * 4);
4149 : : } else {
4150 : : attn.sig[4] = 0;
4151 : : }
4152 : :
4153 [ # # ]: 0 : for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) {
4154 [ # # ]: 0 : if (deasserted & (1 << index)) {
4155 : : group_mask = &sc->attn_group[index];
4156 : :
4157 : 0 : bnx2x_attn_int_deasserted4(sc,
4158 : : attn.
4159 : 0 : sig[4] & group_mask->sig[4]);
4160 : 0 : bnx2x_attn_int_deasserted3(sc,
4161 : : attn.
4162 : 0 : sig[3] & group_mask->sig[3]);
4163 : 0 : bnx2x_attn_int_deasserted1(sc,
4164 : : attn.
4165 : 0 : sig[1] & group_mask->sig[1]);
4166 : 0 : bnx2x_attn_int_deasserted2(sc,
4167 : : attn.
4168 : 0 : sig[2] & group_mask->sig[2]);
4169 : 0 : bnx2x_attn_int_deasserted0(sc,
4170 : : attn.
4171 : 0 : sig[0] & group_mask->sig[0]);
4172 : : }
4173 : : }
4174 : :
4175 : : bnx2x_release_alr(sc);
4176 : :
4177 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
4178 : 0 : reg_addr = (HC_REG_COMMAND_REG + port * 32 +
4179 : : COMMAND_REG_ATTN_BITS_CLR);
4180 : : } else {
4181 : : reg_addr = (BAR_IGU_INTMEM + IGU_CMD_ATTN_BIT_CLR_UPPER * 8);
4182 : : }
4183 : :
4184 : 0 : val = ~deasserted;
4185 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, sc,
4186 : : "about to mask 0x%08x at %s addr 0x%08x", val,
4187 : : (sc->devinfo.int_block == INT_BLOCK_HC) ? "HC" : "IGU",
4188 : : reg_addr);
4189 : 0 : REG_WR(sc, reg_addr, val);
4190 : :
4191 [ # # ]: 0 : if (~sc->attn_state & deasserted) {
4192 : 0 : PMD_DRV_LOG(ERR, sc, "IGU error");
4193 : : }
4194 : :
4195 [ # # ]: 0 : reg_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 :
4196 : : MISC_REG_AEU_MASK_ATTN_FUNC_0;
4197 : :
4198 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port);
4199 : :
4200 : 0 : aeu_mask = REG_RD(sc, reg_addr);
4201 : :
4202 : 0 : aeu_mask |= (deasserted & 0x3ff);
4203 : :
4204 : : REG_WR(sc, reg_addr, aeu_mask);
4205 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port);
4206 : :
4207 : 0 : sc->attn_state &= ~deasserted;
4208 : : }
4209 : :
4210 : 0 : static void bnx2x_attn_int(struct bnx2x_softc *sc)
4211 : : {
4212 : : /* read local copy of bits */
4213 : 0 : uint32_t attn_bits = le32toh(sc->def_sb->atten_status_block.attn_bits);
4214 : : uint32_t attn_ack =
4215 : 0 : le32toh(sc->def_sb->atten_status_block.attn_bits_ack);
4216 : 0 : uint32_t attn_state = sc->attn_state;
4217 : :
4218 : : /* look for changed bits */
4219 : 0 : uint32_t asserted = attn_bits & ~attn_ack & ~attn_state;
4220 : 0 : uint32_t deasserted = ~attn_bits & attn_ack & attn_state;
4221 : :
4222 : 0 : PMD_DRV_LOG(DEBUG, sc,
4223 : : "attn_bits 0x%08x attn_ack 0x%08x asserted 0x%08x deasserted 0x%08x",
4224 : : attn_bits, attn_ack, asserted, deasserted);
4225 : :
4226 [ # # ]: 0 : if (~(attn_bits ^ attn_ack) & (attn_bits ^ attn_state)) {
4227 : 0 : PMD_DRV_LOG(ERR, sc, "BAD attention state");
4228 : : }
4229 : :
4230 : : /* handle bits that were raised */
4231 [ # # ]: 0 : if (asserted) {
4232 : 0 : bnx2x_attn_int_asserted(sc, asserted);
4233 : : }
4234 : :
4235 [ # # ]: 0 : if (deasserted) {
4236 : 0 : bnx2x_attn_int_deasserted(sc, deasserted);
4237 : : }
4238 : 0 : }
4239 : :
4240 : : static uint16_t bnx2x_update_dsb_idx(struct bnx2x_softc *sc)
4241 : : {
4242 : 0 : struct host_sp_status_block *def_sb = sc->def_sb;
4243 : : uint16_t rc = 0;
4244 : :
4245 [ # # # # ]: 0 : if (!def_sb)
4246 : : return 0;
4247 : :
4248 : : mb(); /* status block is written to by the chip */
4249 : :
4250 [ # # # # ]: 0 : if (sc->def_att_idx != def_sb->atten_status_block.attn_bits_index) {
4251 : 0 : sc->def_att_idx = def_sb->atten_status_block.attn_bits_index;
4252 : : rc |= BNX2X_DEF_SB_ATT_IDX;
4253 : : }
4254 : :
4255 [ # # # # ]: 0 : if (sc->def_idx != def_sb->sp_sb.running_index) {
4256 : 0 : sc->def_idx = def_sb->sp_sb.running_index;
4257 : 0 : rc |= BNX2X_DEF_SB_IDX;
4258 : : }
4259 : :
4260 : : mb();
4261 : :
4262 : 0 : return rc;
4263 : : }
4264 : :
4265 : : static struct ecore_queue_sp_obj *bnx2x_cid_to_q_obj(struct bnx2x_softc *sc,
4266 : : uint32_t cid)
4267 : : {
4268 : 0 : return &sc->sp_objs[CID_TO_FP(cid, sc)].q_obj;
4269 : : }
4270 : :
4271 : 0 : static void bnx2x_handle_mcast_eqe(struct bnx2x_softc *sc)
4272 : : {
4273 : : struct ecore_mcast_ramrod_params rparam;
4274 : : int rc;
4275 : :
4276 : : memset(&rparam, 0, sizeof(rparam));
4277 : :
4278 : 0 : rparam.mcast_obj = &sc->mcast_obj;
4279 : :
4280 : : /* clear pending state for the last command */
4281 : 0 : sc->mcast_obj.raw.clear_pending(&sc->mcast_obj.raw);
4282 : :
4283 : : /* if there are pending mcast commands - send them */
4284 [ # # ]: 0 : if (sc->mcast_obj.check_pending(&sc->mcast_obj)) {
4285 : 0 : rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_CONT);
4286 [ # # ]: 0 : if (rc < 0) {
4287 : 0 : PMD_DRV_LOG(INFO, sc,
4288 : : "Failed to send pending mcast commands (%d)",
4289 : : rc);
4290 : : }
4291 : : }
4292 : 0 : }
4293 : :
4294 : : static void
4295 : 0 : bnx2x_handle_classification_eqe(struct bnx2x_softc *sc, union event_ring_elem *elem)
4296 : : {
4297 : 0 : uint32_t ramrod_flags = 0;
4298 : : int rc = 0;
4299 [ # # # ]: 0 : uint32_t cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
4300 : : struct ecore_vlan_mac_obj *vlan_mac_obj;
4301 : :
4302 : : /* always push next commands out, don't wait here */
4303 : : rte_bit_relaxed_set32(RAMROD_CONT, &ramrod_flags);
4304 : :
4305 [ # # # ]: 0 : switch (le32toh(elem->message.data.eth_event.echo) >> BNX2X_SWCID_SHIFT) {
4306 : 0 : case ECORE_FILTER_MAC_PENDING:
4307 : 0 : PMD_DRV_LOG(DEBUG, sc, "Got SETUP_MAC completions");
4308 : 0 : vlan_mac_obj = &sc->sp_objs[cid].mac_obj;
4309 : : break;
4310 : :
4311 : 0 : case ECORE_FILTER_MCAST_PENDING:
4312 : 0 : PMD_DRV_LOG(DEBUG, sc, "Got SETUP_MCAST completions");
4313 : 0 : bnx2x_handle_mcast_eqe(sc);
4314 : 0 : return;
4315 : :
4316 : 0 : default:
4317 : 0 : PMD_DRV_LOG(NOTICE, sc, "Unsupported classification command: %d",
4318 : : elem->message.data.eth_event.echo);
4319 : 0 : return;
4320 : : }
4321 : :
4322 : 0 : rc = vlan_mac_obj->complete(sc, vlan_mac_obj, elem, &ramrod_flags);
4323 : :
4324 [ # # ]: 0 : if (rc < 0) {
4325 : 0 : PMD_DRV_LOG(NOTICE, sc,
4326 : : "Failed to schedule new commands (%d)", rc);
4327 [ # # ]: 0 : } else if (rc > 0) {
4328 : 0 : PMD_DRV_LOG(DEBUG, sc, "Scheduled next pending commands...");
4329 : : }
4330 : : }
4331 : :
4332 : : static void bnx2x_handle_rx_mode_eqe(struct bnx2x_softc *sc)
4333 : : {
4334 : : rte_bit_relaxed_clear32(ECORE_FILTER_RX_MODE_PENDING, &sc->sp_state);
4335 : :
4336 : : /* send rx_mode command again if was requested */
4337 [ # # ]: 0 : if (rte_bit_relaxed_test_and_clear32(ECORE_FILTER_RX_MODE_SCHED,
4338 : : &sc->sp_state))
4339 : 0 : bnx2x_set_storm_rx_mode(sc);
4340 : : }
4341 : :
4342 : : static void bnx2x_update_eq_prod(struct bnx2x_softc *sc, uint16_t prod)
4343 : : {
4344 : 0 : storm_memset_eq_prod(sc, prod, SC_FUNC(sc));
4345 : : wmb(); /* keep prod updates ordered */
4346 : : }
4347 : :
4348 : 0 : static void bnx2x_eq_int(struct bnx2x_softc *sc)
4349 : : {
4350 : : uint16_t hw_cons, sw_cons, sw_prod;
4351 : : union event_ring_elem *elem;
4352 : : uint8_t echo;
4353 : : uint32_t cid;
4354 : : uint8_t opcode;
4355 : : int spqe_cnt = 0;
4356 : : struct ecore_queue_sp_obj *q_obj;
4357 : 0 : struct ecore_func_sp_obj *f_obj = &sc->func_obj;
4358 : 0 : struct ecore_raw_obj *rss_raw = &sc->rss_conf_obj.raw;
4359 : :
4360 : 0 : hw_cons = le16toh(*sc->eq_cons_sb);
4361 : :
4362 : : /*
4363 : : * The hw_cons range is 1-255, 257 - the sw_cons range is 0-254, 256.
4364 : : * when we get to the next-page we need to adjust so the loop
4365 : : * condition below will be met. The next element is the size of a
4366 : : * regular element and hence incrementing by 1
4367 : : */
4368 [ # # ]: 0 : if ((hw_cons & EQ_DESC_MAX_PAGE) == EQ_DESC_MAX_PAGE) {
4369 : 0 : hw_cons++;
4370 : : }
4371 : :
4372 : : /*
4373 : : * This function may never run in parallel with itself for a
4374 : : * specific sc and no need for a read memory barrier here.
4375 : : */
4376 : 0 : sw_cons = sc->eq_cons;
4377 : 0 : sw_prod = sc->eq_prod;
4378 : :
4379 : 0 : for (;
4380 [ # # ]: 0 : sw_cons != hw_cons;
4381 [ # # ]: 0 : sw_prod = NEXT_EQ_IDX(sw_prod), sw_cons = NEXT_EQ_IDX(sw_cons)) {
4382 : :
4383 : 0 : elem = &sc->eq[EQ_DESC(sw_cons)];
4384 : :
4385 : : /* elem CID originates from FW, actually LE */
4386 : 0 : cid = SW_CID(elem->message.data.cfc_del_event.cid);
4387 : 0 : opcode = elem->message.opcode;
4388 : :
4389 : : /* handle eq element */
4390 [ # # # # : 0 : switch (opcode) {
# # # #
# ]
4391 : 0 : case EVENT_RING_OPCODE_STAT_QUERY:
4392 : : PMD_DEBUG_PERIODIC_LOG(DEBUG, sc, "got statistics completion event %d",
4393 : : sc->stats_comp++);
4394 : : /* nothing to do with stats comp */
4395 : 0 : goto next_spqe;
4396 : :
4397 : 0 : case EVENT_RING_OPCODE_CFC_DEL:
4398 : : /* handle according to cid range */
4399 : : /* we may want to verify here that the sc state is HALTING */
4400 : 0 : PMD_DRV_LOG(DEBUG, sc, "got delete ramrod for MULTI[%d]",
4401 : : cid);
4402 : : q_obj = bnx2x_cid_to_q_obj(sc, cid);
4403 [ # # ]: 0 : if (q_obj->complete_cmd(sc, q_obj, ECORE_Q_CMD_CFC_DEL)) {
4404 : : break;
4405 : : }
4406 : 0 : goto next_spqe;
4407 : :
4408 : 0 : case EVENT_RING_OPCODE_STOP_TRAFFIC:
4409 : 0 : PMD_DRV_LOG(DEBUG, sc, "got STOP TRAFFIC");
4410 [ # # ]: 0 : if (f_obj->complete_cmd(sc, f_obj, ECORE_F_CMD_TX_STOP)) {
4411 : : break;
4412 : : }
4413 : 0 : goto next_spqe;
4414 : :
4415 : 0 : case EVENT_RING_OPCODE_START_TRAFFIC:
4416 : 0 : PMD_DRV_LOG(DEBUG, sc, "got START TRAFFIC");
4417 [ # # ]: 0 : if (f_obj->complete_cmd
4418 : : (sc, f_obj, ECORE_F_CMD_TX_START)) {
4419 : : break;
4420 : : }
4421 : 0 : goto next_spqe;
4422 : :
4423 : 0 : case EVENT_RING_OPCODE_FUNCTION_UPDATE:
4424 : 0 : echo = elem->message.data.function_update_event.echo;
4425 [ # # ]: 0 : if (echo == SWITCH_UPDATE) {
4426 : 0 : PMD_DRV_LOG(DEBUG, sc,
4427 : : "got FUNC_SWITCH_UPDATE ramrod");
4428 [ # # ]: 0 : if (f_obj->complete_cmd(sc, f_obj,
4429 : : ECORE_F_CMD_SWITCH_UPDATE))
4430 : : {
4431 : : break;
4432 : : }
4433 : : } else {
4434 : 0 : PMD_DRV_LOG(DEBUG, sc,
4435 : : "AFEX: ramrod completed FUNCTION_UPDATE");
4436 : 0 : f_obj->complete_cmd(sc, f_obj,
4437 : : ECORE_F_CMD_AFEX_UPDATE);
4438 : : }
4439 : 0 : goto next_spqe;
4440 : :
4441 : 0 : case EVENT_RING_OPCODE_FORWARD_SETUP:
4442 : 0 : q_obj = &bnx2x_fwd_sp_obj(sc, q_obj);
4443 [ # # ]: 0 : if (q_obj->complete_cmd(sc, q_obj,
4444 : : ECORE_Q_CMD_SETUP_TX_ONLY)) {
4445 : : break;
4446 : : }
4447 : 0 : goto next_spqe;
4448 : :
4449 : 0 : case EVENT_RING_OPCODE_FUNCTION_START:
4450 : 0 : PMD_DRV_LOG(DEBUG, sc, "got FUNC_START ramrod");
4451 [ # # ]: 0 : if (f_obj->complete_cmd(sc, f_obj, ECORE_F_CMD_START)) {
4452 : : break;
4453 : : }
4454 : 0 : goto next_spqe;
4455 : :
4456 : 0 : case EVENT_RING_OPCODE_FUNCTION_STOP:
4457 : 0 : PMD_DRV_LOG(DEBUG, sc, "got FUNC_STOP ramrod");
4458 [ # # ]: 0 : if (f_obj->complete_cmd(sc, f_obj, ECORE_F_CMD_STOP)) {
4459 : : break;
4460 : : }
4461 : 0 : goto next_spqe;
4462 : : }
4463 : :
4464 [ # # # # : 0 : switch (opcode | sc->state) {
# ]
4465 : 0 : case (EVENT_RING_OPCODE_RSS_UPDATE_RULES | BNX2X_STATE_OPEN):
4466 : : case (EVENT_RING_OPCODE_RSS_UPDATE_RULES | BNX2X_STATE_OPENING_WAITING_PORT):
4467 : 0 : cid =
4468 : 0 : elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
4469 : 0 : PMD_DRV_LOG(DEBUG, sc, "got RSS_UPDATE ramrod. CID %d",
4470 : : cid);
4471 : 0 : rss_raw->clear_pending(rss_raw);
4472 : 0 : break;
4473 : :
4474 : 0 : case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_OPEN):
4475 : : case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_DIAG):
4476 : : case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_CLOSING_WAITING_HALT):
4477 : : case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_OPEN):
4478 : : case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_DIAG):
4479 : : case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_CLOSING_WAITING_HALT):
4480 : 0 : PMD_DRV_LOG(DEBUG, sc,
4481 : : "got (un)set mac ramrod");
4482 : 0 : bnx2x_handle_classification_eqe(sc, elem);
4483 : 0 : break;
4484 : :
4485 : 0 : case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_OPEN):
4486 : : case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_DIAG):
4487 : : case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_CLOSING_WAITING_HALT):
4488 : 0 : PMD_DRV_LOG(DEBUG, sc,
4489 : : "got mcast ramrod");
4490 : 0 : bnx2x_handle_mcast_eqe(sc);
4491 : 0 : break;
4492 : :
4493 : 0 : case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_OPEN):
4494 : : case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_DIAG):
4495 : : case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_CLOSING_WAITING_HALT):
4496 : 0 : PMD_DRV_LOG(DEBUG, sc,
4497 : : "got rx_mode ramrod");
4498 : : bnx2x_handle_rx_mode_eqe(sc);
4499 : : break;
4500 : :
4501 : 0 : default:
4502 : : /* unknown event log error and continue */
4503 : 0 : PMD_DRV_LOG(INFO, sc, "Unknown EQ event %d, sc->state 0x%x",
4504 : : elem->message.opcode, sc->state);
4505 : : }
4506 : :
4507 : 0 : next_spqe:
4508 [ # # ]: 0 : spqe_cnt++;
4509 : : } /* for */
4510 : :
4511 : : mb();
4512 : 0 : atomic_add_acq_long(&sc->eq_spq_left, spqe_cnt);
4513 : :
4514 : 0 : sc->eq_cons = sw_cons;
4515 : 0 : sc->eq_prod = sw_prod;
4516 : :
4517 : : /* make sure that above mem writes were issued towards the memory */
4518 : : wmb();
4519 : :
4520 : : /* update producer */
4521 : 0 : bnx2x_update_eq_prod(sc, sc->eq_prod);
4522 : 0 : }
4523 : :
4524 : 0 : static int bnx2x_handle_sp_tq(struct bnx2x_softc *sc)
4525 : : {
4526 : : uint16_t status;
4527 : : int rc = 0;
4528 : :
4529 : 0 : PMD_DRV_LOG(DEBUG, sc, "---> SP TASK <---");
4530 : :
4531 : : /* what work needs to be performed? */
4532 : : status = bnx2x_update_dsb_idx(sc);
4533 : :
4534 : 0 : PMD_DRV_LOG(DEBUG, sc, "dsb status 0x%04x", status);
4535 : :
4536 : : /* HW attentions */
4537 [ # # ]: 0 : if (status & BNX2X_DEF_SB_ATT_IDX) {
4538 : 0 : PMD_DRV_LOG(DEBUG, sc, "---> ATTN INTR <---");
4539 : 0 : bnx2x_attn_int(sc);
4540 : 0 : status &= ~BNX2X_DEF_SB_ATT_IDX;
4541 : : rc = 1;
4542 : : }
4543 : :
4544 : : /* SP events: STAT_QUERY and others */
4545 [ # # ]: 0 : if (status & BNX2X_DEF_SB_IDX) {
4546 : : /* handle EQ completions */
4547 : 0 : PMD_DRV_LOG(DEBUG, sc, "---> EQ INTR <---");
4548 : 0 : bnx2x_eq_int(sc);
4549 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id, USTORM_ID,
4550 : 0 : le16toh(sc->def_idx), IGU_INT_NOP, 1);
4551 : 0 : status &= ~BNX2X_DEF_SB_IDX;
4552 : : }
4553 : :
4554 : : /* if status is non zero then something went wrong */
4555 [ # # ]: 0 : if (unlikely(status)) {
4556 : 0 : PMD_DRV_LOG(INFO, sc,
4557 : : "Got an unknown SP interrupt! (0x%04x)", status);
4558 : : }
4559 : :
4560 : : /* ack status block only if something was actually handled */
4561 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id, ATTENTION_ID,
4562 : 0 : le16toh(sc->def_att_idx), IGU_INT_ENABLE, 1);
4563 : :
4564 : 0 : return rc;
4565 : : }
4566 : :
4567 : 0 : static void bnx2x_handle_fp_tq(struct bnx2x_fastpath *fp)
4568 : : {
4569 : 0 : struct bnx2x_softc *sc = fp->sc;
4570 : : uint8_t more_rx = FALSE;
4571 : :
4572 : : /* Make sure FP is initialized */
4573 [ # # ]: 0 : if (!fp->sb_running_index)
4574 : : return;
4575 : :
4576 : : PMD_DEBUG_PERIODIC_LOG(DEBUG, sc,
4577 : : "---> FP TASK QUEUE (%d) <--", fp->index);
4578 : :
4579 : : /* update the fastpath index */
4580 : : bnx2x_update_fp_sb_idx(fp);
4581 : :
4582 [ # # ]: 0 : if (rte_atomic32_read(&sc->scan_fp) == 1) {
4583 [ # # ]: 0 : if (bnx2x_has_rx_work(fp)) {
4584 : 0 : more_rx = bnx2x_rxeof(sc, fp);
4585 : : }
4586 : :
4587 [ # # ]: 0 : if (more_rx) {
4588 : : /* still more work to do */
4589 : : bnx2x_handle_fp_tq(fp);
4590 : : return;
4591 : : }
4592 : : /* We have completed slow path completion, clear the flag */
4593 : : rte_atomic32_set(&sc->scan_fp, 0);
4594 : : }
4595 : :
4596 : 0 : bnx2x_ack_sb(sc, fp->igu_sb_id, USTORM_ID,
4597 : 0 : le16toh(fp->fp_hc_idx), IGU_INT_ENABLE, 1);
4598 : : }
4599 : :
4600 : : /*
4601 : : * Legacy interrupt entry point.
4602 : : *
4603 : : * Verifies that the controller generated the interrupt and
4604 : : * then calls a separate routine to handle the various
4605 : : * interrupt causes: link, RX, and TX.
4606 : : */
4607 : 0 : int bnx2x_intr_legacy(struct bnx2x_softc *sc)
4608 : : {
4609 : : struct bnx2x_fastpath *fp;
4610 : : uint32_t status, mask;
4611 : : int i, rc = 0;
4612 : :
4613 : : /*
4614 : : * 0 for ustorm, 1 for cstorm
4615 : : * the bits returned from ack_int() are 0-15
4616 : : * bit 0 = attention status block
4617 : : * bit 1 = fast path status block
4618 : : * a mask of 0x2 or more = tx/rx event
4619 : : * a mask of 1 = slow path event
4620 : : */
4621 : :
4622 : : status = bnx2x_ack_int(sc);
4623 : :
4624 : : /* the interrupt is not for us */
4625 [ # # ]: 0 : if (unlikely(status == 0)) {
4626 : : return 0;
4627 : : }
4628 : :
4629 : : PMD_DEBUG_PERIODIC_LOG(DEBUG, sc, "Interrupt status 0x%04x", status);
4630 : : //bnx2x_dump_status_block(sc);
4631 : :
4632 [ # # ]: 0 : FOR_EACH_ETH_QUEUE(sc, i) {
4633 : 0 : fp = &sc->fp[i];
4634 : 0 : mask = (0x2 << (fp->index + CNIC_SUPPORT(sc)));
4635 [ # # ]: 0 : if (status & mask) {
4636 : : /* acknowledge and disable further fastpath interrupts */
4637 : 0 : bnx2x_ack_sb(sc, fp->igu_sb_id, USTORM_ID,
4638 : : 0, IGU_INT_DISABLE, 0);
4639 : 0 : bnx2x_handle_fp_tq(fp);
4640 : 0 : status &= ~mask;
4641 : : }
4642 : : }
4643 : :
4644 [ # # ]: 0 : if (unlikely(status & 0x1)) {
4645 : : /* acknowledge and disable further slowpath interrupts */
4646 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id, USTORM_ID,
4647 : : 0, IGU_INT_DISABLE, 0);
4648 : 0 : rc = bnx2x_handle_sp_tq(sc);
4649 : 0 : status &= ~0x1;
4650 : : }
4651 : :
4652 [ # # ]: 0 : if (unlikely(status)) {
4653 : 0 : PMD_DRV_LOG(WARNING, sc,
4654 : : "Unexpected fastpath status (0x%08x)!", status);
4655 : : }
4656 : :
4657 : : return rc;
4658 : : }
4659 : :
4660 : : static int bnx2x_init_hw_common_chip(struct bnx2x_softc *sc);
4661 : : static int bnx2x_init_hw_common(struct bnx2x_softc *sc);
4662 : : static int bnx2x_init_hw_port(struct bnx2x_softc *sc);
4663 : : static int bnx2x_init_hw_func(struct bnx2x_softc *sc);
4664 : : static void bnx2x_reset_common(struct bnx2x_softc *sc);
4665 : : static void bnx2x_reset_port(struct bnx2x_softc *sc);
4666 : : static void bnx2x_reset_func(struct bnx2x_softc *sc);
4667 : : static int bnx2x_init_firmware(struct bnx2x_softc *sc);
4668 : : static void bnx2x_release_firmware(struct bnx2x_softc *sc);
4669 : :
4670 : : static struct
4671 : : ecore_func_sp_drv_ops bnx2x_func_sp_drv = {
4672 : : .init_hw_cmn_chip = bnx2x_init_hw_common_chip,
4673 : : .init_hw_cmn = bnx2x_init_hw_common,
4674 : : .init_hw_port = bnx2x_init_hw_port,
4675 : : .init_hw_func = bnx2x_init_hw_func,
4676 : :
4677 : : .reset_hw_cmn = bnx2x_reset_common,
4678 : : .reset_hw_port = bnx2x_reset_port,
4679 : : .reset_hw_func = bnx2x_reset_func,
4680 : :
4681 : : .init_fw = bnx2x_init_firmware,
4682 : : .release_fw = bnx2x_release_firmware,
4683 : : };
4684 : :
4685 : 0 : static void bnx2x_init_func_obj(struct bnx2x_softc *sc)
4686 : : {
4687 : 0 : sc->dmae_ready = 0;
4688 : :
4689 : 0 : PMD_INIT_FUNC_TRACE(sc);
4690 : :
4691 : 0 : ecore_init_func_obj(sc,
4692 : : &sc->func_obj,
4693 : 0 : BNX2X_SP(sc, func_rdata),
4694 : : (rte_iova_t)BNX2X_SP_MAPPING(sc, func_rdata),
4695 : 0 : BNX2X_SP(sc, func_afex_rdata),
4696 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, func_afex_rdata),
4697 : : &bnx2x_func_sp_drv);
4698 : 0 : }
4699 : :
4700 : 0 : static int bnx2x_init_hw(struct bnx2x_softc *sc, uint32_t load_code)
4701 : : {
4702 : 0 : struct ecore_func_state_params func_params = { NULL };
4703 : : int rc;
4704 : :
4705 : 0 : PMD_INIT_FUNC_TRACE(sc);
4706 : :
4707 : : /* prepare the parameters for function state transitions */
4708 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
4709 : :
4710 : 0 : func_params.f_obj = &sc->func_obj;
4711 : 0 : func_params.cmd = ECORE_F_CMD_HW_INIT;
4712 : :
4713 : 0 : func_params.params.hw_init.load_phase = load_code;
4714 : :
4715 : : /*
4716 : : * Via a plethora of function pointers, we will eventually reach
4717 : : * bnx2x_init_hw_common(), bnx2x_init_hw_port(), or bnx2x_init_hw_func().
4718 : : */
4719 : 0 : rc = ecore_func_state_change(sc, &func_params);
4720 : :
4721 : 0 : return rc;
4722 : : }
4723 : :
4724 : : static void
4725 : 0 : bnx2x_fill(struct bnx2x_softc *sc, uint32_t addr, int fill, uint32_t len)
4726 : : {
4727 : : uint32_t i;
4728 : :
4729 [ # # # # ]: 0 : if (!(len % 4) && !(addr % 4)) {
4730 [ # # ]: 0 : for (i = 0; i < len; i += 4) {
4731 : 0 : REG_WR(sc, (addr + i), fill);
4732 : : }
4733 : : } else {
4734 [ # # ]: 0 : for (i = 0; i < len; i++) {
4735 : 0 : REG_WR8(sc, (addr + i), fill);
4736 : : }
4737 : : }
4738 : 0 : }
4739 : :
4740 : : /* writes FP SP data to FW - data_size in dwords */
4741 : : static void
4742 : : bnx2x_wr_fp_sb_data(struct bnx2x_softc *sc, int fw_sb_id, uint32_t * sb_data_p,
4743 : : uint32_t data_size)
4744 : : {
4745 : : uint32_t index;
4746 : :
4747 [ # # # # ]: 0 : for (index = 0; index < data_size; index++) {
4748 : 0 : REG_WR(sc,
4749 : : (BAR_CSTRORM_INTMEM +
4750 : : CSTORM_STATUS_BLOCK_DATA_OFFSET(fw_sb_id) +
4751 : : (sizeof(uint32_t) * index)), *(sb_data_p + index));
4752 : : }
4753 : : }
4754 : :
4755 : 0 : static void bnx2x_zero_fp_sb(struct bnx2x_softc *sc, int fw_sb_id)
4756 : : {
4757 : : struct hc_status_block_data_e2 sb_data_e2;
4758 : : struct hc_status_block_data_e1x sb_data_e1x;
4759 : : uint32_t *sb_data_p;
4760 : : uint32_t data_size = 0;
4761 : :
4762 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
4763 : : memset(&sb_data_e2, 0, sizeof(struct hc_status_block_data_e2));
4764 : : sb_data_e2.common.state = SB_DISABLED;
4765 : : sb_data_e2.common.p_func.vf_valid = FALSE;
4766 : : sb_data_p = (uint32_t *) & sb_data_e2;
4767 : : data_size = (sizeof(struct hc_status_block_data_e2) /
4768 : : sizeof(uint32_t));
4769 : : } else {
4770 : : memset(&sb_data_e1x, 0,
4771 : : sizeof(struct hc_status_block_data_e1x));
4772 : : sb_data_e1x.common.state = SB_DISABLED;
4773 : : sb_data_e1x.common.p_func.vf_valid = FALSE;
4774 : : sb_data_p = (uint32_t *) & sb_data_e1x;
4775 : : data_size = (sizeof(struct hc_status_block_data_e1x) /
4776 : : sizeof(uint32_t));
4777 : : }
4778 : :
4779 : : bnx2x_wr_fp_sb_data(sc, fw_sb_id, sb_data_p, data_size);
4780 : :
4781 : 0 : bnx2x_fill(sc,
4782 : 0 : (BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_OFFSET(fw_sb_id)), 0,
4783 : 0 : CSTORM_STATUS_BLOCK_SIZE);
4784 : 0 : bnx2x_fill(sc, (BAR_CSTRORM_INTMEM + CSTORM_SYNC_BLOCK_OFFSET(fw_sb_id)),
4785 : 0 : 0, CSTORM_SYNC_BLOCK_SIZE);
4786 : 0 : }
4787 : :
4788 : : static void
4789 : : bnx2x_wr_sp_sb_data(struct bnx2x_softc *sc,
4790 : : struct hc_sp_status_block_data *sp_sb_data)
4791 : : {
4792 : : uint32_t i;
4793 : :
4794 : 0 : for (i = 0;
4795 [ # # # # ]: 0 : i < (sizeof(struct hc_sp_status_block_data) / sizeof(uint32_t));
4796 : 0 : i++) {
4797 : 0 : REG_WR(sc,
4798 : : (BAR_CSTRORM_INTMEM +
4799 : : CSTORM_SP_STATUS_BLOCK_DATA_OFFSET(SC_FUNC(sc)) +
4800 : : (i * sizeof(uint32_t))),
4801 : : *((uint32_t *) sp_sb_data + i));
4802 : : }
4803 : : }
4804 : :
4805 : 0 : static void bnx2x_zero_sp_sb(struct bnx2x_softc *sc)
4806 : : {
4807 : : struct hc_sp_status_block_data sp_sb_data;
4808 : :
4809 : : memset(&sp_sb_data, 0, sizeof(struct hc_sp_status_block_data));
4810 : :
4811 : : sp_sb_data.state = SB_DISABLED;
4812 : : sp_sb_data.p_func.vf_valid = FALSE;
4813 : :
4814 : : bnx2x_wr_sp_sb_data(sc, &sp_sb_data);
4815 : :
4816 : 0 : bnx2x_fill(sc,
4817 : : (BAR_CSTRORM_INTMEM +
4818 : 0 : CSTORM_SP_STATUS_BLOCK_OFFSET(SC_FUNC(sc))),
4819 : 0 : 0, CSTORM_SP_STATUS_BLOCK_SIZE);
4820 : 0 : bnx2x_fill(sc,
4821 : : (BAR_CSTRORM_INTMEM +
4822 : 0 : CSTORM_SP_SYNC_BLOCK_OFFSET(SC_FUNC(sc))),
4823 : 0 : 0, CSTORM_SP_SYNC_BLOCK_SIZE);
4824 : 0 : }
4825 : :
4826 : : static void
4827 : : bnx2x_setup_ndsb_state_machine(struct hc_status_block_sm *hc_sm, int igu_sb_id,
4828 : : int igu_seg_id)
4829 : : {
4830 : 0 : hc_sm->igu_sb_id = igu_sb_id;
4831 : 0 : hc_sm->igu_seg_id = igu_seg_id;
4832 : 0 : hc_sm->timer_value = 0xFF;
4833 : 0 : hc_sm->time_to_expire = 0xFFFFFFFF;
4834 : : }
4835 : :
4836 : : static void bnx2x_map_sb_state_machines(struct hc_index_data *index_data)
4837 : : {
4838 : : /* zero out state machine indices */
4839 : :
4840 : : /* rx indices */
4841 : : index_data[HC_INDEX_ETH_RX_CQ_CONS].flags &= ~HC_INDEX_DATA_SM_ID;
4842 : :
4843 : : /* tx indices */
4844 : : index_data[HC_INDEX_OOO_TX_CQ_CONS].flags &= ~HC_INDEX_DATA_SM_ID;
4845 : : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS0].flags &= ~HC_INDEX_DATA_SM_ID;
4846 : : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS1].flags &= ~HC_INDEX_DATA_SM_ID;
4847 : : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS2].flags &= ~HC_INDEX_DATA_SM_ID;
4848 : :
4849 : : /* map indices */
4850 : :
4851 : : /* rx indices */
4852 : : index_data[HC_INDEX_ETH_RX_CQ_CONS].flags |=
4853 : : (SM_RX_ID << HC_INDEX_DATA_SM_ID_SHIFT);
4854 : :
4855 : : /* tx indices */
4856 : 0 : index_data[HC_INDEX_OOO_TX_CQ_CONS].flags |=
4857 : : (SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT);
4858 : 0 : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS0].flags |=
4859 : : (SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT);
4860 : 0 : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS1].flags |=
4861 : : (SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT);
4862 : 0 : index_data[HC_INDEX_ETH_TX_CQ_CONS_COS2].flags |=
4863 : : (SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT);
4864 : 0 : }
4865 : :
4866 : : static void
4867 : 0 : bnx2x_init_sb(struct bnx2x_softc *sc, rte_iova_t busaddr, int vfid,
4868 : : uint8_t vf_valid, int fw_sb_id, int igu_sb_id)
4869 : : {
4870 : : struct hc_status_block_data_e2 sb_data_e2;
4871 : : struct hc_status_block_data_e1x sb_data_e1x;
4872 : : struct hc_status_block_sm *hc_sm_p;
4873 : : uint32_t *sb_data_p;
4874 : : int igu_seg_id;
4875 : : int data_size;
4876 : :
4877 : : if (CHIP_INT_MODE_IS_BC(sc)) {
4878 : : igu_seg_id = HC_SEG_ACCESS_NORM;
4879 : : } else {
4880 : : igu_seg_id = IGU_SEG_ACCESS_NORM;
4881 : : }
4882 : :
4883 : 0 : bnx2x_zero_fp_sb(sc, fw_sb_id);
4884 : :
4885 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
4886 : : memset(&sb_data_e2, 0, sizeof(struct hc_status_block_data_e2));
4887 : 0 : sb_data_e2.common.state = SB_ENABLED;
4888 : 0 : sb_data_e2.common.p_func.pf_id = SC_FUNC(sc);
4889 : 0 : sb_data_e2.common.p_func.vf_id = vfid;
4890 : 0 : sb_data_e2.common.p_func.vf_valid = vf_valid;
4891 : 0 : sb_data_e2.common.p_func.vnic_id = SC_VN(sc);
4892 : 0 : sb_data_e2.common.same_igu_sb_1b = TRUE;
4893 : 0 : sb_data_e2.common.host_sb_addr.hi = U64_HI(busaddr);
4894 : 0 : sb_data_e2.common.host_sb_addr.lo = U64_LO(busaddr);
4895 : : hc_sm_p = sb_data_e2.common.state_machine;
4896 : : sb_data_p = (uint32_t *) & sb_data_e2;
4897 : : data_size = (sizeof(struct hc_status_block_data_e2) /
4898 : : sizeof(uint32_t));
4899 : : bnx2x_map_sb_state_machines(sb_data_e2.index_data);
4900 : : } else {
4901 : : memset(&sb_data_e1x, 0,
4902 : : sizeof(struct hc_status_block_data_e1x));
4903 : 0 : sb_data_e1x.common.state = SB_ENABLED;
4904 : 0 : sb_data_e1x.common.p_func.pf_id = SC_FUNC(sc);
4905 : 0 : sb_data_e1x.common.p_func.vf_id = 0xff;
4906 : : sb_data_e1x.common.p_func.vf_valid = FALSE;
4907 : 0 : sb_data_e1x.common.p_func.vnic_id = SC_VN(sc);
4908 : 0 : sb_data_e1x.common.same_igu_sb_1b = TRUE;
4909 : 0 : sb_data_e1x.common.host_sb_addr.hi = U64_HI(busaddr);
4910 : 0 : sb_data_e1x.common.host_sb_addr.lo = U64_LO(busaddr);
4911 : : hc_sm_p = sb_data_e1x.common.state_machine;
4912 : : sb_data_p = (uint32_t *) & sb_data_e1x;
4913 : : data_size = (sizeof(struct hc_status_block_data_e1x) /
4914 : : sizeof(uint32_t));
4915 : : bnx2x_map_sb_state_machines(sb_data_e1x.index_data);
4916 : : }
4917 : :
4918 : : bnx2x_setup_ndsb_state_machine(&hc_sm_p[SM_RX_ID], igu_sb_id, igu_seg_id);
4919 : : bnx2x_setup_ndsb_state_machine(&hc_sm_p[SM_TX_ID], igu_sb_id, igu_seg_id);
4920 : :
4921 : : /* write indices to HW - PCI guarantees endianity of regpairs */
4922 : : bnx2x_wr_fp_sb_data(sc, fw_sb_id, sb_data_p, data_size);
4923 : 0 : }
4924 : :
4925 : : static uint8_t bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp)
4926 : : {
4927 [ # # ]: 0 : if (CHIP_IS_E1x(fp->sc)) {
4928 : 0 : return fp->cl_id + SC_PORT(fp->sc) * ETH_MAX_RX_CLIENTS_E1H;
4929 : : } else {
4930 : 0 : return fp->cl_id;
4931 : : }
4932 : : }
4933 : :
4934 : : static uint32_t
4935 : 0 : bnx2x_rx_ustorm_prods_offset(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp)
4936 : : {
4937 : : uint32_t offset = BAR_USTRORM_INTMEM;
4938 : :
4939 [ # # ]: 0 : if (IS_VF(sc)) {
4940 : 0 : return PXP_VF_ADDR_USDM_QUEUES_START +
4941 : 0 : (sc->acquire_resp.resc.hw_qid[fp->index] *
4942 : : sizeof(struct ustorm_queue_zone_data));
4943 [ # # ]: 0 : } else if (!CHIP_IS_E1x(sc)) {
4944 : 0 : offset += USTORM_RX_PRODS_E2_OFFSET(fp->cl_qzone_id);
4945 : : } else {
4946 : 0 : offset += USTORM_RX_PRODS_E1X_OFFSET(SC_PORT(sc), fp->cl_id);
4947 : : }
4948 : :
4949 : : return offset;
4950 : : }
4951 : :
4952 : 0 : static void bnx2x_init_eth_fp(struct bnx2x_softc *sc, int idx)
4953 : : {
4954 : 0 : struct bnx2x_fastpath *fp = &sc->fp[idx];
4955 : 0 : uint32_t cids[ECORE_MULTI_TX_COS] = { 0 };
4956 : 0 : uint32_t q_type = 0;
4957 : : int cos;
4958 : :
4959 : 0 : fp->sc = sc;
4960 : 0 : fp->index = idx;
4961 : :
4962 : 0 : fp->igu_sb_id = (sc->igu_base_sb + idx + CNIC_SUPPORT(sc));
4963 : 0 : fp->fw_sb_id = (sc->base_fw_ndsb + idx + CNIC_SUPPORT(sc));
4964 : :
4965 [ # # ]: 0 : if (CHIP_IS_E1x(sc))
4966 : 0 : fp->cl_id = SC_L_ID(sc) + idx;
4967 : : else
4968 : : /* want client ID same as IGU SB ID for non-E1 */
4969 : 0 : fp->cl_id = fp->igu_sb_id;
4970 : 0 : fp->cl_qzone_id = bnx2x_fp_qzone_id(fp);
4971 : :
4972 : : /* setup sb indices */
4973 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
4974 : 0 : fp->sb_index_values = fp->status_block.e2_sb->sb.index_values;
4975 : 0 : fp->sb_running_index = fp->status_block.e2_sb->sb.running_index;
4976 : : } else {
4977 : 0 : fp->sb_index_values = fp->status_block.e1x_sb->sb.index_values;
4978 : 0 : fp->sb_running_index =
4979 : 0 : fp->status_block.e1x_sb->sb.running_index;
4980 : : }
4981 : :
4982 : : /* init shortcut */
4983 : 0 : fp->ustorm_rx_prods_offset = bnx2x_rx_ustorm_prods_offset(sc, fp);
4984 : :
4985 : 0 : fp->rx_cq_cons_sb = &fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS];
4986 : :
4987 [ # # ]: 0 : for (cos = 0; cos < sc->max_cos; cos++) {
4988 : 0 : cids[cos] = idx;
4989 : : }
4990 : 0 : fp->tx_cons_sb = &fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0];
4991 : :
4992 : : /* nothing more for a VF to do */
4993 [ # # ]: 0 : if (IS_VF(sc)) {
4994 : 0 : return;
4995 : : }
4996 : :
4997 : 0 : bnx2x_init_sb(sc, fp->sb_dma.paddr, BNX2X_VF_ID_INVALID, FALSE,
4998 : : fp->fw_sb_id, fp->igu_sb_id);
4999 : :
5000 : : bnx2x_update_fp_sb_idx(fp);
5001 : :
5002 : : /* Configure Queue State object */
5003 : : rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_RX, &q_type);
5004 : : rte_bit_relaxed_set32(ECORE_Q_TYPE_HAS_TX, &q_type);
5005 : :
5006 : 0 : ecore_init_queue_obj(sc,
5007 : : &sc->sp_objs[idx].q_obj,
5008 : 0 : fp->cl_id,
5009 : : cids,
5010 : 0 : sc->max_cos,
5011 : 0 : SC_FUNC(sc),
5012 : 0 : BNX2X_SP(sc, q_rdata),
5013 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, q_rdata),
5014 : : q_type);
5015 : :
5016 : : /* configure classification DBs */
5017 : 0 : ecore_init_mac_obj(sc,
5018 : : &sc->sp_objs[idx].mac_obj,
5019 : 0 : fp->cl_id,
5020 : : idx,
5021 : 0 : SC_FUNC(sc),
5022 : 0 : BNX2X_SP(sc, mac_rdata),
5023 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, mac_rdata),
5024 : : ECORE_FILTER_MAC_PENDING, &sc->sp_state,
5025 : : ECORE_OBJ_TYPE_RX_TX, &sc->macs_pool);
5026 : : }
5027 : :
5028 : : static void
5029 : 0 : bnx2x_update_rx_prod(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
5030 : : uint16_t rx_bd_prod, uint16_t rx_cq_prod)
5031 : : {
5032 : : struct ustorm_eth_rx_producers rx_prods;
5033 : : uint32_t i;
5034 : :
5035 : : memset(&rx_prods, 0, sizeof(rx_prods));
5036 : :
5037 : : /* update producers */
5038 : 0 : rx_prods.bd_prod = rx_bd_prod;
5039 : 0 : rx_prods.cqe_prod = rx_cq_prod;
5040 : :
5041 : : /*
5042 : : * Make sure that the BD and SGE data is updated before updating the
5043 : : * producers since FW might read the BD/SGE right after the producer
5044 : : * is updated.
5045 : : * This is only applicable for weak-ordered memory model archs such
5046 : : * as IA-64. The following barrier is also mandatory since FW will
5047 : : * assumes BDs must have buffers.
5048 : : */
5049 : : wmb();
5050 : :
5051 [ # # ]: 0 : for (i = 0; i < (sizeof(rx_prods) / 4); i++) {
5052 : 0 : REG_WR(sc, (fp->ustorm_rx_prods_offset + (i * 4)),
5053 : : ((uint32_t *)&rx_prods)[i]);
5054 : : }
5055 : :
5056 : : wmb(); /* keep prod updates ordered */
5057 : 0 : }
5058 : :
5059 : 0 : static void bnx2x_init_rx_rings(struct bnx2x_softc *sc)
5060 : : {
5061 : : struct bnx2x_fastpath *fp;
5062 : : int i;
5063 : : struct bnx2x_rx_queue *rxq;
5064 : :
5065 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
5066 : 0 : fp = &sc->fp[i];
5067 : 0 : rxq = sc->rx_queues[fp->index];
5068 [ # # ]: 0 : if (!rxq) {
5069 : : PMD_RX_LOG(ERR, "RX queue is NULL");
5070 : : return;
5071 : : }
5072 : :
5073 : 0 : rxq->rx_bd_head = 0;
5074 : 0 : rxq->rx_bd_tail = rxq->nb_rx_desc;
5075 : 0 : rxq->rx_cq_head = 0;
5076 : 0 : rxq->rx_cq_tail = TOTAL_RCQ_ENTRIES(rxq);
5077 : 0 : *fp->rx_cq_cons_sb = 0;
5078 : :
5079 : : /*
5080 : : * Activate the BD ring...
5081 : : * Warning, this will generate an interrupt (to the TSTORM)
5082 : : * so this can only be done after the chip is initialized
5083 : : */
5084 : 0 : bnx2x_update_rx_prod(sc, fp, rxq->rx_bd_tail, rxq->rx_cq_tail);
5085 : :
5086 : : if (i != 0) {
5087 : : continue;
5088 : : }
5089 : : }
5090 : : }
5091 : :
5092 : : static void bnx2x_init_tx_ring_one(struct bnx2x_fastpath *fp)
5093 : : {
5094 : 0 : struct bnx2x_tx_queue *txq = fp->sc->tx_queues[fp->index];
5095 : :
5096 : 0 : fp->tx_db.data.header.header = 1 << DOORBELL_HDR_DB_TYPE_SHIFT;
5097 : 0 : fp->tx_db.data.zero_fill1 = 0;
5098 : 0 : fp->tx_db.data.prod = 0;
5099 : :
5100 [ # # ]: 0 : if (!txq) {
5101 : : PMD_TX_LOG(ERR, "ERROR: TX queue is NULL");
5102 : : return;
5103 : : }
5104 : :
5105 : 0 : txq->tx_pkt_tail = 0;
5106 : 0 : txq->tx_pkt_head = 0;
5107 : 0 : txq->tx_bd_tail = 0;
5108 : 0 : txq->tx_bd_head = 0;
5109 : : }
5110 : :
5111 : 0 : static void bnx2x_init_tx_rings(struct bnx2x_softc *sc)
5112 : : {
5113 : : int i;
5114 : :
5115 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
5116 : : bnx2x_init_tx_ring_one(&sc->fp[i]);
5117 : : }
5118 : 0 : }
5119 : :
5120 : 0 : static void bnx2x_init_def_sb(struct bnx2x_softc *sc)
5121 : : {
5122 : 0 : struct host_sp_status_block *def_sb = sc->def_sb;
5123 : 0 : rte_iova_t mapping = sc->def_sb_dma.paddr;
5124 : : int igu_sp_sb_index;
5125 : : int igu_seg_id;
5126 [ # # ]: 0 : int port = SC_PORT(sc);
5127 : : int func = SC_FUNC(sc);
5128 : : int reg_offset, reg_offset_en5;
5129 : : uint64_t section;
5130 : : int index, sindex;
5131 : : struct hc_sp_status_block_data sp_sb_data;
5132 : :
5133 : : memset(&sp_sb_data, 0, sizeof(struct hc_sp_status_block_data));
5134 : :
5135 [ # # # # ]: 0 : if (CHIP_INT_MODE_IS_BC(sc)) {
5136 : : igu_sp_sb_index = DEF_SB_IGU_ID;
5137 : : igu_seg_id = HC_SEG_ACCESS_DEF;
5138 : : } else {
5139 : 0 : igu_sp_sb_index = sc->igu_dsb_id;
5140 : : igu_seg_id = IGU_SEG_ACCESS_DEF;
5141 : : }
5142 : :
5143 : : /* attentions */
5144 : : section = ((uint64_t) mapping +
5145 : : offsetof(struct host_sp_status_block, atten_status_block));
5146 : 0 : def_sb->atten_status_block.status_block_id = igu_sp_sb_index;
5147 : 0 : sc->attn_state = 0;
5148 : :
5149 [ # # ]: 0 : reg_offset = (port) ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
5150 : : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0;
5151 : :
5152 [ # # ]: 0 : reg_offset_en5 = (port) ? MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 :
5153 : : MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0;
5154 : :
5155 [ # # ]: 0 : for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) {
5156 : : /* take care of sig[0]..sig[4] */
5157 [ # # ]: 0 : for (sindex = 0; sindex < 4; sindex++) {
5158 : 0 : sc->attn_group[index].sig[sindex] =
5159 : 0 : REG_RD(sc,
5160 : : (reg_offset + (sindex * 0x4) +
5161 : : (0x10 * index)));
5162 : : }
5163 : :
5164 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
5165 : : /*
5166 : : * enable5 is separate from the rest of the registers,
5167 : : * and the address skip is 4 and not 16 between the
5168 : : * different groups
5169 : : */
5170 : 0 : sc->attn_group[index].sig[4] =
5171 : 0 : REG_RD(sc, (reg_offset_en5 + (0x4 * index)));
5172 : : } else {
5173 : 0 : sc->attn_group[index].sig[4] = 0;
5174 : : }
5175 : : }
5176 : :
5177 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
5178 : : reg_offset =
5179 [ # # ]: 0 : port ? HC_REG_ATTN_MSG1_ADDR_L : HC_REG_ATTN_MSG0_ADDR_L;
5180 : 0 : REG_WR(sc, reg_offset, U64_LO(section));
5181 : 0 : REG_WR(sc, (reg_offset + 4), U64_HI(section));
5182 [ # # ]: 0 : } else if (!CHIP_IS_E1x(sc)) {
5183 : 0 : REG_WR(sc, IGU_REG_ATTN_MSG_ADDR_L, U64_LO(section));
5184 : 0 : REG_WR(sc, IGU_REG_ATTN_MSG_ADDR_H, U64_HI(section));
5185 : : }
5186 : :
5187 : 0 : section = ((uint64_t) mapping +
5188 : : offsetof(struct host_sp_status_block, sp_sb));
5189 : :
5190 : 0 : bnx2x_zero_sp_sb(sc);
5191 : :
5192 : : /* PCI guarantees endianity of regpair */
5193 : 0 : sp_sb_data.state = SB_ENABLED;
5194 : 0 : sp_sb_data.host_sb_addr.lo = U64_LO(section);
5195 : 0 : sp_sb_data.host_sb_addr.hi = U64_HI(section);
5196 : 0 : sp_sb_data.igu_sb_id = igu_sp_sb_index;
5197 : 0 : sp_sb_data.igu_seg_id = igu_seg_id;
5198 : 0 : sp_sb_data.p_func.pf_id = func;
5199 : 0 : sp_sb_data.p_func.vnic_id = SC_VN(sc);
5200 : 0 : sp_sb_data.p_func.vf_id = 0xff;
5201 : :
5202 : : bnx2x_wr_sp_sb_data(sc, &sp_sb_data);
5203 : :
5204 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id, USTORM_ID, 0, IGU_INT_ENABLE, 0);
5205 : 0 : }
5206 : :
5207 : : static void bnx2x_init_sp_ring(struct bnx2x_softc *sc)
5208 : : {
5209 : 0 : atomic_store_rel_long(&sc->cq_spq_left, MAX_SPQ_PENDING);
5210 : 0 : sc->spq_prod_idx = 0;
5211 : 0 : sc->dsb_sp_prod =
5212 : 0 : &sc->def_sb->sp_sb.index_values[HC_SP_INDEX_ETH_DEF_CONS];
5213 : 0 : sc->spq_prod_bd = sc->spq;
5214 : 0 : sc->spq_last_bd = (sc->spq_prod_bd + MAX_SP_DESC_CNT);
5215 : : }
5216 : :
5217 : : static void bnx2x_init_eq_ring(struct bnx2x_softc *sc)
5218 : : {
5219 : : union event_ring_elem *elem;
5220 : : int i;
5221 : :
5222 : : for (i = 1; i <= NUM_EQ_PAGES; i++) {
5223 : 0 : elem = &sc->eq[EQ_DESC_CNT_PAGE * i - 1];
5224 : :
5225 : 0 : elem->next_page.addr.hi = htole32(U64_HI(sc->eq_dma.paddr +
5226 : : BNX2X_PAGE_SIZE *
5227 : : (i % NUM_EQ_PAGES)));
5228 : 0 : elem->next_page.addr.lo = htole32(U64_LO(sc->eq_dma.paddr +
5229 : : BNX2X_PAGE_SIZE *
5230 : : (i % NUM_EQ_PAGES)));
5231 : : }
5232 : :
5233 : 0 : sc->eq_cons = 0;
5234 : 0 : sc->eq_prod = NUM_EQ_DESC;
5235 : 0 : sc->eq_cons_sb = &sc->def_sb->sp_sb.index_values[HC_SP_INDEX_EQ_CONS];
5236 : :
5237 : 0 : atomic_store_rel_long(&sc->eq_spq_left,
5238 : : (min((MAX_SP_DESC_CNT - MAX_SPQ_PENDING),
5239 : : NUM_EQ_DESC) - 1));
5240 : : }
5241 : :
5242 : 0 : static void bnx2x_init_internal_common(struct bnx2x_softc *sc)
5243 : : {
5244 : : int i;
5245 : :
5246 : : /*
5247 : : * Zero this manually as its initialization is currently missing
5248 : : * in the initTool.
5249 : : */
5250 [ # # ]: 0 : for (i = 0; i < (USTORM_AGG_DATA_SIZE >> 2); i++) {
5251 : 0 : REG_WR(sc,
5252 : : (BAR_USTRORM_INTMEM + USTORM_AGG_DATA_OFFSET + (i * 4)),
5253 : : 0);
5254 : : }
5255 : :
5256 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
5257 [ # # ]: 0 : REG_WR8(sc, (BAR_CSTRORM_INTMEM + CSTORM_IGU_MODE_OFFSET),
5258 : : CHIP_INT_MODE_IS_BC(sc) ? HC_IGU_BC_MODE :
5259 : : HC_IGU_NBC_MODE);
5260 : : }
5261 : 0 : }
5262 : :
5263 : 0 : static void bnx2x_init_internal(struct bnx2x_softc *sc, uint32_t load_code)
5264 : : {
5265 [ # # # ]: 0 : switch (load_code) {
5266 : 0 : case FW_MSG_CODE_DRV_LOAD_COMMON:
5267 : : case FW_MSG_CODE_DRV_LOAD_COMMON_CHIP:
5268 : 0 : bnx2x_init_internal_common(sc);
5269 : : /* no break */
5270 : :
5271 : : case FW_MSG_CODE_DRV_LOAD_PORT:
5272 : : /* nothing to do */
5273 : : /* no break */
5274 : :
5275 : : case FW_MSG_CODE_DRV_LOAD_FUNCTION:
5276 : : /* internal memory per function is initialized inside bnx2x_pf_init */
5277 : : break;
5278 : :
5279 : 0 : default:
5280 : 0 : PMD_DRV_LOG(NOTICE, sc, "Unknown load_code (0x%x) from MCP",
5281 : : load_code);
5282 : 0 : break;
5283 : : }
5284 : 0 : }
5285 : :
5286 : : static void
5287 : : storm_memset_func_cfg(struct bnx2x_softc *sc,
5288 : : struct tstorm_eth_function_common_config *tcfg,
5289 : : uint16_t abs_fid)
5290 : : {
5291 : : uint32_t addr;
5292 : : size_t size;
5293 : :
5294 : 0 : addr = (BAR_TSTRORM_INTMEM +
5295 : 0 : TSTORM_FUNCTION_COMMON_CONFIG_OFFSET(abs_fid));
5296 : : size = sizeof(struct tstorm_eth_function_common_config);
5297 : 0 : ecore_storm_memset_struct(sc, addr, size, (uint32_t *) tcfg);
5298 : 0 : }
5299 : :
5300 : 0 : static void bnx2x_func_init(struct bnx2x_softc *sc, struct bnx2x_func_init_params *p)
5301 : : {
5302 : 0 : struct tstorm_eth_function_common_config tcfg = { 0 };
5303 : :
5304 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
5305 : 0 : storm_memset_func_cfg(sc, &tcfg, p->func_id);
5306 : : }
5307 : :
5308 : : /* Enable the function in the FW */
5309 : 0 : storm_memset_vf_to_pf(sc, p->func_id, p->pf_id);
5310 : 0 : storm_memset_func_en(sc, p->func_id, 1);
5311 : :
5312 : : /* spq */
5313 [ # # ]: 0 : if (p->func_flgs & FUNC_FLG_SPQ) {
5314 : 0 : storm_memset_spq_addr(sc, p->spq_map, p->func_id);
5315 : 0 : REG_WR(sc,
5316 : : (XSEM_REG_FAST_MEMORY +
5317 : : XSTORM_SPQ_PROD_OFFSET(p->func_id)), p->spq_prod);
5318 : : }
5319 : 0 : }
5320 : :
5321 : : /*
5322 : : * Calculates the sum of vn_min_rates.
5323 : : * It's needed for further normalizing of the min_rates.
5324 : : * Returns:
5325 : : * sum of vn_min_rates.
5326 : : * or
5327 : : * 0 - if all the min_rates are 0.
5328 : : * In the later case fairness algorithm should be deactivated.
5329 : : * If all min rates are not zero then those that are zeroes will be set to 1.
5330 : : */
5331 : 0 : static void bnx2x_calc_vn_min(struct bnx2x_softc *sc, struct cmng_init_input *input)
5332 : : {
5333 : : uint32_t vn_cfg;
5334 : : uint32_t vn_min_rate;
5335 : : int all_zero = 1;
5336 : : int vn;
5337 : :
5338 [ # # # # ]: 0 : for (vn = VN_0; vn < SC_MAX_VN_NUM(sc); vn++) {
5339 : 0 : vn_cfg = sc->devinfo.mf_info.mf_config[vn];
5340 : 0 : vn_min_rate = (((vn_cfg & FUNC_MF_CFG_MIN_BW_MASK) >>
5341 : : FUNC_MF_CFG_MIN_BW_SHIFT) * 100);
5342 : :
5343 [ # # ]: 0 : if (vn_cfg & FUNC_MF_CFG_FUNC_HIDE) {
5344 : : /* skip hidden VNs */
5345 : : vn_min_rate = 0;
5346 [ # # ]: 0 : } else if (!vn_min_rate) {
5347 : : /* If min rate is zero - set it to 100 */
5348 : : vn_min_rate = DEF_MIN_RATE;
5349 : : } else {
5350 : : all_zero = 0;
5351 : : }
5352 : :
5353 : 0 : input->vnic_min_rate[vn] = vn_min_rate;
5354 : : }
5355 : :
5356 : : /* if ETS or all min rates are zeros - disable fairness */
5357 [ # # ]: 0 : if (all_zero) {
5358 : 0 : input->flags.cmng_enables &= ~CMNG_FLAGS_PER_PORT_FAIRNESS_VN;
5359 : : } else {
5360 : 0 : input->flags.cmng_enables |= CMNG_FLAGS_PER_PORT_FAIRNESS_VN;
5361 : : }
5362 : 0 : }
5363 : :
5364 : : static uint16_t
5365 : : bnx2x_extract_max_cfg(__rte_unused struct bnx2x_softc *sc, uint32_t mf_cfg)
5366 : : {
5367 : 0 : uint16_t max_cfg = ((mf_cfg & FUNC_MF_CFG_MAX_BW_MASK) >>
5368 : : FUNC_MF_CFG_MAX_BW_SHIFT);
5369 : :
5370 [ # # ]: 0 : if (!max_cfg) {
5371 : 0 : PMD_DRV_LOG(DEBUG, sc,
5372 : : "Max BW configured to 0 - using 100 instead");
5373 : : max_cfg = 100;
5374 : : }
5375 : :
5376 : : return max_cfg;
5377 : : }
5378 : :
5379 : : static void
5380 : 0 : bnx2x_calc_vn_max(struct bnx2x_softc *sc, int vn, struct cmng_init_input *input)
5381 : : {
5382 : : uint16_t vn_max_rate;
5383 : 0 : uint32_t vn_cfg = sc->devinfo.mf_info.mf_config[vn];
5384 : : uint32_t max_cfg;
5385 : :
5386 [ # # ]: 0 : if (vn_cfg & FUNC_MF_CFG_FUNC_HIDE) {
5387 : : vn_max_rate = 0;
5388 : : } else {
5389 : 0 : max_cfg = bnx2x_extract_max_cfg(sc, vn_cfg);
5390 : :
5391 [ # # # # ]: 0 : if (IS_MF_SI(sc)) {
5392 : : /* max_cfg in percents of linkspeed */
5393 : 0 : vn_max_rate =
5394 : 0 : ((sc->link_vars.line_speed * max_cfg) / 100);
5395 : : } else { /* SD modes */
5396 : : /* max_cfg is absolute in 100Mb units */
5397 : 0 : vn_max_rate = (max_cfg * 100);
5398 : : }
5399 : : }
5400 : :
5401 : 0 : input->vnic_max_rate[vn] = vn_max_rate;
5402 : 0 : }
5403 : :
5404 : : static void
5405 [ # # ]: 0 : bnx2x_cmng_fns_init(struct bnx2x_softc *sc, uint8_t read_cfg, uint8_t cmng_type)
5406 : : {
5407 : : struct cmng_init_input input;
5408 : : int vn;
5409 : :
5410 : : memset(&input, 0, sizeof(struct cmng_init_input));
5411 : :
5412 : 0 : input.port_rate = sc->link_vars.line_speed;
5413 : :
5414 [ # # ]: 0 : if (cmng_type == CMNG_FNS_MINMAX) {
5415 : : /* read mf conf from shmem */
5416 [ # # ]: 0 : if (read_cfg) {
5417 : 0 : bnx2x_read_mf_cfg(sc);
5418 : : }
5419 : :
5420 : : /* get VN min rate and enable fairness if not 0 */
5421 : 0 : bnx2x_calc_vn_min(sc, &input);
5422 : :
5423 : : /* get VN max rate */
5424 [ # # ]: 0 : if (sc->port.pmf) {
5425 [ # # # # ]: 0 : for (vn = VN_0; vn < SC_MAX_VN_NUM(sc); vn++) {
5426 : 0 : bnx2x_calc_vn_max(sc, vn, &input);
5427 : : }
5428 : : }
5429 : :
5430 : : /* always enable rate shaping and fairness */
5431 : 0 : input.flags.cmng_enables |= CMNG_FLAGS_PER_PORT_RATE_SHAPING_VN;
5432 : :
5433 : 0 : ecore_init_cmng(&input, &sc->cmng);
5434 : 0 : return;
5435 : : }
5436 : : }
5437 : :
5438 : : static int bnx2x_get_cmng_fns_mode(struct bnx2x_softc *sc)
5439 : : {
5440 [ # # ]: 0 : if (CHIP_REV_IS_SLOW(sc)) {
5441 : : return CMNG_FNS_NONE;
5442 : : }
5443 : :
5444 [ # # # # : 0 : if (IS_MF(sc)) {
# # # # ]
5445 : 0 : return CMNG_FNS_MINMAX;
5446 : : }
5447 : :
5448 : : return CMNG_FNS_NONE;
5449 : : }
5450 : :
5451 : : static void
5452 : 0 : storm_memset_cmng(struct bnx2x_softc *sc, struct cmng_init *cmng, uint8_t port)
5453 : : {
5454 : : int vn;
5455 : : int func;
5456 : : uint32_t addr;
5457 : : size_t size;
5458 : :
5459 : 0 : addr = (BAR_XSTRORM_INTMEM + XSTORM_CMNG_PER_PORT_VARS_OFFSET(port));
5460 : : size = sizeof(struct cmng_struct_per_port);
5461 : 0 : ecore_storm_memset_struct(sc, addr, size, (uint32_t *) & cmng->port);
5462 : :
5463 [ # # # # ]: 0 : for (vn = VN_0; vn < SC_MAX_VN_NUM(sc); vn++) {
5464 : : func = func_by_vn(sc, vn);
5465 : :
5466 : 0 : addr = (BAR_XSTRORM_INTMEM +
5467 : 0 : XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(func));
5468 : : size = sizeof(struct rate_shaping_vars_per_vn);
5469 : 0 : ecore_storm_memset_struct(sc, addr, size,
5470 : 0 : (uint32_t *) & cmng->
5471 : : vnic.vnic_max_rate[vn]);
5472 : :
5473 : 0 : addr = (BAR_XSTRORM_INTMEM +
5474 : 0 : XSTORM_FAIRNESS_PER_VN_VARS_OFFSET(func));
5475 : : size = sizeof(struct fairness_vars_per_vn);
5476 : 0 : ecore_storm_memset_struct(sc, addr, size,
5477 : 0 : (uint32_t *) & cmng->
5478 : : vnic.vnic_min_rate[vn]);
5479 : : }
5480 : 0 : }
5481 : :
5482 [ # # ]: 0 : static void bnx2x_pf_init(struct bnx2x_softc *sc)
5483 : : {
5484 : : struct bnx2x_func_init_params func_init;
5485 : : struct event_ring_data eq_data;
5486 : : uint16_t flags;
5487 : :
5488 : : memset(&eq_data, 0, sizeof(struct event_ring_data));
5489 : : memset(&func_init, 0, sizeof(struct bnx2x_func_init_params));
5490 : :
5491 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
5492 : : /* reset IGU PF statistics: MSIX + ATTN */
5493 : : /* PF */
5494 [ # # ]: 0 : REG_WR(sc,
5495 : : (IGU_REG_STATISTIC_NUM_MESSAGE_SENT +
5496 : : (BNX2X_IGU_STAS_MSG_VF_CNT * 4) +
5497 : : ((CHIP_IS_MODE_4_PORT(sc) ? SC_FUNC(sc) : SC_VN(sc)) *
5498 : : 4)), 0);
5499 : : /* ATTN */
5500 [ # # ]: 0 : REG_WR(sc,
5501 : : (IGU_REG_STATISTIC_NUM_MESSAGE_SENT +
5502 : : (BNX2X_IGU_STAS_MSG_VF_CNT * 4) +
5503 : : (BNX2X_IGU_STAS_MSG_PF_CNT * 4) +
5504 : : ((CHIP_IS_MODE_4_PORT(sc) ? SC_FUNC(sc) : SC_VN(sc)) *
5505 : : 4)), 0);
5506 : : }
5507 : :
5508 : : /* function setup flags */
5509 : : flags = (FUNC_FLG_STATS | FUNC_FLG_LEADING | FUNC_FLG_SPQ);
5510 : :
5511 : 0 : func_init.func_flgs = flags;
5512 : 0 : func_init.pf_id = SC_FUNC(sc);
5513 : 0 : func_init.func_id = SC_FUNC(sc);
5514 : 0 : func_init.spq_map = sc->spq_dma.paddr;
5515 : 0 : func_init.spq_prod = sc->spq_prod_idx;
5516 : :
5517 : 0 : bnx2x_func_init(sc, &func_init);
5518 : :
5519 [ # # ]: 0 : memset(&sc->cmng, 0, sizeof(struct cmng_struct_per_port));
5520 : :
5521 : : /*
5522 : : * Congestion management values depend on the link rate.
5523 : : * There is no active link so initial link rate is set to 10Gbps.
5524 : : * When the link comes up the congestion management values are
5525 : : * re-calculated according to the actual link rate.
5526 : : */
5527 [ # # ]: 0 : sc->link_vars.line_speed = SPEED_10000;
5528 : 0 : bnx2x_cmng_fns_init(sc, TRUE, bnx2x_get_cmng_fns_mode(sc));
5529 : :
5530 : : /* Only the PMF sets the HW */
5531 [ # # ]: 0 : if (sc->port.pmf) {
5532 : 0 : storm_memset_cmng(sc, &sc->cmng, SC_PORT(sc));
5533 : : }
5534 : :
5535 : : /* init Event Queue - PCI bus guarantees correct endainity */
5536 : 0 : eq_data.base_addr.hi = U64_HI(sc->eq_dma.paddr);
5537 : 0 : eq_data.base_addr.lo = U64_LO(sc->eq_dma.paddr);
5538 : 0 : eq_data.producer = sc->eq_prod;
5539 : 0 : eq_data.index_id = HC_SP_INDEX_EQ_CONS;
5540 : 0 : eq_data.sb_id = DEF_SB_ID;
5541 : 0 : storm_memset_eq_data(sc, &eq_data, SC_FUNC(sc));
5542 : 0 : }
5543 : :
5544 : 0 : static void bnx2x_hc_int_enable(struct bnx2x_softc *sc)
5545 : : {
5546 : 0 : int port = SC_PORT(sc);
5547 [ # # ]: 0 : uint32_t addr = (port) ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0;
5548 : 0 : uint32_t val = REG_RD(sc, addr);
5549 : 0 : uint8_t msix = (sc->interrupt_mode == INTR_MODE_MSIX)
5550 : 0 : || (sc->interrupt_mode == INTR_MODE_SINGLE_MSIX);
5551 : : uint8_t single_msix = (sc->interrupt_mode == INTR_MODE_SINGLE_MSIX);
5552 : : uint8_t msi = (sc->interrupt_mode == INTR_MODE_MSI);
5553 : :
5554 [ # # ]: 0 : if (msix) {
5555 : 0 : val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 |
5556 : : HC_CONFIG_0_REG_INT_LINE_EN_0);
5557 : 0 : val |= (HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 |
5558 : : HC_CONFIG_0_REG_ATTN_BIT_EN_0);
5559 [ # # ]: 0 : if (single_msix) {
5560 : 0 : val |= HC_CONFIG_0_REG_SINGLE_ISR_EN_0;
5561 : : }
5562 [ # # ]: 0 : } else if (msi) {
5563 : 0 : val &= ~HC_CONFIG_0_REG_INT_LINE_EN_0;
5564 : 0 : val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 |
5565 : : HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 |
5566 : : HC_CONFIG_0_REG_ATTN_BIT_EN_0);
5567 : : } else {
5568 : 0 : val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 |
5569 : : HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 |
5570 : : HC_CONFIG_0_REG_INT_LINE_EN_0 |
5571 : : HC_CONFIG_0_REG_ATTN_BIT_EN_0);
5572 : :
5573 : : REG_WR(sc, addr, val);
5574 : :
5575 : 0 : val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0;
5576 : : }
5577 : :
5578 : : REG_WR(sc, addr, val);
5579 : :
5580 : : /* ensure that HC_CONFIG is written before leading/trailing edge config */
5581 : : mb();
5582 : :
5583 : : /* init leading/trailing edge */
5584 [ # # # # ]: 0 : if (IS_MF(sc)) {
5585 : 0 : val = (0xee0f | (1 << (SC_VN(sc) + 4)));
5586 [ # # ]: 0 : if (sc->port.pmf) {
5587 : : /* enable nig and gpio3 attention */
5588 : 0 : val |= 0x1100;
5589 : : }
5590 : : } else {
5591 : : val = 0xffff;
5592 : : }
5593 : :
5594 : 0 : REG_WR(sc, (HC_REG_TRAILING_EDGE_0 + port * 8), val);
5595 : 0 : REG_WR(sc, (HC_REG_LEADING_EDGE_0 + port * 8), val);
5596 : :
5597 : : /* make sure that interrupts are indeed enabled from here on */
5598 : : mb();
5599 : 0 : }
5600 : :
5601 : 0 : static void bnx2x_igu_int_enable(struct bnx2x_softc *sc)
5602 : : {
5603 : : uint32_t val;
5604 : 0 : uint8_t msix = (sc->interrupt_mode == INTR_MODE_MSIX)
5605 : 0 : || (sc->interrupt_mode == INTR_MODE_SINGLE_MSIX);
5606 : 0 : uint8_t single_msix = (sc->interrupt_mode == INTR_MODE_SINGLE_MSIX);
5607 : : uint8_t msi = (sc->interrupt_mode == INTR_MODE_MSI);
5608 : :
5609 : : val = REG_RD(sc, IGU_REG_PF_CONFIGURATION);
5610 : :
5611 [ # # ]: 0 : if (msix) {
5612 : 0 : val &= ~(IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_SINGLE_ISR_EN);
5613 : 0 : val |= (IGU_PF_CONF_MSI_MSIX_EN | IGU_PF_CONF_ATTN_BIT_EN);
5614 [ # # ]: 0 : if (single_msix) {
5615 : 0 : val |= IGU_PF_CONF_SINGLE_ISR_EN;
5616 : : }
5617 [ # # ]: 0 : } else if (msi) {
5618 : 0 : val &= ~IGU_PF_CONF_INT_LINE_EN;
5619 : 0 : val |= (IGU_PF_CONF_MSI_MSIX_EN |
5620 : : IGU_PF_CONF_ATTN_BIT_EN | IGU_PF_CONF_SINGLE_ISR_EN);
5621 : : } else {
5622 : 0 : val &= ~IGU_PF_CONF_MSI_MSIX_EN;
5623 : 0 : val |= (IGU_PF_CONF_INT_LINE_EN |
5624 : : IGU_PF_CONF_ATTN_BIT_EN | IGU_PF_CONF_SINGLE_ISR_EN);
5625 : : }
5626 : :
5627 : : /* clean previous status - need to configure igu prior to ack */
5628 [ # # ]: 0 : if ((!msix) || single_msix) {
5629 : : REG_WR(sc, IGU_REG_PF_CONFIGURATION, val);
5630 : : bnx2x_ack_int(sc);
5631 : : }
5632 : :
5633 : 0 : val |= IGU_PF_CONF_FUNC_EN;
5634 : :
5635 [ # # # # ]: 0 : PMD_DRV_LOG(DEBUG, sc, "write 0x%x to IGU mode %s",
5636 : : val, ((msix) ? "MSI-X" : ((msi) ? "MSI" : "INTx")));
5637 : :
5638 : : REG_WR(sc, IGU_REG_PF_CONFIGURATION, val);
5639 : :
5640 : : mb();
5641 : :
5642 : : /* init leading/trailing edge */
5643 [ # # # # ]: 0 : if (IS_MF(sc)) {
5644 : 0 : val = (0xee0f | (1 << (SC_VN(sc) + 4)));
5645 [ # # ]: 0 : if (sc->port.pmf) {
5646 : : /* enable nig and gpio3 attention */
5647 : 0 : val |= 0x1100;
5648 : : }
5649 : : } else {
5650 : : val = 0xffff;
5651 : : }
5652 : :
5653 : : REG_WR(sc, IGU_REG_TRAILING_EDGE_LATCH, val);
5654 : : REG_WR(sc, IGU_REG_LEADING_EDGE_LATCH, val);
5655 : :
5656 : : /* make sure that interrupts are indeed enabled from here on */
5657 : : mb();
5658 : 0 : }
5659 : :
5660 : 0 : static void bnx2x_int_enable(struct bnx2x_softc *sc)
5661 : : {
5662 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
5663 : 0 : bnx2x_hc_int_enable(sc);
5664 : : } else {
5665 : 0 : bnx2x_igu_int_enable(sc);
5666 : : }
5667 : 0 : }
5668 : :
5669 : 0 : static void bnx2x_hc_int_disable(struct bnx2x_softc *sc)
5670 : : {
5671 : 0 : int port = SC_PORT(sc);
5672 [ # # ]: 0 : uint32_t addr = (port) ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0;
5673 : 0 : uint32_t val = REG_RD(sc, addr);
5674 : :
5675 : 0 : val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 |
5676 : : HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 |
5677 : : HC_CONFIG_0_REG_INT_LINE_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0);
5678 : : /* flush all outstanding writes */
5679 : : mb();
5680 : :
5681 : : REG_WR(sc, addr, val);
5682 [ # # ]: 0 : if (REG_RD(sc, addr) != val) {
5683 : 0 : PMD_DRV_LOG(ERR, sc, "proper val not read from HC IGU!");
5684 : : }
5685 : 0 : }
5686 : :
5687 : 0 : static void bnx2x_igu_int_disable(struct bnx2x_softc *sc)
5688 : : {
5689 : : uint32_t val = REG_RD(sc, IGU_REG_PF_CONFIGURATION);
5690 : :
5691 : 0 : val &= ~(IGU_PF_CONF_MSI_MSIX_EN |
5692 : : IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_ATTN_BIT_EN);
5693 : :
5694 : 0 : PMD_DRV_LOG(DEBUG, sc, "write %x to IGU", val);
5695 : :
5696 : : /* flush all outstanding writes */
5697 : : mb();
5698 : :
5699 : : REG_WR(sc, IGU_REG_PF_CONFIGURATION, val);
5700 [ # # ]: 0 : if (REG_RD(sc, IGU_REG_PF_CONFIGURATION) != val) {
5701 : 0 : PMD_DRV_LOG(ERR, sc, "proper val not read from IGU!");
5702 : : }
5703 : 0 : }
5704 : :
5705 : 0 : static void bnx2x_int_disable(struct bnx2x_softc *sc)
5706 : : {
5707 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
5708 : 0 : bnx2x_hc_int_disable(sc);
5709 : : } else {
5710 : 0 : bnx2x_igu_int_disable(sc);
5711 : : }
5712 : 0 : }
5713 : :
5714 : 0 : static void bnx2x_nic_init(struct bnx2x_softc *sc, int load_code)
5715 : : {
5716 : : int i;
5717 : :
5718 : 0 : PMD_INIT_FUNC_TRACE(sc);
5719 : :
5720 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
5721 : 0 : bnx2x_init_eth_fp(sc, i);
5722 : : }
5723 : :
5724 : : rmb(); /* ensure status block indices were read */
5725 : :
5726 : 0 : bnx2x_init_rx_rings(sc);
5727 : 0 : bnx2x_init_tx_rings(sc);
5728 : :
5729 [ # # ]: 0 : if (IS_VF(sc)) {
5730 : 0 : bnx2x_memset_stats(sc);
5731 : 0 : return;
5732 : : }
5733 : :
5734 : : /* initialize MOD_ABS interrupts */
5735 : 0 : elink_init_mod_abs_int(sc, &sc->link_vars,
5736 : : sc->devinfo.chip_id,
5737 : : sc->devinfo.shmem_base,
5738 : 0 : sc->devinfo.shmem2_base, SC_PORT(sc));
5739 : :
5740 : 0 : bnx2x_init_def_sb(sc);
5741 : : bnx2x_update_dsb_idx(sc);
5742 : : bnx2x_init_sp_ring(sc);
5743 : : bnx2x_init_eq_ring(sc);
5744 : 0 : bnx2x_init_internal(sc, load_code);
5745 : 0 : bnx2x_pf_init(sc);
5746 : 0 : bnx2x_stats_init(sc);
5747 : :
5748 : : /* flush all before enabling interrupts */
5749 : : mb();
5750 : :
5751 : 0 : bnx2x_int_enable(sc);
5752 : :
5753 : : /* check for SPIO5 */
5754 : 0 : bnx2x_attn_int_deasserted0(sc,
5755 : 0 : REG_RD(sc,
5756 : : (MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 +
5757 : : SC_PORT(sc) * 4)) &
5758 : : AEU_INPUTS_ATTN_BITS_SPIO5);
5759 : : }
5760 : :
5761 : 0 : static void bnx2x_init_objs(struct bnx2x_softc *sc)
5762 : : {
5763 : : /* mcast rules must be added to tx if tx switching is enabled */
5764 : : ecore_obj_type o_type;
5765 [ # # ]: 0 : if (sc->flags & BNX2X_TX_SWITCHING)
5766 : : o_type = ECORE_OBJ_TYPE_RX_TX;
5767 : : else
5768 : : o_type = ECORE_OBJ_TYPE_RX;
5769 : :
5770 : : /* RX_MODE controlling object */
5771 : 0 : ecore_init_rx_mode_obj(sc, &sc->rx_mode_obj);
5772 : :
5773 : : /* multicast configuration controlling object */
5774 : 0 : ecore_init_mcast_obj(sc,
5775 : : &sc->mcast_obj,
5776 : 0 : sc->fp[0].cl_id,
5777 : 0 : sc->fp[0].index,
5778 : : SC_FUNC(sc),
5779 : 0 : SC_FUNC(sc),
5780 : 0 : BNX2X_SP(sc, mcast_rdata),
5781 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, mcast_rdata),
5782 : : ECORE_FILTER_MCAST_PENDING,
5783 : : &sc->sp_state, o_type);
5784 : :
5785 : : /* Setup CAM credit pools */
5786 : 0 : ecore_init_mac_credit_pool(sc,
5787 : : &sc->macs_pool,
5788 : 0 : SC_FUNC(sc),
5789 [ # # ]: 0 : CHIP_IS_E1x(sc) ? VNICS_PER_PORT(sc) :
5790 [ # # ]: 0 : VNICS_PER_PATH(sc));
5791 : :
5792 : 0 : ecore_init_vlan_credit_pool(sc,
5793 : : &sc->vlans_pool,
5794 : 0 : SC_ABS_FUNC(sc) >> 1,
5795 [ # # ]: 0 : CHIP_IS_E1x(sc) ? VNICS_PER_PORT(sc) :
5796 [ # # ]: 0 : VNICS_PER_PATH(sc));
5797 : :
5798 : : /* RSS configuration object */
5799 : 0 : ecore_init_rss_config_obj(sc, &sc->rss_conf_obj, sc->fp->cl_id,
5800 : 0 : sc->fp->index, SC_FUNC(sc), SC_FUNC(sc),
5801 : 0 : BNX2X_SP(sc, rss_rdata),
5802 : 0 : (rte_iova_t)BNX2X_SP_MAPPING(sc, rss_rdata),
5803 : : ECORE_FILTER_RSS_CONF_PENDING, &sc->sp_state,
5804 : : ECORE_OBJ_TYPE_RX);
5805 : 0 : }
5806 : :
5807 : : /*
5808 : : * Initialize the function. This must be called before sending CLIENT_SETUP
5809 : : * for the first client.
5810 : : */
5811 : 0 : static int bnx2x_func_start(struct bnx2x_softc *sc)
5812 : : {
5813 [ # # ]: 0 : struct ecore_func_state_params func_params = { NULL };
5814 : : struct ecore_func_start_params *start_params =
5815 : : &func_params.params.start;
5816 : :
5817 : : /* Prepare parameters for function state transitions */
5818 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
5819 : :
5820 : 0 : func_params.f_obj = &sc->func_obj;
5821 : 0 : func_params.cmd = ECORE_F_CMD_START;
5822 : :
5823 : : /* Function parameters */
5824 : 0 : start_params->mf_mode = sc->devinfo.mf_info.mf_mode;
5825 : 0 : start_params->sd_vlan_tag = OVLAN(sc);
5826 : :
5827 [ # # # # ]: 0 : if (CHIP_IS_E2(sc) || CHIP_IS_E3(sc)) {
5828 : 0 : start_params->network_cos_mode = STATIC_COS;
5829 : : } else { /* CHIP_IS_E1X */
5830 : 0 : start_params->network_cos_mode = FW_WRR;
5831 : : }
5832 : :
5833 : 0 : return ecore_func_state_change(sc, &func_params);
5834 : : }
5835 : :
5836 : 0 : static int bnx2x_set_power_state(struct bnx2x_softc *sc, uint8_t state)
5837 : : {
5838 : : uint16_t pmcsr;
5839 : :
5840 : : /* If there is no power capability, silently succeed */
5841 [ # # ]: 0 : if (!(sc->devinfo.pcie_cap_flags & BNX2X_PM_CAPABLE_FLAG)) {
5842 : 0 : PMD_DRV_LOG(INFO, sc, "No power capability");
5843 : 0 : return 0;
5844 : : }
5845 : :
5846 : 0 : pci_read(sc, (sc->devinfo.pcie_pm_cap_reg + RTE_PCI_PM_CTRL), &pmcsr,
5847 : : 2);
5848 : :
5849 [ # # # ]: 0 : switch (state) {
5850 : 0 : case PCI_PM_D0:
5851 : 0 : pci_write_word(sc, (sc->devinfo.pcie_pm_cap_reg + RTE_PCI_PM_CTRL),
5852 : 0 : ((pmcsr & ~RTE_PCI_PM_CTRL_STATE_MASK) | RTE_PCI_PM_CTRL_PME_STATUS));
5853 : :
5854 [ # # ]: 0 : if (pmcsr & RTE_PCI_PM_CTRL_STATE_MASK) {
5855 : : /* delay required during transition out of D3hot */
5856 : 0 : DELAY(20000);
5857 : : }
5858 : :
5859 : : break;
5860 : :
5861 : 0 : case PCI_PM_D3hot:
5862 : : /* don't shut down the power for emulation and FPGA */
5863 [ # # ]: 0 : if (CHIP_REV_IS_SLOW(sc)) {
5864 : : return 0;
5865 : : }
5866 : :
5867 : 0 : pmcsr &= ~RTE_PCI_PM_CTRL_STATE_MASK;
5868 : : /* D3 power state */
5869 : 0 : pmcsr |= 0x3;
5870 : :
5871 [ # # ]: 0 : if (sc->wol) {
5872 : 0 : pmcsr |= RTE_PCI_PM_CTRL_PME_ENABLE;
5873 : : }
5874 : :
5875 : 0 : pci_write_long(sc,
5876 : 0 : (sc->devinfo.pcie_pm_cap_reg +
5877 : : RTE_PCI_PM_CTRL), pmcsr);
5878 : :
5879 : : /*
5880 : : * No more memory access after this point until device is brought back
5881 : : * to D0 state.
5882 : : */
5883 : 0 : break;
5884 : :
5885 : 0 : default:
5886 : 0 : PMD_DRV_LOG(NOTICE, sc, "Can't support PCI power state = %d",
5887 : : state);
5888 : 0 : return -1;
5889 : : }
5890 : :
5891 : : return 0;
5892 : : }
5893 : :
5894 : : /* return true if succeeded to acquire the lock */
5895 : 0 : static uint8_t bnx2x_trylock_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
5896 : : {
5897 : : uint32_t lock_status;
5898 : 0 : uint32_t resource_bit = (1 << resource);
5899 : 0 : int func = SC_FUNC(sc);
5900 : : uint32_t hw_lock_control_reg;
5901 : :
5902 : : /* Validating that the resource is within range */
5903 [ # # ]: 0 : if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
5904 : 0 : PMD_DRV_LOG(INFO, sc,
5905 : : "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)",
5906 : : resource, HW_LOCK_MAX_RESOURCE_VALUE);
5907 : 0 : return FALSE;
5908 : : }
5909 : :
5910 [ # # ]: 0 : if (func <= 5) {
5911 : 0 : hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func * 8);
5912 : : } else {
5913 : 0 : hw_lock_control_reg =
5914 : 0 : (MISC_REG_DRIVER_CONTROL_7 + (func - 6) * 8);
5915 : : }
5916 : :
5917 : : /* try to acquire the lock */
5918 : 0 : REG_WR(sc, hw_lock_control_reg + 4, resource_bit);
5919 : 0 : lock_status = REG_RD(sc, hw_lock_control_reg);
5920 [ # # ]: 0 : if (lock_status & resource_bit) {
5921 : : return TRUE;
5922 : : }
5923 : :
5924 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to get a resource lock 0x%x", resource);
5925 : :
5926 : 0 : return FALSE;
5927 : : }
5928 : :
5929 : : /*
5930 : : * Get the recovery leader resource id according to the engine this function
5931 : : * belongs to. Currently only 2 engines are supported.
5932 : : */
5933 : : static int bnx2x_get_leader_lock_resource(struct bnx2x_softc *sc)
5934 : : {
5935 [ # # # # ]: 0 : if (SC_PATH(sc)) {
5936 : : return HW_LOCK_RESOURCE_RECOVERY_LEADER_1;
5937 : : } else {
5938 : 0 : return HW_LOCK_RESOURCE_RECOVERY_LEADER_0;
5939 : : }
5940 : : }
5941 : :
5942 : : /* try to acquire a leader lock for current engine */
5943 : : static uint8_t bnx2x_trylock_leader_lock(struct bnx2x_softc *sc)
5944 : : {
5945 : 0 : return bnx2x_trylock_hw_lock(sc, bnx2x_get_leader_lock_resource(sc));
5946 : : }
5947 : :
5948 : : static int bnx2x_release_leader_lock(struct bnx2x_softc *sc)
5949 : : {
5950 : 0 : return bnx2x_release_hw_lock(sc, bnx2x_get_leader_lock_resource(sc));
5951 : : }
5952 : :
5953 : : /* close gates #2, #3 and #4 */
5954 : 0 : static void bnx2x_set_234_gates(struct bnx2x_softc *sc, uint8_t close)
5955 : : {
5956 : : uint32_t val;
5957 : :
5958 : : /* gates #2 and #4a are closed/opened */
5959 : : /* #4 */
5960 : 0 : REG_WR(sc, PXP_REG_HST_DISCARD_DOORBELLS, ! !close);
5961 : : /* #2 */
5962 : : REG_WR(sc, PXP_REG_HST_DISCARD_INTERNAL_WRITES, ! !close);
5963 : :
5964 : : /* #3 */
5965 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
5966 : : /* prevent interrupts from HC on both ports */
5967 : : val = REG_RD(sc, HC_REG_CONFIG_1);
5968 [ # # ]: 0 : if (close)
5969 : 0 : REG_WR(sc, HC_REG_CONFIG_1, (val & ~(uint32_t)
5970 : : HC_CONFIG_1_REG_BLOCK_DISABLE_1));
5971 : : else
5972 : 0 : REG_WR(sc, HC_REG_CONFIG_1,
5973 : : (val | HC_CONFIG_1_REG_BLOCK_DISABLE_1));
5974 : :
5975 : : val = REG_RD(sc, HC_REG_CONFIG_0);
5976 [ # # ]: 0 : if (close)
5977 : 0 : REG_WR(sc, HC_REG_CONFIG_0, (val & ~(uint32_t)
5978 : : HC_CONFIG_0_REG_BLOCK_DISABLE_0));
5979 : : else
5980 : 0 : REG_WR(sc, HC_REG_CONFIG_0,
5981 : : (val | HC_CONFIG_0_REG_BLOCK_DISABLE_0));
5982 : :
5983 : : } else {
5984 : : /* Prevent incoming interrupts in IGU */
5985 : : val = REG_RD(sc, IGU_REG_BLOCK_CONFIGURATION);
5986 : :
5987 [ # # ]: 0 : if (close)
5988 : 0 : REG_WR(sc, IGU_REG_BLOCK_CONFIGURATION,
5989 : : (val & ~(uint32_t)
5990 : : IGU_BLOCK_CONFIGURATION_REG_BLOCK_ENABLE));
5991 : : else
5992 : 0 : REG_WR(sc, IGU_REG_BLOCK_CONFIGURATION,
5993 : : (val |
5994 : : IGU_BLOCK_CONFIGURATION_REG_BLOCK_ENABLE));
5995 : : }
5996 : :
5997 : : wmb();
5998 : 0 : }
5999 : :
6000 : : /* poll for pending writes bit, it should get cleared in no more than 1s */
6001 : 0 : static int bnx2x_er_poll_igu_vq(struct bnx2x_softc *sc)
6002 : : {
6003 : : uint32_t cnt = 1000;
6004 : : uint32_t pend_bits = 0;
6005 : :
6006 : : do {
6007 : : pend_bits = REG_RD(sc, IGU_REG_PENDING_BITS_STATUS);
6008 : :
6009 [ # # ]: 0 : if (pend_bits == 0) {
6010 : : break;
6011 : : }
6012 : :
6013 : 0 : DELAY(1000);
6014 [ # # ]: 0 : } while (cnt-- > 0);
6015 : :
6016 [ # # ]: 0 : if (cnt <= 0) {
6017 : 0 : PMD_DRV_LOG(NOTICE, sc, "Still pending IGU requests bits=0x%08x!",
6018 : : pend_bits);
6019 : 0 : return -1;
6020 : : }
6021 : :
6022 : : return 0;
6023 : : }
6024 : :
6025 : : #define SHARED_MF_CLP_MAGIC 0x80000000 /* 'magic' bit */
6026 : :
6027 : : static void bnx2x_clp_reset_prep(struct bnx2x_softc *sc, uint32_t * magic_val)
6028 : : {
6029 : : /* Do some magic... */
6030 : 0 : uint32_t val = MFCFG_RD(sc, shared_mf_config.clp_mb);
6031 : 0 : *magic_val = val & SHARED_MF_CLP_MAGIC;
6032 : 0 : MFCFG_WR(sc, shared_mf_config.clp_mb, val | SHARED_MF_CLP_MAGIC);
6033 : : }
6034 : :
6035 : : /* restore the value of the 'magic' bit */
6036 : : static void bnx2x_clp_reset_done(struct bnx2x_softc *sc, uint32_t magic_val)
6037 : : {
6038 : : /* Restore the 'magic' bit value... */
6039 : 0 : uint32_t val = MFCFG_RD(sc, shared_mf_config.clp_mb);
6040 : 0 : MFCFG_WR(sc, shared_mf_config.clp_mb,
6041 : : (val & (~SHARED_MF_CLP_MAGIC)) | magic_val);
6042 : : }
6043 : :
6044 : : /* prepare for MCP reset, takes care of CLP configurations */
6045 : 0 : static void bnx2x_reset_mcp_prep(struct bnx2x_softc *sc, uint32_t * magic_val)
6046 : : {
6047 : : uint32_t shmem;
6048 : : uint32_t validity_offset;
6049 : :
6050 : : /* set `magic' bit in order to save MF config */
6051 : : bnx2x_clp_reset_prep(sc, magic_val);
6052 : :
6053 : : /* get shmem offset */
6054 : : shmem = REG_RD(sc, MISC_REG_SHARED_MEM_ADDR);
6055 : 0 : validity_offset =
6056 : 0 : offsetof(struct shmem_region, validity_map[SC_PORT(sc)]);
6057 : :
6058 : : /* Clear validity map flags */
6059 [ # # ]: 0 : if (shmem > 0) {
6060 : 0 : REG_WR(sc, shmem + validity_offset, 0);
6061 : : }
6062 : 0 : }
6063 : :
6064 : : #define MCP_TIMEOUT 5000 /* 5 seconds (in ms) */
6065 : : #define MCP_ONE_TIMEOUT 100 /* 100 ms */
6066 : :
6067 : : static void bnx2x_mcp_wait_one(struct bnx2x_softc *sc)
6068 : : {
6069 : : /* special handling for emulation and FPGA (10 times longer) */
6070 [ # # ]: 0 : if (CHIP_REV_IS_SLOW(sc)) {
6071 : 0 : DELAY((MCP_ONE_TIMEOUT * 10) * 1000);
6072 : : } else {
6073 : 0 : DELAY((MCP_ONE_TIMEOUT) * 1000);
6074 : : }
6075 : : }
6076 : :
6077 : : /* initialize shmem_base and waits for validity signature to appear */
6078 : 0 : static int bnx2x_init_shmem(struct bnx2x_softc *sc)
6079 : : {
6080 : : int cnt = 0;
6081 : : uint32_t val = 0;
6082 : :
6083 : : do {
6084 : 0 : sc->devinfo.shmem_base =
6085 : 0 : sc->link_params.shmem_base =
6086 : : REG_RD(sc, MISC_REG_SHARED_MEM_ADDR);
6087 : :
6088 [ # # ]: 0 : if (sc->devinfo.shmem_base) {
6089 : 0 : val = SHMEM_RD(sc, validity_map[SC_PORT(sc)]);
6090 [ # # ]: 0 : if (val & SHR_MEM_VALIDITY_MB)
6091 : : return 0;
6092 : : }
6093 : :
6094 : : bnx2x_mcp_wait_one(sc);
6095 : :
6096 [ # # ]: 0 : } while (cnt++ < (MCP_TIMEOUT / MCP_ONE_TIMEOUT));
6097 : :
6098 : 0 : PMD_DRV_LOG(NOTICE, sc, "BAD MCP validity signature");
6099 : :
6100 : 0 : return -1;
6101 : : }
6102 : :
6103 : 0 : static int bnx2x_reset_mcp_comp(struct bnx2x_softc *sc, uint32_t magic_val)
6104 : : {
6105 : 0 : int rc = bnx2x_init_shmem(sc);
6106 : :
6107 : : /* Restore the `magic' bit value */
6108 : : bnx2x_clp_reset_done(sc, magic_val);
6109 : :
6110 : 0 : return rc;
6111 : : }
6112 : :
6113 : : static void bnx2x_pxp_prep(struct bnx2x_softc *sc)
6114 : : {
6115 : : REG_WR(sc, PXP2_REG_RD_START_INIT, 0);
6116 : : REG_WR(sc, PXP2_REG_RQ_RBC_DONE, 0);
6117 : : wmb();
6118 : : }
6119 : :
6120 : : /*
6121 : : * Reset the whole chip except for:
6122 : : * - PCIE core
6123 : : * - PCI Glue, PSWHST, PXP/PXP2 RF (all controlled by one reset bit)
6124 : : * - IGU
6125 : : * - MISC (including AEU)
6126 : : * - GRC
6127 : : * - RBCN, RBCP
6128 : : */
6129 : 0 : static void bnx2x_process_kill_chip_reset(struct bnx2x_softc *sc, uint8_t global)
6130 : : {
6131 : : uint32_t not_reset_mask1, reset_mask1, not_reset_mask2, reset_mask2;
6132 : : uint32_t global_bits2, stay_reset2;
6133 : :
6134 : : /*
6135 : : * Bits that have to be set in reset_mask2 if we want to reset 'global'
6136 : : * (per chip) blocks.
6137 : : */
6138 : : global_bits2 =
6139 : : MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_CMN_CPU |
6140 : : MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_CMN_CORE;
6141 : :
6142 : : /*
6143 : : * Don't reset the following blocks.
6144 : : * Important: per port blocks (such as EMAC, BMAC, UMAC) can't be
6145 : : * reset, as in 4 port device they might still be owned
6146 : : * by the MCP (there is only one leader per path).
6147 : : */
6148 : : not_reset_mask1 =
6149 : : MISC_REGISTERS_RESET_REG_1_RST_HC |
6150 : : MISC_REGISTERS_RESET_REG_1_RST_PXPV |
6151 : : MISC_REGISTERS_RESET_REG_1_RST_PXP;
6152 : :
6153 : : not_reset_mask2 =
6154 : : MISC_REGISTERS_RESET_REG_2_RST_PCI_MDIO |
6155 : : MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE |
6156 : : MISC_REGISTERS_RESET_REG_2_RST_EMAC1_HARD_CORE |
6157 : : MISC_REGISTERS_RESET_REG_2_RST_MISC_CORE |
6158 : : MISC_REGISTERS_RESET_REG_2_RST_RBCN |
6159 : : MISC_REGISTERS_RESET_REG_2_RST_GRC |
6160 : : MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_REG_HARD_CORE |
6161 : : MISC_REGISTERS_RESET_REG_2_RST_MCP_N_HARD_CORE_RST_B |
6162 : : MISC_REGISTERS_RESET_REG_2_RST_ATC |
6163 : : MISC_REGISTERS_RESET_REG_2_PGLC |
6164 : : MISC_REGISTERS_RESET_REG_2_RST_BMAC0 |
6165 : : MISC_REGISTERS_RESET_REG_2_RST_BMAC1 |
6166 : : MISC_REGISTERS_RESET_REG_2_RST_EMAC0 |
6167 : : MISC_REGISTERS_RESET_REG_2_RST_EMAC1 |
6168 : : MISC_REGISTERS_RESET_REG_2_UMAC0 | MISC_REGISTERS_RESET_REG_2_UMAC1;
6169 : :
6170 : : /*
6171 : : * Keep the following blocks in reset:
6172 : : * - all xxMACs are handled by the elink code.
6173 : : */
6174 : : stay_reset2 =
6175 : : MISC_REGISTERS_RESET_REG_2_XMAC |
6176 : : MISC_REGISTERS_RESET_REG_2_XMAC_SOFT;
6177 : :
6178 : : /* Full reset masks according to the chip */
6179 : : reset_mask1 = 0xffffffff;
6180 : :
6181 [ # # ]: 0 : if (CHIP_IS_E1H(sc))
6182 : : reset_mask2 = 0x1ffff;
6183 [ # # ]: 0 : else if (CHIP_IS_E2(sc))
6184 : : reset_mask2 = 0xfffff;
6185 : : else /* CHIP_IS_E3 */
6186 : : reset_mask2 = 0x3ffffff;
6187 : :
6188 : : /* Don't reset global blocks unless we need to */
6189 [ # # ]: 0 : if (!global)
6190 : 0 : reset_mask2 &= ~global_bits2;
6191 : :
6192 : : /*
6193 : : * In case of attention in the QM, we need to reset PXP
6194 : : * (MISC_REGISTERS_RESET_REG_2_RST_PXP_RQ_RD_WR) before QM
6195 : : * because otherwise QM reset would release 'close the gates' shortly
6196 : : * before resetting the PXP, then the PSWRQ would send a write
6197 : : * request to PGLUE. Then when PXP is reset, PGLUE would try to
6198 : : * read the payload data from PSWWR, but PSWWR would not
6199 : : * respond. The write queue in PGLUE would stuck, dmae commands
6200 : : * would not return. Therefore it's important to reset the second
6201 : : * reset register (containing the
6202 : : * MISC_REGISTERS_RESET_REG_2_RST_PXP_RQ_RD_WR bit) before the
6203 : : * first one (containing the MISC_REGISTERS_RESET_REG_1_RST_QM
6204 : : * bit).
6205 : : */
6206 : 0 : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
6207 : : reset_mask2 & (~not_reset_mask2));
6208 : :
6209 : : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR,
6210 : : reset_mask1 & (~not_reset_mask1));
6211 : :
6212 : : mb();
6213 : : wmb();
6214 : :
6215 : 0 : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET,
6216 : : reset_mask2 & (~stay_reset2));
6217 : :
6218 : : mb();
6219 : : wmb();
6220 : :
6221 : : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, reset_mask1);
6222 : : wmb();
6223 : 0 : }
6224 : :
6225 : 0 : static int bnx2x_process_kill(struct bnx2x_softc *sc, uint8_t global)
6226 : : {
6227 : : int cnt = 1000;
6228 : 0 : uint32_t val = 0;
6229 : : uint32_t sr_cnt, blk_cnt, port_is_idle_0, port_is_idle_1, pgl_exp_rom2;
6230 : : uint32_t tags_63_32 = 0;
6231 : :
6232 : : /* Empty the Tetris buffer, wait for 1s */
6233 : : do {
6234 : : sr_cnt = REG_RD(sc, PXP2_REG_RD_SR_CNT);
6235 : : blk_cnt = REG_RD(sc, PXP2_REG_RD_BLK_CNT);
6236 : : port_is_idle_0 = REG_RD(sc, PXP2_REG_RD_PORT_IS_IDLE_0);
6237 : : port_is_idle_1 = REG_RD(sc, PXP2_REG_RD_PORT_IS_IDLE_1);
6238 : : pgl_exp_rom2 = REG_RD(sc, PXP2_REG_PGL_EXP_ROM2);
6239 [ # # ]: 0 : if (CHIP_IS_E3(sc)) {
6240 : : tags_63_32 = REG_RD(sc, PGLUE_B_REG_TAGS_63_32);
6241 : : }
6242 : :
6243 [ # # ]: 0 : if ((sr_cnt == 0x7e) && (blk_cnt == 0xa0) &&
6244 [ # # ]: 0 : ((port_is_idle_0 & 0x1) == 0x1) &&
6245 [ # # # # ]: 0 : ((port_is_idle_1 & 0x1) == 0x1) &&
6246 : 0 : (pgl_exp_rom2 == 0xffffffff) &&
6247 [ # # # # : 0 : (!CHIP_IS_E3(sc) || (tags_63_32 == 0xffffffff)))
# # # # #
# # # ]
6248 : : break;
6249 : 0 : DELAY(1000);
6250 [ # # ]: 0 : } while (cnt-- > 0);
6251 : :
6252 [ # # ]: 0 : if (cnt <= 0) {
6253 : 0 : PMD_DRV_LOG(NOTICE, sc,
6254 : : "ERROR: Tetris buffer didn't get empty or there "
6255 : : "are still outstanding read requests after 1s! "
6256 : : "sr_cnt=0x%08x, blk_cnt=0x%08x, port_is_idle_0=0x%08x, "
6257 : : "port_is_idle_1=0x%08x, pgl_exp_rom2=0x%08x",
6258 : : sr_cnt, blk_cnt, port_is_idle_0, port_is_idle_1,
6259 : : pgl_exp_rom2);
6260 : 0 : return -1;
6261 : : }
6262 : :
6263 : : mb();
6264 : :
6265 : : /* Close gates #2, #3 and #4 */
6266 : 0 : bnx2x_set_234_gates(sc, TRUE);
6267 : :
6268 : : /* Poll for IGU VQs for 57712 and newer chips */
6269 [ # # # # ]: 0 : if (!CHIP_IS_E1x(sc) && bnx2x_er_poll_igu_vq(sc)) {
6270 : : return -1;
6271 : : }
6272 : :
6273 : : /* clear "unprepared" bit */
6274 : : REG_WR(sc, MISC_REG_UNPREPARED, 0);
6275 : : mb();
6276 : :
6277 : : /* Make sure all is written to the chip before the reset */
6278 : : wmb();
6279 : :
6280 : : /*
6281 : : * Wait for 1ms to empty GLUE and PCI-E core queues,
6282 : : * PSWHST, GRC and PSWRD Tetris buffer.
6283 : : */
6284 : 0 : DELAY(1000);
6285 : :
6286 : : /* Prepare to chip reset: */
6287 : : /* MCP */
6288 [ # # ]: 0 : if (global) {
6289 : 0 : bnx2x_reset_mcp_prep(sc, &val);
6290 : : }
6291 : :
6292 : : /* PXP */
6293 : : bnx2x_pxp_prep(sc);
6294 : : mb();
6295 : :
6296 : : /* reset the chip */
6297 : 0 : bnx2x_process_kill_chip_reset(sc, global);
6298 : : mb();
6299 : :
6300 : : /* Recover after reset: */
6301 : : /* MCP */
6302 [ # # # # ]: 0 : if (global && bnx2x_reset_mcp_comp(sc, val)) {
6303 : : return -1;
6304 : : }
6305 : :
6306 : : /* Open the gates #2, #3 and #4 */
6307 : 0 : bnx2x_set_234_gates(sc, FALSE);
6308 : :
6309 : 0 : return 0;
6310 : : }
6311 : :
6312 : 0 : static int bnx2x_leader_reset(struct bnx2x_softc *sc)
6313 : : {
6314 : : int rc = 0;
6315 : : uint8_t global = bnx2x_reset_is_global(sc);
6316 : : uint32_t load_code;
6317 : :
6318 : : /*
6319 : : * If not going to reset MCP, load "fake" driver to reset HW while
6320 : : * driver is owner of the HW.
6321 : : */
6322 [ # # ]: 0 : if (!global && !BNX2X_NOMCP(sc)) {
6323 : : load_code = bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_REQ,
6324 : : DRV_MSG_CODE_LOAD_REQ_WITH_LFA);
6325 [ # # ]: 0 : if (!load_code) {
6326 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP response failure, aborting");
6327 : : rc = -1;
6328 : 0 : goto exit_leader_reset;
6329 : : }
6330 : :
6331 : 0 : if ((load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) &&
6332 [ # # ]: 0 : (load_code != FW_MSG_CODE_DRV_LOAD_COMMON)) {
6333 : 0 : PMD_DRV_LOG(NOTICE, sc,
6334 : : "MCP unexpected response, aborting");
6335 : : rc = -1;
6336 : 0 : goto exit_leader_reset2;
6337 : : }
6338 : :
6339 : : load_code = bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_DONE, 0);
6340 [ # # ]: 0 : if (!load_code) {
6341 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP response failure, aborting");
6342 : : rc = -1;
6343 : 0 : goto exit_leader_reset2;
6344 : : }
6345 : : }
6346 : :
6347 : : /* try to recover after the failure */
6348 [ # # ]: 0 : if (bnx2x_process_kill(sc, global)) {
6349 : 0 : PMD_DRV_LOG(NOTICE, sc, "Something bad occurred on engine %d!",
6350 : : SC_PATH(sc));
6351 : : rc = -1;
6352 : 0 : goto exit_leader_reset2;
6353 : : }
6354 : :
6355 : : /*
6356 : : * Clear the RESET_IN_PROGRESS and RESET_GLOBAL bits and update the driver
6357 : : * state.
6358 : : */
6359 : 0 : bnx2x_set_reset_done(sc);
6360 : : if (global) {
6361 : : bnx2x_clear_reset_global(sc);
6362 : : }
6363 : :
6364 : 0 : exit_leader_reset2:
6365 : :
6366 : : /* unload "fake driver" if it was loaded */
6367 [ # # ]: 0 : if (!global &&!BNX2X_NOMCP(sc)) {
6368 : : bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP, 0);
6369 : : bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_DONE, 0);
6370 : : }
6371 : :
6372 : 0 : exit_leader_reset:
6373 : :
6374 [ # # ]: 0 : sc->is_leader = 0;
6375 : : bnx2x_release_leader_lock(sc);
6376 : :
6377 : : mb();
6378 : 0 : return rc;
6379 : : }
6380 : :
6381 : : /*
6382 : : * prepare INIT transition, parameters configured:
6383 : : * - HC configuration
6384 : : * - Queue's CDU context
6385 : : */
6386 : : static void
6387 [ # # ]: 0 : bnx2x_pf_q_prep_init(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
6388 : : struct ecore_queue_init_params *init_params)
6389 : : {
6390 : : uint8_t cos;
6391 : : int cxt_index, cxt_offset;
6392 : :
6393 : : rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->rx.flags);
6394 : : rte_bit_relaxed_set32(ECORE_Q_FLG_HC, &init_params->tx.flags);
6395 : :
6396 : : rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->rx.flags);
6397 : : rte_bit_relaxed_set32(ECORE_Q_FLG_HC_EN, &init_params->tx.flags);
6398 : :
6399 : : /* HC rate */
6400 : 0 : init_params->rx.hc_rate =
6401 [ # # ]: 0 : sc->hc_rx_ticks ? (1000000 / sc->hc_rx_ticks) : 0;
6402 : 0 : init_params->tx.hc_rate =
6403 [ # # ]: 0 : sc->hc_tx_ticks ? (1000000 / sc->hc_tx_ticks) : 0;
6404 : :
6405 : : /* FW SB ID */
6406 : 0 : init_params->rx.fw_sb_id = init_params->tx.fw_sb_id = fp->fw_sb_id;
6407 : :
6408 : : /* CQ index among the SB indices */
6409 : 0 : init_params->rx.sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS;
6410 : 0 : init_params->tx.sb_cq_index = HC_INDEX_ETH_FIRST_TX_CQ_CONS;
6411 : :
6412 : : /* set maximum number of COSs supported by this queue */
6413 : 0 : init_params->max_cos = sc->max_cos;
6414 : :
6415 : : /* set the context pointers queue object */
6416 [ # # ]: 0 : for (cos = FIRST_TX_COS_INDEX; cos < init_params->max_cos; cos++) {
6417 : 0 : cxt_index = fp->index / ILT_PAGE_CIDS;
6418 : 0 : cxt_offset = fp->index - (cxt_index * ILT_PAGE_CIDS);
6419 : 0 : init_params->cxts[cos] =
6420 : 0 : &sc->context[cxt_index].vcxt[cxt_offset].eth;
6421 : : }
6422 : 0 : }
6423 : :
6424 : : /* set flags that are common for the Tx-only and not normal connections */
6425 : : static unsigned long
6426 : 0 : bnx2x_get_common_flags(struct bnx2x_softc *sc, uint8_t zero_stats)
6427 : : {
6428 [ # # ]: 0 : uint32_t flags = 0;
6429 : :
6430 : : /* PF driver will always initialize the Queue to an ACTIVE state */
6431 : : rte_bit_relaxed_set32(ECORE_Q_FLG_ACTIVE, &flags);
6432 : :
6433 : : /*
6434 : : * tx only connections collect statistics (on the same index as the
6435 : : * parent connection). The statistics are zeroed when the parent
6436 : : * connection is initialized.
6437 : : */
6438 : :
6439 : : rte_bit_relaxed_set32(ECORE_Q_FLG_STATS, &flags);
6440 [ # # ]: 0 : if (zero_stats) {
6441 : : rte_bit_relaxed_set32(ECORE_Q_FLG_ZERO_STATS, &flags);
6442 : : }
6443 : :
6444 : : /*
6445 : : * tx only connections can support tx-switching, though their
6446 : : * CoS-ness doesn't survive the loopback
6447 : : */
6448 [ # # ]: 0 : if (sc->flags & BNX2X_TX_SWITCHING) {
6449 : : rte_bit_relaxed_set32(ECORE_Q_FLG_TX_SWITCH, &flags);
6450 : : }
6451 : :
6452 : : rte_bit_relaxed_set32(ECORE_Q_FLG_PCSUM_ON_PKT, &flags);
6453 : :
6454 : 0 : return flags;
6455 : : }
6456 : :
6457 : 0 : static unsigned long bnx2x_get_q_flags(struct bnx2x_softc *sc, uint8_t leading)
6458 : : {
6459 : 0 : uint32_t flags = 0;
6460 : :
6461 [ # # # # ]: 0 : if (IS_MF_SD(sc)) {
6462 : : rte_bit_relaxed_set32(ECORE_Q_FLG_OV, &flags);
6463 : : }
6464 : :
6465 [ # # ]: 0 : if (leading) {
6466 : : rte_bit_relaxed_set32(ECORE_Q_FLG_LEADING_RSS, &flags);
6467 : : rte_bit_relaxed_set32(ECORE_Q_FLG_MCAST, &flags);
6468 : : }
6469 : :
6470 : : rte_bit_relaxed_set32(ECORE_Q_FLG_VLAN, &flags);
6471 : :
6472 : : /* merge with common flags */
6473 : 0 : return flags | bnx2x_get_common_flags(sc, TRUE);
6474 : : }
6475 : :
6476 : : static void
6477 : : bnx2x_pf_q_prep_general(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
6478 : : struct ecore_general_setup_params *gen_init, uint8_t cos)
6479 : : {
6480 : 0 : gen_init->stat_id = bnx2x_stats_id(fp);
6481 : 0 : gen_init->spcl_id = fp->cl_id;
6482 : 0 : gen_init->mtu = sc->mtu;
6483 : : gen_init->cos = cos;
6484 : : }
6485 : :
6486 : : static void
6487 : 0 : bnx2x_pf_rx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
6488 : : struct rxq_pause_params *pause,
6489 : : struct ecore_rxq_setup_params *rxq_init)
6490 : : {
6491 : : struct bnx2x_rx_queue *rxq;
6492 : :
6493 : 0 : rxq = sc->rx_queues[fp->index];
6494 [ # # ]: 0 : if (!rxq) {
6495 : : PMD_RX_LOG(ERR, "RX queue is NULL");
6496 : : return;
6497 : : }
6498 : : /* pause */
6499 [ # # # # ]: 0 : pause->bd_th_lo = BD_TH_LO(sc);
6500 [ # # # # ]: 0 : pause->bd_th_hi = BD_TH_HI(sc);
6501 : :
6502 [ # # # # ]: 0 : pause->rcq_th_lo = RCQ_TH_LO(sc);
6503 [ # # # # ]: 0 : pause->rcq_th_hi = RCQ_TH_HI(sc);
6504 : :
6505 : : /* validate rings have enough entries to cross high thresholds */
6506 [ # # ]: 0 : if (sc->dropless_fc &&
6507 [ # # ]: 0 : pause->bd_th_hi + FW_PREFETCH_CNT > sc->rx_ring_size) {
6508 : 0 : PMD_DRV_LOG(WARNING, sc, "rx bd ring threshold limit");
6509 : : }
6510 : :
6511 [ # # ]: 0 : if (sc->dropless_fc &&
6512 [ # # ]: 0 : pause->rcq_th_hi + FW_PREFETCH_CNT > USABLE_RCQ_ENTRIES(rxq)) {
6513 : 0 : PMD_DRV_LOG(WARNING, sc, "rcq ring threshold limit");
6514 : : }
6515 : :
6516 : 0 : pause->pri_map = 1;
6517 : :
6518 : : /* rxq setup */
6519 : 0 : rxq_init->dscr_map = (rte_iova_t)rxq->rx_ring_phys_addr;
6520 : 0 : rxq_init->rcq_map = (rte_iova_t)rxq->cq_ring_phys_addr;
6521 : 0 : rxq_init->rcq_np_map = (rte_iova_t)(rxq->cq_ring_phys_addr +
6522 : : BNX2X_PAGE_SIZE);
6523 : :
6524 : : /*
6525 : : * This should be a maximum number of data bytes that may be
6526 : : * placed on the BD (not including paddings).
6527 : : */
6528 : 0 : rxq_init->buf_sz = (fp->rx_buf_size - IP_HEADER_ALIGNMENT_PADDING);
6529 : :
6530 : 0 : rxq_init->cl_qzone_id = fp->cl_qzone_id;
6531 : 0 : rxq_init->rss_engine_id = SC_FUNC(sc);
6532 : 0 : rxq_init->mcast_engine_id = SC_FUNC(sc);
6533 : :
6534 : 0 : rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT;
6535 : 0 : rxq_init->fw_sb_id = fp->fw_sb_id;
6536 : :
6537 : 0 : rxq_init->sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS;
6538 : :
6539 : : /*
6540 : : * configure silent vlan removal
6541 : : * if multi function mode is afex, then mask default vlan
6542 : : */
6543 [ # # # # ]: 0 : if (IS_MF_AFEX(sc)) {
6544 : 0 : rxq_init->silent_removal_value =
6545 : 0 : sc->devinfo.mf_info.afex_def_vlan_tag;
6546 : 0 : rxq_init->silent_removal_mask = EVL_VLID_MASK;
6547 : : }
6548 : : }
6549 : :
6550 : : static void
6551 : : bnx2x_pf_tx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
6552 : : struct ecore_txq_setup_params *txq_init, uint8_t cos)
6553 : : {
6554 : 0 : struct bnx2x_tx_queue *txq = fp->sc->tx_queues[fp->index];
6555 : :
6556 [ # # ]: 0 : if (!txq) {
6557 : : PMD_TX_LOG(ERR, "ERROR: TX queue is NULL");
6558 : : return;
6559 : : }
6560 : 0 : txq_init->dscr_map = (rte_iova_t)txq->tx_ring_phys_addr;
6561 : 0 : txq_init->sb_cq_index = HC_INDEX_ETH_FIRST_TX_CQ_CONS + cos;
6562 : 0 : txq_init->traffic_type = LLFC_TRAFFIC_TYPE_NW;
6563 : 0 : txq_init->fw_sb_id = fp->fw_sb_id;
6564 : :
6565 : : /*
6566 : : * set the TSS leading client id for Tx classification to the
6567 : : * leading RSS client id
6568 : : */
6569 : 0 : txq_init->tss_leading_cl_id = BNX2X_FP(sc, 0, cl_id);
6570 : : }
6571 : :
6572 : : /*
6573 : : * This function performs 2 steps in a queue state machine:
6574 : : * 1) RESET->INIT
6575 : : * 2) INIT->SETUP
6576 : : */
6577 : : static int
6578 : 0 : bnx2x_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, uint8_t leading)
6579 : : {
6580 : 0 : struct ecore_queue_state_params q_params = { NULL };
6581 : : struct ecore_queue_setup_params *setup_params = &q_params.params.setup;
6582 : : int rc;
6583 : :
6584 : 0 : PMD_DRV_LOG(DEBUG, sc, "setting up queue %d", fp->index);
6585 : :
6586 : 0 : bnx2x_ack_sb(sc, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_ENABLE, 0);
6587 : :
6588 : 0 : q_params.q_obj = &BNX2X_SP_OBJ(sc, fp).q_obj;
6589 : :
6590 : : /* we want to wait for completion in this context */
6591 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
6592 : :
6593 : : /* prepare the INIT parameters */
6594 : 0 : bnx2x_pf_q_prep_init(sc, fp, &q_params.params.init);
6595 : :
6596 : : /* Set the command */
6597 : 0 : q_params.cmd = ECORE_Q_CMD_INIT;
6598 : :
6599 : : /* Change the state to INIT */
6600 : 0 : rc = ecore_queue_state_change(sc, &q_params);
6601 [ # # ]: 0 : if (rc) {
6602 : 0 : PMD_DRV_LOG(NOTICE, sc, "Queue(%d) INIT failed", fp->index);
6603 : 0 : return rc;
6604 : : }
6605 : :
6606 : 0 : PMD_DRV_LOG(DEBUG, sc, "init complete");
6607 : :
6608 : : /* now move the Queue to the SETUP state */
6609 : : memset(setup_params, 0, sizeof(*setup_params));
6610 : :
6611 : : /* set Queue flags */
6612 [ # # ]: 0 : setup_params->flags = bnx2x_get_q_flags(sc, leading);
6613 : :
6614 : : /* set general SETUP parameters */
6615 : : bnx2x_pf_q_prep_general(sc, fp, &setup_params->gen_params,
6616 : : FIRST_TX_COS_INDEX);
6617 : :
6618 : 0 : bnx2x_pf_rx_q_prep(sc, fp,
6619 : : &setup_params->pause_params,
6620 : : &setup_params->rxq_params);
6621 : :
6622 : : bnx2x_pf_tx_q_prep(sc, fp, &setup_params->txq_params, FIRST_TX_COS_INDEX);
6623 : :
6624 : : /* Set the command */
6625 : 0 : q_params.cmd = ECORE_Q_CMD_SETUP;
6626 : :
6627 : : /* change the state to SETUP */
6628 : 0 : rc = ecore_queue_state_change(sc, &q_params);
6629 [ # # ]: 0 : if (rc) {
6630 : 0 : PMD_DRV_LOG(NOTICE, sc, "Queue(%d) SETUP failed", fp->index);
6631 : 0 : return rc;
6632 : : }
6633 : :
6634 : : return rc;
6635 : : }
6636 : :
6637 : 0 : static int bnx2x_setup_leading(struct bnx2x_softc *sc)
6638 : : {
6639 [ # # ]: 0 : if (IS_PF(sc))
6640 : 0 : return bnx2x_setup_queue(sc, &sc->fp[0], TRUE);
6641 : : else /* VF */
6642 : 0 : return bnx2x_vf_setup_queue(sc, &sc->fp[0], TRUE);
6643 : : }
6644 : :
6645 : : static int
6646 : 0 : bnx2x_config_rss_pf(struct bnx2x_softc *sc, struct ecore_rss_config_obj *rss_obj,
6647 : : uint8_t config_hash)
6648 : : {
6649 : 0 : struct ecore_config_rss_params params = { NULL };
6650 : : uint32_t i;
6651 : :
6652 : : /*
6653 : : * Although RSS is meaningless when there is a single HW queue we
6654 : : * still need it enabled in order to have HW Rx hash generated.
6655 : : */
6656 : :
6657 [ # # ]: 0 : params.rss_obj = rss_obj;
6658 : :
6659 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, ¶ms.ramrod_flags);
6660 : :
6661 : : rte_bit_relaxed_set32(ECORE_RSS_MODE_REGULAR, ¶ms.rss_flags);
6662 : :
6663 : : /* RSS configuration */
6664 : : rte_bit_relaxed_set32(ECORE_RSS_IPV4, ¶ms.rss_flags);
6665 : : rte_bit_relaxed_set32(ECORE_RSS_IPV4_TCP, ¶ms.rss_flags);
6666 : : rte_bit_relaxed_set32(ECORE_RSS_IPV6, ¶ms.rss_flags);
6667 : : rte_bit_relaxed_set32(ECORE_RSS_IPV6_TCP, ¶ms.rss_flags);
6668 [ # # ]: 0 : if (rss_obj->udp_rss_v4) {
6669 : : rte_bit_relaxed_set32(ECORE_RSS_IPV4_UDP, ¶ms.rss_flags);
6670 : : }
6671 [ # # ]: 0 : if (rss_obj->udp_rss_v6) {
6672 : : rte_bit_relaxed_set32(ECORE_RSS_IPV6_UDP, ¶ms.rss_flags);
6673 : : }
6674 : :
6675 : : /* Hash bits */
6676 [ # # ]: 0 : params.rss_result_mask = MULTI_MASK;
6677 : :
6678 : : rte_memcpy(params.ind_table, rss_obj->ind_table,
6679 : : sizeof(params.ind_table));
6680 : :
6681 [ # # ]: 0 : if (config_hash) {
6682 : : /* RSS keys */
6683 [ # # ]: 0 : for (i = 0; i < sizeof(params.rss_key) / 4; i++) {
6684 : 0 : params.rss_key[i] = (uint32_t) rte_rand();
6685 : : }
6686 : :
6687 : : rte_bit_relaxed_set32(ECORE_RSS_SET_SRCH, ¶ms.rss_flags);
6688 : : }
6689 : :
6690 [ # # ]: 0 : if (IS_PF(sc))
6691 : 0 : return ecore_config_rss(sc, ¶ms);
6692 : : else
6693 : 0 : return bnx2x_vf_config_rss(sc, ¶ms);
6694 : : }
6695 : :
6696 : : static int bnx2x_config_rss_eth(struct bnx2x_softc *sc, uint8_t config_hash)
6697 : : {
6698 : 0 : return bnx2x_config_rss_pf(sc, &sc->rss_conf_obj, config_hash);
6699 : : }
6700 : :
6701 : 0 : static int bnx2x_init_rss_pf(struct bnx2x_softc *sc)
6702 : : {
6703 : 0 : uint8_t num_eth_queues = BNX2X_NUM_ETH_QUEUES(sc);
6704 : : uint32_t i;
6705 : :
6706 : : /*
6707 : : * Prepare the initial contents of the indirection table if
6708 : : * RSS is enabled
6709 : : */
6710 [ # # ]: 0 : for (i = 0; i < sizeof(sc->rss_conf_obj.ind_table); i++) {
6711 : 0 : sc->rss_conf_obj.ind_table[i] =
6712 : 0 : (sc->fp->cl_id + (i % num_eth_queues));
6713 : : }
6714 : :
6715 [ # # ]: 0 : if (sc->udp_rss) {
6716 : 0 : sc->rss_conf_obj.udp_rss_v4 = sc->rss_conf_obj.udp_rss_v6 = 1;
6717 : : }
6718 : :
6719 : : /*
6720 : : * For 57711 SEARCHER configuration (rss_keys) is
6721 : : * per-port, so if explicit configuration is needed, do it only
6722 : : * for a PMF.
6723 : : *
6724 : : * For 57712 and newer it's a per-function configuration.
6725 : : */
6726 [ # # # # ]: 0 : return bnx2x_config_rss_eth(sc, sc->port.pmf || !CHIP_IS_E1x(sc));
6727 : : }
6728 : :
6729 : : static int
6730 [ # # ]: 0 : bnx2x_set_mac_one(struct bnx2x_softc *sc, uint8_t * mac,
6731 : : struct ecore_vlan_mac_obj *obj, uint8_t set, int mac_type,
6732 : : uint32_t *ramrod_flags)
6733 : : {
6734 : : struct ecore_vlan_mac_ramrod_params ramrod_param;
6735 : : int rc;
6736 : :
6737 : : memset(&ramrod_param, 0, sizeof(ramrod_param));
6738 : :
6739 : : /* fill in general parameters */
6740 : 0 : ramrod_param.vlan_mac_obj = obj;
6741 [ # # ]: 0 : ramrod_param.ramrod_flags = *ramrod_flags;
6742 : :
6743 : : /* fill a user request section if needed */
6744 [ # # ]: 0 : if (!rte_bit_relaxed_get32(RAMROD_CONT, ramrod_flags)) {
6745 : : rte_memcpy(ramrod_param.user_req.u.mac.mac, mac,
6746 : : ETH_ALEN);
6747 : :
6748 : 0 : rte_bit_relaxed_set32(mac_type,
6749 : : &ramrod_param.user_req.vlan_mac_flags);
6750 : :
6751 : : /* Set the command: ADD or DEL */
6752 : 0 : ramrod_param.user_req.cmd = (set) ? ECORE_VLAN_MAC_ADD :
6753 : : ECORE_VLAN_MAC_DEL;
6754 : : }
6755 : :
6756 : 0 : rc = ecore_config_vlan_mac(sc, &ramrod_param);
6757 : :
6758 [ # # ]: 0 : if (rc == ECORE_EXISTS) {
6759 : 0 : PMD_DRV_LOG(INFO, sc, "Failed to schedule ADD operations (EEXIST)");
6760 : : /* do not treat adding same MAC as error */
6761 : : rc = 0;
6762 [ # # ]: 0 : } else if (rc < 0) {
6763 [ # # ]: 0 : PMD_DRV_LOG(ERR, sc,
6764 : : "%s MAC failed (%d)", (set ? "Set" : "Delete"), rc);
6765 : : }
6766 : :
6767 : 0 : return rc;
6768 : : }
6769 : :
6770 : 0 : static int bnx2x_set_eth_mac(struct bnx2x_softc *sc, uint8_t set)
6771 : : {
6772 : 0 : uint32_t ramrod_flags = 0;
6773 : :
6774 : 0 : PMD_DRV_LOG(DEBUG, sc, "Adding Ethernet MAC");
6775 : :
6776 : : rte_bit_relaxed_set32(RAMROD_COMP_WAIT, &ramrod_flags);
6777 : :
6778 : : /* Eth MAC is set on RSS leading client (fp[0]) */
6779 : 0 : return bnx2x_set_mac_one(sc, sc->link_params.mac_addr,
6780 : : &sc->sp_objs->mac_obj,
6781 : : set, ECORE_ETH_MAC, &ramrod_flags);
6782 : : }
6783 : :
6784 : 0 : static int bnx2x_get_cur_phy_idx(struct bnx2x_softc *sc)
6785 : : {
6786 : : uint32_t sel_phy_idx = 0;
6787 : :
6788 [ # # ]: 0 : if (sc->link_params.num_phys <= 1) {
6789 : : return ELINK_INT_PHY;
6790 : : }
6791 : :
6792 [ # # ]: 0 : if (sc->link_vars.link_up) {
6793 : : sel_phy_idx = ELINK_EXT_PHY1;
6794 : : /* In case link is SERDES, check if the ELINK_EXT_PHY2 is the one */
6795 [ # # ]: 0 : if ((sc->link_vars.link_status & LINK_STATUS_SERDES_LINK) &&
6796 [ # # ]: 0 : (sc->link_params.phy[ELINK_EXT_PHY2].supported &
6797 : : ELINK_SUPPORTED_FIBRE))
6798 : : sel_phy_idx = ELINK_EXT_PHY2;
6799 : : } else {
6800 [ # # # ]: 0 : switch (elink_phy_selection(&sc->link_params)) {
6801 : 0 : case PORT_HW_CFG_PHY_SELECTION_HARDWARE_DEFAULT:
6802 : : case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY:
6803 : : case PORT_HW_CFG_PHY_SELECTION_FIRST_PHY_PRIORITY:
6804 : : sel_phy_idx = ELINK_EXT_PHY1;
6805 : 0 : break;
6806 : 0 : case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY:
6807 : : case PORT_HW_CFG_PHY_SELECTION_SECOND_PHY_PRIORITY:
6808 : : sel_phy_idx = ELINK_EXT_PHY2;
6809 : 0 : break;
6810 : : }
6811 : : }
6812 : :
6813 : 0 : return sel_phy_idx;
6814 : : }
6815 : :
6816 : 0 : static int bnx2x_get_link_cfg_idx(struct bnx2x_softc *sc)
6817 : : {
6818 : 0 : uint32_t sel_phy_idx = bnx2x_get_cur_phy_idx(sc);
6819 : :
6820 : : /*
6821 : : * The selected activated PHY is always after swapping (in case PHY
6822 : : * swapping is enabled). So when swapping is enabled, we need to reverse
6823 : : * the configuration
6824 : : */
6825 : :
6826 [ # # ]: 0 : if (sc->link_params.multi_phy_config & PORT_HW_CFG_PHY_SWAPPED_ENABLED) {
6827 [ # # ]: 0 : if (sel_phy_idx == ELINK_EXT_PHY1)
6828 : : sel_phy_idx = ELINK_EXT_PHY2;
6829 [ # # ]: 0 : else if (sel_phy_idx == ELINK_EXT_PHY2)
6830 : : sel_phy_idx = ELINK_EXT_PHY1;
6831 : : }
6832 : :
6833 [ # # ]: 0 : return ELINK_LINK_CONFIG_IDX(sel_phy_idx);
6834 : : }
6835 : :
6836 : : static void bnx2x_set_requested_fc(struct bnx2x_softc *sc)
6837 : : {
6838 : : /*
6839 : : * Initialize link parameters structure variables
6840 : : * It is recommended to turn off RX FC for jumbo frames
6841 : : * for better performance
6842 : : */
6843 [ # # # # : 0 : if (CHIP_IS_E1x(sc) && (sc->mtu > 5000)) {
# # ]
6844 : 0 : sc->link_params.req_fc_auto_adv = ELINK_FLOW_CTRL_TX;
6845 : : } else {
6846 : 0 : sc->link_params.req_fc_auto_adv = ELINK_FLOW_CTRL_BOTH;
6847 : : }
6848 : : }
6849 : :
6850 : 0 : static void bnx2x_calc_fc_adv(struct bnx2x_softc *sc)
6851 : : {
6852 : 0 : uint8_t cfg_idx = bnx2x_get_link_cfg_idx(sc);
6853 [ # # # ]: 0 : switch (sc->link_vars.ieee_fc &
6854 : : MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) {
6855 : 0 : case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE:
6856 : : default:
6857 : 0 : sc->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause |
6858 : : ADVERTISED_Pause);
6859 : 0 : break;
6860 : :
6861 : 0 : case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH:
6862 : 0 : sc->port.advertising[cfg_idx] |= (ADVERTISED_Asym_Pause |
6863 : : ADVERTISED_Pause);
6864 : 0 : break;
6865 : :
6866 : 0 : case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC:
6867 : 0 : sc->port.advertising[cfg_idx] |= ADVERTISED_Asym_Pause;
6868 : 0 : break;
6869 : : }
6870 : 0 : }
6871 : :
6872 : 0 : static uint16_t bnx2x_get_mf_speed(struct bnx2x_softc *sc)
6873 : : {
6874 : 0 : uint16_t line_speed = sc->link_vars.line_speed;
6875 [ # # # # ]: 0 : if (IS_MF(sc)) {
6876 : 0 : uint16_t maxCfg = bnx2x_extract_max_cfg(sc,
6877 : : sc->devinfo.
6878 [ # # ]: 0 : mf_info.mf_config[SC_VN
6879 : : (sc)]);
6880 : :
6881 : : /* calculate the current MAX line speed limit for the MF devices */
6882 [ # # # # ]: 0 : if (IS_MF_SI(sc)) {
6883 : 0 : line_speed = (line_speed * maxCfg) / 100;
6884 : : } else { /* SD mode */
6885 : 0 : uint16_t vn_max_rate = maxCfg * 100;
6886 : :
6887 : : if (vn_max_rate < line_speed) {
6888 : : line_speed = vn_max_rate;
6889 : : }
6890 : : }
6891 : : }
6892 : :
6893 : 0 : return line_speed;
6894 : : }
6895 : :
6896 : : static void
6897 : 0 : bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *data)
6898 : : {
6899 : 0 : uint16_t line_speed = bnx2x_get_mf_speed(sc);
6900 : :
6901 : : memset(data, 0, sizeof(*data));
6902 : :
6903 : : /* fill the report data with the effective line speed */
6904 : 0 : data->line_speed = line_speed;
6905 : :
6906 : : /* Link is down */
6907 [ # # # # ]: 0 : if (!sc->link_vars.link_up || (sc->flags & BNX2X_MF_FUNC_DIS)) {
6908 : : rte_bit_relaxed_set32(BNX2X_LINK_REPORT_LINK_DOWN,
6909 : : &data->link_report_flags);
6910 : : }
6911 : :
6912 : : /* Full DUPLEX */
6913 [ # # ]: 0 : if (sc->link_vars.duplex == DUPLEX_FULL) {
6914 : : rte_bit_relaxed_set32(BNX2X_LINK_REPORT_FULL_DUPLEX,
6915 : : &data->link_report_flags);
6916 : : }
6917 : :
6918 : : /* Rx Flow Control is ON */
6919 [ # # ]: 0 : if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_RX) {
6920 : : rte_bit_relaxed_set32(BNX2X_LINK_REPORT_RX_FC_ON,
6921 : : &data->link_report_flags);
6922 : : }
6923 : :
6924 : : /* Tx Flow Control is ON */
6925 [ # # ]: 0 : if (sc->link_vars.flow_ctrl & ELINK_FLOW_CTRL_TX) {
6926 : : rte_bit_relaxed_set32(BNX2X_LINK_REPORT_TX_FC_ON,
6927 : : &data->link_report_flags);
6928 : : }
6929 : 0 : }
6930 : :
6931 : : /* report link status to OS, should be called under phy_lock */
6932 : 0 : static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
6933 : : {
6934 : : struct bnx2x_link_report_data cur_data;
6935 : :
6936 : : /* reread mf_cfg */
6937 [ # # ]: 0 : if (IS_PF(sc)) {
6938 : 0 : bnx2x_read_mf_cfg(sc);
6939 : : }
6940 : :
6941 : : /* Read the current link report info */
6942 : 0 : bnx2x_fill_report_data(sc, &cur_data);
6943 : :
6944 : : /* Don't report link down or exactly the same link status twice */
6945 [ # # # # ]: 0 : if (!memcmp(&cur_data, &sc->last_reported_link, sizeof(cur_data)) ||
6946 : : (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
6947 [ # # ]: 0 : &sc->last_reported_link.link_report_flags) &&
6948 : : rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
6949 : : &cur_data.link_report_flags))) {
6950 : 0 : return;
6951 : : }
6952 : :
6953 : 0 : ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x",
6954 : : cur_data.link_report_flags,
6955 : : sc->last_reported_link.link_report_flags);
6956 : :
6957 : 0 : sc->link_cnt++;
6958 : :
6959 : 0 : ELINK_DEBUG_P1(sc, "link status change count = %x", sc->link_cnt);
6960 : : /* report new link params and remember the state for the next time */
6961 : : rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
6962 : :
6963 [ # # ]: 0 : if (rte_bit_relaxed_get32(BNX2X_LINK_REPORT_LINK_DOWN,
6964 : : &cur_data.link_report_flags)) {
6965 : 0 : ELINK_DEBUG_P0(sc, "NIC Link is Down");
6966 : : } else {
6967 : : __rte_unused const char *duplex;
6968 : : __rte_unused const char *flow;
6969 : :
6970 [ # # ]: 0 : if (rte_bit_relaxed_test_and_clear32
6971 : : (BNX2X_LINK_REPORT_FULL_DUPLEX,
6972 : : &cur_data.link_report_flags)) {
6973 : : duplex = "full";
6974 : 0 : ELINK_DEBUG_P0(sc, "link set to full duplex");
6975 : : } else {
6976 : : duplex = "half";
6977 : 0 : ELINK_DEBUG_P0(sc, "link set to half duplex");
6978 : : }
6979 : :
6980 : : /*
6981 : : * Handle the FC at the end so that only these flags would be
6982 : : * possibly set. This way we may easily check if there is no FC
6983 : : * enabled.
6984 : : */
6985 [ # # ]: 0 : if (cur_data.link_report_flags) {
6986 [ # # ]: 0 : if (rte_bit_relaxed_get32
6987 : : (BNX2X_LINK_REPORT_RX_FC_ON,
6988 [ # # ]: 0 : &cur_data.link_report_flags) &&
6989 : : rte_bit_relaxed_get32(BNX2X_LINK_REPORT_TX_FC_ON,
6990 : : &cur_data.link_report_flags)) {
6991 : : flow = "ON - receive & transmit";
6992 [ # # ]: 0 : } else if (rte_bit_relaxed_get32
6993 : : (BNX2X_LINK_REPORT_RX_FC_ON,
6994 [ # # ]: 0 : &cur_data.link_report_flags) &&
6995 : : !rte_bit_relaxed_get32
6996 : : (BNX2X_LINK_REPORT_TX_FC_ON,
6997 : : &cur_data.link_report_flags)) {
6998 : : flow = "ON - receive";
6999 [ # # ]: 0 : } else if (!rte_bit_relaxed_get32
7000 : : (BNX2X_LINK_REPORT_RX_FC_ON,
7001 [ # # ]: 0 : &cur_data.link_report_flags) &&
7002 : : rte_bit_relaxed_get32
7003 : : (BNX2X_LINK_REPORT_TX_FC_ON,
7004 : : &cur_data.link_report_flags)) {
7005 : : flow = "ON - transmit";
7006 : : } else {
7007 : : flow = "none"; /* possible? */
7008 : : }
7009 : : } else {
7010 : : flow = "none";
7011 : : }
7012 : :
7013 : 0 : PMD_DRV_LOG(INFO, sc,
7014 : : "NIC Link is Up, %d Mbps %s duplex, Flow control: %s",
7015 : : cur_data.line_speed, duplex, flow);
7016 : : }
7017 : : }
7018 : :
7019 : : static void
7020 : 0 : bnx2x_link_report(struct bnx2x_softc *sc)
7021 : : {
7022 : 0 : bnx2x_acquire_phy_lock(sc);
7023 : 0 : bnx2x_link_report_locked(sc);
7024 : : bnx2x_release_phy_lock(sc);
7025 : 0 : }
7026 : :
7027 : 0 : void bnx2x_link_status_update(struct bnx2x_softc *sc)
7028 : : {
7029 [ # # ]: 0 : if (sc->state != BNX2X_STATE_OPEN) {
7030 : : return;
7031 : : }
7032 : :
7033 [ # # # # ]: 0 : if (IS_PF(sc) && !CHIP_REV_IS_SLOW(sc)) {
7034 : 0 : elink_link_status_update(&sc->link_params, &sc->link_vars);
7035 : : } else {
7036 : 0 : sc->port.supported[0] |= (ELINK_SUPPORTED_10baseT_Half |
7037 : : ELINK_SUPPORTED_10baseT_Full |
7038 : : ELINK_SUPPORTED_100baseT_Half |
7039 : : ELINK_SUPPORTED_100baseT_Full |
7040 : : ELINK_SUPPORTED_1000baseT_Full |
7041 : : ELINK_SUPPORTED_2500baseX_Full |
7042 : : ELINK_SUPPORTED_10000baseT_Full |
7043 : : ELINK_SUPPORTED_TP |
7044 : : ELINK_SUPPORTED_FIBRE |
7045 : : ELINK_SUPPORTED_Autoneg |
7046 : : ELINK_SUPPORTED_Pause |
7047 : : ELINK_SUPPORTED_Asym_Pause);
7048 : 0 : sc->port.advertising[0] = sc->port.supported[0];
7049 : :
7050 : 0 : sc->link_params.sc = sc;
7051 : 0 : sc->link_params.port = SC_PORT(sc);
7052 : 0 : sc->link_params.req_duplex[0] = DUPLEX_FULL;
7053 : 0 : sc->link_params.req_flow_ctrl[0] = ELINK_FLOW_CTRL_NONE;
7054 : 0 : sc->link_params.req_line_speed[0] = SPEED_10000;
7055 : 0 : sc->link_params.speed_cap_mask[0] = 0x7f0000;
7056 : 0 : sc->link_params.switch_cfg = ELINK_SWITCH_CFG_10G;
7057 : :
7058 [ # # # # ]: 0 : if (CHIP_REV_IS_FPGA(sc)) {
7059 : 0 : sc->link_vars.mac_type = ELINK_MAC_TYPE_EMAC;
7060 : 0 : sc->link_vars.line_speed = ELINK_SPEED_1000;
7061 : 0 : sc->link_vars.link_status = (LINK_STATUS_LINK_UP |
7062 : : LINK_STATUS_SPEED_AND_DUPLEX_1000TFD);
7063 : : } else {
7064 : 0 : sc->link_vars.mac_type = ELINK_MAC_TYPE_BMAC;
7065 : 0 : sc->link_vars.line_speed = ELINK_SPEED_10000;
7066 : 0 : sc->link_vars.link_status = (LINK_STATUS_LINK_UP |
7067 : : LINK_STATUS_SPEED_AND_DUPLEX_10GTFD);
7068 : : }
7069 : :
7070 : 0 : sc->link_vars.link_up = 1;
7071 : :
7072 : 0 : sc->link_vars.duplex = DUPLEX_FULL;
7073 : 0 : sc->link_vars.flow_ctrl = ELINK_FLOW_CTRL_NONE;
7074 : :
7075 [ # # ]: 0 : if (IS_PF(sc)) {
7076 : 0 : REG_WR(sc,
7077 : : NIG_REG_EGRESS_DRAIN0_MODE +
7078 : : sc->link_params.port * 4, 0);
7079 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_LINK_UP);
7080 : 0 : bnx2x_link_report(sc);
7081 : : }
7082 : : }
7083 : :
7084 [ # # ]: 0 : if (IS_PF(sc)) {
7085 [ # # ]: 0 : if (sc->link_vars.link_up) {
7086 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_LINK_UP);
7087 : : } else {
7088 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_STOP);
7089 : : }
7090 : 0 : bnx2x_link_report(sc);
7091 : : } else {
7092 : 0 : bnx2x_link_report_locked(sc);
7093 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_LINK_UP);
7094 : : }
7095 : : }
7096 : :
7097 : 0 : static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
7098 : : {
7099 : 0 : int rc, cfg_idx = bnx2x_get_link_cfg_idx(sc);
7100 : 0 : uint16_t req_line_speed = sc->link_params.req_line_speed[cfg_idx];
7101 [ # # ]: 0 : struct elink_params *lp = &sc->link_params;
7102 : :
7103 : : bnx2x_set_requested_fc(sc);
7104 : :
7105 : 0 : bnx2x_acquire_phy_lock(sc);
7106 : :
7107 [ # # ]: 0 : if (load_mode == LOAD_DIAG) {
7108 : 0 : lp->loopback_mode = ELINK_LOOPBACK_XGXS;
7109 : : /* Prefer doing PHY loopback at 10G speed, if possible */
7110 [ # # ]: 0 : if (lp->req_line_speed[cfg_idx] < ELINK_SPEED_10000) {
7111 [ # # ]: 0 : if (lp->speed_cap_mask[cfg_idx] &
7112 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) {
7113 : 0 : lp->req_line_speed[cfg_idx] = ELINK_SPEED_10000;
7114 : : } else {
7115 : 0 : lp->req_line_speed[cfg_idx] = ELINK_SPEED_1000;
7116 : : }
7117 : : }
7118 : : }
7119 : :
7120 [ # # ]: 0 : if (load_mode == LOAD_LOOPBACK_EXT) {
7121 : 0 : lp->loopback_mode = ELINK_LOOPBACK_EXT;
7122 : : }
7123 : :
7124 : 0 : rc = elink_phy_init(&sc->link_params, &sc->link_vars);
7125 : :
7126 : : bnx2x_release_phy_lock(sc);
7127 : :
7128 : 0 : bnx2x_calc_fc_adv(sc);
7129 : :
7130 [ # # ]: 0 : if (sc->link_vars.link_up) {
7131 : 0 : bnx2x_stats_handle(sc, STATS_EVENT_LINK_UP);
7132 : 0 : bnx2x_link_report(sc);
7133 : : }
7134 : :
7135 : 0 : sc->link_params.req_line_speed[cfg_idx] = req_line_speed;
7136 : 0 : return rc;
7137 : : }
7138 : :
7139 : : /* update flags in shmem */
7140 : : static void
7141 : 0 : bnx2x_update_drv_flags(struct bnx2x_softc *sc, uint32_t flags, uint32_t set)
7142 : : {
7143 : : uint32_t drv_flags;
7144 : :
7145 [ # # # # ]: 0 : if (SHMEM2_HAS(sc, drv_flags)) {
7146 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_DRV_FLAGS);
7147 : 0 : drv_flags = SHMEM2_RD(sc, drv_flags);
7148 : :
7149 [ # # ]: 0 : if (set) {
7150 : 0 : drv_flags |= flags;
7151 : : } else {
7152 : 0 : drv_flags &= ~flags;
7153 : : }
7154 : :
7155 : 0 : SHMEM2_WR(sc, drv_flags, drv_flags);
7156 : :
7157 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_DRV_FLAGS);
7158 : : }
7159 : 0 : }
7160 : :
7161 : : /* periodic timer callout routine, only runs when the interface is up */
7162 : 0 : void bnx2x_periodic_callout(struct bnx2x_softc *sc)
7163 : : {
7164 [ # # ]: 0 : if ((sc->state != BNX2X_STATE_OPEN) ||
7165 [ # # ]: 0 : (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP)) {
7166 : 0 : PMD_DRV_LOG(DEBUG, sc, "periodic callout exit (state=0x%x)",
7167 : : sc->state);
7168 : 0 : return;
7169 : : }
7170 [ # # ]: 0 : if (!CHIP_REV_IS_SLOW(sc)) {
7171 : : /*
7172 : : * This barrier is needed to ensure the ordering between the writing
7173 : : * to the sc->port.pmf in the bnx2x_nic_load() or bnx2x_pmf_update() and
7174 : : * the reading here.
7175 : : */
7176 : : mb();
7177 [ # # ]: 0 : if (sc->port.pmf) {
7178 : 0 : bnx2x_acquire_phy_lock(sc);
7179 : 0 : elink_period_func(&sc->link_params, &sc->link_vars);
7180 : : bnx2x_release_phy_lock(sc);
7181 : : }
7182 : : }
7183 : : #ifdef BNX2X_PULSE
7184 : : if (IS_PF(sc) && !BNX2X_NOMCP(sc)) {
7185 : : int mb_idx = SC_FW_MB_IDX(sc);
7186 : : uint32_t drv_pulse;
7187 : : uint32_t mcp_pulse;
7188 : :
7189 : : ++sc->fw_drv_pulse_wr_seq;
7190 : : sc->fw_drv_pulse_wr_seq &= DRV_PULSE_SEQ_MASK;
7191 : :
7192 : : drv_pulse = sc->fw_drv_pulse_wr_seq;
7193 : : bnx2x_drv_pulse(sc);
7194 : :
7195 : : mcp_pulse = (SHMEM_RD(sc, func_mb[mb_idx].mcp_pulse_mb) &
7196 : : MCP_PULSE_SEQ_MASK);
7197 : :
7198 : : /*
7199 : : * The delta between driver pulse and mcp response should
7200 : : * be 1 (before mcp response) or 0 (after mcp response).
7201 : : */
7202 : : if ((drv_pulse != mcp_pulse) &&
7203 : : (drv_pulse != ((mcp_pulse + 1) & MCP_PULSE_SEQ_MASK))) {
7204 : : /* someone lost a heartbeat... */
7205 : : PMD_DRV_LOG(ERR, sc,
7206 : : "drv_pulse (0x%x) != mcp_pulse (0x%x)",
7207 : : drv_pulse, mcp_pulse);
7208 : : }
7209 : : }
7210 : : #endif
7211 : : }
7212 : :
7213 : : /* start the controller */
7214 : : static __rte_noinline
7215 : 0 : int bnx2x_nic_load(struct bnx2x_softc *sc)
7216 : : {
7217 : : uint32_t val;
7218 : 0 : uint32_t load_code = 0;
7219 : : int i, rc = 0;
7220 : :
7221 : 0 : PMD_INIT_FUNC_TRACE(sc);
7222 : :
7223 : 0 : sc->state = BNX2X_STATE_OPENING_WAITING_LOAD;
7224 : :
7225 [ # # ]: 0 : if (IS_PF(sc)) {
7226 : : /* must be called before memory allocation and HW init */
7227 : 0 : bnx2x_ilt_set_info(sc);
7228 : : }
7229 : :
7230 : : bnx2x_set_fp_rx_buf_size(sc);
7231 : :
7232 [ # # ]: 0 : if (IS_PF(sc)) {
7233 [ # # ]: 0 : if (bnx2x_alloc_mem(sc) != 0) {
7234 : 0 : sc->state = BNX2X_STATE_CLOSED;
7235 : : rc = -ENOMEM;
7236 : 0 : goto bnx2x_nic_load_error0;
7237 : : }
7238 : : }
7239 : :
7240 : : /* allocate the host hardware/software hsi structures */
7241 [ # # ]: 0 : if (bnx2x_alloc_hsi_mem(sc) != 0) {
7242 : 0 : PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_hsi_mem was failed");
7243 : 0 : sc->state = BNX2X_STATE_CLOSED;
7244 : : rc = -ENOMEM;
7245 : 0 : goto bnx2x_nic_load_error0;
7246 : : }
7247 : :
7248 [ # # ]: 0 : if (bnx2x_alloc_fw_stats_mem(sc) != 0) {
7249 : 0 : sc->state = BNX2X_STATE_CLOSED;
7250 : : rc = -ENOMEM;
7251 : 0 : goto bnx2x_nic_load_error0;
7252 : : }
7253 : :
7254 [ # # ]: 0 : if (IS_VF(sc)) {
7255 : 0 : rc = bnx2x_vf_init(sc);
7256 [ # # ]: 0 : if (rc) {
7257 : 0 : sc->state = BNX2X_STATE_ERROR;
7258 : 0 : goto bnx2x_nic_load_error0;
7259 : : }
7260 : : }
7261 : :
7262 [ # # ]: 0 : if (IS_PF(sc)) {
7263 : : /* set pf load just before approaching the MCP */
7264 : 0 : bnx2x_set_pf_load(sc);
7265 : :
7266 : : /* if MCP exists send load request and analyze response */
7267 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
7268 : : /* attempt to load pf */
7269 [ # # ]: 0 : if (bnx2x_nic_load_request(sc, &load_code) != 0) {
7270 : 0 : sc->state = BNX2X_STATE_CLOSED;
7271 : : rc = -ENXIO;
7272 : 0 : goto bnx2x_nic_load_error1;
7273 : : }
7274 : :
7275 : : /* what did the MCP say? */
7276 [ # # ]: 0 : if (bnx2x_nic_load_analyze_req(sc, load_code) != 0) {
7277 : : bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_DONE, 0);
7278 : 0 : sc->state = BNX2X_STATE_CLOSED;
7279 : : rc = -ENXIO;
7280 : 0 : goto bnx2x_nic_load_error2;
7281 : : }
7282 : : } else {
7283 : 0 : PMD_DRV_LOG(INFO, sc, "Device has no MCP!");
7284 : 0 : load_code = bnx2x_nic_load_no_mcp(sc);
7285 : : }
7286 : :
7287 : : /* mark PMF if applicable */
7288 : 0 : bnx2x_nic_load_pmf(sc, load_code);
7289 : :
7290 : : /* Init Function state controlling object */
7291 : 0 : bnx2x_init_func_obj(sc);
7292 : :
7293 : : /* Initialize HW */
7294 [ # # ]: 0 : if (bnx2x_init_hw(sc, load_code) != 0) {
7295 : 0 : PMD_DRV_LOG(NOTICE, sc, "HW init failed");
7296 : : bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_DONE, 0);
7297 : 0 : sc->state = BNX2X_STATE_CLOSED;
7298 : : rc = -ENXIO;
7299 : 0 : goto bnx2x_nic_load_error2;
7300 : : }
7301 : : }
7302 : :
7303 : 0 : bnx2x_nic_init(sc, load_code);
7304 : :
7305 : : /* Init per-function objects */
7306 [ # # ]: 0 : if (IS_PF(sc)) {
7307 : 0 : bnx2x_init_objs(sc);
7308 : :
7309 : : /* set AFEX default VLAN tag to an invalid value */
7310 : 0 : sc->devinfo.mf_info.afex_def_vlan_tag = -1;
7311 : :
7312 : 0 : sc->state = BNX2X_STATE_OPENING_WAITING_PORT;
7313 : 0 : rc = bnx2x_func_start(sc);
7314 [ # # ]: 0 : if (rc) {
7315 : 0 : PMD_DRV_LOG(NOTICE, sc, "Function start failed!");
7316 : : bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_DONE, 0);
7317 : 0 : sc->state = BNX2X_STATE_ERROR;
7318 : 0 : goto bnx2x_nic_load_error3;
7319 : : }
7320 : :
7321 : : /* send LOAD_DONE command to MCP */
7322 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
7323 : 0 : load_code =
7324 : : bnx2x_fw_command(sc, DRV_MSG_CODE_LOAD_DONE, 0);
7325 [ # # ]: 0 : if (!load_code) {
7326 : 0 : PMD_DRV_LOG(NOTICE, sc,
7327 : : "MCP response failure, aborting");
7328 : 0 : sc->state = BNX2X_STATE_ERROR;
7329 : : rc = -ENXIO;
7330 : 0 : goto bnx2x_nic_load_error3;
7331 : : }
7332 : : }
7333 : : }
7334 : :
7335 : 0 : rc = bnx2x_setup_leading(sc);
7336 [ # # ]: 0 : if (rc) {
7337 : 0 : PMD_DRV_LOG(NOTICE, sc, "Setup leading failed!");
7338 : 0 : sc->state = BNX2X_STATE_ERROR;
7339 : 0 : goto bnx2x_nic_load_error3;
7340 : : }
7341 : :
7342 [ # # ]: 0 : FOR_EACH_NONDEFAULT_ETH_QUEUE(sc, i) {
7343 [ # # ]: 0 : if (IS_PF(sc))
7344 : 0 : rc = bnx2x_setup_queue(sc, &sc->fp[i], FALSE);
7345 : : else /* IS_VF(sc) */
7346 : 0 : rc = bnx2x_vf_setup_queue(sc, &sc->fp[i], FALSE);
7347 : :
7348 [ # # ]: 0 : if (rc) {
7349 : 0 : PMD_DRV_LOG(NOTICE, sc, "Queue(%d) setup failed", i);
7350 : 0 : sc->state = BNX2X_STATE_ERROR;
7351 : 0 : goto bnx2x_nic_load_error3;
7352 : : }
7353 : : }
7354 : :
7355 : 0 : rc = bnx2x_init_rss_pf(sc);
7356 [ # # ]: 0 : if (rc) {
7357 : 0 : PMD_DRV_LOG(NOTICE, sc, "PF RSS init failed");
7358 : 0 : sc->state = BNX2X_STATE_ERROR;
7359 : 0 : goto bnx2x_nic_load_error3;
7360 : : }
7361 : :
7362 : : /* now when Clients are configured we are ready to work */
7363 : 0 : sc->state = BNX2X_STATE_OPEN;
7364 : :
7365 : : /* Configure a ucast MAC */
7366 [ # # ]: 0 : if (IS_PF(sc)) {
7367 : 0 : rc = bnx2x_set_eth_mac(sc, TRUE);
7368 : : } else { /* IS_VF(sc) */
7369 : 0 : rc = bnx2x_vf_set_mac(sc, TRUE);
7370 : : }
7371 : :
7372 [ # # ]: 0 : if (rc) {
7373 : 0 : PMD_DRV_LOG(NOTICE, sc, "Setting Ethernet MAC failed");
7374 : 0 : sc->state = BNX2X_STATE_ERROR;
7375 : 0 : goto bnx2x_nic_load_error3;
7376 : : }
7377 : :
7378 [ # # ]: 0 : if (sc->port.pmf) {
7379 : 0 : rc = bnx2x_initial_phy_init(sc, LOAD_OPEN);
7380 [ # # ]: 0 : if (rc) {
7381 : 0 : sc->state = BNX2X_STATE_ERROR;
7382 : 0 : goto bnx2x_nic_load_error3;
7383 : : }
7384 : : }
7385 : :
7386 : 0 : sc->link_params.feature_config_flags &=
7387 : : ~ELINK_FEATURE_CONFIG_BOOT_FROM_SAN;
7388 : :
7389 : : /* start the Tx */
7390 : : switch (LOAD_OPEN) {
7391 : : case LOAD_NORMAL:
7392 : : case LOAD_OPEN:
7393 : : break;
7394 : :
7395 : : case LOAD_DIAG:
7396 : : case LOAD_LOOPBACK_EXT:
7397 : : sc->state = BNX2X_STATE_DIAG;
7398 : : break;
7399 : :
7400 : : default:
7401 : : break;
7402 : : }
7403 : :
7404 [ # # ]: 0 : if (sc->port.pmf) {
7405 : 0 : bnx2x_update_drv_flags(sc, 1 << DRV_FLAGS_PORT_MASK, 0);
7406 : : } else {
7407 : 0 : bnx2x_link_status_update(sc);
7408 : : }
7409 : :
7410 [ # # # # : 0 : if (IS_PF(sc) && SHMEM2_HAS(sc, drv_capabilities_flag)) {
# # ]
7411 : : /* mark driver is loaded in shmem2 */
7412 [ # # # # ]: 0 : val = SHMEM2_RD(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)]);
7413 [ # # # # ]: 0 : SHMEM2_WR(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)],
7414 : : (val |
7415 : : DRV_FLAGS_CAPABILITIES_LOADED_SUPPORTED |
7416 : : DRV_FLAGS_CAPABILITIES_LOADED_L2));
7417 : : }
7418 : :
7419 : : /* start fast path */
7420 : : /* Initialize Rx filter */
7421 : 0 : bnx2x_set_rx_mode(sc);
7422 : :
7423 : : /* wait for all pending SP commands to complete */
7424 [ # # # # ]: 0 : if (IS_PF(sc) && !bnx2x_wait_sp_comp(sc, ~0x0U)) {
7425 : 0 : PMD_DRV_LOG(NOTICE, sc, "Timeout waiting for all SPs to complete!");
7426 : 0 : bnx2x_periodic_stop(sc);
7427 : 0 : bnx2x_nic_unload(sc, UNLOAD_CLOSE, FALSE);
7428 : 0 : return -ENXIO;
7429 : : }
7430 : :
7431 : 0 : PMD_DRV_LOG(DEBUG, sc, "NIC successfully loaded");
7432 : :
7433 : 0 : return 0;
7434 : :
7435 : 0 : bnx2x_nic_load_error3:
7436 : :
7437 [ # # ]: 0 : if (IS_PF(sc)) {
7438 : : bnx2x_int_disable_sync(sc, 1);
7439 : :
7440 : : /* clean out queued objects */
7441 : 0 : bnx2x_squeeze_objects(sc);
7442 : : }
7443 : :
7444 : 0 : bnx2x_nic_load_error2:
7445 : :
7446 [ # # ]: 0 : if (IS_PF(sc) && !BNX2X_NOMCP(sc)) {
7447 : : bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP, 0);
7448 : : bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_DONE, 0);
7449 : : }
7450 : :
7451 : 0 : sc->port.pmf = 0;
7452 : :
7453 : 0 : bnx2x_nic_load_error1:
7454 : :
7455 : : /* clear pf_load status, as it was already set */
7456 [ # # ]: 0 : if (IS_PF(sc)) {
7457 : 0 : bnx2x_clear_pf_load(sc);
7458 : : }
7459 : :
7460 : 0 : bnx2x_nic_load_error0:
7461 : :
7462 : : bnx2x_free_fw_stats_mem(sc);
7463 : 0 : bnx2x_free_hsi_mem(sc);
7464 : 0 : bnx2x_free_mem(sc);
7465 : :
7466 : 0 : return rc;
7467 : : }
7468 : :
7469 : : /*
7470 : : * Handles controller initialization.
7471 : : */
7472 : 0 : int bnx2x_init(struct bnx2x_softc *sc)
7473 : : {
7474 : 0 : int other_engine = SC_PATH(sc) ? 0 : 1;
7475 : : uint8_t other_load_status, load_status;
7476 : 0 : uint8_t global = FALSE;
7477 : : int rc;
7478 : :
7479 : : /* Check if the driver is still running and bail out if it is. */
7480 [ # # ]: 0 : if (sc->state != BNX2X_STATE_CLOSED) {
7481 : 0 : PMD_DRV_LOG(DEBUG, sc, "Init called while driver is running!");
7482 : : rc = 0;
7483 : 0 : goto bnx2x_init_done;
7484 : : }
7485 : :
7486 : 0 : bnx2x_set_power_state(sc, PCI_PM_D0);
7487 : :
7488 : : /*
7489 : : * If parity occurred during the unload, then attentions and/or
7490 : : * RECOVERY_IN_PROGRESS may still be set. If so we want the first function
7491 : : * loaded on the current engine to complete the recovery. Parity recovery
7492 : : * is only relevant for PF driver.
7493 : : */
7494 [ # # ]: 0 : if (IS_PF(sc)) {
7495 : : other_load_status = bnx2x_get_load_status(sc, other_engine);
7496 [ # # ]: 0 : load_status = bnx2x_get_load_status(sc, SC_PATH(sc));
7497 : :
7498 [ # # # # ]: 0 : if (!bnx2x_reset_is_done(sc, SC_PATH(sc)) ||
7499 : 0 : bnx2x_chk_parity_attn(sc, &global, TRUE)) {
7500 : : do {
7501 : : /*
7502 : : * If there are attentions and they are in global blocks, set
7503 : : * the GLOBAL_RESET bit regardless whether it will be this
7504 : : * function that will complete the recovery or not.
7505 : : */
7506 [ # # ]: 0 : if (global) {
7507 : 0 : bnx2x_set_reset_global(sc);
7508 : : }
7509 : :
7510 : : /*
7511 : : * Only the first function on the current engine should try
7512 : : * to recover in open. In case of attentions in global blocks
7513 : : * only the first in the chip should try to recover.
7514 : : */
7515 [ # # ]: 0 : if ((!load_status
7516 [ # # # # ]: 0 : && (!global ||!other_load_status))
7517 [ # # ]: 0 : && bnx2x_trylock_leader_lock(sc)
7518 [ # # ]: 0 : && !bnx2x_leader_reset(sc)) {
7519 : 0 : PMD_DRV_LOG(INFO, sc,
7520 : : "Recovered during init");
7521 : 0 : break;
7522 : : }
7523 : :
7524 : : /* recovery has failed... */
7525 : 0 : bnx2x_set_power_state(sc, PCI_PM_D3hot);
7526 : :
7527 : 0 : sc->recovery_state = BNX2X_RECOVERY_FAILED;
7528 : :
7529 : 0 : PMD_DRV_LOG(NOTICE, sc,
7530 : : "Recovery flow hasn't properly "
7531 : : "completed yet, try again later. "
7532 : : "If you still see this message after a "
7533 : : "few retries then power cycle is required.");
7534 : :
7535 : : rc = -ENXIO;
7536 : 0 : goto bnx2x_init_done;
7537 : : } while (0);
7538 : : }
7539 : : }
7540 : :
7541 : 0 : sc->recovery_state = BNX2X_RECOVERY_DONE;
7542 : :
7543 : 0 : rc = bnx2x_nic_load(sc);
7544 : :
7545 : : bnx2x_init_done:
7546 : :
7547 [ # # ]: 0 : if (rc) {
7548 : 0 : PMD_DRV_LOG(NOTICE, sc, "Initialization failed, "
7549 : : "stack notified driver is NOT running!");
7550 : : }
7551 : :
7552 : 0 : return rc;
7553 : : }
7554 : :
7555 : 0 : static void bnx2x_get_function_num(struct bnx2x_softc *sc)
7556 : : {
7557 : : uint32_t val = 0;
7558 : :
7559 : : /*
7560 : : * Read the ME register to get the function number. The ME register
7561 : : * holds the relative-function number and absolute-function number. The
7562 : : * absolute-function number appears only in E2 and above. Before that
7563 : : * these bits always contained zero, therefore we cannot blindly use them.
7564 : : */
7565 : :
7566 : : val = REG_RD(sc, BAR_ME_REGISTER);
7567 : :
7568 : 0 : sc->pfunc_rel =
7569 : 0 : (uint8_t) ((val & ME_REG_PF_NUM) >> ME_REG_PF_NUM_SHIFT);
7570 : 0 : sc->path_id =
7571 : 0 : (uint8_t) ((val & ME_REG_ABS_PF_NUM) >> ME_REG_ABS_PF_NUM_SHIFT) &
7572 : : 1;
7573 : :
7574 [ # # ]: 0 : if (CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) {
7575 : 0 : sc->pfunc_abs = ((sc->pfunc_rel << 1) | sc->path_id);
7576 : : } else {
7577 : 0 : sc->pfunc_abs = (sc->pfunc_rel | sc->path_id);
7578 : : }
7579 : :
7580 : 0 : PMD_DRV_LOG(DEBUG, sc,
7581 : : "Relative function %d, Absolute function %d, Path %d",
7582 : : sc->pfunc_rel, sc->pfunc_abs, sc->path_id);
7583 : 0 : }
7584 : :
7585 : : static uint32_t bnx2x_get_shmem_mf_cfg_base(struct bnx2x_softc *sc)
7586 : : {
7587 : : uint32_t shmem2_size;
7588 : : uint32_t offset;
7589 : : uint32_t mf_cfg_offset_value;
7590 : :
7591 : : /* Non 57712 */
7592 : 0 : offset = (SHMEM_ADDR(sc, func_mb) +
7593 : : (MAX_FUNC_NUM * sizeof(struct drv_func_mb)));
7594 : :
7595 : : /* 57712 plus */
7596 [ # # ]: 0 : if (sc->devinfo.shmem2_base != 0) {
7597 : 0 : shmem2_size = SHMEM2_RD(sc, size);
7598 [ # # ]: 0 : if (shmem2_size > offsetof(struct shmem2_region, mf_cfg_addr)) {
7599 : 0 : mf_cfg_offset_value = SHMEM2_RD(sc, mf_cfg_addr);
7600 [ # # ]: 0 : if (SHMEM_MF_CFG_ADDR_NONE != mf_cfg_offset_value) {
7601 : : offset = mf_cfg_offset_value;
7602 : : }
7603 : : }
7604 : : }
7605 : :
7606 : : return offset;
7607 : : }
7608 : :
7609 : 0 : static uint32_t bnx2x_pcie_capability_read(struct bnx2x_softc *sc, int reg)
7610 : : {
7611 : : uint32_t ret;
7612 : : struct bnx2x_pci_cap *caps;
7613 : :
7614 : : /* ensure PCIe capability is enabled */
7615 : : caps = pci_find_cap(sc, RTE_PCI_CAP_ID_EXP, BNX2X_PCI_CAP);
7616 [ # # ]: 0 : if (NULL != caps) {
7617 : 0 : PMD_DRV_LOG(DEBUG, sc, "Found PCIe capability: "
7618 : : "id=0x%04X type=0x%04X addr=0x%08X",
7619 : : caps->id, caps->type, caps->addr);
7620 : 0 : pci_read(sc, (caps->addr + reg), &ret, 2);
7621 : 0 : return ret;
7622 : : }
7623 : :
7624 : 0 : PMD_DRV_LOG(WARNING, sc, "PCIe capability NOT FOUND!!!");
7625 : :
7626 : 0 : return 0;
7627 : : }
7628 : :
7629 : : static uint8_t bnx2x_is_pcie_pending(struct bnx2x_softc *sc)
7630 : : {
7631 : 0 : return bnx2x_pcie_capability_read(sc, RTE_PCI_EXP_TYPE_RC_EC) &
7632 : : RTE_PCI_EXP_DEVSTA_TRPND;
7633 : : }
7634 : :
7635 : : /*
7636 : : * Walk the PCI capabilities list for the device to find what features are
7637 : : * supported. These capabilities may be enabled/disabled by firmware so it's
7638 : : * best to walk the list rather than make assumptions.
7639 : : */
7640 : 0 : static void bnx2x_probe_pci_caps(struct bnx2x_softc *sc)
7641 : : {
7642 : 0 : PMD_INIT_FUNC_TRACE(sc);
7643 : :
7644 : : struct bnx2x_pci_cap *caps;
7645 : : uint16_t link_status;
7646 : : int reg = 0;
7647 : :
7648 : : /* check if PCI Power Management is enabled */
7649 : : caps = pci_find_cap(sc, RTE_PCI_CAP_ID_PM, BNX2X_PCI_CAP);
7650 [ # # ]: 0 : if (NULL != caps) {
7651 : 0 : PMD_DRV_LOG(DEBUG, sc, "Found PM capability: "
7652 : : "id=0x%04X type=0x%04X addr=0x%08X",
7653 : : caps->id, caps->type, caps->addr);
7654 : :
7655 : 0 : sc->devinfo.pcie_cap_flags |= BNX2X_PM_CAPABLE_FLAG;
7656 : 0 : sc->devinfo.pcie_pm_cap_reg = caps->addr;
7657 : : }
7658 : :
7659 : 0 : link_status = bnx2x_pcie_capability_read(sc, RTE_PCI_EXP_LNKSTA);
7660 : :
7661 : 0 : sc->devinfo.pcie_link_speed = (link_status & RTE_PCI_EXP_LNKSTA_CLS);
7662 : 0 : sc->devinfo.pcie_link_width =
7663 : 0 : ((link_status & RTE_PCI_EXP_LNKSTA_NLW) >> 4);
7664 : :
7665 : 0 : PMD_DRV_LOG(DEBUG, sc, "PCIe link speed=%d width=%d",
7666 : : sc->devinfo.pcie_link_speed, sc->devinfo.pcie_link_width);
7667 : :
7668 : 0 : sc->devinfo.pcie_cap_flags |= BNX2X_PCIE_CAPABLE_FLAG;
7669 : :
7670 : : /* check if MSI capability is enabled */
7671 : : caps = pci_find_cap(sc, RTE_PCI_CAP_ID_MSI, BNX2X_PCI_CAP);
7672 [ # # ]: 0 : if (NULL != caps) {
7673 : 0 : PMD_DRV_LOG(DEBUG, sc, "Found MSI capability at 0x%04x", reg);
7674 : :
7675 : 0 : sc->devinfo.pcie_cap_flags |= BNX2X_MSI_CAPABLE_FLAG;
7676 : 0 : sc->devinfo.pcie_msi_cap_reg = caps->addr;
7677 : : }
7678 : :
7679 : : /* check if MSI-X capability is enabled */
7680 : : caps = pci_find_cap(sc, RTE_PCI_CAP_ID_MSIX, BNX2X_PCI_CAP);
7681 [ # # ]: 0 : if (NULL != caps) {
7682 : 0 : PMD_DRV_LOG(DEBUG, sc, "Found MSI-X capability at 0x%04x", reg);
7683 : :
7684 : 0 : sc->devinfo.pcie_cap_flags |= BNX2X_MSIX_CAPABLE_FLAG;
7685 : 0 : sc->devinfo.pcie_msix_cap_reg = caps->addr;
7686 : : }
7687 : 0 : }
7688 : :
7689 : 0 : static int bnx2x_get_shmem_mf_cfg_info_sd(struct bnx2x_softc *sc)
7690 : : {
7691 : : struct bnx2x_mf_info *mf_info = &sc->devinfo.mf_info;
7692 : : uint32_t val;
7693 : :
7694 : : /* get the outer vlan if we're in switch-dependent mode */
7695 : :
7696 : 0 : val = MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].e1hov_tag);
7697 : 0 : mf_info->ext_id = (uint16_t) val;
7698 : :
7699 : 0 : mf_info->multi_vnics_mode = 1;
7700 : :
7701 [ # # ]: 0 : if (!VALID_OVLAN(mf_info->ext_id)) {
7702 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid VLAN (%d)", mf_info->ext_id);
7703 : 0 : return 1;
7704 : : }
7705 : :
7706 : : /* get the capabilities */
7707 [ # # ]: 0 : if ((mf_info->mf_config[SC_VN(sc)] & FUNC_MF_CFG_PROTOCOL_MASK) ==
7708 : : FUNC_MF_CFG_PROTOCOL_ISCSI) {
7709 : 0 : mf_info->mf_protos_supported |= MF_PROTO_SUPPORT_ISCSI;
7710 [ # # ]: 0 : } else if ((mf_info->mf_config[SC_VN(sc)] & FUNC_MF_CFG_PROTOCOL_MASK)
7711 : : == FUNC_MF_CFG_PROTOCOL_FCOE) {
7712 : 0 : mf_info->mf_protos_supported |= MF_PROTO_SUPPORT_FCOE;
7713 : : } else {
7714 : 0 : mf_info->mf_protos_supported |= MF_PROTO_SUPPORT_ETHERNET;
7715 : : }
7716 : :
7717 : 0 : mf_info->vnics_per_port =
7718 [ # # ]: 0 : (CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) ? 2 : 4;
7719 : :
7720 : 0 : return 0;
7721 : : }
7722 : :
7723 : 0 : static uint32_t bnx2x_get_shmem_ext_proto_support_flags(struct bnx2x_softc *sc)
7724 : : {
7725 : : uint32_t retval = 0;
7726 : : uint32_t val;
7727 : :
7728 : 0 : val = MFCFG_RD(sc, func_ext_config[SC_ABS_FUNC(sc)].func_cfg);
7729 : :
7730 [ # # ]: 0 : if (val & MACP_FUNC_CFG_FLAGS_ENABLED) {
7731 [ # # ]: 0 : if (val & MACP_FUNC_CFG_FLAGS_ETHERNET) {
7732 : : retval |= MF_PROTO_SUPPORT_ETHERNET;
7733 : : }
7734 [ # # ]: 0 : if (val & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) {
7735 : 0 : retval |= MF_PROTO_SUPPORT_ISCSI;
7736 : : }
7737 [ # # ]: 0 : if (val & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) {
7738 : 0 : retval |= MF_PROTO_SUPPORT_FCOE;
7739 : : }
7740 : : }
7741 : :
7742 : 0 : return retval;
7743 : : }
7744 : :
7745 : 0 : static int bnx2x_get_shmem_mf_cfg_info_si(struct bnx2x_softc *sc)
7746 : : {
7747 : : struct bnx2x_mf_info *mf_info = &sc->devinfo.mf_info;
7748 : : uint32_t val;
7749 : :
7750 : : /*
7751 : : * There is no outer vlan if we're in switch-independent mode.
7752 : : * If the mac is valid then assume multi-function.
7753 : : */
7754 : :
7755 : 0 : val = MFCFG_RD(sc, func_ext_config[SC_ABS_FUNC(sc)].func_cfg);
7756 : :
7757 : 0 : mf_info->multi_vnics_mode = ((val & MACP_FUNC_CFG_FLAGS_MASK) != 0);
7758 : :
7759 : 0 : mf_info->mf_protos_supported =
7760 : 0 : bnx2x_get_shmem_ext_proto_support_flags(sc);
7761 : :
7762 : 0 : mf_info->vnics_per_port =
7763 [ # # ]: 0 : (CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) ? 2 : 4;
7764 : :
7765 : 0 : return 0;
7766 : : }
7767 : :
7768 : 0 : static int bnx2x_get_shmem_mf_cfg_info_niv(struct bnx2x_softc *sc)
7769 : : {
7770 : : struct bnx2x_mf_info *mf_info = &sc->devinfo.mf_info;
7771 : : uint32_t e1hov_tag;
7772 : : uint32_t func_config;
7773 : : uint32_t niv_config;
7774 : :
7775 : 0 : mf_info->multi_vnics_mode = 1;
7776 : :
7777 : 0 : e1hov_tag = MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].e1hov_tag);
7778 : 0 : func_config = MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].config);
7779 : 0 : niv_config = MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].afex_config);
7780 : :
7781 : 0 : mf_info->ext_id =
7782 : 0 : (uint16_t) ((e1hov_tag & FUNC_MF_CFG_E1HOV_TAG_MASK) >>
7783 : : FUNC_MF_CFG_E1HOV_TAG_SHIFT);
7784 : :
7785 : 0 : mf_info->default_vlan =
7786 : 0 : (uint16_t) ((e1hov_tag & FUNC_MF_CFG_AFEX_VLAN_MASK) >>
7787 : : FUNC_MF_CFG_AFEX_VLAN_SHIFT);
7788 : :
7789 : 0 : mf_info->niv_allowed_priorities =
7790 : 0 : (uint8_t) ((niv_config & FUNC_MF_CFG_AFEX_COS_FILTER_MASK) >>
7791 : : FUNC_MF_CFG_AFEX_COS_FILTER_SHIFT);
7792 : :
7793 : 0 : mf_info->niv_default_cos =
7794 : 0 : (uint8_t) ((func_config & FUNC_MF_CFG_TRANSMIT_PRIORITY_MASK) >>
7795 : : FUNC_MF_CFG_TRANSMIT_PRIORITY_SHIFT);
7796 : :
7797 : 0 : mf_info->afex_vlan_mode =
7798 : 0 : ((niv_config & FUNC_MF_CFG_AFEX_VLAN_MODE_MASK) >>
7799 : : FUNC_MF_CFG_AFEX_VLAN_MODE_SHIFT);
7800 : :
7801 : 0 : mf_info->niv_mba_enabled =
7802 : 0 : ((niv_config & FUNC_MF_CFG_AFEX_MBA_ENABLED_MASK) >>
7803 : : FUNC_MF_CFG_AFEX_MBA_ENABLED_SHIFT);
7804 : :
7805 : 0 : mf_info->mf_protos_supported =
7806 : 0 : bnx2x_get_shmem_ext_proto_support_flags(sc);
7807 : :
7808 : 0 : mf_info->vnics_per_port =
7809 [ # # ]: 0 : (CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) ? 2 : 4;
7810 : :
7811 : 0 : return 0;
7812 : : }
7813 : :
7814 : 0 : static int bnx2x_check_valid_mf_cfg(struct bnx2x_softc *sc)
7815 : : {
7816 : : struct bnx2x_mf_info *mf_info = &sc->devinfo.mf_info;
7817 : : uint32_t mf_cfg1;
7818 : : uint32_t mf_cfg2;
7819 : : uint32_t ovlan1;
7820 : : uint32_t ovlan2;
7821 : : uint8_t i, j;
7822 : :
7823 : : /* various MF mode sanity checks... */
7824 : :
7825 [ # # ]: 0 : if (mf_info->mf_config[SC_VN(sc)] & FUNC_MF_CFG_FUNC_HIDE) {
7826 : 0 : PMD_DRV_LOG(NOTICE, sc,
7827 : : "Enumerated function %d is marked as hidden",
7828 : : SC_PORT(sc));
7829 : 0 : return 1;
7830 : : }
7831 : :
7832 [ # # # # ]: 0 : if ((mf_info->vnics_per_port > 1) && !mf_info->multi_vnics_mode) {
7833 : 0 : PMD_DRV_LOG(NOTICE, sc, "vnics_per_port=%d multi_vnics_mode=%d",
7834 : : mf_info->vnics_per_port, mf_info->multi_vnics_mode);
7835 : 0 : return 1;
7836 : : }
7837 : :
7838 [ # # ]: 0 : if (mf_info->mf_mode == MULTI_FUNCTION_SD) {
7839 : : /* vnic id > 0 must have valid ovlan in switch-dependent mode */
7840 [ # # # # ]: 0 : if ((SC_VN(sc) > 0) && !VALID_OVLAN(OVLAN(sc))) {
7841 : 0 : PMD_DRV_LOG(NOTICE, sc, "mf_mode=SD vnic_id=%d ovlan=%d",
7842 : : SC_VN(sc), OVLAN(sc));
7843 : 0 : return 1;
7844 : : }
7845 : :
7846 [ # # # # ]: 0 : if (!VALID_OVLAN(OVLAN(sc)) && mf_info->multi_vnics_mode) {
7847 : 0 : PMD_DRV_LOG(NOTICE, sc,
7848 : : "mf_mode=SD multi_vnics_mode=%d ovlan=%d",
7849 : : mf_info->multi_vnics_mode, OVLAN(sc));
7850 : 0 : return 1;
7851 : : }
7852 : :
7853 : : /*
7854 : : * Verify all functions are either MF or SF mode. If MF, make sure
7855 : : * sure that all non-hidden functions have a valid ovlan. If SF,
7856 : : * make sure that all non-hidden functions have an invalid ovlan.
7857 : : */
7858 [ # # # # : 0 : FOREACH_ABS_FUNC_IN_PORT(sc, i) {
# # ]
7859 : 0 : mf_cfg1 = MFCFG_RD(sc, func_mf_config[i].config);
7860 : 0 : ovlan1 = MFCFG_RD(sc, func_mf_config[i].e1hov_tag);
7861 [ # # ]: 0 : if (!(mf_cfg1 & FUNC_MF_CFG_FUNC_HIDE) &&
7862 [ # # ]: 0 : (((mf_info->multi_vnics_mode)
7863 [ # # ]: 0 : && !VALID_OVLAN(ovlan1))
7864 [ # # ]: 0 : || ((!mf_info->multi_vnics_mode)
7865 [ # # ]: 0 : && VALID_OVLAN(ovlan1)))) {
7866 : 0 : PMD_DRV_LOG(NOTICE, sc,
7867 : : "mf_mode=SD function %d MF config "
7868 : : "mismatch, multi_vnics_mode=%d ovlan=%d",
7869 : : i, mf_info->multi_vnics_mode,
7870 : : ovlan1);
7871 : 0 : return 1;
7872 : : }
7873 : : }
7874 : :
7875 : : /* Verify all funcs on the same port each have a different ovlan. */
7876 [ # # # # : 0 : FOREACH_ABS_FUNC_IN_PORT(sc, i) {
# # ]
7877 : 0 : mf_cfg1 = MFCFG_RD(sc, func_mf_config[i].config);
7878 : 0 : ovlan1 = MFCFG_RD(sc, func_mf_config[i].e1hov_tag);
7879 : : /* iterate from the next function on the port to the max func */
7880 [ # # ]: 0 : for (j = i + 2; j < MAX_FUNC_NUM; j += 2) {
7881 : : mf_cfg2 =
7882 : 0 : MFCFG_RD(sc, func_mf_config[j].config);
7883 : : ovlan2 =
7884 : 0 : MFCFG_RD(sc, func_mf_config[j].e1hov_tag);
7885 [ # # ]: 0 : if (!(mf_cfg1 & FUNC_MF_CFG_FUNC_HIDE)
7886 [ # # ]: 0 : && VALID_OVLAN(ovlan1)
7887 [ # # ]: 0 : && !(mf_cfg2 & FUNC_MF_CFG_FUNC_HIDE)
7888 : 0 : && VALID_OVLAN(ovlan2)
7889 [ # # ]: 0 : && (ovlan1 == ovlan2)) {
7890 : 0 : PMD_DRV_LOG(NOTICE, sc,
7891 : : "mf_mode=SD functions %d and %d "
7892 : : "have the same ovlan (%d)",
7893 : : i, j, ovlan1);
7894 : 0 : return 1;
7895 : : }
7896 : : }
7897 : : }
7898 : : }
7899 : : /* MULTI_FUNCTION_SD */
7900 : : return 0;
7901 : : }
7902 : :
7903 : 0 : static int bnx2x_get_mf_cfg_info(struct bnx2x_softc *sc)
7904 : : {
7905 : : struct bnx2x_mf_info *mf_info = &sc->devinfo.mf_info;
7906 : : uint32_t val, mac_upper;
7907 : : uint8_t i, vnic;
7908 : :
7909 : : /* initialize mf_info defaults */
7910 : 0 : mf_info->vnics_per_port = 1;
7911 : 0 : mf_info->multi_vnics_mode = FALSE;
7912 : 0 : mf_info->path_has_ovlan = FALSE;
7913 : 0 : mf_info->mf_mode = SINGLE_FUNCTION;
7914 : :
7915 [ # # # # : 0 : if (!CHIP_IS_MF_CAP(sc)) {
# # # # #
# # # ]
7916 : : return 0;
7917 : : }
7918 : :
7919 [ # # ]: 0 : if (sc->devinfo.mf_cfg_base == SHMEM_MF_CFG_ADDR_NONE) {
7920 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid mf_cfg_base!");
7921 : 0 : return 1;
7922 : : }
7923 : :
7924 : : /* get the MF mode (switch dependent / independent / single-function) */
7925 : :
7926 : 0 : val = SHMEM_RD(sc, dev_info.shared_feature_config.config);
7927 : :
7928 [ # # # # : 0 : switch (val & SHARED_FEAT_CFG_FORCE_SF_MODE_MASK) {
# ]
7929 : 0 : case SHARED_FEAT_CFG_FORCE_SF_MODE_SWITCH_INDEPT:
7930 : :
7931 : : mac_upper =
7932 : 0 : MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].mac_upper);
7933 : :
7934 : : /* check for legal upper mac bytes */
7935 [ # # ]: 0 : if (mac_upper != FUNC_MF_CFG_UPPERMAC_DEFAULT) {
7936 : 0 : mf_info->mf_mode = MULTI_FUNCTION_SI;
7937 : : } else {
7938 : 0 : PMD_DRV_LOG(NOTICE, sc,
7939 : : "Invalid config for Switch Independent mode");
7940 : : }
7941 : :
7942 : : break;
7943 : :
7944 : 0 : case SHARED_FEAT_CFG_FORCE_SF_MODE_MF_ALLOWED:
7945 : : case SHARED_FEAT_CFG_FORCE_SF_MODE_SPIO4:
7946 : :
7947 : : /* get outer vlan configuration */
7948 : 0 : val = MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].e1hov_tag);
7949 : :
7950 [ # # ]: 0 : if ((val & FUNC_MF_CFG_E1HOV_TAG_MASK) !=
7951 : : FUNC_MF_CFG_E1HOV_TAG_DEFAULT) {
7952 : 0 : mf_info->mf_mode = MULTI_FUNCTION_SD;
7953 : : } else {
7954 : 0 : PMD_DRV_LOG(NOTICE, sc,
7955 : : "Invalid config for Switch Dependent mode");
7956 : : }
7957 : :
7958 : : break;
7959 : :
7960 : : case SHARED_FEAT_CFG_FORCE_SF_MODE_FORCED_SF:
7961 : :
7962 : : /* not in MF mode, vnics_per_port=1 and multi_vnics_mode=FALSE */
7963 : : return 0;
7964 : :
7965 : 0 : case SHARED_FEAT_CFG_FORCE_SF_MODE_AFEX_MODE:
7966 : :
7967 : : /*
7968 : : * Mark MF mode as NIV if MCP version includes NPAR-SD support
7969 : : * and the MAC address is valid.
7970 : : */
7971 : : mac_upper =
7972 : 0 : MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].mac_upper);
7973 : :
7974 [ # # # # : 0 : if ((SHMEM2_HAS(sc, afex_driver_support)) &&
# # ]
7975 : : (mac_upper != FUNC_MF_CFG_UPPERMAC_DEFAULT)) {
7976 : 0 : mf_info->mf_mode = MULTI_FUNCTION_AFEX;
7977 : : } else {
7978 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid config for AFEX mode");
7979 : : }
7980 : :
7981 : : break;
7982 : :
7983 : 0 : default:
7984 : :
7985 : 0 : PMD_DRV_LOG(NOTICE, sc, "Unknown MF mode (0x%08x)",
7986 : : (val & SHARED_FEAT_CFG_FORCE_SF_MODE_MASK));
7987 : :
7988 : 0 : return 1;
7989 : : }
7990 : :
7991 : : /* set path mf_mode (which could be different than function mf_mode) */
7992 [ # # ]: 0 : if (mf_info->mf_mode == MULTI_FUNCTION_SD) {
7993 : 0 : mf_info->path_has_ovlan = TRUE;
7994 [ # # ]: 0 : } else if (mf_info->mf_mode == SINGLE_FUNCTION) {
7995 : : /*
7996 : : * Decide on path multi vnics mode. If we're not in MF mode and in
7997 : : * 4-port mode, this is good enough to check vnic-0 of the other port
7998 : : * on the same path
7999 : : */
8000 [ # # ]: 0 : if (CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) {
8001 : 0 : uint8_t other_port = !(PORT_ID(sc) & 1);
8002 : 0 : uint8_t abs_func_other_port =
8003 : 0 : (SC_PATH(sc) + (2 * other_port));
8004 : :
8005 : : val =
8006 : 0 : MFCFG_RD(sc,
8007 : : func_mf_config
8008 : : [abs_func_other_port].e1hov_tag);
8009 : :
8010 : 0 : mf_info->path_has_ovlan = VALID_OVLAN((uint16_t) val);
8011 : : }
8012 : : }
8013 : :
8014 [ # # ]: 0 : if (mf_info->mf_mode == SINGLE_FUNCTION) {
8015 : : /* invalid MF config */
8016 [ # # ]: 0 : if (SC_VN(sc) >= 1) {
8017 : 0 : PMD_DRV_LOG(NOTICE, sc, "VNIC ID >= 1 in SF mode");
8018 : 0 : return 1;
8019 : : }
8020 : :
8021 : : return 0;
8022 : : }
8023 : :
8024 : : /* get the MF configuration */
8025 : 0 : mf_info->mf_config[SC_VN(sc)] =
8026 : 0 : MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].config);
8027 : :
8028 [ # # # # ]: 0 : switch (mf_info->mf_mode) {
8029 : 0 : case MULTI_FUNCTION_SD:
8030 : :
8031 : 0 : bnx2x_get_shmem_mf_cfg_info_sd(sc);
8032 : 0 : break;
8033 : :
8034 : 0 : case MULTI_FUNCTION_SI:
8035 : :
8036 : 0 : bnx2x_get_shmem_mf_cfg_info_si(sc);
8037 : 0 : break;
8038 : :
8039 : 0 : case MULTI_FUNCTION_AFEX:
8040 : :
8041 : 0 : bnx2x_get_shmem_mf_cfg_info_niv(sc);
8042 : 0 : break;
8043 : :
8044 : 0 : default:
8045 : :
8046 : 0 : PMD_DRV_LOG(NOTICE, sc, "Get MF config failed (mf_mode=0x%08x)",
8047 : : mf_info->mf_mode);
8048 : 0 : return 1;
8049 : : }
8050 : :
8051 : : /* get the congestion management parameters */
8052 : :
8053 : : vnic = 0;
8054 [ # # # # ]: 0 : FOREACH_ABS_FUNC_IN_PORT(sc, i) {
8055 : : /* get min/max bw */
8056 : 0 : val = MFCFG_RD(sc, func_mf_config[i].config);
8057 : 0 : mf_info->min_bw[vnic] =
8058 : 0 : ((val & FUNC_MF_CFG_MIN_BW_MASK) >>
8059 : : FUNC_MF_CFG_MIN_BW_SHIFT);
8060 : 0 : mf_info->max_bw[vnic] =
8061 : 0 : ((val & FUNC_MF_CFG_MAX_BW_MASK) >>
8062 : : FUNC_MF_CFG_MAX_BW_SHIFT);
8063 [ # # ]: 0 : vnic++;
8064 : : }
8065 : :
8066 : 0 : return bnx2x_check_valid_mf_cfg(sc);
8067 : : }
8068 : :
8069 : 0 : static int bnx2x_get_shmem_info(struct bnx2x_softc *sc)
8070 : : {
8071 : : int port;
8072 : : uint32_t mac_hi, mac_lo, val;
8073 : :
8074 : 0 : PMD_INIT_FUNC_TRACE(sc);
8075 : :
8076 : 0 : port = SC_PORT(sc);
8077 : : mac_hi = mac_lo = 0;
8078 : :
8079 : 0 : sc->link_params.sc = sc;
8080 : 0 : sc->link_params.port = port;
8081 : :
8082 : : /* get the hardware config info */
8083 : 0 : sc->devinfo.hw_config = SHMEM_RD(sc, dev_info.shared_hw_config.config);
8084 : 0 : sc->devinfo.hw_config2 =
8085 : 0 : SHMEM_RD(sc, dev_info.shared_hw_config.config2);
8086 : :
8087 : 0 : sc->link_params.hw_led_mode =
8088 : 0 : ((sc->devinfo.hw_config & SHARED_HW_CFG_LED_MODE_MASK) >>
8089 : : SHARED_HW_CFG_LED_MODE_SHIFT);
8090 : :
8091 : : /* get the port feature config */
8092 : 0 : sc->port.config =
8093 : 0 : SHMEM_RD(sc, dev_info.port_feature_config[port].config);
8094 : :
8095 : : /* get the link params */
8096 : 0 : sc->link_params.speed_cap_mask[ELINK_INT_PHY] =
8097 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].speed_capability_mask)
8098 : 0 : & PORT_HW_CFG_SPEED_CAPABILITY_D0_MASK;
8099 : 0 : sc->link_params.speed_cap_mask[ELINK_EXT_PHY1] =
8100 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].speed_capability_mask2)
8101 : 0 : & PORT_HW_CFG_SPEED_CAPABILITY_D0_MASK;
8102 : :
8103 : : /* get the lane config */
8104 : 0 : sc->link_params.lane_config =
8105 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].lane_config);
8106 : :
8107 : : /* get the link config */
8108 : 0 : val = SHMEM_RD(sc, dev_info.port_feature_config[port].link_config);
8109 : 0 : sc->port.link_config[ELINK_INT_PHY] = val;
8110 : 0 : sc->link_params.switch_cfg = (val & PORT_FEATURE_CONNECTED_SWITCH_MASK);
8111 : 0 : sc->port.link_config[ELINK_EXT_PHY1] =
8112 : 0 : SHMEM_RD(sc, dev_info.port_feature_config[port].link_config2);
8113 : :
8114 : : /* get the override preemphasis flag and enable it or turn it off */
8115 : 0 : val = SHMEM_RD(sc, dev_info.shared_feature_config.config);
8116 [ # # ]: 0 : if (val & SHARED_FEAT_CFG_OVERRIDE_PREEMPHASIS_CFG_ENABLED) {
8117 : 0 : sc->link_params.feature_config_flags |=
8118 : : ELINK_FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED;
8119 : : } else {
8120 : 0 : sc->link_params.feature_config_flags &=
8121 : : ~ELINK_FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED;
8122 : : }
8123 : :
8124 : 0 : val = sc->devinfo.bc_ver >> 8;
8125 [ # # ]: 0 : if (val < BNX2X_BC_VER) {
8126 : : /* for now only warn later we might need to enforce this */
8127 : 0 : PMD_DRV_LOG(NOTICE, sc, "This driver needs bc_ver %X but found %X, please upgrade BC\n",
8128 : : BNX2X_BC_VER, val);
8129 : : }
8130 : 0 : sc->link_params.feature_config_flags |=
8131 : : (val >= REQ_BC_VER_4_VRFY_FIRST_PHY_OPT_MDL) ?
8132 [ # # ]: 0 : ELINK_FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY :
8133 : : 0;
8134 : :
8135 : 0 : sc->link_params.feature_config_flags |=
8136 : : (val >= REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL) ?
8137 [ # # ]: 0 : ELINK_FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY : 0;
8138 : 0 : sc->link_params.feature_config_flags |=
8139 : : (val >= REQ_BC_VER_4_VRFY_AFEX_SUPPORTED) ?
8140 [ # # ]: 0 : ELINK_FEATURE_CONFIG_BC_SUPPORTS_AFEX : 0;
8141 : 0 : sc->link_params.feature_config_flags |=
8142 : : (val >= REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED) ?
8143 [ # # ]: 0 : ELINK_FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED : 0;
8144 : :
8145 : : /* get the initial value of the link params */
8146 : 0 : sc->link_params.multi_phy_config =
8147 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].multi_phy_config);
8148 : :
8149 : : /* get external phy info */
8150 : 0 : sc->port.ext_phy_config =
8151 : 0 : SHMEM_RD(sc, dev_info.port_hw_config[port].external_phy_config);
8152 : :
8153 : : /* get the multifunction configuration */
8154 : 0 : bnx2x_get_mf_cfg_info(sc);
8155 : :
8156 : : /* get the mac address */
8157 [ # # # # ]: 0 : if (IS_MF(sc)) {
8158 : : mac_hi =
8159 : 0 : MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].mac_upper);
8160 : 0 : mac_lo =
8161 : 0 : MFCFG_RD(sc, func_mf_config[SC_ABS_FUNC(sc)].mac_lower);
8162 : : } else {
8163 : 0 : mac_hi = SHMEM_RD(sc, dev_info.port_hw_config[port].mac_upper);
8164 : 0 : mac_lo = SHMEM_RD(sc, dev_info.port_hw_config[port].mac_lower);
8165 : : }
8166 : :
8167 [ # # ]: 0 : if ((mac_lo == 0) && (mac_hi == 0)) {
8168 : 0 : *sc->mac_addr_str = 0;
8169 : 0 : PMD_DRV_LOG(NOTICE, sc, "No Ethernet address programmed!");
8170 : : } else {
8171 : 0 : sc->link_params.mac_addr[0] = (uint8_t) (mac_hi >> 8);
8172 : 0 : sc->link_params.mac_addr[1] = (uint8_t) (mac_hi);
8173 : 0 : sc->link_params.mac_addr[2] = (uint8_t) (mac_lo >> 24);
8174 : 0 : sc->link_params.mac_addr[3] = (uint8_t) (mac_lo >> 16);
8175 : 0 : sc->link_params.mac_addr[4] = (uint8_t) (mac_lo >> 8);
8176 : 0 : sc->link_params.mac_addr[5] = (uint8_t) (mac_lo);
8177 : 0 : snprintf(sc->mac_addr_str, sizeof(sc->mac_addr_str),
8178 : : RTE_ETHER_ADDR_PRT_FMT,
8179 : : sc->link_params.mac_addr[0],
8180 : : sc->link_params.mac_addr[1],
8181 : : sc->link_params.mac_addr[2],
8182 : : sc->link_params.mac_addr[3],
8183 : : sc->link_params.mac_addr[4],
8184 : : sc->link_params.mac_addr[5]);
8185 : 0 : PMD_DRV_LOG(DEBUG, sc,
8186 : : "Ethernet address: %s", sc->mac_addr_str);
8187 : : }
8188 : :
8189 : 0 : return 0;
8190 : : }
8191 : :
8192 : 0 : static void bnx2x_media_detect(struct bnx2x_softc *sc)
8193 : : {
8194 : 0 : uint32_t phy_idx = bnx2x_get_cur_phy_idx(sc);
8195 [ # # # # : 0 : switch (sc->link_params.phy[phy_idx].media_type) {
# ]
8196 : 0 : case ELINK_ETH_PHY_SFPP_10G_FIBER:
8197 : : case ELINK_ETH_PHY_SFP_1G_FIBER:
8198 : : case ELINK_ETH_PHY_XFP_FIBER:
8199 : : case ELINK_ETH_PHY_KR:
8200 : : case ELINK_ETH_PHY_CX4:
8201 : 0 : PMD_DRV_LOG(INFO, sc, "Found 10GBase-CX4 media.");
8202 : 0 : sc->media = IFM_10G_CX4;
8203 : 0 : break;
8204 : 0 : case ELINK_ETH_PHY_DA_TWINAX:
8205 : 0 : PMD_DRV_LOG(INFO, sc, "Found 10Gb Twinax media.");
8206 : 0 : sc->media = IFM_10G_TWINAX;
8207 : 0 : break;
8208 : 0 : case ELINK_ETH_PHY_BASE_T:
8209 : 0 : PMD_DRV_LOG(INFO, sc, "Found 10GBase-T media.");
8210 : 0 : sc->media = IFM_10G_T;
8211 : 0 : break;
8212 : 0 : case ELINK_ETH_PHY_NOT_PRESENT:
8213 : 0 : PMD_DRV_LOG(INFO, sc, "Media not present.");
8214 : 0 : sc->media = 0;
8215 : 0 : break;
8216 : 0 : case ELINK_ETH_PHY_UNSPECIFIED:
8217 : : default:
8218 : 0 : PMD_DRV_LOG(INFO, sc, "Unknown media!");
8219 : 0 : sc->media = 0;
8220 : 0 : break;
8221 : : }
8222 : 0 : }
8223 : :
8224 : : #define GET_FIELD(value, fname) \
8225 : : (((value) & (fname##_MASK)) >> (fname##_SHIFT))
8226 : : #define IGU_FID(val) GET_FIELD((val), IGU_REG_MAPPING_MEMORY_FID)
8227 : : #define IGU_VEC(val) GET_FIELD((val), IGU_REG_MAPPING_MEMORY_VECTOR)
8228 : :
8229 : 0 : static int bnx2x_get_igu_cam_info(struct bnx2x_softc *sc)
8230 : : {
8231 : 0 : int pfid = SC_FUNC(sc);
8232 : : int igu_sb_id;
8233 : : uint32_t val;
8234 : : uint8_t fid, igu_sb_cnt = 0;
8235 : :
8236 : 0 : sc->igu_base_sb = 0xff;
8237 : :
8238 [ # # # # ]: 0 : if (CHIP_INT_MODE_IS_BC(sc)) {
8239 : 0 : int vn = SC_VN(sc);
8240 : : igu_sb_cnt = sc->igu_sb_cnt;
8241 [ # # ]: 0 : sc->igu_base_sb = ((CHIP_IS_MODE_4_PORT(sc) ? pfid : vn) *
8242 : : FP_SB_MAX_E1x);
8243 [ # # ]: 0 : sc->igu_dsb_id = (E1HVN_MAX * FP_SB_MAX_E1x +
8244 : : (CHIP_IS_MODE_4_PORT(sc) ? pfid : vn));
8245 : 0 : return 0;
8246 : : }
8247 : :
8248 : : /* IGU in normal mode - read CAM */
8249 : : for (igu_sb_id = 0;
8250 [ # # ]: 0 : igu_sb_id < IGU_REG_MAPPING_MEMORY_SIZE; igu_sb_id++) {
8251 : 0 : val = REG_RD(sc, IGU_REG_MAPPING_MEMORY + igu_sb_id * 4);
8252 [ # # ]: 0 : if (!(val & IGU_REG_MAPPING_MEMORY_VALID)) {
8253 : 0 : continue;
8254 : : }
8255 : 0 : fid = IGU_FID(val);
8256 [ # # ]: 0 : if (fid & IGU_FID_ENCODE_IS_PF) {
8257 [ # # ]: 0 : if ((fid & IGU_FID_PF_NUM_MASK) != pfid) {
8258 : 0 : continue;
8259 : : }
8260 [ # # ]: 0 : if (IGU_VEC(val) == 0) {
8261 : : /* default status block */
8262 : 0 : sc->igu_dsb_id = igu_sb_id;
8263 : : } else {
8264 [ # # ]: 0 : if (sc->igu_base_sb == 0xff) {
8265 : 0 : sc->igu_base_sb = igu_sb_id;
8266 : : }
8267 : 0 : igu_sb_cnt++;
8268 : : }
8269 : : }
8270 : : }
8271 : :
8272 : : /*
8273 : : * Due to new PF resource allocation by MFW T7.4 and above, it's optional
8274 : : * that number of CAM entries will not be equal to the value advertised in
8275 : : * PCI. Driver should use the minimal value of both as the actual status
8276 : : * block count
8277 : : */
8278 : 0 : sc->igu_sb_cnt = min(sc->igu_sb_cnt, igu_sb_cnt);
8279 : :
8280 [ # # ]: 0 : if (igu_sb_cnt == 0) {
8281 : 0 : PMD_DRV_LOG(ERR, sc, "CAM configuration error");
8282 : 0 : return -1;
8283 : : }
8284 : :
8285 : : return 0;
8286 : : }
8287 : :
8288 : : /*
8289 : : * Gather various information from the device config space, the device itself,
8290 : : * shmem, and the user input.
8291 : : */
8292 : 0 : static int bnx2x_get_device_info(struct bnx2x_softc *sc)
8293 : : {
8294 : : uint32_t val;
8295 : : int rc;
8296 : :
8297 : : /* get the chip revision (chip metal comes from pci config space) */
8298 : 0 : sc->devinfo.chip_id = sc->link_params.chip_id =
8299 : 0 : (((REG_RD(sc, MISC_REG_CHIP_NUM) & 0xffff) << 16) |
8300 : 0 : ((REG_RD(sc, MISC_REG_CHIP_REV) & 0xf) << 12) |
8301 : 0 : (((REG_RD(sc, PCICFG_OFFSET + PCI_ID_VAL3) >> 24) & 0xf) << 4) |
8302 : 0 : ((REG_RD(sc, MISC_REG_BOND_ID) & 0xf) << 0));
8303 : :
8304 : : /* force 57811 according to MISC register */
8305 [ # # ]: 0 : if (REG_RD(sc, MISC_REG_CHIP_TYPE) & MISC_REG_CHIP_TYPE_57811_MASK) {
8306 [ # # ]: 0 : if (CHIP_IS_57810(sc)) {
8307 : 0 : sc->devinfo.chip_id = ((CHIP_NUM_57811 << 16) |
8308 : : (sc->
8309 : 0 : devinfo.chip_id & 0x0000ffff));
8310 [ # # ]: 0 : } else if (CHIP_IS_57810_MF(sc)) {
8311 : 0 : sc->devinfo.chip_id = ((CHIP_NUM_57811_MF << 16) |
8312 : : (sc->
8313 : 0 : devinfo.chip_id & 0x0000ffff));
8314 : : }
8315 : 0 : sc->devinfo.chip_id |= 0x1;
8316 : : }
8317 : :
8318 : 0 : PMD_DRV_LOG(DEBUG, sc,
8319 : : "chip_id=0x%08x (num=0x%04x rev=0x%01x metal=0x%02x bond=0x%01x)",
8320 : : sc->devinfo.chip_id,
8321 : : ((sc->devinfo.chip_id >> 16) & 0xffff),
8322 : : ((sc->devinfo.chip_id >> 12) & 0xf),
8323 : : ((sc->devinfo.chip_id >> 4) & 0xff),
8324 : : ((sc->devinfo.chip_id >> 0) & 0xf));
8325 : :
8326 : 0 : val = (REG_RD(sc, 0x2874) & 0x55);
8327 [ # # # # : 0 : if ((sc->devinfo.chip_id & 0x1) || (CHIP_IS_E1H(sc) && (val == 0x55))) {
# # ]
8328 : 0 : sc->flags |= BNX2X_ONE_PORT_FLAG;
8329 : 0 : PMD_DRV_LOG(DEBUG, sc, "single port device");
8330 : : }
8331 : :
8332 : : /* set the doorbell size */
8333 : 0 : sc->doorbell_size = (1 << BNX2X_DB_SHIFT);
8334 : :
8335 : : /* determine whether the device is in 2 port or 4 port mode */
8336 : 0 : sc->devinfo.chip_port_mode = CHIP_PORT_MODE_NONE; /* E1h */
8337 [ # # # # ]: 0 : if (CHIP_IS_E2E3(sc)) {
8338 : : /*
8339 : : * Read port4mode_en_ovwr[0]:
8340 : : * If 1, four port mode is in port4mode_en_ovwr[1].
8341 : : * If 0, four port mode is in port4mode_en[0].
8342 : : */
8343 : : val = REG_RD(sc, MISC_REG_PORT4MODE_EN_OVWR);
8344 [ # # ]: 0 : if (val & 1) {
8345 : 0 : val = ((val >> 1) & 1);
8346 : : } else {
8347 : : val = REG_RD(sc, MISC_REG_PORT4MODE_EN);
8348 : : }
8349 : :
8350 : 0 : sc->devinfo.chip_port_mode =
8351 : 0 : (val) ? CHIP_4_PORT_MODE : CHIP_2_PORT_MODE;
8352 : :
8353 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, sc, "Port mode = %s", (val) ? "4" : "2");
8354 : : }
8355 : :
8356 : : /* get the function and path info for the device */
8357 : 0 : bnx2x_get_function_num(sc);
8358 : :
8359 : : /* get the shared memory base address */
8360 : 0 : sc->devinfo.shmem_base =
8361 : 0 : sc->link_params.shmem_base = REG_RD(sc, MISC_REG_SHARED_MEM_ADDR);
8362 : 0 : sc->devinfo.shmem2_base =
8363 [ # # ]: 0 : REG_RD(sc, (SC_PATH(sc) ? MISC_REG_GENERIC_CR_1 :
8364 : : MISC_REG_GENERIC_CR_0));
8365 : :
8366 [ # # ]: 0 : if (!sc->devinfo.shmem_base) {
8367 : : /* this should ONLY prevent upcoming shmem reads */
8368 : 0 : PMD_DRV_LOG(INFO, sc, "MCP not active");
8369 : 0 : sc->flags |= BNX2X_NO_MCP_FLAG;
8370 : 0 : return 0;
8371 : : }
8372 : :
8373 : : /* make sure the shared memory contents are valid */
8374 : 0 : val = SHMEM_RD(sc, validity_map[SC_PORT(sc)]);
8375 [ # # ]: 0 : if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) !=
8376 : : (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) {
8377 : 0 : PMD_DRV_LOG(NOTICE, sc, "Invalid SHMEM validity signature: 0x%08x",
8378 : : val);
8379 : 0 : return 0;
8380 : : }
8381 : :
8382 : : /* get the bootcode version */
8383 : 0 : sc->devinfo.bc_ver = SHMEM_RD(sc, dev_info.bc_rev);
8384 : 0 : snprintf(sc->devinfo.bc_ver_str,
8385 : : sizeof(sc->devinfo.bc_ver_str),
8386 : : "%d.%d.%d",
8387 : : ((sc->devinfo.bc_ver >> 24) & 0xff),
8388 : 0 : ((sc->devinfo.bc_ver >> 16) & 0xff),
8389 : 0 : ((sc->devinfo.bc_ver >> 8) & 0xff));
8390 : 0 : PMD_DRV_LOG(DEBUG, sc, "Bootcode version: %s", sc->devinfo.bc_ver_str);
8391 : :
8392 : : /* get the bootcode shmem address */
8393 : 0 : sc->devinfo.mf_cfg_base = bnx2x_get_shmem_mf_cfg_base(sc);
8394 : :
8395 : : /* clean indirect addresses as they're not used */
8396 : 0 : pci_write_long(sc, PCICFG_GRC_ADDRESS, 0);
8397 [ # # ]: 0 : if (IS_PF(sc)) {
8398 : : REG_WR(sc, PXP2_REG_PGL_ADDR_88_F0, 0);
8399 : : REG_WR(sc, PXP2_REG_PGL_ADDR_8C_F0, 0);
8400 : : REG_WR(sc, PXP2_REG_PGL_ADDR_90_F0, 0);
8401 : : REG_WR(sc, PXP2_REG_PGL_ADDR_94_F0, 0);
8402 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
8403 : : REG_WR(sc, PXP2_REG_PGL_ADDR_88_F1, 0);
8404 : : REG_WR(sc, PXP2_REG_PGL_ADDR_8C_F1, 0);
8405 : : REG_WR(sc, PXP2_REG_PGL_ADDR_90_F1, 0);
8406 : : REG_WR(sc, PXP2_REG_PGL_ADDR_94_F1, 0);
8407 : : }
8408 : : }
8409 : :
8410 : : /* get the nvram size */
8411 : : val = REG_RD(sc, MCP_REG_MCPR_NVM_CFG4);
8412 : 0 : sc->devinfo.flash_size =
8413 : 0 : (NVRAM_1MB_SIZE << (val & MCPR_NVM_CFG4_FLASH_SIZE));
8414 : :
8415 : 0 : bnx2x_set_power_state(sc, PCI_PM_D0);
8416 : : /* get various configuration parameters from shmem */
8417 : 0 : bnx2x_get_shmem_info(sc);
8418 : :
8419 : : /* initialize IGU parameters */
8420 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
8421 : 0 : sc->devinfo.int_block = INT_BLOCK_HC;
8422 : 0 : sc->igu_dsb_id = DEF_SB_IGU_ID;
8423 : 0 : sc->igu_base_sb = 0;
8424 : : } else {
8425 : 0 : sc->devinfo.int_block = INT_BLOCK_IGU;
8426 : :
8427 : : /* do not allow device reset during IGU info processing */
8428 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RESET);
8429 : :
8430 : : val = REG_RD(sc, IGU_REG_BLOCK_CONFIGURATION);
8431 : :
8432 [ # # ]: 0 : if (val & IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN) {
8433 : : int tout = 5000;
8434 : :
8435 : 0 : val &= ~(IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN);
8436 : : REG_WR(sc, IGU_REG_BLOCK_CONFIGURATION, val);
8437 : : REG_WR(sc, IGU_REG_RESET_MEMORIES, 0x7f);
8438 : :
8439 [ # # # # ]: 0 : while (tout && REG_RD(sc, IGU_REG_RESET_MEMORIES)) {
8440 : 0 : tout--;
8441 : 0 : DELAY(1000);
8442 : : }
8443 : :
8444 [ # # ]: 0 : if (REG_RD(sc, IGU_REG_RESET_MEMORIES)) {
8445 : 0 : PMD_DRV_LOG(NOTICE, sc,
8446 : : "FORCING IGU Normal Mode failed!!!");
8447 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RESET);
8448 : 0 : return -1;
8449 : : }
8450 : : }
8451 : :
8452 [ # # ]: 0 : if (val & IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN) {
8453 : 0 : PMD_DRV_LOG(DEBUG, sc, "IGU Backward Compatible Mode");
8454 : 0 : sc->devinfo.int_block |= INT_BLOCK_MODE_BW_COMP;
8455 : : } else {
8456 : 0 : PMD_DRV_LOG(DEBUG, sc, "IGU Normal Mode");
8457 : : }
8458 : :
8459 : 0 : rc = bnx2x_get_igu_cam_info(sc);
8460 : :
8461 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RESET);
8462 : :
8463 [ # # ]: 0 : if (rc) {
8464 : : return rc;
8465 : : }
8466 : : }
8467 : :
8468 : : /*
8469 : : * Get base FW non-default (fast path) status block ID. This value is
8470 : : * used to initialize the fw_sb_id saved on the fp/queue structure to
8471 : : * determine the id used by the FW.
8472 : : */
8473 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
8474 : 0 : sc->base_fw_ndsb =
8475 : 0 : ((SC_PORT(sc) * FP_SB_MAX_E1x) + SC_L_ID(sc));
8476 : : } else {
8477 : : /*
8478 : : * 57712+ - We currently use one FW SB per IGU SB (Rx and Tx of
8479 : : * the same queue are indicated on the same IGU SB). So we prefer
8480 : : * FW and IGU SBs to be the same value.
8481 : : */
8482 : 0 : sc->base_fw_ndsb = sc->igu_base_sb;
8483 : : }
8484 : :
8485 : 0 : elink_phy_probe(&sc->link_params);
8486 : :
8487 : 0 : return 0;
8488 : : }
8489 : :
8490 : : static void
8491 : 0 : bnx2x_link_settings_supported(struct bnx2x_softc *sc, uint32_t switch_cfg)
8492 : : {
8493 : : uint32_t cfg_size = 0;
8494 : : uint32_t idx;
8495 : 0 : uint8_t port = SC_PORT(sc);
8496 : :
8497 : : /* aggregation of supported attributes of all external phys */
8498 : 0 : sc->port.supported[0] = 0;
8499 : 0 : sc->port.supported[1] = 0;
8500 : :
8501 [ # # # # ]: 0 : switch (sc->link_params.num_phys) {
8502 : 0 : case 1:
8503 : 0 : sc->port.supported[0] =
8504 : 0 : sc->link_params.phy[ELINK_INT_PHY].supported;
8505 : : cfg_size = 1;
8506 : 0 : break;
8507 : 0 : case 2:
8508 : 0 : sc->port.supported[0] =
8509 : 0 : sc->link_params.phy[ELINK_EXT_PHY1].supported;
8510 : : cfg_size = 1;
8511 : 0 : break;
8512 : 0 : case 3:
8513 [ # # ]: 0 : if (sc->link_params.multi_phy_config &
8514 : : PORT_HW_CFG_PHY_SWAPPED_ENABLED) {
8515 : 0 : sc->port.supported[1] =
8516 : 0 : sc->link_params.phy[ELINK_EXT_PHY1].supported;
8517 : 0 : sc->port.supported[0] =
8518 : 0 : sc->link_params.phy[ELINK_EXT_PHY2].supported;
8519 : : } else {
8520 : 0 : sc->port.supported[0] =
8521 : 0 : sc->link_params.phy[ELINK_EXT_PHY1].supported;
8522 : 0 : sc->port.supported[1] =
8523 : 0 : sc->link_params.phy[ELINK_EXT_PHY2].supported;
8524 : : }
8525 : : cfg_size = 2;
8526 : : break;
8527 : : }
8528 : :
8529 [ # # # # ]: 0 : if (!(sc->port.supported[0] || sc->port.supported[1])) {
8530 : 0 : PMD_DRV_LOG(ERR, sc,
8531 : : "Invalid phy config in NVRAM (PHY1=0x%08x PHY2=0x%08x)",
8532 : : SHMEM_RD(sc,
8533 : : dev_info.port_hw_config
8534 : : [port].external_phy_config),
8535 : : SHMEM_RD(sc,
8536 : : dev_info.port_hw_config
8537 : : [port].external_phy_config2));
8538 : 0 : return;
8539 : : }
8540 : :
8541 [ # # ]: 0 : if (CHIP_IS_E3(sc))
8542 : 0 : sc->port.phy_addr = REG_RD(sc, MISC_REG_WC0_CTRL_PHY_ADDR);
8543 : : else {
8544 [ # # # ]: 0 : switch (switch_cfg) {
8545 : 0 : case ELINK_SWITCH_CFG_1G:
8546 : 0 : sc->port.phy_addr =
8547 : 0 : REG_RD(sc,
8548 : : NIG_REG_SERDES0_CTRL_PHY_ADDR + port * 0x10);
8549 : 0 : break;
8550 : 0 : case ELINK_SWITCH_CFG_10G:
8551 : 0 : sc->port.phy_addr =
8552 : 0 : REG_RD(sc,
8553 : : NIG_REG_XGXS0_CTRL_PHY_ADDR + port * 0x18);
8554 : 0 : break;
8555 : 0 : default:
8556 : 0 : PMD_DRV_LOG(ERR, sc,
8557 : : "Invalid switch config in"
8558 : : "link_config=0x%08x",
8559 : : sc->port.link_config[0]);
8560 : 0 : return;
8561 : : }
8562 : : }
8563 : :
8564 : 0 : PMD_DRV_LOG(INFO, sc, "PHY addr 0x%08x", sc->port.phy_addr);
8565 : :
8566 : : /* mask what we support according to speed_cap_mask per configuration */
8567 [ # # ]: 0 : for (idx = 0; idx < cfg_size; idx++) {
8568 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8569 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) {
8570 : 0 : sc->port.supported[idx] &=
8571 : : ~ELINK_SUPPORTED_10baseT_Half;
8572 : : }
8573 : :
8574 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8575 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL)) {
8576 : 0 : sc->port.supported[idx] &=
8577 : : ~ELINK_SUPPORTED_10baseT_Full;
8578 : : }
8579 : :
8580 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8581 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)) {
8582 : 0 : sc->port.supported[idx] &=
8583 : : ~ELINK_SUPPORTED_100baseT_Half;
8584 : : }
8585 : :
8586 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8587 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL)) {
8588 : 0 : sc->port.supported[idx] &=
8589 : : ~ELINK_SUPPORTED_100baseT_Full;
8590 : : }
8591 : :
8592 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8593 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) {
8594 : 0 : sc->port.supported[idx] &=
8595 : : ~ELINK_SUPPORTED_1000baseT_Full;
8596 : : }
8597 : :
8598 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8599 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) {
8600 : 0 : sc->port.supported[idx] &=
8601 : : ~ELINK_SUPPORTED_2500baseX_Full;
8602 : : }
8603 : :
8604 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8605 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) {
8606 : 0 : sc->port.supported[idx] &=
8607 : : ~ELINK_SUPPORTED_10000baseT_Full;
8608 : : }
8609 : :
8610 [ # # ]: 0 : if (!(sc->link_params.speed_cap_mask[idx] &
8611 : : PORT_HW_CFG_SPEED_CAPABILITY_D0_20G)) {
8612 : 0 : sc->port.supported[idx] &=
8613 : : ~ELINK_SUPPORTED_20000baseKR2_Full;
8614 : : }
8615 : : }
8616 : :
8617 : 0 : PMD_DRV_LOG(INFO, sc, "PHY supported 0=0x%08x 1=0x%08x",
8618 : : sc->port.supported[0], sc->port.supported[1]);
8619 : : }
8620 : :
8621 : 0 : static void bnx2x_link_settings_requested(struct bnx2x_softc *sc)
8622 : : {
8623 : : uint32_t link_config;
8624 : : uint32_t idx;
8625 : : uint32_t cfg_size = 0;
8626 : :
8627 : 0 : sc->port.advertising[0] = 0;
8628 : 0 : sc->port.advertising[1] = 0;
8629 : :
8630 [ # # # ]: 0 : switch (sc->link_params.num_phys) {
8631 : 0 : case 1:
8632 : : case 2:
8633 : : cfg_size = 1;
8634 : 0 : break;
8635 : 0 : case 3:
8636 : : cfg_size = 2;
8637 : 0 : break;
8638 : : }
8639 : :
8640 [ # # ]: 0 : for (idx = 0; idx < cfg_size; idx++) {
8641 : 0 : sc->link_params.req_duplex[idx] = DUPLEX_FULL;
8642 : 0 : link_config = sc->port.link_config[idx];
8643 : :
8644 [ # # # # : 0 : switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) {
# # # # #
# ]
8645 : 0 : case PORT_FEATURE_LINK_SPEED_AUTO:
8646 [ # # ]: 0 : if (sc->port.supported[idx] & ELINK_SUPPORTED_Autoneg) {
8647 : 0 : sc->link_params.req_line_speed[idx] =
8648 : : ELINK_SPEED_AUTO_NEG;
8649 : 0 : sc->port.advertising[idx] |=
8650 : : sc->port.supported[idx];
8651 [ # # ]: 0 : if (sc->link_params.phy[ELINK_EXT_PHY1].type ==
8652 : : PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BNX2X84833)
8653 : 0 : sc->port.advertising[idx] |=
8654 : : (ELINK_SUPPORTED_100baseT_Half |
8655 : : ELINK_SUPPORTED_100baseT_Full);
8656 : : } else {
8657 : : /* force 10G, no AN */
8658 : 0 : sc->link_params.req_line_speed[idx] =
8659 : : ELINK_SPEED_10000;
8660 : 0 : sc->port.advertising[idx] |=
8661 : : (ADVERTISED_10000baseT_Full |
8662 : : ADVERTISED_FIBRE);
8663 : 0 : continue;
8664 : : }
8665 : : break;
8666 : :
8667 : 0 : case PORT_FEATURE_LINK_SPEED_10M_FULL:
8668 : 0 : if (sc->
8669 [ # # ]: 0 : port.supported[idx] & ELINK_SUPPORTED_10baseT_Full)
8670 : : {
8671 : 0 : sc->link_params.req_line_speed[idx] =
8672 : : ELINK_SPEED_10;
8673 : 0 : sc->port.advertising[idx] |=
8674 : : (ADVERTISED_10baseT_Full | ADVERTISED_TP);
8675 : : } else {
8676 : 0 : PMD_DRV_LOG(ERR, sc,
8677 : : "Invalid NVRAM config link_config=0x%08x "
8678 : : "speed_cap_mask=0x%08x",
8679 : : link_config,
8680 : : sc->
8681 : : link_params.speed_cap_mask[idx]);
8682 : 0 : return;
8683 : : }
8684 : 0 : break;
8685 : :
8686 : 0 : case PORT_FEATURE_LINK_SPEED_10M_HALF:
8687 : 0 : if (sc->
8688 [ # # ]: 0 : port.supported[idx] & ELINK_SUPPORTED_10baseT_Half)
8689 : : {
8690 : 0 : sc->link_params.req_line_speed[idx] =
8691 : : ELINK_SPEED_10;
8692 : 0 : sc->link_params.req_duplex[idx] = DUPLEX_HALF;
8693 : 0 : sc->port.advertising[idx] |=
8694 : : (ADVERTISED_10baseT_Half | ADVERTISED_TP);
8695 : : } else {
8696 : 0 : PMD_DRV_LOG(ERR, sc,
8697 : : "Invalid NVRAM config link_config=0x%08x "
8698 : : "speed_cap_mask=0x%08x",
8699 : : link_config,
8700 : : sc->
8701 : : link_params.speed_cap_mask[idx]);
8702 : 0 : return;
8703 : : }
8704 : 0 : break;
8705 : :
8706 : 0 : case PORT_FEATURE_LINK_SPEED_100M_FULL:
8707 : 0 : if (sc->
8708 [ # # ]: 0 : port.supported[idx] & ELINK_SUPPORTED_100baseT_Full)
8709 : : {
8710 : 0 : sc->link_params.req_line_speed[idx] =
8711 : : ELINK_SPEED_100;
8712 : 0 : sc->port.advertising[idx] |=
8713 : : (ADVERTISED_100baseT_Full | ADVERTISED_TP);
8714 : : } else {
8715 : 0 : PMD_DRV_LOG(ERR, sc,
8716 : : "Invalid NVRAM config link_config=0x%08x "
8717 : : "speed_cap_mask=0x%08x",
8718 : : link_config,
8719 : : sc->
8720 : : link_params.speed_cap_mask[idx]);
8721 : 0 : return;
8722 : : }
8723 : 0 : break;
8724 : :
8725 : 0 : case PORT_FEATURE_LINK_SPEED_100M_HALF:
8726 : 0 : if (sc->
8727 [ # # ]: 0 : port.supported[idx] & ELINK_SUPPORTED_100baseT_Half)
8728 : : {
8729 : 0 : sc->link_params.req_line_speed[idx] =
8730 : : ELINK_SPEED_100;
8731 : 0 : sc->link_params.req_duplex[idx] = DUPLEX_HALF;
8732 : 0 : sc->port.advertising[idx] |=
8733 : : (ADVERTISED_100baseT_Half | ADVERTISED_TP);
8734 : : } else {
8735 : 0 : PMD_DRV_LOG(ERR, sc,
8736 : : "Invalid NVRAM config link_config=0x%08x "
8737 : : "speed_cap_mask=0x%08x",
8738 : : link_config,
8739 : : sc->
8740 : : link_params.speed_cap_mask[idx]);
8741 : 0 : return;
8742 : : }
8743 : 0 : break;
8744 : :
8745 : 0 : case PORT_FEATURE_LINK_SPEED_1G:
8746 [ # # ]: 0 : if (sc->port.supported[idx] &
8747 : : ELINK_SUPPORTED_1000baseT_Full) {
8748 : 0 : sc->link_params.req_line_speed[idx] =
8749 : : ELINK_SPEED_1000;
8750 : 0 : sc->port.advertising[idx] |=
8751 : : (ADVERTISED_1000baseT_Full | ADVERTISED_TP);
8752 : : } else {
8753 : 0 : PMD_DRV_LOG(ERR, sc,
8754 : : "Invalid NVRAM config link_config=0x%08x "
8755 : : "speed_cap_mask=0x%08x",
8756 : : link_config,
8757 : : sc->
8758 : : link_params.speed_cap_mask[idx]);
8759 : 0 : return;
8760 : : }
8761 : 0 : break;
8762 : :
8763 : 0 : case PORT_FEATURE_LINK_SPEED_2_5G:
8764 [ # # ]: 0 : if (sc->port.supported[idx] &
8765 : : ELINK_SUPPORTED_2500baseX_Full) {
8766 : 0 : sc->link_params.req_line_speed[idx] =
8767 : : ELINK_SPEED_2500;
8768 : 0 : sc->port.advertising[idx] |=
8769 : : (ADVERTISED_2500baseX_Full | ADVERTISED_TP);
8770 : : } else {
8771 : 0 : PMD_DRV_LOG(ERR, sc,
8772 : : "Invalid NVRAM config link_config=0x%08x "
8773 : : "speed_cap_mask=0x%08x",
8774 : : link_config,
8775 : : sc->
8776 : : link_params.speed_cap_mask[idx]);
8777 : 0 : return;
8778 : : }
8779 : 0 : break;
8780 : :
8781 : 0 : case PORT_FEATURE_LINK_SPEED_10G_CX4:
8782 [ # # ]: 0 : if (sc->port.supported[idx] &
8783 : : ELINK_SUPPORTED_10000baseT_Full) {
8784 : 0 : sc->link_params.req_line_speed[idx] =
8785 : : ELINK_SPEED_10000;
8786 : 0 : sc->port.advertising[idx] |=
8787 : : (ADVERTISED_10000baseT_Full |
8788 : : ADVERTISED_FIBRE);
8789 : : } else {
8790 : 0 : PMD_DRV_LOG(ERR, sc,
8791 : : "Invalid NVRAM config link_config=0x%08x "
8792 : : "speed_cap_mask=0x%08x",
8793 : : link_config,
8794 : : sc->
8795 : : link_params.speed_cap_mask[idx]);
8796 : 0 : return;
8797 : : }
8798 : 0 : break;
8799 : :
8800 : 0 : case PORT_FEATURE_LINK_SPEED_20G:
8801 : 0 : sc->link_params.req_line_speed[idx] = ELINK_SPEED_20000;
8802 : 0 : break;
8803 : :
8804 : 0 : default:
8805 : 0 : PMD_DRV_LOG(ERR, sc,
8806 : : "Invalid NVRAM config link_config=0x%08x "
8807 : : "speed_cap_mask=0x%08x", link_config,
8808 : : sc->link_params.speed_cap_mask[idx]);
8809 : 0 : sc->link_params.req_line_speed[idx] =
8810 : : ELINK_SPEED_AUTO_NEG;
8811 : 0 : sc->port.advertising[idx] = sc->port.supported[idx];
8812 : 0 : break;
8813 : : }
8814 : :
8815 : 0 : sc->link_params.req_flow_ctrl[idx] =
8816 : 0 : (link_config & PORT_FEATURE_FLOW_CONTROL_MASK);
8817 : :
8818 [ # # ]: 0 : if (sc->link_params.req_flow_ctrl[idx] == ELINK_FLOW_CTRL_AUTO) {
8819 : 0 : if (!
8820 : : (sc->
8821 [ # # ]: 0 : port.supported[idx] & ELINK_SUPPORTED_Autoneg)) {
8822 : 0 : sc->link_params.req_flow_ctrl[idx] =
8823 : : ELINK_FLOW_CTRL_NONE;
8824 : : } else {
8825 : : bnx2x_set_requested_fc(sc);
8826 : : }
8827 : : }
8828 : : }
8829 : : }
8830 : :
8831 : 0 : static void bnx2x_get_phy_info(struct bnx2x_softc *sc)
8832 : : {
8833 : 0 : uint8_t port = SC_PORT(sc);
8834 : : uint32_t eee_mode;
8835 : :
8836 : 0 : PMD_INIT_FUNC_TRACE(sc);
8837 : :
8838 : : /* shmem data already read in bnx2x_get_shmem_info() */
8839 : :
8840 : 0 : bnx2x_link_settings_supported(sc, sc->link_params.switch_cfg);
8841 : 0 : bnx2x_link_settings_requested(sc);
8842 : :
8843 : : /* configure link feature according to nvram value */
8844 : 0 : eee_mode =
8845 : 0 : (((SHMEM_RD(sc, dev_info.port_feature_config[port].eee_power_mode))
8846 : : & PORT_FEAT_CFG_EEE_POWER_MODE_MASK) >>
8847 : : PORT_FEAT_CFG_EEE_POWER_MODE_SHIFT);
8848 [ # # ]: 0 : if (eee_mode != PORT_FEAT_CFG_EEE_POWER_MODE_DISABLED) {
8849 : 0 : sc->link_params.eee_mode = (ELINK_EEE_MODE_ADV_LPI |
8850 : : ELINK_EEE_MODE_ENABLE_LPI |
8851 : : ELINK_EEE_MODE_OUTPUT_TIME);
8852 : : } else {
8853 : 0 : sc->link_params.eee_mode = 0;
8854 : : }
8855 : :
8856 : : /* get the media type */
8857 : 0 : bnx2x_media_detect(sc);
8858 : 0 : }
8859 : :
8860 : 0 : static void bnx2x_set_modes_bitmap(struct bnx2x_softc *sc)
8861 : : {
8862 : : uint32_t flags = MODE_ASIC | MODE_PORT2;
8863 : :
8864 [ # # ]: 0 : if (CHIP_IS_E2(sc)) {
8865 : : flags |= MODE_E2;
8866 [ # # ]: 0 : } else if (CHIP_IS_E3(sc)) {
8867 : : flags |= MODE_E3;
8868 [ # # ]: 0 : if (CHIP_REV(sc) == CHIP_REV_Ax) {
8869 : : flags |= MODE_E3_A0;
8870 : : } else { /*if (CHIP_REV(sc) == CHIP_REV_Bx) */
8871 : :
8872 : : flags |= MODE_E3_B0 | MODE_COS3;
8873 : : }
8874 : : }
8875 : :
8876 [ # # # # ]: 0 : if (IS_MF(sc)) {
8877 : 0 : flags |= MODE_MF;
8878 [ # # # # ]: 0 : switch (sc->devinfo.mf_info.mf_mode) {
8879 : 0 : case MULTI_FUNCTION_SD:
8880 : 0 : flags |= MODE_MF_SD;
8881 : 0 : break;
8882 : 0 : case MULTI_FUNCTION_SI:
8883 : 0 : flags |= MODE_MF_SI;
8884 : 0 : break;
8885 : 0 : case MULTI_FUNCTION_AFEX:
8886 : 0 : flags |= MODE_MF_AFEX;
8887 : 0 : break;
8888 : : }
8889 : : } else {
8890 : 0 : flags |= MODE_SF;
8891 : : }
8892 : :
8893 : : #if defined(__LITTLE_ENDIAN)
8894 : 0 : flags |= MODE_LITTLE_ENDIAN;
8895 : : #else /* __BIG_ENDIAN */
8896 : : flags |= MODE_BIG_ENDIAN;
8897 : : #endif
8898 : :
8899 : 0 : INIT_MODE_FLAGS(sc) = flags;
8900 : 0 : }
8901 : :
8902 : 0 : int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
8903 : : {
8904 : : struct bnx2x_fastpath *fp;
8905 : : char buf[32];
8906 : : uint32_t i;
8907 : :
8908 [ # # ]: 0 : if (IS_PF(sc)) {
8909 : : /************************/
8910 : : /* DEFAULT STATUS BLOCK */
8911 : : /************************/
8912 : :
8913 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, sizeof(struct host_sp_status_block),
8914 : : &sc->def_sb_dma, "def_sb",
8915 : : RTE_CACHE_LINE_SIZE) != 0) {
8916 : : return -1;
8917 : : }
8918 : :
8919 : 0 : sc->def_sb =
8920 : 0 : (struct host_sp_status_block *)sc->def_sb_dma.vaddr;
8921 : : /***************/
8922 : : /* EVENT QUEUE */
8923 : : /***************/
8924 : :
8925 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
8926 : : &sc->eq_dma, "ev_queue",
8927 : : RTE_CACHE_LINE_SIZE) != 0) {
8928 : 0 : sc->def_sb = NULL;
8929 : 0 : return -1;
8930 : : }
8931 : :
8932 : 0 : sc->eq = (union event_ring_elem *)sc->eq_dma.vaddr;
8933 : :
8934 : : /*************/
8935 : : /* SLOW PATH */
8936 : : /*************/
8937 : :
8938 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_slowpath),
8939 : : &sc->sp_dma, "sp",
8940 : : RTE_CACHE_LINE_SIZE) != 0) {
8941 : 0 : sc->eq = NULL;
8942 : 0 : sc->def_sb = NULL;
8943 : 0 : return -1;
8944 : : }
8945 : :
8946 : 0 : sc->sp = (struct bnx2x_slowpath *)sc->sp_dma.vaddr;
8947 : :
8948 : : /*******************/
8949 : : /* SLOW PATH QUEUE */
8950 : : /*******************/
8951 : :
8952 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
8953 : : &sc->spq_dma, "sp_queue",
8954 : : RTE_CACHE_LINE_SIZE) != 0) {
8955 : 0 : sc->sp = NULL;
8956 : 0 : sc->eq = NULL;
8957 : 0 : sc->def_sb = NULL;
8958 : 0 : return -1;
8959 : : }
8960 : :
8961 : 0 : sc->spq = (struct eth_spe *)sc->spq_dma.vaddr;
8962 : :
8963 : : /***************************/
8964 : : /* FW DECOMPRESSION BUFFER */
8965 : : /***************************/
8966 : :
8967 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, FW_BUF_SIZE, &sc->gz_buf_dma,
8968 : : "fw_buf", RTE_CACHE_LINE_SIZE) != 0) {
8969 : 0 : sc->spq = NULL;
8970 : 0 : sc->sp = NULL;
8971 : 0 : sc->eq = NULL;
8972 : 0 : sc->def_sb = NULL;
8973 : 0 : return -1;
8974 : : }
8975 : :
8976 : 0 : sc->gz_buf = (void *)sc->gz_buf_dma.vaddr;
8977 : : }
8978 : :
8979 : : /*************/
8980 : : /* FASTPATHS */
8981 : : /*************/
8982 : :
8983 : : /* allocate DMA memory for each fastpath structure */
8984 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
8985 : : fp = &sc->fp[i];
8986 : 0 : fp->sc = sc;
8987 : 0 : fp->index = i;
8988 : :
8989 : : /*******************/
8990 : : /* FP STATUS BLOCK */
8991 : : /*******************/
8992 : :
8993 : : snprintf(buf, sizeof(buf), "fp_%d_sb", i);
8994 [ # # ]: 0 : if (bnx2x_dma_alloc(sc, sizeof(union bnx2x_host_hc_status_block),
8995 : : &fp->sb_dma, buf, RTE_CACHE_LINE_SIZE) != 0) {
8996 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to alloc %s", buf);
8997 : 0 : return -1;
8998 : : } else {
8999 [ # # # # ]: 0 : if (CHIP_IS_E2E3(sc)) {
9000 : 0 : fp->status_block.e2_sb =
9001 : : (struct host_hc_status_block_e2 *)
9002 : 0 : fp->sb_dma.vaddr;
9003 : : } else {
9004 : 0 : fp->status_block.e1x_sb =
9005 : : (struct host_hc_status_block_e1x *)
9006 : 0 : fp->sb_dma.vaddr;
9007 : : }
9008 : : }
9009 : : }
9010 : :
9011 : : return 0;
9012 : : }
9013 : :
9014 : 0 : void bnx2x_free_hsi_mem(struct bnx2x_softc *sc)
9015 : : {
9016 : : struct bnx2x_fastpath *fp;
9017 : : int i;
9018 : :
9019 [ # # ]: 0 : for (i = 0; i < sc->num_queues; i++) {
9020 : : fp = &sc->fp[i];
9021 : :
9022 : : /*******************/
9023 : : /* FP STATUS BLOCK */
9024 : : /*******************/
9025 : :
9026 : 0 : memset(&fp->status_block, 0, sizeof(fp->status_block));
9027 : 0 : bnx2x_dma_free(&fp->sb_dma);
9028 : : }
9029 : :
9030 [ # # ]: 0 : if (IS_PF(sc)) {
9031 : : /***************************/
9032 : : /* FW DECOMPRESSION BUFFER */
9033 : : /***************************/
9034 : :
9035 : 0 : bnx2x_dma_free(&sc->gz_buf_dma);
9036 : 0 : sc->gz_buf = NULL;
9037 : :
9038 : : /*******************/
9039 : : /* SLOW PATH QUEUE */
9040 : : /*******************/
9041 : :
9042 : 0 : bnx2x_dma_free(&sc->spq_dma);
9043 : 0 : sc->spq = NULL;
9044 : :
9045 : : /*************/
9046 : : /* SLOW PATH */
9047 : : /*************/
9048 : :
9049 : 0 : bnx2x_dma_free(&sc->sp_dma);
9050 : 0 : sc->sp = NULL;
9051 : :
9052 : : /***************/
9053 : : /* EVENT QUEUE */
9054 : : /***************/
9055 : :
9056 : 0 : bnx2x_dma_free(&sc->eq_dma);
9057 : 0 : sc->eq = NULL;
9058 : :
9059 : : /************************/
9060 : : /* DEFAULT STATUS BLOCK */
9061 : : /************************/
9062 : :
9063 : 0 : bnx2x_dma_free(&sc->def_sb_dma);
9064 : 0 : sc->def_sb = NULL;
9065 : : }
9066 : 0 : }
9067 : :
9068 : : /*
9069 : : * Previous driver DMAE transaction may have occurred when pre-boot stage
9070 : : * ended and boot began. This would invalidate the addresses of the
9071 : : * transaction, resulting in was-error bit set in the PCI causing all
9072 : : * hw-to-host PCIe transactions to timeout. If this happened we want to clear
9073 : : * the interrupt which detected this from the pglueb and the was-done bit
9074 : : */
9075 : : static void bnx2x_prev_interrupted_dmae(struct bnx2x_softc *sc)
9076 : : {
9077 : : uint32_t val;
9078 : :
9079 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
9080 : : val = REG_RD(sc, PGLUE_B_REG_PGLUE_B_INT_STS);
9081 [ # # ]: 0 : if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) {
9082 : 0 : REG_WR(sc, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR,
9083 : : 1 << SC_FUNC(sc));
9084 : : }
9085 : : }
9086 : : }
9087 : :
9088 : 0 : static int bnx2x_prev_mcp_done(struct bnx2x_softc *sc)
9089 : : {
9090 : : uint32_t rc = bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_DONE,
9091 : : DRV_MSG_CODE_UNLOAD_SKIP_LINK_RESET);
9092 [ # # ]: 0 : if (!rc) {
9093 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP response failure, aborting");
9094 : 0 : return -1;
9095 : : }
9096 : :
9097 : : return 0;
9098 : : }
9099 : :
9100 : : static struct bnx2x_prev_list_node *bnx2x_prev_path_get_entry(struct bnx2x_softc *sc)
9101 : : {
9102 : : struct bnx2x_prev_list_node *tmp;
9103 : :
9104 [ # # # # ]: 0 : LIST_FOREACH(tmp, &bnx2x_prev_list, node) {
9105 [ # # # # ]: 0 : if ((sc->pcie_bus == tmp->bus) &&
9106 [ # # # # ]: 0 : (sc->pcie_device == tmp->slot) &&
9107 [ # # # # ]: 0 : (SC_PATH(sc) == tmp->path)) {
9108 : : return tmp;
9109 : : }
9110 : : }
9111 : :
9112 : : return NULL;
9113 : : }
9114 : :
9115 : 0 : static uint8_t bnx2x_prev_is_path_marked(struct bnx2x_softc *sc)
9116 : : {
9117 : : struct bnx2x_prev_list_node *tmp;
9118 : : int rc = FALSE;
9119 : :
9120 : : rte_spinlock_lock(&bnx2x_prev_mtx);
9121 : :
9122 : : tmp = bnx2x_prev_path_get_entry(sc);
9123 [ # # ]: 0 : if (tmp) {
9124 [ # # ]: 0 : if (tmp->aer) {
9125 : 0 : PMD_DRV_LOG(DEBUG, sc,
9126 : : "Path %d/%d/%d was marked by AER",
9127 : : sc->pcie_bus, sc->pcie_device, SC_PATH(sc));
9128 : : } else {
9129 : : rc = TRUE;
9130 : 0 : PMD_DRV_LOG(DEBUG, sc,
9131 : : "Path %d/%d/%d was already cleaned from previous drivers",
9132 : : sc->pcie_bus, sc->pcie_device, SC_PATH(sc));
9133 : : }
9134 : : }
9135 : :
9136 : : rte_spinlock_unlock(&bnx2x_prev_mtx);
9137 : :
9138 : 0 : return rc;
9139 : : }
9140 : :
9141 : 0 : static int bnx2x_prev_mark_path(struct bnx2x_softc *sc, uint8_t after_undi)
9142 : : {
9143 : : struct bnx2x_prev_list_node *tmp;
9144 : :
9145 : : rte_spinlock_lock(&bnx2x_prev_mtx);
9146 : :
9147 : : /* Check whether the entry for this path already exists */
9148 : : tmp = bnx2x_prev_path_get_entry(sc);
9149 [ # # ]: 0 : if (tmp) {
9150 [ # # ]: 0 : if (!tmp->aer) {
9151 : 0 : PMD_DRV_LOG(DEBUG, sc,
9152 : : "Re-marking AER in path %d/%d/%d",
9153 : : sc->pcie_bus, sc->pcie_device, SC_PATH(sc));
9154 : : } else {
9155 : 0 : PMD_DRV_LOG(DEBUG, sc,
9156 : : "Removing AER indication from path %d/%d/%d",
9157 : : sc->pcie_bus, sc->pcie_device, SC_PATH(sc));
9158 : 0 : tmp->aer = 0;
9159 : : }
9160 : :
9161 : : rte_spinlock_unlock(&bnx2x_prev_mtx);
9162 : 0 : return 0;
9163 : : }
9164 : :
9165 : : rte_spinlock_unlock(&bnx2x_prev_mtx);
9166 : :
9167 : : /* Create an entry for this path and add it */
9168 : 0 : tmp = rte_malloc("", sizeof(struct bnx2x_prev_list_node),
9169 : : RTE_CACHE_LINE_SIZE);
9170 [ # # ]: 0 : if (!tmp) {
9171 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to allocate 'bnx2x_prev_list_node'");
9172 : 0 : return -1;
9173 : : }
9174 : :
9175 : 0 : tmp->bus = sc->pcie_bus;
9176 : 0 : tmp->slot = sc->pcie_device;
9177 : 0 : tmp->path = SC_PATH(sc);
9178 : 0 : tmp->aer = 0;
9179 [ # # ]: 0 : tmp->undi = after_undi ? (1 << SC_PORT(sc)) : 0;
9180 : :
9181 : : rte_spinlock_lock(&bnx2x_prev_mtx);
9182 : :
9183 [ # # ]: 0 : LIST_INSERT_HEAD(&bnx2x_prev_list, tmp, node);
9184 : :
9185 : : rte_spinlock_unlock(&bnx2x_prev_mtx);
9186 : :
9187 : 0 : return 0;
9188 : : }
9189 : :
9190 : 0 : static int bnx2x_do_flr(struct bnx2x_softc *sc)
9191 : : {
9192 : : int i;
9193 : :
9194 : : /* only E2 and onwards support FLR */
9195 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
9196 : 0 : PMD_DRV_LOG(WARNING, sc, "FLR not supported in E1H");
9197 : 0 : return -1;
9198 : : }
9199 : :
9200 : : /* only bootcode REQ_BC_VER_4_INITIATE_FLR and onwards support flr */
9201 [ # # ]: 0 : if (sc->devinfo.bc_ver < REQ_BC_VER_4_INITIATE_FLR) {
9202 : 0 : PMD_DRV_LOG(WARNING, sc,
9203 : : "FLR not supported by BC_VER: 0x%08x",
9204 : : sc->devinfo.bc_ver);
9205 : 0 : return -1;
9206 : : }
9207 : :
9208 : : /* Wait for Transaction Pending bit clean */
9209 [ # # ]: 0 : for (i = 0; i < 4; i++) {
9210 [ # # ]: 0 : if (i) {
9211 : 0 : DELAY(((1 << (i - 1)) * 100) * 1000);
9212 : : }
9213 : :
9214 [ # # ]: 0 : if (!bnx2x_is_pcie_pending(sc)) {
9215 : 0 : goto clear;
9216 : : }
9217 : : }
9218 : :
9219 : 0 : PMD_DRV_LOG(NOTICE, sc, "PCIE transaction is not cleared, "
9220 : : "proceeding with reset anyway");
9221 : :
9222 : 0 : clear:
9223 : : bnx2x_fw_command(sc, DRV_MSG_CODE_INITIATE_FLR, 0);
9224 : :
9225 : 0 : return 0;
9226 : : }
9227 : :
9228 : : struct bnx2x_mac_vals {
9229 : : uint32_t xmac_addr;
9230 : : uint32_t xmac_val;
9231 : : uint32_t emac_addr;
9232 : : uint32_t emac_val;
9233 : : uint32_t umac_addr;
9234 : : uint32_t umac_val;
9235 : : uint32_t bmac_addr;
9236 : : uint32_t bmac_val[2];
9237 : : };
9238 : :
9239 : : static void
9240 : 0 : bnx2x_prev_unload_close_mac(struct bnx2x_softc *sc, struct bnx2x_mac_vals *vals)
9241 : : {
9242 : : uint32_t val, base_addr, offset, mask, reset_reg;
9243 : : uint8_t mac_stopped = FALSE;
9244 : 0 : uint8_t port = SC_PORT(sc);
9245 : : uint32_t wb_data[2];
9246 : :
9247 : : /* reset addresses as they also mark which values were changed */
9248 : 0 : vals->bmac_addr = 0;
9249 : 0 : vals->umac_addr = 0;
9250 : 0 : vals->xmac_addr = 0;
9251 : 0 : vals->emac_addr = 0;
9252 : :
9253 : : reset_reg = REG_RD(sc, MISC_REG_RESET_REG_2);
9254 : :
9255 [ # # # # : 0 : if (!CHIP_IS_E3(sc)) {
# # # # #
# ]
9256 : 0 : val = REG_RD(sc, NIG_REG_BMAC0_REGS_OUT_EN + port * 4);
9257 : 0 : mask = MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port;
9258 [ # # # # ]: 0 : if ((mask & reset_reg) && val) {
9259 : 0 : base_addr = SC_PORT(sc) ? NIG_REG_INGRESS_BMAC1_MEM
9260 [ # # ]: 0 : : NIG_REG_INGRESS_BMAC0_MEM;
9261 : : offset = CHIP_IS_E2(sc) ? BIGMAC2_REGISTER_BMAC_CONTROL
9262 : : : BIGMAC_REGISTER_BMAC_CONTROL;
9263 : :
9264 : : /*
9265 : : * use rd/wr since we cannot use dmae. This is safe
9266 : : * since MCP won't access the bus due to the request
9267 : : * to unload, and no function on the path can be
9268 : : * loaded at this time.
9269 : : */
9270 : 0 : wb_data[0] = REG_RD(sc, base_addr + offset);
9271 : 0 : wb_data[1] = REG_RD(sc, base_addr + offset + 0x4);
9272 : 0 : vals->bmac_addr = base_addr + offset;
9273 : 0 : vals->bmac_val[0] = wb_data[0];
9274 : 0 : vals->bmac_val[1] = wb_data[1];
9275 : 0 : wb_data[0] &= ~ELINK_BMAC_CONTROL_RX_ENABLE;
9276 : : REG_WR(sc, vals->bmac_addr, wb_data[0]);
9277 : 0 : REG_WR(sc, vals->bmac_addr + 0x4, wb_data[1]);
9278 : : }
9279 : :
9280 : 0 : vals->emac_addr = NIG_REG_NIG_EMAC0_EN + SC_PORT(sc) * 4;
9281 : 0 : vals->emac_val = REG_RD(sc, vals->emac_addr);
9282 : 0 : REG_WR(sc, vals->emac_addr, 0);
9283 : : mac_stopped = TRUE;
9284 : : } else {
9285 [ # # ]: 0 : if (reset_reg & MISC_REGISTERS_RESET_REG_2_XMAC) {
9286 [ # # ]: 0 : base_addr = SC_PORT(sc) ? GRCBASE_XMAC1 : GRCBASE_XMAC0;
9287 : 0 : val = REG_RD(sc, base_addr + XMAC_REG_PFC_CTRL_HI);
9288 : 0 : REG_WR(sc, base_addr + XMAC_REG_PFC_CTRL_HI,
9289 : : val & ~(1 << 1));
9290 : 0 : REG_WR(sc, base_addr + XMAC_REG_PFC_CTRL_HI,
9291 : : val | (1 << 1));
9292 : 0 : vals->xmac_addr = base_addr + XMAC_REG_CTRL;
9293 : 0 : vals->xmac_val = REG_RD(sc, vals->xmac_addr);
9294 : 0 : REG_WR(sc, vals->xmac_addr, 0);
9295 : : mac_stopped = TRUE;
9296 : : }
9297 : :
9298 : 0 : mask = MISC_REGISTERS_RESET_REG_2_UMAC0 << port;
9299 [ # # ]: 0 : if (mask & reset_reg) {
9300 [ # # ]: 0 : base_addr = SC_PORT(sc) ? GRCBASE_UMAC1 : GRCBASE_UMAC0;
9301 : 0 : vals->umac_addr = base_addr + UMAC_REG_COMMAND_CONFIG;
9302 : 0 : vals->umac_val = REG_RD(sc, vals->umac_addr);
9303 : 0 : REG_WR(sc, vals->umac_addr, 0);
9304 : : mac_stopped = TRUE;
9305 : : }
9306 : : }
9307 : :
9308 [ # # ]: 0 : if (mac_stopped) {
9309 : 0 : DELAY(20000);
9310 : : }
9311 : 0 : }
9312 : :
9313 : : #define BNX2X_PREV_UNDI_PROD_ADDR(p) (BAR_TSTRORM_INTMEM + 0x1508 + ((p) << 4))
9314 : : #define BNX2X_PREV_UNDI_RCQ(val) ((val) & 0xffff)
9315 : : #define BNX2X_PREV_UNDI_BD(val) ((val) >> 16 & 0xffff)
9316 : : #define BNX2X_PREV_UNDI_PROD(rcq, bd) ((bd) << 16 | (rcq))
9317 : :
9318 : : static void
9319 : : bnx2x_prev_unload_undi_inc(struct bnx2x_softc *sc, uint8_t port, uint8_t inc)
9320 : : {
9321 : : uint16_t rcq, bd;
9322 : 0 : uint32_t tmp_reg = REG_RD(sc, BNX2X_PREV_UNDI_PROD_ADDR(port));
9323 : :
9324 : 0 : rcq = BNX2X_PREV_UNDI_RCQ(tmp_reg) + inc;
9325 : 0 : bd = BNX2X_PREV_UNDI_BD(tmp_reg) + inc;
9326 : :
9327 : 0 : tmp_reg = BNX2X_PREV_UNDI_PROD(rcq, bd);
9328 : : REG_WR(sc, BNX2X_PREV_UNDI_PROD_ADDR(port), tmp_reg);
9329 : 0 : }
9330 : :
9331 : 0 : static int bnx2x_prev_unload_common(struct bnx2x_softc *sc)
9332 : : {
9333 : : uint32_t reset_reg, tmp_reg = 0, rc;
9334 : : uint8_t prev_undi = FALSE;
9335 : : struct bnx2x_mac_vals mac_vals;
9336 : : uint32_t timer_count = 1000;
9337 : : uint32_t prev_brb;
9338 : :
9339 : : /*
9340 : : * It is possible a previous function received 'common' answer,
9341 : : * but hasn't loaded yet, therefore creating a scenario of
9342 : : * multiple functions receiving 'common' on the same path.
9343 : : */
9344 : : memset(&mac_vals, 0, sizeof(mac_vals));
9345 : :
9346 [ # # ]: 0 : if (bnx2x_prev_is_path_marked(sc)) {
9347 : 0 : return bnx2x_prev_mcp_done(sc);
9348 : : }
9349 : :
9350 : : reset_reg = REG_RD(sc, MISC_REG_RESET_REG_1);
9351 : :
9352 : : /* Reset should be performed after BRB is emptied */
9353 [ # # ]: 0 : if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_BRB1) {
9354 : : /* Close the MAC Rx to prevent BRB from filling up */
9355 : 0 : bnx2x_prev_unload_close_mac(sc, &mac_vals);
9356 : :
9357 : : /* close LLH filters towards the BRB */
9358 : 0 : elink_set_rx_filter(&sc->link_params, 0);
9359 : :
9360 : : /*
9361 : : * Check if the UNDI driver was previously loaded.
9362 : : * UNDI driver initializes CID offset for normal bell to 0x7
9363 : : */
9364 [ # # ]: 0 : if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_DORQ) {
9365 : : tmp_reg = REG_RD(sc, DORQ_REG_NORM_CID_OFST);
9366 [ # # ]: 0 : if (tmp_reg == 0x7) {
9367 : 0 : PMD_DRV_LOG(DEBUG, sc, "UNDI previously loaded");
9368 : : prev_undi = TRUE;
9369 : : /* clear the UNDI indication */
9370 : : REG_WR(sc, DORQ_REG_NORM_CID_OFST, 0);
9371 : : /* clear possible idle check errors */
9372 : : REG_RD(sc, NIG_REG_NIG_INT_STS_CLR_0);
9373 : : }
9374 : : }
9375 : :
9376 : : /* wait until BRB is empty */
9377 : : tmp_reg = REG_RD(sc, BRB1_REG_NUM_OF_FULL_BLOCKS);
9378 [ # # ]: 0 : while (timer_count) {
9379 : : prev_brb = tmp_reg;
9380 : :
9381 : : tmp_reg = REG_RD(sc, BRB1_REG_NUM_OF_FULL_BLOCKS);
9382 [ # # ]: 0 : if (!tmp_reg) {
9383 : : break;
9384 : : }
9385 : :
9386 : 0 : PMD_DRV_LOG(DEBUG, sc, "BRB still has 0x%08x", tmp_reg);
9387 : :
9388 : : /* reset timer as long as BRB actually gets emptied */
9389 [ # # ]: 0 : if (prev_brb > tmp_reg) {
9390 : : timer_count = 1000;
9391 : : } else {
9392 : 0 : timer_count--;
9393 : : }
9394 : :
9395 : : /* If UNDI resides in memory, manually increment it */
9396 [ # # ]: 0 : if (prev_undi) {
9397 : 0 : bnx2x_prev_unload_undi_inc(sc, SC_PORT(sc), 1);
9398 : : }
9399 : :
9400 : 0 : DELAY(10);
9401 : : }
9402 : :
9403 [ # # ]: 0 : if (!timer_count) {
9404 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to empty BRB");
9405 : : }
9406 : : }
9407 : :
9408 : : /* No packets are in the pipeline, path is ready for reset */
9409 : 0 : bnx2x_reset_common(sc);
9410 : :
9411 [ # # ]: 0 : if (mac_vals.xmac_addr) {
9412 : 0 : REG_WR(sc, mac_vals.xmac_addr, mac_vals.xmac_val);
9413 : : }
9414 [ # # ]: 0 : if (mac_vals.umac_addr) {
9415 : 0 : REG_WR(sc, mac_vals.umac_addr, mac_vals.umac_val);
9416 : : }
9417 [ # # ]: 0 : if (mac_vals.emac_addr) {
9418 : 0 : REG_WR(sc, mac_vals.emac_addr, mac_vals.emac_val);
9419 : : }
9420 [ # # ]: 0 : if (mac_vals.bmac_addr) {
9421 : 0 : REG_WR(sc, mac_vals.bmac_addr, mac_vals.bmac_val[0]);
9422 : 0 : REG_WR(sc, mac_vals.bmac_addr + 4, mac_vals.bmac_val[1]);
9423 : : }
9424 : :
9425 : 0 : rc = bnx2x_prev_mark_path(sc, prev_undi);
9426 [ # # ]: 0 : if (rc) {
9427 : 0 : bnx2x_prev_mcp_done(sc);
9428 : 0 : return rc;
9429 : : }
9430 : :
9431 : 0 : return bnx2x_prev_mcp_done(sc);
9432 : : }
9433 : :
9434 : 0 : static int bnx2x_prev_unload_uncommon(struct bnx2x_softc *sc)
9435 : : {
9436 : : int rc;
9437 : :
9438 : : /* Test if previous unload process was already finished for this path */
9439 [ # # ]: 0 : if (bnx2x_prev_is_path_marked(sc)) {
9440 : 0 : return bnx2x_prev_mcp_done(sc);
9441 : : }
9442 : :
9443 : : /*
9444 : : * If function has FLR capabilities, and existing FW version matches
9445 : : * the one required, then FLR will be sufficient to clean any residue
9446 : : * left by previous driver
9447 : : */
9448 : 0 : rc = bnx2x_nic_load_analyze_req(sc, FW_MSG_CODE_DRV_LOAD_FUNCTION);
9449 [ # # ]: 0 : if (!rc) {
9450 : : /* fw version is good */
9451 : 0 : rc = bnx2x_do_flr(sc);
9452 : : }
9453 : :
9454 [ # # ]: 0 : if (!rc) {
9455 : : /* FLR was performed */
9456 : : return 0;
9457 : : }
9458 : :
9459 : 0 : PMD_DRV_LOG(INFO, sc, "Could not FLR");
9460 : :
9461 : : /* Close the MCP request, return failure */
9462 : 0 : rc = bnx2x_prev_mcp_done(sc);
9463 [ # # ]: 0 : if (!rc) {
9464 : : rc = BNX2X_PREV_WAIT_NEEDED;
9465 : : }
9466 : :
9467 : : return rc;
9468 : : }
9469 : :
9470 : 0 : static int bnx2x_prev_unload(struct bnx2x_softc *sc)
9471 : : {
9472 : : int time_counter = 10;
9473 : : uint32_t fw, hw_lock_reg, hw_lock_val;
9474 : : uint32_t rc = 0;
9475 : :
9476 : 0 : PMD_INIT_FUNC_TRACE(sc);
9477 : :
9478 : : /*
9479 : : * Clear HW from errors which may have resulted from an interrupted
9480 : : * DMAE transaction.
9481 : : */
9482 : : bnx2x_prev_interrupted_dmae(sc);
9483 : :
9484 : : /* Release previously held locks */
9485 : 0 : hw_lock_reg = (SC_FUNC(sc) <= 5) ?
9486 [ # # ]: 0 : (MISC_REG_DRIVER_CONTROL_1 + SC_FUNC(sc) * 8) :
9487 : 0 : (MISC_REG_DRIVER_CONTROL_7 + (SC_FUNC(sc) - 6) * 8);
9488 : :
9489 : 0 : hw_lock_val = (REG_RD(sc, hw_lock_reg));
9490 [ # # ]: 0 : if (hw_lock_val) {
9491 [ # # ]: 0 : if (hw_lock_val & HW_LOCK_RESOURCE_NVRAM) {
9492 : 0 : PMD_DRV_LOG(DEBUG, sc, "Releasing previously held NVRAM lock\n");
9493 : 0 : REG_WR(sc, MCP_REG_MCPR_NVM_SW_ARB,
9494 : : (MCPR_NVM_SW_ARB_ARB_REQ_CLR1 << SC_PORT(sc)));
9495 : : }
9496 : 0 : PMD_DRV_LOG(DEBUG, sc, "Releasing previously held HW lock\n");
9497 : : REG_WR(sc, hw_lock_reg, 0xffffffff);
9498 : : }
9499 : :
9500 [ # # ]: 0 : if (MCPR_ACCESS_LOCK_LOCK & REG_RD(sc, MCP_REG_MCPR_ACCESS_LOCK)) {
9501 : 0 : PMD_DRV_LOG(DEBUG, sc, "Releasing previously held ALR\n");
9502 : : REG_WR(sc, MCP_REG_MCPR_ACCESS_LOCK, 0);
9503 : : }
9504 : :
9505 : : do {
9506 : : /* Lock MCP using an unload request */
9507 : : fw = bnx2x_fw_command(sc, DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS, 0);
9508 [ # # ]: 0 : if (!fw) {
9509 : 0 : PMD_DRV_LOG(NOTICE, sc, "MCP response failure, aborting");
9510 : : rc = -1;
9511 : 0 : break;
9512 : : }
9513 : :
9514 [ # # ]: 0 : if (fw == FW_MSG_CODE_DRV_UNLOAD_COMMON) {
9515 : 0 : rc = bnx2x_prev_unload_common(sc);
9516 : 0 : break;
9517 : : }
9518 : :
9519 : : /* non-common reply from MCP might require looping */
9520 : 0 : rc = bnx2x_prev_unload_uncommon(sc);
9521 [ # # ]: 0 : if (rc != BNX2X_PREV_WAIT_NEEDED) {
9522 : : break;
9523 : : }
9524 : :
9525 : 0 : DELAY(20000);
9526 [ # # ]: 0 : } while (--time_counter);
9527 : :
9528 [ # # ]: 0 : if (!time_counter || rc) {
9529 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to unload previous driver!");
9530 : : rc = -1;
9531 : : }
9532 : :
9533 : 0 : return rc;
9534 : : }
9535 : :
9536 : : static void
9537 : 0 : bnx2x_dcbx_set_state(struct bnx2x_softc *sc, uint8_t dcb_on, uint32_t dcbx_enabled)
9538 : : {
9539 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
9540 : 0 : sc->dcb_state = dcb_on;
9541 : 0 : sc->dcbx_enabled = dcbx_enabled;
9542 : : } else {
9543 : 0 : sc->dcb_state = FALSE;
9544 : 0 : sc->dcbx_enabled = BNX2X_DCBX_ENABLED_INVALID;
9545 : : }
9546 [ # # # # : 0 : PMD_DRV_LOG(DEBUG, sc,
# # # # ]
9547 : : "DCB state [%s:%s]",
9548 : : dcb_on ? "ON" : "OFF",
9549 : : (dcbx_enabled == BNX2X_DCBX_ENABLED_OFF) ? "user-mode" :
9550 : : (dcbx_enabled ==
9551 : : BNX2X_DCBX_ENABLED_ON_NEG_OFF) ? "on-chip static"
9552 : : : (dcbx_enabled ==
9553 : : BNX2X_DCBX_ENABLED_ON_NEG_ON) ?
9554 : : "on-chip with negotiation" : "invalid");
9555 : 0 : }
9556 : :
9557 : : static int bnx2x_set_qm_cid_count(struct bnx2x_softc *sc)
9558 : : {
9559 : 0 : int cid_count = BNX2X_L2_MAX_CID(sc);
9560 : :
9561 : : if (CNIC_SUPPORT(sc)) {
9562 : : cid_count += CNIC_CID_MAX;
9563 : : }
9564 : :
9565 : 0 : return roundup(cid_count, QM_CID_ROUND);
9566 : : }
9567 : :
9568 : 0 : static void bnx2x_init_multi_cos(struct bnx2x_softc *sc)
9569 : : {
9570 : : int pri, cos;
9571 : :
9572 : : uint32_t pri_map = 0;
9573 : :
9574 [ # # ]: 0 : for (pri = 0; pri < BNX2X_MAX_PRIORITY; pri++) {
9575 : : cos = ((pri_map & (0xf << (pri * 4))) >> (pri * 4));
9576 [ # # ]: 0 : if (cos < sc->max_cos) {
9577 : 0 : sc->prio_to_cos[pri] = cos;
9578 : : } else {
9579 : 0 : PMD_DRV_LOG(WARNING, sc,
9580 : : "Invalid COS %d for priority %d "
9581 : : "(max COS is %d), setting to 0", cos, pri,
9582 : : (sc->max_cos - 1));
9583 : 0 : sc->prio_to_cos[pri] = 0;
9584 : : }
9585 : : }
9586 : 0 : }
9587 : :
9588 : : static uint8_t bnx2x_pci_capabilities[] = {
9589 : : RTE_PCI_CAP_ID_EXP,
9590 : : RTE_PCI_CAP_ID_PM,
9591 : : RTE_PCI_CAP_ID_MSI,
9592 : : RTE_PCI_CAP_ID_MSIX,
9593 : : };
9594 : :
9595 : 0 : static int bnx2x_pci_get_caps(struct bnx2x_softc *sc)
9596 : : {
9597 : : struct bnx2x_pci_cap *cap;
9598 : : unsigned int i;
9599 : :
9600 : 0 : cap = sc->pci_caps = rte_zmalloc("caps", sizeof(struct bnx2x_pci_cap),
9601 : : RTE_CACHE_LINE_SIZE);
9602 [ # # ]: 0 : if (!cap) {
9603 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to allocate memory");
9604 : 0 : return -ENOMEM;
9605 : : }
9606 : :
9607 [ # # ]: 0 : if (!rte_pci_has_capability_list(sc->pci_dev)) {
9608 : 0 : PMD_DRV_LOG(NOTICE, sc, "PCIe capability reading failed");
9609 : 0 : return -1;
9610 : : }
9611 : :
9612 [ # # ]: 0 : for (i = 0; i < RTE_DIM(bnx2x_pci_capabilities); i++) {
9613 : 0 : off_t pos = rte_pci_find_capability(sc->pci_dev,
9614 : 0 : bnx2x_pci_capabilities[i]);
9615 : :
9616 [ # # ]: 0 : if (pos <= 0)
9617 : 0 : continue;
9618 : :
9619 : 0 : cap->id = bnx2x_pci_capabilities[i];
9620 : 0 : cap->type = BNX2X_PCI_CAP;
9621 : 0 : cap->addr = pos;
9622 : 0 : cap->next = rte_zmalloc("pci_cap",
9623 : : sizeof(struct bnx2x_pci_cap),
9624 : : RTE_CACHE_LINE_SIZE);
9625 [ # # ]: 0 : if (!cap->next) {
9626 : 0 : PMD_DRV_LOG(NOTICE, sc, "Failed to allocate memory");
9627 : 0 : return -ENOMEM;
9628 : : }
9629 : : cap = cap->next;
9630 : : }
9631 : :
9632 : : return 0;
9633 : : }
9634 : :
9635 : : static void bnx2x_init_rte(struct bnx2x_softc *sc)
9636 : : {
9637 [ # # ]: 0 : if (IS_VF(sc)) {
9638 : 0 : sc->max_tx_queues = min(BNX2X_VF_MAX_QUEUES_PER_VF,
9639 : : sc->igu_sb_cnt);
9640 : 0 : sc->max_rx_queues = min(BNX2X_VF_MAX_QUEUES_PER_VF,
9641 : : sc->igu_sb_cnt);
9642 : : } else {
9643 : 0 : sc->max_rx_queues = BNX2X_MAX_RSS_COUNT(sc);
9644 : 0 : sc->max_tx_queues = sc->max_rx_queues;
9645 : : }
9646 : : }
9647 : :
9648 : : #define FW_HEADER_LEN 104
9649 : : #define FW_NAME_57711 "/lib/firmware/bnx2x/bnx2x-e1h-7.13.11.0.fw"
9650 : : #define FW_NAME_57810 "/lib/firmware/bnx2x/bnx2x-e2-7.13.11.0.fw"
9651 : :
9652 : 0 : void bnx2x_load_firmware(struct bnx2x_softc *sc)
9653 : : {
9654 : : const char *fwname;
9655 : : void *buf;
9656 : : size_t bufsz;
9657 : :
9658 : 0 : fwname = sc->devinfo.device_id == CHIP_NUM_57711
9659 [ # # ]: 0 : ? FW_NAME_57711 : FW_NAME_57810;
9660 [ # # ]: 0 : if (rte_firmware_read(fwname, &buf, &bufsz) != 0) {
9661 : 0 : PMD_DRV_LOG(NOTICE, sc, "Can't open firmware file");
9662 : 0 : return;
9663 : : }
9664 : :
9665 : 0 : sc->firmware = rte_zmalloc("bnx2x_fw", bufsz, RTE_CACHE_LINE_SIZE);
9666 [ # # ]: 0 : if (!sc->firmware) {
9667 : 0 : PMD_DRV_LOG(NOTICE, sc, "Can't allocate memory for firmware");
9668 : 0 : goto out;
9669 : : }
9670 : :
9671 : 0 : sc->fw_len = bufsz;
9672 [ # # ]: 0 : if (sc->fw_len < FW_HEADER_LEN) {
9673 : 0 : PMD_DRV_LOG(NOTICE, sc,
9674 : : "Invalid fw size: %" PRIu64, sc->fw_len);
9675 : 0 : goto out;
9676 : : }
9677 : :
9678 : 0 : memcpy(sc->firmware, buf, sc->fw_len);
9679 : 0 : PMD_DRV_LOG(DEBUG, sc, "fw_len = %" PRIu64, sc->fw_len);
9680 : 0 : out:
9681 : 0 : free(buf);
9682 : : }
9683 : :
9684 : : static void
9685 : 0 : bnx2x_data_to_init_ops(uint8_t * data, struct raw_op *dst, uint32_t len)
9686 : : {
9687 : : uint32_t *src = (uint32_t *) data;
9688 : : uint32_t i, j, tmp;
9689 : :
9690 [ # # ]: 0 : for (i = 0, j = 0; i < len / 8; ++i, j += 2) {
9691 [ # # ]: 0 : tmp = rte_be_to_cpu_32(src[j]);
9692 : 0 : dst[i].op = (tmp >> 24) & 0xFF;
9693 : 0 : dst[i].offset = tmp & 0xFFFFFF;
9694 [ # # ]: 0 : dst[i].raw_data = rte_be_to_cpu_32(src[j + 1]);
9695 : : }
9696 : 0 : }
9697 : :
9698 : : static void
9699 : : bnx2x_data_to_init_offsets(uint8_t * data, uint16_t * dst, uint32_t len)
9700 : : {
9701 : : uint16_t *src = (uint16_t *) data;
9702 : : uint32_t i;
9703 : :
9704 [ # # ]: 0 : for (i = 0; i < len / 2; ++i)
9705 [ # # ]: 0 : dst[i] = rte_be_to_cpu_16(src[i]);
9706 : : }
9707 : :
9708 : 0 : static void bnx2x_data_to_init_data(uint8_t * data, uint32_t * dst, uint32_t len)
9709 : : {
9710 : : uint32_t *src = (uint32_t *) data;
9711 : : uint32_t i;
9712 : :
9713 [ # # ]: 0 : for (i = 0; i < len / 4; ++i)
9714 [ # # ]: 0 : dst[i] = rte_be_to_cpu_32(src[i]);
9715 : 0 : }
9716 : :
9717 : 0 : static void bnx2x_data_to_iro_array(uint8_t * data, struct iro *dst, uint32_t len)
9718 : : {
9719 : : uint32_t *src = (uint32_t *) data;
9720 : : uint32_t i, j, tmp;
9721 : :
9722 [ # # ]: 0 : for (i = 0, j = 0; i < len / sizeof(struct iro); ++i, ++j) {
9723 : 0 : dst[i].base = rte_be_to_cpu_32(src[j++]);
9724 [ # # ]: 0 : tmp = rte_be_to_cpu_32(src[j]);
9725 : 0 : dst[i].m1 = (tmp >> 16) & 0xFFFF;
9726 : 0 : dst[i].m2 = tmp & 0xFFFF;
9727 : 0 : ++j;
9728 [ # # ]: 0 : tmp = rte_be_to_cpu_32(src[j]);
9729 : 0 : dst[i].m3 = (tmp >> 16) & 0xFFFF;
9730 : 0 : dst[i].size = tmp & 0xFFFF;
9731 : : }
9732 : 0 : }
9733 : :
9734 : : /*
9735 : : * Device attach function.
9736 : : *
9737 : : * Allocates device resources, performs secondary chip identification, and
9738 : : * initializes driver instance variables. This function is called from driver
9739 : : * load after a successful probe.
9740 : : *
9741 : : * Returns:
9742 : : * 0 = Success, >0 = Failure
9743 : : */
9744 : 0 : int bnx2x_attach(struct bnx2x_softc *sc)
9745 : : {
9746 : : int rc;
9747 : :
9748 : 0 : PMD_DRV_LOG(DEBUG, sc, "Starting attach...");
9749 : :
9750 : 0 : rc = bnx2x_pci_get_caps(sc);
9751 [ # # ]: 0 : if (rc) {
9752 : 0 : PMD_DRV_LOG(NOTICE, sc, "PCIe caps reading was failed");
9753 : 0 : return rc;
9754 : : }
9755 : :
9756 : 0 : sc->state = BNX2X_STATE_CLOSED;
9757 : :
9758 : 0 : pci_write_long(sc, PCICFG_GRC_ADDRESS, PCICFG_VENDOR_ID_OFFSET);
9759 : :
9760 [ # # ]: 0 : sc->igu_base_addr = IS_VF(sc) ? PXP_VF_ADDR_IGU_START : BAR_IGU_INTMEM;
9761 : :
9762 : : /* get PCI capabilities */
9763 : 0 : bnx2x_probe_pci_caps(sc);
9764 : :
9765 [ # # ]: 0 : if (sc->devinfo.pcie_msix_cap_reg != 0) {
9766 : : uint32_t val;
9767 : 0 : pci_read(sc,
9768 : 0 : (sc->devinfo.pcie_msix_cap_reg + RTE_PCI_MSIX_FLAGS), &val,
9769 : : 2);
9770 : 0 : sc->igu_sb_cnt = (val & RTE_PCI_MSIX_FLAGS_QSIZE) + 1;
9771 : : } else {
9772 : 0 : sc->igu_sb_cnt = 1;
9773 : : }
9774 : :
9775 : : /* Init RTE stuff */
9776 : : bnx2x_init_rte(sc);
9777 : :
9778 [ # # ]: 0 : if (IS_PF(sc)) {
9779 : : /* Enable internal target-read (in case we are probed after PF
9780 : : * FLR). Must be done prior to any BAR read access. Only for
9781 : : * 57712 and up
9782 : : */
9783 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
9784 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ,
9785 : : 1);
9786 : 0 : DELAY(200000);
9787 : : }
9788 : :
9789 : : /* get device info and set params */
9790 [ # # ]: 0 : if (bnx2x_get_device_info(sc) != 0) {
9791 : 0 : PMD_DRV_LOG(NOTICE, sc, "getting device info");
9792 : 0 : return -ENXIO;
9793 : : }
9794 : :
9795 : : /* get phy settings from shmem and 'and' against admin settings */
9796 : 0 : bnx2x_get_phy_info(sc);
9797 : : } else {
9798 : : /* Left mac of VF unfilled, PF should set it for VF */
9799 : 0 : memset(sc->link_params.mac_addr, 0, RTE_ETHER_ADDR_LEN);
9800 : : }
9801 : :
9802 : 0 : sc->wol = 0;
9803 : :
9804 : : /* set the default MTU (changed via ifconfig) */
9805 : 0 : sc->mtu = RTE_ETHER_MTU;
9806 : :
9807 : 0 : bnx2x_set_modes_bitmap(sc);
9808 : :
9809 : : /* need to reset chip if UNDI was active */
9810 [ # # ]: 0 : if (IS_PF(sc) && !BNX2X_NOMCP(sc)) {
9811 : : /* init fw_seq */
9812 : 0 : sc->fw_seq =
9813 [ # # # # ]: 0 : (SHMEM_RD(sc, func_mb[SC_FW_MB_IDX(sc)].drv_mb_header) &
9814 : : DRV_MSG_SEQ_NUMBER_MASK);
9815 : 0 : PMD_DRV_LOG(DEBUG, sc, "prev unload fw_seq 0x%04x",
9816 : : sc->fw_seq);
9817 : 0 : bnx2x_prev_unload(sc);
9818 : : }
9819 : :
9820 : 0 : bnx2x_dcbx_set_state(sc, FALSE, BNX2X_DCBX_ENABLED_OFF);
9821 : :
9822 : : /* calculate qm_cid_count */
9823 : 0 : sc->qm_cid_count = bnx2x_set_qm_cid_count(sc);
9824 : :
9825 : 0 : sc->max_cos = 1;
9826 : 0 : bnx2x_init_multi_cos(sc);
9827 : :
9828 : 0 : return 0;
9829 : : }
9830 : :
9831 : : static void
9832 : : bnx2x_igu_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id, uint8_t segment,
9833 : : uint16_t index, uint8_t op, uint8_t update)
9834 : : {
9835 : 0 : uint32_t igu_addr = sc->igu_base_addr;
9836 : 0 : igu_addr += (IGU_CMD_INT_ACK_BASE + igu_sb_id) * 8;
9837 : : bnx2x_igu_ack_sb_gen(sc, segment, index, op, update, igu_addr);
9838 : 0 : }
9839 : :
9840 : : static void
9841 : 0 : bnx2x_ack_sb(struct bnx2x_softc *sc, uint8_t igu_sb_id, uint8_t storm,
9842 : : uint16_t index, uint8_t op, uint8_t update)
9843 : : {
9844 [ # # ]: 0 : if (unlikely(sc->devinfo.int_block == INT_BLOCK_HC))
9845 : 0 : bnx2x_hc_ack_sb(sc, igu_sb_id, storm, index, op, update);
9846 : : else {
9847 : : uint8_t segment;
9848 [ # # # # ]: 0 : if (CHIP_INT_MODE_IS_BC(sc)) {
9849 : : segment = storm;
9850 [ # # ]: 0 : } else if (igu_sb_id != sc->igu_dsb_id) {
9851 : : segment = IGU_SEG_ACCESS_DEF;
9852 [ # # ]: 0 : } else if (storm == ATTENTION_ID) {
9853 : : segment = IGU_SEG_ACCESS_ATTN;
9854 : : } else {
9855 : : segment = IGU_SEG_ACCESS_DEF;
9856 : : }
9857 : 0 : bnx2x_igu_ack_sb(sc, igu_sb_id, segment, index, op, update);
9858 : : }
9859 : 0 : }
9860 : :
9861 : : static void
9862 : 0 : bnx2x_igu_clear_sb_gen(struct bnx2x_softc *sc, uint8_t func, uint8_t idu_sb_id,
9863 : : uint8_t is_pf)
9864 : : {
9865 : : uint32_t data, ctl, cnt = 100;
9866 : : uint32_t igu_addr_data = IGU_REG_COMMAND_REG_32LSB_DATA;
9867 : : uint32_t igu_addr_ctl = IGU_REG_COMMAND_REG_CTRL;
9868 : 0 : uint32_t igu_addr_ack = IGU_REG_CSTORM_TYPE_0_SB_CLEANUP +
9869 : 0 : (idu_sb_id / 32) * 4;
9870 : 0 : uint32_t sb_bit = 1 << (idu_sb_id % 32);
9871 : 0 : uint32_t func_encode = func |
9872 [ # # ]: 0 : (is_pf ? 1 : 0) << IGU_FID_ENCODE_IS_PF_SHIFT;
9873 : 0 : uint32_t addr_encode = IGU_CMD_E2_PROD_UPD_BASE + idu_sb_id;
9874 : :
9875 : : /* Not supported in BC mode */
9876 [ # # # # ]: 0 : if (CHIP_INT_MODE_IS_BC(sc)) {
9877 : : return;
9878 : : }
9879 : :
9880 : : data = ((IGU_USE_REGISTER_cstorm_type_0_sb_cleanup <<
9881 : : IGU_REGULAR_CLEANUP_TYPE_SHIFT) |
9882 : : IGU_REGULAR_CLEANUP_SET | IGU_REGULAR_BCLEANUP);
9883 : :
9884 : 0 : ctl = ((addr_encode << IGU_CTRL_REG_ADDRESS_SHIFT) |
9885 : 0 : (func_encode << IGU_CTRL_REG_FID_SHIFT) |
9886 : : (IGU_CTRL_CMD_TYPE_WR << IGU_CTRL_REG_TYPE_SHIFT));
9887 : :
9888 : : REG_WR(sc, igu_addr_data, data);
9889 : :
9890 : : mb();
9891 : :
9892 : 0 : PMD_DRV_LOG(DEBUG, sc, "write 0x%08x to IGU(via GRC) addr 0x%x",
9893 : : ctl, igu_addr_ctl);
9894 : : REG_WR(sc, igu_addr_ctl, ctl);
9895 : :
9896 : : mb();
9897 : :
9898 : : /* wait for clean up to finish */
9899 [ # # # # ]: 0 : while (!(REG_RD(sc, igu_addr_ack) & sb_bit) && --cnt) {
9900 : 0 : DELAY(20000);
9901 : : }
9902 : :
9903 [ # # ]: 0 : if (!(REG_RD(sc, igu_addr_ack) & sb_bit)) {
9904 : 0 : PMD_DRV_LOG(DEBUG, sc,
9905 : : "Unable to finish IGU cleanup: "
9906 : : "idu_sb_id %d offset %d bit %d (cnt %d)",
9907 : : idu_sb_id, idu_sb_id / 32, idu_sb_id % 32, cnt);
9908 : : }
9909 : : }
9910 : :
9911 : : static void bnx2x_igu_clear_sb(struct bnx2x_softc *sc, uint8_t idu_sb_id)
9912 : : {
9913 : 0 : bnx2x_igu_clear_sb_gen(sc, SC_FUNC(sc), idu_sb_id, TRUE /*PF*/);
9914 : : }
9915 : :
9916 : : /*******************/
9917 : : /* ECORE CALLBACKS */
9918 : : /*******************/
9919 : :
9920 : 0 : static void bnx2x_reset_common(struct bnx2x_softc *sc)
9921 : : {
9922 : : uint32_t val = 0x1400;
9923 : :
9924 : 0 : PMD_INIT_FUNC_TRACE(sc);
9925 : :
9926 : : /* reset_common */
9927 : : REG_WR(sc, (GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR),
9928 : : 0xd3ffff7f);
9929 : :
9930 [ # # ]: 0 : if (CHIP_IS_E3(sc)) {
9931 : : val |= MISC_REGISTERS_RESET_REG_2_MSTAT0;
9932 : : val |= MISC_REGISTERS_RESET_REG_2_MSTAT1;
9933 : : }
9934 : :
9935 : : REG_WR(sc, (GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR), val);
9936 : 0 : }
9937 : :
9938 : 0 : static void bnx2x_common_init_phy(struct bnx2x_softc *sc)
9939 : : {
9940 : : uint32_t shmem_base[2];
9941 : : uint32_t shmem2_base[2];
9942 : :
9943 : : /* Avoid common init in case MFW supports LFA */
9944 : 0 : if (SHMEM2_RD(sc, size) >
9945 [ # # ]: 0 : (uint32_t) offsetof(struct shmem2_region,
9946 : : lfa_host_addr[SC_PORT(sc)])) {
9947 : 0 : return;
9948 : : }
9949 : :
9950 : 0 : shmem_base[0] = sc->devinfo.shmem_base;
9951 : 0 : shmem2_base[0] = sc->devinfo.shmem2_base;
9952 : :
9953 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
9954 : 0 : shmem_base[1] = SHMEM2_RD(sc, other_shmem_base_addr);
9955 : 0 : shmem2_base[1] = SHMEM2_RD(sc, other_shmem2_base_addr);
9956 : : }
9957 : :
9958 : 0 : bnx2x_acquire_phy_lock(sc);
9959 : 0 : elink_common_init_phy(sc, shmem_base, shmem2_base,
9960 : : sc->devinfo.chip_id, 0);
9961 : : bnx2x_release_phy_lock(sc);
9962 : : }
9963 : :
9964 : : static void bnx2x_pf_disable(struct bnx2x_softc *sc)
9965 : : {
9966 : : uint32_t val = REG_RD(sc, IGU_REG_PF_CONFIGURATION);
9967 : :
9968 : 0 : val &= ~IGU_PF_CONF_FUNC_EN;
9969 : :
9970 : : REG_WR(sc, IGU_REG_PF_CONFIGURATION, val);
9971 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 0);
9972 : : REG_WR(sc, CFC_REG_WEAK_ENABLE_PF, 0);
9973 : 0 : }
9974 : :
9975 : 0 : static void bnx2x_init_pxp(struct bnx2x_softc *sc)
9976 : : {
9977 : : uint16_t devctl;
9978 : : int r_order, w_order;
9979 : :
9980 : 0 : devctl = bnx2x_pcie_capability_read(sc, RTE_PCI_EXP_DEVCTL);
9981 : :
9982 : 0 : w_order = ((devctl & RTE_PCI_EXP_DEVCTL_PAYLOAD) >> 5);
9983 : 0 : r_order = ((devctl & RTE_PCI_EXP_DEVCTL_READRQ) >> 12);
9984 : :
9985 : 0 : ecore_init_pxp_arb(sc, r_order, w_order);
9986 : 0 : }
9987 : :
9988 : : static uint32_t bnx2x_get_pretend_reg(struct bnx2x_softc *sc)
9989 : : {
9990 : : uint32_t base = PXP2_REG_PGL_PRETEND_FUNC_F0;
9991 : : uint32_t stride = (PXP2_REG_PGL_PRETEND_FUNC_F1 - base);
9992 : 0 : return base + (SC_ABS_FUNC(sc)) * stride;
9993 : : }
9994 : :
9995 : : /*
9996 : : * Called only on E1H or E2.
9997 : : * When pretending to be PF, the pretend value is the function number 0..7.
9998 : : * When pretending to be VF, the pretend val is the PF-num:VF-valid:ABS-VFID
9999 : : * combination.
10000 : : */
10001 : : static int bnx2x_pretend_func(struct bnx2x_softc *sc, uint16_t pretend_func_val)
10002 : : {
10003 : : uint32_t pretend_reg;
10004 : :
10005 [ # # # # ]: 0 : if (CHIP_IS_E1H(sc) && (pretend_func_val > E1H_FUNC_MAX))
10006 : : return -1;
10007 : :
10008 : : /* get my own pretend register */
10009 : : pretend_reg = bnx2x_get_pretend_reg(sc);
10010 : 0 : REG_WR(sc, pretend_reg, pretend_func_val);
10011 : : REG_RD(sc, pretend_reg);
10012 : 0 : return 0;
10013 : : }
10014 : :
10015 : 0 : static void bnx2x_setup_fan_failure_detection(struct bnx2x_softc *sc)
10016 : : {
10017 : : int is_required;
10018 : : uint32_t val;
10019 : : int port;
10020 : :
10021 : : is_required = 0;
10022 : 0 : val = (SHMEM_RD(sc, dev_info.shared_hw_config.config2) &
10023 : : SHARED_HW_CFG_FAN_FAILURE_MASK);
10024 : :
10025 [ # # ]: 0 : if (val == SHARED_HW_CFG_FAN_FAILURE_ENABLED) {
10026 : : is_required = 1;
10027 : : }
10028 : : /*
10029 : : * The fan failure mechanism is usually related to the PHY type since
10030 : : * the power consumption of the board is affected by the PHY. Currently,
10031 : : * fan is required for most designs with SFX7101, BNX2X8727 and BNX2X8481.
10032 : : */
10033 [ # # ]: 0 : else if (val == SHARED_HW_CFG_FAN_FAILURE_PHY_TYPE) {
10034 [ # # ]: 0 : for (port = PORT_0; port < PORT_MAX; port++) {
10035 : 0 : is_required |= elink_fan_failure_det_req(sc,
10036 : : sc->
10037 : : devinfo.shmem_base,
10038 : : sc->
10039 : : devinfo.shmem2_base,
10040 : : port);
10041 : : }
10042 : : }
10043 : :
10044 [ # # ]: 0 : if (is_required == 0) {
10045 : 0 : return;
10046 : : }
10047 : :
10048 : : /* Fan failure is indicated by SPIO 5 */
10049 : 0 : bnx2x_set_spio(sc, MISC_SPIO_SPIO5, MISC_SPIO_INPUT_HI_Z);
10050 : :
10051 : : /* set to active low mode */
10052 : : val = REG_RD(sc, MISC_REG_SPIO_INT);
10053 : 0 : val |= (MISC_SPIO_SPIO5 << MISC_SPIO_INT_OLD_SET_POS);
10054 : : REG_WR(sc, MISC_REG_SPIO_INT, val);
10055 : :
10056 : : /* enable interrupt to signal the IGU */
10057 : : val = REG_RD(sc, MISC_REG_SPIO_EVENT_EN);
10058 : 0 : val |= MISC_SPIO_SPIO5;
10059 : : REG_WR(sc, MISC_REG_SPIO_EVENT_EN, val);
10060 : : }
10061 : :
10062 : 0 : static void bnx2x_enable_blocks_attention(struct bnx2x_softc *sc)
10063 : : {
10064 : : uint32_t val;
10065 : :
10066 : : REG_WR(sc, PXP_REG_PXP_INT_MASK_0, 0);
10067 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10068 : : REG_WR(sc, PXP_REG_PXP_INT_MASK_1, 0x40);
10069 : : } else {
10070 : : REG_WR(sc, PXP_REG_PXP_INT_MASK_1, 0);
10071 : : }
10072 : : REG_WR(sc, DORQ_REG_DORQ_INT_MASK, 0);
10073 : : REG_WR(sc, CFC_REG_CFC_INT_MASK, 0);
10074 : : /*
10075 : : * mask read length error interrupts in brb for parser
10076 : : * (parsing unit and 'checksum and crc' unit)
10077 : : * these errors are legal (PU reads fixed length and CAC can cause
10078 : : * read length error on truncated packets)
10079 : : */
10080 : : REG_WR(sc, BRB1_REG_BRB1_INT_MASK, 0xFC00);
10081 : : REG_WR(sc, QM_REG_QM_INT_MASK, 0);
10082 : : REG_WR(sc, TM_REG_TM_INT_MASK, 0);
10083 : : REG_WR(sc, XSDM_REG_XSDM_INT_MASK_0, 0);
10084 : : REG_WR(sc, XSDM_REG_XSDM_INT_MASK_1, 0);
10085 : : REG_WR(sc, XCM_REG_XCM_INT_MASK, 0);
10086 : : /* REG_WR(sc, XSEM_REG_XSEM_INT_MASK_0, 0); */
10087 : : /* REG_WR(sc, XSEM_REG_XSEM_INT_MASK_1, 0); */
10088 : : REG_WR(sc, USDM_REG_USDM_INT_MASK_0, 0);
10089 : : REG_WR(sc, USDM_REG_USDM_INT_MASK_1, 0);
10090 : : REG_WR(sc, UCM_REG_UCM_INT_MASK, 0);
10091 : : /* REG_WR(sc, USEM_REG_USEM_INT_MASK_0, 0); */
10092 : : /* REG_WR(sc, USEM_REG_USEM_INT_MASK_1, 0); */
10093 : : REG_WR(sc, GRCBASE_UPB + PB_REG_PB_INT_MASK, 0);
10094 : : REG_WR(sc, CSDM_REG_CSDM_INT_MASK_0, 0);
10095 : : REG_WR(sc, CSDM_REG_CSDM_INT_MASK_1, 0);
10096 : : REG_WR(sc, CCM_REG_CCM_INT_MASK, 0);
10097 : : /* REG_WR(sc, CSEM_REG_CSEM_INT_MASK_0, 0); */
10098 : : /* REG_WR(sc, CSEM_REG_CSEM_INT_MASK_1, 0); */
10099 : :
10100 : : val = (PXP2_PXP2_INT_MASK_0_REG_PGL_CPL_AFT |
10101 : : PXP2_PXP2_INT_MASK_0_REG_PGL_CPL_OF |
10102 : : PXP2_PXP2_INT_MASK_0_REG_PGL_PCIE_ATTN);
10103 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10104 : : val |= (PXP2_PXP2_INT_MASK_0_REG_PGL_READ_BLOCKED |
10105 : : PXP2_PXP2_INT_MASK_0_REG_PGL_WRITE_BLOCKED);
10106 : : }
10107 : : REG_WR(sc, PXP2_REG_PXP2_INT_MASK_0, val);
10108 : :
10109 : : REG_WR(sc, TSDM_REG_TSDM_INT_MASK_0, 0);
10110 : : REG_WR(sc, TSDM_REG_TSDM_INT_MASK_1, 0);
10111 : : REG_WR(sc, TCM_REG_TCM_INT_MASK, 0);
10112 : : /* REG_WR(sc, TSEM_REG_TSEM_INT_MASK_0, 0); */
10113 : :
10114 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10115 : : /* enable VFC attentions: bits 11 and 12, bits 31:13 reserved */
10116 : : REG_WR(sc, TSEM_REG_TSEM_INT_MASK_1, 0x07ff);
10117 : : }
10118 : :
10119 : : REG_WR(sc, CDU_REG_CDU_INT_MASK, 0);
10120 : : REG_WR(sc, DMAE_REG_DMAE_INT_MASK, 0);
10121 : : /* REG_WR(sc, MISC_REG_MISC_INT_MASK, 0); */
10122 : : REG_WR(sc, PBF_REG_PBF_INT_MASK, 0x18); /* bit 3,4 masked */
10123 : 0 : }
10124 : :
10125 : : /**
10126 : : * bnx2x_init_hw_common - initialize the HW at the COMMON phase.
10127 : : *
10128 : : * @sc: driver handle
10129 : : */
10130 : 0 : static int bnx2x_init_hw_common(struct bnx2x_softc *sc)
10131 : : {
10132 : : uint8_t abs_func_id;
10133 : : uint32_t val;
10134 : :
10135 : 0 : PMD_DRV_LOG(DEBUG, sc,
10136 : : "starting common init for func %d", SC_ABS_FUNC(sc));
10137 : :
10138 : : /*
10139 : : * take the RESET lock to protect undi_unload flow from accessing
10140 : : * registers while we are resetting the chip
10141 : : */
10142 : 0 : bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_RESET);
10143 : :
10144 : 0 : bnx2x_reset_common(sc);
10145 : :
10146 : : REG_WR(sc, (GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET), 0xffffffff);
10147 : :
10148 : : val = 0xfffc;
10149 [ # # ]: 0 : if (CHIP_IS_E3(sc)) {
10150 : : val |= MISC_REGISTERS_RESET_REG_2_MSTAT0;
10151 : : val |= MISC_REGISTERS_RESET_REG_2_MSTAT1;
10152 : : }
10153 : :
10154 : : REG_WR(sc, (GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET), val);
10155 : :
10156 : 0 : bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_RESET);
10157 : :
10158 : 0 : ecore_init_block(sc, BLOCK_MISC, PHASE_COMMON);
10159 : :
10160 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10161 : : /*
10162 : : * 4-port mode or 2-port mode we need to turn off master-enable for
10163 : : * everyone. After that we turn it back on for self. So, we disregard
10164 : : * multi-function, and always disable all functions on the given path,
10165 : : * this means 0,2,4,6 for path 0 and 1,3,5,7 for path 1
10166 : : */
10167 : 0 : for (abs_func_id = SC_PATH(sc);
10168 [ # # ]: 0 : abs_func_id < (E2_FUNC_MAX * 2); abs_func_id += 2) {
10169 [ # # ]: 0 : if (abs_func_id == SC_ABS_FUNC(sc)) {
10170 : : REG_WR(sc,
10171 : : PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER,
10172 : : 1);
10173 : 0 : continue;
10174 : : }
10175 : :
10176 : : bnx2x_pretend_func(sc, abs_func_id);
10177 : :
10178 : : /* clear pf enable */
10179 : : bnx2x_pf_disable(sc);
10180 : :
10181 [ # # ]: 0 : bnx2x_pretend_func(sc, SC_ABS_FUNC(sc));
10182 : : }
10183 : : }
10184 : :
10185 : 0 : ecore_init_block(sc, BLOCK_PXP, PHASE_COMMON);
10186 : :
10187 : 0 : ecore_init_block(sc, BLOCK_PXP2, PHASE_COMMON);
10188 : 0 : bnx2x_init_pxp(sc);
10189 : :
10190 : : #ifdef __BIG_ENDIAN
10191 : : REG_WR(sc, PXP2_REG_RQ_QM_ENDIAN_M, 1);
10192 : : REG_WR(sc, PXP2_REG_RQ_TM_ENDIAN_M, 1);
10193 : : REG_WR(sc, PXP2_REG_RQ_SRC_ENDIAN_M, 1);
10194 : : REG_WR(sc, PXP2_REG_RQ_CDU_ENDIAN_M, 1);
10195 : : REG_WR(sc, PXP2_REG_RQ_DBG_ENDIAN_M, 1);
10196 : : /* make sure this value is 0 */
10197 : : REG_WR(sc, PXP2_REG_RQ_HC_ENDIAN_M, 0);
10198 : :
10199 : : //REG_WR(sc, PXP2_REG_RD_PBF_SWAP_MODE, 1);
10200 : : REG_WR(sc, PXP2_REG_RD_QM_SWAP_MODE, 1);
10201 : : REG_WR(sc, PXP2_REG_RD_TM_SWAP_MODE, 1);
10202 : : REG_WR(sc, PXP2_REG_RD_SRC_SWAP_MODE, 1);
10203 : : REG_WR(sc, PXP2_REG_RD_CDURD_SWAP_MODE, 1);
10204 : : #endif
10205 : :
10206 : 0 : ecore_ilt_init_page_size(sc, INITOP_SET);
10207 : :
10208 [ # # # # : 0 : if (CHIP_REV_IS_FPGA(sc) && CHIP_IS_E1H(sc)) {
# # ]
10209 : : REG_WR(sc, PXP2_REG_PGL_TAGS_LIMIT, 0x1);
10210 : : }
10211 : :
10212 : : /* let the HW do it's magic... */
10213 : 0 : DELAY(100000);
10214 : :
10215 : : /* finish PXP init */
10216 : :
10217 : : val = REG_RD(sc, PXP2_REG_RQ_CFG_DONE);
10218 [ # # ]: 0 : if (val != 1) {
10219 : 0 : PMD_DRV_LOG(NOTICE, sc, "PXP2 CFG failed");
10220 : 0 : return -1;
10221 : : }
10222 : : val = REG_RD(sc, PXP2_REG_RD_INIT_DONE);
10223 [ # # ]: 0 : if (val != 1) {
10224 : 0 : PMD_DRV_LOG(NOTICE, sc, "PXP2 RD_INIT failed");
10225 : 0 : return -1;
10226 : : }
10227 : :
10228 : : /*
10229 : : * Timer bug workaround for E2 only. We need to set the entire ILT to have
10230 : : * entries with value "0" and valid bit on. This needs to be done by the
10231 : : * first PF that is loaded in a path (i.e. common phase)
10232 : : */
10233 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10234 : : /*
10235 : : * In E2 there is a bug in the timers block that can cause function 6 / 7
10236 : : * (i.e. vnic3) to start even if it is marked as "scan-off".
10237 : : * This occurs when a different function (func2,3) is being marked
10238 : : * as "scan-off". Real-life scenario for example: if a driver is being
10239 : : * load-unloaded while func6,7 are down. This will cause the timer to access
10240 : : * the ilt, translate to a logical address and send a request to read/write.
10241 : : * Since the ilt for the function that is down is not valid, this will cause
10242 : : * a translation error which is unrecoverable.
10243 : : * The Workaround is intended to make sure that when this happens nothing
10244 : : * fatal will occur. The workaround:
10245 : : * 1. First PF driver which loads on a path will:
10246 : : * a. After taking the chip out of reset, by using pretend,
10247 : : * it will write "0" to the following registers of
10248 : : * the other vnics.
10249 : : * REG_WR(pdev, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 0);
10250 : : * REG_WR(pdev, CFC_REG_WEAK_ENABLE_PF,0);
10251 : : * REG_WR(pdev, CFC_REG_STRONG_ENABLE_PF,0);
10252 : : * And for itself it will write '1' to
10253 : : * PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER to enable
10254 : : * dmae-operations (writing to pram for example.)
10255 : : * note: can be done for only function 6,7 but cleaner this
10256 : : * way.
10257 : : * b. Write zero+valid to the entire ILT.
10258 : : * c. Init the first_timers_ilt_entry, last_timers_ilt_entry of
10259 : : * VNIC3 (of that port). The range allocated will be the
10260 : : * entire ILT. This is needed to prevent ILT range error.
10261 : : * 2. Any PF driver load flow:
10262 : : * a. ILT update with the physical addresses of the allocated
10263 : : * logical pages.
10264 : : * b. Wait 20msec. - note that this timeout is needed to make
10265 : : * sure there are no requests in one of the PXP internal
10266 : : * queues with "old" ILT addresses.
10267 : : * c. PF enable in the PGLC.
10268 : : * d. Clear the was_error of the PF in the PGLC. (could have
10269 : : * occurred while driver was down)
10270 : : * e. PF enable in the CFC (WEAK + STRONG)
10271 : : * f. Timers scan enable
10272 : : * 3. PF driver unload flow:
10273 : : * a. Clear the Timers scan_en.
10274 : : * b. Polling for scan_on=0 for that PF.
10275 : : * c. Clear the PF enable bit in the PXP.
10276 : : * d. Clear the PF enable in the CFC (WEAK + STRONG)
10277 : : * e. Write zero+valid to all ILT entries (The valid bit must
10278 : : * stay set)
10279 : : * f. If this is VNIC 3 of a port then also init
10280 : : * first_timers_ilt_entry to zero and last_timers_ilt_entry
10281 : : * to the last entry in the ILT.
10282 : : *
10283 : : * Notes:
10284 : : * Currently the PF error in the PGLC is non recoverable.
10285 : : * In the future the there will be a recovery routine for this error.
10286 : : * Currently attention is masked.
10287 : : * Having an MCP lock on the load/unload process does not guarantee that
10288 : : * there is no Timer disable during Func6/7 enable. This is because the
10289 : : * Timers scan is currently being cleared by the MCP on FLR.
10290 : : * Step 2.d can be done only for PF6/7 and the driver can also check if
10291 : : * there is error before clearing it. But the flow above is simpler and
10292 : : * more general.
10293 : : * All ILT entries are written by zero+valid and not just PF6/7
10294 : : * ILT entries since in the future the ILT entries allocation for
10295 : : * PF-s might be dynamic.
10296 : : */
10297 : : struct ilt_client_info ilt_cli;
10298 : : struct ecore_ilt ilt;
10299 : :
10300 : : memset(&ilt_cli, 0, sizeof(struct ilt_client_info));
10301 : : memset(&ilt, 0, sizeof(struct ecore_ilt));
10302 : :
10303 : : /* initialize dummy TM client */
10304 : : ilt_cli.start = 0;
10305 : 0 : ilt_cli.end = ILT_NUM_PAGE_ENTRIES - 1;
10306 : 0 : ilt_cli.client_num = ILT_CLIENT_TM;
10307 : :
10308 : : /*
10309 : : * Step 1: set zeroes to all ilt page entries with valid bit on
10310 : : * Step 2: set the timers first/last ilt entry to point
10311 : : * to the entire range to prevent ILT range error for 3rd/4th
10312 : : * vnic (this code assumes existence of the vnic)
10313 : : *
10314 : : * both steps performed by call to ecore_ilt_client_init_op()
10315 : : * with dummy TM client
10316 : : *
10317 : : * we must use pretend since PXP2_REG_RQ_##blk##_FIRST_ILT
10318 : : * and his brother are split registers
10319 : : */
10320 : :
10321 : 0 : bnx2x_pretend_func(sc, (SC_PATH(sc) + 6));
10322 : 0 : ecore_ilt_client_init_op_ilt(sc, &ilt, &ilt_cli, INITOP_CLEAR);
10323 [ # # ]: 0 : bnx2x_pretend_func(sc, SC_ABS_FUNC(sc));
10324 : :
10325 : : REG_WR(sc, PXP2_REG_RQ_DRAM_ALIGN, BNX2X_PXP_DRAM_ALIGN);
10326 : : REG_WR(sc, PXP2_REG_RQ_DRAM_ALIGN_RD, BNX2X_PXP_DRAM_ALIGN);
10327 : : REG_WR(sc, PXP2_REG_RQ_DRAM_ALIGN_SEL, 1);
10328 : : }
10329 : :
10330 : : REG_WR(sc, PXP2_REG_RQ_DISABLE_INPUTS, 0);
10331 : : REG_WR(sc, PXP2_REG_RD_DISABLE_INPUTS, 0);
10332 : :
10333 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10334 : : int factor = 0;
10335 : :
10336 : 0 : ecore_init_block(sc, BLOCK_PGLUE_B, PHASE_COMMON);
10337 : 0 : ecore_init_block(sc, BLOCK_ATC, PHASE_COMMON);
10338 : :
10339 : : /* let the HW do it's magic... */
10340 : : do {
10341 : 0 : DELAY(200000);
10342 : : val = REG_RD(sc, ATC_REG_ATC_INIT_DONE);
10343 : : } while (factor-- && (val != 1));
10344 : :
10345 [ # # ]: 0 : if (val != 1) {
10346 : 0 : PMD_DRV_LOG(NOTICE, sc, "ATC_INIT failed");
10347 : 0 : return -1;
10348 : : }
10349 : : }
10350 : :
10351 : 0 : ecore_init_block(sc, BLOCK_DMAE, PHASE_COMMON);
10352 : :
10353 : : /* clean the DMAE memory */
10354 : 0 : sc->dmae_ready = 1;
10355 : 0 : ecore_init_fill(sc, TSEM_REG_PRAM, 0, 8, 1);
10356 : :
10357 : 0 : ecore_init_block(sc, BLOCK_TCM, PHASE_COMMON);
10358 : :
10359 : 0 : ecore_init_block(sc, BLOCK_UCM, PHASE_COMMON);
10360 : :
10361 : 0 : ecore_init_block(sc, BLOCK_CCM, PHASE_COMMON);
10362 : :
10363 : 0 : ecore_init_block(sc, BLOCK_XCM, PHASE_COMMON);
10364 : :
10365 : 0 : bnx2x_read_dmae(sc, XSEM_REG_PASSIVE_BUFFER, 3);
10366 : 0 : bnx2x_read_dmae(sc, CSEM_REG_PASSIVE_BUFFER, 3);
10367 : 0 : bnx2x_read_dmae(sc, TSEM_REG_PASSIVE_BUFFER, 3);
10368 : 0 : bnx2x_read_dmae(sc, USEM_REG_PASSIVE_BUFFER, 3);
10369 : :
10370 : 0 : ecore_init_block(sc, BLOCK_QM, PHASE_COMMON);
10371 : :
10372 : : /* QM queues pointers table */
10373 : 0 : ecore_qm_init_ptr_table(sc, sc->qm_cid_count, INITOP_SET);
10374 : :
10375 : : /* soft reset pulse */
10376 : : REG_WR(sc, QM_REG_SOFT_RESET, 1);
10377 : : REG_WR(sc, QM_REG_SOFT_RESET, 0);
10378 : :
10379 : : if (CNIC_SUPPORT(sc))
10380 : : ecore_init_block(sc, BLOCK_TM, PHASE_COMMON);
10381 : :
10382 : 0 : ecore_init_block(sc, BLOCK_DORQ, PHASE_COMMON);
10383 : :
10384 [ # # ]: 0 : if (!CHIP_REV_IS_SLOW(sc)) {
10385 : : /* enable hw interrupt from doorbell Q */
10386 : : REG_WR(sc, DORQ_REG_DORQ_INT_MASK, 0);
10387 : : }
10388 : :
10389 : 0 : ecore_init_block(sc, BLOCK_BRB1, PHASE_COMMON);
10390 : :
10391 : 0 : ecore_init_block(sc, BLOCK_PRS, PHASE_COMMON);
10392 : : REG_WR(sc, PRS_REG_A_PRSU_20, 0xf);
10393 : 0 : REG_WR(sc, PRS_REG_E1HOV_MODE, sc->devinfo.mf_info.path_has_ovlan);
10394 : :
10395 [ # # # # : 0 : if (!CHIP_IS_E1x(sc) && !CHIP_IS_E3B0(sc)) {
# # # # #
# # # #
# ]
10396 [ # # # # ]: 0 : if (IS_MF_AFEX(sc)) {
10397 : : /*
10398 : : * configure that AFEX and VLAN headers must be
10399 : : * received in AFEX mode
10400 : : */
10401 : : REG_WR(sc, PRS_REG_HDRS_AFTER_BASIC, 0xE);
10402 : : REG_WR(sc, PRS_REG_MUST_HAVE_HDRS, 0xA);
10403 : : REG_WR(sc, PRS_REG_HDRS_AFTER_TAG_0, 0x6);
10404 : : REG_WR(sc, PRS_REG_TAG_ETHERTYPE_0, 0x8926);
10405 : : REG_WR(sc, PRS_REG_TAG_LEN_0, 0x4);
10406 : : } else {
10407 : : /*
10408 : : * Bit-map indicating which L2 hdrs may appear
10409 : : * after the basic Ethernet header
10410 : : */
10411 [ # # ]: 0 : REG_WR(sc, PRS_REG_HDRS_AFTER_BASIC,
10412 : : sc->devinfo.mf_info.path_has_ovlan ? 7 : 6);
10413 : : }
10414 : : }
10415 : :
10416 : 0 : ecore_init_block(sc, BLOCK_TSDM, PHASE_COMMON);
10417 : 0 : ecore_init_block(sc, BLOCK_CSDM, PHASE_COMMON);
10418 : 0 : ecore_init_block(sc, BLOCK_USDM, PHASE_COMMON);
10419 : 0 : ecore_init_block(sc, BLOCK_XSDM, PHASE_COMMON);
10420 : :
10421 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10422 : : /* reset VFC memories */
10423 : : REG_WR(sc, TSEM_REG_FAST_MEMORY + VFC_REG_MEMORIES_RST,
10424 : : VFC_MEMORIES_RST_REG_CAM_RST |
10425 : : VFC_MEMORIES_RST_REG_RAM_RST);
10426 : : REG_WR(sc, XSEM_REG_FAST_MEMORY + VFC_REG_MEMORIES_RST,
10427 : : VFC_MEMORIES_RST_REG_CAM_RST |
10428 : : VFC_MEMORIES_RST_REG_RAM_RST);
10429 : :
10430 : 0 : DELAY(20000);
10431 : : }
10432 : :
10433 : 0 : ecore_init_block(sc, BLOCK_TSEM, PHASE_COMMON);
10434 : 0 : ecore_init_block(sc, BLOCK_USEM, PHASE_COMMON);
10435 : 0 : ecore_init_block(sc, BLOCK_CSEM, PHASE_COMMON);
10436 : 0 : ecore_init_block(sc, BLOCK_XSEM, PHASE_COMMON);
10437 : :
10438 : : /* sync semi rtc */
10439 : : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0x80000000);
10440 : : REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x80000000);
10441 : :
10442 : 0 : ecore_init_block(sc, BLOCK_UPB, PHASE_COMMON);
10443 : 0 : ecore_init_block(sc, BLOCK_XPB, PHASE_COMMON);
10444 : 0 : ecore_init_block(sc, BLOCK_PBF, PHASE_COMMON);
10445 : :
10446 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10447 [ # # # # ]: 0 : if (IS_MF_AFEX(sc)) {
10448 : : /*
10449 : : * configure that AFEX and VLAN headers must be
10450 : : * sent in AFEX mode
10451 : : */
10452 : : REG_WR(sc, PBF_REG_HDRS_AFTER_BASIC, 0xE);
10453 : : REG_WR(sc, PBF_REG_MUST_HAVE_HDRS, 0xA);
10454 : : REG_WR(sc, PBF_REG_HDRS_AFTER_TAG_0, 0x6);
10455 : : REG_WR(sc, PBF_REG_TAG_ETHERTYPE_0, 0x8926);
10456 : : REG_WR(sc, PBF_REG_TAG_LEN_0, 0x4);
10457 : : } else {
10458 [ # # ]: 0 : REG_WR(sc, PBF_REG_HDRS_AFTER_BASIC,
10459 : : sc->devinfo.mf_info.path_has_ovlan ? 7 : 6);
10460 : : }
10461 : : }
10462 : :
10463 : : REG_WR(sc, SRC_REG_SOFT_RST, 1);
10464 : :
10465 : 0 : ecore_init_block(sc, BLOCK_SRC, PHASE_COMMON);
10466 : :
10467 : : if (CNIC_SUPPORT(sc)) {
10468 : : REG_WR(sc, SRC_REG_KEYSEARCH_0, 0x63285672);
10469 : : REG_WR(sc, SRC_REG_KEYSEARCH_1, 0x24b8f2cc);
10470 : : REG_WR(sc, SRC_REG_KEYSEARCH_2, 0x223aef9b);
10471 : : REG_WR(sc, SRC_REG_KEYSEARCH_3, 0x26001e3a);
10472 : : REG_WR(sc, SRC_REG_KEYSEARCH_4, 0x7ae91116);
10473 : : REG_WR(sc, SRC_REG_KEYSEARCH_5, 0x5ce5230b);
10474 : : REG_WR(sc, SRC_REG_KEYSEARCH_6, 0x298d8adf);
10475 : : REG_WR(sc, SRC_REG_KEYSEARCH_7, 0x6eb0ff09);
10476 : : REG_WR(sc, SRC_REG_KEYSEARCH_8, 0x1830f82f);
10477 : : REG_WR(sc, SRC_REG_KEYSEARCH_9, 0x01e46be7);
10478 : : }
10479 : : REG_WR(sc, SRC_REG_SOFT_RST, 0);
10480 : :
10481 : : if (sizeof(union cdu_context) != 1024) {
10482 : : /* we currently assume that a context is 1024 bytes */
10483 : : PMD_DRV_LOG(NOTICE, sc,
10484 : : "please adjust the size of cdu_context(%ld)",
10485 : : (long)sizeof(union cdu_context));
10486 : : }
10487 : :
10488 : 0 : ecore_init_block(sc, BLOCK_CDU, PHASE_COMMON);
10489 : : val = (4 << 24) + (0 << 12) + 1024;
10490 : : REG_WR(sc, CDU_REG_CDU_GLOBAL_PARAMS, val);
10491 : :
10492 : 0 : ecore_init_block(sc, BLOCK_CFC, PHASE_COMMON);
10493 : :
10494 : : REG_WR(sc, CFC_REG_INIT_REG, 0x7FF);
10495 : : /* enable context validation interrupt from CFC */
10496 : : REG_WR(sc, CFC_REG_CFC_INT_MASK, 0);
10497 : :
10498 : : /* set the thresholds to prevent CFC/CDU race */
10499 : : REG_WR(sc, CFC_REG_DEBUG0, 0x20020000);
10500 : 0 : ecore_init_block(sc, BLOCK_HC, PHASE_COMMON);
10501 : :
10502 [ # # # # ]: 0 : if (!CHIP_IS_E1x(sc) && BNX2X_NOMCP(sc)) {
10503 : : REG_WR(sc, IGU_REG_RESET_MEMORIES, 0x36);
10504 : : }
10505 : :
10506 : 0 : ecore_init_block(sc, BLOCK_IGU, PHASE_COMMON);
10507 : 0 : ecore_init_block(sc, BLOCK_MISC_AEU, PHASE_COMMON);
10508 : :
10509 : : /* Reset PCIE errors for debug */
10510 : : REG_WR(sc, 0x2814, 0xffffffff);
10511 : : REG_WR(sc, 0x3820, 0xffffffff);
10512 : :
10513 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10514 : : REG_WR(sc, PCICFG_OFFSET + PXPCS_TL_CONTROL_5,
10515 : : (PXPCS_TL_CONTROL_5_ERR_UNSPPORT1 |
10516 : : PXPCS_TL_CONTROL_5_ERR_UNSPPORT));
10517 : : REG_WR(sc, PCICFG_OFFSET + PXPCS_TL_FUNC345_STAT,
10518 : : (PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT4 |
10519 : : PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT3 |
10520 : : PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT2));
10521 : : REG_WR(sc, PCICFG_OFFSET + PXPCS_TL_FUNC678_STAT,
10522 : : (PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT7 |
10523 : : PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT6 |
10524 : : PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT5));
10525 : : }
10526 : :
10527 : 0 : ecore_init_block(sc, BLOCK_NIG, PHASE_COMMON);
10528 : :
10529 : : /* in E3 this done in per-port section */
10530 [ # # # # : 0 : if (!CHIP_IS_E3(sc))
# # # # #
# ]
10531 [ # # # # ]: 0 : REG_WR(sc, NIG_REG_LLH_MF_MODE, IS_MF(sc));
10532 : :
10533 [ # # ]: 0 : if (CHIP_IS_E1H(sc)) {
10534 : : /* not applicable for E2 (and above ...) */
10535 [ # # # # ]: 0 : REG_WR(sc, NIG_REG_LLH_E1HOV_MODE, IS_MF_SD(sc));
10536 : : }
10537 : :
10538 [ # # ]: 0 : if (CHIP_REV_IS_SLOW(sc)) {
10539 : 0 : DELAY(200000);
10540 : : }
10541 : :
10542 : : /* finish CFC init */
10543 : : val = reg_poll(sc, CFC_REG_LL_INIT_DONE, 1, 100, 10);
10544 [ # # ]: 0 : if (val != 1) {
10545 : 0 : PMD_DRV_LOG(NOTICE, sc, "CFC LL_INIT failed");
10546 : 0 : return -1;
10547 : : }
10548 : : val = reg_poll(sc, CFC_REG_AC_INIT_DONE, 1, 100, 10);
10549 [ # # ]: 0 : if (val != 1) {
10550 : 0 : PMD_DRV_LOG(NOTICE, sc, "CFC AC_INIT failed");
10551 : 0 : return -1;
10552 : : }
10553 : : val = reg_poll(sc, CFC_REG_CAM_INIT_DONE, 1, 100, 10);
10554 [ # # ]: 0 : if (val != 1) {
10555 : 0 : PMD_DRV_LOG(NOTICE, sc, "CFC CAM_INIT failed");
10556 : 0 : return -1;
10557 : : }
10558 : : REG_WR(sc, CFC_REG_DEBUG0, 0);
10559 : :
10560 : 0 : bnx2x_setup_fan_failure_detection(sc);
10561 : :
10562 : : /* clear PXP2 attentions */
10563 : : REG_RD(sc, PXP2_REG_PXP2_INT_STS_CLR_0);
10564 : :
10565 : 0 : bnx2x_enable_blocks_attention(sc);
10566 : :
10567 [ # # ]: 0 : if (!CHIP_REV_IS_SLOW(sc)) {
10568 : 0 : ecore_enable_blocks_parity(sc);
10569 : : }
10570 : :
10571 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
10572 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
10573 : 0 : bnx2x_common_init_phy(sc);
10574 : : }
10575 : : }
10576 : :
10577 : : return 0;
10578 : : }
10579 : :
10580 : : /**
10581 : : * bnx2x_init_hw_common_chip - init HW at the COMMON_CHIP phase.
10582 : : *
10583 : : * @sc: driver handle
10584 : : */
10585 : 0 : static int bnx2x_init_hw_common_chip(struct bnx2x_softc *sc)
10586 : : {
10587 : 0 : int rc = bnx2x_init_hw_common(sc);
10588 : :
10589 [ # # ]: 0 : if (rc) {
10590 : : return rc;
10591 : : }
10592 : :
10593 : : /* In E2 2-PORT mode, same ext phy is used for the two paths */
10594 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
10595 : 0 : bnx2x_common_init_phy(sc);
10596 : : }
10597 : :
10598 : : return 0;
10599 : : }
10600 : :
10601 : 0 : static int bnx2x_init_hw_port(struct bnx2x_softc *sc)
10602 : : {
10603 : 0 : int port = SC_PORT(sc);
10604 [ # # ]: 0 : int init_phase = port ? PHASE_PORT1 : PHASE_PORT0;
10605 : : uint32_t low, high;
10606 : : uint32_t val;
10607 : :
10608 : 0 : PMD_DRV_LOG(DEBUG, sc, "starting port init for port %d", port);
10609 : :
10610 : 0 : REG_WR(sc, NIG_REG_MASK_INTERRUPT_PORT0 + port * 4, 0);
10611 : :
10612 : 0 : ecore_init_block(sc, BLOCK_MISC, init_phase);
10613 : 0 : ecore_init_block(sc, BLOCK_PXP, init_phase);
10614 : 0 : ecore_init_block(sc, BLOCK_PXP2, init_phase);
10615 : :
10616 : : /*
10617 : : * Timers bug workaround: disables the pf_master bit in pglue at
10618 : : * common phase, we need to enable it here before any dmae access are
10619 : : * attempted. Therefore we manually added the enable-master to the
10620 : : * port phase (it also happens in the function phase)
10621 : : */
10622 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10623 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1);
10624 : : }
10625 : :
10626 : 0 : ecore_init_block(sc, BLOCK_ATC, init_phase);
10627 : 0 : ecore_init_block(sc, BLOCK_DMAE, init_phase);
10628 : 0 : ecore_init_block(sc, BLOCK_PGLUE_B, init_phase);
10629 : 0 : ecore_init_block(sc, BLOCK_QM, init_phase);
10630 : :
10631 : 0 : ecore_init_block(sc, BLOCK_TCM, init_phase);
10632 : 0 : ecore_init_block(sc, BLOCK_UCM, init_phase);
10633 : 0 : ecore_init_block(sc, BLOCK_CCM, init_phase);
10634 : 0 : ecore_init_block(sc, BLOCK_XCM, init_phase);
10635 : :
10636 : : /* QM cid (connection) count */
10637 [ # # ]: 0 : ecore_qm_init_cid_count(sc, sc->qm_cid_count, INITOP_SET);
10638 : :
10639 : : if (CNIC_SUPPORT(sc)) {
10640 : : ecore_init_block(sc, BLOCK_TM, init_phase);
10641 : : REG_WR(sc, TM_REG_LIN0_SCAN_TIME + port * 4, 20);
10642 : : REG_WR(sc, TM_REG_LIN0_MAX_ACTIVE_CID + port * 4, 31);
10643 : : }
10644 : :
10645 : 0 : ecore_init_block(sc, BLOCK_DORQ, init_phase);
10646 : :
10647 : 0 : ecore_init_block(sc, BLOCK_BRB1, init_phase);
10648 : :
10649 [ # # ]: 0 : if (CHIP_IS_E1H(sc)) {
10650 [ # # # # ]: 0 : if (IS_MF(sc)) {
10651 [ # # ]: 0 : low = (BNX2X_ONE_PORT(sc) ? 160 : 246);
10652 [ # # ]: 0 : } else if (sc->mtu > 4096) {
10653 [ # # ]: 0 : if (BNX2X_ONE_PORT(sc)) {
10654 : : low = 160;
10655 : : } else {
10656 : 0 : val = sc->mtu;
10657 : : /* (24*1024 + val*4)/256 */
10658 [ # # ]: 0 : low = (96 + (val / 64) + ((val % 64) ? 1 : 0));
10659 : : }
10660 : : } else {
10661 [ # # ]: 0 : low = (BNX2X_ONE_PORT(sc) ? 80 : 160);
10662 : : }
10663 : 0 : high = (low + 56); /* 14*1024/256 */
10664 : 0 : REG_WR(sc, BRB1_REG_PAUSE_LOW_THRESHOLD_0 + port * 4, low);
10665 : 0 : REG_WR(sc, BRB1_REG_PAUSE_HIGH_THRESHOLD_0 + port * 4, high);
10666 : : }
10667 : :
10668 [ # # ]: 0 : if (CHIP_IS_MODE_4_PORT(sc)) {
10669 [ # # ]: 0 : REG_WR(sc, SC_PORT(sc) ?
10670 : : BRB1_REG_MAC_GUARANTIED_1 :
10671 : : BRB1_REG_MAC_GUARANTIED_0, 40);
10672 : : }
10673 : :
10674 : 0 : ecore_init_block(sc, BLOCK_PRS, init_phase);
10675 [ # # # # ]: 0 : if (CHIP_IS_E3B0(sc)) {
10676 [ # # # # ]: 0 : if (IS_MF_AFEX(sc)) {
10677 : : /* configure headers for AFEX mode */
10678 [ # # ]: 0 : if (SC_PORT(sc)) {
10679 : : REG_WR(sc, PRS_REG_HDRS_AFTER_BASIC_PORT_1,
10680 : : 0xE);
10681 : : REG_WR(sc, PRS_REG_HDRS_AFTER_TAG_0_PORT_1,
10682 : : 0x6);
10683 : : REG_WR(sc, PRS_REG_MUST_HAVE_HDRS_PORT_1, 0xA);
10684 : : } else {
10685 : : REG_WR(sc, PRS_REG_HDRS_AFTER_BASIC_PORT_0,
10686 : : 0xE);
10687 : : REG_WR(sc, PRS_REG_HDRS_AFTER_TAG_0_PORT_0,
10688 : : 0x6);
10689 : : REG_WR(sc, PRS_REG_MUST_HAVE_HDRS_PORT_0, 0xA);
10690 : : }
10691 : : } else {
10692 : : /* Ovlan exists only if we are in multi-function +
10693 : : * switch-dependent mode, in switch-independent there
10694 : : * is no ovlan headers
10695 : : */
10696 [ # # # # ]: 0 : REG_WR(sc, SC_PORT(sc) ?
10697 : : PRS_REG_HDRS_AFTER_BASIC_PORT_1 :
10698 : : PRS_REG_HDRS_AFTER_BASIC_PORT_0,
10699 : : (sc->devinfo.mf_info.path_has_ovlan ? 7 : 6));
10700 : : }
10701 : : }
10702 : :
10703 : 0 : ecore_init_block(sc, BLOCK_TSDM, init_phase);
10704 : 0 : ecore_init_block(sc, BLOCK_CSDM, init_phase);
10705 : 0 : ecore_init_block(sc, BLOCK_USDM, init_phase);
10706 : 0 : ecore_init_block(sc, BLOCK_XSDM, init_phase);
10707 : :
10708 : 0 : ecore_init_block(sc, BLOCK_TSEM, init_phase);
10709 : 0 : ecore_init_block(sc, BLOCK_USEM, init_phase);
10710 : 0 : ecore_init_block(sc, BLOCK_CSEM, init_phase);
10711 : 0 : ecore_init_block(sc, BLOCK_XSEM, init_phase);
10712 : :
10713 : 0 : ecore_init_block(sc, BLOCK_UPB, init_phase);
10714 : 0 : ecore_init_block(sc, BLOCK_XPB, init_phase);
10715 : :
10716 : 0 : ecore_init_block(sc, BLOCK_PBF, init_phase);
10717 : :
10718 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
10719 : : /* configure PBF to work without PAUSE mtu 9000 */
10720 : 0 : REG_WR(sc, PBF_REG_P0_PAUSE_ENABLE + port * 4, 0);
10721 : :
10722 : : /* update threshold */
10723 : 0 : REG_WR(sc, PBF_REG_P0_ARB_THRSH + port * 4, (9040 / 16));
10724 : : /* update init credit */
10725 : 0 : REG_WR(sc, PBF_REG_P0_INIT_CRD + port * 4,
10726 : : (9040 / 16) + 553 - 22);
10727 : :
10728 : : /* probe changes */
10729 : 0 : REG_WR(sc, PBF_REG_INIT_P0 + port * 4, 1);
10730 : 0 : DELAY(50);
10731 : : REG_WR(sc, PBF_REG_INIT_P0 + port * 4, 0);
10732 : : }
10733 : :
10734 : : if (CNIC_SUPPORT(sc)) {
10735 : : ecore_init_block(sc, BLOCK_SRC, init_phase);
10736 : : }
10737 : :
10738 : 0 : ecore_init_block(sc, BLOCK_CDU, init_phase);
10739 : 0 : ecore_init_block(sc, BLOCK_CFC, init_phase);
10740 : 0 : ecore_init_block(sc, BLOCK_HC, init_phase);
10741 : 0 : ecore_init_block(sc, BLOCK_IGU, init_phase);
10742 : 0 : ecore_init_block(sc, BLOCK_MISC_AEU, init_phase);
10743 : : /* init aeu_mask_attn_func_0/1:
10744 : : * - SF mode: bits 3-7 are masked. only bits 0-2 are in use
10745 : : * - MF mode: bit 3 is masked. bits 0-2 are in use as in SF
10746 : : * bits 4-7 are used for "per vn group attention" */
10747 [ # # # # ]: 0 : val = IS_MF(sc) ? 0xF7 : 0x7;
10748 : 0 : val |= 0x10;
10749 : 0 : REG_WR(sc, MISC_REG_AEU_MASK_ATTN_FUNC_0 + port * 4, val);
10750 : :
10751 : 0 : ecore_init_block(sc, BLOCK_NIG, init_phase);
10752 : :
10753 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10754 : : /* Bit-map indicating which L2 hdrs may appear after the
10755 : : * basic Ethernet header
10756 : : */
10757 [ # # # # ]: 0 : if (IS_MF_AFEX(sc)) {
10758 [ # # ]: 0 : REG_WR(sc, SC_PORT(sc) ?
10759 : : NIG_REG_P1_HDRS_AFTER_BASIC :
10760 : : NIG_REG_P0_HDRS_AFTER_BASIC, 0xE);
10761 : : } else {
10762 [ # # # # : 0 : REG_WR(sc, SC_PORT(sc) ?
# # ]
10763 : : NIG_REG_P1_HDRS_AFTER_BASIC :
10764 : : NIG_REG_P0_HDRS_AFTER_BASIC,
10765 : : IS_MF_SD(sc) ? 7 : 6);
10766 : : }
10767 : :
10768 [ # # ]: 0 : if (CHIP_IS_E3(sc)) {
10769 [ # # # # : 0 : REG_WR(sc, SC_PORT(sc) ?
# # ]
10770 : : NIG_REG_LLH1_MF_MODE :
10771 : : NIG_REG_LLH_MF_MODE, IS_MF(sc));
10772 : : }
10773 : : }
10774 [ # # # # : 0 : if (!CHIP_IS_E3(sc)) {
# # # # #
# ]
10775 : 0 : REG_WR(sc, NIG_REG_XGXS_SERDES0_MODE_SEL + port * 4, 1);
10776 : : }
10777 : :
10778 : : /* 0x2 disable mf_ov, 0x1 enable */
10779 [ # # # # ]: 0 : REG_WR(sc, NIG_REG_LLH0_BRB1_DRV_MASK_MF + port * 4,
10780 : : (IS_MF_SD(sc) ? 0x1 : 0x2));
10781 : :
10782 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
10783 : : val = 0;
10784 [ # # # ]: 0 : switch (sc->devinfo.mf_info.mf_mode) {
10785 : 0 : case MULTI_FUNCTION_SD:
10786 : : val = 1;
10787 : 0 : break;
10788 : 0 : case MULTI_FUNCTION_SI:
10789 : : case MULTI_FUNCTION_AFEX:
10790 : : val = 2;
10791 : 0 : break;
10792 : : }
10793 : :
10794 [ # # ]: 0 : REG_WR(sc, (SC_PORT(sc) ? NIG_REG_LLH1_CLS_TYPE :
10795 : : NIG_REG_LLH0_CLS_TYPE), val);
10796 : : }
10797 : 0 : REG_WR(sc, NIG_REG_LLFC_ENABLE_0 + port * 4, 0);
10798 : 0 : REG_WR(sc, NIG_REG_LLFC_OUT_EN_0 + port * 4, 0);
10799 : 0 : REG_WR(sc, NIG_REG_PAUSE_ENABLE_0 + port * 4, 1);
10800 : :
10801 : : /* If SPIO5 is set to generate interrupts, enable it for this port */
10802 : : val = REG_RD(sc, MISC_REG_SPIO_EVENT_EN);
10803 [ # # ]: 0 : if (val & MISC_SPIO_SPIO5) {
10804 [ # # ]: 0 : uint32_t reg_addr = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
10805 : : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
10806 : 0 : val = REG_RD(sc, reg_addr);
10807 : 0 : val |= AEU_INPUTS_ATTN_BITS_SPIO5;
10808 : : REG_WR(sc, reg_addr, val);
10809 : : }
10810 : :
10811 : 0 : return 0;
10812 : : }
10813 : :
10814 : : static uint32_t
10815 : : bnx2x_flr_clnup_reg_poll(struct bnx2x_softc *sc, uint32_t reg,
10816 : : uint32_t expected, uint32_t poll_count)
10817 : : {
10818 : : uint32_t cur_cnt = poll_count;
10819 : : uint32_t val;
10820 : :
10821 [ # # # # : 0 : while ((val = REG_RD(sc, reg)) != expected && cur_cnt--) {
# # # # ]
10822 : 0 : DELAY(FLR_WAIT_INTERVAL);
10823 : : }
10824 : :
10825 : : return val;
10826 : : }
10827 : :
10828 : : static int
10829 : 0 : bnx2x_flr_clnup_poll_hw_counter(struct bnx2x_softc *sc, uint32_t reg,
10830 : : __rte_unused const char *msg, uint32_t poll_cnt)
10831 : : {
10832 : : uint32_t val = bnx2x_flr_clnup_reg_poll(sc, reg, 0, poll_cnt);
10833 : :
10834 [ # # ]: 0 : if (val != 0) {
10835 : 0 : PMD_DRV_LOG(NOTICE, sc, "%s usage count=%d", msg, val);
10836 : 0 : return -1;
10837 : : }
10838 : :
10839 : : return 0;
10840 : : }
10841 : :
10842 : : /* Common routines with VF FLR cleanup */
10843 : : static uint32_t bnx2x_flr_clnup_poll_count(struct bnx2x_softc *sc)
10844 : : {
10845 : : /* adjust polling timeout */
10846 [ # # ]: 0 : if (CHIP_REV_IS_EMUL(sc)) {
10847 : : return FLR_POLL_CNT * 2000;
10848 : : }
10849 : :
10850 [ # # # # ]: 0 : if (CHIP_REV_IS_FPGA(sc)) {
10851 : 0 : return FLR_POLL_CNT * 120;
10852 : : }
10853 : :
10854 : : return FLR_POLL_CNT;
10855 : : }
10856 : :
10857 : 0 : static int bnx2x_poll_hw_usage_counters(struct bnx2x_softc *sc, uint32_t poll_cnt)
10858 : : {
10859 : : /* wait for CFC PF usage-counter to zero (includes all the VFs) */
10860 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10861 : : CFC_REG_NUM_LCIDS_INSIDE_PF,
10862 : : "CFC PF usage counter timed out",
10863 : : poll_cnt)) {
10864 : : return -1;
10865 : : }
10866 : :
10867 : : /* Wait for DQ PF usage-counter to zero (until DQ cleanup) */
10868 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10869 : : DORQ_REG_PF_USAGE_CNT,
10870 : : "DQ PF usage counter timed out",
10871 : : poll_cnt)) {
10872 : : return -1;
10873 : : }
10874 : :
10875 : : /* Wait for QM PF usage-counter to zero (until DQ cleanup) */
10876 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10877 : 0 : QM_REG_PF_USG_CNT_0 + 4 * SC_FUNC(sc),
10878 : : "QM PF usage counter timed out",
10879 : : poll_cnt)) {
10880 : : return -1;
10881 : : }
10882 : :
10883 : : /* Wait for Timer PF usage-counters to zero (until DQ cleanup) */
10884 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10885 : 0 : TM_REG_LIN0_VNIC_UC + 4 * SC_PORT(sc),
10886 : : "Timers VNIC usage counter timed out",
10887 : : poll_cnt)) {
10888 : : return -1;
10889 : : }
10890 : :
10891 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10892 : 0 : TM_REG_LIN0_NUM_SCANS +
10893 : 0 : 4 * SC_PORT(sc),
10894 : : "Timers NUM_SCANS usage counter timed out",
10895 : : poll_cnt)) {
10896 : : return -1;
10897 : : }
10898 : :
10899 : : /* Wait DMAE PF usage counter to zero */
10900 [ # # ]: 0 : if (bnx2x_flr_clnup_poll_hw_counter(sc,
10901 : 0 : dmae_reg_go_c[INIT_DMAE_C(sc)],
10902 : : "DMAE dommand register timed out",
10903 : : poll_cnt)) {
10904 : 0 : return -1;
10905 : : }
10906 : :
10907 : : return 0;
10908 : : }
10909 : :
10910 : : #define OP_GEN_PARAM(param) \
10911 : : (((param) << SDM_OP_GEN_COMP_PARAM_SHIFT) & SDM_OP_GEN_COMP_PARAM)
10912 : : #define OP_GEN_TYPE(type) \
10913 : : (((type) << SDM_OP_GEN_COMP_TYPE_SHIFT) & SDM_OP_GEN_COMP_TYPE)
10914 : : #define OP_GEN_AGG_VECT(index) \
10915 : : (((index) << SDM_OP_GEN_AGG_VECT_IDX_SHIFT) & SDM_OP_GEN_AGG_VECT_IDX)
10916 : :
10917 : : static int
10918 : 0 : bnx2x_send_final_clnup(struct bnx2x_softc *sc, uint8_t clnup_func,
10919 : : uint32_t poll_cnt)
10920 : : {
10921 : : uint32_t op_gen_command = 0;
10922 : 0 : uint32_t comp_addr = (BAR_CSTRORM_INTMEM +
10923 : 0 : CSTORM_FINAL_CLEANUP_COMPLETE_OFFSET(clnup_func));
10924 : : int ret = 0;
10925 : :
10926 [ # # ]: 0 : if (REG_RD(sc, comp_addr)) {
10927 : 0 : PMD_DRV_LOG(NOTICE, sc,
10928 : : "Cleanup complete was not 0 before sending");
10929 : 0 : return -1;
10930 : : }
10931 : :
10932 : 0 : op_gen_command |= OP_GEN_PARAM(XSTORM_AGG_INT_FINAL_CLEANUP_INDEX);
10933 : 0 : op_gen_command |= OP_GEN_TYPE(XSTORM_AGG_INT_FINAL_CLEANUP_COMP_TYPE);
10934 : 0 : op_gen_command |= OP_GEN_AGG_VECT(clnup_func);
10935 : 0 : op_gen_command |= 1 << SDM_OP_GEN_AGG_VECT_IDX_VALID_SHIFT;
10936 : :
10937 : : REG_WR(sc, XSDM_REG_OPERATION_GEN, op_gen_command);
10938 : :
10939 [ # # ]: 0 : if (bnx2x_flr_clnup_reg_poll(sc, comp_addr, 1, poll_cnt) != 1) {
10940 : 0 : PMD_DRV_LOG(NOTICE, sc, "FW final cleanup did not succeed");
10941 : 0 : PMD_DRV_LOG(DEBUG, sc, "At timeout completion address contained %x",
10942 : : (REG_RD(sc, comp_addr)));
10943 : 0 : rte_panic("FLR cleanup failed");
10944 : : return -1;
10945 : : }
10946 : :
10947 : : /* Zero completion for nxt FLR */
10948 : : REG_WR(sc, comp_addr, 0);
10949 : :
10950 : 0 : return ret;
10951 : : }
10952 : :
10953 : : static void
10954 : 0 : bnx2x_pbf_pN_buf_flushed(struct bnx2x_softc *sc, struct pbf_pN_buf_regs *regs,
10955 : : uint32_t poll_count)
10956 : : {
10957 : : uint32_t init_crd, crd, crd_start, crd_freed, crd_freed_start;
10958 : : uint32_t cur_cnt = poll_count;
10959 : :
10960 : 0 : crd_freed = crd_freed_start = REG_RD(sc, regs->crd_freed);
10961 : 0 : crd = crd_start = REG_RD(sc, regs->crd);
10962 : 0 : init_crd = REG_RD(sc, regs->init_crd);
10963 : :
10964 [ # # ]: 0 : while ((crd != init_crd) &&
10965 : 0 : ((uint32_t) ((int32_t) crd_freed - (int32_t) crd_freed_start) <
10966 [ # # ]: 0 : (init_crd - crd_start))) {
10967 [ # # ]: 0 : if (cur_cnt--) {
10968 : 0 : DELAY(FLR_WAIT_INTERVAL);
10969 : 0 : crd = REG_RD(sc, regs->crd);
10970 : 0 : crd_freed = REG_RD(sc, regs->crd_freed);
10971 : : } else {
10972 : : break;
10973 : : }
10974 : : }
10975 : 0 : }
10976 : :
10977 : : static void
10978 : 0 : bnx2x_pbf_pN_cmd_flushed(struct bnx2x_softc *sc, struct pbf_pN_cmd_regs *regs,
10979 : : uint32_t poll_count)
10980 : : {
10981 : : uint32_t occup, to_free, freed, freed_start;
10982 : : uint32_t cur_cnt = poll_count;
10983 : :
10984 : 0 : occup = to_free = REG_RD(sc, regs->lines_occup);
10985 : 0 : freed = freed_start = REG_RD(sc, regs->lines_freed);
10986 : :
10987 [ # # ]: 0 : while (occup &&
10988 [ # # ]: 0 : ((uint32_t) ((int32_t) freed - (int32_t) freed_start) <
10989 : : to_free)) {
10990 [ # # ]: 0 : if (cur_cnt--) {
10991 : 0 : DELAY(FLR_WAIT_INTERVAL);
10992 : 0 : occup = REG_RD(sc, regs->lines_occup);
10993 : 0 : freed = REG_RD(sc, regs->lines_freed);
10994 : : } else {
10995 : : break;
10996 : : }
10997 : : }
10998 : 0 : }
10999 : :
11000 : 0 : static void bnx2x_tx_hw_flushed(struct bnx2x_softc *sc, uint32_t poll_count)
11001 : : {
11002 : 0 : struct pbf_pN_cmd_regs cmd_regs[] = {
11003 [ # # ]: 0 : {0, (CHIP_IS_E3B0(sc)) ?
11004 [ # # ]: 0 : PBF_REG_TQ_OCCUPANCY_Q0 : PBF_REG_P0_TQ_OCCUPANCY,
11005 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11006 [ # # ]: 0 : PBF_REG_TQ_LINES_FREED_CNT_Q0 : PBF_REG_P0_TQ_LINES_FREED_CNT},
11007 [ # # ]: 0 : {1, (CHIP_IS_E3B0(sc)) ?
11008 [ # # ]: 0 : PBF_REG_TQ_OCCUPANCY_Q1 : PBF_REG_P1_TQ_OCCUPANCY,
11009 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11010 [ # # ]: 0 : PBF_REG_TQ_LINES_FREED_CNT_Q1 : PBF_REG_P1_TQ_LINES_FREED_CNT},
11011 [ # # ]: 0 : {4, (CHIP_IS_E3B0(sc)) ?
11012 [ # # ]: 0 : PBF_REG_TQ_OCCUPANCY_LB_Q : PBF_REG_P4_TQ_OCCUPANCY,
11013 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11014 [ # # ]: 0 : PBF_REG_TQ_LINES_FREED_CNT_LB_Q :
11015 : : PBF_REG_P4_TQ_LINES_FREED_CNT}
11016 : : };
11017 : :
11018 : 0 : struct pbf_pN_buf_regs buf_regs[] = {
11019 [ # # ]: 0 : {0, (CHIP_IS_E3B0(sc)) ?
11020 [ # # ]: 0 : PBF_REG_INIT_CRD_Q0 : PBF_REG_P0_INIT_CRD,
11021 [ # # # # ]: 0 : (CHIP_IS_E3B0(sc)) ? PBF_REG_CREDIT_Q0 : PBF_REG_P0_CREDIT,
11022 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11023 [ # # ]: 0 : PBF_REG_INTERNAL_CRD_FREED_CNT_Q0 :
11024 : : PBF_REG_P0_INTERNAL_CRD_FREED_CNT},
11025 [ # # ]: 0 : {1, (CHIP_IS_E3B0(sc)) ?
11026 [ # # ]: 0 : PBF_REG_INIT_CRD_Q1 : PBF_REG_P1_INIT_CRD,
11027 [ # # # # ]: 0 : (CHIP_IS_E3B0(sc)) ? PBF_REG_CREDIT_Q1 : PBF_REG_P1_CREDIT,
11028 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11029 [ # # ]: 0 : PBF_REG_INTERNAL_CRD_FREED_CNT_Q1 :
11030 : : PBF_REG_P1_INTERNAL_CRD_FREED_CNT},
11031 [ # # ]: 0 : {4, (CHIP_IS_E3B0(sc)) ?
11032 [ # # ]: 0 : PBF_REG_INIT_CRD_LB_Q : PBF_REG_P4_INIT_CRD,
11033 [ # # # # ]: 0 : (CHIP_IS_E3B0(sc)) ? PBF_REG_CREDIT_LB_Q : PBF_REG_P4_CREDIT,
11034 [ # # ]: 0 : (CHIP_IS_E3B0(sc)) ?
11035 [ # # ]: 0 : PBF_REG_INTERNAL_CRD_FREED_CNT_LB_Q :
11036 : : PBF_REG_P4_INTERNAL_CRD_FREED_CNT},
11037 : : };
11038 : :
11039 : : uint32_t i;
11040 : :
11041 : : /* Verify the command queues are flushed P0, P1, P4 */
11042 [ # # ]: 0 : for (i = 0; i < ARRAY_SIZE(cmd_regs); i++) {
11043 : 0 : bnx2x_pbf_pN_cmd_flushed(sc, &cmd_regs[i], poll_count);
11044 : : }
11045 : :
11046 : : /* Verify the transmission buffers are flushed P0, P1, P4 */
11047 [ # # ]: 0 : for (i = 0; i < ARRAY_SIZE(buf_regs); i++) {
11048 : 0 : bnx2x_pbf_pN_buf_flushed(sc, &buf_regs[i], poll_count);
11049 : : }
11050 : 0 : }
11051 : :
11052 : 0 : static void bnx2x_hw_enable_status(struct bnx2x_softc *sc)
11053 : : {
11054 : : __rte_unused uint32_t val;
11055 : :
11056 : : val = REG_RD(sc, CFC_REG_WEAK_ENABLE_PF);
11057 : 0 : PMD_DRV_LOG(DEBUG, sc, "CFC_REG_WEAK_ENABLE_PF is 0x%x", val);
11058 : :
11059 : : val = REG_RD(sc, PBF_REG_DISABLE_PF);
11060 : 0 : PMD_DRV_LOG(DEBUG, sc, "PBF_REG_DISABLE_PF is 0x%x", val);
11061 : :
11062 : : val = REG_RD(sc, IGU_REG_PCI_PF_MSI_EN);
11063 : 0 : PMD_DRV_LOG(DEBUG, sc, "IGU_REG_PCI_PF_MSI_EN is 0x%x", val);
11064 : :
11065 : : val = REG_RD(sc, IGU_REG_PCI_PF_MSIX_EN);
11066 : 0 : PMD_DRV_LOG(DEBUG, sc, "IGU_REG_PCI_PF_MSIX_EN is 0x%x", val);
11067 : :
11068 : : val = REG_RD(sc, IGU_REG_PCI_PF_MSIX_FUNC_MASK);
11069 : 0 : PMD_DRV_LOG(DEBUG, sc, "IGU_REG_PCI_PF_MSIX_FUNC_MASK is 0x%x", val);
11070 : :
11071 : : val = REG_RD(sc, PGLUE_B_REG_SHADOW_BME_PF_7_0_CLR);
11072 : 0 : PMD_DRV_LOG(DEBUG, sc,
11073 : : "PGLUE_B_REG_SHADOW_BME_PF_7_0_CLR is 0x%x", val);
11074 : :
11075 : : val = REG_RD(sc, PGLUE_B_REG_FLR_REQUEST_PF_7_0_CLR);
11076 : 0 : PMD_DRV_LOG(DEBUG, sc,
11077 : : "PGLUE_B_REG_FLR_REQUEST_PF_7_0_CLR is 0x%x", val);
11078 : :
11079 : : val = REG_RD(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER);
11080 : 0 : PMD_DRV_LOG(DEBUG, sc, "PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER is 0x%x",
11081 : : val);
11082 : 0 : }
11083 : :
11084 : : /**
11085 : : * bnx2x_pf_flr_clnup
11086 : : * a. re-enable target read on the PF
11087 : : * b. poll cfc per function usage counter
11088 : : * c. poll the qm perfunction usage counter
11089 : : * d. poll the tm per function usage counter
11090 : : * e. poll the tm per function scan-done indication
11091 : : * f. clear the dmae channel associated wit hthe PF
11092 : : * g. zero the igu 'trailing edge' and 'leading edge' regs (attentions)
11093 : : * h. call the common flr cleanup code with -1 (pf indication)
11094 : : */
11095 [ # # ]: 0 : static int bnx2x_pf_flr_clnup(struct bnx2x_softc *sc)
11096 : : {
11097 : : uint32_t poll_cnt = bnx2x_flr_clnup_poll_count(sc);
11098 : :
11099 : : /* Re-enable PF target read access */
11100 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1);
11101 : :
11102 : : /* Poll HW usage counters */
11103 [ # # ]: 0 : if (bnx2x_poll_hw_usage_counters(sc, poll_cnt)) {
11104 : : return -1;
11105 : : }
11106 : :
11107 : : /* Zero the igu 'trailing edge' and 'leading edge' */
11108 : :
11109 : : /* Send the FW cleanup command */
11110 [ # # ]: 0 : if (bnx2x_send_final_clnup(sc, (uint8_t) SC_FUNC(sc), poll_cnt)) {
11111 : : return -1;
11112 : : }
11113 : :
11114 : : /* ATC cleanup */
11115 : :
11116 : : /* Verify TX hw is flushed */
11117 : 0 : bnx2x_tx_hw_flushed(sc, poll_cnt);
11118 : :
11119 : : /* Wait 100ms (not adjusted according to platform) */
11120 : 0 : DELAY(100000);
11121 : :
11122 : : /* Verify no pending pci transactions */
11123 [ # # ]: 0 : if (bnx2x_is_pcie_pending(sc)) {
11124 : 0 : PMD_DRV_LOG(NOTICE, sc, "PCIE Transactions still pending");
11125 : : }
11126 : :
11127 : : /* Debug */
11128 : 0 : bnx2x_hw_enable_status(sc);
11129 : :
11130 : : /*
11131 : : * Master enable - Due to WB DMAE writes performed before this
11132 : : * register is re-initialized as part of the regular function init
11133 : : */
11134 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1);
11135 : :
11136 : 0 : return 0;
11137 : : }
11138 : :
11139 : 0 : static int bnx2x_init_hw_func(struct bnx2x_softc *sc)
11140 : : {
11141 : 0 : int port = SC_PORT(sc);
11142 : : int func = SC_FUNC(sc);
11143 : 0 : int init_phase = PHASE_PF0 + func;
11144 : : struct ecore_ilt *ilt = sc->ilt;
11145 : : uint16_t cdu_ilt_start;
11146 : : uint32_t addr, val;
11147 : : uint32_t main_mem_base, main_mem_size, main_mem_prty_clr;
11148 : : int main_mem_width, rc;
11149 : : uint32_t i;
11150 : :
11151 : 0 : PMD_DRV_LOG(DEBUG, sc, "starting func init for func %d", func);
11152 : :
11153 : : /* FLR cleanup */
11154 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11155 : 0 : rc = bnx2x_pf_flr_clnup(sc);
11156 [ # # ]: 0 : if (rc) {
11157 : 0 : PMD_DRV_LOG(NOTICE, sc, "FLR cleanup failed!");
11158 : 0 : return rc;
11159 : : }
11160 : : }
11161 : :
11162 : : /* set MSI reconfigure capability */
11163 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
11164 [ # # ]: 0 : addr = (port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0);
11165 : 0 : val = REG_RD(sc, addr);
11166 : 0 : val |= HC_CONFIG_0_REG_MSI_ATTN_EN_0;
11167 : : REG_WR(sc, addr, val);
11168 : : }
11169 : :
11170 : 0 : ecore_init_block(sc, BLOCK_PXP, init_phase);
11171 : 0 : ecore_init_block(sc, BLOCK_PXP2, init_phase);
11172 : :
11173 : 0 : ilt = sc->ilt;
11174 : 0 : cdu_ilt_start = ilt->clients[ILT_CLIENT_CDU].start;
11175 : :
11176 [ # # ]: 0 : for (i = 0; i < L2_ILT_LINES(sc); i++) {
11177 : 0 : ilt->lines[cdu_ilt_start + i].page = sc->context[i].vcxt;
11178 : 0 : ilt->lines[cdu_ilt_start + i].page_mapping =
11179 : 0 : (rte_iova_t)sc->context[i].vcxt_dma.paddr;
11180 : 0 : ilt->lines[cdu_ilt_start + i].size = sc->context[i].size;
11181 : : }
11182 : 0 : ecore_ilt_init_op(sc, INITOP_SET);
11183 : :
11184 : : REG_WR(sc, PRS_REG_NIC_MODE, 1);
11185 : :
11186 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11187 : : uint32_t pf_conf = IGU_PF_CONF_FUNC_EN;
11188 : :
11189 : : /* Turn on a single ISR mode in IGU if driver is going to use
11190 : : * INT#x or MSI
11191 : : */
11192 : : if ((sc->interrupt_mode != INTR_MODE_MSIX)
11193 : : || (sc->interrupt_mode != INTR_MODE_SINGLE_MSIX)) {
11194 : : pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN;
11195 : : }
11196 : :
11197 : : /*
11198 : : * Timers workaround bug: function init part.
11199 : : * Need to wait 20msec after initializing ILT,
11200 : : * needed to make sure there are no requests in
11201 : : * one of the PXP internal queues with "old" ILT addresses
11202 : : */
11203 : 0 : DELAY(20000);
11204 : :
11205 : : /*
11206 : : * Master enable - Due to WB DMAE writes performed before this
11207 : : * register is re-initialized as part of the regular function
11208 : : * init
11209 : : */
11210 : : REG_WR(sc, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1);
11211 : : /* Enable the function in IGU */
11212 : : REG_WR(sc, IGU_REG_PF_CONFIGURATION, pf_conf);
11213 : : }
11214 : :
11215 : 0 : sc->dmae_ready = 1;
11216 : :
11217 : 0 : ecore_init_block(sc, BLOCK_PGLUE_B, init_phase);
11218 : :
11219 [ # # ]: 0 : if (!CHIP_IS_E1x(sc))
11220 : 0 : REG_WR(sc, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, func);
11221 : :
11222 : 0 : ecore_init_block(sc, BLOCK_ATC, init_phase);
11223 : 0 : ecore_init_block(sc, BLOCK_DMAE, init_phase);
11224 : 0 : ecore_init_block(sc, BLOCK_NIG, init_phase);
11225 : 0 : ecore_init_block(sc, BLOCK_SRC, init_phase);
11226 : 0 : ecore_init_block(sc, BLOCK_MISC, init_phase);
11227 : 0 : ecore_init_block(sc, BLOCK_TCM, init_phase);
11228 : 0 : ecore_init_block(sc, BLOCK_UCM, init_phase);
11229 : 0 : ecore_init_block(sc, BLOCK_CCM, init_phase);
11230 : 0 : ecore_init_block(sc, BLOCK_XCM, init_phase);
11231 : 0 : ecore_init_block(sc, BLOCK_TSEM, init_phase);
11232 : 0 : ecore_init_block(sc, BLOCK_USEM, init_phase);
11233 : 0 : ecore_init_block(sc, BLOCK_CSEM, init_phase);
11234 : 0 : ecore_init_block(sc, BLOCK_XSEM, init_phase);
11235 : :
11236 [ # # ]: 0 : if (!CHIP_IS_E1x(sc))
11237 : : REG_WR(sc, QM_REG_PF_EN, 1);
11238 : :
11239 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11240 : 0 : REG_WR(sc, TSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func);
11241 : : REG_WR(sc, USEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func);
11242 : : REG_WR(sc, CSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func);
11243 : : REG_WR(sc, XSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func);
11244 : : }
11245 : 0 : ecore_init_block(sc, BLOCK_QM, init_phase);
11246 : :
11247 : 0 : ecore_init_block(sc, BLOCK_TM, init_phase);
11248 : 0 : ecore_init_block(sc, BLOCK_DORQ, init_phase);
11249 : :
11250 : 0 : ecore_init_block(sc, BLOCK_BRB1, init_phase);
11251 : 0 : ecore_init_block(sc, BLOCK_PRS, init_phase);
11252 : 0 : ecore_init_block(sc, BLOCK_TSDM, init_phase);
11253 : 0 : ecore_init_block(sc, BLOCK_CSDM, init_phase);
11254 : 0 : ecore_init_block(sc, BLOCK_USDM, init_phase);
11255 : 0 : ecore_init_block(sc, BLOCK_XSDM, init_phase);
11256 : 0 : ecore_init_block(sc, BLOCK_UPB, init_phase);
11257 : 0 : ecore_init_block(sc, BLOCK_XPB, init_phase);
11258 : 0 : ecore_init_block(sc, BLOCK_PBF, init_phase);
11259 [ # # ]: 0 : if (!CHIP_IS_E1x(sc))
11260 : : REG_WR(sc, PBF_REG_DISABLE_PF, 0);
11261 : :
11262 : 0 : ecore_init_block(sc, BLOCK_CDU, init_phase);
11263 : :
11264 : 0 : ecore_init_block(sc, BLOCK_CFC, init_phase);
11265 : :
11266 [ # # ]: 0 : if (!CHIP_IS_E1x(sc))
11267 : : REG_WR(sc, CFC_REG_WEAK_ENABLE_PF, 1);
11268 : :
11269 [ # # # # ]: 0 : if (IS_MF(sc)) {
11270 : 0 : REG_WR(sc, NIG_REG_LLH0_FUNC_EN + port * 8, 1);
11271 : 0 : REG_WR(sc, NIG_REG_LLH0_FUNC_VLAN_ID + port * 8, OVLAN(sc));
11272 : : }
11273 : :
11274 : 0 : ecore_init_block(sc, BLOCK_MISC_AEU, init_phase);
11275 : :
11276 : : /* HC init per function */
11277 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
11278 [ # # ]: 0 : if (CHIP_IS_E1H(sc)) {
11279 : 0 : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_12 + func * 4, 0);
11280 : :
11281 : 0 : REG_WR(sc, HC_REG_LEADING_EDGE_0 + port * 8, 0);
11282 : 0 : REG_WR(sc, HC_REG_TRAILING_EDGE_0 + port * 8, 0);
11283 : : }
11284 : 0 : ecore_init_block(sc, BLOCK_HC, init_phase);
11285 : :
11286 : : } else {
11287 : : uint32_t num_segs, sb_idx, prod_offset;
11288 : :
11289 : 0 : REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_12 + func * 4, 0);
11290 : :
11291 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11292 : : REG_WR(sc, IGU_REG_LEADING_EDGE_LATCH, 0);
11293 : : REG_WR(sc, IGU_REG_TRAILING_EDGE_LATCH, 0);
11294 : : }
11295 : :
11296 : 0 : ecore_init_block(sc, BLOCK_IGU, init_phase);
11297 : :
11298 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11299 : : int dsb_idx = 0;
11300 : : /**
11301 : : * Producer memory:
11302 : : * E2 mode: address 0-135 match to the mapping memory;
11303 : : * 136 - PF0 default prod; 137 - PF1 default prod;
11304 : : * 138 - PF2 default prod; 139 - PF3 default prod;
11305 : : * 140 - PF0 attn prod; 141 - PF1 attn prod;
11306 : : * 142 - PF2 attn prod; 143 - PF3 attn prod;
11307 : : * 144-147 reserved.
11308 : : *
11309 : : * E1.5 mode - In backward compatible mode;
11310 : : * for non default SB; each even line in the memory
11311 : : * holds the U producer and each odd line hold
11312 : : * the C producer. The first 128 producers are for
11313 : : * NDSB (PF0 - 0-31; PF1 - 32-63 and so on). The last 20
11314 : : * producers are for the DSB for each PF.
11315 : : * Each PF has five segments: (the order inside each
11316 : : * segment is PF0; PF1; PF2; PF3) - 128-131 U prods;
11317 : : * 132-135 C prods; 136-139 X prods; 140-143 T prods;
11318 : : * 144-147 attn prods;
11319 : : */
11320 : : /* non-default-status-blocks */
11321 [ # # ]: 0 : num_segs = CHIP_INT_MODE_IS_BC(sc) ?
11322 : : IGU_BC_NDSB_NUM_SEGS : IGU_NORM_NDSB_NUM_SEGS;
11323 [ # # ]: 0 : for (sb_idx = 0; sb_idx < sc->igu_sb_cnt; sb_idx++) {
11324 : 0 : prod_offset = (sc->igu_base_sb + sb_idx) *
11325 : : num_segs;
11326 : :
11327 [ # # ]: 0 : for (i = 0; i < num_segs; i++) {
11328 : 0 : addr = IGU_REG_PROD_CONS_MEMORY +
11329 : 0 : (prod_offset + i) * 4;
11330 : 0 : REG_WR(sc, addr, 0);
11331 : : }
11332 : : /* send consumer update with value 0 */
11333 : 0 : bnx2x_ack_sb(sc, sc->igu_base_sb + sb_idx,
11334 : : USTORM_ID, 0, IGU_INT_NOP, 1);
11335 : 0 : bnx2x_igu_clear_sb(sc, sc->igu_base_sb + sb_idx);
11336 : : }
11337 : :
11338 : : /* default-status-blocks */
11339 [ # # ]: 0 : num_segs = CHIP_INT_MODE_IS_BC(sc) ?
11340 [ # # ]: 0 : IGU_BC_DSB_NUM_SEGS : IGU_NORM_DSB_NUM_SEGS;
11341 : :
11342 [ # # ]: 0 : if (CHIP_IS_MODE_4_PORT(sc))
11343 : 0 : dsb_idx = SC_FUNC(sc);
11344 : : else
11345 : 0 : dsb_idx = SC_VN(sc);
11346 : :
11347 [ # # ]: 0 : prod_offset = (CHIP_INT_MODE_IS_BC(sc) ?
11348 [ # # ]: 0 : IGU_BC_BASE_DSB_PROD + dsb_idx :
11349 : 0 : IGU_NORM_BASE_DSB_PROD + dsb_idx);
11350 : :
11351 : : /*
11352 : : * igu prods come in chunks of E1HVN_MAX (4) -
11353 : : * does not matters what is the current chip mode
11354 : : */
11355 [ # # ]: 0 : for (i = 0; i < (num_segs * E1HVN_MAX); i += E1HVN_MAX) {
11356 : 0 : addr = IGU_REG_PROD_CONS_MEMORY +
11357 : 0 : (prod_offset + i) * 4;
11358 : 0 : REG_WR(sc, addr, 0);
11359 : : }
11360 : : /* send consumer update with 0 */
11361 [ # # # # ]: 0 : if (CHIP_INT_MODE_IS_BC(sc)) {
11362 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11363 : : USTORM_ID, 0, IGU_INT_NOP, 1);
11364 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11365 : : CSTORM_ID, 0, IGU_INT_NOP, 1);
11366 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11367 : : XSTORM_ID, 0, IGU_INT_NOP, 1);
11368 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11369 : : TSTORM_ID, 0, IGU_INT_NOP, 1);
11370 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11371 : : ATTENTION_ID, 0, IGU_INT_NOP, 1);
11372 : : } else {
11373 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11374 : : USTORM_ID, 0, IGU_INT_NOP, 1);
11375 : 0 : bnx2x_ack_sb(sc, sc->igu_dsb_id,
11376 : : ATTENTION_ID, 0, IGU_INT_NOP, 1);
11377 : : }
11378 : 0 : bnx2x_igu_clear_sb(sc, sc->igu_dsb_id);
11379 : :
11380 : : /* !!! these should become driver const once
11381 : : rf-tool supports split-68 const */
11382 : : REG_WR(sc, IGU_REG_SB_INT_BEFORE_MASK_LSB, 0);
11383 : : REG_WR(sc, IGU_REG_SB_INT_BEFORE_MASK_MSB, 0);
11384 : : REG_WR(sc, IGU_REG_SB_MASK_LSB, 0);
11385 : : REG_WR(sc, IGU_REG_SB_MASK_MSB, 0);
11386 : : REG_WR(sc, IGU_REG_PBA_STATUS_LSB, 0);
11387 : : REG_WR(sc, IGU_REG_PBA_STATUS_MSB, 0);
11388 : : }
11389 : : }
11390 : :
11391 : : /* Reset PCIE errors for debug */
11392 : : REG_WR(sc, 0x2114, 0xffffffff);
11393 : : REG_WR(sc, 0x2120, 0xffffffff);
11394 : :
11395 [ # # ]: 0 : if (CHIP_IS_E1x(sc)) {
11396 : : main_mem_size = HC_REG_MAIN_MEMORY_SIZE / 2; /*dwords */
11397 : 0 : main_mem_base = HC_REG_MAIN_MEMORY +
11398 : 0 : SC_PORT(sc) * (main_mem_size * 4);
11399 : : main_mem_prty_clr = HC_REG_HC_PRTY_STS_CLR;
11400 : : main_mem_width = 8;
11401 : :
11402 : : val = REG_RD(sc, main_mem_prty_clr);
11403 [ # # ]: 0 : if (val) {
11404 : 0 : PMD_DRV_LOG(DEBUG, sc,
11405 : : "Parity errors in HC block during function init (0x%x)!",
11406 : : val);
11407 : : }
11408 : :
11409 : : /* Clear "false" parity errors in MSI-X table */
11410 : : for (i = main_mem_base;
11411 [ # # ]: 0 : i < main_mem_base + main_mem_size * 4;
11412 : 0 : i += main_mem_width) {
11413 : 0 : bnx2x_read_dmae(sc, i, main_mem_width / 4);
11414 : 0 : bnx2x_write_dmae(sc, BNX2X_SP_MAPPING(sc, wb_data),
11415 : : i, main_mem_width / 4);
11416 : : }
11417 : : /* Clear HC parity attention */
11418 : : REG_RD(sc, main_mem_prty_clr);
11419 : : }
11420 : :
11421 : : /* Enable STORMs SP logging */
11422 : 0 : REG_WR8(sc, BAR_USTRORM_INTMEM +
11423 : : USTORM_RECORD_SLOW_PATH_OFFSET(SC_FUNC(sc)), 1);
11424 : 0 : REG_WR8(sc, BAR_TSTRORM_INTMEM +
11425 : : TSTORM_RECORD_SLOW_PATH_OFFSET(SC_FUNC(sc)), 1);
11426 : 0 : REG_WR8(sc, BAR_CSTRORM_INTMEM +
11427 : : CSTORM_RECORD_SLOW_PATH_OFFSET(SC_FUNC(sc)), 1);
11428 : 0 : REG_WR8(sc, BAR_XSTRORM_INTMEM +
11429 : : XSTORM_RECORD_SLOW_PATH_OFFSET(SC_FUNC(sc)), 1);
11430 : :
11431 : 0 : elink_phy_probe(&sc->link_params);
11432 : :
11433 : 0 : return 0;
11434 : : }
11435 : :
11436 : 0 : static void bnx2x_link_reset(struct bnx2x_softc *sc)
11437 : : {
11438 [ # # ]: 0 : if (!BNX2X_NOMCP(sc)) {
11439 : 0 : bnx2x_acquire_phy_lock(sc);
11440 : 0 : elink_lfa_reset(&sc->link_params, &sc->link_vars);
11441 : : bnx2x_release_phy_lock(sc);
11442 : : } else {
11443 [ # # ]: 0 : if (!CHIP_REV_IS_SLOW(sc)) {
11444 : 0 : PMD_DRV_LOG(WARNING, sc,
11445 : : "Bootcode is missing - cannot reset link");
11446 : : }
11447 : : }
11448 : 0 : }
11449 : :
11450 : 0 : static void bnx2x_reset_port(struct bnx2x_softc *sc)
11451 : : {
11452 : 0 : int port = SC_PORT(sc);
11453 : : uint32_t val;
11454 : :
11455 : : /* reset physical Link */
11456 : 0 : bnx2x_link_reset(sc);
11457 : :
11458 : 0 : REG_WR(sc, NIG_REG_MASK_INTERRUPT_PORT0 + port * 4, 0);
11459 : :
11460 : : /* Do not rcv packets to BRB */
11461 : 0 : REG_WR(sc, NIG_REG_LLH0_BRB1_DRV_MASK + port * 4, 0x0);
11462 : : /* Do not direct rcv packets that are not for MCP to the BRB */
11463 [ # # ]: 0 : REG_WR(sc, (port ? NIG_REG_LLH1_BRB1_NOT_MCP :
11464 : : NIG_REG_LLH0_BRB1_NOT_MCP), 0x0);
11465 : :
11466 : : /* Configure AEU */
11467 : 0 : REG_WR(sc, MISC_REG_AEU_MASK_ATTN_FUNC_0 + port * 4, 0);
11468 : :
11469 : 0 : DELAY(100000);
11470 : :
11471 : : /* Check for BRB port occupancy */
11472 : 0 : val = REG_RD(sc, BRB1_REG_PORT_NUM_OCC_BLOCKS_0 + port * 4);
11473 [ # # ]: 0 : if (val) {
11474 : 0 : PMD_DRV_LOG(DEBUG, sc,
11475 : : "BRB1 is not empty, %d blocks are occupied", val);
11476 : : }
11477 : 0 : }
11478 : :
11479 : 0 : static void bnx2x_ilt_wr(struct bnx2x_softc *sc, uint32_t index, rte_iova_t addr)
11480 : : {
11481 : : int reg;
11482 : : uint32_t wb_write[2];
11483 : :
11484 : 0 : reg = PXP2_REG_RQ_ONCHIP_AT_B0 + index * 8;
11485 : :
11486 : 0 : wb_write[0] = ONCHIP_ADDR1(addr);
11487 : 0 : wb_write[1] = ONCHIP_ADDR2(addr);
11488 [ # # ]: 0 : REG_WR_DMAE(sc, reg, wb_write, 2);
11489 : 0 : }
11490 : :
11491 : : static void bnx2x_clear_func_ilt(struct bnx2x_softc *sc, uint32_t func)
11492 : : {
11493 : 0 : uint32_t i, base = FUNC_ILT_BASE(func);
11494 [ # # ]: 0 : for (i = base; i < base + ILT_PER_FUNC; i++) {
11495 : 0 : bnx2x_ilt_wr(sc, i, 0);
11496 : : }
11497 : : }
11498 : :
11499 : 0 : static void bnx2x_reset_func(struct bnx2x_softc *sc)
11500 : : {
11501 : : struct bnx2x_fastpath *fp;
11502 : 0 : int port = SC_PORT(sc);
11503 : : int func = SC_FUNC(sc);
11504 : : int i;
11505 : :
11506 : : /* Disable the function in the FW */
11507 : 0 : REG_WR8(sc, BAR_XSTRORM_INTMEM + XSTORM_FUNC_EN_OFFSET(func), 0);
11508 : 0 : REG_WR8(sc, BAR_CSTRORM_INTMEM + CSTORM_FUNC_EN_OFFSET(func), 0);
11509 : 0 : REG_WR8(sc, BAR_TSTRORM_INTMEM + TSTORM_FUNC_EN_OFFSET(func), 0);
11510 : 0 : REG_WR8(sc, BAR_USTRORM_INTMEM + USTORM_FUNC_EN_OFFSET(func), 0);
11511 : :
11512 : : /* FP SBs */
11513 [ # # ]: 0 : FOR_EACH_ETH_QUEUE(sc, i) {
11514 : : fp = &sc->fp[i];
11515 : 0 : REG_WR8(sc, BAR_CSTRORM_INTMEM +
11516 : : CSTORM_STATUS_BLOCK_DATA_STATE_OFFSET(fp->fw_sb_id),
11517 : : SB_DISABLED);
11518 : : }
11519 : :
11520 : : /* SP SB */
11521 : 0 : REG_WR8(sc, BAR_CSTRORM_INTMEM +
11522 : : CSTORM_SP_STATUS_BLOCK_DATA_STATE_OFFSET(func), SB_DISABLED);
11523 : :
11524 [ # # ]: 0 : for (i = 0; i < XSTORM_SPQ_DATA_SIZE / 4; i++) {
11525 : 0 : REG_WR(sc, BAR_XSTRORM_INTMEM + XSTORM_SPQ_DATA_OFFSET(func),
11526 : : 0);
11527 : : }
11528 : :
11529 : : /* Configure IGU */
11530 [ # # ]: 0 : if (sc->devinfo.int_block == INT_BLOCK_HC) {
11531 : 0 : REG_WR(sc, HC_REG_LEADING_EDGE_0 + port * 8, 0);
11532 : 0 : REG_WR(sc, HC_REG_TRAILING_EDGE_0 + port * 8, 0);
11533 : : } else {
11534 : : REG_WR(sc, IGU_REG_LEADING_EDGE_LATCH, 0);
11535 : : REG_WR(sc, IGU_REG_TRAILING_EDGE_LATCH, 0);
11536 : : }
11537 : :
11538 : : if (CNIC_LOADED(sc)) {
11539 : : /* Disable Timer scan */
11540 : : REG_WR(sc, TM_REG_EN_LINEAR0_TIMER + port * 4, 0);
11541 : : /*
11542 : : * Wait for at least 10ms and up to 2 second for the timers
11543 : : * scan to complete
11544 : : */
11545 : : for (i = 0; i < 200; i++) {
11546 : : DELAY(10000);
11547 : : if (!REG_RD(sc, TM_REG_LIN0_SCAN_ON + port * 4))
11548 : : break;
11549 : : }
11550 : : }
11551 : :
11552 : : /* Clear ILT */
11553 : 0 : bnx2x_clear_func_ilt(sc, func);
11554 : :
11555 : : /*
11556 : : * Timers workaround bug for E2: if this is vnic-3,
11557 : : * we need to set the entire ilt range for this timers.
11558 : : */
11559 [ # # # # ]: 0 : if (!CHIP_IS_E1x(sc) && SC_VN(sc) == 3) {
11560 : : struct ilt_client_info ilt_cli;
11561 : : /* use dummy TM client */
11562 : : memset(&ilt_cli, 0, sizeof(struct ilt_client_info));
11563 : : ilt_cli.start = 0;
11564 : 0 : ilt_cli.end = ILT_NUM_PAGE_ENTRIES - 1;
11565 : 0 : ilt_cli.client_num = ILT_CLIENT_TM;
11566 : :
11567 : 0 : ecore_ilt_boundary_init_op(sc, &ilt_cli, 0, INITOP_CLEAR);
11568 : : }
11569 : :
11570 : : /* this assumes that reset_port() called before reset_func() */
11571 [ # # ]: 0 : if (!CHIP_IS_E1x(sc)) {
11572 : : bnx2x_pf_disable(sc);
11573 : : }
11574 : :
11575 : 0 : sc->dmae_ready = 0;
11576 : 0 : }
11577 : :
11578 : 0 : static void bnx2x_release_firmware(struct bnx2x_softc *sc)
11579 : : {
11580 : 0 : rte_free(sc->init_ops);
11581 : 0 : rte_free(sc->init_ops_offsets);
11582 : 0 : rte_free(sc->init_data);
11583 : 0 : rte_free(sc->iro_array);
11584 : 0 : }
11585 : :
11586 : 0 : static int bnx2x_init_firmware(struct bnx2x_softc *sc)
11587 : : {
11588 : : uint32_t len, i;
11589 : 0 : uint8_t *p = sc->firmware;
11590 : : uint32_t off[24];
11591 : :
11592 [ # # ]: 0 : for (i = 0; i < 24; ++i)
11593 [ # # ]: 0 : off[i] = rte_be_to_cpu_32(*((uint32_t *) sc->firmware + i));
11594 : :
11595 : 0 : len = off[0];
11596 : 0 : sc->init_ops = rte_zmalloc("", len, RTE_CACHE_LINE_SIZE);
11597 [ # # ]: 0 : if (!sc->init_ops)
11598 : 0 : goto alloc_failed;
11599 : 0 : bnx2x_data_to_init_ops(p + off[1], sc->init_ops, len);
11600 : :
11601 : 0 : len = off[2];
11602 : 0 : sc->init_ops_offsets = rte_zmalloc("", len, RTE_CACHE_LINE_SIZE);
11603 [ # # ]: 0 : if (!sc->init_ops_offsets)
11604 : 0 : goto alloc_failed;
11605 : 0 : bnx2x_data_to_init_offsets(p + off[3], sc->init_ops_offsets, len);
11606 : :
11607 : 0 : len = off[4];
11608 : 0 : sc->init_data = rte_zmalloc("", len, RTE_CACHE_LINE_SIZE);
11609 [ # # ]: 0 : if (!sc->init_data)
11610 : 0 : goto alloc_failed;
11611 : 0 : bnx2x_data_to_init_data(p + off[5], sc->init_data, len);
11612 : :
11613 : 0 : sc->tsem_int_table_data = p + off[7];
11614 : 0 : sc->tsem_pram_data = p + off[9];
11615 : 0 : sc->usem_int_table_data = p + off[11];
11616 : 0 : sc->usem_pram_data = p + off[13];
11617 : 0 : sc->csem_int_table_data = p + off[15];
11618 : 0 : sc->csem_pram_data = p + off[17];
11619 : 0 : sc->xsem_int_table_data = p + off[19];
11620 : 0 : sc->xsem_pram_data = p + off[21];
11621 : :
11622 : 0 : len = off[22];
11623 : 0 : sc->iro_array = rte_zmalloc("", len, RTE_CACHE_LINE_SIZE);
11624 [ # # ]: 0 : if (!sc->iro_array)
11625 : 0 : goto alloc_failed;
11626 : 0 : bnx2x_data_to_iro_array(p + off[23], sc->iro_array, len);
11627 : :
11628 : 0 : return 0;
11629 : :
11630 : 0 : alloc_failed:
11631 : 0 : bnx2x_release_firmware(sc);
11632 : 0 : return -1;
11633 : : }
11634 : :
11635 : 0 : static int cut_gzip_prefix(const uint8_t * zbuf, int len)
11636 : : {
11637 : : #define MIN_PREFIX_SIZE (10)
11638 : :
11639 : : int n = MIN_PREFIX_SIZE;
11640 : : uint16_t xlen;
11641 : :
11642 [ # # # # : 0 : if (!(zbuf[0] == 0x1f && zbuf[1] == 0x8b && zbuf[2] == Z_DEFLATED) ||
# # # # ]
11643 : : len <= MIN_PREFIX_SIZE) {
11644 : : return -1;
11645 : : }
11646 : :
11647 : : /* optional extra fields are present */
11648 [ # # ]: 0 : if (zbuf[3] & 0x4) {
11649 : 0 : xlen = zbuf[13];
11650 : 0 : xlen <<= 8;
11651 : 0 : xlen += zbuf[12];
11652 : :
11653 : 0 : n += xlen;
11654 : : }
11655 : : /* file name is present */
11656 [ # # ]: 0 : if (zbuf[3] & 0x8) {
11657 [ # # # # ]: 0 : while ((zbuf[n++] != 0) && (n < len)) ;
11658 : : }
11659 : :
11660 : : return n;
11661 : : }
11662 : :
11663 : 0 : static int ecore_gunzip(struct bnx2x_softc *sc, const uint8_t * zbuf, int len)
11664 : : {
11665 : : int ret;
11666 : 0 : int data_begin = cut_gzip_prefix(zbuf, len);
11667 : :
11668 : 0 : PMD_DRV_LOG(DEBUG, sc, "ecore_gunzip %d", len);
11669 : :
11670 [ # # ]: 0 : if (data_begin <= 0) {
11671 : 0 : PMD_DRV_LOG(NOTICE, sc, "bad gzip prefix");
11672 : 0 : return -1;
11673 : : }
11674 : :
11675 : : memset(&zlib_stream, 0, sizeof(zlib_stream));
11676 : 0 : zlib_stream.next_in = zbuf + data_begin;
11677 : 0 : zlib_stream.avail_in = len - data_begin;
11678 : 0 : zlib_stream.next_out = sc->gz_buf;
11679 : 0 : zlib_stream.avail_out = FW_BUF_SIZE;
11680 : :
11681 : 0 : ret = inflateInit2(&zlib_stream, -MAX_WBITS);
11682 [ # # ]: 0 : if (ret != Z_OK) {
11683 : 0 : PMD_DRV_LOG(NOTICE, sc, "zlib inflateInit2 error");
11684 : 0 : return ret;
11685 : : }
11686 : :
11687 : 0 : ret = inflate(&zlib_stream, Z_FINISH);
11688 [ # # ]: 0 : if ((ret != Z_STREAM_END) && (ret != Z_OK)) {
11689 : 0 : PMD_DRV_LOG(NOTICE, sc, "zlib inflate error: %d %s", ret,
11690 : : zlib_stream.msg);
11691 : : }
11692 : :
11693 : 0 : sc->gz_outlen = zlib_stream.total_out;
11694 [ # # ]: 0 : if (sc->gz_outlen & 0x3) {
11695 : 0 : PMD_DRV_LOG(NOTICE, sc, "firmware is not aligned. gz_outlen == %d",
11696 : : sc->gz_outlen);
11697 : : }
11698 : 0 : sc->gz_outlen >>= 2;
11699 : :
11700 : 0 : inflateEnd(&zlib_stream);
11701 : :
11702 [ # # ]: 0 : if (ret == Z_STREAM_END)
11703 : 0 : return 0;
11704 : :
11705 : : return ret;
11706 : : }
11707 : :
11708 : : static void
11709 : : ecore_write_dmae_phys_len(struct bnx2x_softc *sc, rte_iova_t phys_addr,
11710 : : uint32_t addr, uint32_t len)
11711 : : {
11712 : 0 : bnx2x_write_dmae_phys_len(sc, phys_addr, addr, len);
11713 : 0 : }
11714 : :
11715 : : void
11716 : 0 : ecore_storm_memset_struct(struct bnx2x_softc *sc, uint32_t addr, size_t size,
11717 : : uint32_t * data)
11718 : : {
11719 : : uint8_t i;
11720 [ # # ]: 0 : for (i = 0; i < size / 4; i++) {
11721 : 0 : REG_WR(sc, addr + (i * 4), data[i]);
11722 : : }
11723 : 0 : }
11724 : :
11725 : : static const char *get_ext_phy_type(uint32_t ext_phy_type)
11726 : : {
11727 : 0 : uint32_t phy_type_idx = ext_phy_type >> 8;
11728 : : static const char *types[] =
11729 : : { "DIRECT", "BNX2X-8071", "BNX2X-8072", "BNX2X-8073",
11730 : : "BNX2X-8705", "BNX2X-8706", "BNX2X-8726", "BNX2X-8481", "SFX-7101",
11731 : : "BNX2X-8727",
11732 : : "BNX2X-8727-NOC", "BNX2X-84823", "NOT_CONN", "FAILURE"
11733 : : };
11734 : :
11735 [ # # ]: 0 : if (phy_type_idx < 12)
11736 : 0 : return types[phy_type_idx];
11737 [ # # ]: 0 : else if (PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN == ext_phy_type)
11738 : 0 : return types[12];
11739 : : else
11740 : 0 : return types[13];
11741 : : }
11742 : :
11743 : : static const char *get_state(uint32_t state)
11744 : : {
11745 : 0 : uint32_t state_idx = state >> 12;
11746 : : static const char *states[] = { "CLOSED", "OPENING_WAIT4_LOAD",
11747 : : "OPENING_WAIT4_PORT", "OPEN", "CLOSING_WAIT4_HALT",
11748 : : "CLOSING_WAIT4_DELETE", "CLOSING_WAIT4_UNLOAD",
11749 : : "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN",
11750 : : "UNKNOWN", "DISABLED", "DIAG", "ERROR", "UNDEFINED"
11751 : : };
11752 : :
11753 : 0 : if (state_idx <= 0xF)
11754 : 0 : return states[state_idx];
11755 : : else
11756 : 0 : return states[0x10];
11757 : : }
11758 : :
11759 : : static const char *get_recovery_state(uint32_t state)
11760 : : {
11761 : : static const char *states[] = { "NONE", "DONE", "INIT",
11762 : : "WAIT", "FAILED", "NIC_LOADING"
11763 : : };
11764 : 0 : return states[state];
11765 : : }
11766 : :
11767 : : static const char *get_rx_mode(uint32_t mode)
11768 : : {
11769 : : static const char *modes[] = { "NONE", "NORMAL", "ALLMULTI",
11770 : : "PROMISC", "MAX_MULTICAST", "ERROR"
11771 : : };
11772 : :
11773 : 0 : if (mode < 0x4)
11774 : 0 : return modes[mode];
11775 [ # # ]: 0 : else if (BNX2X_MAX_MULTICAST == mode)
11776 : 0 : return modes[4];
11777 : : else
11778 : 0 : return modes[5];
11779 : : }
11780 : :
11781 : : #define BNX2X_INFO_STR_MAX 256
11782 : 0 : static const char *get_bnx2x_flags(uint32_t flags)
11783 : : {
11784 : : int i;
11785 : : static const char *flag[] = { "ONE_PORT ", "NO_ISCSI ",
11786 : : "NO_FCOE ", "NO_WOL ", "USING_DAC ", "USING_MSIX ",
11787 : : "USING_MSI ", "DISABLE_MSI ", "UNKNOWN ", "NO_MCP ",
11788 : : "SAFC_TX_FLAG ", "MF_FUNC_DIS ", "TX_SWITCHING "
11789 : : };
11790 : : static char flag_str[BNX2X_INFO_STR_MAX];
11791 : : memset(flag_str, 0, BNX2X_INFO_STR_MAX);
11792 : :
11793 [ # # ]: 0 : for (i = 0; i < 5; i++)
11794 [ # # ]: 0 : if (flags & (1 << i)) {
11795 : 0 : strlcat(flag_str, flag[i], sizeof(flag_str));
11796 : 0 : flags ^= (1 << i);
11797 : : }
11798 [ # # ]: 0 : if (flags) {
11799 : : static char unknown[BNX2X_INFO_STR_MAX];
11800 : : snprintf(unknown, 32, "Unknown flag mask %x", flags);
11801 : 0 : strlcat(flag_str, unknown, sizeof(flag_str));
11802 : : }
11803 : 0 : return flag_str;
11804 : : }
11805 : :
11806 : : /* Prints useful adapter info. */
11807 : 0 : void bnx2x_print_adapter_info(struct bnx2x_softc *sc)
11808 : : {
11809 : : int i = 0;
11810 : :
11811 : 0 : PMD_DRV_LOG(INFO, sc, "========================================");
11812 : : /* DPDK and Driver versions */
11813 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "DPDK",
11814 : : rte_version());
11815 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "Driver",
11816 : : bnx2x_pmd_version());
11817 : : /* Firmware versions. */
11818 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %d.%d.%d",
11819 : : "Firmware",
11820 : : BNX2X_5710_FW_MAJOR_VERSION,
11821 : : BNX2X_5710_FW_MINOR_VERSION,
11822 : : BNX2X_5710_FW_REVISION_VERSION);
11823 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s",
11824 : : "Bootcode", sc->devinfo.bc_ver_str);
11825 : : /* Hardware chip info. */
11826 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %#08x", "ASIC", sc->devinfo.chip_id);
11827 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %c%d", "Rev", (CHIP_REV(sc) >> 12) + 'A',
11828 : : (CHIP_METAL(sc) >> 4));
11829 : : /* Bus PCIe info. */
11830 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : 0x%x", "Vendor Id",
11831 : : sc->devinfo.vendor_id);
11832 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : 0x%x", "Device Id",
11833 : : sc->devinfo.device_id);
11834 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : width x%d, ", "Bus PCIe",
11835 : : sc->devinfo.pcie_link_width);
11836 [ # # # # ]: 0 : switch (sc->devinfo.pcie_link_speed) {
11837 : : case 1:
11838 : 0 : PMD_DRV_LOG(INFO, sc, "%23s", "2.5 Gbps");
11839 : 0 : break;
11840 : : case 2:
11841 : 0 : PMD_DRV_LOG(INFO, sc, "%21s", "5 Gbps");
11842 : 0 : break;
11843 : : case 4:
11844 : 0 : PMD_DRV_LOG(INFO, sc, "%21s", "8 Gbps");
11845 : 0 : break;
11846 : : default:
11847 : 0 : PMD_DRV_LOG(INFO, sc, "%33s", "Unknown link speed");
11848 : : }
11849 : : /* Device features. */
11850 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : ", "Flags");
11851 : : /* Miscellaneous flags. */
11852 [ # # ]: 0 : if (sc->devinfo.pcie_cap_flags & BNX2X_MSI_CAPABLE_FLAG) {
11853 : 0 : PMD_DRV_LOG(INFO, sc, "%18s", "MSI");
11854 : : i++;
11855 : : }
11856 [ # # ]: 0 : if (sc->devinfo.pcie_cap_flags & BNX2X_MSIX_CAPABLE_FLAG) {
11857 [ # # ]: 0 : if (i > 0)
11858 : 0 : PMD_DRV_LOG(INFO, sc, "|");
11859 : 0 : PMD_DRV_LOG(INFO, sc, "%20s", "MSI-X");
11860 : : i++;
11861 : : }
11862 [ # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "OVLAN", (OVLAN(sc) ? "YES" : "NO"));
11863 [ # # # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "MF", (IS_MF(sc) ? "YES" : "NO"));
11864 : 0 : PMD_DRV_LOG(INFO, sc, "========================================");
11865 : 0 : }
11866 : :
11867 : : /* Prints useful device info. */
11868 : 0 : void bnx2x_print_device_info(struct bnx2x_softc *sc)
11869 : : {
11870 : : __rte_unused uint32_t ext_phy_type;
11871 : : uint32_t offset, reg_val;
11872 : :
11873 : 0 : PMD_INIT_FUNC_TRACE(sc);
11874 : : offset = offsetof(struct shmem_region,
11875 : : dev_info.port_hw_config[0].external_phy_config);
11876 : 0 : reg_val = REG_RD(sc, sc->devinfo.shmem_base + offset);
11877 [ # # ]: 0 : if (sc->link_vars.phy_flags & PHY_XGXS_FLAG)
11878 : 0 : ext_phy_type = ELINK_XGXS_EXT_PHY_TYPE(reg_val);
11879 : : else
11880 : 0 : ext_phy_type = ELINK_SERDES_EXT_PHY_TYPE(reg_val);
11881 : :
11882 : : /* Device features. */
11883 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %u", "Bnx2x Func", sc->pcie_func);
11884 : 0 : PMD_DRV_LOG(INFO, sc,
11885 : : "%12s : %s", "Bnx2x Flags", get_bnx2x_flags(sc->flags));
11886 [ # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "DMAE Is",
11887 : : (sc->dmae_ready ? "Ready" : "Not Ready"));
11888 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %u", "MTU", sc->mtu);
11889 : 0 : PMD_DRV_LOG(INFO, sc,
11890 : : "%12s : %s", "PHY Type", get_ext_phy_type(ext_phy_type));
11891 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : " RTE_ETHER_ADDR_PRT_FMT, "MAC Addr",
11892 : : sc->link_params.mac_addr[0],
11893 : : sc->link_params.mac_addr[1],
11894 : : sc->link_params.mac_addr[2],
11895 : : sc->link_params.mac_addr[3],
11896 : : sc->link_params.mac_addr[4],
11897 : : sc->link_params.mac_addr[5]);
11898 [ # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "RX Mode", get_rx_mode(sc->rx_mode));
11899 [ # # ]: 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "State", get_state(sc->state));
11900 [ # # ]: 0 : if (sc->recovery_state)
11901 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "Recovery",
11902 : : get_recovery_state(sc->recovery_state));
11903 : : /* Queue info. */
11904 [ # # ]: 0 : if (IS_PF(sc)) {
11905 [ # # # ]: 0 : switch (sc->sp->rss_rdata.rss_mode) {
11906 : : case ETH_RSS_MODE_DISABLED:
11907 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "Queues", "RSS mode - None");
11908 : 0 : break;
11909 : : case ETH_RSS_MODE_REGULAR:
11910 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s,", "Queues", "RSS mode - Regular");
11911 : 0 : PMD_DRV_LOG(INFO, sc, "%16d", sc->num_queues);
11912 : 0 : break;
11913 : : default:
11914 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : %s", "Queues", "RSS mode - Unknown");
11915 : 0 : break;
11916 : : }
11917 : : }
11918 : 0 : PMD_DRV_LOG(INFO, sc, "%12s : CQ = %lx, EQ = %lx", "SPQ Left",
11919 : : sc->cq_spq_left, sc->eq_spq_left);
11920 : :
11921 : 0 : PMD_DRV_LOG(INFO, sc,
11922 : : "%12s : %x", "Switch", sc->link_params.switch_cfg);
11923 : 0 : PMD_DRV_LOG(INFO, sc, "pcie_bus=%d, pcie_device=%d",
11924 : : sc->pcie_bus, sc->pcie_device);
11925 : 0 : PMD_DRV_LOG(INFO, sc, "bar0.addr=%p, bar1.addr=%p",
11926 : : sc->bar[BAR0].base_addr, sc->bar[BAR1].base_addr);
11927 : 0 : PMD_DRV_LOG(INFO, sc, "port=%d, path=%d, vnic=%d, func=%d",
11928 : : PORT_ID(sc), PATH_ID(sc), VNIC_ID(sc), FUNC_ID(sc));
11929 : 0 : }
|