- patches.suse/slab-handle-memoryless-nodes-v2a.patch: Refresh.
[linux-flexiantxendom0-3.2.10.git] / drivers / scsi / bfa / include / protocol / fcp.h
1 /*
2  * Copyright (c) 2005-2009 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 __FCPPROTO_H__
19 #define __FCPPROTO_H__
20
21 #include <protocol/scsi.h>
22
23 #pragma pack(1)
24
25 enum {
26         FCP_RJT         = 0x01000000,   /* SRR reject */
27         FCP_SRR_ACCEPT  = 0x02000000,   /* SRR accept */
28         FCP_SRR         = 0x14000000,   /* Sequence Retransmission Request */
29 };
30
31 /*
32  * SRR FC-4 LS payload
33  */
34 struct fc_srr_s{
35         u32     ls_cmd;
36         u32        ox_id:16;    /* ox-id */
37         u32        rx_id:16;    /* rx-id */
38         u32        ro;          /* relative offset */
39         u32        r_ctl:8;             /* R_CTL for I.U. */
40         u32        res:24;
41 };
42
43
44 /*
45  * FCP_CMND definitions
46  */
47 #define FCP_CMND_CDB_LEN    16
48 #define FCP_CMND_LUN_LEN    8
49
50 struct fcp_cmnd_s{
51         lun_t           lun;            /* 64-bit LU number */
52         u8         crn;         /* command reference number */
53 #ifdef __BIGENDIAN
54         u8         resvd:1,
55                         priority:4,     /* FCP-3: SAM-3 priority */
56                         taskattr:3;     /* scsi task attribute */
57 #else
58         u8         taskattr:3,  /* scsi task attribute */
59                         priority:4,     /* FCP-3: SAM-3 priority */
60                         resvd:1;
61 #endif
62         u8         tm_flags;    /* task management flags */
63 #ifdef __BIGENDIAN
64         u8         addl_cdb_len:6,      /* additional CDB length words */
65                         iodir:2;        /* read/write FCP_DATA IUs */
66 #else
67         u8         iodir:2,     /* read/write FCP_DATA IUs */
68                         addl_cdb_len:6; /* additional CDB length */
69 #endif
70         struct scsi_cdb_s      cdb;
71
72         /*
73          * !!! additional cdb bytes follows here!!!
74          */
75         u32        fcp_dl;      /* bytes to be transferred */
76 };
77
78 #define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
79 #define fcp_cmnd_fcpdl(_cmnd)   ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
80
81 /*
82  * fcp_cmnd_t.iodir field values
83  */
84 enum fcp_iodir{
85         FCP_IODIR_NONE  = 0,
86         FCP_IODIR_WRITE = 1,
87         FCP_IODIR_READ  = 2,
88         FCP_IODIR_RW    = 3,
89 };
90
91 /*
92  * Task attribute field
93  */
94 enum {
95         FCP_TASK_ATTR_SIMPLE    = 0,
96         FCP_TASK_ATTR_HOQ       = 1,
97         FCP_TASK_ATTR_ORDERED   = 2,
98         FCP_TASK_ATTR_ACA       = 4,
99         FCP_TASK_ATTR_UNTAGGED  = 5,    /* obsolete in FCP-3 */
100 };
101
102 /*
103  * Task management flags field - only one bit shall be set
104  */
105 #ifndef BIT
106 #define BIT(_x) (1 << (_x))
107 #endif
108 enum fcp_tm_cmnd{
109         FCP_TM_ABORT_TASK_SET   = BIT(1),
110         FCP_TM_CLEAR_TASK_SET   = BIT(2),
111         FCP_TM_LUN_RESET        = BIT(4),
112         FCP_TM_TARGET_RESET     = BIT(5),       /* obsolete in FCP-3 */
113         FCP_TM_CLEAR_ACA        = BIT(6),
114 };
115
116 /*
117  * FCP_XFER_RDY IU defines
118  */
119 struct fcp_xfer_rdy_s{
120         u32        data_ro;
121         u32        burst_len;
122         u32        reserved;
123 };
124
125 /*
126  * FCP_RSP residue flags
127  */
128 enum fcp_residue{
129         FCP_NO_RESIDUE = 0,     /* no residue */
130         FCP_RESID_OVER = 1,     /* more data left that was not sent */
131         FCP_RESID_UNDER = 2,    /* less data than requested */
132 };
133
134 enum {
135         FCP_RSPINFO_GOOD = 0,
136         FCP_RSPINFO_DATALEN_MISMATCH = 1,
137         FCP_RSPINFO_CMND_INVALID = 2,
138         FCP_RSPINFO_ROLEN_MISMATCH = 3,
139         FCP_RSPINFO_TM_NOT_SUPP = 4,
140         FCP_RSPINFO_TM_FAILED = 5,
141 };
142
143 struct fcp_rspinfo_s{
144         u32        res0:24;
145         u32        rsp_code:8;  /* response code (as above) */
146         u32        res1;
147 };
148
149 struct fcp_resp_s{
150         u32        reserved[2]; /* 2 words reserved */
151         u16        reserved2;
152 #ifdef __BIGENDIAN
153         u8         reserved3:3;
154         u8         fcp_conf_req:1;      /* FCP_CONF is requested */
155         u8         resid_flags:2;       /* underflow/overflow */
156         u8         sns_len_valid:1;/* sense len is valid */
157         u8         rsp_len_valid:1;/* response len is valid */
158 #else
159         u8         rsp_len_valid:1;/* response len is valid */
160         u8         sns_len_valid:1;/* sense len is valid */
161         u8         resid_flags:2;       /* underflow/overflow */
162         u8         fcp_conf_req:1;      /* FCP_CONF is requested */
163         u8         reserved3:3;
164 #endif
165         u8         scsi_status; /* one byte SCSI status */
166         u32        residue;     /* residual data bytes */
167         u32        sns_len;     /* length od sense info */
168         u32        rsp_len;     /* length of response info */
169 };
170
171 #define fcp_snslen(__fcprsp)    ((__fcprsp)->sns_len_valid ?            \
172                                         (__fcprsp)->sns_len : 0)
173 #define fcp_rsplen(__fcprsp)    ((__fcprsp)->rsp_len_valid ?            \
174                                         (__fcprsp)->rsp_len : 0)
175 #define fcp_rspinfo(__fcprsp)   ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
176 #define fcp_snsinfo(__fcprsp)   (((u8 *)fcp_rspinfo(__fcprsp)) +        \
177                                                 fcp_rsplen(__fcprsp))
178
179 struct fcp_cmnd_fr_s{
180         struct fchs_s          fchs;
181         struct fcp_cmnd_s      fcp;
182 };
183
184 #pragma pack()
185
186 #endif