2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
18 #ifndef __BFI_FCPIM_H__
19 #define __BFI_FCPIM_H__
22 #include <protocol/fcp.h>
27 * Initiator mode I-T nexus interface defines.
31 BFI_ITNIM_H2I_CREATE_REQ
= 1, /* i-t nexus creation */
32 BFI_ITNIM_H2I_DELETE_REQ
= 2, /* i-t nexus deletion */
36 BFI_ITNIM_I2H_CREATE_RSP
= BFA_I2HM(1),
37 BFI_ITNIM_I2H_DELETE_RSP
= BFA_I2HM(2),
38 BFI_ITNIM_I2H_SLER_EVENT
= BFA_I2HM(3),
41 struct bfi_itnim_create_req_s
{
42 struct bfi_mhdr_s mh
; /* common msg header */
43 u16 fw_handle
; /* f/w handle for itnim */
44 u8
class; /* FC class for IO */
45 u8 seq_rec
; /* sequence recovery support */
46 u8 msg_no
; /* seq id of the msg */
49 struct bfi_itnim_create_rsp_s
{
50 struct bfi_mhdr_s mh
; /* common msg header */
51 u16 bfa_handle
; /* bfa handle for itnim */
52 u8 status
; /* fcp request status */
53 u8 seq_id
; /* seq id of the msg */
56 struct bfi_itnim_delete_req_s
{
57 struct bfi_mhdr_s mh
; /* common msg header */
58 u16 fw_handle
; /* f/w itnim handle */
59 u8 seq_id
; /* seq id of the msg */
63 struct bfi_itnim_delete_rsp_s
{
64 struct bfi_mhdr_s mh
; /* common msg header */
65 u16 bfa_handle
; /* bfa handle for itnim */
66 u8 status
; /* fcp request status */
67 u8 seq_id
; /* seq id of the msg */
70 struct bfi_itnim_sler_event_s
{
71 struct bfi_mhdr_s mh
; /* common msg header */
72 u16 bfa_handle
; /* bfa handle for itnim */
76 union bfi_itnim_h2i_msg_u
{
77 struct bfi_itnim_create_req_s
*create_req
;
78 struct bfi_itnim_delete_req_s
*delete_req
;
79 struct bfi_msg_s
*msg
;
82 union bfi_itnim_i2h_msg_u
{
83 struct bfi_itnim_create_rsp_s
*create_rsp
;
84 struct bfi_itnim_delete_rsp_s
*delete_rsp
;
85 struct bfi_itnim_sler_event_s
*sler_event
;
86 struct bfi_msg_s
*msg
;
90 * Initiator mode IO interface defines.
94 BFI_IOIM_H2I_IOABORT_REQ
= 1, /* IO abort request */
95 BFI_IOIM_H2I_IOCLEANUP_REQ
= 2, /* IO cleanup request */
99 BFI_IOIM_I2H_IO_RSP
= BFA_I2HM(1), /* non-fp IO response */
100 BFI_IOIM_I2H_IOABORT_RSP
= BFA_I2HM(2),/* ABORT rsp */
104 * IO command DIF info
106 struct bfi_ioim_dif_s
{
111 * FCP IO messages overview
114 * - Max CDB length supported is 64 bytes.
115 * - SCSI Linked commands and SCSI bi-directional Commands not
119 struct bfi_ioim_req_s
{
120 struct bfi_mhdr_s mh
; /* Common msg header */
121 u16 io_tag
; /* I/O tag */
122 u16 rport_hdl
; /* itnim/rport firmware handle */
123 struct fcp_cmnd_s cmnd
; /* IO request info */
126 * SG elements array within the IO request must be double word
127 * aligned. This aligment is required to optimize SGM setup for the IO.
129 struct bfi_sge_s sges
[BFI_SGE_INLINE_MAX
];
133 struct bfi_ioim_dif_s dif
;
137 * This table shows various IO status codes from firmware and their
138 * meaning. Host driver can use these status codes to further process
141 * BFI_IOIM_STS_OK : IO completed with error free SCSI &
143 * - io-tag can be reused.
145 * BFA_IOIM_STS_SCSI_ERR : IO completed with scsi error.
146 * - io-tag can be reused.
148 * BFI_IOIM_STS_HOST_ABORTED : IO was aborted successfully due to
150 * - io-tag cannot be reused yet.
152 * BFI_IOIM_STS_ABORTED : IO was aborted successfully
154 * - io-tag cannot be reused yet.
156 * BFI_IOIM_STS_TIMEDOUT : IO timedout and ABTS/RRQ is happening
157 * in the firmware and
158 * - io-tag cannot be reused yet.
160 * BFI_IOIM_STS_SQER_NEEDED : Firmware could not recover the IO
161 * with sequence level error
162 * logic and hence host needs to retry
163 * this IO with a different IO tag
164 * - io-tag cannot be used yet.
166 * BFI_IOIM_STS_NEXUS_ABORT : Second Level Error Recovery from host
167 * is required because 2 consecutive ABTS
168 * timedout and host needs logout and
169 * re-login with the target
170 * - io-tag cannot be used yet.
172 * BFI_IOIM_STS_UNDERRUN : IO completed with SCSI status good,
173 * but the data tranferred is less than
174 * the fcp data length in the command.
175 * ex. SCSI INQUIRY where transferred
176 * data length and residue count in FCP
177 * response accounts for total fcp-dl
178 * - io-tag can be reused.
180 * BFI_IOIM_STS_OVERRUN : IO completed with SCSI status good,
181 * but the data transerred is more than
182 * fcp data length in the command. ex.
183 * TAPE IOs where blocks can of unequal
185 * - io-tag can be reused.
187 * BFI_IOIM_STS_RES_FREE : Firmware has completed using io-tag
188 * during abort process
189 * - io-tag can be reused.
191 * BFI_IOIM_STS_PROTO_ERR : Firmware detected a protocol error.
192 * ex target sent more data than
193 * requested, or there was data frame
194 * loss and other reasons
195 * - io-tag cannot be used yet.
197 * BFI_IOIM_STS_DIF_ERR : Firwmare detected DIF error. ex: DIF
198 * CRC err or Ref Tag err or App tag err.
199 * - io-tag can be reused.
201 * BFA_IOIM_STS_TSK_MGT_ABORT : IO was aborted because of Task
202 * Management command from the host
203 * - io-tag can be reused.
205 * BFI_IOIM_STS_UTAG : Firmware does not know about this
207 * - io-tag can be reused.
209 enum bfi_ioim_status
{
211 BFI_IOIM_STS_HOST_ABORTED
= 1,
212 BFI_IOIM_STS_ABORTED
= 2,
213 BFI_IOIM_STS_TIMEDOUT
= 3,
214 BFI_IOIM_STS_RES_FREE
= 4,
215 BFI_IOIM_STS_SQER_NEEDED
= 5,
216 BFI_IOIM_STS_PROTO_ERR
= 6,
217 BFI_IOIM_STS_UTAG
= 7,
218 BFI_IOIM_STS_PATHTOV
= 8,
221 #define BFI_IOIM_SNSLEN (256)
223 * I/O response message
225 struct bfi_ioim_rsp_s
{
226 struct bfi_mhdr_s mh
; /* common msg header */
227 u16 io_tag
; /* completed IO tag */
228 u16 bfa_rport_hndl
; /* releated rport handle */
229 u8 io_status
; /* IO completion status */
230 u8 reuse_io_tag
; /* IO tag can be reused */
231 u16 abort_tag
; /* host abort request tag */
232 u8 scsi_status
; /* scsi status from target */
233 u8 sns_len
; /* scsi sense length */
234 u8 resid_flags
; /* IO residue flags */
236 u32 residue
; /* IO residual length in bytes */
240 struct bfi_ioim_abort_req_s
{
241 struct bfi_mhdr_s mh
; /* Common msg header */
242 u16 io_tag
; /* I/O tag */
243 u16 abort_tag
; /* unique request tag */
247 * Initiator mode task management command interface defines.
251 BFI_TSKIM_H2I_TM_REQ
= 1, /* task-mgmt command */
252 BFI_TSKIM_H2I_ABORT_REQ
= 2, /* task-mgmt command */
256 BFI_TSKIM_I2H_TM_RSP
= BFA_I2HM(1),
259 struct bfi_tskim_req_s
{
260 struct bfi_mhdr_s mh
; /* Common msg header */
261 u16 tsk_tag
; /* task management tag */
262 u16 itn_fhdl
; /* itn firmware handle */
263 lun_t lun
; /* LU number */
264 u8 tm_flags
; /* see fcp_tm_cmnd_t */
265 u8 t_secs
; /* Timeout value in seconds */
269 struct bfi_tskim_abortreq_s
{
270 struct bfi_mhdr_s mh
; /* Common msg header */
271 u16 tsk_tag
; /* task management tag */
275 enum bfi_tskim_status
{
277 * Following are FCP-4 spec defined status codes,
278 * **DO NOT CHANGE THEM **
280 BFI_TSKIM_STS_OK
= 0,
281 BFI_TSKIM_STS_NOT_SUPP
= 4,
282 BFI_TSKIM_STS_FAILED
= 5,
287 BFI_TSKIM_STS_TIMEOUT
= 10, /* TM request timedout */
288 BFI_TSKIM_STS_ABORTED
= 11, /* Aborted on host request */
291 struct bfi_tskim_rsp_s
{
292 struct bfi_mhdr_s mh
; /* Common msg header */
293 u16 tsk_tag
; /* task mgmt cmnd tag */
294 u8 tsk_status
; /* @ref bfi_tskim_status */
300 #endif /* __BFI_FCPIM_H__ */