blob: 4b954e13c007b909f37738025b9c0c1b3c4ded9b [file] [log] [blame]
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001/*
2 * QLogic QLA41xx NIC HBA Driver
3 * Copyright (c) 2003-2006 QLogic Corporation
4 *
5 * See LICENSE.qlge for copyright and licensing details.
6 */
7#ifndef _QLGE_H_
8#define _QLGE_H_
9
10#include <linux/pci.h>
11#include <linux/netdevice.h>
Ron Mercer86aaf9a2009-10-05 11:46:49 +000012#include <linux/rtnetlink.h>
Ron Mercerc4e84bd2008-09-18 11:56:28 -040013
14/*
15 * General definitions...
16 */
17#define DRV_NAME "qlge"
18#define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver "
19#define DRV_VERSION "v1.00.00-b3"
20
21#define PFX "qlge: "
22#define QPRINTK(qdev, nlevel, klevel, fmt, args...) \
23 do { \
24 if (!((qdev)->msg_enable & NETIF_MSG_##nlevel)) \
25 ; \
26 else \
27 dev_printk(KERN_##klevel, &((qdev)->pdev->dev), \
28 "%s: " fmt, __func__, ##args); \
29 } while (0)
30
Ron Mercer88c55e32009-06-10 15:49:33 +000031#define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */
32
Ron Mercerc4e84bd2008-09-18 11:56:28 -040033#define QLGE_VENDOR_ID 0x1077
Ron Mercerb0c2aad2009-02-26 10:08:35 +000034#define QLGE_DEVICE_ID_8012 0x8012
Ron Mercercdca8d02009-03-02 08:07:31 +000035#define QLGE_DEVICE_ID_8000 0x8000
Ron Mercer683d46a2009-01-09 11:31:53 +000036#define MAX_CPUS 8
37#define MAX_TX_RINGS MAX_CPUS
38#define MAX_RX_RINGS ((MAX_CPUS * 2) + 1)
Ron Mercerc4e84bd2008-09-18 11:56:28 -040039
40#define NUM_TX_RING_ENTRIES 256
41#define NUM_RX_RING_ENTRIES 256
42
43#define NUM_SMALL_BUFFERS 512
44#define NUM_LARGE_BUFFERS 512
Ron Mercerb8facca2009-06-10 15:49:34 +000045#define DB_PAGE_SIZE 4096
Ron Mercerc4e84bd2008-09-18 11:56:28 -040046
Ron Mercerb8facca2009-06-10 15:49:34 +000047/* Calculate the number of (4k) pages required to
48 * contain a buffer queue of the given length.
49 */
50#define MAX_DB_PAGES_PER_BQ(x) \
51 (((x * sizeof(u64)) / DB_PAGE_SIZE) + \
52 (((x * sizeof(u64)) % DB_PAGE_SIZE) ? 1 : 0))
53
54#define RX_RING_SHADOW_SPACE (sizeof(u64) + \
55 MAX_DB_PAGES_PER_BQ(NUM_SMALL_BUFFERS) * sizeof(u64) + \
56 MAX_DB_PAGES_PER_BQ(NUM_LARGE_BUFFERS) * sizeof(u64))
Ron Mercer52e55f32009-10-10 09:35:07 +000057#define SMALL_BUFFER_SIZE 512
58#define SMALL_BUF_MAP_SIZE (SMALL_BUFFER_SIZE / 2)
Ron Mercer7c734352009-10-19 03:32:19 +000059#define LARGE_BUFFER_MAX_SIZE 8192
60#define LARGE_BUFFER_MIN_SIZE 2048
Ron Mercerc4e84bd2008-09-18 11:56:28 -040061#define MAX_SPLIT_SIZE 1023
62#define QLGE_SB_PAD 32
63
Ron Mercer683d46a2009-01-09 11:31:53 +000064#define MAX_CQ 128
Ron Mercerc4e84bd2008-09-18 11:56:28 -040065#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */
66#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */
67#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2)
68#define UDELAY_COUNT 3
Ron Mercerd2ba4982009-06-07 13:58:28 +000069#define UDELAY_DELAY 100
Ron Mercerc4e84bd2008-09-18 11:56:28 -040070
71
72#define TX_DESC_PER_IOCB 8
73/* The maximum number of frags we handle is based
74 * on PAGE_SIZE...
75 */
76#if (PAGE_SHIFT == 12) || (PAGE_SHIFT == 13) /* 4k & 8k pages */
77#define TX_DESC_PER_OAL ((MAX_SKB_FRAGS - TX_DESC_PER_IOCB) + 2)
Ron Mercer48501372008-10-13 22:55:59 -070078#else /* all other page sizes */
Ron Mercerc4e84bd2008-09-18 11:56:28 -040079#define TX_DESC_PER_OAL 0
80#endif
81
Ron Mercere4552f52009-06-09 05:39:32 +000082/* MPI test register definitions. This register
83 * is used for determining alternate NIC function's
84 * PCI->func number.
85 */
86enum {
87 MPI_TEST_FUNC_PORT_CFG = 0x1002,
88 MPI_TEST_NIC1_FUNC_SHIFT = 1,
89 MPI_TEST_NIC2_FUNC_SHIFT = 5,
90 MPI_TEST_NIC_FUNC_MASK = 0x00000007,
91};
92
Ron Mercerc4e84bd2008-09-18 11:56:28 -040093/*
94 * Processor Address Register (PROC_ADDR) bit definitions.
95 */
96enum {
97
98 /* Misc. stuff */
99 MAILBOX_COUNT = 16,
100
101 PROC_ADDR_RDY = (1 << 31),
102 PROC_ADDR_R = (1 << 30),
103 PROC_ADDR_ERR = (1 << 29),
104 PROC_ADDR_DA = (1 << 28),
105 PROC_ADDR_FUNC0_MBI = 0x00001180,
106 PROC_ADDR_FUNC0_MBO = (PROC_ADDR_FUNC0_MBI + MAILBOX_COUNT),
107 PROC_ADDR_FUNC0_CTL = 0x000011a1,
108 PROC_ADDR_FUNC2_MBI = 0x00001280,
109 PROC_ADDR_FUNC2_MBO = (PROC_ADDR_FUNC2_MBI + MAILBOX_COUNT),
110 PROC_ADDR_FUNC2_CTL = 0x000012a1,
111 PROC_ADDR_MPI_RISC = 0x00000000,
112 PROC_ADDR_MDE = 0x00010000,
113 PROC_ADDR_REGBLOCK = 0x00020000,
114 PROC_ADDR_RISC_REG = 0x00030000,
115};
116
117/*
118 * System Register (SYS) bit definitions.
119 */
120enum {
121 SYS_EFE = (1 << 0),
122 SYS_FAE = (1 << 1),
123 SYS_MDC = (1 << 2),
124 SYS_DST = (1 << 3),
125 SYS_DWC = (1 << 4),
126 SYS_EVW = (1 << 5),
127 SYS_OMP_DLY_MASK = 0x3f000000,
128 /*
129 * There are no values defined as of edit #15.
130 */
131 SYS_ODI = (1 << 14),
132};
133
134/*
135 * Reset/Failover Register (RST_FO) bit definitions.
136 */
137enum {
138 RST_FO_TFO = (1 << 0),
139 RST_FO_RR_MASK = 0x00060000,
140 RST_FO_RR_CQ_CAM = 0x00000000,
Ron Mercerd799bbf2009-10-05 11:46:47 +0000141 RST_FO_RR_DROP = 0x00000002,
142 RST_FO_RR_DQ = 0x00000004,
143 RST_FO_RR_RCV_FUNC_CQ = 0x00000006,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400144 RST_FO_FRB = (1 << 12),
145 RST_FO_MOP = (1 << 13),
146 RST_FO_REG = (1 << 14),
147 RST_FO_FR = (1 << 15),
148};
149
150/*
151 * Function Specific Control Register (FSC) bit definitions.
152 */
153enum {
154 FSC_DBRST_MASK = 0x00070000,
155 FSC_DBRST_256 = 0x00000000,
156 FSC_DBRST_512 = 0x00000001,
157 FSC_DBRST_768 = 0x00000002,
158 FSC_DBRST_1024 = 0x00000003,
159 FSC_DBL_MASK = 0x00180000,
160 FSC_DBL_DBRST = 0x00000000,
161 FSC_DBL_MAX_PLD = 0x00000008,
162 FSC_DBL_MAX_BRST = 0x00000010,
163 FSC_DBL_128_BYTES = 0x00000018,
164 FSC_EC = (1 << 5),
165 FSC_EPC_MASK = 0x00c00000,
166 FSC_EPC_INBOUND = (1 << 6),
167 FSC_EPC_OUTBOUND = (1 << 7),
168 FSC_VM_PAGESIZE_MASK = 0x07000000,
169 FSC_VM_PAGE_2K = 0x00000100,
170 FSC_VM_PAGE_4K = 0x00000200,
171 FSC_VM_PAGE_8K = 0x00000300,
172 FSC_VM_PAGE_64K = 0x00000600,
173 FSC_SH = (1 << 11),
174 FSC_DSB = (1 << 12),
175 FSC_STE = (1 << 13),
176 FSC_FE = (1 << 15),
177};
178
179/*
180 * Host Command Status Register (CSR) bit definitions.
181 */
182enum {
183 CSR_ERR_STS_MASK = 0x0000003f,
184 /*
185 * There are no valued defined as of edit #15.
186 */
187 CSR_RR = (1 << 8),
188 CSR_HRI = (1 << 9),
189 CSR_RP = (1 << 10),
190 CSR_CMD_PARM_SHIFT = 22,
191 CSR_CMD_NOP = 0x00000000,
Ron Mercerb82808b2009-02-26 10:08:32 +0000192 CSR_CMD_SET_RST = 0x10000000,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400193 CSR_CMD_CLR_RST = 0x20000000,
194 CSR_CMD_SET_PAUSE = 0x30000000,
195 CSR_CMD_CLR_PAUSE = 0x40000000,
196 CSR_CMD_SET_H2R_INT = 0x50000000,
197 CSR_CMD_CLR_H2R_INT = 0x60000000,
198 CSR_CMD_PAR_EN = 0x70000000,
199 CSR_CMD_SET_BAD_PAR = 0x80000000,
200 CSR_CMD_CLR_BAD_PAR = 0x90000000,
201 CSR_CMD_CLR_R2PCI_INT = 0xa0000000,
202};
203
204/*
205 * Configuration Register (CFG) bit definitions.
206 */
207enum {
208 CFG_LRQ = (1 << 0),
209 CFG_DRQ = (1 << 1),
210 CFG_LR = (1 << 2),
211 CFG_DR = (1 << 3),
212 CFG_LE = (1 << 5),
213 CFG_LCQ = (1 << 6),
214 CFG_DCQ = (1 << 7),
215 CFG_Q_SHIFT = 8,
216 CFG_Q_MASK = 0x7f000000,
217};
218
219/*
220 * Status Register (STS) bit definitions.
221 */
222enum {
223 STS_FE = (1 << 0),
224 STS_PI = (1 << 1),
225 STS_PL0 = (1 << 2),
226 STS_PL1 = (1 << 3),
227 STS_PI0 = (1 << 4),
228 STS_PI1 = (1 << 5),
229 STS_FUNC_ID_MASK = 0x000000c0,
230 STS_FUNC_ID_SHIFT = 6,
231 STS_F0E = (1 << 8),
232 STS_F1E = (1 << 9),
233 STS_F2E = (1 << 10),
234 STS_F3E = (1 << 11),
235 STS_NFE = (1 << 12),
236};
237
238/*
239 * Interrupt Enable Register (INTR_EN) bit definitions.
240 */
241enum {
242 INTR_EN_INTR_MASK = 0x007f0000,
243 INTR_EN_TYPE_MASK = 0x03000000,
244 INTR_EN_TYPE_ENABLE = 0x00000100,
245 INTR_EN_TYPE_DISABLE = 0x00000200,
246 INTR_EN_TYPE_READ = 0x00000300,
247 INTR_EN_IHD = (1 << 13),
248 INTR_EN_IHD_MASK = (INTR_EN_IHD << 16),
249 INTR_EN_EI = (1 << 14),
250 INTR_EN_EN = (1 << 15),
251};
252
253/*
254 * Interrupt Mask Register (INTR_MASK) bit definitions.
255 */
256enum {
257 INTR_MASK_PI = (1 << 0),
258 INTR_MASK_HL0 = (1 << 1),
259 INTR_MASK_LH0 = (1 << 2),
260 INTR_MASK_HL1 = (1 << 3),
261 INTR_MASK_LH1 = (1 << 4),
262 INTR_MASK_SE = (1 << 5),
263 INTR_MASK_LSC = (1 << 6),
264 INTR_MASK_MC = (1 << 7),
265 INTR_MASK_LINK_IRQS = INTR_MASK_LSC | INTR_MASK_SE | INTR_MASK_MC,
266};
267
268/*
269 * Register (REV_ID) bit definitions.
270 */
271enum {
272 REV_ID_MASK = 0x0000000f,
273 REV_ID_NICROLL_SHIFT = 0,
274 REV_ID_NICREV_SHIFT = 4,
275 REV_ID_XGROLL_SHIFT = 8,
276 REV_ID_XGREV_SHIFT = 12,
277 REV_ID_CHIPREV_SHIFT = 28,
278};
279
280/*
281 * Force ECC Error Register (FRC_ECC_ERR) bit definitions.
282 */
283enum {
284 FRC_ECC_ERR_VW = (1 << 12),
285 FRC_ECC_ERR_VB = (1 << 13),
286 FRC_ECC_ERR_NI = (1 << 14),
287 FRC_ECC_ERR_NO = (1 << 15),
288 FRC_ECC_PFE_SHIFT = 16,
289 FRC_ECC_ERR_DO = (1 << 18),
290 FRC_ECC_P14 = (1 << 19),
291};
292
293/*
294 * Error Status Register (ERR_STS) bit definitions.
295 */
296enum {
297 ERR_STS_NOF = (1 << 0),
298 ERR_STS_NIF = (1 << 1),
299 ERR_STS_DRP = (1 << 2),
300 ERR_STS_XGP = (1 << 3),
301 ERR_STS_FOU = (1 << 4),
302 ERR_STS_FOC = (1 << 5),
303 ERR_STS_FOF = (1 << 6),
304 ERR_STS_FIU = (1 << 7),
305 ERR_STS_FIC = (1 << 8),
306 ERR_STS_FIF = (1 << 9),
307 ERR_STS_MOF = (1 << 10),
308 ERR_STS_TA = (1 << 11),
309 ERR_STS_MA = (1 << 12),
310 ERR_STS_MPE = (1 << 13),
311 ERR_STS_SCE = (1 << 14),
312 ERR_STS_STE = (1 << 15),
313 ERR_STS_FOW = (1 << 16),
314 ERR_STS_UE = (1 << 17),
315 ERR_STS_MCH = (1 << 26),
316 ERR_STS_LOC_SHIFT = 27,
317};
318
319/*
320 * RAM Debug Address Register (RAM_DBG_ADDR) bit definitions.
321 */
322enum {
323 RAM_DBG_ADDR_FW = (1 << 30),
324 RAM_DBG_ADDR_FR = (1 << 31),
325};
326
327/*
328 * Semaphore Register (SEM) bit definitions.
329 */
330enum {
331 /*
332 * Example:
333 * reg = SEM_XGMAC0_MASK | (SEM_SET << SEM_XGMAC0_SHIFT)
334 */
335 SEM_CLEAR = 0,
336 SEM_SET = 1,
337 SEM_FORCE = 3,
338 SEM_XGMAC0_SHIFT = 0,
339 SEM_XGMAC1_SHIFT = 2,
340 SEM_ICB_SHIFT = 4,
341 SEM_MAC_ADDR_SHIFT = 6,
342 SEM_FLASH_SHIFT = 8,
343 SEM_PROBE_SHIFT = 10,
344 SEM_RT_IDX_SHIFT = 12,
345 SEM_PROC_REG_SHIFT = 14,
346 SEM_XGMAC0_MASK = 0x00030000,
347 SEM_XGMAC1_MASK = 0x000c0000,
348 SEM_ICB_MASK = 0x00300000,
349 SEM_MAC_ADDR_MASK = 0x00c00000,
350 SEM_FLASH_MASK = 0x03000000,
351 SEM_PROBE_MASK = 0x0c000000,
352 SEM_RT_IDX_MASK = 0x30000000,
353 SEM_PROC_REG_MASK = 0xc0000000,
354};
355
356/*
357 * 10G MAC Address Register (XGMAC_ADDR) bit definitions.
358 */
359enum {
360 XGMAC_ADDR_RDY = (1 << 31),
361 XGMAC_ADDR_R = (1 << 30),
362 XGMAC_ADDR_XME = (1 << 29),
363
364 /* XGMAC control registers */
365 PAUSE_SRC_LO = 0x00000100,
366 PAUSE_SRC_HI = 0x00000104,
367 GLOBAL_CFG = 0x00000108,
368 GLOBAL_CFG_RESET = (1 << 0),
369 GLOBAL_CFG_JUMBO = (1 << 6),
370 GLOBAL_CFG_TX_STAT_EN = (1 << 10),
371 GLOBAL_CFG_RX_STAT_EN = (1 << 11),
372 TX_CFG = 0x0000010c,
373 TX_CFG_RESET = (1 << 0),
374 TX_CFG_EN = (1 << 1),
375 TX_CFG_PREAM = (1 << 2),
376 RX_CFG = 0x00000110,
377 RX_CFG_RESET = (1 << 0),
378 RX_CFG_EN = (1 << 1),
379 RX_CFG_PREAM = (1 << 2),
380 FLOW_CTL = 0x0000011c,
381 PAUSE_OPCODE = 0x00000120,
382 PAUSE_TIMER = 0x00000124,
383 PAUSE_FRM_DEST_LO = 0x00000128,
384 PAUSE_FRM_DEST_HI = 0x0000012c,
385 MAC_TX_PARAMS = 0x00000134,
386 MAC_TX_PARAMS_JUMBO = (1 << 31),
387 MAC_TX_PARAMS_SIZE_SHIFT = 16,
388 MAC_RX_PARAMS = 0x00000138,
389 MAC_SYS_INT = 0x00000144,
390 MAC_SYS_INT_MASK = 0x00000148,
391 MAC_MGMT_INT = 0x0000014c,
392 MAC_MGMT_IN_MASK = 0x00000150,
393 EXT_ARB_MODE = 0x000001fc,
394
395 /* XGMAC TX statistics registers */
396 TX_PKTS = 0x00000200,
397 TX_BYTES = 0x00000208,
398 TX_MCAST_PKTS = 0x00000210,
399 TX_BCAST_PKTS = 0x00000218,
400 TX_UCAST_PKTS = 0x00000220,
401 TX_CTL_PKTS = 0x00000228,
402 TX_PAUSE_PKTS = 0x00000230,
403 TX_64_PKT = 0x00000238,
404 TX_65_TO_127_PKT = 0x00000240,
405 TX_128_TO_255_PKT = 0x00000248,
406 TX_256_511_PKT = 0x00000250,
407 TX_512_TO_1023_PKT = 0x00000258,
408 TX_1024_TO_1518_PKT = 0x00000260,
409 TX_1519_TO_MAX_PKT = 0x00000268,
410 TX_UNDERSIZE_PKT = 0x00000270,
411 TX_OVERSIZE_PKT = 0x00000278,
412
413 /* XGMAC statistics control registers */
414 RX_HALF_FULL_DET = 0x000002a0,
415 TX_HALF_FULL_DET = 0x000002a4,
416 RX_OVERFLOW_DET = 0x000002a8,
417 TX_OVERFLOW_DET = 0x000002ac,
418 RX_HALF_FULL_MASK = 0x000002b0,
419 TX_HALF_FULL_MASK = 0x000002b4,
420 RX_OVERFLOW_MASK = 0x000002b8,
421 TX_OVERFLOW_MASK = 0x000002bc,
422 STAT_CNT_CTL = 0x000002c0,
423 STAT_CNT_CTL_CLEAR_TX = (1 << 0),
424 STAT_CNT_CTL_CLEAR_RX = (1 << 1),
425 AUX_RX_HALF_FULL_DET = 0x000002d0,
426 AUX_TX_HALF_FULL_DET = 0x000002d4,
427 AUX_RX_OVERFLOW_DET = 0x000002d8,
428 AUX_TX_OVERFLOW_DET = 0x000002dc,
429 AUX_RX_HALF_FULL_MASK = 0x000002f0,
430 AUX_TX_HALF_FULL_MASK = 0x000002f4,
431 AUX_RX_OVERFLOW_MASK = 0x000002f8,
432 AUX_TX_OVERFLOW_MASK = 0x000002fc,
433
434 /* XGMAC RX statistics registers */
435 RX_BYTES = 0x00000300,
436 RX_BYTES_OK = 0x00000308,
437 RX_PKTS = 0x00000310,
438 RX_PKTS_OK = 0x00000318,
439 RX_BCAST_PKTS = 0x00000320,
440 RX_MCAST_PKTS = 0x00000328,
441 RX_UCAST_PKTS = 0x00000330,
442 RX_UNDERSIZE_PKTS = 0x00000338,
443 RX_OVERSIZE_PKTS = 0x00000340,
444 RX_JABBER_PKTS = 0x00000348,
445 RX_UNDERSIZE_FCERR_PKTS = 0x00000350,
446 RX_DROP_EVENTS = 0x00000358,
447 RX_FCERR_PKTS = 0x00000360,
448 RX_ALIGN_ERR = 0x00000368,
449 RX_SYMBOL_ERR = 0x00000370,
450 RX_MAC_ERR = 0x00000378,
451 RX_CTL_PKTS = 0x00000380,
Ron Mercerb82808b2009-02-26 10:08:32 +0000452 RX_PAUSE_PKTS = 0x00000388,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400453 RX_64_PKTS = 0x00000390,
454 RX_65_TO_127_PKTS = 0x00000398,
455 RX_128_255_PKTS = 0x000003a0,
456 RX_256_511_PKTS = 0x000003a8,
457 RX_512_TO_1023_PKTS = 0x000003b0,
458 RX_1024_TO_1518_PKTS = 0x000003b8,
459 RX_1519_TO_MAX_PKTS = 0x000003c0,
460 RX_LEN_ERR_PKTS = 0x000003c8,
461
462 /* XGMAC MDIO control registers */
463 MDIO_TX_DATA = 0x00000400,
464 MDIO_RX_DATA = 0x00000410,
465 MDIO_CMD = 0x00000420,
466 MDIO_PHY_ADDR = 0x00000430,
467 MDIO_PORT = 0x00000440,
468 MDIO_STATUS = 0x00000450,
469
470 /* XGMAC AUX statistics registers */
471};
472
473/*
474 * Enhanced Transmission Schedule Registers (NIC_ETS,CNA_ETS) bit definitions.
475 */
476enum {
477 ETS_QUEUE_SHIFT = 29,
478 ETS_REF = (1 << 26),
479 ETS_RS = (1 << 27),
480 ETS_P = (1 << 28),
481 ETS_FC_COS_SHIFT = 23,
482};
483
484/*
485 * Flash Address Register (FLASH_ADDR) bit definitions.
486 */
487enum {
488 FLASH_ADDR_RDY = (1 << 31),
489 FLASH_ADDR_R = (1 << 30),
490 FLASH_ADDR_ERR = (1 << 29),
491};
492
493/*
494 * Stop CQ Processing Register (CQ_STOP) bit definitions.
495 */
496enum {
497 CQ_STOP_QUEUE_MASK = (0x007f0000),
498 CQ_STOP_TYPE_MASK = (0x03000000),
499 CQ_STOP_TYPE_START = 0x00000100,
500 CQ_STOP_TYPE_STOP = 0x00000200,
501 CQ_STOP_TYPE_READ = 0x00000300,
502 CQ_STOP_EN = (1 << 15),
503};
504
505/*
506 * MAC Protocol Address Index Register (MAC_ADDR_IDX) bit definitions.
507 */
508enum {
509 MAC_ADDR_IDX_SHIFT = 4,
510 MAC_ADDR_TYPE_SHIFT = 16,
511 MAC_ADDR_TYPE_MASK = 0x000f0000,
512 MAC_ADDR_TYPE_CAM_MAC = 0x00000000,
513 MAC_ADDR_TYPE_MULTI_MAC = 0x00010000,
514 MAC_ADDR_TYPE_VLAN = 0x00020000,
515 MAC_ADDR_TYPE_MULTI_FLTR = 0x00030000,
516 MAC_ADDR_TYPE_FC_MAC = 0x00040000,
517 MAC_ADDR_TYPE_MGMT_MAC = 0x00050000,
518 MAC_ADDR_TYPE_MGMT_VLAN = 0x00060000,
519 MAC_ADDR_TYPE_MGMT_V4 = 0x00070000,
520 MAC_ADDR_TYPE_MGMT_V6 = 0x00080000,
521 MAC_ADDR_TYPE_MGMT_TU_DP = 0x00090000,
522 MAC_ADDR_ADR = (1 << 25),
523 MAC_ADDR_RS = (1 << 26),
524 MAC_ADDR_E = (1 << 27),
525 MAC_ADDR_MR = (1 << 30),
526 MAC_ADDR_MW = (1 << 31),
527 MAX_MULTICAST_ENTRIES = 32,
528};
529
530/*
531 * MAC Protocol Address Index Register (SPLT_HDR) bit definitions.
532 */
533enum {
534 SPLT_HDR_EP = (1 << 31),
535};
536
537/*
538 * FCoE Receive Configuration Register (FC_RCV_CFG) bit definitions.
539 */
540enum {
541 FC_RCV_CFG_ECT = (1 << 15),
542 FC_RCV_CFG_DFH = (1 << 20),
543 FC_RCV_CFG_DVF = (1 << 21),
544 FC_RCV_CFG_RCE = (1 << 27),
545 FC_RCV_CFG_RFE = (1 << 28),
546 FC_RCV_CFG_TEE = (1 << 29),
547 FC_RCV_CFG_TCE = (1 << 30),
548 FC_RCV_CFG_TFE = (1 << 31),
549};
550
551/*
552 * NIC Receive Configuration Register (NIC_RCV_CFG) bit definitions.
553 */
554enum {
555 NIC_RCV_CFG_PPE = (1 << 0),
556 NIC_RCV_CFG_VLAN_MASK = 0x00060000,
557 NIC_RCV_CFG_VLAN_ALL = 0x00000000,
558 NIC_RCV_CFG_VLAN_MATCH_ONLY = 0x00000002,
559 NIC_RCV_CFG_VLAN_MATCH_AND_NON = 0x00000004,
560 NIC_RCV_CFG_VLAN_NONE_AND_NON = 0x00000006,
561 NIC_RCV_CFG_RV = (1 << 3),
562 NIC_RCV_CFG_DFQ_MASK = (0x7f000000),
563 NIC_RCV_CFG_DFQ_SHIFT = 8,
564 NIC_RCV_CFG_DFQ = 0, /* HARDCODE default queue to 0. */
565};
566
567/*
568 * Mgmt Receive Configuration Register (MGMT_RCV_CFG) bit definitions.
569 */
570enum {
571 MGMT_RCV_CFG_ARP = (1 << 0),
572 MGMT_RCV_CFG_DHC = (1 << 1),
573 MGMT_RCV_CFG_DHS = (1 << 2),
574 MGMT_RCV_CFG_NP = (1 << 3),
575 MGMT_RCV_CFG_I6N = (1 << 4),
576 MGMT_RCV_CFG_I6R = (1 << 5),
577 MGMT_RCV_CFG_DH6 = (1 << 6),
578 MGMT_RCV_CFG_UD1 = (1 << 7),
579 MGMT_RCV_CFG_UD0 = (1 << 8),
580 MGMT_RCV_CFG_BCT = (1 << 9),
581 MGMT_RCV_CFG_MCT = (1 << 10),
582 MGMT_RCV_CFG_DM = (1 << 11),
583 MGMT_RCV_CFG_RM = (1 << 12),
584 MGMT_RCV_CFG_STL = (1 << 13),
585 MGMT_RCV_CFG_VLAN_MASK = 0xc0000000,
586 MGMT_RCV_CFG_VLAN_ALL = 0x00000000,
587 MGMT_RCV_CFG_VLAN_MATCH_ONLY = 0x00004000,
588 MGMT_RCV_CFG_VLAN_MATCH_AND_NON = 0x00008000,
589 MGMT_RCV_CFG_VLAN_NONE_AND_NON = 0x0000c000,
590};
591
592/*
593 * Routing Index Register (RT_IDX) bit definitions.
594 */
595enum {
596 RT_IDX_IDX_SHIFT = 8,
597 RT_IDX_TYPE_MASK = 0x000f0000,
598 RT_IDX_TYPE_RT = 0x00000000,
599 RT_IDX_TYPE_RT_INV = 0x00010000,
600 RT_IDX_TYPE_NICQ = 0x00020000,
601 RT_IDX_TYPE_NICQ_INV = 0x00030000,
602 RT_IDX_DST_MASK = 0x00700000,
603 RT_IDX_DST_RSS = 0x00000000,
604 RT_IDX_DST_CAM_Q = 0x00100000,
605 RT_IDX_DST_COS_Q = 0x00200000,
606 RT_IDX_DST_DFLT_Q = 0x00300000,
607 RT_IDX_DST_DEST_Q = 0x00400000,
608 RT_IDX_RS = (1 << 26),
609 RT_IDX_E = (1 << 27),
610 RT_IDX_MR = (1 << 30),
611 RT_IDX_MW = (1 << 31),
612
613 /* Nic Queue format - type 2 bits */
614 RT_IDX_BCAST = (1 << 0),
615 RT_IDX_MCAST = (1 << 1),
616 RT_IDX_MCAST_MATCH = (1 << 2),
617 RT_IDX_MCAST_REG_MATCH = (1 << 3),
618 RT_IDX_MCAST_HASH_MATCH = (1 << 4),
619 RT_IDX_FC_MACH = (1 << 5),
620 RT_IDX_ETH_FCOE = (1 << 6),
621 RT_IDX_CAM_HIT = (1 << 7),
622 RT_IDX_CAM_BIT0 = (1 << 8),
623 RT_IDX_CAM_BIT1 = (1 << 9),
624 RT_IDX_VLAN_TAG = (1 << 10),
625 RT_IDX_VLAN_MATCH = (1 << 11),
626 RT_IDX_VLAN_FILTER = (1 << 12),
627 RT_IDX_ETH_SKIP1 = (1 << 13),
628 RT_IDX_ETH_SKIP2 = (1 << 14),
629 RT_IDX_BCAST_MCAST_MATCH = (1 << 15),
630 RT_IDX_802_3 = (1 << 16),
631 RT_IDX_LLDP = (1 << 17),
632 RT_IDX_UNUSED018 = (1 << 18),
633 RT_IDX_UNUSED019 = (1 << 19),
634 RT_IDX_UNUSED20 = (1 << 20),
635 RT_IDX_UNUSED21 = (1 << 21),
636 RT_IDX_ERR = (1 << 22),
637 RT_IDX_VALID = (1 << 23),
638 RT_IDX_TU_CSUM_ERR = (1 << 24),
639 RT_IDX_IP_CSUM_ERR = (1 << 25),
640 RT_IDX_MAC_ERR = (1 << 26),
641 RT_IDX_RSS_TCP6 = (1 << 27),
642 RT_IDX_RSS_TCP4 = (1 << 28),
643 RT_IDX_RSS_IPV6 = (1 << 29),
644 RT_IDX_RSS_IPV4 = (1 << 30),
645 RT_IDX_RSS_MATCH = (1 << 31),
646
647 /* Hierarchy for the NIC Queue Mask */
648 RT_IDX_ALL_ERR_SLOT = 0,
649 RT_IDX_MAC_ERR_SLOT = 0,
650 RT_IDX_IP_CSUM_ERR_SLOT = 1,
651 RT_IDX_TCP_UDP_CSUM_ERR_SLOT = 2,
652 RT_IDX_BCAST_SLOT = 3,
653 RT_IDX_MCAST_MATCH_SLOT = 4,
654 RT_IDX_ALLMULTI_SLOT = 5,
655 RT_IDX_UNUSED6_SLOT = 6,
656 RT_IDX_UNUSED7_SLOT = 7,
657 RT_IDX_RSS_MATCH_SLOT = 8,
658 RT_IDX_RSS_IPV4_SLOT = 8,
659 RT_IDX_RSS_IPV6_SLOT = 9,
660 RT_IDX_RSS_TCP4_SLOT = 10,
661 RT_IDX_RSS_TCP6_SLOT = 11,
662 RT_IDX_CAM_HIT_SLOT = 12,
663 RT_IDX_UNUSED013 = 13,
664 RT_IDX_UNUSED014 = 14,
665 RT_IDX_PROMISCUOUS_SLOT = 15,
666 RT_IDX_MAX_SLOTS = 16,
667};
668
669/*
670 * Control Register Set Map
671 */
672enum {
673 PROC_ADDR = 0, /* Use semaphore */
674 PROC_DATA = 0x04, /* Use semaphore */
675 SYS = 0x08,
676 RST_FO = 0x0c,
677 FSC = 0x10,
678 CSR = 0x14,
679 LED = 0x18,
680 ICB_RID = 0x1c, /* Use semaphore */
681 ICB_L = 0x20, /* Use semaphore */
682 ICB_H = 0x24, /* Use semaphore */
683 CFG = 0x28,
684 BIOS_ADDR = 0x2c,
685 STS = 0x30,
686 INTR_EN = 0x34,
687 INTR_MASK = 0x38,
688 ISR1 = 0x3c,
689 ISR2 = 0x40,
690 ISR3 = 0x44,
691 ISR4 = 0x48,
692 REV_ID = 0x4c,
693 FRC_ECC_ERR = 0x50,
694 ERR_STS = 0x54,
695 RAM_DBG_ADDR = 0x58,
696 RAM_DBG_DATA = 0x5c,
697 ECC_ERR_CNT = 0x60,
698 SEM = 0x64,
699 GPIO_1 = 0x68, /* Use semaphore */
700 GPIO_2 = 0x6c, /* Use semaphore */
701 GPIO_3 = 0x70, /* Use semaphore */
702 RSVD2 = 0x74,
703 XGMAC_ADDR = 0x78, /* Use semaphore */
704 XGMAC_DATA = 0x7c, /* Use semaphore */
705 NIC_ETS = 0x80,
706 CNA_ETS = 0x84,
707 FLASH_ADDR = 0x88, /* Use semaphore */
708 FLASH_DATA = 0x8c, /* Use semaphore */
709 CQ_STOP = 0x90,
710 PAGE_TBL_RID = 0x94,
711 WQ_PAGE_TBL_LO = 0x98,
712 WQ_PAGE_TBL_HI = 0x9c,
713 CQ_PAGE_TBL_LO = 0xa0,
714 CQ_PAGE_TBL_HI = 0xa4,
715 MAC_ADDR_IDX = 0xa8, /* Use semaphore */
716 MAC_ADDR_DATA = 0xac, /* Use semaphore */
717 COS_DFLT_CQ1 = 0xb0,
718 COS_DFLT_CQ2 = 0xb4,
719 ETYPE_SKIP1 = 0xb8,
720 ETYPE_SKIP2 = 0xbc,
721 SPLT_HDR = 0xc0,
722 FC_PAUSE_THRES = 0xc4,
723 NIC_PAUSE_THRES = 0xc8,
724 FC_ETHERTYPE = 0xcc,
725 FC_RCV_CFG = 0xd0,
726 NIC_RCV_CFG = 0xd4,
727 FC_COS_TAGS = 0xd8,
728 NIC_COS_TAGS = 0xdc,
729 MGMT_RCV_CFG = 0xe0,
730 RT_IDX = 0xe4,
731 RT_DATA = 0xe8,
732 RSVD7 = 0xec,
733 XG_SERDES_ADDR = 0xf0,
734 XG_SERDES_DATA = 0xf4,
735 PRB_MX_ADDR = 0xf8, /* Use semaphore */
736 PRB_MX_DATA = 0xfc, /* Use semaphore */
737};
738
739/*
740 * CAM output format.
741 */
742enum {
743 CAM_OUT_ROUTE_FC = 0,
744 CAM_OUT_ROUTE_NIC = 1,
745 CAM_OUT_FUNC_SHIFT = 2,
746 CAM_OUT_RV = (1 << 4),
747 CAM_OUT_SH = (1 << 15),
748 CAM_OUT_CQ_ID_SHIFT = 5,
749};
750
751/*
752 * Mailbox definitions
753 */
754enum {
755 /* Asynchronous Event Notifications */
756 AEN_SYS_ERR = 0x00008002,
757 AEN_LINK_UP = 0x00008011,
758 AEN_LINK_DOWN = 0x00008012,
759 AEN_IDC_CMPLT = 0x00008100,
760 AEN_IDC_REQ = 0x00008101,
Ron Mercerb82808b2009-02-26 10:08:32 +0000761 AEN_IDC_EXT = 0x00008102,
762 AEN_DCBX_CHG = 0x00008110,
763 AEN_AEN_LOST = 0x00008120,
764 AEN_AEN_SFP_IN = 0x00008130,
765 AEN_AEN_SFP_OUT = 0x00008131,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400766 AEN_FW_INIT_DONE = 0x00008400,
767 AEN_FW_INIT_FAIL = 0x00008401,
768
769 /* Mailbox Command Opcodes. */
770 MB_CMD_NOP = 0x00000000,
771 MB_CMD_EX_FW = 0x00000002,
772 MB_CMD_MB_TEST = 0x00000006,
773 MB_CMD_CSUM_TEST = 0x00000007, /* Verify Checksum */
774 MB_CMD_ABOUT_FW = 0x00000008,
Ron Mercerb82808b2009-02-26 10:08:32 +0000775 MB_CMD_COPY_RISC_RAM = 0x0000000a,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400776 MB_CMD_LOAD_RISC_RAM = 0x0000000b,
777 MB_CMD_DUMP_RISC_RAM = 0x0000000c,
778 MB_CMD_WRITE_RAM = 0x0000000d,
Ron Mercerb82808b2009-02-26 10:08:32 +0000779 MB_CMD_INIT_RISC_RAM = 0x0000000e,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400780 MB_CMD_READ_RAM = 0x0000000f,
781 MB_CMD_STOP_FW = 0x00000014,
782 MB_CMD_MAKE_SYS_ERR = 0x0000002a,
Ron Mercerb82808b2009-02-26 10:08:32 +0000783 MB_CMD_WRITE_SFP = 0x00000030,
784 MB_CMD_READ_SFP = 0x00000031,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400785 MB_CMD_INIT_FW = 0x00000060,
Ron Mercerb82808b2009-02-26 10:08:32 +0000786 MB_CMD_GET_IFCB = 0x00000061,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400787 MB_CMD_GET_FW_STATE = 0x00000069,
788 MB_CMD_IDC_REQ = 0x00000100, /* Inter-Driver Communication */
789 MB_CMD_IDC_ACK = 0x00000101, /* Inter-Driver Communication */
790 MB_CMD_SET_WOL_MODE = 0x00000110, /* Wake On Lan */
Ron Mercerb82808b2009-02-26 10:08:32 +0000791 MB_WOL_DISABLE = 0,
792 MB_WOL_MAGIC_PKT = (1 << 1),
793 MB_WOL_FLTR = (1 << 2),
794 MB_WOL_UCAST = (1 << 3),
795 MB_WOL_MCAST = (1 << 4),
796 MB_WOL_BCAST = (1 << 5),
797 MB_WOL_LINK_UP = (1 << 6),
798 MB_WOL_LINK_DOWN = (1 << 7),
Ron Mercerbc083ce2009-10-21 11:07:40 +0000799 MB_WOL_MODE_ON = (1 << 16), /* Wake on Lan Mode on */
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400800 MB_CMD_SET_WOL_FLTR = 0x00000111, /* Wake On Lan Filter */
Ron Mercerb82808b2009-02-26 10:08:32 +0000801 MB_CMD_CLEAR_WOL_FLTR = 0x00000112, /* Wake On Lan Filter */
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400802 MB_CMD_SET_WOL_MAGIC = 0x00000113, /* Wake On Lan Magic Packet */
Ron Mercerb82808b2009-02-26 10:08:32 +0000803 MB_CMD_CLEAR_WOL_MAGIC = 0x00000114,/* Wake On Lan Magic Packet */
804 MB_CMD_SET_WOL_IMMED = 0x00000115,
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400805 MB_CMD_PORT_RESET = 0x00000120,
806 MB_CMD_SET_PORT_CFG = 0x00000122,
807 MB_CMD_GET_PORT_CFG = 0x00000123,
Ron Mercerb82808b2009-02-26 10:08:32 +0000808 MB_CMD_GET_LINK_STS = 0x00000124,
Ron Mercerd8eb59d2009-10-21 11:07:39 +0000809 MB_CMD_SET_LED_CFG = 0x00000125, /* Set LED Configuration Register */
810 QL_LED_BLINK = 0x03e803e8,
811 MB_CMD_GET_LED_CFG = 0x00000126, /* Get LED Configuration Register */
Ron Mercer84087f42009-10-08 09:54:41 +0000812 MB_CMD_SET_MGMNT_TFK_CTL = 0x00000160, /* Set Mgmnt Traffic Control */
813 MB_SET_MPI_TFK_STOP = (1 << 0),
814 MB_SET_MPI_TFK_RESUME = (1 << 1),
815 MB_CMD_GET_MGMNT_TFK_CTL = 0x00000161, /* Get Mgmnt Traffic Control */
816 MB_GET_MPI_TFK_STOPPED = (1 << 0),
817 MB_GET_MPI_TFK_FIFO_EMPTY = (1 << 1),
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400818
819 /* Mailbox Command Status. */
820 MB_CMD_STS_GOOD = 0x00004000, /* Success. */
821 MB_CMD_STS_INTRMDT = 0x00001000, /* Intermediate Complete. */
Ron Mercerb82808b2009-02-26 10:08:32 +0000822 MB_CMD_STS_INVLD_CMD = 0x00004001, /* Invalid. */
823 MB_CMD_STS_XFC_ERR = 0x00004002, /* Interface Error. */
824 MB_CMD_STS_CSUM_ERR = 0x00004003, /* Csum Error. */
825 MB_CMD_STS_ERR = 0x00004005, /* System Error. */
826 MB_CMD_STS_PARAM_ERR = 0x00004006, /* Parameter Error. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400827};
828
829struct mbox_params {
830 u32 mbox_in[MAILBOX_COUNT];
831 u32 mbox_out[MAILBOX_COUNT];
832 int in_count;
833 int out_count;
834};
835
Ron Mercerb0c2aad2009-02-26 10:08:35 +0000836struct flash_params_8012 {
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400837 u8 dev_id_str[4];
Ron Mercer26351472009-02-02 13:53:57 -0800838 __le16 size;
839 __le16 csum;
840 __le16 ver;
841 __le16 sub_dev_id;
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400842 u8 mac_addr[6];
Ron Mercer26351472009-02-02 13:53:57 -0800843 __le16 res;
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400844};
845
Ron Mercercdca8d02009-03-02 08:07:31 +0000846/* 8000 device's flash is a different structure
847 * at a different offset in flash.
848 */
849#define FUNC0_FLASH_OFFSET 0x140200
850#define FUNC1_FLASH_OFFSET 0x140600
851
852/* Flash related data structures. */
853struct flash_params_8000 {
854 u8 dev_id_str[4]; /* "8000" */
855 __le16 ver;
856 __le16 size;
857 __le16 csum;
858 __le16 reserved0;
859 __le16 total_size;
860 __le16 entry_count;
861 u8 data_type0;
862 u8 data_size0;
863 u8 mac_addr[6];
864 u8 data_type1;
865 u8 data_size1;
866 u8 mac_addr1[6];
867 u8 data_type2;
868 u8 data_size2;
869 __le16 vlan_id;
870 u8 data_type3;
871 u8 data_size3;
872 __le16 last;
873 u8 reserved1[464];
874 __le16 subsys_ven_id;
875 __le16 subsys_dev_id;
876 u8 reserved2[4];
877};
878
Ron Mercerb0c2aad2009-02-26 10:08:35 +0000879union flash_params {
880 struct flash_params_8012 flash_params_8012;
Ron Mercercdca8d02009-03-02 08:07:31 +0000881 struct flash_params_8000 flash_params_8000;
Ron Mercerb0c2aad2009-02-26 10:08:35 +0000882};
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400883
884/*
885 * doorbell space for the rx ring context
886 */
887struct rx_doorbell_context {
888 u32 cnsmr_idx; /* 0x00 */
889 u32 valid; /* 0x04 */
890 u32 reserved[4]; /* 0x08-0x14 */
891 u32 lbq_prod_idx; /* 0x18 */
892 u32 sbq_prod_idx; /* 0x1c */
893};
894
895/*
896 * doorbell space for the tx ring context
897 */
898struct tx_doorbell_context {
899 u32 prod_idx; /* 0x00 */
900 u32 valid; /* 0x04 */
901 u32 reserved[4]; /* 0x08-0x14 */
902 u32 lbq_prod_idx; /* 0x18 */
903 u32 sbq_prod_idx; /* 0x1c */
904};
905
906/* DATA STRUCTURES SHARED WITH HARDWARE. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400907struct tx_buf_desc {
908 __le64 addr;
909 __le32 len;
910#define TX_DESC_LEN_MASK 0x000fffff
911#define TX_DESC_C 0x40000000
912#define TX_DESC_E 0x80000000
913} __attribute((packed));
914
915/*
916 * IOCB Definitions...
917 */
918
919#define OPCODE_OB_MAC_IOCB 0x01
920#define OPCODE_OB_MAC_TSO_IOCB 0x02
921#define OPCODE_IB_MAC_IOCB 0x20
922#define OPCODE_IB_MPI_IOCB 0x21
923#define OPCODE_IB_AE_IOCB 0x3f
924
925struct ob_mac_iocb_req {
926 u8 opcode;
927 u8 flags1;
928#define OB_MAC_IOCB_REQ_OI 0x01
929#define OB_MAC_IOCB_REQ_I 0x02
930#define OB_MAC_IOCB_REQ_D 0x08
931#define OB_MAC_IOCB_REQ_F 0x10
932 u8 flags2;
933 u8 flags3;
934#define OB_MAC_IOCB_DFP 0x02
935#define OB_MAC_IOCB_V 0x04
936 __le32 reserved1[2];
937 __le16 frame_len;
938#define OB_MAC_IOCB_LEN_MASK 0x3ffff
939 __le16 reserved2;
Ron Mercer3537d542009-01-05 18:19:59 -0800940 u32 tid;
941 u32 txq_idx;
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400942 __le32 reserved3;
943 __le16 vlan_tci;
944 __le16 reserved4;
945 struct tx_buf_desc tbd[TX_DESC_PER_IOCB];
946} __attribute((packed));
947
948struct ob_mac_iocb_rsp {
949 u8 opcode; /* */
950 u8 flags1; /* */
951#define OB_MAC_IOCB_RSP_OI 0x01 /* */
952#define OB_MAC_IOCB_RSP_I 0x02 /* */
953#define OB_MAC_IOCB_RSP_E 0x08 /* */
954#define OB_MAC_IOCB_RSP_S 0x10 /* too Short */
955#define OB_MAC_IOCB_RSP_L 0x20 /* too Large */
956#define OB_MAC_IOCB_RSP_P 0x40 /* Padded */
957 u8 flags2; /* */
958 u8 flags3; /* */
959#define OB_MAC_IOCB_RSP_B 0x80 /* */
Ron Mercer3537d542009-01-05 18:19:59 -0800960 u32 tid;
961 u32 txq_idx;
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400962 __le32 reserved[13];
963} __attribute((packed));
964
965struct ob_mac_tso_iocb_req {
966 u8 opcode;
967 u8 flags1;
968#define OB_MAC_TSO_IOCB_OI 0x01
969#define OB_MAC_TSO_IOCB_I 0x02
970#define OB_MAC_TSO_IOCB_D 0x08
971#define OB_MAC_TSO_IOCB_IP4 0x40
972#define OB_MAC_TSO_IOCB_IP6 0x80
973 u8 flags2;
974#define OB_MAC_TSO_IOCB_LSO 0x20
975#define OB_MAC_TSO_IOCB_UC 0x40
976#define OB_MAC_TSO_IOCB_TC 0x80
977 u8 flags3;
978#define OB_MAC_TSO_IOCB_IC 0x01
979#define OB_MAC_TSO_IOCB_DFP 0x02
980#define OB_MAC_TSO_IOCB_V 0x04
981 __le32 reserved1[2];
982 __le32 frame_len;
Ron Mercer3537d542009-01-05 18:19:59 -0800983 u32 tid;
984 u32 txq_idx;
Ron Mercerc4e84bd2008-09-18 11:56:28 -0400985 __le16 total_hdrs_len;
986 __le16 net_trans_offset;
987#define OB_MAC_TRANSPORT_HDR_SHIFT 6
988 __le16 vlan_tci;
989 __le16 mss;
990 struct tx_buf_desc tbd[TX_DESC_PER_IOCB];
991} __attribute((packed));
992
993struct ob_mac_tso_iocb_rsp {
994 u8 opcode;
995 u8 flags1;
996#define OB_MAC_TSO_IOCB_RSP_OI 0x01
997#define OB_MAC_TSO_IOCB_RSP_I 0x02
998#define OB_MAC_TSO_IOCB_RSP_E 0x08
999#define OB_MAC_TSO_IOCB_RSP_S 0x10
1000#define OB_MAC_TSO_IOCB_RSP_L 0x20
1001#define OB_MAC_TSO_IOCB_RSP_P 0x40
1002 u8 flags2; /* */
1003 u8 flags3; /* */
1004#define OB_MAC_TSO_IOCB_RSP_B 0x8000
Ron Mercer3537d542009-01-05 18:19:59 -08001005 u32 tid;
1006 u32 txq_idx;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001007 __le32 reserved2[13];
1008} __attribute((packed));
1009
1010struct ib_mac_iocb_rsp {
1011 u8 opcode; /* 0x20 */
1012 u8 flags1;
1013#define IB_MAC_IOCB_RSP_OI 0x01 /* Overide intr delay */
1014#define IB_MAC_IOCB_RSP_I 0x02 /* Disble Intr Generation */
Ron Mercerd555f592009-03-09 10:59:19 +00001015#define IB_MAC_CSUM_ERR_MASK 0x1c /* A mask to use for csum errs */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001016#define IB_MAC_IOCB_RSP_TE 0x04 /* Checksum error */
1017#define IB_MAC_IOCB_RSP_NU 0x08 /* No checksum rcvd */
1018#define IB_MAC_IOCB_RSP_IE 0x10 /* IPv4 checksum error */
1019#define IB_MAC_IOCB_RSP_M_MASK 0x60 /* Multicast info */
1020#define IB_MAC_IOCB_RSP_M_NONE 0x00 /* Not mcast frame */
1021#define IB_MAC_IOCB_RSP_M_HASH 0x20 /* HASH mcast frame */
1022#define IB_MAC_IOCB_RSP_M_REG 0x40 /* Registered mcast frame */
1023#define IB_MAC_IOCB_RSP_M_PROM 0x60 /* Promiscuous mcast frame */
1024#define IB_MAC_IOCB_RSP_B 0x80 /* Broadcast frame */
1025 u8 flags2;
1026#define IB_MAC_IOCB_RSP_P 0x01 /* Promiscuous frame */
1027#define IB_MAC_IOCB_RSP_V 0x02 /* Vlan tag present */
1028#define IB_MAC_IOCB_RSP_ERR_MASK 0x1c /* */
1029#define IB_MAC_IOCB_RSP_ERR_CODE_ERR 0x04
1030#define IB_MAC_IOCB_RSP_ERR_OVERSIZE 0x08
1031#define IB_MAC_IOCB_RSP_ERR_UNDERSIZE 0x10
1032#define IB_MAC_IOCB_RSP_ERR_PREAMBLE 0x14
1033#define IB_MAC_IOCB_RSP_ERR_FRAME_LEN 0x18
1034#define IB_MAC_IOCB_RSP_ERR_CRC 0x1c
1035#define IB_MAC_IOCB_RSP_U 0x20 /* UDP packet */
1036#define IB_MAC_IOCB_RSP_T 0x40 /* TCP packet */
1037#define IB_MAC_IOCB_RSP_FO 0x80 /* Failover port */
1038 u8 flags3;
1039#define IB_MAC_IOCB_RSP_RSS_MASK 0x07 /* RSS mask */
1040#define IB_MAC_IOCB_RSP_M_NONE 0x00 /* No RSS match */
1041#define IB_MAC_IOCB_RSP_M_IPV4 0x04 /* IPv4 RSS match */
1042#define IB_MAC_IOCB_RSP_M_IPV6 0x02 /* IPv6 RSS match */
1043#define IB_MAC_IOCB_RSP_M_TCP_V4 0x05 /* TCP with IPv4 */
1044#define IB_MAC_IOCB_RSP_M_TCP_V6 0x03 /* TCP with IPv6 */
1045#define IB_MAC_IOCB_RSP_V4 0x08 /* IPV4 */
1046#define IB_MAC_IOCB_RSP_V6 0x10 /* IPV6 */
1047#define IB_MAC_IOCB_RSP_IH 0x20 /* Split after IP header */
1048#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */
1049#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */
1050 __le32 data_len; /* */
Ron Mercer97345522009-01-09 11:31:50 +00001051 __le64 data_addr; /* */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001052 __le32 rss; /* */
1053 __le16 vlan_id; /* 12 bits */
1054#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */
1055#define IB_MAC_IOCB_RSP_COS_SHIFT 12 /* class of service value */
Ron Mercerb82808b2009-02-26 10:08:32 +00001056#define IB_MAC_IOCB_RSP_VLAN_MASK 0x0ffff
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001057
1058 __le16 reserved1;
1059 __le32 reserved2[6];
Ron Mercera303ce02009-01-05 18:18:22 -08001060 u8 reserved3[3];
1061 u8 flags4;
1062#define IB_MAC_IOCB_RSP_HV 0x20
1063#define IB_MAC_IOCB_RSP_HS 0x40
1064#define IB_MAC_IOCB_RSP_HL 0x80
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001065 __le32 hdr_len; /* */
Ron Mercer97345522009-01-09 11:31:50 +00001066 __le64 hdr_addr; /* */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001067} __attribute((packed));
1068
1069struct ib_ae_iocb_rsp {
1070 u8 opcode;
1071 u8 flags1;
1072#define IB_AE_IOCB_RSP_OI 0x01
1073#define IB_AE_IOCB_RSP_I 0x02
1074 u8 event;
1075#define LINK_UP_EVENT 0x00
1076#define LINK_DOWN_EVENT 0x01
1077#define CAM_LOOKUP_ERR_EVENT 0x06
1078#define SOFT_ECC_ERROR_EVENT 0x07
1079#define MGMT_ERR_EVENT 0x08
1080#define TEN_GIG_MAC_EVENT 0x09
1081#define GPI0_H2L_EVENT 0x10
1082#define GPI0_L2H_EVENT 0x20
1083#define GPI1_H2L_EVENT 0x11
1084#define GPI1_L2H_EVENT 0x21
1085#define PCI_ERR_ANON_BUF_RD 0x40
1086 u8 q_id;
1087 __le32 reserved[15];
1088} __attribute((packed));
1089
1090/*
1091 * These three structures are for generic
1092 * handling of ib and ob iocbs.
1093 */
1094struct ql_net_rsp_iocb {
1095 u8 opcode;
1096 u8 flags0;
1097 __le16 length;
1098 __le32 tid;
1099 __le32 reserved[14];
1100} __attribute((packed));
1101
1102struct net_req_iocb {
1103 u8 opcode;
1104 u8 flags0;
1105 __le16 flags1;
1106 __le32 tid;
1107 __le32 reserved1[30];
1108} __attribute((packed));
1109
1110/*
1111 * tx ring initialization control block for chip.
1112 * It is defined as:
1113 * "Work Queue Initialization Control Block"
1114 */
1115struct wqicb {
1116 __le16 len;
1117#define Q_LEN_V (1 << 4)
1118#define Q_LEN_CPP_CONT 0x0000
1119#define Q_LEN_CPP_16 0x0001
1120#define Q_LEN_CPP_32 0x0002
1121#define Q_LEN_CPP_64 0x0003
Ron Mercerb82808b2009-02-26 10:08:32 +00001122#define Q_LEN_CPP_512 0x0006
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001123 __le16 flags;
1124#define Q_PRI_SHIFT 1
1125#define Q_FLAGS_LC 0x1000
1126#define Q_FLAGS_LB 0x2000
1127#define Q_FLAGS_LI 0x4000
1128#define Q_FLAGS_LO 0x8000
1129 __le16 cq_id_rss;
1130#define Q_CQ_ID_RSS_RV 0x8000
1131 __le16 rid;
Ron Mercer97345522009-01-09 11:31:50 +00001132 __le64 addr;
1133 __le64 cnsmr_idx_addr;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001134} __attribute((packed));
1135
1136/*
1137 * rx ring initialization control block for chip.
1138 * It is defined as:
1139 * "Completion Queue Initialization Control Block"
1140 */
1141struct cqicb {
1142 u8 msix_vect;
1143 u8 reserved1;
1144 u8 reserved2;
1145 u8 flags;
1146#define FLAGS_LV 0x08
1147#define FLAGS_LS 0x10
1148#define FLAGS_LL 0x20
1149#define FLAGS_LI 0x40
1150#define FLAGS_LC 0x80
1151 __le16 len;
1152#define LEN_V (1 << 4)
1153#define LEN_CPP_CONT 0x0000
1154#define LEN_CPP_32 0x0001
1155#define LEN_CPP_64 0x0002
1156#define LEN_CPP_128 0x0003
1157 __le16 rid;
Ron Mercer97345522009-01-09 11:31:50 +00001158 __le64 addr;
1159 __le64 prod_idx_addr;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001160 __le16 pkt_delay;
1161 __le16 irq_delay;
Ron Mercer97345522009-01-09 11:31:50 +00001162 __le64 lbq_addr;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001163 __le16 lbq_buf_size;
1164 __le16 lbq_len; /* entry count */
Ron Mercer97345522009-01-09 11:31:50 +00001165 __le64 sbq_addr;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001166 __le16 sbq_buf_size;
1167 __le16 sbq_len; /* entry count */
1168} __attribute((packed));
1169
1170struct ricb {
1171 u8 base_cq;
1172#define RSS_L4K 0x80
1173 u8 flags;
1174#define RSS_L6K 0x01
1175#define RSS_LI 0x02
1176#define RSS_LB 0x04
1177#define RSS_LM 0x08
1178#define RSS_RI4 0x10
1179#define RSS_RT4 0x20
1180#define RSS_RI6 0x40
1181#define RSS_RT6 0x80
1182 __le16 mask;
Ron Mercer541ae282009-10-08 09:54:37 +00001183 u8 hash_cq_id[1024];
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001184 __le32 ipv6_hash_key[10];
1185 __le32 ipv4_hash_key[4];
1186} __attribute((packed));
1187
1188/* SOFTWARE/DRIVER DATA STRUCTURES. */
1189
1190struct oal {
1191 struct tx_buf_desc oal[TX_DESC_PER_OAL];
1192};
1193
1194struct map_list {
1195 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1196 DECLARE_PCI_UNMAP_LEN(maplen);
1197};
1198
1199struct tx_ring_desc {
1200 struct sk_buff *skb;
1201 struct ob_mac_iocb_req *queue_entry;
Ron Mercer3537d542009-01-05 18:19:59 -08001202 u32 index;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001203 struct oal oal;
1204 struct map_list map[MAX_SKB_FRAGS + 1];
1205 int map_cnt;
1206 struct tx_ring_desc *next;
1207};
1208
Ron Mercer7c734352009-10-19 03:32:19 +00001209struct page_chunk {
1210 struct page *page; /* master page */
1211 char *va; /* virt addr for this chunk */
1212 u64 map; /* mapping for master */
1213 unsigned int offset; /* offset for this chunk */
1214 unsigned int last_flag; /* flag set for last chunk in page */
1215};
1216
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001217struct bq_desc {
1218 union {
Ron Mercer7c734352009-10-19 03:32:19 +00001219 struct page_chunk pg_chunk;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001220 struct sk_buff *skb;
1221 } p;
Ron Mercer2c9a0d42009-01-05 18:19:20 -08001222 __le64 *addr;
Ron Mercer3537d542009-01-05 18:19:59 -08001223 u32 index;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001224 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1225 DECLARE_PCI_UNMAP_LEN(maplen);
1226};
1227
1228#define QL_TXQ_IDX(qdev, skb) (smp_processor_id()%(qdev->tx_ring_count))
1229
1230struct tx_ring {
1231 /*
1232 * queue info.
1233 */
1234 struct wqicb wqicb; /* structure used to inform chip of new queue */
1235 void *wq_base; /* pci_alloc:virtual addr for tx */
1236 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */
Ron Mercerba7cd3b2009-01-09 11:31:49 +00001237 __le32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001238 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */
1239 u32 wq_size; /* size in bytes of queue area */
1240 u32 wq_len; /* number of entries in queue */
1241 void __iomem *prod_idx_db_reg; /* doorbell area index reg at offset 0x00 */
1242 void __iomem *valid_db_reg; /* doorbell area valid reg at offset 0x04 */
1243 u16 prod_idx; /* current value for prod idx */
1244 u16 cq_id; /* completion (rx) queue for tx completions */
1245 u8 wq_id; /* queue id for this entry */
1246 u8 reserved1[3];
1247 struct tx_ring_desc *q; /* descriptor list for the queue */
1248 spinlock_t lock;
1249 atomic_t tx_count; /* counts down for every outstanding IO */
1250 atomic_t queue_stopped; /* Turns queue off when full. */
1251 struct delayed_work tx_work;
1252 struct ql_adapter *qdev;
1253};
1254
1255/*
1256 * Type of inbound queue.
1257 */
1258enum {
1259 DEFAULT_Q = 2, /* Handles slow queue and chip/MPI events. */
1260 TX_Q = 3, /* Handles outbound completions. */
1261 RX_Q = 4, /* Handles inbound completions. */
1262};
1263
1264struct rx_ring {
1265 struct cqicb cqicb; /* The chip's completion queue init control block. */
1266
1267 /* Completion queue elements. */
1268 void *cq_base;
1269 dma_addr_t cq_base_dma;
1270 u32 cq_size;
1271 u32 cq_len;
1272 u16 cq_id;
Ron Mercerba7cd3b2009-01-09 11:31:49 +00001273 __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001274 dma_addr_t prod_idx_sh_reg_dma;
1275 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1276 u32 cnsmr_idx; /* current sw idx */
1277 struct ql_net_rsp_iocb *curr_entry; /* next entry on queue */
1278 void __iomem *valid_db_reg; /* PCI doorbell mem area + 0x04 */
1279
1280 /* Large buffer queue elements. */
1281 u32 lbq_len; /* entry count */
1282 u32 lbq_size; /* size in bytes of queue */
1283 u32 lbq_buf_size;
1284 void *lbq_base;
1285 dma_addr_t lbq_base_dma;
1286 void *lbq_base_indirect;
1287 dma_addr_t lbq_base_indirect_dma;
Ron Mercer7c734352009-10-19 03:32:19 +00001288 struct page_chunk pg_chunk; /* current page for chunks */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001289 struct bq_desc *lbq; /* array of control blocks */
1290 void __iomem *lbq_prod_idx_db_reg; /* PCI doorbell mem area + 0x18 */
1291 u32 lbq_prod_idx; /* current sw prod idx */
1292 u32 lbq_curr_idx; /* next entry we expect */
1293 u32 lbq_clean_idx; /* beginning of new descs */
1294 u32 lbq_free_cnt; /* free buffer desc cnt */
1295
1296 /* Small buffer queue elements. */
1297 u32 sbq_len; /* entry count */
1298 u32 sbq_size; /* size in bytes of queue */
1299 u32 sbq_buf_size;
1300 void *sbq_base;
1301 dma_addr_t sbq_base_dma;
1302 void *sbq_base_indirect;
1303 dma_addr_t sbq_base_indirect_dma;
1304 struct bq_desc *sbq; /* array of control blocks */
1305 void __iomem *sbq_prod_idx_db_reg; /* PCI doorbell mem area + 0x1c */
1306 u32 sbq_prod_idx; /* current sw prod idx */
1307 u32 sbq_curr_idx; /* next entry we expect */
1308 u32 sbq_clean_idx; /* beginning of new descs */
1309 u32 sbq_free_cnt; /* free buffer desc cnt */
1310
1311 /* Misc. handler elements. */
Ron Mercerb2014ff2009-08-27 11:02:09 +00001312 u32 type; /* Type of queue, tx, rx. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001313 u32 irq; /* Which vector this ring is assigned. */
1314 u32 cpu; /* Which CPU this should run on. */
1315 char name[IFNAMSIZ + 5];
1316 struct napi_struct napi;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001317 u8 reserved;
1318 struct ql_adapter *qdev;
1319};
1320
1321/*
1322 * RSS Initialization Control Block
1323 */
1324struct hash_id {
1325 u8 value[4];
1326};
1327
1328struct nic_stats {
1329 /*
1330 * These stats come from offset 200h to 278h
1331 * in the XGMAC register.
1332 */
1333 u64 tx_pkts;
1334 u64 tx_bytes;
1335 u64 tx_mcast_pkts;
1336 u64 tx_bcast_pkts;
1337 u64 tx_ucast_pkts;
1338 u64 tx_ctl_pkts;
1339 u64 tx_pause_pkts;
1340 u64 tx_64_pkt;
1341 u64 tx_65_to_127_pkt;
1342 u64 tx_128_to_255_pkt;
1343 u64 tx_256_511_pkt;
1344 u64 tx_512_to_1023_pkt;
1345 u64 tx_1024_to_1518_pkt;
1346 u64 tx_1519_to_max_pkt;
1347 u64 tx_undersize_pkt;
1348 u64 tx_oversize_pkt;
1349
1350 /*
1351 * These stats come from offset 300h to 3C8h
1352 * in the XGMAC register.
1353 */
1354 u64 rx_bytes;
1355 u64 rx_bytes_ok;
1356 u64 rx_pkts;
1357 u64 rx_pkts_ok;
1358 u64 rx_bcast_pkts;
1359 u64 rx_mcast_pkts;
1360 u64 rx_ucast_pkts;
1361 u64 rx_undersize_pkts;
1362 u64 rx_oversize_pkts;
1363 u64 rx_jabber_pkts;
1364 u64 rx_undersize_fcerr_pkts;
1365 u64 rx_drop_events;
1366 u64 rx_fcerr_pkts;
1367 u64 rx_align_err;
1368 u64 rx_symbol_err;
1369 u64 rx_mac_err;
1370 u64 rx_ctl_pkts;
1371 u64 rx_pause_pkts;
1372 u64 rx_64_pkts;
1373 u64 rx_65_to_127_pkts;
1374 u64 rx_128_255_pkts;
1375 u64 rx_256_511_pkts;
1376 u64 rx_512_to_1023_pkts;
1377 u64 rx_1024_to_1518_pkts;
1378 u64 rx_1519_to_max_pkts;
1379 u64 rx_len_err_pkts;
Ron Mercer6abd2342009-10-10 09:35:10 +00001380 /*
1381 * These stats come from offset 500h to 5C8h
1382 * in the XGMAC register.
1383 */
1384 u64 tx_cbfc_pause_frames0;
1385 u64 tx_cbfc_pause_frames1;
1386 u64 tx_cbfc_pause_frames2;
1387 u64 tx_cbfc_pause_frames3;
1388 u64 tx_cbfc_pause_frames4;
1389 u64 tx_cbfc_pause_frames5;
1390 u64 tx_cbfc_pause_frames6;
1391 u64 tx_cbfc_pause_frames7;
1392 u64 rx_cbfc_pause_frames0;
1393 u64 rx_cbfc_pause_frames1;
1394 u64 rx_cbfc_pause_frames2;
1395 u64 rx_cbfc_pause_frames3;
1396 u64 rx_cbfc_pause_frames4;
1397 u64 rx_cbfc_pause_frames5;
1398 u64 rx_cbfc_pause_frames6;
1399 u64 rx_cbfc_pause_frames7;
1400 u64 rx_nic_fifo_drop;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001401};
1402
Ron Mercera61f8022009-10-21 11:07:41 +00001403/* Address/Length pairs for the coredump. */
1404enum {
1405 MPI_CORE_REGS_ADDR = 0x00030000,
1406 MPI_CORE_REGS_CNT = 127,
1407 MPI_CORE_SH_REGS_CNT = 16,
1408 TEST_REGS_ADDR = 0x00001000,
1409 TEST_REGS_CNT = 23,
1410 RMII_REGS_ADDR = 0x00001040,
1411 RMII_REGS_CNT = 64,
1412 FCMAC1_REGS_ADDR = 0x00001080,
1413 FCMAC2_REGS_ADDR = 0x000010c0,
1414 FCMAC_REGS_CNT = 64,
1415 FC1_MBX_REGS_ADDR = 0x00001100,
1416 FC2_MBX_REGS_ADDR = 0x00001240,
1417 FC_MBX_REGS_CNT = 64,
1418 IDE_REGS_ADDR = 0x00001140,
1419 IDE_REGS_CNT = 64,
1420 NIC1_MBX_REGS_ADDR = 0x00001180,
1421 NIC2_MBX_REGS_ADDR = 0x00001280,
1422 NIC_MBX_REGS_CNT = 64,
1423 SMBUS_REGS_ADDR = 0x00001200,
1424 SMBUS_REGS_CNT = 64,
1425 I2C_REGS_ADDR = 0x00001fc0,
1426 I2C_REGS_CNT = 64,
1427 MEMC_REGS_ADDR = 0x00003000,
1428 MEMC_REGS_CNT = 256,
1429 PBUS_REGS_ADDR = 0x00007c00,
1430 PBUS_REGS_CNT = 256,
1431 MDE_REGS_ADDR = 0x00010000,
1432 MDE_REGS_CNT = 6,
1433 CODE_RAM_ADDR = 0x00020000,
1434 CODE_RAM_CNT = 0x2000,
1435 MEMC_RAM_ADDR = 0x00100000,
1436 MEMC_RAM_CNT = 0x2000,
1437};
1438
1439#define MPI_COREDUMP_COOKIE 0x5555aaaa
1440struct mpi_coredump_global_header {
1441 u32 cookie;
1442 u8 idString[16];
1443 u32 timeLo;
1444 u32 timeHi;
1445 u32 imageSize;
1446 u32 headerSize;
1447 u8 info[220];
1448};
1449
1450struct mpi_coredump_segment_header {
1451 u32 cookie;
1452 u32 segNum;
1453 u32 segSize;
1454 u32 extra;
1455 u8 description[16];
1456};
1457
1458/* Reg dump segment numbers. */
1459enum {
1460 CORE_SEG_NUM = 1,
1461 TEST_LOGIC_SEG_NUM = 2,
1462 RMII_SEG_NUM = 3,
1463 FCMAC1_SEG_NUM = 4,
1464 FCMAC2_SEG_NUM = 5,
1465 FC1_MBOX_SEG_NUM = 6,
1466 IDE_SEG_NUM = 7,
1467 NIC1_MBOX_SEG_NUM = 8,
1468 SMBUS_SEG_NUM = 9,
1469 FC2_MBOX_SEG_NUM = 10,
1470 NIC2_MBOX_SEG_NUM = 11,
1471 I2C_SEG_NUM = 12,
1472 MEMC_SEG_NUM = 13,
1473 PBUS_SEG_NUM = 14,
1474 MDE_SEG_NUM = 15,
1475 NIC1_CONTROL_SEG_NUM = 16,
1476 NIC2_CONTROL_SEG_NUM = 17,
1477 NIC1_XGMAC_SEG_NUM = 18,
1478 NIC2_XGMAC_SEG_NUM = 19,
1479 WCS_RAM_SEG_NUM = 20,
1480 MEMC_RAM_SEG_NUM = 21,
1481 XAUI_AN_SEG_NUM = 22,
1482 XAUI_HSS_PCS_SEG_NUM = 23,
1483 XFI_AN_SEG_NUM = 24,
1484 XFI_TRAIN_SEG_NUM = 25,
1485 XFI_HSS_PCS_SEG_NUM = 26,
1486 XFI_HSS_TX_SEG_NUM = 27,
1487 XFI_HSS_RX_SEG_NUM = 28,
1488 XFI_HSS_PLL_SEG_NUM = 29,
1489 MISC_NIC_INFO_SEG_NUM = 30,
1490 INTR_STATES_SEG_NUM = 31,
1491 CAM_ENTRIES_SEG_NUM = 32,
1492 ROUTING_WORDS_SEG_NUM = 33,
1493 ETS_SEG_NUM = 34,
1494 PROBE_DUMP_SEG_NUM = 35,
1495 ROUTING_INDEX_SEG_NUM = 36,
1496 MAC_PROTOCOL_SEG_NUM = 37,
1497 XAUI2_AN_SEG_NUM = 38,
1498 XAUI2_HSS_PCS_SEG_NUM = 39,
1499 XFI2_AN_SEG_NUM = 40,
1500 XFI2_TRAIN_SEG_NUM = 41,
1501 XFI2_HSS_PCS_SEG_NUM = 42,
1502 XFI2_HSS_TX_SEG_NUM = 43,
1503 XFI2_HSS_RX_SEG_NUM = 44,
1504 XFI2_HSS_PLL_SEG_NUM = 45,
1505 SEM_REGS_SEG_NUM = 50
1506
1507};
1508
1509struct ql_nic_misc {
1510 u32 rx_ring_count;
1511 u32 tx_ring_count;
1512 u32 intr_count;
1513 u32 function;
1514};
1515
1516struct ql_reg_dump {
1517
1518 /* segment 0 */
1519 struct mpi_coredump_global_header mpi_global_header;
1520
1521 /* segment 16 */
1522 struct mpi_coredump_segment_header nic_regs_seg_hdr;
1523 u32 nic_regs[64];
1524
1525 /* segment 30 */
1526 struct mpi_coredump_segment_header misc_nic_seg_hdr;
1527 struct ql_nic_misc misc_nic_info;
1528
1529 /* segment 31 */
1530 /* one interrupt state for each CQ */
1531 struct mpi_coredump_segment_header intr_states_seg_hdr;
1532 u32 intr_states[MAX_CPUS];
1533
1534 /* segment 32 */
1535 /* 3 cam words each for 16 unicast,
1536 * 2 cam words for each of 32 multicast.
1537 */
1538 struct mpi_coredump_segment_header cam_entries_seg_hdr;
1539 u32 cam_entries[(16 * 3) + (32 * 3)];
1540
1541 /* segment 33 */
1542 struct mpi_coredump_segment_header nic_routing_words_seg_hdr;
1543 u32 nic_routing_words[16];
1544
1545 /* segment 34 */
1546 struct mpi_coredump_segment_header ets_seg_hdr;
1547 u32 ets[8+2];
1548};
1549
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001550/*
1551 * intr_context structure is used during initialization
1552 * to hook the interrupts. It is also used in a single
1553 * irq environment as a context to the ISR.
1554 */
1555struct intr_context {
1556 struct ql_adapter *qdev;
1557 u32 intr;
Ron Mercer39aa8162009-08-27 11:02:11 +00001558 u32 irq_mask; /* Mask of which rings the vector services. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001559 u32 hooked;
1560 u32 intr_en_mask; /* value/mask used to enable this intr */
1561 u32 intr_dis_mask; /* value/mask used to disable this intr */
1562 u32 intr_read_mask; /* value/mask used to read this intr */
1563 char name[IFNAMSIZ * 2];
1564 atomic_t irq_cnt; /* irq_cnt is used in single vector
1565 * environment. It's incremented for each
1566 * irq handler that is scheduled. When each
1567 * handler finishes it decrements irq_cnt and
1568 * enables interrupts if it's zero. */
1569 irq_handler_t handler;
1570};
1571
1572/* adapter flags definitions. */
1573enum {
Ron Mercerfbcbe56c2009-09-29 08:39:21 +00001574 QL_ADAPTER_UP = 0, /* Adapter has been brought up. */
1575 QL_LEGACY_ENABLED = 1,
1576 QL_MSI_ENABLED = 2,
1577 QL_MSIX_ENABLED = 3,
1578 QL_DMA64 = 4,
1579 QL_PROMISCUOUS = 5,
1580 QL_ALLMULTI = 6,
1581 QL_PORT_CFG = 7,
1582 QL_CAM_RT_SET = 8,
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001583};
1584
1585/* link_status bit definitions */
1586enum {
Ron Mercerb82808b2009-02-26 10:08:32 +00001587 STS_LOOPBACK_MASK = 0x00000700,
1588 STS_LOOPBACK_PCS = 0x00000100,
1589 STS_LOOPBACK_HSS = 0x00000200,
1590 STS_LOOPBACK_EXT = 0x00000300,
1591 STS_PAUSE_MASK = 0x000000c0,
1592 STS_PAUSE_STD = 0x00000040,
1593 STS_PAUSE_PRI = 0x00000080,
1594 STS_SPEED_MASK = 0x00000038,
1595 STS_SPEED_100Mb = 0x00000000,
1596 STS_SPEED_1Gb = 0x00000008,
1597 STS_SPEED_10Gb = 0x00000010,
1598 STS_LINK_TYPE_MASK = 0x00000007,
1599 STS_LINK_TYPE_XFI = 0x00000001,
1600 STS_LINK_TYPE_XAUI = 0x00000002,
1601 STS_LINK_TYPE_XFI_BP = 0x00000003,
1602 STS_LINK_TYPE_XAUI_BP = 0x00000004,
1603 STS_LINK_TYPE_10GBASET = 0x00000005,
1604};
1605
1606/* link_config bit definitions */
1607enum {
1608 CFG_JUMBO_FRAME_SIZE = 0x00010000,
1609 CFG_PAUSE_MASK = 0x00000060,
1610 CFG_PAUSE_STD = 0x00000020,
1611 CFG_PAUSE_PRI = 0x00000040,
1612 CFG_DCBX = 0x00000010,
1613 CFG_LOOPBACK_MASK = 0x00000007,
1614 CFG_LOOPBACK_PCS = 0x00000002,
1615 CFG_LOOPBACK_HSS = 0x00000004,
1616 CFG_LOOPBACK_EXT = 0x00000006,
1617 CFG_DEFAULT_MAX_FRAME_SIZE = 0x00002580,
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001618};
1619
Ron Mercerb0c2aad2009-02-26 10:08:35 +00001620struct nic_operations {
1621
1622 int (*get_flash) (struct ql_adapter *);
1623 int (*port_initialize) (struct ql_adapter *);
1624};
1625
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001626/*
1627 * The main Adapter structure definition.
1628 * This structure has all fields relevant to the hardware.
1629 */
1630struct ql_adapter {
1631 struct ricb ricb;
1632 unsigned long flags;
1633 u32 wol;
1634
1635 struct nic_stats nic_stats;
1636
1637 struct vlan_group *vlgrp;
1638
1639 /* PCI Configuration information for this device */
1640 struct pci_dev *pdev;
1641 struct net_device *ndev; /* Parent NET device */
1642
1643 /* Hardware information */
1644 u32 chip_rev_id;
Ron Mercercfec0cb2009-06-09 05:39:29 +00001645 u32 fw_rev_id;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001646 u32 func; /* PCI function for this adapter */
Ron Mercere4552f52009-06-09 05:39:32 +00001647 u32 alt_func; /* PCI function for alternate adapter */
1648 u32 port; /* Port number this adapter */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001649
1650 spinlock_t adapter_lock;
1651 spinlock_t hw_lock;
1652 spinlock_t stats_lock;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001653
1654 /* PCI Bus Relative Register Addresses */
1655 void __iomem *reg_base;
1656 void __iomem *doorbell_area;
1657 u32 doorbell_area_size;
1658
1659 u32 msg_enable;
1660
1661 /* Page for Shadow Registers */
1662 void *rx_ring_shadow_reg_area;
1663 dma_addr_t rx_ring_shadow_reg_dma;
1664 void *tx_ring_shadow_reg_area;
1665 dma_addr_t tx_ring_shadow_reg_dma;
1666
1667 u32 mailbox_in;
1668 u32 mailbox_out;
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001669 struct mbox_params idc_mbc;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001670
1671 int tx_ring_size;
1672 int rx_ring_size;
1673 u32 intr_count;
1674 struct msix_entry *msi_x_entry;
1675 struct intr_context intr_context[MAX_RX_RINGS];
1676
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001677 int tx_ring_count; /* One per online CPU. */
Ron Mercer39aa8162009-08-27 11:02:11 +00001678 u32 rss_ring_count; /* One per irq vector. */
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001679 /*
1680 * rx_ring_count =
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001681 * (CPU count * outbound completion rx_ring) +
Ron Mercer39aa8162009-08-27 11:02:11 +00001682 * (irq_vector_cnt * inbound (RSS) completion rx_ring)
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001683 */
1684 int rx_ring_count;
1685 int ring_mem_size;
1686 void *ring_mem;
Ron Mercer683d46a2009-01-09 11:31:53 +00001687
1688 struct rx_ring rx_ring[MAX_RX_RINGS];
1689 struct tx_ring tx_ring[MAX_TX_RINGS];
Ron Mercer7c734352009-10-19 03:32:19 +00001690 unsigned int lbq_buf_order;
Ron Mercer683d46a2009-01-09 11:31:53 +00001691
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001692 int rx_csum;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001693 u32 default_rx_queue;
1694
1695 u16 rx_coalesce_usecs; /* cqicb->int_delay */
1696 u16 rx_max_coalesced_frames; /* cqicb->pkt_int_delay */
1697 u16 tx_coalesce_usecs; /* cqicb->int_delay */
1698 u16 tx_max_coalesced_frames; /* cqicb->pkt_int_delay */
1699
1700 u32 xg_sem_mask;
1701 u32 port_link_up;
1702 u32 port_init;
1703 u32 link_status;
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001704 u32 link_config;
Ron Mercerd8eb59d2009-10-21 11:07:39 +00001705 u32 led_config;
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001706 u32 max_frame_size;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001707
Ron Mercerb0c2aad2009-02-26 10:08:35 +00001708 union flash_params flash;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001709
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001710 struct workqueue_struct *workqueue;
1711 struct delayed_work asic_reset_work;
1712 struct delayed_work mpi_reset_work;
1713 struct delayed_work mpi_work;
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001714 struct delayed_work mpi_port_cfg_work;
Ron Mercer2ee1e272009-03-03 12:10:33 +00001715 struct delayed_work mpi_idc_work;
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001716 struct completion ide_completion;
Ron Mercerb0c2aad2009-02-26 10:08:35 +00001717 struct nic_operations *nic_ops;
1718 u16 device_id;
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001719};
1720
1721/*
1722 * Typical Register accessor for memory mapped device.
1723 */
1724static inline u32 ql_read32(const struct ql_adapter *qdev, int reg)
1725{
1726 return readl(qdev->reg_base + reg);
1727}
1728
1729/*
1730 * Typical Register accessor for memory mapped device.
1731 */
1732static inline void ql_write32(const struct ql_adapter *qdev, int reg, u32 val)
1733{
1734 writel(val, qdev->reg_base + reg);
1735}
1736
1737/*
1738 * Doorbell Registers:
1739 * Doorbell registers are virtual registers in the PCI memory space.
1740 * The space is allocated by the chip during PCI initialization. The
1741 * device driver finds the doorbell address in BAR 3 in PCI config space.
1742 * The registers are used to control outbound and inbound queues. For
1743 * example, the producer index for an outbound queue. Each queue uses
1744 * 1 4k chunk of memory. The lower half of the space is for outbound
1745 * queues. The upper half is for inbound queues.
1746 */
1747static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1748{
1749 writel(val, addr);
1750 mmiowb();
1751}
1752
Ron Mercerba7cd3b2009-01-09 11:31:49 +00001753/*
1754 * Shadow Registers:
1755 * Outbound queues have a consumer index that is maintained by the chip.
1756 * Inbound queues have a producer index that is maintained by the chip.
1757 * For lower overhead, these registers are "shadowed" to host memory
1758 * which allows the device driver to track the queue progress without
1759 * PCI reads. When an entry is placed on an inbound queue, the chip will
1760 * update the relevant index register and then copy the value to the
1761 * shadow register in host memory.
1762 */
1763static inline u32 ql_read_sh_reg(__le32 *addr)
1764{
1765 u32 reg;
1766 reg = le32_to_cpu(*addr);
1767 rmb();
1768 return reg;
1769}
1770
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001771extern char qlge_driver_name[];
1772extern const char qlge_driver_version[];
1773extern const struct ethtool_ops qlge_ethtool_ops;
1774
1775extern int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask);
1776extern void ql_sem_unlock(struct ql_adapter *qdev, u32 sem_mask);
1777extern int ql_read_xgmac_reg(struct ql_adapter *qdev, u32 reg, u32 *data);
1778extern int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
1779 u32 *value);
1780extern int ql_get_routing_reg(struct ql_adapter *qdev, u32 index, u32 *value);
1781extern int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
1782 u16 q_id);
1783void ql_queue_fw_error(struct ql_adapter *qdev);
1784void ql_mpi_work(struct work_struct *work);
1785void ql_mpi_reset_work(struct work_struct *work);
1786int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 ebit);
1787void ql_queue_asic_error(struct ql_adapter *qdev);
Ron Mercerbb0d2152008-10-20 10:30:26 -07001788u32 ql_enable_completion_interrupt(struct ql_adapter *qdev, u32 intr);
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001789void ql_set_ethtool_ops(struct net_device *ndev);
1790int ql_read_xgmac_reg64(struct ql_adapter *qdev, u32 reg, u64 *data);
Ron Mercer2ee1e272009-03-03 12:10:33 +00001791void ql_mpi_idc_work(struct work_struct *work);
Ron Mercerbcc2cb32009-03-02 08:07:32 +00001792void ql_mpi_port_cfg_work(struct work_struct *work);
Ron Mercercdca8d02009-03-02 08:07:31 +00001793int ql_mb_get_fw_state(struct ql_adapter *qdev);
Ron Mercer2ee1e272009-03-03 12:10:33 +00001794int ql_cam_route_initialize(struct ql_adapter *qdev);
Ron Mercere4552f52009-06-09 05:39:32 +00001795int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data);
Ron Mercercfec0cb2009-06-09 05:39:29 +00001796int ql_mb_about_fw(struct ql_adapter *qdev);
Ron Mercerbc083ce2009-10-21 11:07:40 +00001797int ql_wol(struct ql_adapter *qdev);
1798int ql_mb_wol_set_magic(struct ql_adapter *qdev, u32 enable_wol);
1799int ql_mb_wol_mode(struct ql_adapter *qdev, u32 wol);
Ron Mercerd8eb59d2009-10-21 11:07:39 +00001800int ql_mb_set_led_cfg(struct ql_adapter *qdev, u32 led_config);
1801int ql_mb_get_led_cfg(struct ql_adapter *qdev);
Ron Mercer6a473302009-07-02 06:06:12 +00001802void ql_link_on(struct ql_adapter *qdev);
1803void ql_link_off(struct ql_adapter *qdev);
Ron Mercer84087f42009-10-08 09:54:41 +00001804int ql_mb_set_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 control);
Ron Mercer1d30df22009-10-21 11:07:38 +00001805int ql_mb_get_port_cfg(struct ql_adapter *qdev);
1806int ql_mb_set_port_cfg(struct ql_adapter *qdev);
Ron Mercer84087f42009-10-08 09:54:41 +00001807int ql_wait_fifo_empty(struct ql_adapter *qdev);
Ron Mercera61f8022009-10-21 11:07:41 +00001808void ql_gen_reg_dump(struct ql_adapter *qdev,
1809 struct ql_reg_dump *mpi_coredump);
Ron Mercerc4e84bd2008-09-18 11:56:28 -04001810
1811#if 1
1812#define QL_ALL_DUMP
1813#define QL_REG_DUMP
1814#define QL_DEV_DUMP
1815#define QL_CB_DUMP
1816/* #define QL_IB_DUMP */
1817/* #define QL_OB_DUMP */
1818#endif
1819
1820#ifdef QL_REG_DUMP
1821extern void ql_dump_xgmac_control_regs(struct ql_adapter *qdev);
1822extern void ql_dump_routing_entries(struct ql_adapter *qdev);
1823extern void ql_dump_regs(struct ql_adapter *qdev);
1824#define QL_DUMP_REGS(qdev) ql_dump_regs(qdev)
1825#define QL_DUMP_ROUTE(qdev) ql_dump_routing_entries(qdev)
1826#define QL_DUMP_XGMAC_CONTROL_REGS(qdev) ql_dump_xgmac_control_regs(qdev)
1827#else
1828#define QL_DUMP_REGS(qdev)
1829#define QL_DUMP_ROUTE(qdev)
1830#define QL_DUMP_XGMAC_CONTROL_REGS(qdev)
1831#endif
1832
1833#ifdef QL_STAT_DUMP
1834extern void ql_dump_stat(struct ql_adapter *qdev);
1835#define QL_DUMP_STAT(qdev) ql_dump_stat(qdev)
1836#else
1837#define QL_DUMP_STAT(qdev)
1838#endif
1839
1840#ifdef QL_DEV_DUMP
1841extern void ql_dump_qdev(struct ql_adapter *qdev);
1842#define QL_DUMP_QDEV(qdev) ql_dump_qdev(qdev)
1843#else
1844#define QL_DUMP_QDEV(qdev)
1845#endif
1846
1847#ifdef QL_CB_DUMP
1848extern void ql_dump_wqicb(struct wqicb *wqicb);
1849extern void ql_dump_tx_ring(struct tx_ring *tx_ring);
1850extern void ql_dump_ricb(struct ricb *ricb);
1851extern void ql_dump_cqicb(struct cqicb *cqicb);
1852extern void ql_dump_rx_ring(struct rx_ring *rx_ring);
1853extern void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id);
1854#define QL_DUMP_RICB(ricb) ql_dump_ricb(ricb)
1855#define QL_DUMP_WQICB(wqicb) ql_dump_wqicb(wqicb)
1856#define QL_DUMP_TX_RING(tx_ring) ql_dump_tx_ring(tx_ring)
1857#define QL_DUMP_CQICB(cqicb) ql_dump_cqicb(cqicb)
1858#define QL_DUMP_RX_RING(rx_ring) ql_dump_rx_ring(rx_ring)
1859#define QL_DUMP_HW_CB(qdev, size, bit, q_id) \
1860 ql_dump_hw_cb(qdev, size, bit, q_id)
1861#else
1862#define QL_DUMP_RICB(ricb)
1863#define QL_DUMP_WQICB(wqicb)
1864#define QL_DUMP_TX_RING(tx_ring)
1865#define QL_DUMP_CQICB(cqicb)
1866#define QL_DUMP_RX_RING(rx_ring)
1867#define QL_DUMP_HW_CB(qdev, size, bit, q_id)
1868#endif
1869
1870#ifdef QL_OB_DUMP
1871extern void ql_dump_tx_desc(struct tx_buf_desc *tbd);
1872extern void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb);
1873extern void ql_dump_ob_mac_rsp(struct ob_mac_iocb_rsp *ob_mac_rsp);
1874#define QL_DUMP_OB_MAC_IOCB(ob_mac_iocb) ql_dump_ob_mac_iocb(ob_mac_iocb)
1875#define QL_DUMP_OB_MAC_RSP(ob_mac_rsp) ql_dump_ob_mac_rsp(ob_mac_rsp)
1876#else
1877#define QL_DUMP_OB_MAC_IOCB(ob_mac_iocb)
1878#define QL_DUMP_OB_MAC_RSP(ob_mac_rsp)
1879#endif
1880
1881#ifdef QL_IB_DUMP
1882extern void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp);
1883#define QL_DUMP_IB_MAC_RSP(ib_mac_rsp) ql_dump_ib_mac_rsp(ib_mac_rsp)
1884#else
1885#define QL_DUMP_IB_MAC_RSP(ib_mac_rsp)
1886#endif
1887
1888#ifdef QL_ALL_DUMP
1889extern void ql_dump_all(struct ql_adapter *qdev);
1890#define QL_DUMP_ALL(qdev) ql_dump_all(qdev)
1891#else
1892#define QL_DUMP_ALL(qdev)
1893#endif
1894
1895#endif /* _QLGE_H_ */