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 __FCPPROTO_H__
19 #define __FCPPROTO_H__
21 #include <linux/bitops.h>
22 #include <protocol/scsi.h>
27 FCP_RJT
= 0x01000000, /* SRR reject */
28 FCP_SRR_ACCEPT
= 0x02000000, /* SRR accept */
29 FCP_SRR
= 0x14000000, /* Sequence Retransmission Request */
37 u32 ox_id
:16; /* ox-id */
38 u32 rx_id
:16; /* rx-id */
39 u32 ro
; /* relative offset */
40 u32 r_ctl
:8; /* R_CTL for I.U. */
46 * FCP_CMND definitions
48 #define FCP_CMND_CDB_LEN 16
49 #define FCP_CMND_LUN_LEN 8
52 lun_t lun
; /* 64-bit LU number */
53 u8 crn
; /* command reference number */
56 priority
:4, /* FCP-3: SAM-3 priority */
57 taskattr
:3; /* scsi task attribute */
59 u8 taskattr
:3, /* scsi task attribute */
60 priority
:4, /* FCP-3: SAM-3 priority */
63 u8 tm_flags
; /* task management flags */
65 u8 addl_cdb_len
:6, /* additional CDB length words */
66 iodir
:2; /* read/write FCP_DATA IUs */
68 u8 iodir
:2, /* read/write FCP_DATA IUs */
69 addl_cdb_len
:6; /* additional CDB length */
71 struct scsi_cdb_s cdb
;
74 * !!! additional cdb bytes follows here!!!
76 u32 fcp_dl
; /* bytes to be transferred */
79 #define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
80 #define fcp_cmnd_fcpdl(_cmnd) ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
83 * fcp_cmnd_t.iodir field values
93 * Task attribute field
96 FCP_TASK_ATTR_SIMPLE
= 0,
97 FCP_TASK_ATTR_HOQ
= 1,
98 FCP_TASK_ATTR_ORDERED
= 2,
99 FCP_TASK_ATTR_ACA
= 4,
100 FCP_TASK_ATTR_UNTAGGED
= 5, /* obsolete in FCP-3 */
104 * Task management flags field - only one bit shall be set
107 FCP_TM_ABORT_TASK_SET
= BIT(1),
108 FCP_TM_CLEAR_TASK_SET
= BIT(2),
109 FCP_TM_LUN_RESET
= BIT(4),
110 FCP_TM_TARGET_RESET
= BIT(5), /* obsolete in FCP-3 */
111 FCP_TM_CLEAR_ACA
= BIT(6),
115 * FCP_XFER_RDY IU defines
117 struct fcp_xfer_rdy_s
{
124 * FCP_RSP residue flags
127 FCP_NO_RESIDUE
= 0, /* no residue */
128 FCP_RESID_OVER
= 1, /* more data left that was not sent */
129 FCP_RESID_UNDER
= 2, /* less data than requested */
133 FCP_RSPINFO_GOOD
= 0,
134 FCP_RSPINFO_DATALEN_MISMATCH
= 1,
135 FCP_RSPINFO_CMND_INVALID
= 2,
136 FCP_RSPINFO_ROLEN_MISMATCH
= 3,
137 FCP_RSPINFO_TM_NOT_SUPP
= 4,
138 FCP_RSPINFO_TM_FAILED
= 5,
141 struct fcp_rspinfo_s
{
143 u32 rsp_code
:8; /* response code (as above) */
148 u32 reserved
[2]; /* 2 words reserved */
152 u8 fcp_conf_req
:1; /* FCP_CONF is requested */
153 u8 resid_flags
:2; /* underflow/overflow */
154 u8 sns_len_valid
:1;/* sense len is valid */
155 u8 rsp_len_valid
:1;/* response len is valid */
157 u8 rsp_len_valid
:1;/* response len is valid */
158 u8 sns_len_valid
:1;/* sense len is valid */
159 u8 resid_flags
:2; /* underflow/overflow */
160 u8 fcp_conf_req
:1; /* FCP_CONF is requested */
163 u8 scsi_status
; /* one byte SCSI status */
164 u32 residue
; /* residual data bytes */
165 u32 sns_len
; /* length od sense info */
166 u32 rsp_len
; /* length of response info */
169 #define fcp_snslen(__fcprsp) ((__fcprsp)->sns_len_valid ? \
170 (__fcprsp)->sns_len : 0)
171 #define fcp_rsplen(__fcprsp) ((__fcprsp)->rsp_len_valid ? \
172 (__fcprsp)->rsp_len : 0)
173 #define fcp_rspinfo(__fcprsp) ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
174 #define fcp_snsinfo(__fcprsp) (((u8 *)fcp_rspinfo(__fcprsp)) + \
175 fcp_rsplen(__fcprsp))
177 struct fcp_cmnd_fr_s
{
179 struct fcp_cmnd_s fcp
;