Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bfi.h
Go to the documentation of this file.
1 /*
2  * Linux network driver for Brocade Converged Network Adapter.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License (GPL) Version 2 as
6  * published by the Free Software Foundation
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  */
13 /*
14  * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
15  * All rights reserved
16  * www.brocade.com
17  */
18 #ifndef __BFI_H__
19 #define __BFI_H__
20 
21 #include "bfa_defs.h"
22 
23 #pragma pack(1)
24 
25 /* BFI FW image type */
26 #define BFI_FLASH_CHUNK_SZ 256
27 #define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
28 
29 /* Msg header common to all msgs */
30 struct bfi_mhdr {
33  union {
34  struct {
37  } h2i;
39  } mtag;
40 };
41 
42 #define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu))
43 #define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1)
44 #define bfi_mhdr_2_qid(_mh) ((_mh)->mtag.h2i.qid)
45 
46 #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \
47  (_mh).msg_class = (_mc); \
48  (_mh).msg_id = (_op); \
49  (_mh).mtag.h2i.fn_lpu = (_fn_lpu); \
50 } while (0)
51 
52 #define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
53  (_mh).msg_class = (_mc); \
54  (_mh).msg_id = (_op); \
55  (_mh).mtag.i2htok = (_i2htok); \
56 } while (0)
57 
58 /*
59  * Message opcodes: 0-127 to firmware, 128-255 to host
60  */
61 #define BFI_I2H_OPCODE_BASE 128
62 #define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
63 
64 /****************************************************************************
65  *
66  * Scatter Gather Element and Page definition
67  *
68  ****************************************************************************
69  */
70 
71 /* DMA addresses */
72 union bfi_addr_u {
73  struct {
76  } a32;
77 };
78 
79 /* Generic DMA addr-len pair. */
80 struct bfi_alen {
81  union bfi_addr_u al_addr; /* DMA addr of buffer */
82  u32 al_len; /* length of buffer */
83 };
84 
85 /*
86  * Large Message structure - 128 Bytes size Msgs
87  */
88 #define BFI_LMSG_SZ 128
89 #define BFI_LMSG_PL_WSZ \
90  ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr)) / 4)
91 
92 /* Mailbox message structure */
93 #define BFI_MBMSG_SZ 7
94 struct bfi_mbmsg {
95  struct bfi_mhdr mh;
97 };
98 
99 /* Supported PCI function class codes (personality) */
103 };
104 
105 /* Message Classes */
113  BFI_MC_LL = 7,
114  BFI_MC_UF = 8,
116  BFI_MC_LPS = 10,
122  BFI_MC_IOIM = 16,
126  BFI_MC_IPFC = 20,
127  BFI_MC_PORT = 21,
128  BFI_MC_SFP = 22,
129  BFI_MC_MSGQ = 23,
130  BFI_MC_ENET = 24,
131  BFI_MC_PHY = 25,
137  BFI_MC_TIO = 31,
138  BFI_MC_MFG = 32,
139  BFI_MC_EDMA = 33,
141 };
142 
143 #define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
144 
145 #define BFI_FWBOOT_ENV_OS 0
146 
147 /*----------------------------------------------------------------------
148  * IOC
149  *----------------------------------------------------------------------
150  */
151 
152 /* Different asic generations */
157 };
158 
160  BFI_ASIC_MODE_FC = 1, /* FC upto 8G speed */
161  BFI_ASIC_MODE_FC16 = 2, /* FC upto 16G speed */
162  BFI_ASIC_MODE_ETH = 3, /* Ethernet ports */
163  BFI_ASIC_MODE_COMBO = 4, /* FC 16G and Ethernet 10G port */
164 };
165 
172 };
173 
179 };
180 
181 /* BFI_IOC_H2I_GETATTR_REQ message */
183  struct bfi_mhdr mh;
185 };
186 
187 struct bfi_ioc_attr {
191  u8 port_mode; /* enum bfi_port_mode */
206  char asic_rev;
210  struct bfa_mfg_vpd vpd;
212 };
213 
214 /* BFI_IOC_I2H_GETATTR_REPLY message */
216  struct bfi_mhdr mh;
218  u8 rsvd[3];
219 };
220 
221 /* Firmware memory page offsets */
222 #define BFI_IOC_SMEM_PG0_CB (0x40)
223 #define BFI_IOC_SMEM_PG0_CT (0x180)
224 
225 /* Firmware statistic offset */
226 #define BFI_IOC_FWSTATS_OFF (0x6B40)
227 #define BFI_IOC_FWSTATS_SZ (4096)
228 
229 /* Firmware trace offset */
230 #define BFI_IOC_TRC_OFF (0x4b00)
231 #define BFI_IOC_TRC_ENTS 256
232 #define BFI_IOC_TRC_ENT_SZ 16
233 #define BFI_IOC_TRC_HDR_SZ 32
234 
235 #define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
236 #define BFI_IOC_MD5SUM_SZ 4
247 };
248 
249 #define BFI_FWBOOT_DEVMODE_OFF 4
250 #define BFI_FWBOOT_TYPE_OFF 8
251 #define BFI_FWBOOT_ENV_OFF 12
252 #define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \
253  (((u32)(__asic_gen)) << 24 | \
254  ((u32)(__asic_mode)) << 16 | \
255  ((u32)(__p0_mode)) << 8 | \
256  ((u32)(__p1_mode)))
257 
262 };
263 
267 };
268 
270  struct bfi_mhdr mh;
272 };
273 
274 /* IOC hardware/firmware state */
286 };
287 
288 #define BFI_IOC_ENDIAN_SIG 0x12345678
289 
290 enum {
292  BFI_ADAPTER_TYPE_MK = 0x0f0000,
298  BFI_ADAPTER_PROTO = 0x100000,
299  BFI_ADAPTER_TTV = 0x200000,
300  BFI_ADAPTER_UNSUPP = 0x400000,
301 };
302 
303 #define BFI_ADAPTER_GETP(__prop, __adap_prop) \
304  (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
305  BFI_ADAPTER_ ## __prop ## _SH)
306 #define BFI_ADAPTER_SETP(__prop, __val) \
307  ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
308 #define BFI_ADAPTER_IS_PROTO(__adap_type) \
309  ((__adap_type) & BFI_ADAPTER_PROTO)
310 #define BFI_ADAPTER_IS_TTV(__adap_type) \
311  ((__adap_type) & BFI_ADAPTER_TTV)
312 #define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
313  ((__adap_type) & BFI_ADAPTER_UNSUPP)
314 #define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
315  ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
316  BFI_ADAPTER_UNSUPP))
317 
318 /* BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages */
320  struct bfi_mhdr mh;
324 };
325 
326 /* BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages */
328  struct bfi_mhdr mh;
333 };
334 
335 #define BFI_IOC_MSGSZ 8
336 /* H2I Messages */
338  struct bfi_mhdr mh;
343 };
344 
345 /* I2H Messages */
347  struct bfi_mhdr mh;
350 };
351 
352 /*----------------------------------------------------------------------
353  * MSGQ
354  *----------------------------------------------------------------------
355  */
356 
362 };
363 
369 };
370 
371 /* Messages(commands/responsed/AENS will have the following header */
378  u8 rsvd[1];
379 };
380 
381 #define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \
382  (_mh).msg_class = (_mc); \
383  (_mh).msg_id = (_mid); \
384  (_mh).msg_token = (_tok); \
385  (_mh).enet_id = (_enet_id); \
386 } while (0)
387 
388 /*
389  * Mailbox for messaging interface
390  */
391 #define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */
392 #define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */
393 
394 #define bfi_msgq_num_cmd_entries(_size) \
395  (((_size) + BFI_MSGQ_CMD_ENTRY_SIZE - 1) / BFI_MSGQ_CMD_ENTRY_SIZE)
396 
397 struct bfi_msgq {
399  u16 q_depth; /* Total num of entries in the queue */
400  u8 rsvd[2];
401 };
402 
403 /* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
405  struct bfi_mhdr mh;
406  struct bfi_msgq cmdq;
407  struct bfi_msgq rspq;
408 };
409 
410 /* BFI_ENET_MSGQ_CFG_RSP */
412  struct bfi_mhdr mh;
414  u8 rsvd[3];
415 };
416 
417 /* BFI_MSGQ_H2I_DOORBELL */
419  struct bfi_mhdr mh;
420  union {
423  } idx;
424 };
425 
426 /* BFI_MSGQ_I2H_DOORBELL */
428  struct bfi_mhdr mh;
429  union {
432  } idx;
433 };
434 
435 #define BFI_CMD_COPY_SZ 28
436 
437 /* BFI_MSGQ_H2I_CMD_COPY_RSP */
439  struct bfi_mhdr mh;
441 };
442 
443 /* BFI_MSGQ_I2H_CMD_COPY_REQ */
445  struct bfi_mhdr mh;
448 };
449 
450 /*
451  * FLASH module specific
452  */
459 };
460 
468 };
469 
470 /*
471  * Flash query request
472  */
474  struct bfi_mhdr mh; /* Common msg header */
475  struct bfi_alen alen;
476 };
477 
478 /*
479  * Flash write request
480  */
482  struct bfi_mhdr mh; /* Common msg header */
483  struct bfi_alen alen;
484  u32 type; /* partition type */
485  u8 instance; /* partition instance */
487  u8 rsv[2];
490 };
491 
492 /*
493  * Flash read request
494  */
496  struct bfi_mhdr mh; /* Common msg header */
497  u32 type; /* partition type */
498  u8 instance; /* partition instance */
499  u8 rsv[3];
502  struct bfi_alen alen;
503 };
504 
505 /*
506  * Flash query response
507  */
509  struct bfi_mhdr mh; /* Common msg header */
511 };
512 
513 /*
514  * Flash read response
515  */
517  struct bfi_mhdr mh; /* Common msg header */
518  u32 type; /* partition type */
519  u8 instance; /* partition instance */
520  u8 rsv[3];
523 };
524 
525 /*
526  * Flash write response
527  */
529  struct bfi_mhdr mh; /* Common msg header */
530  u32 type; /* partition type */
531  u8 instance; /* partition instance */
532  u8 rsv[3];
535 };
536 
537 #pragma pack()
538 
539 #endif /* __BFI_H__ */