15 #ifndef BNX2X_INIT_OPS_H
16 #define BNX2X_INIT_OPS_H
20 #define BP_ILT(bp) NULL
31 #ifndef BNX2X_ILT_FREE
32 #define BNX2X_ILT_FREE(x, y, sz)
35 #ifndef BNX2X_ILT_ZALLOC
36 #define BNX2X_ILT_ZALLOC(x, y, sz)
43 static int bnx2x_gunzip(
struct bnx2x *bp,
const u8 *zbuf,
int len);
45 static void bnx2x_write_dmae_phys_len(
struct bnx2x *bp,
49 static void bnx2x_init_str_wr(
struct bnx2x *bp,
u32 addr,
54 for (i = 0; i < len; i++)
55 REG_WR(bp, addr + i*4, data[i]);
58 static void bnx2x_init_ind_wr(
struct bnx2x *bp,
u32 addr,
63 for (i = 0; i < len; i++)
64 bnx2x_reg_wr_ind(bp, addr + i*4, data[i]);
67 static void bnx2x_write_big_buf(
struct bnx2x *bp,
u32 addr,
u32 len,
71 bnx2x_write_dmae_phys_len(bp,
GUNZIP_PHYS(bp), addr, len);
75 bnx2x_init_ind_wr(bp, addr,
GUNZIP_BUF(bp), len);
79 bnx2x_init_str_wr(bp, addr,
GUNZIP_BUF(bp), len);
82 static void bnx2x_init_fill(
struct bnx2x *bp,
u32 addr,
int fill,
86 u32 buf_len32 = buf_len/4;
91 for (i = 0; i < len; i += buf_len32) {
92 u32 cur_len =
min(buf_len32, len - i);
94 bnx2x_write_big_buf(bp, addr + i*4, cur_len, wb);
98 static void bnx2x_write_big_buf_wb(
struct bnx2x *bp,
u32 addr,
u32 len)
101 bnx2x_write_dmae_phys_len(bp,
GUNZIP_PHYS(bp), addr, len);
105 bnx2x_init_ind_wr(bp, addr,
GUNZIP_BUF(bp), len);
109 bnx2x_init_str_wr(bp, addr,
GUNZIP_BUF(bp), len);
112 static void bnx2x_init_wr_64(
struct bnx2x *bp,
u32 addr,
113 const u32 *data,
u32 len64)
121 data64 =
HILO_U64((*(data + 1)), (*data));
124 for (i = 0; i < len64; i++) {
130 for (i = 0; i < len; i += buf_len32) {
131 u32 cur_len =
min(buf_len32, len - i);
133 bnx2x_write_big_buf_wb(bp, addr + i*4, cur_len);
145 #define IF_IS_INT_TABLE_ADDR(base, addr) \
146 if (((base) <= (addr)) && ((base) + 0x400 >= (addr)))
148 #define IF_IS_PRAM_ADDR(base, addr) \
149 if (((base) <= (addr)) && ((base) + 0x40000 >= (addr)))
151 static const u8 *bnx2x_sel_blob(
struct bnx2x *bp,
u32 addr,
181 static void bnx2x_init_wr_wb(
struct bnx2x *bp,
u32 addr,
189 bnx2x_init_ind_wr(bp, addr, data, len);
193 bnx2x_init_str_wr(bp, addr, data, len);
201 wb_write[0] = val_lo;
202 wb_write[1] = val_hi;
205 static void bnx2x_init_wr_zp(
struct bnx2x *bp,
u32 addr,
u32 len,
212 data = bnx2x_sel_blob(bp, addr, data) + blob_off*4;
214 rc = bnx2x_gunzip(bp, data, len);
220 for (i = 0; i < len; i++)
224 bnx2x_write_big_buf_wb(bp, addr, len);
240 if (op_start == op_end)
245 for (op_idx = op_start; op_idx < op_end; op_idx++) {
249 op_type = op->
raw.op;
250 addr = op->
raw.offset;
255 len = op->
arr_wr.data_len;
256 data = data_base + op->
arr_wr.data_off;
266 bnx2x_init_str_wr(bp, addr, data, len);
269 bnx2x_init_wr_wb(bp, addr, data, len);
272 bnx2x_init_fill(bp, addr, 0, op->
zero.len, 0);
275 bnx2x_init_fill(bp, addr, 0, op->
zero.len, 1);
278 bnx2x_init_wr_zp(bp, addr, len,
282 bnx2x_init_wr_64(bp, addr, data, len);
291 op_idx += op->
if_mode.cmd_offset;
298 op->
if_mode.mode_bit_map) == 0)
299 op_idx += op->
if_mode.cmd_offset;
337 { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
338 { {4, 8, 4}, {4, 8, 4}, {4, 8, 4}, {4, 8, 4} },
339 { {4, 3, 3}, {4, 3, 3}, {4, 3, 3}, {4, 3, 3} },
340 { {8, 3, 6}, {16, 3, 11}, {16, 3, 11}, {16, 3, 11} },
341 { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
342 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
343 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
344 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
345 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
346 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
347 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
348 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
349 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
350 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
351 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
352 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
353 { {8, 64, 6}, {16, 64, 11}, {32, 64, 21}, {32, 64, 21} },
354 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
355 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
356 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
357 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
358 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
359 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
360 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
361 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
362 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
363 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
364 { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
365 { {8, 64, 25}, {16, 64, 41}, {32, 64, 81}, {64, 64, 120} }
370 { {4, 6, 3}, {4, 6, 3}, {4, 6, 3} },
371 { {4, 2, 3}, {4, 2, 3}, {4, 2, 3} },
372 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
373 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
374 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
375 { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
376 { {8, 64, 25}, {16, 64, 25}, {32, 64, 25} },
377 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
378 { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
379 { {8, 9, 6}, {16, 9, 11}, {32, 9, 21} },
380 { {8, 47, 19}, {16, 47, 19}, {32, 47, 21} },
381 { {8, 9, 6}, {16, 9, 11}, {16, 9, 11} },
382 { {8, 64, 25}, {16, 64, 41}, {32, 64, 81} }
473 static void bnx2x_init_pxp_arb(
struct bnx2x *bp,
int r_order,
492 DP(
NETIF_MSG_HW,
"read order %d write order %d\n", r_order, w_order);
495 REG_WR(bp, read_arb_addr[i].
l, read_arb_data[i][r_order].l);
497 read_arb_data[i][r_order].add);
499 read_arb_data[i][r_order].ubound);
506 REG_WR(bp, write_arb_addr[i].
l,
507 write_arb_data[i][w_order].l);
510 write_arb_data[i][w_order].add);
513 write_arb_data[i][w_order].ubound);
516 val =
REG_RD(bp, write_arb_addr[i].
l);
517 REG_WR(bp, write_arb_addr[i].
l,
518 val | (write_arb_data[i][w_order].l << 10));
522 val | (write_arb_data[i][w_order].add << 10));
526 val | (write_arb_data[i][w_order].ubound << 7));
530 val = write_arb_data[NUM_WR_Q-1][w_order].
add;
531 val += write_arb_data[NUM_WR_Q-1][w_order].
ubound << 10;
532 val += write_arb_data[NUM_WR_Q-1][w_order].
l << 17;
535 val = read_arb_data[NUM_RD_Q-1][r_order].
add;
536 val += read_arb_data[NUM_RD_Q-1][r_order].
ubound << 10;
537 val += read_arb_data[NUM_RD_Q-1][r_order].
l << 17;
567 val = ((w_order == 0) ? 2 : 3);
584 #define PCIE_REG_PCIER_TL_HDR_FC_ST 0x2980
585 val =
REG_RD(bp, PCIE_REG_PCIER_TL_HDR_FC_ST);
604 #define ILT_MEMOP_ALLOC 0
605 #define ILT_MEMOP_FREE 1
612 #define ILT_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
613 #define ILT_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
614 #define ILT_RANGE(f, l) (((l) << 10) | f)
616 static int bnx2x_ilt_line_mem_op(
struct bnx2x *bp,
631 static int bnx2x_ilt_client_mem_op(
struct bnx2x *bp,
int cli_num,
638 if (!ilt || !ilt->
lines)
644 for (rc = 0, i = ilt_cli->
start; i <= ilt_cli->
end && !rc; i++) {
645 rc = bnx2x_ilt_line_mem_op(bp, &ilt->
lines[i],
651 static int bnx2x_ilt_mem_op(
struct bnx2x *bp,
u8 memop)
664 static void bnx2x_ilt_line_wr(
struct bnx2x *bp,
int abs_idx,
677 static void bnx2x_ilt_line_init_op(
struct bnx2x *bp,
688 bnx2x_ilt_line_wr(bp, abs_idx, ilt->
lines[idx].page_mapping);
692 bnx2x_ilt_line_wr(bp, abs_idx, null_mapping);
697 static void bnx2x_ilt_boundry_init_op(
struct bnx2x *bp,
699 u32 ilt_start,
u8 initop)
725 (ilt_start + ilt_cli->
end)));
745 REG_WR(bp, start_reg, (ilt_start + ilt_cli->
start));
746 REG_WR(bp, end_reg, (ilt_start + ilt_cli->
end));
750 static void bnx2x_ilt_client_init_op_ilt(
struct bnx2x *bp,
760 for (i = ilt_cli->
start; i <= ilt_cli->
end; i++)
761 bnx2x_ilt_line_init_op(bp, ilt, i, initop);
764 bnx2x_ilt_boundry_init_op(bp, ilt_cli, ilt->
start_line, initop);
767 static void bnx2x_ilt_client_init_op(
struct bnx2x *bp,
772 bnx2x_ilt_client_init_op_ilt(bp, ilt, ilt_cli, initop);
775 static void bnx2x_ilt_client_id_init_op(
struct bnx2x *bp,
776 int cli_num,
u8 initop)
781 bnx2x_ilt_client_init_op(bp, ilt_cli, initop);
784 static void bnx2x_ilt_init_op(
struct bnx2x *bp,
u8 initop)
792 static void bnx2x_ilt_init_client_psz(
struct bnx2x *bp,
int cli_num,
793 u32 psz_reg,
u8 initop)
816 static void bnx2x_ilt_init_page_size(
struct bnx2x *bp,
u8 initop)
831 #define QM_QUEUES_PER_FUNC 16
832 #define QM_INIT_MIN_CID_COUNT 31
833 #define QM_INIT(cid_cnt) (cid_cnt > QM_INIT_MIN_CID_COUNT)
836 static void bnx2x_qm_init_cid_count(
struct bnx2x *bp,
int qm_cid_count,
847 qm_cid_count/16 - 1);
855 static void bnx2x_qm_set_ptr_table(
struct bnx2x *bp,
int qm_cid_count,
859 u32 wb_data[2] = {0, 0};
861 REG_WR(bp, base_reg + i*4,
862 qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC));
863 bnx2x_init_wr_wb(bp, reg + i*8, wb_data, 2);
868 static void bnx2x_qm_init_ptr_table(
struct bnx2x *bp,
int qm_cid_count,
878 bnx2x_qm_set_ptr_table(bp, qm_cid_count,
881 bnx2x_qm_set_ptr_table(bp, qm_cid_count,
895 static void bnx2x_src_init_t2(
struct bnx2x *bp,
struct src_ent *
t2,
902 for (i = 0; i < src_cid_count-1; i++)
903 t2[i].
next = (
u64)(t2_mapping +
914 (src_cid_count-1) *
sizeof(
struct src_ent)),
916 (src_cid_count-1) *
sizeof(
struct src_ent)));