blob: efa41b64bb320efec81b90e291571ebebcc7150b [file] [log] [blame]
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001/*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFI_H__
19#define __BFI_H__
20
21#include "bfa_defs.h"
22#include "bfa_defs_svc.h"
23
24#pragma pack(1)
25
Krishna Gudipati45070252011-06-24 20:24:29 -070026/* Per dma segment max size */
27#define BFI_MEM_DMA_SEG_SZ (131072)
28
29/* Get number of dma segments required */
30#define BFI_MEM_DMA_NSEGS(_num_reqs, _req_sz) \
31 ((u16)(((((_num_reqs) * (_req_sz)) + BFI_MEM_DMA_SEG_SZ - 1) & \
32 ~(BFI_MEM_DMA_SEG_SZ - 1)) / BFI_MEM_DMA_SEG_SZ))
33
34/* Get num dma reqs - that fit in a segment */
35#define BFI_MEM_NREQS_SEG(_rqsz) (BFI_MEM_DMA_SEG_SZ / (_rqsz))
36
37/* Get segment num from tag */
38#define BFI_MEM_SEG_FROM_TAG(_tag, _rqsz) ((_tag) / BFI_MEM_NREQS_SEG(_rqsz))
39
40/* Get dma req offset in a segment */
41#define BFI_MEM_SEG_REQ_OFFSET(_tag, _sz) \
42 ((_tag) - (BFI_MEM_SEG_FROM_TAG(_tag, _sz) * BFI_MEM_NREQS_SEG(_sz)))
43
Jing Huangacdc79a2010-10-18 17:15:55 -070044/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070045 * BFI FW image type
46 */
47#define BFI_FLASH_CHUNK_SZ 256 /* Flash chunk size */
48#define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070049
Jing Huangacdc79a2010-10-18 17:15:55 -070050/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070051 * Msg header common to all msgs
52 */
53struct bfi_mhdr_s {
54 u8 msg_class; /* @ref bfi_mclass_t */
55 u8 msg_id; /* msg opcode with in the class */
56 union {
57 struct {
Krishna Gudipatid37779f2011-06-13 15:42:10 -070058 u8 qid;
Krishna Gudipati3fd45982011-06-24 20:24:08 -070059 u8 fn_lpu; /* msg destination */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070060 } h2i;
61 u16 i2htok; /* token in msgs to host */
62 } mtag;
63};
64
Krishna Gudipati3fd45982011-06-24 20:24:08 -070065#define bfi_fn_lpu(__fn, __lpu) ((__fn) << 1 | (__lpu))
66#define bfi_mhdr_2_fn(_mh) ((_mh)->mtag.h2i.fn_lpu >> 1)
Krishna Gudipatid37779f2011-06-13 15:42:10 -070067
Krishna Gudipati3fd45982011-06-24 20:24:08 -070068#define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do { \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070069 (_mh).msg_class = (_mc); \
70 (_mh).msg_id = (_op); \
Krishna Gudipati3fd45982011-06-24 20:24:08 -070071 (_mh).mtag.h2i.fn_lpu = (_fn_lpu); \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070072} while (0)
73
74#define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
75 (_mh).msg_class = (_mc); \
76 (_mh).msg_id = (_op); \
77 (_mh).mtag.i2htok = (_i2htok); \
78} while (0)
79
80/*
81 * Message opcodes: 0-127 to firmware, 128-255 to host
82 */
83#define BFI_I2H_OPCODE_BASE 128
84#define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
85
Jing Huangacdc79a2010-10-18 17:15:55 -070086/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070087 ****************************************************************************
88 *
89 * Scatter Gather Element and Page definition
90 *
91 ****************************************************************************
92 */
93
94#define BFI_SGE_INLINE 1
95#define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1)
96
Jing Huangacdc79a2010-10-18 17:15:55 -070097/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070098 * SG Flags
99 */
100enum {
101 BFI_SGE_DATA = 0, /* data address, not last */
102 BFI_SGE_DATA_CPL = 1, /* data addr, last in current page */
103 BFI_SGE_DATA_LAST = 3, /* data address, last */
104 BFI_SGE_LINK = 2, /* link address */
105 BFI_SGE_PGDLEN = 2, /* cumulative data length for page */
106};
107
Jing Huangacdc79a2010-10-18 17:15:55 -0700108/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700109 * DMA addresses
110 */
111union bfi_addr_u {
112 struct {
Maggie50444a32010-11-29 18:26:32 -0800113 __be32 addr_lo;
114 __be32 addr_hi;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700115 } a32;
116};
117
Jing Huangacdc79a2010-10-18 17:15:55 -0700118/*
Krishna Gudipati85ce9282011-06-13 15:39:36 -0700119 * Scatter Gather Element used for fast-path IO requests
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700120 */
121struct bfi_sge_s {
Maggie Zhangf16a1752010-12-09 19:12:32 -0800122#ifdef __BIG_ENDIAN
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700123 u32 flags:2,
124 rsvd:2,
125 sg_len:28;
126#else
127 u32 sg_len:28,
128 rsvd:2,
129 flags:2;
130#endif
131 union bfi_addr_u sga;
132};
133
Krishna Gudipati85ce9282011-06-13 15:39:36 -0700134/**
135 * Generic DMA addr-len pair.
136 */
137struct bfi_alen_s {
138 union bfi_addr_u al_addr; /* DMA addr of buffer */
139 u32 al_len; /* length of buffer */
140};
141
Jing Huangacdc79a2010-10-18 17:15:55 -0700142/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700143 * Scatter Gather Page
144 */
145#define BFI_SGPG_DATA_SGES 7
146#define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1)
147#define BFI_SGPG_RSVD_WD_LEN 8
148struct bfi_sgpg_s {
149 struct bfi_sge_s sges[BFI_SGPG_SGES_MAX];
150 u32 rsvd[BFI_SGPG_RSVD_WD_LEN];
151};
152
Krishna Gudipati45070252011-06-24 20:24:29 -0700153/* FCP module definitions */
154#define BFI_IO_MAX (2000)
155#define BFI_IOIM_SNSLEN (256)
156#define BFI_IOIM_SNSBUF_SEGS \
157 BFI_MEM_DMA_NSEGS(BFI_IO_MAX, BFI_IOIM_SNSLEN)
158
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700159/*
160 * Large Message structure - 128 Bytes size Msgs
161 */
162#define BFI_LMSG_SZ 128
163#define BFI_LMSG_PL_WSZ \
164 ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr_s)) / 4)
165
166struct bfi_msg_s {
167 struct bfi_mhdr_s mhdr;
168 u32 pl[BFI_LMSG_PL_WSZ];
169};
170
Jing Huangacdc79a2010-10-18 17:15:55 -0700171/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700172 * Mailbox message structure
173 */
174#define BFI_MBMSG_SZ 7
175struct bfi_mbmsg_s {
176 struct bfi_mhdr_s mh;
177 u32 pl[BFI_MBMSG_SZ];
178};
179
Jing Huangacdc79a2010-10-18 17:15:55 -0700180/*
Krishna Gudipatid37779f2011-06-13 15:42:10 -0700181 * Supported PCI function class codes (personality)
182 */
183enum bfi_pcifn_class {
184 BFI_PCIFN_CLASS_FC = 0x0c04,
185 BFI_PCIFN_CLASS_ETH = 0x0200,
186};
187
188/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700189 * Message Classes
190 */
191enum bfi_mclass {
192 BFI_MC_IOC = 1, /* IO Controller (IOC) */
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700193 BFI_MC_DIAG = 2, /* Diagnostic Msgs */
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -0700194 BFI_MC_FLASH = 3, /* Flash message class */
Krishna Gudipati148d6102011-06-24 20:25:36 -0700195 BFI_MC_CEE = 4, /* CEE */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700196 BFI_MC_FCPORT = 5, /* FC port */
197 BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700198 BFI_MC_ABLK = 7, /* ASIC block configuration */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700199 BFI_MC_UF = 8, /* Unsolicited frame receive */
200 BFI_MC_FCXP = 9, /* FC Transport */
201 BFI_MC_LPS = 10, /* lport fc login services */
202 BFI_MC_RPORT = 11, /* Remote port */
Krishna Gudipatidd5aaf42011-06-13 15:51:24 -0700203 BFI_MC_ITN = 12, /* I-T nexus (Initiator mode) */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700204 BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */
205 BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */
206 BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */
207 BFI_MC_IOIM = 16, /* IO (Initiator mode) */
208 BFI_MC_IOIM_IOCOM = 17, /* good IO completion */
209 BFI_MC_TSKIM = 18, /* Initiator Task management */
210 BFI_MC_PORT = 21, /* Physical port */
Krishna Gudipati51e569a2011-06-24 20:26:25 -0700211 BFI_MC_SFP = 22, /* SFP module */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700212 BFI_MC_MAX = 32
213};
214
215#define BFI_IOC_MAX_CQS 4
216#define BFI_IOC_MAX_CQS_ASIC 8
217#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
218
Jing Huangacdc79a2010-10-18 17:15:55 -0700219/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700220 *----------------------------------------------------------------------
221 * IOC
222 *----------------------------------------------------------------------
223 */
224
Krishna Gudipati11189202011-06-13 15:50:35 -0700225/*
226 * Different asic generations
227 */
228enum bfi_asic_gen {
229 BFI_ASIC_GEN_CB = 1, /* crossbow 8G FC */
230 BFI_ASIC_GEN_CT = 2, /* catapult 8G FC or 10G CNA */
231 BFI_ASIC_GEN_CT2 = 3, /* catapult-2 16G FC or 10G CNA */
232};
233
234enum bfi_asic_mode {
235 BFI_ASIC_MODE_FC = 1, /* FC upto 8G speed */
236 BFI_ASIC_MODE_FC16 = 2, /* FC upto 16G speed */
237 BFI_ASIC_MODE_ETH = 3, /* Ethernet ports */
238 BFI_ASIC_MODE_COMBO = 4, /* FC 16G and Ethernet 10G port */
239};
240
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700241enum bfi_ioc_h2i_msgs {
242 BFI_IOC_H2I_ENABLE_REQ = 1,
243 BFI_IOC_H2I_DISABLE_REQ = 2,
244 BFI_IOC_H2I_GETATTR_REQ = 3,
245 BFI_IOC_H2I_DBG_SYNC = 4,
246 BFI_IOC_H2I_DBG_DUMP = 5,
247};
248
249enum bfi_ioc_i2h_msgs {
250 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
251 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
252 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
Krishna Gudipati775c7742011-06-13 15:52:12 -0700253 BFI_IOC_I2H_HBEAT = BFA_I2HM(4),
Krishna Gudipatia7141342011-06-24 20:23:19 -0700254 BFI_IOC_I2H_ACQ_ADDR_REPLY = BFA_I2HM(5),
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700255};
256
Jing Huangacdc79a2010-10-18 17:15:55 -0700257/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700258 * BFI_IOC_H2I_GETATTR_REQ message
259 */
260struct bfi_ioc_getattr_req_s {
261 struct bfi_mhdr_s mh;
262 union bfi_addr_u attr_addr;
263};
264
265struct bfi_ioc_attr_s {
266 wwn_t mfg_pwwn; /* Mfg port wwn */
267 wwn_t mfg_nwwn; /* Mfg node wwn */
268 mac_t mfg_mac; /* Mfg mac */
Krishna Gudipati5a0adae2011-06-24 20:22:56 -0700269 u8 port_mode; /* bfi_port_mode */
270 u8 rsvd_a;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700271 wwn_t pwwn;
272 wwn_t nwwn;
273 mac_t mac; /* PBC or Mfg mac */
274 u16 rsvd_b;
275 mac_t fcoe_mac;
276 u16 rsvd_c;
277 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
278 u8 pcie_gen;
279 u8 pcie_lanes_orig;
280 u8 pcie_lanes;
281 u8 rx_bbcredit; /* receive buffer credits */
282 u32 adapter_prop; /* adapter properties */
283 u16 maxfrsize; /* max receive frame size */
284 char asic_rev;
Krishna Gudipati10a07372011-06-24 20:23:38 -0700285 u8 rsvd_d;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700286 char fw_version[BFA_VERSION_LEN];
287 char optrom_version[BFA_VERSION_LEN];
288 struct bfa_mfg_vpd_s vpd;
289 u32 card_type; /* card type */
290};
291
Jing Huangacdc79a2010-10-18 17:15:55 -0700292/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700293 * BFI_IOC_I2H_GETATTR_REPLY message
294 */
295struct bfi_ioc_getattr_reply_s {
296 struct bfi_mhdr_s mh; /* Common msg header */
297 u8 status; /* cfg reply status */
298 u8 rsvd[3];
299};
300
Jing Huangacdc79a2010-10-18 17:15:55 -0700301/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700302 * Firmware memory page offsets
303 */
304#define BFI_IOC_SMEM_PG0_CB (0x40)
305#define BFI_IOC_SMEM_PG0_CT (0x180)
306
Jing Huangacdc79a2010-10-18 17:15:55 -0700307/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700308 * Firmware statistic offset
309 */
310#define BFI_IOC_FWSTATS_OFF (0x6B40)
311#define BFI_IOC_FWSTATS_SZ (4096)
312
Jing Huangacdc79a2010-10-18 17:15:55 -0700313/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700314 * Firmware trace offset
315 */
316#define BFI_IOC_TRC_OFF (0x4b00)
317#define BFI_IOC_TRC_ENTS 256
318
319#define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
320#define BFI_IOC_MD5SUM_SZ 4
321struct bfi_ioc_image_hdr_s {
Krishna Gudipati11189202011-06-13 15:50:35 -0700322 u32 signature; /* constant signature */
323 u8 asic_gen; /* asic generation */
324 u8 asic_mode;
325 u8 port0_mode; /* device mode for port 0 */
326 u8 port1_mode; /* device mode for port 1 */
327 u32 exec; /* exec vector */
328 u32 bootenv; /* fimware boot env */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700329 u32 rsvd_b[4];
330 u32 md5sum[BFI_IOC_MD5SUM_SZ];
331};
332
Krishna Gudipati11189202011-06-13 15:50:35 -0700333#define BFI_FWBOOT_DEVMODE_OFF 4
334#define BFI_FWBOOT_TYPE_OFF 8
335#define BFI_FWBOOT_ENV_OFF 12
336#define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \
337 (((u32)(__asic_gen)) << 24 | \
338 ((u32)(__asic_mode)) << 16 | \
339 ((u32)(__p0_mode)) << 8 | \
340 ((u32)(__p1_mode)))
341
342#define BFI_FWBOOT_TYPE_NORMAL 0
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700343#define BFI_FWBOOT_TYPE_MEMTEST 2
Krishna Gudipati11189202011-06-13 15:50:35 -0700344#define BFI_FWBOOT_ENV_OS 0
345
346enum bfi_port_mode {
347 BFI_PORT_MODE_FC = 1,
348 BFI_PORT_MODE_ETH = 2,
349};
350
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700351struct bfi_ioc_hbeat_s {
352 struct bfi_mhdr_s mh; /* common msg header */
353 u32 hb_count; /* current heart beat count */
354};
355
Jing Huangacdc79a2010-10-18 17:15:55 -0700356/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700357 * IOC hardware/firmware state
358 */
359enum bfi_ioc_state {
360 BFI_IOC_UNINIT = 0, /* not initialized */
361 BFI_IOC_INITING = 1, /* h/w is being initialized */
362 BFI_IOC_HWINIT = 2, /* h/w is initialized */
363 BFI_IOC_CFG = 3, /* IOC configuration in progress */
364 BFI_IOC_OP = 4, /* IOC is operational */
365 BFI_IOC_DISABLING = 5, /* IOC is being disabled */
366 BFI_IOC_DISABLED = 6, /* IOC is disabled */
367 BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */
368 BFI_IOC_FAIL = 8, /* IOC heart-beat failure */
369 BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */
370};
371
372#define BFI_IOC_ENDIAN_SIG 0x12345678
373
374enum {
375 BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */
376 BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */
377 BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */
378 BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */
379 BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */
380 BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */
381 BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */
382 BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */
383 BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */
384 BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */
385};
386
387#define BFI_ADAPTER_GETP(__prop, __adap_prop) \
388 (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
389 BFI_ADAPTER_ ## __prop ## _SH)
390#define BFI_ADAPTER_SETP(__prop, __val) \
391 ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
392#define BFI_ADAPTER_IS_PROTO(__adap_type) \
393 ((__adap_type) & BFI_ADAPTER_PROTO)
394#define BFI_ADAPTER_IS_TTV(__adap_type) \
395 ((__adap_type) & BFI_ADAPTER_TTV)
396#define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
397 ((__adap_type) & BFI_ADAPTER_UNSUPP)
398#define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
399 ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
400 BFI_ADAPTER_UNSUPP))
401
Jing Huangacdc79a2010-10-18 17:15:55 -0700402/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700403 * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
404 */
405struct bfi_ioc_ctrl_req_s {
406 struct bfi_mhdr_s mh;
Krishna Gudipatid37779f2011-06-13 15:42:10 -0700407 u16 clscode;
408 u16 rsvd;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700409 u32 tv_sec;
410};
411#define bfi_ioc_enable_req_t struct bfi_ioc_ctrl_req_s;
412#define bfi_ioc_disable_req_t struct bfi_ioc_ctrl_req_s;
413
Jing Huangacdc79a2010-10-18 17:15:55 -0700414/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700415 * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
416 */
417struct bfi_ioc_ctrl_reply_s {
418 struct bfi_mhdr_s mh; /* Common msg header */
419 u8 status; /* enable/disable status */
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700420 u8 port_mode; /* bfa_mode_s */
421 u8 cap_bm; /* capability bit mask */
422 u8 rsvd;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700423};
424#define bfi_ioc_enable_reply_t struct bfi_ioc_ctrl_reply_s;
425#define bfi_ioc_disable_reply_t struct bfi_ioc_ctrl_reply_s;
426
427#define BFI_IOC_MSGSZ 8
Jing Huangacdc79a2010-10-18 17:15:55 -0700428/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700429 * H2I Messages
430 */
431union bfi_ioc_h2i_msg_u {
432 struct bfi_mhdr_s mh;
433 struct bfi_ioc_ctrl_req_s enable_req;
434 struct bfi_ioc_ctrl_req_s disable_req;
435 struct bfi_ioc_getattr_req_s getattr_req;
436 u32 mboxmsg[BFI_IOC_MSGSZ];
437};
438
Jing Huangacdc79a2010-10-18 17:15:55 -0700439/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700440 * I2H Messages
441 */
442union bfi_ioc_i2h_msg_u {
443 struct bfi_mhdr_s mh;
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700444 struct bfi_ioc_ctrl_reply_s fw_event;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700445 u32 mboxmsg[BFI_IOC_MSGSZ];
446};
447
448
Jing Huangacdc79a2010-10-18 17:15:55 -0700449/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700450 *----------------------------------------------------------------------
451 * PBC
452 *----------------------------------------------------------------------
453 */
454
455#define BFI_PBC_MAX_BLUNS 8
456#define BFI_PBC_MAX_VPORTS 16
Krishna Gudipati43ffdf42011-06-13 15:46:21 -0700457#define BFI_PBC_PORT_DISABLED 2
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700458
Jing Huangacdc79a2010-10-18 17:15:55 -0700459/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700460 * PBC boot lun configuration
461 */
462struct bfi_pbc_blun_s {
463 wwn_t tgt_pwwn;
Maggie Zhangf3148782010-12-09 19:11:39 -0800464 struct scsi_lun tgt_lun;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700465};
466
Jing Huangacdc79a2010-10-18 17:15:55 -0700467/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700468 * PBC virtual port configuration
469 */
470struct bfi_pbc_vport_s {
471 wwn_t vp_pwwn;
472 wwn_t vp_nwwn;
473};
474
Jing Huangacdc79a2010-10-18 17:15:55 -0700475/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700476 * BFI pre-boot configuration information
477 */
478struct bfi_pbc_s {
479 u8 port_enabled;
480 u8 boot_enabled;
481 u8 nbluns;
482 u8 nvports;
483 u8 port_speed;
484 u8 rsvd_a;
485 u16 hss;
486 wwn_t pbc_pwwn;
487 wwn_t pbc_nwwn;
488 struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS];
489 struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS];
490};
491
Jing Huangacdc79a2010-10-18 17:15:55 -0700492/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700493 *----------------------------------------------------------------------
494 * MSGQ
495 *----------------------------------------------------------------------
496 */
497#define BFI_MSGQ_FULL(_q) (((_q->pi + 1) % _q->q_depth) == _q->ci)
498#define BFI_MSGQ_EMPTY(_q) (_q->pi == _q->ci)
499#define BFI_MSGQ_UPDATE_CI(_q) (_q->ci = (_q->ci + 1) % _q->q_depth)
500#define BFI_MSGQ_UPDATE_PI(_q) (_q->pi = (_q->pi + 1) % _q->q_depth)
501
502/* q_depth must be power of 2 */
503#define BFI_MSGQ_FREE_CNT(_q) ((_q->ci - _q->pi - 1) & (_q->q_depth - 1))
504
505enum bfi_msgq_h2i_msgs_e {
506 BFI_MSGQ_H2I_INIT_REQ = 1,
507 BFI_MSGQ_H2I_DOORBELL = 2,
508 BFI_MSGQ_H2I_SHUTDOWN = 3,
509};
510
511enum bfi_msgq_i2h_msgs_e {
512 BFI_MSGQ_I2H_INIT_RSP = 1,
513 BFI_MSGQ_I2H_DOORBELL = 2,
514};
515
516
517/* Messages(commands/responsed/AENS will have the following header */
518struct bfi_msgq_mhdr_s {
519 u8 msg_class;
520 u8 msg_id;
521 u16 msg_token;
522 u16 num_entries;
523 u8 enet_id;
524 u8 rsvd[1];
525};
526
527#define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \
528 (_mh).msg_class = (_mc); \
529 (_mh).msg_id = (_mid); \
530 (_mh).msg_token = (_tok); \
531 (_mh).enet_id = (_enet_id); \
532} while (0)
533
534/*
535 * Mailbox for messaging interface
536 *
537*/
538#define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */
539#define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */
540#define BFI_MSGQ_MSG_SIZE_MAX (2048) /* TBD */
541
542struct bfi_msgq_s {
543 union bfi_addr_u addr;
544 u16 q_depth; /* Total num of entries in the queue */
545 u8 rsvd[2];
546};
547
548/* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
549struct bfi_msgq_cfg_req_s {
550 struct bfi_mhdr_s mh;
551 struct bfi_msgq_s cmdq;
552 struct bfi_msgq_s rspq;
553};
554
555/* BFI_ENET_MSGQ_CFG_RSP */
556struct bfi_msgq_cfg_rsp_s {
557 struct bfi_mhdr_s mh;
558 u8 cmd_status;
559 u8 rsvd[3];
560};
561
562
563/* BFI_MSGQ_H2I_DOORBELL */
564struct bfi_msgq_h2i_db_s {
565 struct bfi_mhdr_s mh;
566 u16 cmdq_pi;
567 u16 rspq_ci;
568};
569
570/* BFI_MSGQ_I2H_DOORBELL */
571struct bfi_msgq_i2h_db_s {
572 struct bfi_mhdr_s mh;
573 u16 rspq_pi;
574 u16 cmdq_ci;
575};
576
577#pragma pack()
578
579/* BFI port specific */
580#pragma pack(1)
581
582enum bfi_port_h2i {
583 BFI_PORT_H2I_ENABLE_REQ = (1),
584 BFI_PORT_H2I_DISABLE_REQ = (2),
585 BFI_PORT_H2I_GET_STATS_REQ = (3),
586 BFI_PORT_H2I_CLEAR_STATS_REQ = (4),
587};
588
589enum bfi_port_i2h {
590 BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1),
591 BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2),
592 BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3),
593 BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4),
594};
595
Jing Huangacdc79a2010-10-18 17:15:55 -0700596/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700597 * Generic REQ type
598 */
599struct bfi_port_generic_req_s {
600 struct bfi_mhdr_s mh; /* msg header */
601 u32 msgtag; /* msgtag for reply */
602 u32 rsvd;
603};
604
Jing Huangacdc79a2010-10-18 17:15:55 -0700605/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700606 * Generic RSP type
607 */
608struct bfi_port_generic_rsp_s {
609 struct bfi_mhdr_s mh; /* common msg header */
610 u8 status; /* port enable status */
611 u8 rsvd[3];
612 u32 msgtag; /* msgtag for reply */
613};
614
Jing Huangacdc79a2010-10-18 17:15:55 -0700615/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700616 * BFI_PORT_H2I_GET_STATS_REQ
617 */
618struct bfi_port_get_stats_req_s {
619 struct bfi_mhdr_s mh; /* common msg header */
620 union bfi_addr_u dma_addr;
621};
622
623union bfi_port_h2i_msg_u {
624 struct bfi_mhdr_s mh;
625 struct bfi_port_generic_req_s enable_req;
626 struct bfi_port_generic_req_s disable_req;
627 struct bfi_port_get_stats_req_s getstats_req;
628 struct bfi_port_generic_req_s clearstats_req;
629};
630
631union bfi_port_i2h_msg_u {
632 struct bfi_mhdr_s mh;
633 struct bfi_port_generic_rsp_s enable_rsp;
634 struct bfi_port_generic_rsp_s disable_rsp;
635 struct bfi_port_generic_rsp_s getstats_rsp;
636 struct bfi_port_generic_rsp_s clearstats_rsp;
637};
638
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700639/*
640 *----------------------------------------------------------------------
641 * ABLK
642 *----------------------------------------------------------------------
643 */
644enum bfi_ablk_h2i_msgs_e {
645 BFI_ABLK_H2I_QUERY = 1,
646 BFI_ABLK_H2I_ADPT_CONFIG = 2,
647 BFI_ABLK_H2I_PORT_CONFIG = 3,
648 BFI_ABLK_H2I_PF_CREATE = 4,
649 BFI_ABLK_H2I_PF_DELETE = 5,
650 BFI_ABLK_H2I_PF_UPDATE = 6,
651 BFI_ABLK_H2I_OPTROM_ENABLE = 7,
652 BFI_ABLK_H2I_OPTROM_DISABLE = 8,
653};
654
655enum bfi_ablk_i2h_msgs_e {
656 BFI_ABLK_I2H_QUERY = BFA_I2HM(BFI_ABLK_H2I_QUERY),
657 BFI_ABLK_I2H_ADPT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_ADPT_CONFIG),
658 BFI_ABLK_I2H_PORT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_PORT_CONFIG),
659 BFI_ABLK_I2H_PF_CREATE = BFA_I2HM(BFI_ABLK_H2I_PF_CREATE),
660 BFI_ABLK_I2H_PF_DELETE = BFA_I2HM(BFI_ABLK_H2I_PF_DELETE),
661 BFI_ABLK_I2H_PF_UPDATE = BFA_I2HM(BFI_ABLK_H2I_PF_UPDATE),
662 BFI_ABLK_I2H_OPTROM_ENABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_ENABLE),
663 BFI_ABLK_I2H_OPTROM_DISABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_DISABLE),
664};
665
666/* BFI_ABLK_H2I_QUERY */
667struct bfi_ablk_h2i_query_s {
668 struct bfi_mhdr_s mh;
669 union bfi_addr_u addr;
670};
671
672/* BFI_ABL_H2I_ADPT_CONFIG, BFI_ABLK_H2I_PORT_CONFIG */
673struct bfi_ablk_h2i_cfg_req_s {
674 struct bfi_mhdr_s mh;
675 u8 mode;
676 u8 port;
677 u8 max_pf;
678 u8 max_vf;
679};
680
681/*
682 * BFI_ABLK_H2I_PF_CREATE, BFI_ABLK_H2I_PF_DELETE,
683 */
684struct bfi_ablk_h2i_pf_req_s {
685 struct bfi_mhdr_s mh;
686 u8 pcifn;
687 u8 port;
688 u16 pers;
689 u32 bw;
690};
691
692/* BFI_ABLK_H2I_OPTROM_ENABLE, BFI_ABLK_H2I_OPTROM_DISABLE */
693struct bfi_ablk_h2i_optrom_s {
694 struct bfi_mhdr_s mh;
695};
696
697/*
698 * BFI_ABLK_I2H_QUERY
699 * BFI_ABLK_I2H_PORT_CONFIG
700 * BFI_ABLK_I2H_PF_CREATE
701 * BFI_ABLK_I2H_PF_DELETE
702 * BFI_ABLK_I2H_PF_UPDATE
703 * BFI_ABLK_I2H_OPTROM_ENABLE
704 * BFI_ABLK_I2H_OPTROM_DISABLE
705 */
706struct bfi_ablk_i2h_rsp_s {
707 struct bfi_mhdr_s mh;
708 u8 status;
709 u8 pcifn;
710 u8 port_mode;
711};
712
Krishna Gudipati148d6102011-06-24 20:25:36 -0700713
714/*
715 * CEE module specific messages
716 */
717
718/* Mailbox commands from host to firmware */
719enum bfi_cee_h2i_msgs_e {
720 BFI_CEE_H2I_GET_CFG_REQ = 1,
721 BFI_CEE_H2I_RESET_STATS = 2,
722 BFI_CEE_H2I_GET_STATS_REQ = 3,
723};
724
725enum bfi_cee_i2h_msgs_e {
726 BFI_CEE_I2H_GET_CFG_RSP = BFA_I2HM(1),
727 BFI_CEE_I2H_RESET_STATS_RSP = BFA_I2HM(2),
728 BFI_CEE_I2H_GET_STATS_RSP = BFA_I2HM(3),
729};
730
731/*
732 * H2I command structure for resetting the stats
733 */
734struct bfi_cee_reset_stats_s {
735 struct bfi_mhdr_s mh;
736};
737
738/*
739 * Get configuration command from host
740 */
741struct bfi_cee_get_req_s {
742 struct bfi_mhdr_s mh;
743 union bfi_addr_u dma_addr;
744};
745
746/*
747 * Reply message from firmware
748 */
749struct bfi_cee_get_rsp_s {
750 struct bfi_mhdr_s mh;
751 u8 cmd_status;
752 u8 rsvd[3];
753};
754
755/*
756 * Reply message from firmware
757 */
758struct bfi_cee_stats_rsp_s {
759 struct bfi_mhdr_s mh;
760 u8 cmd_status;
761 u8 rsvd[3];
762};
763
764/* Mailbox message structures from firmware to host */
765union bfi_cee_i2h_msg_u {
766 struct bfi_mhdr_s mh;
767 struct bfi_cee_get_rsp_s get_rsp;
768 struct bfi_cee_stats_rsp_s stats_rsp;
769};
770
Krishna Gudipati51e569a2011-06-24 20:26:25 -0700771/*
772 * SFP related
773 */
774
775enum bfi_sfp_h2i_e {
776 BFI_SFP_H2I_SHOW = 1,
777 BFI_SFP_H2I_SCN = 2,
778};
779
780enum bfi_sfp_i2h_e {
781 BFI_SFP_I2H_SHOW = BFA_I2HM(BFI_SFP_H2I_SHOW),
782 BFI_SFP_I2H_SCN = BFA_I2HM(BFI_SFP_H2I_SCN),
783};
784
785/*
786 * SFP state
787 */
788enum bfa_sfp_stat_e {
789 BFA_SFP_STATE_INIT = 0, /* SFP state is uninit */
790 BFA_SFP_STATE_REMOVED = 1, /* SFP is removed */
791 BFA_SFP_STATE_INSERTED = 2, /* SFP is inserted */
792 BFA_SFP_STATE_VALID = 3, /* SFP is valid */
793 BFA_SFP_STATE_UNSUPPORT = 4, /* SFP is unsupport */
794 BFA_SFP_STATE_FAILED = 5, /* SFP i2c read fail */
795};
796
797/*
798 * SFP memory access type
799 */
800enum bfi_sfp_mem_e {
801 BFI_SFP_MEM_ALL = 0x1, /* access all data field */
802 BFI_SFP_MEM_DIAGEXT = 0x2, /* access diag ext data field only */
803};
804
805struct bfi_sfp_req_s {
806 struct bfi_mhdr_s mh;
807 u8 memtype;
808 u8 rsvd[3];
809 struct bfi_alen_s alen;
810};
811
812struct bfi_sfp_rsp_s {
813 struct bfi_mhdr_s mh;
814 u8 status;
815 u8 state;
816 u8 rsvd[2];
817};
818
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -0700819/*
820 * FLASH module specific
821 */
822enum bfi_flash_h2i_msgs {
823 BFI_FLASH_H2I_QUERY_REQ = 1,
824 BFI_FLASH_H2I_ERASE_REQ = 2,
825 BFI_FLASH_H2I_WRITE_REQ = 3,
826 BFI_FLASH_H2I_READ_REQ = 4,
827 BFI_FLASH_H2I_BOOT_VER_REQ = 5,
828};
829
830enum bfi_flash_i2h_msgs {
831 BFI_FLASH_I2H_QUERY_RSP = BFA_I2HM(1),
832 BFI_FLASH_I2H_ERASE_RSP = BFA_I2HM(2),
833 BFI_FLASH_I2H_WRITE_RSP = BFA_I2HM(3),
834 BFI_FLASH_I2H_READ_RSP = BFA_I2HM(4),
835 BFI_FLASH_I2H_BOOT_VER_RSP = BFA_I2HM(5),
836 BFI_FLASH_I2H_EVENT = BFA_I2HM(127),
837};
838
839/*
840 * Flash query request
841 */
842struct bfi_flash_query_req_s {
843 struct bfi_mhdr_s mh; /* Common msg header */
844 struct bfi_alen_s alen;
845};
846
847/*
848 * Flash erase request
849 */
850struct bfi_flash_erase_req_s {
851 struct bfi_mhdr_s mh; /* Common msg header */
852 u32 type; /* partition type */
853 u8 instance; /* partition instance */
854 u8 rsv[3];
855};
856
857/*
858 * Flash write request
859 */
860struct bfi_flash_write_req_s {
861 struct bfi_mhdr_s mh; /* Common msg header */
862 struct bfi_alen_s alen;
863 u32 type; /* partition type */
864 u8 instance; /* partition instance */
865 u8 last;
866 u8 rsv[2];
867 u32 offset;
868 u32 length;
869};
870
871/*
872 * Flash read request
873 */
874struct bfi_flash_read_req_s {
875 struct bfi_mhdr_s mh; /* Common msg header */
876 u32 type; /* partition type */
877 u8 instance; /* partition instance */
878 u8 rsv[3];
879 u32 offset;
880 u32 length;
881 struct bfi_alen_s alen;
882};
883
884/*
885 * Flash query response
886 */
887struct bfi_flash_query_rsp_s {
888 struct bfi_mhdr_s mh; /* Common msg header */
889 u32 status;
890};
891
892/*
893 * Flash read response
894 */
895struct bfi_flash_read_rsp_s {
896 struct bfi_mhdr_s mh; /* Common msg header */
897 u32 type; /* partition type */
898 u8 instance; /* partition instance */
899 u8 rsv[3];
900 u32 status;
901 u32 length;
902};
903
904/*
905 * Flash write response
906 */
907struct bfi_flash_write_rsp_s {
908 struct bfi_mhdr_s mh; /* Common msg header */
909 u32 type; /* partition type */
910 u8 instance; /* partition instance */
911 u8 rsv[3];
912 u32 status;
913 u32 length;
914};
915
916/*
917 * Flash erase response
918 */
919struct bfi_flash_erase_rsp_s {
920 struct bfi_mhdr_s mh; /* Common msg header */
921 u32 type; /* partition type */
922 u8 instance; /* partition instance */
923 u8 rsv[3];
924 u32 status;
925};
926
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700927/*
928 *----------------------------------------------------------------------
929 * DIAG
930 *----------------------------------------------------------------------
931 */
932enum bfi_diag_h2i {
933 BFI_DIAG_H2I_PORTBEACON = 1,
934 BFI_DIAG_H2I_LOOPBACK = 2,
935 BFI_DIAG_H2I_FWPING = 3,
936 BFI_DIAG_H2I_TEMPSENSOR = 4,
937 BFI_DIAG_H2I_LEDTEST = 5,
938 BFI_DIAG_H2I_QTEST = 6,
939};
940
941enum bfi_diag_i2h {
942 BFI_DIAG_I2H_PORTBEACON = BFA_I2HM(BFI_DIAG_H2I_PORTBEACON),
943 BFI_DIAG_I2H_LOOPBACK = BFA_I2HM(BFI_DIAG_H2I_LOOPBACK),
944 BFI_DIAG_I2H_FWPING = BFA_I2HM(BFI_DIAG_H2I_FWPING),
945 BFI_DIAG_I2H_TEMPSENSOR = BFA_I2HM(BFI_DIAG_H2I_TEMPSENSOR),
946 BFI_DIAG_I2H_LEDTEST = BFA_I2HM(BFI_DIAG_H2I_LEDTEST),
947 BFI_DIAG_I2H_QTEST = BFA_I2HM(BFI_DIAG_H2I_QTEST),
948};
949
950#define BFI_DIAG_MAX_SGES 2
951#define BFI_DIAG_DMA_BUF_SZ (2 * 1024)
952#define BFI_BOOT_MEMTEST_RES_ADDR 0x900
953#define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3
954
955struct bfi_diag_lb_req_s {
956 struct bfi_mhdr_s mh;
957 u32 loopcnt;
958 u32 pattern;
959 u8 lb_mode; /*!< bfa_port_opmode_t */
960 u8 speed; /*!< bfa_port_speed_t */
961 u8 rsvd[2];
962};
963
964struct bfi_diag_lb_rsp_s {
965 struct bfi_mhdr_s mh; /* 4 bytes */
966 struct bfa_diag_loopback_result_s res; /* 16 bytes */
967};
968
969struct bfi_diag_fwping_req_s {
970 struct bfi_mhdr_s mh; /* 4 bytes */
971 struct bfi_alen_s alen; /* 12 bytes */
972 u32 data; /* user input data pattern */
973 u32 count; /* user input dma count */
974 u8 qtag; /* track CPE vc */
975 u8 rsv[3];
976};
977
978struct bfi_diag_fwping_rsp_s {
979 struct bfi_mhdr_s mh; /* 4 bytes */
980 u32 data; /* user input data pattern */
981 u8 qtag; /* track CPE vc */
982 u8 dma_status; /* dma status */
983 u8 rsv[2];
984};
985
986/*
987 * Temperature Sensor
988 */
989struct bfi_diag_ts_req_s {
990 struct bfi_mhdr_s mh; /* 4 bytes */
991 u16 temp; /* 10-bit A/D value */
992 u16 brd_temp; /* 9-bit board temp */
993 u8 status;
994 u8 ts_junc; /* show junction tempsensor */
995 u8 ts_brd; /* show board tempsensor */
996 u8 rsv;
997};
998#define bfi_diag_ts_rsp_t struct bfi_diag_ts_req_s
999
1000struct bfi_diag_ledtest_req_s {
1001 struct bfi_mhdr_s mh; /* 4 bytes */
1002 u8 cmd;
1003 u8 color;
1004 u8 portid;
1005 u8 led; /* bitmap of LEDs to be tested */
1006 u16 freq; /* no. of blinks every 10 secs */
1007 u8 rsv[2];
1008};
1009
1010/* notify host led operation is done */
1011struct bfi_diag_ledtest_rsp_s {
1012 struct bfi_mhdr_s mh; /* 4 bytes */
1013};
1014
1015struct bfi_diag_portbeacon_req_s {
1016 struct bfi_mhdr_s mh; /* 4 bytes */
1017 u32 period; /* beaconing period */
1018 u8 beacon; /* 1: beacon on */
1019 u8 rsvd[3];
1020};
1021
1022/* notify host the beacon is off */
1023struct bfi_diag_portbeacon_rsp_s {
1024 struct bfi_mhdr_s mh; /* 4 bytes */
1025};
1026
1027struct bfi_diag_qtest_req_s {
1028 struct bfi_mhdr_s mh; /* 4 bytes */
1029 u32 data[BFI_LMSG_PL_WSZ]; /* fill up tcm prefetch area */
1030};
1031#define bfi_diag_qtest_rsp_t struct bfi_diag_qtest_req_s
1032
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001033#pragma pack()
1034
1035#endif /* __BFI_H__ */