xref: /linux/drivers/net/ethernet/brocade/bna/bfi.h (revision 2732ba56)
1f844a0eaSJeff Kirsher /*
2*2732ba56SRasesh Mody  * Linux network driver for QLogic BR-series Converged Network Adapter.
3f844a0eaSJeff Kirsher  *
4f844a0eaSJeff Kirsher  * This program is free software; you can redistribute it and/or modify it
5f844a0eaSJeff Kirsher  * under the terms of the GNU General Public License (GPL) Version 2 as
6f844a0eaSJeff Kirsher  * published by the Free Software Foundation
7f844a0eaSJeff Kirsher  *
8f844a0eaSJeff Kirsher  * This program is distributed in the hope that it will be useful, but
9f844a0eaSJeff Kirsher  * WITHOUT ANY WARRANTY; without even the implied warranty of
10f844a0eaSJeff Kirsher  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11f844a0eaSJeff Kirsher  * General Public License for more details.
12f844a0eaSJeff Kirsher  */
13f844a0eaSJeff Kirsher /*
14*2732ba56SRasesh Mody  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
15*2732ba56SRasesh Mody  * Copyright (c) 2014-2015 QLogic Corporation
16f844a0eaSJeff Kirsher  * All rights reserved
17*2732ba56SRasesh Mody  * www.qlogic.com
18f844a0eaSJeff Kirsher  */
19f844a0eaSJeff Kirsher #ifndef __BFI_H__
20f844a0eaSJeff Kirsher #define __BFI_H__
21f844a0eaSJeff Kirsher 
22f844a0eaSJeff Kirsher #include "bfa_defs.h"
23f844a0eaSJeff Kirsher 
24f844a0eaSJeff Kirsher #pragma pack(1)
25f844a0eaSJeff Kirsher 
261aa8b471SBen Hutchings /* BFI FW image type */
27f844a0eaSJeff Kirsher #define	BFI_FLASH_CHUNK_SZ			256	/*!< Flash chunk size */
28f844a0eaSJeff Kirsher #define	BFI_FLASH_CHUNK_SZ_WORDS	(BFI_FLASH_CHUNK_SZ/sizeof(u32))
29c107ba17SRasesh Mody #define BFI_FLASH_IMAGE_SZ		0x100000
30f844a0eaSJeff Kirsher 
311aa8b471SBen Hutchings /* Msg header common to all msgs */
32f844a0eaSJeff Kirsher struct bfi_mhdr {
33f844a0eaSJeff Kirsher 	u8		msg_class;	/*!< @ref enum bfi_mclass	    */
34f844a0eaSJeff Kirsher 	u8		msg_id;		/*!< msg opcode with in the class   */
35f844a0eaSJeff Kirsher 	union {
36f844a0eaSJeff Kirsher 		struct {
37078086f3SRasesh Mody 			u8	qid;
38078086f3SRasesh Mody 			u8	fn_lpu;	/*!< msg destination		    */
39f844a0eaSJeff Kirsher 		} h2i;
40f844a0eaSJeff Kirsher 		u16	i2htok;	/*!< token in msgs to host	    */
41f844a0eaSJeff Kirsher 	} mtag;
42f844a0eaSJeff Kirsher };
43f844a0eaSJeff Kirsher 
44078086f3SRasesh Mody #define bfi_fn_lpu(__fn, __lpu)	((__fn) << 1 | (__lpu))
45078086f3SRasesh Mody #define bfi_mhdr_2_fn(_mh)	((_mh)->mtag.h2i.fn_lpu >> 1)
46078086f3SRasesh Mody #define bfi_mhdr_2_qid(_mh)	((_mh)->mtag.h2i.qid)
47078086f3SRasesh Mody 
48078086f3SRasesh Mody #define bfi_h2i_set(_mh, _mc, _op, _fn_lpu) do {		\
49f844a0eaSJeff Kirsher 	(_mh).msg_class			= (_mc);		\
50f844a0eaSJeff Kirsher 	(_mh).msg_id			= (_op);		\
51078086f3SRasesh Mody 	(_mh).mtag.h2i.fn_lpu	= (_fn_lpu);			\
52f844a0eaSJeff Kirsher } while (0)
53f844a0eaSJeff Kirsher 
54f844a0eaSJeff Kirsher #define bfi_i2h_set(_mh, _mc, _op, _i2htok) do {		\
55f844a0eaSJeff Kirsher 	(_mh).msg_class			= (_mc);		\
56f844a0eaSJeff Kirsher 	(_mh).msg_id			= (_op);		\
57f844a0eaSJeff Kirsher 	(_mh).mtag.i2htok		= (_i2htok);		\
58f844a0eaSJeff Kirsher } while (0)
59f844a0eaSJeff Kirsher 
60f844a0eaSJeff Kirsher /*
61f844a0eaSJeff Kirsher  * Message opcodes: 0-127 to firmware, 128-255 to host
62f844a0eaSJeff Kirsher  */
63f844a0eaSJeff Kirsher #define BFI_I2H_OPCODE_BASE	128
64f844a0eaSJeff Kirsher #define BFA_I2HM(_x)			((_x) + BFI_I2H_OPCODE_BASE)
65f844a0eaSJeff Kirsher 
661aa8b471SBen Hutchings /****************************************************************************
67f844a0eaSJeff Kirsher  *
68f844a0eaSJeff Kirsher  * Scatter Gather Element and Page definition
69f844a0eaSJeff Kirsher  *
70f844a0eaSJeff Kirsher  ****************************************************************************
71f844a0eaSJeff Kirsher  */
72f844a0eaSJeff Kirsher 
731aa8b471SBen Hutchings /* DMA addresses */
74f844a0eaSJeff Kirsher union bfi_addr_u {
75f844a0eaSJeff Kirsher 	struct {
76f844a0eaSJeff Kirsher 		u32	addr_lo;
77f844a0eaSJeff Kirsher 		u32	addr_hi;
78f844a0eaSJeff Kirsher 	} a32;
79f844a0eaSJeff Kirsher };
80f844a0eaSJeff Kirsher 
811aa8b471SBen Hutchings /* Generic DMA addr-len pair. */
8272a9730bSKrishna Gudipati struct bfi_alen {
8372a9730bSKrishna Gudipati 	union bfi_addr_u	al_addr;	/* DMA addr of buffer	*/
8472a9730bSKrishna Gudipati 	u32			al_len;		/* length of buffer */
8572a9730bSKrishna Gudipati };
8672a9730bSKrishna Gudipati 
87f844a0eaSJeff Kirsher /*
88f844a0eaSJeff Kirsher  * Large Message structure - 128 Bytes size Msgs
89f844a0eaSJeff Kirsher  */
90f844a0eaSJeff Kirsher #define BFI_LMSG_SZ		128
91f844a0eaSJeff Kirsher #define BFI_LMSG_PL_WSZ	\
92f844a0eaSJeff Kirsher 			((BFI_LMSG_SZ - sizeof(struct bfi_mhdr)) / 4)
93f844a0eaSJeff Kirsher 
941aa8b471SBen Hutchings /* Mailbox message structure */
95f844a0eaSJeff Kirsher #define BFI_MBMSG_SZ		7
96f844a0eaSJeff Kirsher struct bfi_mbmsg {
97f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;
98f844a0eaSJeff Kirsher 	u32		pl[BFI_MBMSG_SZ];
99f844a0eaSJeff Kirsher };
100f844a0eaSJeff Kirsher 
1011aa8b471SBen Hutchings /* Supported PCI function class codes (personality) */
102078086f3SRasesh Mody enum bfi_pcifn_class {
103078086f3SRasesh Mody 	BFI_PCIFN_CLASS_FC	= 0x0c04,
104078086f3SRasesh Mody 	BFI_PCIFN_CLASS_ETH	= 0x0200,
105078086f3SRasesh Mody };
106078086f3SRasesh Mody 
1071aa8b471SBen Hutchings /* Message Classes */
108f844a0eaSJeff Kirsher enum bfi_mclass {
109f844a0eaSJeff Kirsher 	BFI_MC_IOC		= 1,	/*!< IO Controller (IOC)	    */
110f844a0eaSJeff Kirsher 	BFI_MC_DIAG		= 2,	/*!< Diagnostic Msgs		    */
111f844a0eaSJeff Kirsher 	BFI_MC_FLASH		= 3,	/*!< Flash message class	    */
112f844a0eaSJeff Kirsher 	BFI_MC_CEE		= 4,	/*!< CEE			    */
113f844a0eaSJeff Kirsher 	BFI_MC_FCPORT		= 5,	/*!< FC port			    */
114f844a0eaSJeff Kirsher 	BFI_MC_IOCFC		= 6,	/*!< FC - IO Controller (IOC)	    */
115f844a0eaSJeff Kirsher 	BFI_MC_LL		= 7,	/*!< Link Layer			    */
116f844a0eaSJeff Kirsher 	BFI_MC_UF		= 8,	/*!< Unsolicited frame receive	    */
117f844a0eaSJeff Kirsher 	BFI_MC_FCXP		= 9,	/*!< FC Transport		    */
118f844a0eaSJeff Kirsher 	BFI_MC_LPS		= 10,	/*!< lport fc login services	    */
119f844a0eaSJeff Kirsher 	BFI_MC_RPORT		= 11,	/*!< Remote port		    */
120f844a0eaSJeff Kirsher 	BFI_MC_ITNIM		= 12,	/*!< I-T nexus (Initiator mode)	    */
121f844a0eaSJeff Kirsher 	BFI_MC_IOIM_READ	= 13,	/*!< read IO (Initiator mode)	    */
122f844a0eaSJeff Kirsher 	BFI_MC_IOIM_WRITE	= 14,	/*!< write IO (Initiator mode)	    */
123f844a0eaSJeff Kirsher 	BFI_MC_IOIM_IO		= 15,	/*!< IO (Initiator mode)	    */
124f844a0eaSJeff Kirsher 	BFI_MC_IOIM		= 16,	/*!< IO (Initiator mode)	    */
125f844a0eaSJeff Kirsher 	BFI_MC_IOIM_IOCOM	= 17,	/*!< good IO completion		    */
126f844a0eaSJeff Kirsher 	BFI_MC_TSKIM		= 18,	/*!< Initiator Task management	    */
127f844a0eaSJeff Kirsher 	BFI_MC_SBOOT		= 19,	/*!< SAN boot services		    */
128f844a0eaSJeff Kirsher 	BFI_MC_IPFC		= 20,	/*!< IP over FC Msgs		    */
129f844a0eaSJeff Kirsher 	BFI_MC_PORT		= 21,	/*!< Physical port		    */
130f844a0eaSJeff Kirsher 	BFI_MC_SFP		= 22,	/*!< SFP module			    */
131f844a0eaSJeff Kirsher 	BFI_MC_MSGQ		= 23,	/*!< MSGQ			    */
132f844a0eaSJeff Kirsher 	BFI_MC_ENET		= 24,	/*!< ENET commands/responses	    */
133aafd5c2cSRasesh Mody 	BFI_MC_PHY		= 25,	/*!< External PHY message class	    */
134aafd5c2cSRasesh Mody 	BFI_MC_NBOOT		= 26,	/*!< Network Boot		    */
135aafd5c2cSRasesh Mody 	BFI_MC_TIO_READ		= 27,	/*!< read IO (Target mode)	    */
136aafd5c2cSRasesh Mody 	BFI_MC_TIO_WRITE	= 28,	/*!< write IO (Target mode)	    */
137aafd5c2cSRasesh Mody 	BFI_MC_TIO_DATA_XFERED	= 29,	/*!< ds transferred (target mode)   */
138aafd5c2cSRasesh Mody 	BFI_MC_TIO_IO		= 30,	/*!< IO (Target mode)		    */
139aafd5c2cSRasesh Mody 	BFI_MC_TIO		= 31,	/*!< IO (target mode)		    */
140aafd5c2cSRasesh Mody 	BFI_MC_MFG		= 32,	/*!< MFG/ASIC block commands	    */
141aafd5c2cSRasesh Mody 	BFI_MC_EDMA		= 33,	/*!< EDMA copy commands		    */
142aafd5c2cSRasesh Mody 	BFI_MC_MAX		= 34
143f844a0eaSJeff Kirsher };
144f844a0eaSJeff Kirsher 
145f844a0eaSJeff Kirsher #define BFI_IOC_MSGLEN_MAX	32	/* 32 bytes */
146f844a0eaSJeff Kirsher 
147af027a34SRasesh Mody #define BFI_FWBOOT_ENV_OS		0
148af027a34SRasesh Mody 
1491aa8b471SBen Hutchings /*----------------------------------------------------------------------
150f844a0eaSJeff Kirsher  *				IOC
151f844a0eaSJeff Kirsher  *----------------------------------------------------------------------
152f844a0eaSJeff Kirsher  */
153f844a0eaSJeff Kirsher 
1541aa8b471SBen Hutchings /* Different asic generations */
155078086f3SRasesh Mody enum bfi_asic_gen {
156078086f3SRasesh Mody 	BFI_ASIC_GEN_CB		= 1,
157078086f3SRasesh Mody 	BFI_ASIC_GEN_CT		= 2,
1581bf9fd70SRasesh Mody 	BFI_ASIC_GEN_CT2	= 3,
159078086f3SRasesh Mody };
160078086f3SRasesh Mody 
161078086f3SRasesh Mody enum bfi_asic_mode {
162078086f3SRasesh Mody 	BFI_ASIC_MODE_FC	= 1,	/* FC upto 8G speed		*/
163078086f3SRasesh Mody 	BFI_ASIC_MODE_FC16	= 2,	/* FC upto 16G speed		*/
164078086f3SRasesh Mody 	BFI_ASIC_MODE_ETH	= 3,	/* Ethernet ports		*/
165078086f3SRasesh Mody 	BFI_ASIC_MODE_COMBO	= 4,	/* FC 16G and Ethernet 10G port	*/
166078086f3SRasesh Mody };
167078086f3SRasesh Mody 
168f844a0eaSJeff Kirsher enum bfi_ioc_h2i_msgs {
169f844a0eaSJeff Kirsher 	BFI_IOC_H2I_ENABLE_REQ		= 1,
170f844a0eaSJeff Kirsher 	BFI_IOC_H2I_DISABLE_REQ		= 2,
171f844a0eaSJeff Kirsher 	BFI_IOC_H2I_GETATTR_REQ		= 3,
172f844a0eaSJeff Kirsher 	BFI_IOC_H2I_DBG_SYNC		= 4,
173f844a0eaSJeff Kirsher 	BFI_IOC_H2I_DBG_DUMP		= 5,
174f844a0eaSJeff Kirsher };
175f844a0eaSJeff Kirsher 
176f844a0eaSJeff Kirsher enum bfi_ioc_i2h_msgs {
177f844a0eaSJeff Kirsher 	BFI_IOC_I2H_ENABLE_REPLY	= BFA_I2HM(1),
178f844a0eaSJeff Kirsher 	BFI_IOC_I2H_DISABLE_REPLY	= BFA_I2HM(2),
179f844a0eaSJeff Kirsher 	BFI_IOC_I2H_GETATTR_REPLY	= BFA_I2HM(3),
180078086f3SRasesh Mody 	BFI_IOC_I2H_HBEAT		= BFA_I2HM(4),
181f844a0eaSJeff Kirsher };
182f844a0eaSJeff Kirsher 
1831aa8b471SBen Hutchings /* BFI_IOC_H2I_GETATTR_REQ message */
184f844a0eaSJeff Kirsher struct bfi_ioc_getattr_req {
185f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;
186f844a0eaSJeff Kirsher 	union bfi_addr_u	attr_addr;
187f844a0eaSJeff Kirsher };
188f844a0eaSJeff Kirsher 
189f844a0eaSJeff Kirsher struct bfi_ioc_attr {
190f844a0eaSJeff Kirsher 	u64		mfg_pwwn;	/*!< Mfg port wwn	   */
191f844a0eaSJeff Kirsher 	u64		mfg_nwwn;	/*!< Mfg node wwn	   */
192f844a0eaSJeff Kirsher 	mac_t		mfg_mac;	/*!< Mfg mac		   */
193078086f3SRasesh Mody 	u8		port_mode;	/* enum bfi_port_mode	   */
194078086f3SRasesh Mody 	u8		rsvd_a;
195f844a0eaSJeff Kirsher 	u64		pwwn;
196f844a0eaSJeff Kirsher 	u64		nwwn;
197f844a0eaSJeff Kirsher 	mac_t		mac;		/*!< PBC or Mfg mac	   */
198f844a0eaSJeff Kirsher 	u16	rsvd_b;
199f844a0eaSJeff Kirsher 	mac_t		fcoe_mac;
200f844a0eaSJeff Kirsher 	u16	rsvd_c;
201f844a0eaSJeff Kirsher 	char		brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
202f844a0eaSJeff Kirsher 	u8		pcie_gen;
203f844a0eaSJeff Kirsher 	u8		pcie_lanes_orig;
204f844a0eaSJeff Kirsher 	u8		pcie_lanes;
205f844a0eaSJeff Kirsher 	u8		rx_bbcredit;	/*!< receive buffer credits */
206f844a0eaSJeff Kirsher 	u32	adapter_prop;	/*!< adapter properties     */
207f844a0eaSJeff Kirsher 	u16	maxfrsize;	/*!< max receive frame size */
208f844a0eaSJeff Kirsher 	char		asic_rev;
209f844a0eaSJeff Kirsher 	u8		rsvd_d;
210f844a0eaSJeff Kirsher 	char		fw_version[BFA_VERSION_LEN];
211f844a0eaSJeff Kirsher 	char		optrom_version[BFA_VERSION_LEN];
212f844a0eaSJeff Kirsher 	struct bfa_mfg_vpd vpd;
213f844a0eaSJeff Kirsher 	u32	card_type;	/*!< card type			*/
214f844a0eaSJeff Kirsher };
215f844a0eaSJeff Kirsher 
2161aa8b471SBen Hutchings /* BFI_IOC_I2H_GETATTR_REPLY message */
217f844a0eaSJeff Kirsher struct bfi_ioc_getattr_reply {
218f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;	/*!< Common msg header		*/
219f844a0eaSJeff Kirsher 	u8			status;	/*!< cfg reply status		*/
220f844a0eaSJeff Kirsher 	u8			rsvd[3];
221f844a0eaSJeff Kirsher };
222f844a0eaSJeff Kirsher 
2231aa8b471SBen Hutchings /* Firmware memory page offsets */
224f844a0eaSJeff Kirsher #define BFI_IOC_SMEM_PG0_CB	(0x40)
225f844a0eaSJeff Kirsher #define BFI_IOC_SMEM_PG0_CT	(0x180)
226f844a0eaSJeff Kirsher 
2271aa8b471SBen Hutchings /* Firmware statistic offset */
228f844a0eaSJeff Kirsher #define BFI_IOC_FWSTATS_OFF	(0x6B40)
229f844a0eaSJeff Kirsher #define BFI_IOC_FWSTATS_SZ	(4096)
230f844a0eaSJeff Kirsher 
2311aa8b471SBen Hutchings /* Firmware trace offset */
232f844a0eaSJeff Kirsher #define BFI_IOC_TRC_OFF		(0x4b00)
233f844a0eaSJeff Kirsher #define BFI_IOC_TRC_ENTS	256
2347afc5dbdSKrishna Gudipati #define BFI_IOC_TRC_ENT_SZ	16
2357afc5dbdSKrishna Gudipati #define BFI_IOC_TRC_HDR_SZ	32
236f844a0eaSJeff Kirsher 
237f844a0eaSJeff Kirsher #define BFI_IOC_FW_SIGNATURE	(0xbfadbfad)
238c107ba17SRasesh Mody #define BFI_IOC_FW_INV_SIGN	(0xdeaddead)
239f844a0eaSJeff Kirsher #define BFI_IOC_MD5SUM_SZ	4
240c107ba17SRasesh Mody 
241c107ba17SRasesh Mody struct bfi_ioc_fwver {
242c107ba17SRasesh Mody #ifdef __BIG_ENDIAN
243c107ba17SRasesh Mody 	u8 patch;
244c107ba17SRasesh Mody 	u8 maint;
245c107ba17SRasesh Mody 	u8 minor;
246c107ba17SRasesh Mody 	u8 major;
247c107ba17SRasesh Mody 	u8 rsvd[2];
248c107ba17SRasesh Mody 	u8 build;
249c107ba17SRasesh Mody 	u8 phase;
250c107ba17SRasesh Mody #else
251c107ba17SRasesh Mody 	u8 major;
252c107ba17SRasesh Mody 	u8 minor;
253c107ba17SRasesh Mody 	u8 maint;
254c107ba17SRasesh Mody 	u8 patch;
255c107ba17SRasesh Mody 	u8 phase;
256c107ba17SRasesh Mody 	u8 build;
257c107ba17SRasesh Mody 	u8 rsvd[2];
258c107ba17SRasesh Mody #endif
259c107ba17SRasesh Mody };
260c107ba17SRasesh Mody 
261f844a0eaSJeff Kirsher struct bfi_ioc_image_hdr {
262f844a0eaSJeff Kirsher 	u32	signature;	/*!< constant signature */
263078086f3SRasesh Mody 	u8	asic_gen;	/*!< asic generation */
264078086f3SRasesh Mody 	u8	asic_mode;
265078086f3SRasesh Mody 	u8	port0_mode;	/*!< device mode for port 0 */
266078086f3SRasesh Mody 	u8	port1_mode;	/*!< device mode for port 1 */
267f844a0eaSJeff Kirsher 	u32	exec;		/*!< exec vector	*/
268078086f3SRasesh Mody 	u32	bootenv;	/*!< firmware boot env */
269c107ba17SRasesh Mody 	u32	rsvd_b[2];
270c107ba17SRasesh Mody 	struct bfi_ioc_fwver fwver;
271f844a0eaSJeff Kirsher 	u32	md5sum[BFI_IOC_MD5SUM_SZ];
272f844a0eaSJeff Kirsher };
273f844a0eaSJeff Kirsher 
274c107ba17SRasesh Mody enum bfi_ioc_img_ver_cmp {
275c107ba17SRasesh Mody 	BFI_IOC_IMG_VER_INCOMP,
276c107ba17SRasesh Mody 	BFI_IOC_IMG_VER_OLD,
277c107ba17SRasesh Mody 	BFI_IOC_IMG_VER_SAME,
278c107ba17SRasesh Mody 	BFI_IOC_IMG_VER_BETTER
279c107ba17SRasesh Mody };
280c107ba17SRasesh Mody 
281078086f3SRasesh Mody #define BFI_FWBOOT_DEVMODE_OFF		4
282078086f3SRasesh Mody #define BFI_FWBOOT_TYPE_OFF		8
283078086f3SRasesh Mody #define BFI_FWBOOT_ENV_OFF		12
284078086f3SRasesh Mody #define BFI_FWBOOT_DEVMODE(__asic_gen, __asic_mode, __p0_mode, __p1_mode) \
285078086f3SRasesh Mody 	(((u32)(__asic_gen)) << 24 |	\
286078086f3SRasesh Mody 	 ((u32)(__asic_mode)) << 16 |	\
287078086f3SRasesh Mody 	 ((u32)(__p0_mode)) << 8 |	\
288078086f3SRasesh Mody 	 ((u32)(__p1_mode)))
289078086f3SRasesh Mody 
290f844a0eaSJeff Kirsher enum bfi_fwboot_type {
291f844a0eaSJeff Kirsher 	BFI_FWBOOT_TYPE_NORMAL	= 0,
292f844a0eaSJeff Kirsher 	BFI_FWBOOT_TYPE_FLASH	= 1,
293f844a0eaSJeff Kirsher 	BFI_FWBOOT_TYPE_MEMTEST	= 2,
294f844a0eaSJeff Kirsher };
295f844a0eaSJeff Kirsher 
296078086f3SRasesh Mody enum bfi_port_mode {
297078086f3SRasesh Mody 	BFI_PORT_MODE_FC	= 1,
298078086f3SRasesh Mody 	BFI_PORT_MODE_ETH	= 2,
299078086f3SRasesh Mody };
300078086f3SRasesh Mody 
301f844a0eaSJeff Kirsher struct bfi_ioc_hbeat {
302f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;		/*!< common msg header		*/
303f844a0eaSJeff Kirsher 	u32	   hb_count;	/*!< current heart beat count	*/
304f844a0eaSJeff Kirsher };
305f844a0eaSJeff Kirsher 
3061aa8b471SBen Hutchings /* IOC hardware/firmware state */
307f844a0eaSJeff Kirsher enum bfi_ioc_state {
308f844a0eaSJeff Kirsher 	BFI_IOC_UNINIT		= 0,	/*!< not initialized		     */
309f844a0eaSJeff Kirsher 	BFI_IOC_INITING		= 1,	/*!< h/w is being initialized	     */
310f844a0eaSJeff Kirsher 	BFI_IOC_HWINIT		= 2,	/*!< h/w is initialized		     */
311f844a0eaSJeff Kirsher 	BFI_IOC_CFG		= 3,	/*!< IOC configuration in progress   */
312f844a0eaSJeff Kirsher 	BFI_IOC_OP		= 4,	/*!< IOC is operational		     */
313f844a0eaSJeff Kirsher 	BFI_IOC_DISABLING	= 5,	/*!< IOC is being disabled	     */
314f844a0eaSJeff Kirsher 	BFI_IOC_DISABLED	= 6,	/*!< IOC is disabled		     */
315f844a0eaSJeff Kirsher 	BFI_IOC_CFG_DISABLED	= 7,	/*!< IOC is being disabled;transient */
316f844a0eaSJeff Kirsher 	BFI_IOC_FAIL		= 8,	/*!< IOC heart-beat failure	     */
317f844a0eaSJeff Kirsher 	BFI_IOC_MEMTEST		= 9,	/*!< IOC is doing memtest	     */
318f844a0eaSJeff Kirsher };
319f844a0eaSJeff Kirsher 
320f844a0eaSJeff Kirsher #define BFI_IOC_ENDIAN_SIG  0x12345678
321f844a0eaSJeff Kirsher 
322f844a0eaSJeff Kirsher enum {
323f844a0eaSJeff Kirsher 	BFI_ADAPTER_TYPE_FC	= 0x01,		/*!< FC adapters	   */
324f844a0eaSJeff Kirsher 	BFI_ADAPTER_TYPE_MK	= 0x0f0000,	/*!< adapter type mask     */
325f844a0eaSJeff Kirsher 	BFI_ADAPTER_TYPE_SH	= 16,	        /*!< adapter type shift    */
326f844a0eaSJeff Kirsher 	BFI_ADAPTER_NPORTS_MK	= 0xff00,	/*!< number of ports mask  */
327f844a0eaSJeff Kirsher 	BFI_ADAPTER_NPORTS_SH	= 8,	        /*!< number of ports shift */
328f844a0eaSJeff Kirsher 	BFI_ADAPTER_SPEED_MK	= 0xff,		/*!< adapter speed mask    */
329f844a0eaSJeff Kirsher 	BFI_ADAPTER_SPEED_SH	= 0,	        /*!< adapter speed shift   */
330f844a0eaSJeff Kirsher 	BFI_ADAPTER_PROTO	= 0x100000,	/*!< prototype adapaters   */
331f844a0eaSJeff Kirsher 	BFI_ADAPTER_TTV		= 0x200000,	/*!< TTV debug capable     */
332f844a0eaSJeff Kirsher 	BFI_ADAPTER_UNSUPP	= 0x400000,	/*!< unknown adapter type  */
333f844a0eaSJeff Kirsher };
334f844a0eaSJeff Kirsher 
335f844a0eaSJeff Kirsher #define BFI_ADAPTER_GETP(__prop, __adap_prop)			\
336f844a0eaSJeff Kirsher 	(((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >>	\
337f844a0eaSJeff Kirsher 		BFI_ADAPTER_ ## __prop ## _SH)
338f844a0eaSJeff Kirsher #define BFI_ADAPTER_SETP(__prop, __val)				\
339f844a0eaSJeff Kirsher 	((__val) << BFI_ADAPTER_ ## __prop ## _SH)
340f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_PROTO(__adap_type)			\
341f844a0eaSJeff Kirsher 	((__adap_type) & BFI_ADAPTER_PROTO)
342f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_TTV(__adap_type)				\
343f844a0eaSJeff Kirsher 	((__adap_type) & BFI_ADAPTER_TTV)
344f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_UNSUPP(__adap_type)			\
345f844a0eaSJeff Kirsher 	((__adap_type) & BFI_ADAPTER_UNSUPP)
346f844a0eaSJeff Kirsher #define BFI_ADAPTER_IS_SPECIAL(__adap_type)			\
347f844a0eaSJeff Kirsher 	((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO |	\
348f844a0eaSJeff Kirsher 			BFI_ADAPTER_UNSUPP))
349f844a0eaSJeff Kirsher 
3501aa8b471SBen Hutchings /* BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages */
351f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_req {
352f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;
353078086f3SRasesh Mody 	u16			clscode;
354078086f3SRasesh Mody 	u16			rsvd;
355f844a0eaSJeff Kirsher 	u32		tv_sec;
356f844a0eaSJeff Kirsher };
357f844a0eaSJeff Kirsher 
3581aa8b471SBen Hutchings /* BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages */
359f844a0eaSJeff Kirsher struct bfi_ioc_ctrl_reply {
360f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;			/*!< Common msg header     */
361f844a0eaSJeff Kirsher 	u8			status;		/*!< enable/disable status */
362078086f3SRasesh Mody 	u8			port_mode;	/*!< enum bfa_mode */
363078086f3SRasesh Mody 	u8			cap_bm;		/*!< capability bit mask */
364078086f3SRasesh Mody 	u8			rsvd;
365f844a0eaSJeff Kirsher };
366f844a0eaSJeff Kirsher 
367f844a0eaSJeff Kirsher #define BFI_IOC_MSGSZ   8
3681aa8b471SBen Hutchings /* H2I Messages */
369f844a0eaSJeff Kirsher union bfi_ioc_h2i_msg_u {
370f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;
371f844a0eaSJeff Kirsher 	struct bfi_ioc_ctrl_req enable_req;
372f844a0eaSJeff Kirsher 	struct bfi_ioc_ctrl_req disable_req;
373f844a0eaSJeff Kirsher 	struct bfi_ioc_getattr_req getattr_req;
374f844a0eaSJeff Kirsher 	u32			mboxmsg[BFI_IOC_MSGSZ];
375f844a0eaSJeff Kirsher };
376f844a0eaSJeff Kirsher 
3771aa8b471SBen Hutchings /* I2H Messages */
378f844a0eaSJeff Kirsher union bfi_ioc_i2h_msg_u {
379f844a0eaSJeff Kirsher 	struct bfi_mhdr mh;
380078086f3SRasesh Mody 	struct bfi_ioc_ctrl_reply fw_event;
381f844a0eaSJeff Kirsher 	u32			mboxmsg[BFI_IOC_MSGSZ];
382f844a0eaSJeff Kirsher };
383f844a0eaSJeff Kirsher 
3841aa8b471SBen Hutchings /*----------------------------------------------------------------------
385af027a34SRasesh Mody  *				MSGQ
386af027a34SRasesh Mody  *----------------------------------------------------------------------
387af027a34SRasesh Mody  */
388af027a34SRasesh Mody 
389af027a34SRasesh Mody enum bfi_msgq_h2i_msgs {
390af027a34SRasesh Mody 	BFI_MSGQ_H2I_INIT_REQ	   = 1,
391af027a34SRasesh Mody 	BFI_MSGQ_H2I_DOORBELL_PI	= 2,
392af027a34SRasesh Mody 	BFI_MSGQ_H2I_DOORBELL_CI	= 3,
393af027a34SRasesh Mody 	BFI_MSGQ_H2I_CMDQ_COPY_RSP      = 4,
394af027a34SRasesh Mody };
395af027a34SRasesh Mody 
396af027a34SRasesh Mody enum bfi_msgq_i2h_msgs {
397af027a34SRasesh Mody 	BFI_MSGQ_I2H_INIT_RSP	   = BFA_I2HM(BFI_MSGQ_H2I_INIT_REQ),
398af027a34SRasesh Mody 	BFI_MSGQ_I2H_DOORBELL_PI	= BFA_I2HM(BFI_MSGQ_H2I_DOORBELL_PI),
399af027a34SRasesh Mody 	BFI_MSGQ_I2H_DOORBELL_CI	= BFA_I2HM(BFI_MSGQ_H2I_DOORBELL_CI),
400af027a34SRasesh Mody 	BFI_MSGQ_I2H_CMDQ_COPY_REQ      = BFA_I2HM(BFI_MSGQ_H2I_CMDQ_COPY_RSP),
401af027a34SRasesh Mody };
402af027a34SRasesh Mody 
403af027a34SRasesh Mody /* Messages(commands/responsed/AENS will have the following header */
404af027a34SRasesh Mody struct bfi_msgq_mhdr {
405af027a34SRasesh Mody 	u8	msg_class;
406af027a34SRasesh Mody 	u8	msg_id;
407af027a34SRasesh Mody 	u16	msg_token;
408af027a34SRasesh Mody 	u16	num_entries;
409af027a34SRasesh Mody 	u8	enet_id;
410af027a34SRasesh Mody 	u8	rsvd[1];
411af027a34SRasesh Mody };
412af027a34SRasesh Mody 
413af027a34SRasesh Mody #define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do {	\
414af027a34SRasesh Mody 	(_mh).msg_class	 = (_mc);	\
415af027a34SRasesh Mody 	(_mh).msg_id	    = (_mid);       \
416af027a34SRasesh Mody 	(_mh).msg_token	 = (_tok);       \
417af027a34SRasesh Mody 	(_mh).enet_id	   = (_enet_id);   \
418af027a34SRasesh Mody } while (0)
419af027a34SRasesh Mody 
420af027a34SRasesh Mody /*
421af027a34SRasesh Mody  * Mailbox  for messaging interface
422af027a34SRasesh Mody  */
423af027a34SRasesh Mody #define BFI_MSGQ_CMD_ENTRY_SIZE	 (64)    /* TBD */
424af027a34SRasesh Mody #define BFI_MSGQ_RSP_ENTRY_SIZE	 (64)    /* TBD */
425af027a34SRasesh Mody 
426af027a34SRasesh Mody #define bfi_msgq_num_cmd_entries(_size)				 \
427af027a34SRasesh Mody 	(((_size) + BFI_MSGQ_CMD_ENTRY_SIZE - 1) / BFI_MSGQ_CMD_ENTRY_SIZE)
428af027a34SRasesh Mody 
429af027a34SRasesh Mody struct bfi_msgq {
430af027a34SRasesh Mody 	union bfi_addr_u addr;
431af027a34SRasesh Mody 	u16 q_depth;     /* Total num of entries in the queue */
432af027a34SRasesh Mody 	u8 rsvd[2];
433af027a34SRasesh Mody };
434af027a34SRasesh Mody 
435af027a34SRasesh Mody /* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
436af027a34SRasesh Mody struct bfi_msgq_cfg_req {
437af027a34SRasesh Mody 	struct bfi_mhdr mh;
438af027a34SRasesh Mody 	struct bfi_msgq cmdq;
439af027a34SRasesh Mody 	struct bfi_msgq rspq;
440af027a34SRasesh Mody };
441af027a34SRasesh Mody 
442af027a34SRasesh Mody /* BFI_ENET_MSGQ_CFG_RSP */
443af027a34SRasesh Mody struct bfi_msgq_cfg_rsp {
444af027a34SRasesh Mody 	struct bfi_mhdr mh;
445af027a34SRasesh Mody 	u8 cmd_status;
446af027a34SRasesh Mody 	u8 rsvd[3];
447af027a34SRasesh Mody };
448af027a34SRasesh Mody 
449af027a34SRasesh Mody /* BFI_MSGQ_H2I_DOORBELL */
450af027a34SRasesh Mody struct bfi_msgq_h2i_db {
451af027a34SRasesh Mody 	struct bfi_mhdr mh;
452af027a34SRasesh Mody 	union {
453af027a34SRasesh Mody 		u16 cmdq_pi;
454af027a34SRasesh Mody 		u16 rspq_ci;
455af027a34SRasesh Mody 	} idx;
456af027a34SRasesh Mody };
457af027a34SRasesh Mody 
458af027a34SRasesh Mody /* BFI_MSGQ_I2H_DOORBELL */
459af027a34SRasesh Mody struct bfi_msgq_i2h_db {
460af027a34SRasesh Mody 	struct bfi_mhdr mh;
461af027a34SRasesh Mody 	union {
462af027a34SRasesh Mody 		u16 rspq_pi;
463af027a34SRasesh Mody 		u16 cmdq_ci;
464af027a34SRasesh Mody 	} idx;
465af027a34SRasesh Mody };
466af027a34SRasesh Mody 
467af027a34SRasesh Mody #define BFI_CMD_COPY_SZ 28
468af027a34SRasesh Mody 
469af027a34SRasesh Mody /* BFI_MSGQ_H2I_CMD_COPY_RSP */
470af027a34SRasesh Mody struct bfi_msgq_h2i_cmdq_copy_rsp {
471af027a34SRasesh Mody 	struct bfi_mhdr mh;
472af027a34SRasesh Mody 	u8	      data[BFI_CMD_COPY_SZ];
473af027a34SRasesh Mody };
474af027a34SRasesh Mody 
475af027a34SRasesh Mody /* BFI_MSGQ_I2H_CMD_COPY_REQ */
476af027a34SRasesh Mody struct bfi_msgq_i2h_cmdq_copy_req {
477af027a34SRasesh Mody 	struct bfi_mhdr mh;
478af027a34SRasesh Mody 	u16     offset;
479af027a34SRasesh Mody 	u16     len;
480af027a34SRasesh Mody };
481af027a34SRasesh Mody 
48272a9730bSKrishna Gudipati /*
48372a9730bSKrishna Gudipati  *      FLASH module specific
48472a9730bSKrishna Gudipati  */
48572a9730bSKrishna Gudipati enum bfi_flash_h2i_msgs {
48672a9730bSKrishna Gudipati 	BFI_FLASH_H2I_QUERY_REQ = 1,
48772a9730bSKrishna Gudipati 	BFI_FLASH_H2I_ERASE_REQ = 2,
48872a9730bSKrishna Gudipati 	BFI_FLASH_H2I_WRITE_REQ = 3,
48972a9730bSKrishna Gudipati 	BFI_FLASH_H2I_READ_REQ = 4,
49072a9730bSKrishna Gudipati 	BFI_FLASH_H2I_BOOT_VER_REQ = 5,
49172a9730bSKrishna Gudipati };
49272a9730bSKrishna Gudipati 
49372a9730bSKrishna Gudipati enum bfi_flash_i2h_msgs {
49472a9730bSKrishna Gudipati 	BFI_FLASH_I2H_QUERY_RSP = BFA_I2HM(1),
49572a9730bSKrishna Gudipati 	BFI_FLASH_I2H_ERASE_RSP = BFA_I2HM(2),
49672a9730bSKrishna Gudipati 	BFI_FLASH_I2H_WRITE_RSP = BFA_I2HM(3),
49772a9730bSKrishna Gudipati 	BFI_FLASH_I2H_READ_RSP = BFA_I2HM(4),
49872a9730bSKrishna Gudipati 	BFI_FLASH_I2H_BOOT_VER_RSP = BFA_I2HM(5),
49972a9730bSKrishna Gudipati 	BFI_FLASH_I2H_EVENT = BFA_I2HM(127),
50072a9730bSKrishna Gudipati };
50172a9730bSKrishna Gudipati 
50272a9730bSKrishna Gudipati /*
50372a9730bSKrishna Gudipati  * Flash query request
50472a9730bSKrishna Gudipati  */
50572a9730bSKrishna Gudipati struct bfi_flash_query_req {
50672a9730bSKrishna Gudipati 	struct bfi_mhdr mh;   /* Common msg header */
50772a9730bSKrishna Gudipati 	struct bfi_alen alen;
50872a9730bSKrishna Gudipati };
50972a9730bSKrishna Gudipati 
51072a9730bSKrishna Gudipati /*
51172a9730bSKrishna Gudipati  * Flash write request
51272a9730bSKrishna Gudipati  */
51372a9730bSKrishna Gudipati struct bfi_flash_write_req {
51472a9730bSKrishna Gudipati 	struct bfi_mhdr mh;	/* Common msg header */
51572a9730bSKrishna Gudipati 	struct bfi_alen alen;
51672a9730bSKrishna Gudipati 	u32	type;   /* partition type */
51772a9730bSKrishna Gudipati 	u8	instance; /* partition instance */
51872a9730bSKrishna Gudipati 	u8	last;
51972a9730bSKrishna Gudipati 	u8	rsv[2];
52072a9730bSKrishna Gudipati 	u32	offset;
52172a9730bSKrishna Gudipati 	u32	length;
52272a9730bSKrishna Gudipati };
52372a9730bSKrishna Gudipati 
52472a9730bSKrishna Gudipati /*
52572a9730bSKrishna Gudipati  * Flash read request
52672a9730bSKrishna Gudipati  */
52772a9730bSKrishna Gudipati struct bfi_flash_read_req {
52872a9730bSKrishna Gudipati 	struct bfi_mhdr mh;	/* Common msg header */
52972a9730bSKrishna Gudipati 	u32	type;		/* partition type */
53072a9730bSKrishna Gudipati 	u8	instance;	/* partition instance */
53172a9730bSKrishna Gudipati 	u8	rsv[3];
53272a9730bSKrishna Gudipati 	u32	offset;
53372a9730bSKrishna Gudipati 	u32	length;
53472a9730bSKrishna Gudipati 	struct bfi_alen alen;
53572a9730bSKrishna Gudipati };
53672a9730bSKrishna Gudipati 
53772a9730bSKrishna Gudipati /*
53872a9730bSKrishna Gudipati  * Flash query response
53972a9730bSKrishna Gudipati  */
54072a9730bSKrishna Gudipati struct bfi_flash_query_rsp {
54172a9730bSKrishna Gudipati 	struct bfi_mhdr mh;	/* Common msg header */
54272a9730bSKrishna Gudipati 	u32	status;
54372a9730bSKrishna Gudipati };
54472a9730bSKrishna Gudipati 
54572a9730bSKrishna Gudipati /*
54672a9730bSKrishna Gudipati  * Flash read response
54772a9730bSKrishna Gudipati  */
54872a9730bSKrishna Gudipati struct bfi_flash_read_rsp {
54972a9730bSKrishna Gudipati 	struct bfi_mhdr mh;	/* Common msg header */
55072a9730bSKrishna Gudipati 	u32	type;		/* partition type */
55172a9730bSKrishna Gudipati 	u8	instance;	/* partition instance */
55272a9730bSKrishna Gudipati 	u8	rsv[3];
55372a9730bSKrishna Gudipati 	u32	status;
55472a9730bSKrishna Gudipati 	u32	length;
55572a9730bSKrishna Gudipati };
55672a9730bSKrishna Gudipati 
55772a9730bSKrishna Gudipati /*
55872a9730bSKrishna Gudipati  * Flash write response
55972a9730bSKrishna Gudipati  */
56072a9730bSKrishna Gudipati struct bfi_flash_write_rsp {
56172a9730bSKrishna Gudipati 	struct bfi_mhdr mh;	/* Common msg header */
56272a9730bSKrishna Gudipati 	u32	type;		/* partition type */
56372a9730bSKrishna Gudipati 	u8	instance;	/* partition instance */
56472a9730bSKrishna Gudipati 	u8	rsv[3];
56572a9730bSKrishna Gudipati 	u32	status;
56672a9730bSKrishna Gudipati 	u32	length;
56772a9730bSKrishna Gudipati };
56872a9730bSKrishna Gudipati 
569f844a0eaSJeff Kirsher #pragma pack()
570f844a0eaSJeff Kirsher 
571f844a0eaSJeff Kirsher #endif /* __BFI_H__ */
572