14ad79e13SYuval Mintz /* bnx2x_init_ops.h: Qlogic Everest network driver.
2adfc5217SJeff Kirsher * Static functions needed during the initialization.
3adfc5217SJeff Kirsher * This file is "included" in bnx2x_main.c.
4adfc5217SJeff Kirsher *
5247fa82bSYuval Mintz * Copyright (c) 2007-2013 Broadcom Corporation
64ad79e13SYuval Mintz * Copyright (c) 2014 QLogic Corporation
74ad79e13SYuval Mintz All rights reserved
8adfc5217SJeff Kirsher *
9adfc5217SJeff Kirsher * This program is free software; you can redistribute it and/or modify
10adfc5217SJeff Kirsher * it under the terms of the GNU General Public License as published by
11adfc5217SJeff Kirsher * the Free Software Foundation.
12adfc5217SJeff Kirsher *
1308f6dd89SAriel Elior * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
1408f6dd89SAriel Elior * Written by: Vladislav Zolotarov
15adfc5217SJeff Kirsher */
16adfc5217SJeff Kirsher
17adfc5217SJeff Kirsher #ifndef BNX2X_INIT_OPS_H
18adfc5217SJeff Kirsher #define BNX2X_INIT_OPS_H
19adfc5217SJeff Kirsher
20adfc5217SJeff Kirsher
21adfc5217SJeff Kirsher #ifndef BP_ILT
22adfc5217SJeff Kirsher #define BP_ILT(bp) NULL
23adfc5217SJeff Kirsher #endif
24adfc5217SJeff Kirsher
25adfc5217SJeff Kirsher #ifndef BP_FUNC
26adfc5217SJeff Kirsher #define BP_FUNC(bp) 0
27adfc5217SJeff Kirsher #endif
28adfc5217SJeff Kirsher
29adfc5217SJeff Kirsher #ifndef BP_PORT
30adfc5217SJeff Kirsher #define BP_PORT(bp) 0
31adfc5217SJeff Kirsher #endif
32adfc5217SJeff Kirsher
33adfc5217SJeff Kirsher #ifndef BNX2X_ILT_FREE
34adfc5217SJeff Kirsher #define BNX2X_ILT_FREE(x, y, sz)
35adfc5217SJeff Kirsher #endif
36adfc5217SJeff Kirsher
37adfc5217SJeff Kirsher #ifndef BNX2X_ILT_ZALLOC
38adfc5217SJeff Kirsher #define BNX2X_ILT_ZALLOC(x, y, sz)
39adfc5217SJeff Kirsher #endif
40adfc5217SJeff Kirsher
41adfc5217SJeff Kirsher #ifndef ILOG2
42adfc5217SJeff Kirsher #define ILOG2(x) x
43adfc5217SJeff Kirsher #endif
44adfc5217SJeff Kirsher
45adfc5217SJeff Kirsher static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len);
46adfc5217SJeff Kirsher static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
47adfc5217SJeff Kirsher static void bnx2x_write_dmae_phys_len(struct bnx2x *bp,
48adfc5217SJeff Kirsher dma_addr_t phys_addr, u32 addr,
49adfc5217SJeff Kirsher u32 len);
50adfc5217SJeff Kirsher
bnx2x_init_str_wr(struct bnx2x * bp,u32 addr,const u32 * data,u32 len)51adfc5217SJeff Kirsher static void bnx2x_init_str_wr(struct bnx2x *bp, u32 addr,
52adfc5217SJeff Kirsher const u32 *data, u32 len)
53adfc5217SJeff Kirsher {
54adfc5217SJeff Kirsher u32 i;
55adfc5217SJeff Kirsher
56adfc5217SJeff Kirsher for (i = 0; i < len; i++)
57adfc5217SJeff Kirsher REG_WR(bp, addr + i*4, data[i]);
58adfc5217SJeff Kirsher }
59adfc5217SJeff Kirsher
bnx2x_init_ind_wr(struct bnx2x * bp,u32 addr,const u32 * data,u32 len)60adfc5217SJeff Kirsher static void bnx2x_init_ind_wr(struct bnx2x *bp, u32 addr,
61adfc5217SJeff Kirsher const u32 *data, u32 len)
62adfc5217SJeff Kirsher {
63adfc5217SJeff Kirsher u32 i;
64adfc5217SJeff Kirsher
65adfc5217SJeff Kirsher for (i = 0; i < len; i++)
66adfc5217SJeff Kirsher bnx2x_reg_wr_ind(bp, addr + i*4, data[i]);
67adfc5217SJeff Kirsher }
68adfc5217SJeff Kirsher
bnx2x_write_big_buf(struct bnx2x * bp,u32 addr,u32 len,u8 wb)69adfc5217SJeff Kirsher static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len,
70adfc5217SJeff Kirsher u8 wb)
71adfc5217SJeff Kirsher {
72adfc5217SJeff Kirsher if (bp->dmae_ready)
73adfc5217SJeff Kirsher bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len);
74127a425eSAriel Elior
75127a425eSAriel Elior /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
76127a425eSAriel Elior else if (wb && CHIP_IS_E1(bp))
77adfc5217SJeff Kirsher bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len);
78127a425eSAriel Elior
79127a425eSAriel Elior /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
80adfc5217SJeff Kirsher else
81adfc5217SJeff Kirsher bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len);
82adfc5217SJeff Kirsher }
83adfc5217SJeff Kirsher
bnx2x_init_fill(struct bnx2x * bp,u32 addr,int fill,u32 len,u8 wb)84adfc5217SJeff Kirsher static void bnx2x_init_fill(struct bnx2x *bp, u32 addr, int fill,
85adfc5217SJeff Kirsher u32 len, u8 wb)
86adfc5217SJeff Kirsher {
87adfc5217SJeff Kirsher u32 buf_len = (((len*4) > FW_BUF_SIZE) ? FW_BUF_SIZE : (len*4));
88adfc5217SJeff Kirsher u32 buf_len32 = buf_len/4;
89adfc5217SJeff Kirsher u32 i;
90adfc5217SJeff Kirsher
91adfc5217SJeff Kirsher memset(GUNZIP_BUF(bp), (u8)fill, buf_len);
92adfc5217SJeff Kirsher
93adfc5217SJeff Kirsher for (i = 0; i < len; i += buf_len32) {
94adfc5217SJeff Kirsher u32 cur_len = min(buf_len32, len - i);
95adfc5217SJeff Kirsher
96adfc5217SJeff Kirsher bnx2x_write_big_buf(bp, addr + i*4, cur_len, wb);
97adfc5217SJeff Kirsher }
98adfc5217SJeff Kirsher }
99adfc5217SJeff Kirsher
bnx2x_write_big_buf_wb(struct bnx2x * bp,u32 addr,u32 len)100adfc5217SJeff Kirsher static void bnx2x_write_big_buf_wb(struct bnx2x *bp, u32 addr, u32 len)
101adfc5217SJeff Kirsher {
102adfc5217SJeff Kirsher if (bp->dmae_ready)
103adfc5217SJeff Kirsher bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len);
104127a425eSAriel Elior
105127a425eSAriel Elior /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
106127a425eSAriel Elior else if (CHIP_IS_E1(bp))
107adfc5217SJeff Kirsher bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len);
108127a425eSAriel Elior
109127a425eSAriel Elior /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
110127a425eSAriel Elior else
111127a425eSAriel Elior bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len);
112adfc5217SJeff Kirsher }
113adfc5217SJeff Kirsher
bnx2x_init_wr_64(struct bnx2x * bp,u32 addr,const u32 * data,u32 len64)114adfc5217SJeff Kirsher static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr,
115adfc5217SJeff Kirsher const u32 *data, u32 len64)
116adfc5217SJeff Kirsher {
117adfc5217SJeff Kirsher u32 buf_len32 = FW_BUF_SIZE/4;
118adfc5217SJeff Kirsher u32 len = len64*2;
119adfc5217SJeff Kirsher u64 data64 = 0;
120adfc5217SJeff Kirsher u32 i;
121adfc5217SJeff Kirsher
122adfc5217SJeff Kirsher /* 64 bit value is in a blob: first low DWORD, then high DWORD */
123adfc5217SJeff Kirsher data64 = HILO_U64((*(data + 1)), (*data));
124adfc5217SJeff Kirsher
125adfc5217SJeff Kirsher len64 = min((u32)(FW_BUF_SIZE/8), len64);
126adfc5217SJeff Kirsher for (i = 0; i < len64; i++) {
127adfc5217SJeff Kirsher u64 *pdata = ((u64 *)(GUNZIP_BUF(bp))) + i;
128adfc5217SJeff Kirsher
129adfc5217SJeff Kirsher *pdata = data64;
130adfc5217SJeff Kirsher }
131adfc5217SJeff Kirsher
132adfc5217SJeff Kirsher for (i = 0; i < len; i += buf_len32) {
133adfc5217SJeff Kirsher u32 cur_len = min(buf_len32, len - i);
134adfc5217SJeff Kirsher
135adfc5217SJeff Kirsher bnx2x_write_big_buf_wb(bp, addr + i*4, cur_len);
136adfc5217SJeff Kirsher }
137adfc5217SJeff Kirsher }
138adfc5217SJeff Kirsher
139adfc5217SJeff Kirsher /*********************************************************
140adfc5217SJeff Kirsher There are different blobs for each PRAM section.
141adfc5217SJeff Kirsher In addition, each blob write operation is divided into a few operations
142adfc5217SJeff Kirsher in order to decrease the amount of phys. contiguous buffer needed.
143adfc5217SJeff Kirsher Thus, when we select a blob the address may be with some offset
144adfc5217SJeff Kirsher from the beginning of PRAM section.
145adfc5217SJeff Kirsher The same holds for the INT_TABLE sections.
146adfc5217SJeff Kirsher **********************************************************/
147adfc5217SJeff Kirsher #define IF_IS_INT_TABLE_ADDR(base, addr) \
148adfc5217SJeff Kirsher if (((base) <= (addr)) && ((base) + 0x400 >= (addr)))
149adfc5217SJeff Kirsher
150adfc5217SJeff Kirsher #define IF_IS_PRAM_ADDR(base, addr) \
151adfc5217SJeff Kirsher if (((base) <= (addr)) && ((base) + 0x40000 >= (addr)))
152adfc5217SJeff Kirsher
bnx2x_sel_blob(struct bnx2x * bp,u32 addr,const u8 * data)153adfc5217SJeff Kirsher static const u8 *bnx2x_sel_blob(struct bnx2x *bp, u32 addr,
154adfc5217SJeff Kirsher const u8 *data)
155adfc5217SJeff Kirsher {
156adfc5217SJeff Kirsher IF_IS_INT_TABLE_ADDR(TSEM_REG_INT_TABLE, addr)
157adfc5217SJeff Kirsher data = INIT_TSEM_INT_TABLE_DATA(bp);
158adfc5217SJeff Kirsher else
159adfc5217SJeff Kirsher IF_IS_INT_TABLE_ADDR(CSEM_REG_INT_TABLE, addr)
160adfc5217SJeff Kirsher data = INIT_CSEM_INT_TABLE_DATA(bp);
161adfc5217SJeff Kirsher else
162adfc5217SJeff Kirsher IF_IS_INT_TABLE_ADDR(USEM_REG_INT_TABLE, addr)
163adfc5217SJeff Kirsher data = INIT_USEM_INT_TABLE_DATA(bp);
164adfc5217SJeff Kirsher else
165adfc5217SJeff Kirsher IF_IS_INT_TABLE_ADDR(XSEM_REG_INT_TABLE, addr)
166adfc5217SJeff Kirsher data = INIT_XSEM_INT_TABLE_DATA(bp);
167adfc5217SJeff Kirsher else
168adfc5217SJeff Kirsher IF_IS_PRAM_ADDR(TSEM_REG_PRAM, addr)
169adfc5217SJeff Kirsher data = INIT_TSEM_PRAM_DATA(bp);
170adfc5217SJeff Kirsher else
171adfc5217SJeff Kirsher IF_IS_PRAM_ADDR(CSEM_REG_PRAM, addr)
172adfc5217SJeff Kirsher data = INIT_CSEM_PRAM_DATA(bp);
173adfc5217SJeff Kirsher else
174adfc5217SJeff Kirsher IF_IS_PRAM_ADDR(USEM_REG_PRAM, addr)
175adfc5217SJeff Kirsher data = INIT_USEM_PRAM_DATA(bp);
176adfc5217SJeff Kirsher else
177adfc5217SJeff Kirsher IF_IS_PRAM_ADDR(XSEM_REG_PRAM, addr)
178adfc5217SJeff Kirsher data = INIT_XSEM_PRAM_DATA(bp);
179adfc5217SJeff Kirsher
180adfc5217SJeff Kirsher return data;
181adfc5217SJeff Kirsher }
182adfc5217SJeff Kirsher
bnx2x_init_wr_wb(struct bnx2x * bp,u32 addr,const u32 * data,u32 len)183adfc5217SJeff Kirsher static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr,
184adfc5217SJeff Kirsher const u32 *data, u32 len)
185adfc5217SJeff Kirsher {
186adfc5217SJeff Kirsher if (bp->dmae_ready)
187adfc5217SJeff Kirsher VIRT_WR_DMAE_LEN(bp, data, addr, len, 0);
188127a425eSAriel Elior
189127a425eSAriel Elior /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
190127a425eSAriel Elior else if (CHIP_IS_E1(bp))
191adfc5217SJeff Kirsher bnx2x_init_ind_wr(bp, addr, data, len);
192127a425eSAriel Elior
193127a425eSAriel Elior /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
194127a425eSAriel Elior else
195127a425eSAriel Elior bnx2x_init_str_wr(bp, addr, data, len);
196adfc5217SJeff Kirsher }
197adfc5217SJeff Kirsher
bnx2x_wr_64(struct bnx2x * bp,u32 reg,u32 val_lo,u32 val_hi)198adfc5217SJeff Kirsher static void bnx2x_wr_64(struct bnx2x *bp, u32 reg, u32 val_lo,
199adfc5217SJeff Kirsher u32 val_hi)
200adfc5217SJeff Kirsher {
201adfc5217SJeff Kirsher u32 wb_write[2];
202adfc5217SJeff Kirsher
203adfc5217SJeff Kirsher wb_write[0] = val_lo;
204adfc5217SJeff Kirsher wb_write[1] = val_hi;
205adfc5217SJeff Kirsher REG_WR_DMAE_LEN(bp, reg, wb_write, 2);
206adfc5217SJeff Kirsher }
bnx2x_init_wr_zp(struct bnx2x * bp,u32 addr,u32 len,u32 blob_off)207adfc5217SJeff Kirsher static void bnx2x_init_wr_zp(struct bnx2x *bp, u32 addr, u32 len,
208adfc5217SJeff Kirsher u32 blob_off)
209adfc5217SJeff Kirsher {
210adfc5217SJeff Kirsher const u8 *data = NULL;
211adfc5217SJeff Kirsher int rc;
212adfc5217SJeff Kirsher u32 i;
213adfc5217SJeff Kirsher
214adfc5217SJeff Kirsher data = bnx2x_sel_blob(bp, addr, data) + blob_off*4;
215adfc5217SJeff Kirsher
216adfc5217SJeff Kirsher rc = bnx2x_gunzip(bp, data, len);
217adfc5217SJeff Kirsher if (rc)
218adfc5217SJeff Kirsher return;
219adfc5217SJeff Kirsher
220adfc5217SJeff Kirsher /* gunzip_outlen is in dwords */
221adfc5217SJeff Kirsher len = GUNZIP_OUTLEN(bp);
222adfc5217SJeff Kirsher for (i = 0; i < len; i++)
22386564c3fSYuval Mintz ((u32 *)GUNZIP_BUF(bp))[i] = (__force u32)
224adfc5217SJeff Kirsher cpu_to_le32(((u32 *)GUNZIP_BUF(bp))[i]);
225adfc5217SJeff Kirsher
226adfc5217SJeff Kirsher bnx2x_write_big_buf_wb(bp, addr, len);
227adfc5217SJeff Kirsher }
228adfc5217SJeff Kirsher
bnx2x_init_block(struct bnx2x * bp,u32 block,u32 stage)229adfc5217SJeff Kirsher static void bnx2x_init_block(struct bnx2x *bp, u32 block, u32 stage)
230adfc5217SJeff Kirsher {
231adfc5217SJeff Kirsher u16 op_start =
232adfc5217SJeff Kirsher INIT_OPS_OFFSETS(bp)[BLOCK_OPS_IDX(block, stage,
233adfc5217SJeff Kirsher STAGE_START)];
234adfc5217SJeff Kirsher u16 op_end =
235adfc5217SJeff Kirsher INIT_OPS_OFFSETS(bp)[BLOCK_OPS_IDX(block, stage,
236adfc5217SJeff Kirsher STAGE_END)];
23786564c3fSYuval Mintz const union init_op *op;
238adfc5217SJeff Kirsher u32 op_idx, op_type, addr, len;
239adfc5217SJeff Kirsher const u32 *data, *data_base;
240adfc5217SJeff Kirsher
241adfc5217SJeff Kirsher /* If empty block */
242adfc5217SJeff Kirsher if (op_start == op_end)
243adfc5217SJeff Kirsher return;
244adfc5217SJeff Kirsher
245adfc5217SJeff Kirsher data_base = INIT_DATA(bp);
246adfc5217SJeff Kirsher
247adfc5217SJeff Kirsher for (op_idx = op_start; op_idx < op_end; op_idx++) {
248adfc5217SJeff Kirsher
24986564c3fSYuval Mintz op = (const union init_op *)&(INIT_OPS(bp)[op_idx]);
250adfc5217SJeff Kirsher /* Get generic data */
251adfc5217SJeff Kirsher op_type = op->raw.op;
252adfc5217SJeff Kirsher addr = op->raw.offset;
253adfc5217SJeff Kirsher /* Get data that's used for OP_SW, OP_WB, OP_FW, OP_ZP and
254adfc5217SJeff Kirsher * OP_WR64 (we assume that op_arr_write and op_write have the
255adfc5217SJeff Kirsher * same structure).
256adfc5217SJeff Kirsher */
257adfc5217SJeff Kirsher len = op->arr_wr.data_len;
258adfc5217SJeff Kirsher data = data_base + op->arr_wr.data_off;
259adfc5217SJeff Kirsher
260adfc5217SJeff Kirsher switch (op_type) {
261adfc5217SJeff Kirsher case OP_RD:
262adfc5217SJeff Kirsher REG_RD(bp, addr);
263adfc5217SJeff Kirsher break;
264adfc5217SJeff Kirsher case OP_WR:
265adfc5217SJeff Kirsher REG_WR(bp, addr, op->write.val);
266adfc5217SJeff Kirsher break;
267adfc5217SJeff Kirsher case OP_SW:
268adfc5217SJeff Kirsher bnx2x_init_str_wr(bp, addr, data, len);
269adfc5217SJeff Kirsher break;
270adfc5217SJeff Kirsher case OP_WB:
271adfc5217SJeff Kirsher bnx2x_init_wr_wb(bp, addr, data, len);
272adfc5217SJeff Kirsher break;
273adfc5217SJeff Kirsher case OP_ZR:
274adfc5217SJeff Kirsher bnx2x_init_fill(bp, addr, 0, op->zero.len, 0);
275adfc5217SJeff Kirsher break;
276adfc5217SJeff Kirsher case OP_WB_ZR:
277adfc5217SJeff Kirsher bnx2x_init_fill(bp, addr, 0, op->zero.len, 1);
278adfc5217SJeff Kirsher break;
279adfc5217SJeff Kirsher case OP_ZP:
280adfc5217SJeff Kirsher bnx2x_init_wr_zp(bp, addr, len,
281adfc5217SJeff Kirsher op->arr_wr.data_off);
282adfc5217SJeff Kirsher break;
283adfc5217SJeff Kirsher case OP_WR_64:
284adfc5217SJeff Kirsher bnx2x_init_wr_64(bp, addr, data, len);
285adfc5217SJeff Kirsher break;
286adfc5217SJeff Kirsher case OP_IF_MODE_AND:
287adfc5217SJeff Kirsher /* if any of the flags doesn't match, skip the
288adfc5217SJeff Kirsher * conditional block.
289adfc5217SJeff Kirsher */
290adfc5217SJeff Kirsher if ((INIT_MODE_FLAGS(bp) &
291adfc5217SJeff Kirsher op->if_mode.mode_bit_map) !=
292adfc5217SJeff Kirsher op->if_mode.mode_bit_map)
293adfc5217SJeff Kirsher op_idx += op->if_mode.cmd_offset;
294adfc5217SJeff Kirsher break;
295adfc5217SJeff Kirsher case OP_IF_MODE_OR:
296adfc5217SJeff Kirsher /* if all the flags don't match, skip the conditional
297adfc5217SJeff Kirsher * block.
298adfc5217SJeff Kirsher */
299adfc5217SJeff Kirsher if ((INIT_MODE_FLAGS(bp) &
300adfc5217SJeff Kirsher op->if_mode.mode_bit_map) == 0)
301adfc5217SJeff Kirsher op_idx += op->if_mode.cmd_offset;
302adfc5217SJeff Kirsher break;
303adfc5217SJeff Kirsher default:
304adfc5217SJeff Kirsher /* Should never get here! */
305adfc5217SJeff Kirsher
306adfc5217SJeff Kirsher break;
307adfc5217SJeff Kirsher }
308adfc5217SJeff Kirsher }
309adfc5217SJeff Kirsher }
310adfc5217SJeff Kirsher
311adfc5217SJeff Kirsher
312adfc5217SJeff Kirsher /****************************************************************************
313adfc5217SJeff Kirsher * PXP Arbiter
314adfc5217SJeff Kirsher ****************************************************************************/
315adfc5217SJeff Kirsher /*
316adfc5217SJeff Kirsher * This code configures the PCI read/write arbiter
317adfc5217SJeff Kirsher * which implements a weighted round robin
318adfc5217SJeff Kirsher * between the virtual queues in the chip.
319adfc5217SJeff Kirsher *
320adfc5217SJeff Kirsher * The values were derived for each PCI max payload and max request size.
321adfc5217SJeff Kirsher * since max payload and max request size are only known at run time,
322adfc5217SJeff Kirsher * this is done as a separate init stage.
323adfc5217SJeff Kirsher */
324adfc5217SJeff Kirsher
325adfc5217SJeff Kirsher #define NUM_WR_Q 13
326adfc5217SJeff Kirsher #define NUM_RD_Q 29
327adfc5217SJeff Kirsher #define MAX_RD_ORD 3
328adfc5217SJeff Kirsher #define MAX_WR_ORD 2
329adfc5217SJeff Kirsher
330adfc5217SJeff Kirsher /* configuration for one arbiter queue */
331adfc5217SJeff Kirsher struct arb_line {
332adfc5217SJeff Kirsher int l;
333adfc5217SJeff Kirsher int add;
334adfc5217SJeff Kirsher int ubound;
335adfc5217SJeff Kirsher };
336adfc5217SJeff Kirsher
337adfc5217SJeff Kirsher /* derived configuration for each read queue for each max request size */
338adfc5217SJeff Kirsher static const struct arb_line read_arb_data[NUM_RD_Q][MAX_RD_ORD + 1] = {
339adfc5217SJeff Kirsher /* 1 */ { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
340adfc5217SJeff Kirsher { {4, 8, 4}, {4, 8, 4}, {4, 8, 4}, {4, 8, 4} },
341adfc5217SJeff Kirsher { {4, 3, 3}, {4, 3, 3}, {4, 3, 3}, {4, 3, 3} },
342adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {16, 3, 11}, {16, 3, 11} },
343adfc5217SJeff Kirsher { {8, 64, 25}, {16, 64, 25}, {32, 64, 25}, {64, 64, 41} },
344adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
345adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
346adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
347adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {64, 3, 41} },
348adfc5217SJeff Kirsher /* 10 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
349adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
350adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
351adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
352adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
353adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
354adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
355adfc5217SJeff Kirsher { {8, 64, 6}, {16, 64, 11}, {32, 64, 21}, {32, 64, 21} },
356adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
357adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
358adfc5217SJeff Kirsher /* 20 */{ {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
359adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
360adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
361adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
362adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
363adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
364adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
365adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
366adfc5217SJeff Kirsher { {8, 3, 6}, {16, 3, 11}, {32, 3, 21}, {32, 3, 21} },
367adfc5217SJeff Kirsher { {8, 64, 25}, {16, 64, 41}, {32, 64, 81}, {64, 64, 120} }
368adfc5217SJeff Kirsher };
369adfc5217SJeff Kirsher
370adfc5217SJeff Kirsher /* derived configuration for each write queue for each max request size */
371adfc5217SJeff Kirsher static const struct arb_line write_arb_data[NUM_WR_Q][MAX_WR_ORD + 1] = {
372adfc5217SJeff Kirsher /* 1 */ { {4, 6, 3}, {4, 6, 3}, {4, 6, 3} },
373adfc5217SJeff Kirsher { {4, 2, 3}, {4, 2, 3}, {4, 2, 3} },
374adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
375adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
376adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
377adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {32, 2, 21} },
378adfc5217SJeff Kirsher { {8, 64, 25}, {16, 64, 25}, {32, 64, 25} },
379adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
380adfc5217SJeff Kirsher { {8, 2, 6}, {16, 2, 11}, {16, 2, 11} },
381adfc5217SJeff Kirsher /* 10 */{ {8, 9, 6}, {16, 9, 11}, {32, 9, 21} },
382adfc5217SJeff Kirsher { {8, 47, 19}, {16, 47, 19}, {32, 47, 21} },
383adfc5217SJeff Kirsher { {8, 9, 6}, {16, 9, 11}, {16, 9, 11} },
384adfc5217SJeff Kirsher { {8, 64, 25}, {16, 64, 41}, {32, 64, 81} }
385adfc5217SJeff Kirsher };
386adfc5217SJeff Kirsher
387adfc5217SJeff Kirsher /* register addresses for read queues */
388adfc5217SJeff Kirsher static const struct arb_line read_arb_addr[NUM_RD_Q-1] = {
389adfc5217SJeff Kirsher /* 1 */ {PXP2_REG_RQ_BW_RD_L0, PXP2_REG_RQ_BW_RD_ADD0,
390adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND0},
391adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
392adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB1},
393adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
394adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB2},
395adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
396adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB3},
397adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L4, PXP2_REG_RQ_BW_RD_ADD4,
398adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND4},
399adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L5, PXP2_REG_RQ_BW_RD_ADD5,
400adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND5},
401adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
402adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB6},
403adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
404adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB7},
405adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
406adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB8},
407adfc5217SJeff Kirsher /* 10 */{PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
408adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB9},
409adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
410adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB10},
411adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
412adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB11},
413adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L12, PXP2_REG_RQ_BW_RD_ADD12,
414adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND12},
415adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L13, PXP2_REG_RQ_BW_RD_ADD13,
416adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND13},
417adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L14, PXP2_REG_RQ_BW_RD_ADD14,
418adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND14},
419adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L15, PXP2_REG_RQ_BW_RD_ADD15,
420adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND15},
421adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L16, PXP2_REG_RQ_BW_RD_ADD16,
422adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND16},
423adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L17, PXP2_REG_RQ_BW_RD_ADD17,
424adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND17},
425adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L18, PXP2_REG_RQ_BW_RD_ADD18,
426adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND18},
427adfc5217SJeff Kirsher /* 20 */{PXP2_REG_RQ_BW_RD_L19, PXP2_REG_RQ_BW_RD_ADD19,
428adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND19},
429adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L20, PXP2_REG_RQ_BW_RD_ADD20,
430adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND20},
431adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L22, PXP2_REG_RQ_BW_RD_ADD22,
432adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND22},
433adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L23, PXP2_REG_RQ_BW_RD_ADD23,
434adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND23},
435adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L24, PXP2_REG_RQ_BW_RD_ADD24,
436adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND24},
437adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L25, PXP2_REG_RQ_BW_RD_ADD25,
438adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND25},
439adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L26, PXP2_REG_RQ_BW_RD_ADD26,
440adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND26},
441adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_RD_L27, PXP2_REG_RQ_BW_RD_ADD27,
442adfc5217SJeff Kirsher PXP2_REG_RQ_BW_RD_UBOUND27},
443adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
444adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB28}
445adfc5217SJeff Kirsher };
446adfc5217SJeff Kirsher
447adfc5217SJeff Kirsher /* register addresses for write queues */
448adfc5217SJeff Kirsher static const struct arb_line write_arb_addr[NUM_WR_Q-1] = {
449adfc5217SJeff Kirsher /* 1 */ {PXP2_REG_PSWRQ_BW_L1, PXP2_REG_PSWRQ_BW_ADD1,
450adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB1},
451adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L2, PXP2_REG_PSWRQ_BW_ADD2,
452adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB2},
453adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L3, PXP2_REG_PSWRQ_BW_ADD3,
454adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB3},
455adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L6, PXP2_REG_PSWRQ_BW_ADD6,
456adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB6},
457adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L7, PXP2_REG_PSWRQ_BW_ADD7,
458adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB7},
459adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L8, PXP2_REG_PSWRQ_BW_ADD8,
460adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB8},
461adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L9, PXP2_REG_PSWRQ_BW_ADD9,
462adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB9},
463adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L10, PXP2_REG_PSWRQ_BW_ADD10,
464adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB10},
465adfc5217SJeff Kirsher {PXP2_REG_PSWRQ_BW_L11, PXP2_REG_PSWRQ_BW_ADD11,
466adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB11},
467adfc5217SJeff Kirsher /* 10 */{PXP2_REG_PSWRQ_BW_L28, PXP2_REG_PSWRQ_BW_ADD28,
468adfc5217SJeff Kirsher PXP2_REG_PSWRQ_BW_UB28},
469adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_WR_L29, PXP2_REG_RQ_BW_WR_ADD29,
470adfc5217SJeff Kirsher PXP2_REG_RQ_BW_WR_UBOUND29},
471adfc5217SJeff Kirsher {PXP2_REG_RQ_BW_WR_L30, PXP2_REG_RQ_BW_WR_ADD30,
472adfc5217SJeff Kirsher PXP2_REG_RQ_BW_WR_UBOUND30}
473adfc5217SJeff Kirsher };
474adfc5217SJeff Kirsher
bnx2x_init_pxp_arb(struct bnx2x * bp,int r_order,int w_order)475adfc5217SJeff Kirsher static void bnx2x_init_pxp_arb(struct bnx2x *bp, int r_order,
476adfc5217SJeff Kirsher int w_order)
477adfc5217SJeff Kirsher {
478adfc5217SJeff Kirsher u32 val, i;
479adfc5217SJeff Kirsher
480adfc5217SJeff Kirsher if (r_order > MAX_RD_ORD) {
481adfc5217SJeff Kirsher DP(NETIF_MSG_HW, "read order of %d order adjusted to %d\n",
482adfc5217SJeff Kirsher r_order, MAX_RD_ORD);
483adfc5217SJeff Kirsher r_order = MAX_RD_ORD;
484adfc5217SJeff Kirsher }
485adfc5217SJeff Kirsher if (w_order > MAX_WR_ORD) {
486adfc5217SJeff Kirsher DP(NETIF_MSG_HW, "write order of %d order adjusted to %d\n",
487adfc5217SJeff Kirsher w_order, MAX_WR_ORD);
488adfc5217SJeff Kirsher w_order = MAX_WR_ORD;
489adfc5217SJeff Kirsher }
490adfc5217SJeff Kirsher if (CHIP_REV_IS_FPGA(bp)) {
491adfc5217SJeff Kirsher DP(NETIF_MSG_HW, "write order adjusted to 1 for FPGA\n");
492adfc5217SJeff Kirsher w_order = 0;
493adfc5217SJeff Kirsher }
494adfc5217SJeff Kirsher DP(NETIF_MSG_HW, "read order %d write order %d\n", r_order, w_order);
495adfc5217SJeff Kirsher
496adfc5217SJeff Kirsher for (i = 0; i < NUM_RD_Q-1; i++) {
497adfc5217SJeff Kirsher REG_WR(bp, read_arb_addr[i].l, read_arb_data[i][r_order].l);
498adfc5217SJeff Kirsher REG_WR(bp, read_arb_addr[i].add,
499adfc5217SJeff Kirsher read_arb_data[i][r_order].add);
500adfc5217SJeff Kirsher REG_WR(bp, read_arb_addr[i].ubound,
501adfc5217SJeff Kirsher read_arb_data[i][r_order].ubound);
502adfc5217SJeff Kirsher }
503adfc5217SJeff Kirsher
504adfc5217SJeff Kirsher for (i = 0; i < NUM_WR_Q-1; i++) {
505adfc5217SJeff Kirsher if ((write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L29) ||
506adfc5217SJeff Kirsher (write_arb_addr[i].l == PXP2_REG_RQ_BW_WR_L30)) {
507adfc5217SJeff Kirsher
508adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].l,
509adfc5217SJeff Kirsher write_arb_data[i][w_order].l);
510adfc5217SJeff Kirsher
511adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].add,
512adfc5217SJeff Kirsher write_arb_data[i][w_order].add);
513adfc5217SJeff Kirsher
514adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].ubound,
515adfc5217SJeff Kirsher write_arb_data[i][w_order].ubound);
516adfc5217SJeff Kirsher } else {
517adfc5217SJeff Kirsher
518adfc5217SJeff Kirsher val = REG_RD(bp, write_arb_addr[i].l);
519adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].l,
520adfc5217SJeff Kirsher val | (write_arb_data[i][w_order].l << 10));
521adfc5217SJeff Kirsher
522adfc5217SJeff Kirsher val = REG_RD(bp, write_arb_addr[i].add);
523adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].add,
524adfc5217SJeff Kirsher val | (write_arb_data[i][w_order].add << 10));
525adfc5217SJeff Kirsher
526adfc5217SJeff Kirsher val = REG_RD(bp, write_arb_addr[i].ubound);
527adfc5217SJeff Kirsher REG_WR(bp, write_arb_addr[i].ubound,
528adfc5217SJeff Kirsher val | (write_arb_data[i][w_order].ubound << 7));
529adfc5217SJeff Kirsher }
530adfc5217SJeff Kirsher }
531adfc5217SJeff Kirsher
532adfc5217SJeff Kirsher val = write_arb_data[NUM_WR_Q-1][w_order].add;
533adfc5217SJeff Kirsher val += write_arb_data[NUM_WR_Q-1][w_order].ubound << 10;
534adfc5217SJeff Kirsher val += write_arb_data[NUM_WR_Q-1][w_order].l << 17;
535adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_PSWRQ_BW_RD, val);
536adfc5217SJeff Kirsher
537adfc5217SJeff Kirsher val = read_arb_data[NUM_RD_Q-1][r_order].add;
538adfc5217SJeff Kirsher val += read_arb_data[NUM_RD_Q-1][r_order].ubound << 10;
539adfc5217SJeff Kirsher val += read_arb_data[NUM_RD_Q-1][r_order].l << 17;
540adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val);
541adfc5217SJeff Kirsher
542adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order);
543adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_RQ_WR_MBS1, w_order);
544adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order);
545adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_RQ_RD_MBS1, r_order);
546adfc5217SJeff Kirsher
547adfc5217SJeff Kirsher if ((CHIP_IS_E1(bp) || CHIP_IS_E1H(bp)) && (r_order == MAX_RD_ORD))
548adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_RQ_PDR_LIMIT, 0xe00);
549adfc5217SJeff Kirsher
550adfc5217SJeff Kirsher if (CHIP_IS_E3(bp))
551adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x4 << w_order));
552adfc5217SJeff Kirsher else if (CHIP_IS_E2(bp))
553adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x8 << w_order));
554adfc5217SJeff Kirsher else
555adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x18 << w_order));
556adfc5217SJeff Kirsher
557adfc5217SJeff Kirsher if (!CHIP_IS_E1(bp)) {
558adfc5217SJeff Kirsher /* MPS w_order optimal TH presently TH
559adfc5217SJeff Kirsher * 128 0 0 2
560adfc5217SJeff Kirsher * 256 1 1 3
561adfc5217SJeff Kirsher * >=512 2 2 3
562adfc5217SJeff Kirsher */
563adfc5217SJeff Kirsher /* DMAE is special */
564adfc5217SJeff Kirsher if (!CHIP_IS_E1H(bp)) {
565adfc5217SJeff Kirsher /* E2 can use optimal TH */
566adfc5217SJeff Kirsher val = w_order;
567adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_DMAE_MPS, val);
568adfc5217SJeff Kirsher } else {
569adfc5217SJeff Kirsher val = ((w_order == 0) ? 2 : 3);
570adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_DMAE_MPS, 2);
571adfc5217SJeff Kirsher }
572adfc5217SJeff Kirsher
573adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_HC_MPS, val);
574adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_USDM_MPS, val);
575adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_CSDM_MPS, val);
576adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_TSDM_MPS, val);
577adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_XSDM_MPS, val);
578adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_QM_MPS, val);
579adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_TM_MPS, val);
580adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_SRC_MPS, val);
581adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_DBG_MPS, val);
582adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_WR_CDU_MPS, val);
583adfc5217SJeff Kirsher }
584adfc5217SJeff Kirsher
585adfc5217SJeff Kirsher /* Validate number of tags suppoted by device */
586adfc5217SJeff Kirsher #define PCIE_REG_PCIER_TL_HDR_FC_ST 0x2980
587adfc5217SJeff Kirsher val = REG_RD(bp, PCIE_REG_PCIER_TL_HDR_FC_ST);
588adfc5217SJeff Kirsher val &= 0xFF;
589adfc5217SJeff Kirsher if (val <= 0x20)
590adfc5217SJeff Kirsher REG_WR(bp, PXP2_REG_PGL_TAGS_LIMIT, 0x20);
591adfc5217SJeff Kirsher }
592adfc5217SJeff Kirsher
593adfc5217SJeff Kirsher /****************************************************************************
594adfc5217SJeff Kirsher * ILT management
595adfc5217SJeff Kirsher ****************************************************************************/
596adfc5217SJeff Kirsher /*
597adfc5217SJeff Kirsher * This codes hides the low level HW interaction for ILT management and
598adfc5217SJeff Kirsher * configuration. The API consists of a shadow ILT table which is set by the
599adfc5217SJeff Kirsher * driver and a set of routines to use it to configure the HW.
600adfc5217SJeff Kirsher *
601adfc5217SJeff Kirsher */
602adfc5217SJeff Kirsher
603adfc5217SJeff Kirsher /* ILT HW init operations */
604adfc5217SJeff Kirsher
605adfc5217SJeff Kirsher /* ILT memory management operations */
606adfc5217SJeff Kirsher #define ILT_MEMOP_ALLOC 0
607adfc5217SJeff Kirsher #define ILT_MEMOP_FREE 1
608adfc5217SJeff Kirsher
609adfc5217SJeff Kirsher /* the phys address is shifted right 12 bits and has an added
610adfc5217SJeff Kirsher * 1=valid bit added to the 53rd bit
611adfc5217SJeff Kirsher * then since this is a wide register(TM)
612adfc5217SJeff Kirsher * we split it into two 32 bit writes
613adfc5217SJeff Kirsher */
614adfc5217SJeff Kirsher #define ILT_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
615adfc5217SJeff Kirsher #define ILT_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
616adfc5217SJeff Kirsher #define ILT_RANGE(f, l) (((l) << 10) | f)
617adfc5217SJeff Kirsher
bnx2x_ilt_line_mem_op(struct bnx2x * bp,struct ilt_line * line,u32 size,u8 memop)618adfc5217SJeff Kirsher static int bnx2x_ilt_line_mem_op(struct bnx2x *bp,
619adfc5217SJeff Kirsher struct ilt_line *line, u32 size, u8 memop)
620adfc5217SJeff Kirsher {
621adfc5217SJeff Kirsher if (memop == ILT_MEMOP_FREE) {
622adfc5217SJeff Kirsher BNX2X_ILT_FREE(line->page, line->page_mapping, line->size);
623adfc5217SJeff Kirsher return 0;
624adfc5217SJeff Kirsher }
625adfc5217SJeff Kirsher BNX2X_ILT_ZALLOC(line->page, &line->page_mapping, size);
626adfc5217SJeff Kirsher if (!line->page)
627adfc5217SJeff Kirsher return -1;
628adfc5217SJeff Kirsher line->size = size;
629adfc5217SJeff Kirsher return 0;
630adfc5217SJeff Kirsher }
631adfc5217SJeff Kirsher
632adfc5217SJeff Kirsher
bnx2x_ilt_client_mem_op(struct bnx2x * bp,int cli_num,u8 memop)633adfc5217SJeff Kirsher static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num,
634adfc5217SJeff Kirsher u8 memop)
635adfc5217SJeff Kirsher {
636adfc5217SJeff Kirsher int i, rc;
637adfc5217SJeff Kirsher struct bnx2x_ilt *ilt = BP_ILT(bp);
638*f8885ac8SPavel Skripkin struct ilt_client_info *ilt_cli;
639adfc5217SJeff Kirsher
640adfc5217SJeff Kirsher if (!ilt || !ilt->lines)
641adfc5217SJeff Kirsher return -1;
642adfc5217SJeff Kirsher
643*f8885ac8SPavel Skripkin ilt_cli = &ilt->clients[cli_num];
644*f8885ac8SPavel Skripkin
645adfc5217SJeff Kirsher if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM))
646adfc5217SJeff Kirsher return 0;
647adfc5217SJeff Kirsher
648adfc5217SJeff Kirsher for (rc = 0, i = ilt_cli->start; i <= ilt_cli->end && !rc; i++) {
649adfc5217SJeff Kirsher rc = bnx2x_ilt_line_mem_op(bp, &ilt->lines[i],
650adfc5217SJeff Kirsher ilt_cli->page_size, memop);
651adfc5217SJeff Kirsher }
652adfc5217SJeff Kirsher return rc;
653adfc5217SJeff Kirsher }
654adfc5217SJeff Kirsher
bnx2x_ilt_mem_op_cnic(struct bnx2x * bp,u8 memop)65555c11941SMerav Sicron static int bnx2x_ilt_mem_op_cnic(struct bnx2x *bp, u8 memop)
65655c11941SMerav Sicron {
65755c11941SMerav Sicron int rc = 0;
65855c11941SMerav Sicron
65955c11941SMerav Sicron if (CONFIGURE_NIC_MODE(bp))
66055c11941SMerav Sicron rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_SRC, memop);
66155c11941SMerav Sicron if (!rc)
66255c11941SMerav Sicron rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_TM, memop);
66355c11941SMerav Sicron
66455c11941SMerav Sicron return rc;
66555c11941SMerav Sicron }
66655c11941SMerav Sicron
bnx2x_ilt_mem_op(struct bnx2x * bp,u8 memop)667adfc5217SJeff Kirsher static int bnx2x_ilt_mem_op(struct bnx2x *bp, u8 memop)
668adfc5217SJeff Kirsher {
669adfc5217SJeff Kirsher int rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_CDU, memop);
670adfc5217SJeff Kirsher if (!rc)
671adfc5217SJeff Kirsher rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_QM, memop);
67255c11941SMerav Sicron if (!rc && CNIC_SUPPORT(bp) && !CONFIGURE_NIC_MODE(bp))
673adfc5217SJeff Kirsher rc = bnx2x_ilt_client_mem_op(bp, ILT_CLIENT_SRC, memop);
674adfc5217SJeff Kirsher
675adfc5217SJeff Kirsher return rc;
676adfc5217SJeff Kirsher }
677adfc5217SJeff Kirsher
bnx2x_ilt_line_wr(struct bnx2x * bp,int abs_idx,dma_addr_t page_mapping)678adfc5217SJeff Kirsher static void bnx2x_ilt_line_wr(struct bnx2x *bp, int abs_idx,
679adfc5217SJeff Kirsher dma_addr_t page_mapping)
680adfc5217SJeff Kirsher {
681adfc5217SJeff Kirsher u32 reg;
682adfc5217SJeff Kirsher
683adfc5217SJeff Kirsher if (CHIP_IS_E1(bp))
684adfc5217SJeff Kirsher reg = PXP2_REG_RQ_ONCHIP_AT + abs_idx*8;
685adfc5217SJeff Kirsher else
686adfc5217SJeff Kirsher reg = PXP2_REG_RQ_ONCHIP_AT_B0 + abs_idx*8;
687adfc5217SJeff Kirsher
688adfc5217SJeff Kirsher bnx2x_wr_64(bp, reg, ILT_ADDR1(page_mapping), ILT_ADDR2(page_mapping));
689adfc5217SJeff Kirsher }
690adfc5217SJeff Kirsher
bnx2x_ilt_line_init_op(struct bnx2x * bp,struct bnx2x_ilt * ilt,int idx,u8 initop)691adfc5217SJeff Kirsher static void bnx2x_ilt_line_init_op(struct bnx2x *bp,
692adfc5217SJeff Kirsher struct bnx2x_ilt *ilt, int idx, u8 initop)
693adfc5217SJeff Kirsher {
694adfc5217SJeff Kirsher dma_addr_t null_mapping;
695adfc5217SJeff Kirsher int abs_idx = ilt->start_line + idx;
696adfc5217SJeff Kirsher
697adfc5217SJeff Kirsher
698adfc5217SJeff Kirsher switch (initop) {
699adfc5217SJeff Kirsher case INITOP_INIT:
700adfc5217SJeff Kirsher /* set in the init-value array */
701adfc5217SJeff Kirsher case INITOP_SET:
702adfc5217SJeff Kirsher bnx2x_ilt_line_wr(bp, abs_idx, ilt->lines[idx].page_mapping);
703adfc5217SJeff Kirsher break;
704adfc5217SJeff Kirsher case INITOP_CLEAR:
705adfc5217SJeff Kirsher null_mapping = 0;
706adfc5217SJeff Kirsher bnx2x_ilt_line_wr(bp, abs_idx, null_mapping);
707adfc5217SJeff Kirsher break;
708adfc5217SJeff Kirsher }
709adfc5217SJeff Kirsher }
710adfc5217SJeff Kirsher
bnx2x_ilt_boundry_init_op(struct bnx2x * bp,struct ilt_client_info * ilt_cli,u32 ilt_start,u8 initop)711adfc5217SJeff Kirsher static void bnx2x_ilt_boundry_init_op(struct bnx2x *bp,
712adfc5217SJeff Kirsher struct ilt_client_info *ilt_cli,
713adfc5217SJeff Kirsher u32 ilt_start, u8 initop)
714adfc5217SJeff Kirsher {
715adfc5217SJeff Kirsher u32 start_reg = 0;
716adfc5217SJeff Kirsher u32 end_reg = 0;
717adfc5217SJeff Kirsher
718adfc5217SJeff Kirsher /* The boundary is either SET or INIT,
719adfc5217SJeff Kirsher CLEAR => SET and for now SET ~~ INIT */
720adfc5217SJeff Kirsher
721adfc5217SJeff Kirsher /* find the appropriate regs */
722adfc5217SJeff Kirsher if (CHIP_IS_E1(bp)) {
723adfc5217SJeff Kirsher switch (ilt_cli->client_num) {
724adfc5217SJeff Kirsher case ILT_CLIENT_CDU:
725adfc5217SJeff Kirsher start_reg = PXP2_REG_PSWRQ_CDU0_L2P;
726adfc5217SJeff Kirsher break;
727adfc5217SJeff Kirsher case ILT_CLIENT_QM:
728adfc5217SJeff Kirsher start_reg = PXP2_REG_PSWRQ_QM0_L2P;
729adfc5217SJeff Kirsher break;
730adfc5217SJeff Kirsher case ILT_CLIENT_SRC:
731adfc5217SJeff Kirsher start_reg = PXP2_REG_PSWRQ_SRC0_L2P;
732adfc5217SJeff Kirsher break;
733adfc5217SJeff Kirsher case ILT_CLIENT_TM:
734adfc5217SJeff Kirsher start_reg = PXP2_REG_PSWRQ_TM0_L2P;
735adfc5217SJeff Kirsher break;
736adfc5217SJeff Kirsher }
737adfc5217SJeff Kirsher REG_WR(bp, start_reg + BP_FUNC(bp)*4,
738adfc5217SJeff Kirsher ILT_RANGE((ilt_start + ilt_cli->start),
739adfc5217SJeff Kirsher (ilt_start + ilt_cli->end)));
740adfc5217SJeff Kirsher } else {
741adfc5217SJeff Kirsher switch (ilt_cli->client_num) {
742adfc5217SJeff Kirsher case ILT_CLIENT_CDU:
743adfc5217SJeff Kirsher start_reg = PXP2_REG_RQ_CDU_FIRST_ILT;
744adfc5217SJeff Kirsher end_reg = PXP2_REG_RQ_CDU_LAST_ILT;
745adfc5217SJeff Kirsher break;
746adfc5217SJeff Kirsher case ILT_CLIENT_QM:
747adfc5217SJeff Kirsher start_reg = PXP2_REG_RQ_QM_FIRST_ILT;
748adfc5217SJeff Kirsher end_reg = PXP2_REG_RQ_QM_LAST_ILT;
749adfc5217SJeff Kirsher break;
750adfc5217SJeff Kirsher case ILT_CLIENT_SRC:
751adfc5217SJeff Kirsher start_reg = PXP2_REG_RQ_SRC_FIRST_ILT;
752adfc5217SJeff Kirsher end_reg = PXP2_REG_RQ_SRC_LAST_ILT;
753adfc5217SJeff Kirsher break;
754adfc5217SJeff Kirsher case ILT_CLIENT_TM:
755adfc5217SJeff Kirsher start_reg = PXP2_REG_RQ_TM_FIRST_ILT;
756adfc5217SJeff Kirsher end_reg = PXP2_REG_RQ_TM_LAST_ILT;
757adfc5217SJeff Kirsher break;
758adfc5217SJeff Kirsher }
759adfc5217SJeff Kirsher REG_WR(bp, start_reg, (ilt_start + ilt_cli->start));
760adfc5217SJeff Kirsher REG_WR(bp, end_reg, (ilt_start + ilt_cli->end));
761adfc5217SJeff Kirsher }
762adfc5217SJeff Kirsher }
763adfc5217SJeff Kirsher
bnx2x_ilt_client_init_op_ilt(struct bnx2x * bp,struct bnx2x_ilt * ilt,struct ilt_client_info * ilt_cli,u8 initop)764adfc5217SJeff Kirsher static void bnx2x_ilt_client_init_op_ilt(struct bnx2x *bp,
765adfc5217SJeff Kirsher struct bnx2x_ilt *ilt,
766adfc5217SJeff Kirsher struct ilt_client_info *ilt_cli,
767adfc5217SJeff Kirsher u8 initop)
768adfc5217SJeff Kirsher {
769adfc5217SJeff Kirsher int i;
770adfc5217SJeff Kirsher
771adfc5217SJeff Kirsher if (ilt_cli->flags & ILT_CLIENT_SKIP_INIT)
772adfc5217SJeff Kirsher return;
773adfc5217SJeff Kirsher
774adfc5217SJeff Kirsher for (i = ilt_cli->start; i <= ilt_cli->end; i++)
775adfc5217SJeff Kirsher bnx2x_ilt_line_init_op(bp, ilt, i, initop);
776adfc5217SJeff Kirsher
777adfc5217SJeff Kirsher /* init/clear the ILT boundries */
778adfc5217SJeff Kirsher bnx2x_ilt_boundry_init_op(bp, ilt_cli, ilt->start_line, initop);
779adfc5217SJeff Kirsher }
780adfc5217SJeff Kirsher
bnx2x_ilt_client_init_op(struct bnx2x * bp,struct ilt_client_info * ilt_cli,u8 initop)781adfc5217SJeff Kirsher static void bnx2x_ilt_client_init_op(struct bnx2x *bp,
782adfc5217SJeff Kirsher struct ilt_client_info *ilt_cli, u8 initop)
783adfc5217SJeff Kirsher {
784adfc5217SJeff Kirsher struct bnx2x_ilt *ilt = BP_ILT(bp);
785adfc5217SJeff Kirsher
786adfc5217SJeff Kirsher bnx2x_ilt_client_init_op_ilt(bp, ilt, ilt_cli, initop);
787adfc5217SJeff Kirsher }
788adfc5217SJeff Kirsher
bnx2x_ilt_client_id_init_op(struct bnx2x * bp,int cli_num,u8 initop)789adfc5217SJeff Kirsher static void bnx2x_ilt_client_id_init_op(struct bnx2x *bp,
790adfc5217SJeff Kirsher int cli_num, u8 initop)
791adfc5217SJeff Kirsher {
792adfc5217SJeff Kirsher struct bnx2x_ilt *ilt = BP_ILT(bp);
793adfc5217SJeff Kirsher struct ilt_client_info *ilt_cli = &ilt->clients[cli_num];
794adfc5217SJeff Kirsher
795adfc5217SJeff Kirsher bnx2x_ilt_client_init_op(bp, ilt_cli, initop);
796adfc5217SJeff Kirsher }
797adfc5217SJeff Kirsher
bnx2x_ilt_init_op_cnic(struct bnx2x * bp,u8 initop)79855c11941SMerav Sicron static void bnx2x_ilt_init_op_cnic(struct bnx2x *bp, u8 initop)
79955c11941SMerav Sicron {
80055c11941SMerav Sicron if (CONFIGURE_NIC_MODE(bp))
80155c11941SMerav Sicron bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_SRC, initop);
80255c11941SMerav Sicron bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_TM, initop);
80355c11941SMerav Sicron }
80455c11941SMerav Sicron
bnx2x_ilt_init_op(struct bnx2x * bp,u8 initop)805adfc5217SJeff Kirsher static void bnx2x_ilt_init_op(struct bnx2x *bp, u8 initop)
806adfc5217SJeff Kirsher {
807adfc5217SJeff Kirsher bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_CDU, initop);
808adfc5217SJeff Kirsher bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_QM, initop);
80955c11941SMerav Sicron if (CNIC_SUPPORT(bp) && !CONFIGURE_NIC_MODE(bp))
810adfc5217SJeff Kirsher bnx2x_ilt_client_id_init_op(bp, ILT_CLIENT_SRC, initop);
811adfc5217SJeff Kirsher }
812adfc5217SJeff Kirsher
bnx2x_ilt_init_client_psz(struct bnx2x * bp,int cli_num,u32 psz_reg,u8 initop)813adfc5217SJeff Kirsher static void bnx2x_ilt_init_client_psz(struct bnx2x *bp, int cli_num,
814adfc5217SJeff Kirsher u32 psz_reg, u8 initop)
815adfc5217SJeff Kirsher {
816adfc5217SJeff Kirsher struct bnx2x_ilt *ilt = BP_ILT(bp);
817adfc5217SJeff Kirsher struct ilt_client_info *ilt_cli = &ilt->clients[cli_num];
818adfc5217SJeff Kirsher
819adfc5217SJeff Kirsher if (ilt_cli->flags & ILT_CLIENT_SKIP_INIT)
820adfc5217SJeff Kirsher return;
821adfc5217SJeff Kirsher
822adfc5217SJeff Kirsher switch (initop) {
823adfc5217SJeff Kirsher case INITOP_INIT:
824adfc5217SJeff Kirsher /* set in the init-value array */
825adfc5217SJeff Kirsher case INITOP_SET:
826adfc5217SJeff Kirsher REG_WR(bp, psz_reg, ILOG2(ilt_cli->page_size >> 12));
827adfc5217SJeff Kirsher break;
828adfc5217SJeff Kirsher case INITOP_CLEAR:
829adfc5217SJeff Kirsher break;
830adfc5217SJeff Kirsher }
831adfc5217SJeff Kirsher }
832adfc5217SJeff Kirsher
833adfc5217SJeff Kirsher /*
834adfc5217SJeff Kirsher * called during init common stage, ilt clients should be initialized
835adfc5217SJeff Kirsher * prioir to calling this function
836adfc5217SJeff Kirsher */
bnx2x_ilt_init_page_size(struct bnx2x * bp,u8 initop)837adfc5217SJeff Kirsher static void bnx2x_ilt_init_page_size(struct bnx2x *bp, u8 initop)
838adfc5217SJeff Kirsher {
839adfc5217SJeff Kirsher bnx2x_ilt_init_client_psz(bp, ILT_CLIENT_CDU,
840adfc5217SJeff Kirsher PXP2_REG_RQ_CDU_P_SIZE, initop);
841adfc5217SJeff Kirsher bnx2x_ilt_init_client_psz(bp, ILT_CLIENT_QM,
842adfc5217SJeff Kirsher PXP2_REG_RQ_QM_P_SIZE, initop);
843adfc5217SJeff Kirsher bnx2x_ilt_init_client_psz(bp, ILT_CLIENT_SRC,
844adfc5217SJeff Kirsher PXP2_REG_RQ_SRC_P_SIZE, initop);
845adfc5217SJeff Kirsher bnx2x_ilt_init_client_psz(bp, ILT_CLIENT_TM,
846adfc5217SJeff Kirsher PXP2_REG_RQ_TM_P_SIZE, initop);
847adfc5217SJeff Kirsher }
848adfc5217SJeff Kirsher
849adfc5217SJeff Kirsher /****************************************************************************
850adfc5217SJeff Kirsher * QM initializations
851adfc5217SJeff Kirsher ****************************************************************************/
852adfc5217SJeff Kirsher #define QM_QUEUES_PER_FUNC 16 /* E1 has 32, but only 16 are used */
853adfc5217SJeff Kirsher #define QM_INIT_MIN_CID_COUNT 31
854adfc5217SJeff Kirsher #define QM_INIT(cid_cnt) (cid_cnt > QM_INIT_MIN_CID_COUNT)
855adfc5217SJeff Kirsher
856adfc5217SJeff Kirsher /* called during init port stage */
bnx2x_qm_init_cid_count(struct bnx2x * bp,int qm_cid_count,u8 initop)857adfc5217SJeff Kirsher static void bnx2x_qm_init_cid_count(struct bnx2x *bp, int qm_cid_count,
858adfc5217SJeff Kirsher u8 initop)
859adfc5217SJeff Kirsher {
860adfc5217SJeff Kirsher int port = BP_PORT(bp);
861adfc5217SJeff Kirsher
862adfc5217SJeff Kirsher if (QM_INIT(qm_cid_count)) {
863adfc5217SJeff Kirsher switch (initop) {
864adfc5217SJeff Kirsher case INITOP_INIT:
865adfc5217SJeff Kirsher /* set in the init-value array */
866adfc5217SJeff Kirsher case INITOP_SET:
867adfc5217SJeff Kirsher REG_WR(bp, QM_REG_CONNNUM_0 + port*4,
868adfc5217SJeff Kirsher qm_cid_count/16 - 1);
869adfc5217SJeff Kirsher break;
870adfc5217SJeff Kirsher case INITOP_CLEAR:
871adfc5217SJeff Kirsher break;
872adfc5217SJeff Kirsher }
873adfc5217SJeff Kirsher }
874adfc5217SJeff Kirsher }
875adfc5217SJeff Kirsher
bnx2x_qm_set_ptr_table(struct bnx2x * bp,int qm_cid_count,u32 base_reg,u32 reg)876127a425eSAriel Elior static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count,
877127a425eSAriel Elior u32 base_reg, u32 reg)
878adfc5217SJeff Kirsher {
879adfc5217SJeff Kirsher int i;
880127a425eSAriel Elior u32 wb_data[2] = {0, 0};
881adfc5217SJeff Kirsher for (i = 0; i < 4 * QM_QUEUES_PER_FUNC; i++) {
882127a425eSAriel Elior REG_WR(bp, base_reg + i*4,
883adfc5217SJeff Kirsher qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC));
884127a425eSAriel Elior bnx2x_init_wr_wb(bp, reg + i*8, wb_data, 2);
885adfc5217SJeff Kirsher }
886adfc5217SJeff Kirsher }
887adfc5217SJeff Kirsher
888adfc5217SJeff Kirsher /* called during init common stage */
bnx2x_qm_init_ptr_table(struct bnx2x * bp,int qm_cid_count,u8 initop)889adfc5217SJeff Kirsher static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
890adfc5217SJeff Kirsher u8 initop)
891adfc5217SJeff Kirsher {
892adfc5217SJeff Kirsher if (!QM_INIT(qm_cid_count))
893adfc5217SJeff Kirsher return;
894adfc5217SJeff Kirsher
895adfc5217SJeff Kirsher switch (initop) {
896adfc5217SJeff Kirsher case INITOP_INIT:
897adfc5217SJeff Kirsher /* set in the init-value array */
898adfc5217SJeff Kirsher case INITOP_SET:
899127a425eSAriel Elior bnx2x_qm_set_ptr_table(bp, qm_cid_count,
900127a425eSAriel Elior QM_REG_BASEADDR, QM_REG_PTRTBL);
901127a425eSAriel Elior if (CHIP_IS_E1H(bp))
902127a425eSAriel Elior bnx2x_qm_set_ptr_table(bp, qm_cid_count,
903127a425eSAriel Elior QM_REG_BASEADDR_EXT_A,
904127a425eSAriel Elior QM_REG_PTRTBL_EXT_A);
905adfc5217SJeff Kirsher break;
906adfc5217SJeff Kirsher case INITOP_CLEAR:
907adfc5217SJeff Kirsher break;
908adfc5217SJeff Kirsher }
909adfc5217SJeff Kirsher }
910adfc5217SJeff Kirsher
911adfc5217SJeff Kirsher /****************************************************************************
912adfc5217SJeff Kirsher * SRC initializations
913adfc5217SJeff Kirsher ****************************************************************************/
914adfc5217SJeff Kirsher /* called during init func stage */
bnx2x_src_init_t2(struct bnx2x * bp,struct src_ent * t2,dma_addr_t t2_mapping,int src_cid_count)915adfc5217SJeff Kirsher static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
916adfc5217SJeff Kirsher dma_addr_t t2_mapping, int src_cid_count)
917adfc5217SJeff Kirsher {
918adfc5217SJeff Kirsher int i;
919adfc5217SJeff Kirsher int port = BP_PORT(bp);
920adfc5217SJeff Kirsher
921adfc5217SJeff Kirsher /* Initialize T2 */
922adfc5217SJeff Kirsher for (i = 0; i < src_cid_count-1; i++)
923adfc5217SJeff Kirsher t2[i].next = (u64)(t2_mapping +
924adfc5217SJeff Kirsher (i+1)*sizeof(struct src_ent));
925adfc5217SJeff Kirsher
926adfc5217SJeff Kirsher /* tell the searcher where the T2 table is */
927adfc5217SJeff Kirsher REG_WR(bp, SRC_REG_COUNTFREE0 + port*4, src_cid_count);
928adfc5217SJeff Kirsher
929adfc5217SJeff Kirsher bnx2x_wr_64(bp, SRC_REG_FIRSTFREE0 + port*16,
930adfc5217SJeff Kirsher U64_LO(t2_mapping), U64_HI(t2_mapping));
931adfc5217SJeff Kirsher
932adfc5217SJeff Kirsher bnx2x_wr_64(bp, SRC_REG_LASTFREE0 + port*16,
933adfc5217SJeff Kirsher U64_LO((u64)t2_mapping +
934adfc5217SJeff Kirsher (src_cid_count-1) * sizeof(struct src_ent)),
935adfc5217SJeff Kirsher U64_HI((u64)t2_mapping +
936adfc5217SJeff Kirsher (src_cid_count-1) * sizeof(struct src_ent)));
937adfc5217SJeff Kirsher }
938adfc5217SJeff Kirsher #endif /* BNX2X_INIT_OPS_H */
939