Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / include / scsi / fc / fc_fs.h
1 /*
2  * Copyright(c) 2007 Intel Corporation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16  *
17  * Maintained at www.Open-FCoE.org
18  */
19
20 #ifndef _FC_FS_H_
21 #define _FC_FS_H_
22
23 /*
24  * Fibre Channel Framing and Signalling definitions.
25  * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.
26  */
27
28 /*
29  * Frame header
30  */
31 struct fc_frame_header {
32         __u8          fh_r_ctl; /* routing control */
33         __u8          fh_d_id[3];       /* Destination ID */
34
35         __u8          fh_cs_ctl;        /* class of service control / pri */
36         __u8          fh_s_id[3];       /* Source ID */
37
38         __u8          fh_type;          /* see enum fc_fh_type below */
39         __u8          fh_f_ctl[3];      /* frame control */
40
41         __u8          fh_seq_id;        /* sequence ID */
42         __u8          fh_df_ctl;        /* data field control */
43         __be16        fh_seq_cnt;       /* sequence count */
44
45         __be16        fh_ox_id;         /* originator exchange ID */
46         __be16        fh_rx_id;         /* responder exchange ID */
47         __be32        fh_parm_offset;   /* parameter or relative offset */
48 };
49
50 #define FC_FRAME_HEADER_LEN 24  /* expected length of structure */
51
52 #define FC_MAX_PAYLOAD  2112U           /* max payload length in bytes */
53 #define FC_MIN_MAX_PAYLOAD  256U        /* lower limit on max payload */
54
55 #define FC_MAX_FRAME    (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
56 #define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
57
58 /*
59  * fh_r_ctl - Routing control definitions.
60  */
61     /*
62      * FC-4 device_data.
63      */
64 enum fc_rctl {
65         FC_RCTL_DD_UNCAT = 0x00,        /* uncategorized information */
66         FC_RCTL_DD_SOL_DATA = 0x01,     /* solicited data */
67         FC_RCTL_DD_UNSOL_CTL = 0x02,    /* unsolicited control */
68         FC_RCTL_DD_SOL_CTL = 0x03,      /* solicited control or reply */
69         FC_RCTL_DD_UNSOL_DATA = 0x04,   /* unsolicited data */
70         FC_RCTL_DD_DATA_DESC = 0x05,    /* data descriptor */
71         FC_RCTL_DD_UNSOL_CMD = 0x06,    /* unsolicited command */
72         FC_RCTL_DD_CMD_STATUS = 0x07,   /* command status */
73
74 #define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL    /* ILS request */
75 #define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL      /* ILS reply */
76
77         /*
78          * Extended Link_Data
79          */
80         FC_RCTL_ELS_REQ = 0x22, /* extended link services request */
81         FC_RCTL_ELS_REP = 0x23, /* extended link services reply */
82         FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */
83         FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */
84         /*
85          * Optional Extended Headers
86          */
87         FC_RCTL_VFTH = 0x50,    /* virtual fabric tagging header */
88         FC_RCTL_IFRH = 0x51,    /* inter-fabric routing header */
89         FC_RCTL_ENCH = 0x52,    /* encapsulation header */
90         /*
91          * Basic Link Services fh_r_ctl values.
92          */
93         FC_RCTL_BA_NOP = 0x80,  /* basic link service NOP */
94         FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */
95         FC_RCTL_BA_RMC = 0x82,  /* remove connection */
96         FC_RCTL_BA_ACC = 0x84,  /* basic accept */
97         FC_RCTL_BA_RJT = 0x85,  /* basic reject */
98         FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */
99         /*
100          * Link Control Information.
101          */
102         FC_RCTL_ACK_1 = 0xc0,   /* acknowledge_1 */
103         FC_RCTL_ACK_0 = 0xc1,   /* acknowledge_0 */
104         FC_RCTL_P_RJT = 0xc2,   /* port reject */
105         FC_RCTL_F_RJT = 0xc3,   /* fabric reject */
106         FC_RCTL_P_BSY = 0xc4,   /* port busy */
107         FC_RCTL_F_BSY = 0xc5,   /* fabric busy to data frame */
108         FC_RCTL_F_BSYL = 0xc6,  /* fabric busy to link control frame */
109         FC_RCTL_LCR = 0xc7,     /* link credit reset */
110         FC_RCTL_END = 0xc9,     /* end */
111 };
112                                     /* incomplete list of definitions */
113
114 /*
115  * R_CTL names initializer.
116  * Please keep this matching the above definitions.
117  */
118 #define FC_RCTL_NAMES_INIT { \
119         [FC_RCTL_DD_UNCAT] =            "uncat",                        \
120         [FC_RCTL_DD_SOL_DATA] =         "sol data",                     \
121         [FC_RCTL_DD_UNSOL_CTL] =        "unsol ctl",                    \
122         [FC_RCTL_DD_SOL_CTL] =          "sol ctl/reply",                \
123         [FC_RCTL_DD_UNSOL_DATA] =       "unsol data",                   \
124         [FC_RCTL_DD_DATA_DESC] =        "data desc",                    \
125         [FC_RCTL_DD_UNSOL_CMD] =        "unsol cmd",                    \
126         [FC_RCTL_DD_CMD_STATUS] =       "cmd status",                   \
127         [FC_RCTL_ELS_REQ] =             "ELS req",                      \
128         [FC_RCTL_ELS_REP] =             "ELS rep",                      \
129         [FC_RCTL_ELS4_REQ] =            "FC-4 ELS req",                 \
130         [FC_RCTL_ELS4_REP] =            "FC-4 ELS rep",                 \
131         [FC_RCTL_BA_NOP] =              "BLS NOP",                      \
132         [FC_RCTL_BA_ABTS] =             "BLS abort",                    \
133         [FC_RCTL_BA_RMC] =              "BLS remove connection",        \
134         [FC_RCTL_BA_ACC] =              "BLS accept",                   \
135         [FC_RCTL_BA_RJT] =              "BLS reject",                   \
136         [FC_RCTL_BA_PRMT] =             "BLS dedicated connection preempted", \
137         [FC_RCTL_ACK_1] =               "LC ACK_1",                     \
138         [FC_RCTL_ACK_0] =               "LC ACK_0",                     \
139         [FC_RCTL_P_RJT] =               "LC port reject",               \
140         [FC_RCTL_F_RJT] =               "LC fabric reject",             \
141         [FC_RCTL_P_BSY] =               "LC port busy",                 \
142         [FC_RCTL_F_BSY] =               "LC fabric busy to data frame", \
143         [FC_RCTL_F_BSYL] =              "LC fabric busy to link control frame",\
144         [FC_RCTL_LCR] =                 "LC link credit reset",         \
145         [FC_RCTL_END] =                 "LC end",                       \
146 }
147
148 /*
149  * Well-known fabric addresses.
150  */
151 enum fc_well_known_fid {
152         FC_FID_NONE =           0x000000,       /* No destination */
153         FC_FID_BCAST =          0xffffff,       /* broadcast */
154         FC_FID_FLOGI =          0xfffffe,       /* fabric login */
155         FC_FID_FCTRL =          0xfffffd,       /* fabric controller */
156         FC_FID_DIR_SERV =       0xfffffc,       /* directory server */
157         FC_FID_TIME_SERV =      0xfffffb,       /* time server */
158         FC_FID_MGMT_SERV =      0xfffffa,       /* management server */
159         FC_FID_QOS =            0xfffff9,       /* QoS Facilitator */
160         FC_FID_ALIASES =        0xfffff8,       /* alias server (FC-PH2) */
161         FC_FID_SEC_KEY =        0xfffff7,       /* Security key dist. server */
162         FC_FID_CLOCK =          0xfffff6,       /* clock synch server */
163         FC_FID_MCAST_SERV =     0xfffff5,       /* multicast server */
164 };
165
166 #define FC_FID_WELL_KNOWN_MAX   0xffffff /* highest well-known fabric ID */
167 #define FC_FID_WELL_KNOWN_BASE  0xfffff5 /* start of well-known fabric ID */
168
169 /*
170  * Other well-known addresses, outside the above contiguous range.
171  */
172 #define FC_FID_DOM_MGR          0xfffc00        /* domain manager base */
173
174 /*
175  * Fabric ID bytes.
176  */
177 #define FC_FID_DOMAIN           0
178 #define FC_FID_PORT             1
179 #define FC_FID_LINK             2
180
181 /*
182  * fh_type codes
183  */
184 enum fc_fh_type {
185         FC_TYPE_BLS =   0x00,   /* basic link service */
186         FC_TYPE_ELS =   0x01,   /* extended link service */
187         FC_TYPE_IP =    0x05,   /* IP over FC, RFC 4338 */
188         FC_TYPE_FCP =   0x08,   /* SCSI FCP */
189         FC_TYPE_CT =    0x20,   /* Fibre Channel Services (FC-CT) */
190         FC_TYPE_ILS =   0x22,   /* internal link service */
191 };
192
193 /*
194  * FC_TYPE names initializer.
195  * Please keep this matching the above definitions.
196  */
197 #define FC_TYPE_NAMES_INIT {                            \
198         [FC_TYPE_BLS] =         "BLS",                  \
199         [FC_TYPE_ELS] =         "ELS",                  \
200         [FC_TYPE_IP] =          "IP",                   \
201         [FC_TYPE_FCP] =         "FCP",                  \
202         [FC_TYPE_CT] =          "CT",                   \
203         [FC_TYPE_ILS] =         "ILS",                  \
204 }
205
206 /*
207  * Exchange IDs.
208  */
209 #define FC_XID_UNKNOWN  0xffff  /* unknown exchange ID */
210 #define FC_XID_MIN      0x0     /* supported min exchange ID */
211 #define FC_XID_MAX      0xfffe  /* supported max exchange ID */
212
213 /*
214  * fh_f_ctl - Frame control flags.
215  */
216 #define FC_FC_EX_CTX    (1 << 23)       /* sent by responder to exchange */
217 #define FC_FC_SEQ_CTX   (1 << 22)       /* sent by responder to sequence */
218 #define FC_FC_FIRST_SEQ (1 << 21)       /* first sequence of this exchange */
219 #define FC_FC_LAST_SEQ  (1 << 20)       /* last sequence of this exchange */
220 #define FC_FC_END_SEQ   (1 << 19)       /* last frame of sequence */
221 #define FC_FC_END_CONN  (1 << 18)       /* end of class 1 connection pending */
222 #define FC_FC_RES_B17   (1 << 17)       /* reserved */
223 #define FC_FC_SEQ_INIT  (1 << 16)       /* transfer of sequence initiative */
224 #define FC_FC_X_ID_REASS (1 << 15)      /* exchange ID has been changed */
225 #define FC_FC_X_ID_INVAL (1 << 14)      /* exchange ID invalidated */
226
227 #define FC_FC_ACK_1     (1 << 12)       /* 13:12 = 1: ACK_1 expected */
228 #define FC_FC_ACK_N     (2 << 12)       /* 13:12 = 2: ACK_N expected */
229 #define FC_FC_ACK_0     (3 << 12)       /* 13:12 = 3: ACK_0 expected */
230
231 #define FC_FC_RES_B11   (1 << 11)       /* reserved */
232 #define FC_FC_RES_B10   (1 << 10)       /* reserved */
233 #define FC_FC_RETX_SEQ  (1 << 9)        /* retransmitted sequence */
234 #define FC_FC_UNI_TX    (1 << 8)        /* unidirectional transmit (class 1) */
235 #define FC_FC_CONT_SEQ(i) ((i) << 6)
236 #define FC_FC_ABT_SEQ(i) ((i) << 4)
237 #define FC_FC_REL_OFF   (1 << 3)        /* parameter is relative offset */
238 #define FC_FC_RES2      (1 << 2)        /* reserved */
239 #define FC_FC_FILL(i)   ((i) & 3)       /* 1:0: bytes of trailing fill */
240
241 /*
242  * BA_ACC payload.
243  */
244 struct fc_ba_acc {
245         __u8            ba_seq_id_val;  /* SEQ_ID validity */
246 #define FC_BA_SEQ_ID_VAL 0x80
247         __u8            ba_seq_id;      /* SEQ_ID of seq last deliverable */
248         __u8            ba_resvd[2];    /* reserved */
249         __be16          ba_ox_id;       /* OX_ID for aborted seq or exch */
250         __be16          ba_rx_id;       /* RX_ID for aborted seq or exch */
251         __be16          ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */
252         __be16          ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
253 };
254
255 /*
256  * BA_RJT: Basic Reject payload.
257  */
258 struct fc_ba_rjt {
259         __u8            br_resvd;       /* reserved */
260         __u8            br_reason;      /* reason code */
261         __u8            br_explan;      /* reason explanation */
262         __u8            br_vendor;      /* vendor unique code */
263 };
264
265 /*
266  * BA_RJT reason codes.
267  * From FS-2.
268  */
269 enum fc_ba_rjt_reason {
270         FC_BA_RJT_NONE =        0,      /* in software this means no reject */
271         FC_BA_RJT_INVL_CMD =    0x01,   /* invalid command code */
272         FC_BA_RJT_LOG_ERR =     0x03,   /* logical error */
273         FC_BA_RJT_LOG_BUSY =    0x05,   /* logical busy */
274         FC_BA_RJT_PROTO_ERR =   0x07,   /* protocol error */
275         FC_BA_RJT_UNABLE =      0x09,   /* unable to perform request */
276         FC_BA_RJT_VENDOR =      0xff,   /* vendor-specific (see br_vendor) */
277 };
278
279 /*
280  * BA_RJT reason code explanations.
281  */
282 enum fc_ba_rjt_explan {
283         FC_BA_RJT_EXP_NONE =    0x00,   /* no additional expanation */
284         FC_BA_RJT_INV_XID =     0x03,   /* invalid OX_ID-RX_ID combination */
285         FC_BA_RJT_ABT =         0x05,   /* sequence aborted, no seq info */
286 };
287
288 /*
289  * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
290  */
291 struct fc_pf_rjt {
292         __u8            rj_action;      /* reserved */
293         __u8            rj_reason;      /* reason code */
294         __u8            rj_resvd;       /* reserved */
295         __u8            rj_vendor;      /* vendor unique code */
296 };
297
298 /*
299  * P_RJT and F_RJT reject reason codes.
300  */
301 enum fc_pf_rjt_reason {
302         FC_RJT_NONE =           0,      /* non-reject (reserved by standard) */
303         FC_RJT_INVL_DID =       0x01,   /* invalid destination ID */
304         FC_RJT_INVL_SID =       0x02,   /* invalid source ID */
305         FC_RJT_P_UNAV_T =       0x03,   /* port unavailable, temporary */
306         FC_RJT_P_UNAV =         0x04,   /* port unavailable, permanent */
307         FC_RJT_CLS_UNSUP =      0x05,   /* class not supported */
308         FC_RJT_DEL_USAGE =      0x06,   /* delimiter usage error */
309         FC_RJT_TYPE_UNSUP =     0x07,   /* type not supported */
310         FC_RJT_LINK_CTL =       0x08,   /* invalid link control */
311         FC_RJT_R_CTL =          0x09,   /* invalid R_CTL field */
312         FC_RJT_F_CTL =          0x0a,   /* invalid F_CTL field */
313         FC_RJT_OX_ID =          0x0b,   /* invalid originator exchange ID */
314         FC_RJT_RX_ID =          0x0c,   /* invalid responder exchange ID */
315         FC_RJT_SEQ_ID =         0x0d,   /* invalid sequence ID */
316         FC_RJT_DF_CTL =         0x0e,   /* invalid DF_CTL field */
317         FC_RJT_SEQ_CNT =        0x0f,   /* invalid SEQ_CNT field */
318         FC_RJT_PARAM =          0x10,   /* invalid parameter field */
319         FC_RJT_EXCH_ERR =       0x11,   /* exchange error */
320         FC_RJT_PROTO =          0x12,   /* protocol error */
321         FC_RJT_LEN =            0x13,   /* incorrect length */
322         FC_RJT_UNEXP_ACK =      0x14,   /* unexpected ACK */
323         FC_RJT_FAB_CLASS =      0x15,   /* class unsupported by fabric entity */
324         FC_RJT_LOGI_REQ =       0x16,   /* login required */
325         FC_RJT_SEQ_XS =         0x17,   /* excessive sequences attempted */
326         FC_RJT_EXCH_EST =       0x18,   /* unable to establish exchange */
327         FC_RJT_FAB_UNAV =       0x1a,   /* fabric unavailable */
328         FC_RJT_VC_ID =          0x1b,   /* invalid VC_ID (class 4) */
329         FC_RJT_CS_CTL =         0x1c,   /* invalid CS_CTL field */
330         FC_RJT_INSUF_RES =      0x1d,   /* insuff. resources for VC (Class 4) */
331         FC_RJT_INVL_CLS =       0x1f,   /* invalid class of service */
332         FC_RJT_PREEMT_RJT =     0x20,   /* preemption request rejected */
333         FC_RJT_PREEMT_DIS =     0x21,   /* preemption not enabled */
334         FC_RJT_MCAST_ERR =      0x22,   /* multicast error */
335         FC_RJT_MCAST_ET =       0x23,   /* multicast error terminate */
336         FC_RJT_PRLI_REQ =       0x24,   /* process login required */
337         FC_RJT_INVL_ATT =       0x25,   /* invalid attachment */
338         FC_RJT_VENDOR =         0xff,   /* vendor specific reject */
339 };
340
341 /* default timeout values */
342
343 #define FC_DEF_E_D_TOV  2000UL
344 #define FC_DEF_R_A_TOV  10000UL
345
346 #endif /* _FC_FS_H_ */