1/*
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_MS_H__
19#define __BFI_MS_H__
20
21#include "bfi.h"
22#include "bfa_fc.h"
23#include "bfa_defs_svc.h"
24
25#pragma pack(1)
26
27enum bfi_iocfc_h2i_msgs {
28	BFI_IOCFC_H2I_CFG_REQ		= 1,
29	BFI_IOCFC_H2I_SET_INTR_REQ	= 2,
30	BFI_IOCFC_H2I_UPDATEQ_REQ	= 3,
31	BFI_IOCFC_H2I_FAA_QUERY_REQ	= 4,
32	BFI_IOCFC_H2I_ADDR_REQ		= 5,
33};
34
35enum bfi_iocfc_i2h_msgs {
36	BFI_IOCFC_I2H_CFG_REPLY		= BFA_I2HM(1),
37	BFI_IOCFC_I2H_UPDATEQ_RSP	= BFA_I2HM(3),
38	BFI_IOCFC_I2H_FAA_QUERY_RSP	= BFA_I2HM(4),
39	BFI_IOCFC_I2H_ADDR_MSG		= BFA_I2HM(5),
40};
41
42struct bfi_iocfc_cfg_s {
43	u8	num_cqs;	/*  Number of CQs to be used	*/
44	u8	 sense_buf_len;	/*  SCSI sense length	    */
45	u16	rsvd_1;
46	u32	endian_sig;	/*  endian signature of host     */
47	u8	rsvd_2;
48	u8	single_msix_vec;
49	u8	rsvd[2];
50	__be16	num_ioim_reqs;
51	__be16	num_fwtio_reqs;
52
53
54	/*
55	 * Request and response circular queue base addresses, size and
56	 * shadow index pointers.
57	 */
58	union bfi_addr_u  req_cq_ba[BFI_IOC_MAX_CQS];
59	union bfi_addr_u  req_shadow_ci[BFI_IOC_MAX_CQS];
60	__be16    req_cq_elems[BFI_IOC_MAX_CQS];
61	union bfi_addr_u  rsp_cq_ba[BFI_IOC_MAX_CQS];
62	union bfi_addr_u  rsp_shadow_pi[BFI_IOC_MAX_CQS];
63	__be16    rsp_cq_elems[BFI_IOC_MAX_CQS];
64
65	union bfi_addr_u  stats_addr;	/*  DMA-able address for stats	  */
66	union bfi_addr_u  cfgrsp_addr;	/*  config response dma address  */
67	union bfi_addr_u  ioim_snsbase[BFI_IOIM_SNSBUF_SEGS];
68					/*  IO sense buf base addr segments */
69	struct bfa_iocfc_intr_attr_s intr_attr; /*  IOC interrupt attributes */
70};
71
72/*
73 * Boot target wwn information for this port. This contains either the stored
74 * or discovered boot target port wwns for the port.
75 */
76struct bfi_iocfc_bootwwns {
77	wwn_t		wwn[BFA_BOOT_BOOTLUN_MAX];
78	u8		nwwns;
79	u8		rsvd[7];
80};
81
82/**
83 * Queue configuration response from firmware
84 */
85struct bfi_iocfc_qreg_s {
86	u32	cpe_q_ci_off[BFI_IOC_MAX_CQS];
87	u32	cpe_q_pi_off[BFI_IOC_MAX_CQS];
88	u32	cpe_qctl_off[BFI_IOC_MAX_CQS];
89	u32	rme_q_ci_off[BFI_IOC_MAX_CQS];
90	u32	rme_q_pi_off[BFI_IOC_MAX_CQS];
91	u32	rme_qctl_off[BFI_IOC_MAX_CQS];
92	u8	hw_qid[BFI_IOC_MAX_CQS];
93};
94
95struct bfi_iocfc_cfgrsp_s {
96	struct bfa_iocfc_fwcfg_s	fwcfg;
97	struct bfa_iocfc_intr_attr_s	intr_attr;
98	struct bfi_iocfc_bootwwns	bootwwns;
99	struct bfi_pbc_s		pbc_cfg;
100	struct bfi_iocfc_qreg_s		qreg;
101};
102
103/*
104 * BFI_IOCFC_H2I_CFG_REQ message
105 */
106struct bfi_iocfc_cfg_req_s {
107	struct bfi_mhdr_s      mh;
108	union bfi_addr_u      ioc_cfg_dma_addr;
109};
110
111
112/*
113 * BFI_IOCFC_I2H_CFG_REPLY message
114 */
115struct bfi_iocfc_cfg_reply_s {
116	struct bfi_mhdr_s  mh;		/*  Common msg header	  */
117	u8	 cfg_success;	/*  cfg reply status	   */
118	u8	 lpu_bm;		/*  LPUs assigned for this IOC */
119	u8	 rsvd[2];
120};
121
122
123/*
124 * BFI_IOCFC_H2I_SET_INTR_REQ message
125 */
126struct bfi_iocfc_set_intr_req_s {
127	struct bfi_mhdr_s mh;		/*  common msg header		*/
128	u8		coalesce;	/*  enable intr coalescing	*/
129	u8		rsvd[3];
130	__be16	delay;		/*  delay timer 0..1125us	*/
131	__be16	latency;	/*  latency timer 0..225us	*/
132};
133
134
135/*
136 * BFI_IOCFC_H2I_UPDATEQ_REQ message
137 */
138struct bfi_iocfc_updateq_req_s {
139	struct bfi_mhdr_s mh;		/*  common msg header		*/
140	u32 reqq_ba;		/*  reqq base addr		*/
141	u32 rspq_ba;		/*  rspq base addr		*/
142	u32 reqq_sci;		/*  reqq shadow ci		*/
143	u32 rspq_spi;		/*  rspq shadow pi		*/
144};
145
146
147/*
148 * BFI_IOCFC_I2H_UPDATEQ_RSP message
149 */
150struct bfi_iocfc_updateq_rsp_s {
151	struct bfi_mhdr_s mh;		/*  common msg header	*/
152	u8	status;			/*  updateq  status	*/
153	u8	rsvd[3];
154};
155
156
157/*
158 * H2I Messages
159 */
160union bfi_iocfc_h2i_msg_u {
161	struct bfi_mhdr_s		mh;
162	struct bfi_iocfc_cfg_req_s	cfg_req;
163	struct bfi_iocfc_updateq_req_s updateq_req;
164	u32 mboxmsg[BFI_IOC_MSGSZ];
165};
166
167
168/*
169 * I2H Messages
170 */
171union bfi_iocfc_i2h_msg_u {
172	struct bfi_mhdr_s		mh;
173	struct bfi_iocfc_cfg_reply_s	cfg_reply;
174	struct bfi_iocfc_updateq_rsp_s updateq_rsp;
175	u32 mboxmsg[BFI_IOC_MSGSZ];
176};
177
178/*
179 * BFI_IOCFC_H2I_FAA_ENABLE_REQ BFI_IOCFC_H2I_FAA_DISABLE_REQ message
180 */
181struct bfi_faa_en_dis_s {
182	struct bfi_mhdr_s mh;	/* common msg header    */
183};
184
185struct bfi_faa_addr_msg_s {
186	struct  bfi_mhdr_s mh;	/* common msg header	*/
187	u8	rsvd[4];
188	wwn_t	pwwn;		/* Fabric acquired PWWN	*/
189	wwn_t	nwwn;		/* Fabric acquired PWWN	*/
190};
191
192/*
193 * BFI_IOCFC_H2I_FAA_QUERY_REQ message
194 */
195struct bfi_faa_query_s {
196	struct bfi_mhdr_s mh;	/* common msg header    */
197	u8	faa_status;	/* FAA status           */
198	u8	addr_source;	/* PWWN source          */
199	u8	rsvd[2];
200	wwn_t	faa;		/* Fabric acquired PWWN	*/
201};
202
203/*
204 * BFI_IOCFC_I2H_FAA_ENABLE_RSP, BFI_IOCFC_I2H_FAA_DISABLE_RSP message
205 */
206struct bfi_faa_en_dis_rsp_s {
207	struct bfi_mhdr_s mh;	/* common msg header    */
208	u8	status;		/* updateq  status      */
209	u8	rsvd[3];
210};
211
212/*
213 * BFI_IOCFC_I2H_FAA_QUERY_RSP message
214 */
215#define bfi_faa_query_rsp_t struct bfi_faa_query_s
216
217enum bfi_fcport_h2i {
218	BFI_FCPORT_H2I_ENABLE_REQ		= (1),
219	BFI_FCPORT_H2I_DISABLE_REQ		= (2),
220	BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ	= (3),
221	BFI_FCPORT_H2I_STATS_GET_REQ		= (4),
222	BFI_FCPORT_H2I_STATS_CLEAR_REQ		= (5),
223};
224
225
226enum bfi_fcport_i2h {
227	BFI_FCPORT_I2H_ENABLE_RSP		= BFA_I2HM(1),
228	BFI_FCPORT_I2H_DISABLE_RSP		= BFA_I2HM(2),
229	BFI_FCPORT_I2H_SET_SVC_PARAMS_RSP	= BFA_I2HM(3),
230	BFI_FCPORT_I2H_STATS_GET_RSP		= BFA_I2HM(4),
231	BFI_FCPORT_I2H_STATS_CLEAR_RSP		= BFA_I2HM(5),
232	BFI_FCPORT_I2H_EVENT			= BFA_I2HM(6),
233	BFI_FCPORT_I2H_TRUNK_SCN		= BFA_I2HM(7),
234	BFI_FCPORT_I2H_ENABLE_AEN		= BFA_I2HM(8),
235	BFI_FCPORT_I2H_DISABLE_AEN		= BFA_I2HM(9),
236};
237
238
239/*
240 * Generic REQ type
241 */
242struct bfi_fcport_req_s {
243	struct bfi_mhdr_s  mh;		/*  msg header			    */
244	u32	   msgtag;	/*  msgtag for reply		    */
245};
246
247/*
248 * Generic RSP type
249 */
250struct bfi_fcport_rsp_s {
251	struct bfi_mhdr_s  mh;		/*  common msg header		    */
252	u8		   status;	/*  port enable status		    */
253	u8		   rsvd[3];
254	struct	bfa_port_cfg_s port_cfg;/* port configuration	*/
255	u32	msgtag;			/* msgtag for reply	*/
256};
257
258/*
259 * BFI_FCPORT_H2I_ENABLE_REQ
260 */
261struct bfi_fcport_enable_req_s {
262	struct bfi_mhdr_s  mh;		/*  msg header			    */
263	u32	   rsvd1;
264	wwn_t		   nwwn;	/*  node wwn of physical port	    */
265	wwn_t		   pwwn;	/*  port wwn of physical port	    */
266	struct bfa_port_cfg_s port_cfg; /*  port configuration	    */
267	union bfi_addr_u   stats_dma_addr; /*  DMA address for stats	    */
268	u32	   msgtag;	/*  msgtag for reply		    */
269	u8	use_flash_cfg;	/* get prot cfg from flash */
270	u8	rsvd2[3];
271};
272
273/*
274 * BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ
275 */
276struct bfi_fcport_set_svc_params_req_s {
277	struct bfi_mhdr_s  mh;		/*  msg header */
278	__be16	   tx_bbcredit;	/*  Tx credits */
279	u8	bb_scn;		/* BB_SC FC credit recovery */
280	u8	rsvd;
281};
282
283/*
284 * BFI_FCPORT_I2H_EVENT
285 */
286struct bfi_fcport_event_s {
287	struct bfi_mhdr_s	mh;	/*  common msg header */
288	struct bfa_port_link_s	link_state;
289};
290
291/*
292 * BFI_FCPORT_I2H_TRUNK_SCN
293 */
294struct bfi_fcport_trunk_link_s {
295	wwn_t			trunk_wwn;
296	u8			fctl;		/* bfa_trunk_link_fctl_t */
297	u8			state;		/* bfa_trunk_link_state_t */
298	u8			speed;		/* bfa_port_speed_t */
299	u8			rsvd;
300	__be32		deskew;
301};
302
303#define BFI_FCPORT_MAX_LINKS	2
304struct bfi_fcport_trunk_scn_s {
305	struct bfi_mhdr_s	mh;
306	u8			trunk_state;	/* bfa_trunk_state_t */
307	u8			trunk_speed;	/* bfa_port_speed_t */
308	u8			rsvd_a[2];
309	struct bfi_fcport_trunk_link_s tlink[BFI_FCPORT_MAX_LINKS];
310};
311
312/*
313 * fcport H2I message
314 */
315union bfi_fcport_h2i_msg_u {
316	struct bfi_mhdr_s			*mhdr;
317	struct bfi_fcport_enable_req_s		*penable;
318	struct bfi_fcport_req_s			*pdisable;
319	struct bfi_fcport_set_svc_params_req_s	*psetsvcparams;
320	struct bfi_fcport_req_s			*pstatsget;
321	struct bfi_fcport_req_s			*pstatsclear;
322};
323
324/*
325 * fcport I2H message
326 */
327union bfi_fcport_i2h_msg_u {
328	struct bfi_msg_s			*msg;
329	struct bfi_fcport_rsp_s			*penable_rsp;
330	struct bfi_fcport_rsp_s			*pdisable_rsp;
331	struct bfi_fcport_rsp_s			*psetsvcparams_rsp;
332	struct bfi_fcport_rsp_s			*pstatsget_rsp;
333	struct bfi_fcport_rsp_s			*pstatsclear_rsp;
334	struct bfi_fcport_event_s		*event;
335	struct bfi_fcport_trunk_scn_s		*trunk_scn;
336};
337
338enum bfi_fcxp_h2i {
339	BFI_FCXP_H2I_SEND_REQ = 1,
340};
341
342enum bfi_fcxp_i2h {
343	BFI_FCXP_I2H_SEND_RSP = BFA_I2HM(1),
344};
345
346#define BFA_FCXP_MAX_SGES	2
347
348/*
349 * FCXP send request structure
350 */
351struct bfi_fcxp_send_req_s {
352	struct bfi_mhdr_s  mh;		/*  Common msg header		    */
353	__be16	fcxp_tag;	/*  driver request tag		    */
354	__be16	max_frmsz;	/*  max send frame size	    */
355	__be16	vf_id;		/*  vsan tag if applicable	    */
356	u16	rport_fw_hndl;	/*  FW Handle for the remote port  */
357	u8	 class;		/*  FC class used for req/rsp	    */
358	u8	 rsp_timeout;	/*  timeout in secs, 0-no response */
359	u8	 cts;		/*  continue sequence		    */
360	u8	 lp_fwtag;	/*  lport tag			    */
361	struct fchs_s	fchs;	/*  request FC header structure    */
362	__be32	req_len;	/*  request payload length	    */
363	__be32	rsp_maxlen;	/*  max response length expected   */
364	struct bfi_alen_s req_alen;	/* request buffer	*/
365	struct bfi_alen_s rsp_alen;	/* response buffer	*/
366};
367
368/*
369 * FCXP send response structure
370 */
371struct bfi_fcxp_send_rsp_s {
372	struct bfi_mhdr_s  mh;		/*  Common msg header		    */
373	__be16	fcxp_tag;	/*  send request tag		    */
374	u8	 req_status;	/*  request status		    */
375	u8	 rsvd;
376	__be32	rsp_len;	/*  actual response length	    */
377	__be32	residue_len;	/*  residual response length	    */
378	struct fchs_s	fchs;	/*  response FC header structure   */
379};
380
381enum bfi_uf_h2i {
382	BFI_UF_H2I_BUF_POST = 1,
383};
384
385enum bfi_uf_i2h {
386	BFI_UF_I2H_FRM_RCVD = BFA_I2HM(1),
387};
388
389#define BFA_UF_MAX_SGES	2
390
391struct bfi_uf_buf_post_s {
392	struct bfi_mhdr_s  mh;		/*  Common msg header		*/
393	u16	buf_tag;	/*  buffer tag			*/
394	__be16	buf_len;	/*  total buffer length	*/
395	struct bfi_alen_s alen;	/* buffer address/len pair	*/
396};
397
398struct bfi_uf_frm_rcvd_s {
399	struct bfi_mhdr_s  mh;		/*  Common msg header		*/
400	u16	buf_tag;	/*  buffer tag			*/
401	u16	rsvd;
402	u16	frm_len;	/*  received frame length	*/
403	u16	xfr_len;	/*  tranferred length		*/
404};
405
406enum bfi_lps_h2i_msgs {
407	BFI_LPS_H2I_LOGIN_REQ	= 1,
408	BFI_LPS_H2I_LOGOUT_REQ	= 2,
409	BFI_LPS_H2I_N2N_PID_REQ = 3,
410};
411
412enum bfi_lps_i2h_msgs {
413	BFI_LPS_I2H_LOGIN_RSP	= BFA_I2HM(1),
414	BFI_LPS_I2H_LOGOUT_RSP	= BFA_I2HM(2),
415	BFI_LPS_I2H_CVL_EVENT	= BFA_I2HM(3),
416};
417
418struct bfi_lps_login_req_s {
419	struct bfi_mhdr_s  mh;		/*  common msg header		*/
420	u8		bfa_tag;
421	u8		alpa;
422	__be16		pdu_size;
423	wwn_t		pwwn;
424	wwn_t		nwwn;
425	u8		fdisc;
426	u8		auth_en;
427	u8		lps_role;
428	u8		bb_scn;
429};
430
431struct bfi_lps_login_rsp_s {
432	struct bfi_mhdr_s  mh;		/*  common msg header		*/
433	u8		fw_tag;
434	u8		status;
435	u8		lsrjt_rsn;
436	u8		lsrjt_expl;
437	wwn_t		port_name;
438	wwn_t		node_name;
439	__be16		bb_credit;
440	u8		f_port;
441	u8		npiv_en;
442	u32	lp_pid:24;
443	u32	auth_req:8;
444	mac_t		lp_mac;
445	mac_t		fcf_mac;
446	u8		ext_status;
447	u8		brcd_switch;	/*  attached peer is brcd switch */
448	u8		bb_scn;		/* atatched port's bb_scn */
449	u8		bfa_tag;
450};
451
452struct bfi_lps_logout_req_s {
453	struct bfi_mhdr_s  mh;		/*  common msg header		*/
454	u8		fw_tag;
455	u8		rsvd[3];
456	wwn_t		port_name;
457};
458
459struct bfi_lps_logout_rsp_s {
460	struct bfi_mhdr_s  mh;		/*  common msg header		*/
461	u8		bfa_tag;
462	u8		status;
463	u8		rsvd[2];
464};
465
466struct bfi_lps_cvl_event_s {
467	struct bfi_mhdr_s  mh;		/*  common msg header		*/
468	u8		bfa_tag;
469	u8		rsvd[3];
470};
471
472struct bfi_lps_n2n_pid_req_s {
473	struct bfi_mhdr_s	mh;	/*  common msg header		*/
474	u8	fw_tag;
475	u32	lp_pid:24;
476};
477
478union bfi_lps_h2i_msg_u {
479	struct bfi_mhdr_s		*msg;
480	struct bfi_lps_login_req_s	*login_req;
481	struct bfi_lps_logout_req_s	*logout_req;
482	struct bfi_lps_n2n_pid_req_s	*n2n_pid_req;
483};
484
485union bfi_lps_i2h_msg_u {
486	struct bfi_msg_s		*msg;
487	struct bfi_lps_login_rsp_s	*login_rsp;
488	struct bfi_lps_logout_rsp_s	*logout_rsp;
489	struct bfi_lps_cvl_event_s	*cvl_event;
490};
491
492enum bfi_rport_h2i_msgs {
493	BFI_RPORT_H2I_CREATE_REQ = 1,
494	BFI_RPORT_H2I_DELETE_REQ = 2,
495	BFI_RPORT_H2I_SET_SPEED_REQ  = 3,
496};
497
498enum bfi_rport_i2h_msgs {
499	BFI_RPORT_I2H_CREATE_RSP = BFA_I2HM(1),
500	BFI_RPORT_I2H_DELETE_RSP = BFA_I2HM(2),
501	BFI_RPORT_I2H_QOS_SCN    = BFA_I2HM(3),
502};
503
504struct bfi_rport_create_req_s {
505	struct bfi_mhdr_s  mh;		/*  common msg header		*/
506	u16	bfa_handle;	/*  host rport handle		*/
507	__be16	max_frmsz;	/*  max rcv pdu size		*/
508	u32	pid:24,	/*  remote port ID		*/
509		lp_fwtag:8;	/*  local port tag		*/
510	u32	local_pid:24,	/*  local port ID		*/
511		cisc:8;
512	u8	fc_class;	/*  supported FC classes	*/
513	u8	vf_en;		/*  virtual fabric enable	*/
514	u16	vf_id;		/*  virtual fabric ID		*/
515};
516
517struct bfi_rport_create_rsp_s {
518	struct bfi_mhdr_s  mh;		/*  common msg header		*/
519	u8		status;		/*  rport creation status	*/
520	u8		rsvd[3];
521	u16	bfa_handle;	/*  host rport handle		*/
522	u16	fw_handle;	/*  firmware rport handle	*/
523	struct bfa_rport_qos_attr_s qos_attr;  /* QoS Attributes */
524};
525
526struct bfa_rport_speed_req_s {
527	struct bfi_mhdr_s  mh;		/*  common msg header		*/
528	u16	fw_handle;	/*  firmware rport handle	*/
529	u8		speed;		/*  rport's speed via RPSC	*/
530	u8		rsvd;
531};
532
533struct bfi_rport_delete_req_s {
534	struct bfi_mhdr_s  mh;		/*  common msg header		*/
535	u16	fw_handle;	/*  firmware rport handle	*/
536	u16	rsvd;
537};
538
539struct bfi_rport_delete_rsp_s {
540	struct bfi_mhdr_s  mh;		/*  common msg header		*/
541	u16	bfa_handle;	/*  host rport handle		*/
542	u8		status;		/*  rport deletion status	*/
543	u8		rsvd;
544};
545
546struct bfi_rport_qos_scn_s {
547	struct bfi_mhdr_s  mh;		/*  common msg header		*/
548	u16	bfa_handle;	/*  host rport handle		*/
549	u16	rsvd;
550	struct bfa_rport_qos_attr_s old_qos_attr;  /* Old QoS Attributes */
551	struct bfa_rport_qos_attr_s new_qos_attr;  /* New QoS Attributes */
552};
553
554union bfi_rport_h2i_msg_u {
555	struct bfi_msg_s		*msg;
556	struct bfi_rport_create_req_s	*create_req;
557	struct bfi_rport_delete_req_s	*delete_req;
558	struct bfi_rport_speed_req_s	*speed_req;
559};
560
561union bfi_rport_i2h_msg_u {
562	struct bfi_msg_s		*msg;
563	struct bfi_rport_create_rsp_s	*create_rsp;
564	struct bfi_rport_delete_rsp_s	*delete_rsp;
565	struct bfi_rport_qos_scn_s	*qos_scn_evt;
566};
567
568/*
569 * Initiator mode I-T nexus interface defines.
570 */
571
572enum bfi_itn_h2i {
573	BFI_ITN_H2I_CREATE_REQ = 1,	/*  i-t nexus creation */
574	BFI_ITN_H2I_DELETE_REQ = 2,	/*  i-t nexus deletion */
575};
576
577enum bfi_itn_i2h {
578	BFI_ITN_I2H_CREATE_RSP = BFA_I2HM(1),
579	BFI_ITN_I2H_DELETE_RSP = BFA_I2HM(2),
580	BFI_ITN_I2H_SLER_EVENT = BFA_I2HM(3),
581};
582
583struct bfi_itn_create_req_s {
584	struct bfi_mhdr_s  mh;		/*  common msg header		 */
585	u16	fw_handle;	/*  f/w handle for itnim	 */
586	u8	class;		/*  FC class for IO		 */
587	u8	seq_rec;	/*  sequence recovery support	 */
588	u8	msg_no;		/*  seq id of the msg		 */
589	u8	role;
590};
591
592struct bfi_itn_create_rsp_s {
593	struct bfi_mhdr_s  mh;		/*  common msg header		 */
594	u16	bfa_handle;	/*  bfa handle for itnim	 */
595	u8	status;		/*  fcp request status		 */
596	u8	seq_id;		/*  seq id of the msg		 */
597};
598
599struct bfi_itn_delete_req_s {
600	struct bfi_mhdr_s  mh;		/*  common msg header		 */
601	u16	fw_handle;	/*  f/w itnim handle		 */
602	u8	seq_id;		/*  seq id of the msg		 */
603	u8	rsvd;
604};
605
606struct bfi_itn_delete_rsp_s {
607	struct bfi_mhdr_s  mh;		/*  common msg header		 */
608	u16	bfa_handle;	/*  bfa handle for itnim	 */
609	u8	status;		/*  fcp request status		 */
610	u8	seq_id;		/*  seq id of the msg		 */
611};
612
613struct bfi_itn_sler_event_s {
614	struct bfi_mhdr_s  mh;		/*  common msg header		 */
615	u16	bfa_handle;	/*  bfa handle for itnim	 */
616	u16	rsvd;
617};
618
619union bfi_itn_h2i_msg_u {
620	struct bfi_itn_create_req_s *create_req;
621	struct bfi_itn_delete_req_s *delete_req;
622	struct bfi_msg_s	*msg;
623};
624
625union bfi_itn_i2h_msg_u {
626	struct bfi_itn_create_rsp_s *create_rsp;
627	struct bfi_itn_delete_rsp_s *delete_rsp;
628	struct bfi_itn_sler_event_s *sler_event;
629	struct bfi_msg_s	*msg;
630};
631
632/*
633 * Initiator mode IO interface defines.
634 */
635
636enum bfi_ioim_h2i {
637	BFI_IOIM_H2I_IOABORT_REQ = 1,	/*  IO abort request	 */
638	BFI_IOIM_H2I_IOCLEANUP_REQ = 2,	/*  IO cleanup request	 */
639};
640
641enum bfi_ioim_i2h {
642	BFI_IOIM_I2H_IO_RSP = BFA_I2HM(1),	/*  non-fp IO response	 */
643	BFI_IOIM_I2H_IOABORT_RSP = BFA_I2HM(2),	/*  ABORT rsp	 */
644};
645
646/*
647 * IO command DIF info
648 */
649struct bfi_ioim_dif_s {
650	u32	dif_info[4];
651};
652
653/*
654 * FCP IO messages overview
655 *
656 * @note
657 * - Max CDB length supported is 64 bytes.
658 * - SCSI Linked commands and SCSI bi-directional Commands not
659 *	supported.
660 *
661 */
662struct bfi_ioim_req_s {
663	struct bfi_mhdr_s  mh;		/*  Common msg header		 */
664	__be16	io_tag;		/*  I/O tag			 */
665	u16	rport_hdl;	/*  itnim/rport firmware handle */
666	struct fcp_cmnd_s	cmnd;	/*  IO request info	*/
667
668	/*
669	 * SG elements array within the IO request must be double word
670	 * aligned. This aligment is required to optimize SGM setup for the IO.
671	 */
672	struct bfi_sge_s	sges[BFI_SGE_INLINE_MAX];
673	u8	io_timeout;
674	u8	dif_en;
675	u8	rsvd_a[2];
676	struct bfi_ioim_dif_s  dif;
677};
678
679/*
680 *	This table shows various IO status codes from firmware and their
681 *	meaning. Host driver can use these status codes to further process
682 *	IO completions.
683 *
684 *	BFI_IOIM_STS_OK		: IO completed with error free SCSI &
685 *					transport status.
686 *					 io-tag can be reused.
687 *
688 *	BFA_IOIM_STS_SCSI_ERR		: IO completed with scsi error.
689 *	- io-tag can be reused.
690 *
691 *	BFI_IOIM_STS_HOST_ABORTED	: IO was aborted successfully due to
692 *						host request.
693 *					- io-tag cannot be reused yet.
694 *
695 *	BFI_IOIM_STS_ABORTED		: IO was aborted successfully
696 *						internally by f/w.
697 *					- io-tag cannot be reused yet.
698 *
699 *	BFI_IOIM_STS_TIMEDOUT	: IO timedout and ABTS/RRQ is happening
700 *					in the firmware and
701 *					- io-tag cannot be reused yet.
702 *
703 *	BFI_IOIM_STS_SQER_NEEDED	: Firmware could not recover the IO
704 *					  with sequence level error
705 *	logic and hence host needs to retry
706 *					  this IO with a different IO tag
707 *					- io-tag cannot be used yet.
708 *
709 *	BFI_IOIM_STS_NEXUS_ABORT	: Second Level Error Recovery from host
710 *					  is required because 2 consecutive ABTS
711 *					  timedout and host needs logout and
712 *					  re-login with the target
713 *					- io-tag cannot be used yet.
714 *
715 *	BFI_IOIM_STS_UNDERRUN	: IO completed with SCSI status good,
716 *					  but the data tranferred is less than
717 *					  the fcp data length in the command.
718 *					  ex. SCSI INQUIRY where transferred
719 *					  data length and residue count in FCP
720 *					  response accounts for total fcp-dl
721 *					  - io-tag can be reused.
722 *
723 *	BFI_IOIM_STS_OVERRUN	: IO completed with SCSI status good,
724 *					  but the data transerred is more than
725 *					  fcp data length in the command. ex.
726 *					  TAPE IOs where blocks can of unequal
727 *					  lengths.
728 *					- io-tag can be reused.
729 *
730 *	BFI_IOIM_STS_RES_FREE	: Firmware has completed using io-tag
731 *					  during abort process
732 *					- io-tag can be reused.
733 *
734 *	BFI_IOIM_STS_PROTO_ERR	: Firmware detected a protocol error.
735 *					  ex target sent more data than
736 *					  requested, or there was data frame
737 *					  loss and other reasons
738 *					- io-tag cannot be used yet.
739 *
740 *	BFI_IOIM_STS_DIF_ERR	: Firwmare detected DIF error. ex: DIF
741 *					CRC err or Ref Tag err or App tag err.
742 *					- io-tag can be reused.
743 *
744 *	BFA_IOIM_STS_TSK_MGT_ABORT	: IO was aborted because of Task
745 *					  Management command from the host
746 *					  - io-tag can be reused.
747 *
748 *	BFI_IOIM_STS_UTAG		: Firmware does not know about this
749 *					  io_tag.
750 *					- io-tag can be reused.
751 */
752enum bfi_ioim_status {
753	BFI_IOIM_STS_OK = 0,
754	BFI_IOIM_STS_HOST_ABORTED = 1,
755	BFI_IOIM_STS_ABORTED = 2,
756	BFI_IOIM_STS_TIMEDOUT = 3,
757	BFI_IOIM_STS_RES_FREE = 4,
758	BFI_IOIM_STS_SQER_NEEDED = 5,
759	BFI_IOIM_STS_PROTO_ERR = 6,
760	BFI_IOIM_STS_UTAG = 7,
761	BFI_IOIM_STS_PATHTOV = 8,
762};
763
764/*
765 * I/O response message
766 */
767struct bfi_ioim_rsp_s {
768	struct bfi_mhdr_s	mh;	/*  common msg header		*/
769	__be16	io_tag;		/*  completed IO tag		 */
770	u16	bfa_rport_hndl;	/*  releated rport handle	 */
771	u8	io_status;	/*  IO completion status	 */
772	u8	reuse_io_tag;	/*  IO tag can be reused	*/
773	u16	abort_tag;	/*  host abort request tag	*/
774	u8		scsi_status;	/*  scsi status from target	 */
775	u8		sns_len;	/*  scsi sense length		 */
776	u8		resid_flags;	/*  IO residue flags		 */
777	u8		rsvd_a;
778	__be32	residue;	/*  IO residual length in bytes */
779	u32	rsvd_b[3];
780};
781
782struct bfi_ioim_abort_req_s {
783	struct bfi_mhdr_s  mh;	/*  Common msg header  */
784	__be16	io_tag;	/*  I/O tag	*/
785	u16	abort_tag;	/*  unique request tag */
786};
787
788/*
789 * Initiator mode task management command interface defines.
790 */
791
792enum bfi_tskim_h2i {
793	BFI_TSKIM_H2I_TM_REQ	= 1, /*  task-mgmt command	*/
794	BFI_TSKIM_H2I_ABORT_REQ = 2, /*  task-mgmt command	*/
795};
796
797enum bfi_tskim_i2h {
798	BFI_TSKIM_I2H_TM_RSP = BFA_I2HM(1),
799};
800
801struct bfi_tskim_req_s {
802	struct bfi_mhdr_s  mh;	/*  Common msg header	*/
803	__be16	tsk_tag;	/*  task management tag	*/
804	u16	itn_fhdl;	/*  itn firmware handle	*/
805	struct 	scsi_lun lun;	/*  LU number	*/
806	u8	tm_flags;	/*  see enum fcp_tm_cmnd	*/
807	u8	t_secs;	/*  Timeout value in seconds	*/
808	u8	rsvd[2];
809};
810
811struct bfi_tskim_abortreq_s {
812	struct bfi_mhdr_s  mh;	/*  Common msg header	*/
813	__be16	tsk_tag;	/*  task management tag	*/
814	u16	rsvd;
815};
816
817enum bfi_tskim_status {
818	/*
819	 * Following are FCP-4 spec defined status codes,
820	 * **DO NOT CHANGE THEM **
821	 */
822	BFI_TSKIM_STS_OK	= 0,
823	BFI_TSKIM_STS_NOT_SUPP = 4,
824	BFI_TSKIM_STS_FAILED	= 5,
825
826	/*
827	 * Defined by BFA
828	 */
829	BFI_TSKIM_STS_TIMEOUT  = 10,	/*  TM request timedout	*/
830	BFI_TSKIM_STS_ABORTED  = 11,	/*  Aborted on host request */
831};
832
833struct bfi_tskim_rsp_s {
834	struct bfi_mhdr_s  mh;		/*  Common msg header		 */
835	__be16	tsk_tag;	/*  task mgmt cmnd tag		 */
836	u8	tsk_status;	/*  @ref bfi_tskim_status */
837	u8	rsvd;
838};
839
840#pragma pack()
841
842/*
843 * Crossbow PCI MSI-X vector defines
844 */
845enum {
846	BFI_MSIX_CPE_QMIN_CB = 0,
847	BFI_MSIX_CPE_QMAX_CB = 7,
848	BFI_MSIX_RME_QMIN_CB = 8,
849	BFI_MSIX_RME_QMAX_CB = 15,
850	BFI_MSIX_CB_MAX = 22,
851};
852
853/*
854 * Catapult FC PCI MSI-X vector defines
855 */
856enum {
857	BFI_MSIX_LPU_ERR_CT = 0,
858	BFI_MSIX_CPE_QMIN_CT = 1,
859	BFI_MSIX_CPE_QMAX_CT = 4,
860	BFI_MSIX_RME_QMIN_CT = 5,
861	BFI_MSIX_RME_QMAX_CT = 8,
862	BFI_MSIX_CT_MAX = 9,
863};
864
865#endif /* __BFI_MS_H__ */
866