blob: 0d249984fd08a8247c57665a8e17605b0aa2dab9 [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 Gudipati148d6102011-06-24 20:25:36 -0700193 BFI_MC_CEE = 4, /* CEE */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700194 BFI_MC_FCPORT = 5, /* FC port */
195 BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700196 BFI_MC_ABLK = 7, /* ASIC block configuration */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700197 BFI_MC_UF = 8, /* Unsolicited frame receive */
198 BFI_MC_FCXP = 9, /* FC Transport */
199 BFI_MC_LPS = 10, /* lport fc login services */
200 BFI_MC_RPORT = 11, /* Remote port */
Krishna Gudipatidd5aaf42011-06-13 15:51:24 -0700201 BFI_MC_ITN = 12, /* I-T nexus (Initiator mode) */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700202 BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */
203 BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */
204 BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */
205 BFI_MC_IOIM = 16, /* IO (Initiator mode) */
206 BFI_MC_IOIM_IOCOM = 17, /* good IO completion */
207 BFI_MC_TSKIM = 18, /* Initiator Task management */
208 BFI_MC_PORT = 21, /* Physical port */
Krishna Gudipati51e569a2011-06-24 20:26:25 -0700209 BFI_MC_SFP = 22, /* SFP module */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700210 BFI_MC_MAX = 32
211};
212
213#define BFI_IOC_MAX_CQS 4
214#define BFI_IOC_MAX_CQS_ASIC 8
215#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
216
Jing Huangacdc79a2010-10-18 17:15:55 -0700217/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700218 *----------------------------------------------------------------------
219 * IOC
220 *----------------------------------------------------------------------
221 */
222
Krishna Gudipati11189202011-06-13 15:50:35 -0700223/*
224 * Different asic generations
225 */
226enum bfi_asic_gen {
227 BFI_ASIC_GEN_CB = 1, /* crossbow 8G FC */
228 BFI_ASIC_GEN_CT = 2, /* catapult 8G FC or 10G CNA */
229 BFI_ASIC_GEN_CT2 = 3, /* catapult-2 16G FC or 10G CNA */
230};
231
232enum bfi_asic_mode {
233 BFI_ASIC_MODE_FC = 1, /* FC upto 8G speed */
234 BFI_ASIC_MODE_FC16 = 2, /* FC upto 16G speed */
235 BFI_ASIC_MODE_ETH = 3, /* Ethernet ports */
236 BFI_ASIC_MODE_COMBO = 4, /* FC 16G and Ethernet 10G port */
237};
238
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700239enum bfi_ioc_h2i_msgs {
240 BFI_IOC_H2I_ENABLE_REQ = 1,
241 BFI_IOC_H2I_DISABLE_REQ = 2,
242 BFI_IOC_H2I_GETATTR_REQ = 3,
243 BFI_IOC_H2I_DBG_SYNC = 4,
244 BFI_IOC_H2I_DBG_DUMP = 5,
245};
246
247enum bfi_ioc_i2h_msgs {
248 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
249 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
250 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
Krishna Gudipati775c7742011-06-13 15:52:12 -0700251 BFI_IOC_I2H_HBEAT = BFA_I2HM(4),
Krishna Gudipatia7141342011-06-24 20:23:19 -0700252 BFI_IOC_I2H_ACQ_ADDR_REPLY = BFA_I2HM(5),
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700253};
254
Jing Huangacdc79a2010-10-18 17:15:55 -0700255/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700256 * BFI_IOC_H2I_GETATTR_REQ message
257 */
258struct bfi_ioc_getattr_req_s {
259 struct bfi_mhdr_s mh;
260 union bfi_addr_u attr_addr;
261};
262
263struct bfi_ioc_attr_s {
264 wwn_t mfg_pwwn; /* Mfg port wwn */
265 wwn_t mfg_nwwn; /* Mfg node wwn */
266 mac_t mfg_mac; /* Mfg mac */
Krishna Gudipati5a0adae2011-06-24 20:22:56 -0700267 u8 port_mode; /* bfi_port_mode */
268 u8 rsvd_a;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700269 wwn_t pwwn;
270 wwn_t nwwn;
271 mac_t mac; /* PBC or Mfg mac */
272 u16 rsvd_b;
273 mac_t fcoe_mac;
274 u16 rsvd_c;
275 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
276 u8 pcie_gen;
277 u8 pcie_lanes_orig;
278 u8 pcie_lanes;
279 u8 rx_bbcredit; /* receive buffer credits */
280 u32 adapter_prop; /* adapter properties */
281 u16 maxfrsize; /* max receive frame size */
282 char asic_rev;
Krishna Gudipati10a07372011-06-24 20:23:38 -0700283 u8 rsvd_d;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700284 char fw_version[BFA_VERSION_LEN];
285 char optrom_version[BFA_VERSION_LEN];
286 struct bfa_mfg_vpd_s vpd;
287 u32 card_type; /* card type */
288};
289
Jing Huangacdc79a2010-10-18 17:15:55 -0700290/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700291 * BFI_IOC_I2H_GETATTR_REPLY message
292 */
293struct bfi_ioc_getattr_reply_s {
294 struct bfi_mhdr_s mh; /* Common msg header */
295 u8 status; /* cfg reply status */
296 u8 rsvd[3];
297};
298
Jing Huangacdc79a2010-10-18 17:15:55 -0700299/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700300 * Firmware memory page offsets
301 */
302#define BFI_IOC_SMEM_PG0_CB (0x40)
303#define BFI_IOC_SMEM_PG0_CT (0x180)
304
Jing Huangacdc79a2010-10-18 17:15:55 -0700305/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700306 * Firmware statistic offset
307 */
308#define BFI_IOC_FWSTATS_OFF (0x6B40)
309#define BFI_IOC_FWSTATS_SZ (4096)
310
Jing Huangacdc79a2010-10-18 17:15:55 -0700311/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700312 * Firmware trace offset
313 */
314#define BFI_IOC_TRC_OFF (0x4b00)
315#define BFI_IOC_TRC_ENTS 256
316
317#define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
318#define BFI_IOC_MD5SUM_SZ 4
319struct bfi_ioc_image_hdr_s {
Krishna Gudipati11189202011-06-13 15:50:35 -0700320 u32 signature; /* constant signature */
321 u8 asic_gen; /* asic generation */
322 u8 asic_mode;
323 u8 port0_mode; /* device mode for port 0 */
324 u8 port1_mode; /* device mode for port 1 */
325 u32 exec; /* exec vector */
326 u32 bootenv; /* fimware boot env */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700327 u32 rsvd_b[4];
328 u32 md5sum[BFI_IOC_MD5SUM_SZ];
329};
330
Krishna Gudipati11189202011-06-13 15:50:35 -0700331#define BFI_FWBOOT_DEVMODE_OFF 4
332#define BFI_FWBOOT_TYPE_OFF 8
333#define BFI_FWBOOT_ENV_OFF 12
334#define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \
335 (((u32)(__asic_gen)) << 24 | \
336 ((u32)(__asic_mode)) << 16 | \
337 ((u32)(__p0_mode)) << 8 | \
338 ((u32)(__p1_mode)))
339
340#define BFI_FWBOOT_TYPE_NORMAL 0
341#define BFI_FWBOOT_TYPE_MEMTEST 1
342#define BFI_FWBOOT_ENV_OS 0
343
344enum bfi_port_mode {
345 BFI_PORT_MODE_FC = 1,
346 BFI_PORT_MODE_ETH = 2,
347};
348
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700349struct bfi_ioc_hbeat_s {
350 struct bfi_mhdr_s mh; /* common msg header */
351 u32 hb_count; /* current heart beat count */
352};
353
Jing Huangacdc79a2010-10-18 17:15:55 -0700354/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700355 * IOC hardware/firmware state
356 */
357enum bfi_ioc_state {
358 BFI_IOC_UNINIT = 0, /* not initialized */
359 BFI_IOC_INITING = 1, /* h/w is being initialized */
360 BFI_IOC_HWINIT = 2, /* h/w is initialized */
361 BFI_IOC_CFG = 3, /* IOC configuration in progress */
362 BFI_IOC_OP = 4, /* IOC is operational */
363 BFI_IOC_DISABLING = 5, /* IOC is being disabled */
364 BFI_IOC_DISABLED = 6, /* IOC is disabled */
365 BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */
366 BFI_IOC_FAIL = 8, /* IOC heart-beat failure */
367 BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */
368};
369
370#define BFI_IOC_ENDIAN_SIG 0x12345678
371
372enum {
373 BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */
374 BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */
375 BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */
376 BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */
377 BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */
378 BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */
379 BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */
380 BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */
381 BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */
382 BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */
383};
384
385#define BFI_ADAPTER_GETP(__prop, __adap_prop) \
386 (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
387 BFI_ADAPTER_ ## __prop ## _SH)
388#define BFI_ADAPTER_SETP(__prop, __val) \
389 ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
390#define BFI_ADAPTER_IS_PROTO(__adap_type) \
391 ((__adap_type) & BFI_ADAPTER_PROTO)
392#define BFI_ADAPTER_IS_TTV(__adap_type) \
393 ((__adap_type) & BFI_ADAPTER_TTV)
394#define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
395 ((__adap_type) & BFI_ADAPTER_UNSUPP)
396#define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
397 ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
398 BFI_ADAPTER_UNSUPP))
399
Jing Huangacdc79a2010-10-18 17:15:55 -0700400/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700401 * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
402 */
403struct bfi_ioc_ctrl_req_s {
404 struct bfi_mhdr_s mh;
Krishna Gudipatid37779f2011-06-13 15:42:10 -0700405 u16 clscode;
406 u16 rsvd;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700407 u32 tv_sec;
408};
409#define bfi_ioc_enable_req_t struct bfi_ioc_ctrl_req_s;
410#define bfi_ioc_disable_req_t struct bfi_ioc_ctrl_req_s;
411
Jing Huangacdc79a2010-10-18 17:15:55 -0700412/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700413 * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
414 */
415struct bfi_ioc_ctrl_reply_s {
416 struct bfi_mhdr_s mh; /* Common msg header */
417 u8 status; /* enable/disable status */
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700418 u8 port_mode; /* bfa_mode_s */
419 u8 cap_bm; /* capability bit mask */
420 u8 rsvd;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700421};
422#define bfi_ioc_enable_reply_t struct bfi_ioc_ctrl_reply_s;
423#define bfi_ioc_disable_reply_t struct bfi_ioc_ctrl_reply_s;
424
425#define BFI_IOC_MSGSZ 8
Jing Huangacdc79a2010-10-18 17:15:55 -0700426/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700427 * H2I Messages
428 */
429union bfi_ioc_h2i_msg_u {
430 struct bfi_mhdr_s mh;
431 struct bfi_ioc_ctrl_req_s enable_req;
432 struct bfi_ioc_ctrl_req_s disable_req;
433 struct bfi_ioc_getattr_req_s getattr_req;
434 u32 mboxmsg[BFI_IOC_MSGSZ];
435};
436
Jing Huangacdc79a2010-10-18 17:15:55 -0700437/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700438 * I2H Messages
439 */
440union bfi_ioc_i2h_msg_u {
441 struct bfi_mhdr_s mh;
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700442 struct bfi_ioc_ctrl_reply_s fw_event;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700443 u32 mboxmsg[BFI_IOC_MSGSZ];
444};
445
446
Jing Huangacdc79a2010-10-18 17:15:55 -0700447/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700448 *----------------------------------------------------------------------
449 * PBC
450 *----------------------------------------------------------------------
451 */
452
453#define BFI_PBC_MAX_BLUNS 8
454#define BFI_PBC_MAX_VPORTS 16
Krishna Gudipati43ffdf42011-06-13 15:46:21 -0700455#define BFI_PBC_PORT_DISABLED 2
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700456
Jing Huangacdc79a2010-10-18 17:15:55 -0700457/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700458 * PBC boot lun configuration
459 */
460struct bfi_pbc_blun_s {
461 wwn_t tgt_pwwn;
Maggie Zhangf3148782010-12-09 19:11:39 -0800462 struct scsi_lun tgt_lun;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700463};
464
Jing Huangacdc79a2010-10-18 17:15:55 -0700465/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700466 * PBC virtual port configuration
467 */
468struct bfi_pbc_vport_s {
469 wwn_t vp_pwwn;
470 wwn_t vp_nwwn;
471};
472
Jing Huangacdc79a2010-10-18 17:15:55 -0700473/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700474 * BFI pre-boot configuration information
475 */
476struct bfi_pbc_s {
477 u8 port_enabled;
478 u8 boot_enabled;
479 u8 nbluns;
480 u8 nvports;
481 u8 port_speed;
482 u8 rsvd_a;
483 u16 hss;
484 wwn_t pbc_pwwn;
485 wwn_t pbc_nwwn;
486 struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS];
487 struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS];
488};
489
Jing Huangacdc79a2010-10-18 17:15:55 -0700490/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700491 *----------------------------------------------------------------------
492 * MSGQ
493 *----------------------------------------------------------------------
494 */
495#define BFI_MSGQ_FULL(_q) (((_q->pi + 1) % _q->q_depth) == _q->ci)
496#define BFI_MSGQ_EMPTY(_q) (_q->pi == _q->ci)
497#define BFI_MSGQ_UPDATE_CI(_q) (_q->ci = (_q->ci + 1) % _q->q_depth)
498#define BFI_MSGQ_UPDATE_PI(_q) (_q->pi = (_q->pi + 1) % _q->q_depth)
499
500/* q_depth must be power of 2 */
501#define BFI_MSGQ_FREE_CNT(_q) ((_q->ci - _q->pi - 1) & (_q->q_depth - 1))
502
503enum bfi_msgq_h2i_msgs_e {
504 BFI_MSGQ_H2I_INIT_REQ = 1,
505 BFI_MSGQ_H2I_DOORBELL = 2,
506 BFI_MSGQ_H2I_SHUTDOWN = 3,
507};
508
509enum bfi_msgq_i2h_msgs_e {
510 BFI_MSGQ_I2H_INIT_RSP = 1,
511 BFI_MSGQ_I2H_DOORBELL = 2,
512};
513
514
515/* Messages(commands/responsed/AENS will have the following header */
516struct bfi_msgq_mhdr_s {
517 u8 msg_class;
518 u8 msg_id;
519 u16 msg_token;
520 u16 num_entries;
521 u8 enet_id;
522 u8 rsvd[1];
523};
524
525#define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \
526 (_mh).msg_class = (_mc); \
527 (_mh).msg_id = (_mid); \
528 (_mh).msg_token = (_tok); \
529 (_mh).enet_id = (_enet_id); \
530} while (0)
531
532/*
533 * Mailbox for messaging interface
534 *
535*/
536#define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */
537#define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */
538#define BFI_MSGQ_MSG_SIZE_MAX (2048) /* TBD */
539
540struct bfi_msgq_s {
541 union bfi_addr_u addr;
542 u16 q_depth; /* Total num of entries in the queue */
543 u8 rsvd[2];
544};
545
546/* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
547struct bfi_msgq_cfg_req_s {
548 struct bfi_mhdr_s mh;
549 struct bfi_msgq_s cmdq;
550 struct bfi_msgq_s rspq;
551};
552
553/* BFI_ENET_MSGQ_CFG_RSP */
554struct bfi_msgq_cfg_rsp_s {
555 struct bfi_mhdr_s mh;
556 u8 cmd_status;
557 u8 rsvd[3];
558};
559
560
561/* BFI_MSGQ_H2I_DOORBELL */
562struct bfi_msgq_h2i_db_s {
563 struct bfi_mhdr_s mh;
564 u16 cmdq_pi;
565 u16 rspq_ci;
566};
567
568/* BFI_MSGQ_I2H_DOORBELL */
569struct bfi_msgq_i2h_db_s {
570 struct bfi_mhdr_s mh;
571 u16 rspq_pi;
572 u16 cmdq_ci;
573};
574
575#pragma pack()
576
577/* BFI port specific */
578#pragma pack(1)
579
580enum bfi_port_h2i {
581 BFI_PORT_H2I_ENABLE_REQ = (1),
582 BFI_PORT_H2I_DISABLE_REQ = (2),
583 BFI_PORT_H2I_GET_STATS_REQ = (3),
584 BFI_PORT_H2I_CLEAR_STATS_REQ = (4),
585};
586
587enum bfi_port_i2h {
588 BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1),
589 BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2),
590 BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3),
591 BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4),
592};
593
Jing Huangacdc79a2010-10-18 17:15:55 -0700594/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700595 * Generic REQ type
596 */
597struct bfi_port_generic_req_s {
598 struct bfi_mhdr_s mh; /* msg header */
599 u32 msgtag; /* msgtag for reply */
600 u32 rsvd;
601};
602
Jing Huangacdc79a2010-10-18 17:15:55 -0700603/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700604 * Generic RSP type
605 */
606struct bfi_port_generic_rsp_s {
607 struct bfi_mhdr_s mh; /* common msg header */
608 u8 status; /* port enable status */
609 u8 rsvd[3];
610 u32 msgtag; /* msgtag for reply */
611};
612
Jing Huangacdc79a2010-10-18 17:15:55 -0700613/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700614 * BFI_PORT_H2I_GET_STATS_REQ
615 */
616struct bfi_port_get_stats_req_s {
617 struct bfi_mhdr_s mh; /* common msg header */
618 union bfi_addr_u dma_addr;
619};
620
621union bfi_port_h2i_msg_u {
622 struct bfi_mhdr_s mh;
623 struct bfi_port_generic_req_s enable_req;
624 struct bfi_port_generic_req_s disable_req;
625 struct bfi_port_get_stats_req_s getstats_req;
626 struct bfi_port_generic_req_s clearstats_req;
627};
628
629union bfi_port_i2h_msg_u {
630 struct bfi_mhdr_s mh;
631 struct bfi_port_generic_rsp_s enable_rsp;
632 struct bfi_port_generic_rsp_s disable_rsp;
633 struct bfi_port_generic_rsp_s getstats_rsp;
634 struct bfi_port_generic_rsp_s clearstats_rsp;
635};
636
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700637/*
638 *----------------------------------------------------------------------
639 * ABLK
640 *----------------------------------------------------------------------
641 */
642enum bfi_ablk_h2i_msgs_e {
643 BFI_ABLK_H2I_QUERY = 1,
644 BFI_ABLK_H2I_ADPT_CONFIG = 2,
645 BFI_ABLK_H2I_PORT_CONFIG = 3,
646 BFI_ABLK_H2I_PF_CREATE = 4,
647 BFI_ABLK_H2I_PF_DELETE = 5,
648 BFI_ABLK_H2I_PF_UPDATE = 6,
649 BFI_ABLK_H2I_OPTROM_ENABLE = 7,
650 BFI_ABLK_H2I_OPTROM_DISABLE = 8,
651};
652
653enum bfi_ablk_i2h_msgs_e {
654 BFI_ABLK_I2H_QUERY = BFA_I2HM(BFI_ABLK_H2I_QUERY),
655 BFI_ABLK_I2H_ADPT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_ADPT_CONFIG),
656 BFI_ABLK_I2H_PORT_CONFIG = BFA_I2HM(BFI_ABLK_H2I_PORT_CONFIG),
657 BFI_ABLK_I2H_PF_CREATE = BFA_I2HM(BFI_ABLK_H2I_PF_CREATE),
658 BFI_ABLK_I2H_PF_DELETE = BFA_I2HM(BFI_ABLK_H2I_PF_DELETE),
659 BFI_ABLK_I2H_PF_UPDATE = BFA_I2HM(BFI_ABLK_H2I_PF_UPDATE),
660 BFI_ABLK_I2H_OPTROM_ENABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_ENABLE),
661 BFI_ABLK_I2H_OPTROM_DISABLE = BFA_I2HM(BFI_ABLK_H2I_OPTROM_DISABLE),
662};
663
664/* BFI_ABLK_H2I_QUERY */
665struct bfi_ablk_h2i_query_s {
666 struct bfi_mhdr_s mh;
667 union bfi_addr_u addr;
668};
669
670/* BFI_ABL_H2I_ADPT_CONFIG, BFI_ABLK_H2I_PORT_CONFIG */
671struct bfi_ablk_h2i_cfg_req_s {
672 struct bfi_mhdr_s mh;
673 u8 mode;
674 u8 port;
675 u8 max_pf;
676 u8 max_vf;
677};
678
679/*
680 * BFI_ABLK_H2I_PF_CREATE, BFI_ABLK_H2I_PF_DELETE,
681 */
682struct bfi_ablk_h2i_pf_req_s {
683 struct bfi_mhdr_s mh;
684 u8 pcifn;
685 u8 port;
686 u16 pers;
687 u32 bw;
688};
689
690/* BFI_ABLK_H2I_OPTROM_ENABLE, BFI_ABLK_H2I_OPTROM_DISABLE */
691struct bfi_ablk_h2i_optrom_s {
692 struct bfi_mhdr_s mh;
693};
694
695/*
696 * BFI_ABLK_I2H_QUERY
697 * BFI_ABLK_I2H_PORT_CONFIG
698 * BFI_ABLK_I2H_PF_CREATE
699 * BFI_ABLK_I2H_PF_DELETE
700 * BFI_ABLK_I2H_PF_UPDATE
701 * BFI_ABLK_I2H_OPTROM_ENABLE
702 * BFI_ABLK_I2H_OPTROM_DISABLE
703 */
704struct bfi_ablk_i2h_rsp_s {
705 struct bfi_mhdr_s mh;
706 u8 status;
707 u8 pcifn;
708 u8 port_mode;
709};
710
Krishna Gudipati148d6102011-06-24 20:25:36 -0700711
712/*
713 * CEE module specific messages
714 */
715
716/* Mailbox commands from host to firmware */
717enum bfi_cee_h2i_msgs_e {
718 BFI_CEE_H2I_GET_CFG_REQ = 1,
719 BFI_CEE_H2I_RESET_STATS = 2,
720 BFI_CEE_H2I_GET_STATS_REQ = 3,
721};
722
723enum bfi_cee_i2h_msgs_e {
724 BFI_CEE_I2H_GET_CFG_RSP = BFA_I2HM(1),
725 BFI_CEE_I2H_RESET_STATS_RSP = BFA_I2HM(2),
726 BFI_CEE_I2H_GET_STATS_RSP = BFA_I2HM(3),
727};
728
729/*
730 * H2I command structure for resetting the stats
731 */
732struct bfi_cee_reset_stats_s {
733 struct bfi_mhdr_s mh;
734};
735
736/*
737 * Get configuration command from host
738 */
739struct bfi_cee_get_req_s {
740 struct bfi_mhdr_s mh;
741 union bfi_addr_u dma_addr;
742};
743
744/*
745 * Reply message from firmware
746 */
747struct bfi_cee_get_rsp_s {
748 struct bfi_mhdr_s mh;
749 u8 cmd_status;
750 u8 rsvd[3];
751};
752
753/*
754 * Reply message from firmware
755 */
756struct bfi_cee_stats_rsp_s {
757 struct bfi_mhdr_s mh;
758 u8 cmd_status;
759 u8 rsvd[3];
760};
761
762/* Mailbox message structures from firmware to host */
763union bfi_cee_i2h_msg_u {
764 struct bfi_mhdr_s mh;
765 struct bfi_cee_get_rsp_s get_rsp;
766 struct bfi_cee_stats_rsp_s stats_rsp;
767};
768
Krishna Gudipati51e569a2011-06-24 20:26:25 -0700769/*
770 * SFP related
771 */
772
773enum bfi_sfp_h2i_e {
774 BFI_SFP_H2I_SHOW = 1,
775 BFI_SFP_H2I_SCN = 2,
776};
777
778enum bfi_sfp_i2h_e {
779 BFI_SFP_I2H_SHOW = BFA_I2HM(BFI_SFP_H2I_SHOW),
780 BFI_SFP_I2H_SCN = BFA_I2HM(BFI_SFP_H2I_SCN),
781};
782
783/*
784 * SFP state
785 */
786enum bfa_sfp_stat_e {
787 BFA_SFP_STATE_INIT = 0, /* SFP state is uninit */
788 BFA_SFP_STATE_REMOVED = 1, /* SFP is removed */
789 BFA_SFP_STATE_INSERTED = 2, /* SFP is inserted */
790 BFA_SFP_STATE_VALID = 3, /* SFP is valid */
791 BFA_SFP_STATE_UNSUPPORT = 4, /* SFP is unsupport */
792 BFA_SFP_STATE_FAILED = 5, /* SFP i2c read fail */
793};
794
795/*
796 * SFP memory access type
797 */
798enum bfi_sfp_mem_e {
799 BFI_SFP_MEM_ALL = 0x1, /* access all data field */
800 BFI_SFP_MEM_DIAGEXT = 0x2, /* access diag ext data field only */
801};
802
803struct bfi_sfp_req_s {
804 struct bfi_mhdr_s mh;
805 u8 memtype;
806 u8 rsvd[3];
807 struct bfi_alen_s alen;
808};
809
810struct bfi_sfp_rsp_s {
811 struct bfi_mhdr_s mh;
812 u8 status;
813 u8 state;
814 u8 rsvd[2];
815};
816
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700817#pragma pack()
818
819#endif /* __BFI_H__ */