aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorRobert Love <robert.w.love@intel.com>2008-12-09 18:10:11 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-12-29 12:24:32 -0500
commitf032c2f7cdaae0e8907cd3b26426fc651dc5c275 (patch)
treea8ee4e4aee28c9d5173cd2c39d83dbbc0b7ebcdb /include/scsi
parent21465eda9eafa275ed11c27779d90aa95559b6f6 (diff)
[SCSI] FC protocol definition header files
Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/fc/fc_els.h816
-rw-r--r--include/scsi/fc/fc_encaps.h138
-rw-r--r--include/scsi/fc/fc_fc2.h124
-rw-r--r--include/scsi/fc/fc_fcoe.h114
-rw-r--r--include/scsi/fc/fc_fcp.h199
-rw-r--r--include/scsi/fc/fc_fs.h340
-rw-r--r--include/scsi/fc/fc_gs.h93
-rw-r--r--include/scsi/fc/fc_ns.h159
8 files changed, 1983 insertions, 0 deletions
diff --git a/include/scsi/fc/fc_els.h b/include/scsi/fc/fc_els.h
new file mode 100644
index 000000000000..195ca014d3ce
--- /dev/null
+++ b/include/scsi/fc/fc_els.h
@@ -0,0 +1,816 @@
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_ELS_H_
21#define _FC_ELS_H_
22
23/*
24 * Fibre Channel Switch - Enhanced Link Services definitions.
25 * From T11 FC-LS Rev 1.2 June 7, 2005.
26 */
27
28/*
29 * ELS Command codes - byte 0 of the frame payload
30 */
31enum fc_els_cmd {
32 ELS_LS_RJT = 0x01, /* ESL reject */
33 ELS_LS_ACC = 0x02, /* ESL Accept */
34 ELS_PLOGI = 0x03, /* N_Port login */
35 ELS_FLOGI = 0x04, /* F_Port login */
36 ELS_LOGO = 0x05, /* Logout */
37 ELS_ABTX = 0x06, /* Abort exchange - obsolete */
38 ELS_RCS = 0x07, /* read connection status */
39 ELS_RES = 0x08, /* read exchange status block */
40 ELS_RSS = 0x09, /* read sequence status block */
41 ELS_RSI = 0x0a, /* read sequence initiative */
42 ELS_ESTS = 0x0b, /* establish streaming */
43 ELS_ESTC = 0x0c, /* estimate credit */
44 ELS_ADVC = 0x0d, /* advise credit */
45 ELS_RTV = 0x0e, /* read timeout value */
46 ELS_RLS = 0x0f, /* read link error status block */
47 ELS_ECHO = 0x10, /* echo */
48 ELS_TEST = 0x11, /* test */
49 ELS_RRQ = 0x12, /* reinstate recovery qualifier */
50 ELS_REC = 0x13, /* read exchange concise */
51 ELS_SRR = 0x14, /* sequence retransmission request */
52 ELS_PRLI = 0x20, /* process login */
53 ELS_PRLO = 0x21, /* process logout */
54 ELS_SCN = 0x22, /* state change notification */
55 ELS_TPLS = 0x23, /* test process login state */
56 ELS_TPRLO = 0x24, /* third party process logout */
57 ELS_LCLM = 0x25, /* login control list mgmt (obs) */
58 ELS_GAID = 0x30, /* get alias_ID */
59 ELS_FACT = 0x31, /* fabric activate alias_id */
60 ELS_FDACDT = 0x32, /* fabric deactivate alias_id */
61 ELS_NACT = 0x33, /* N-port activate alias_id */
62 ELS_NDACT = 0x34, /* N-port deactivate alias_id */
63 ELS_QOSR = 0x40, /* quality of service request */
64 ELS_RVCS = 0x41, /* read virtual circuit status */
65 ELS_PDISC = 0x50, /* discover N_port service params */
66 ELS_FDISC = 0x51, /* discover F_port service params */
67 ELS_ADISC = 0x52, /* discover address */
68 ELS_RNC = 0x53, /* report node cap (obs) */
69 ELS_FARP_REQ = 0x54, /* FC ARP request */
70 ELS_FARP_REPL = 0x55, /* FC ARP reply */
71 ELS_RPS = 0x56, /* read port status block */
72 ELS_RPL = 0x57, /* read port list */
73 ELS_RPBC = 0x58, /* read port buffer condition */
74 ELS_FAN = 0x60, /* fabric address notification */
75 ELS_RSCN = 0x61, /* registered state change notification */
76 ELS_SCR = 0x62, /* state change registration */
77 ELS_RNFT = 0x63, /* report node FC-4 types */
78 ELS_CSR = 0x68, /* clock synch. request */
79 ELS_CSU = 0x69, /* clock synch. update */
80 ELS_LINIT = 0x70, /* loop initialize */
81 ELS_LSTS = 0x72, /* loop status */
82 ELS_RNID = 0x78, /* request node ID data */
83 ELS_RLIR = 0x79, /* registered link incident report */
84 ELS_LIRR = 0x7a, /* link incident record registration */
85 ELS_SRL = 0x7b, /* scan remote loop */
86 ELS_SBRP = 0x7c, /* set bit-error reporting params */
87 ELS_RPSC = 0x7d, /* report speed capabilities */
88 ELS_QSA = 0x7e, /* query security attributes */
89 ELS_EVFP = 0x7f, /* exchange virt. fabrics params */
90 ELS_LKA = 0x80, /* link keep-alive */
91 ELS_AUTH_ELS = 0x90, /* authentication ELS */
92};
93
94/*
95 * Initializer useful for decoding table.
96 * Please keep this in sync with the above definitions.
97 */
98#define FC_ELS_CMDS_INIT { \
99 [ELS_LS_RJT] = "LS_RJT", \
100 [ELS_LS_ACC] = "LS_ACC", \
101 [ELS_PLOGI] = "PLOGI", \
102 [ELS_FLOGI] = "FLOGI", \
103 [ELS_LOGO] = "LOGO", \
104 [ELS_ABTX] = "ABTX", \
105 [ELS_RCS] = "RCS", \
106 [ELS_RES] = "RES", \
107 [ELS_RSS] = "RSS", \
108 [ELS_RSI] = "RSI", \
109 [ELS_ESTS] = "ESTS", \
110 [ELS_ESTC] = "ESTC", \
111 [ELS_ADVC] = "ADVC", \
112 [ELS_RTV] = "RTV", \
113 [ELS_RLS] = "RLS", \
114 [ELS_ECHO] = "ECHO", \
115 [ELS_TEST] = "TEST", \
116 [ELS_RRQ] = "RRQ", \
117 [ELS_REC] = "REC", \
118 [ELS_SRR] = "SRR", \
119 [ELS_PRLI] = "PRLI", \
120 [ELS_PRLO] = "PRLO", \
121 [ELS_SCN] = "SCN", \
122 [ELS_TPLS] = "TPLS", \
123 [ELS_TPRLO] = "TPRLO", \
124 [ELS_LCLM] = "LCLM", \
125 [ELS_GAID] = "GAID", \
126 [ELS_FACT] = "FACT", \
127 [ELS_FDACDT] = "FDACDT", \
128 [ELS_NACT] = "NACT", \
129 [ELS_NDACT] = "NDACT", \
130 [ELS_QOSR] = "QOSR", \
131 [ELS_RVCS] = "RVCS", \
132 [ELS_PDISC] = "PDISC", \
133 [ELS_FDISC] = "FDISC", \
134 [ELS_ADISC] = "ADISC", \
135 [ELS_RNC] = "RNC", \
136 [ELS_FARP_REQ] = "FARP_REQ", \
137 [ELS_FARP_REPL] = "FARP_REPL", \
138 [ELS_RPS] = "RPS", \
139 [ELS_RPL] = "RPL", \
140 [ELS_RPBC] = "RPBC", \
141 [ELS_FAN] = "FAN", \
142 [ELS_RSCN] = "RSCN", \
143 [ELS_SCR] = "SCR", \
144 [ELS_RNFT] = "RNFT", \
145 [ELS_CSR] = "CSR", \
146 [ELS_CSU] = "CSU", \
147 [ELS_LINIT] = "LINIT", \
148 [ELS_LSTS] = "LSTS", \
149 [ELS_RNID] = "RNID", \
150 [ELS_RLIR] = "RLIR", \
151 [ELS_LIRR] = "LIRR", \
152 [ELS_SRL] = "SRL", \
153 [ELS_SBRP] = "SBRP", \
154 [ELS_RPSC] = "RPSC", \
155 [ELS_QSA] = "QSA", \
156 [ELS_EVFP] = "EVFP", \
157 [ELS_LKA] = "LKA", \
158 [ELS_AUTH_ELS] = "AUTH_ELS", \
159}
160
161/*
162 * LS_ACC payload.
163 */
164struct fc_els_ls_acc {
165 __u8 la_cmd; /* command code ELS_LS_ACC */
166 __u8 la_resv[3]; /* reserved */
167};
168
169/*
170 * ELS reject payload.
171 */
172struct fc_els_ls_rjt {
173 __u8 er_cmd; /* command code ELS_LS_RJT */
174 __u8 er_resv[4]; /* reserved must be zero */
175 __u8 er_reason; /* reason (enum fc_els_rjt_reason below) */
176 __u8 er_explan; /* explanation (enum fc_els_rjt_explan below) */
177 __u8 er_vendor; /* vendor specific code */
178};
179
180/*
181 * ELS reject reason codes (er_reason).
182 */
183enum fc_els_rjt_reason {
184 ELS_RJT_NONE = 0, /* no reject - not to be sent */
185 ELS_RJT_INVAL = 0x01, /* invalid ELS command code */
186 ELS_RJT_LOGIC = 0x03, /* logical error */
187 ELS_RJT_BUSY = 0x05, /* logical busy */
188 ELS_RJT_PROT = 0x07, /* protocol error */
189 ELS_RJT_UNAB = 0x09, /* unable to perform command request */
190 ELS_RJT_UNSUP = 0x0b, /* command not supported */
191 ELS_RJT_INPROG = 0x0e, /* command already in progress */
192 ELS_RJT_VENDOR = 0xff, /* vendor specific error */
193};
194
195
196/*
197 * reason code explanation (er_explan).
198 */
199enum fc_els_rjt_explan {
200 ELS_EXPL_NONE = 0x00, /* No additional explanation */
201 ELS_EXPL_SPP_OPT_ERR = 0x01, /* service parameter error - options */
202 ELS_EXPL_SPP_ICTL_ERR = 0x03, /* service parm error - initiator ctl */
203 ELS_EXPL_AH = 0x11, /* invalid association header */
204 ELS_EXPL_AH_REQ = 0x13, /* association_header required */
205 ELS_EXPL_SID = 0x15, /* invalid originator S_ID */
206 ELS_EXPL_OXID_RXID = 0x17, /* invalid OX_ID-RX_ID combination */
207 ELS_EXPL_INPROG = 0x19, /* Request already in progress */
208 ELS_EXPL_PLOGI_REQD = 0x1e, /* N_Port login required */
209 ELS_EXPL_INSUF_RES = 0x29, /* insufficient resources */
210 ELS_EXPL_UNAB_DATA = 0x2a, /* unable to supply requested data */
211 ELS_EXPL_UNSUPR = 0x2c, /* Request not supported */
212 ELS_EXPL_INV_LEN = 0x2d, /* Invalid payload length */
213 /* TBD - above definitions incomplete */
214};
215
216/*
217 * Common service parameters (N ports).
218 */
219struct fc_els_csp {
220 __u8 sp_hi_ver; /* highest version supported (obs.) */
221 __u8 sp_lo_ver; /* highest version supported (obs.) */
222 __be16 sp_bb_cred; /* buffer-to-buffer credits */
223 __be16 sp_features; /* common feature flags */
224 __be16 sp_bb_data; /* b-b state number and data field sz */
225 union {
226 struct {
227 __be16 _sp_tot_seq; /* total concurrent sequences */
228 __be16 _sp_rel_off; /* rel. offset by info cat */
229 } sp_plogi;
230 struct {
231 __be32 _sp_r_a_tov; /* resource alloc. timeout msec */
232 } sp_flogi_acc;
233 } sp_u;
234 __be32 sp_e_d_tov; /* error detect timeout value */
235};
236#define sp_tot_seq sp_u.sp_plogi._sp_tot_seq
237#define sp_rel_off sp_u.sp_plogi._sp_rel_off
238#define sp_r_a_tov sp_u.sp_flogi_acc._sp_r_a_tov
239
240#define FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */
241
242/*
243 * Minimum and maximum values for max data field size in service parameters.
244 */
245#define FC_SP_MIN_MAX_PAYLOAD FC_MIN_MAX_PAYLOAD
246#define FC_SP_MAX_MAX_PAYLOAD FC_MAX_PAYLOAD
247
248/*
249 * sp_features
250 */
251#define FC_SP_FT_CIRO 0x8000 /* continuously increasing rel. off. */
252#define FC_SP_FT_CLAD 0x8000 /* clean address (in FLOGI LS_ACC) */
253#define FC_SP_FT_RAND 0x4000 /* random relative offset */
254#define FC_SP_FT_VAL 0x2000 /* valid vendor version level */
255#define FC_SP_FT_FPORT 0x1000 /* F port (1) vs. N port (0) */
256#define FC_SP_FT_ABB 0x0800 /* alternate BB_credit management */
257#define FC_SP_FT_EDTR 0x0400 /* E_D_TOV Resolution is nanoseconds */
258#define FC_SP_FT_MCAST 0x0200 /* multicast */
259#define FC_SP_FT_BCAST 0x0100 /* broadcast */
260#define FC_SP_FT_HUNT 0x0080 /* hunt group */
261#define FC_SP_FT_SIMP 0x0040 /* dedicated simplex */
262#define FC_SP_FT_SEC 0x0020 /* reserved for security */
263#define FC_SP_FT_CSYN 0x0010 /* clock synch. supported */
264#define FC_SP_FT_RTTOV 0x0008 /* R_T_TOV value 100 uS, else 100 mS */
265#define FC_SP_FT_HALF 0x0004 /* dynamic half duplex */
266#define FC_SP_FT_SEQC 0x0002 /* SEQ_CNT */
267#define FC_SP_FT_PAYL 0x0001 /* FLOGI payload length 256, else 116 */
268
269/*
270 * Class-specific service parameters.
271 */
272struct fc_els_cssp {
273 __be16 cp_class; /* class flags */
274 __be16 cp_init; /* initiator flags */
275 __be16 cp_recip; /* recipient flags */
276 __be16 cp_rdfs; /* receive data field size */
277 __be16 cp_con_seq; /* concurrent sequences */
278 __be16 cp_ee_cred; /* N-port end-to-end credit */
279 __u8 cp_resv1; /* reserved */
280 __u8 cp_open_seq; /* open sequences per exchange */
281 __u8 _cp_resv2[2]; /* reserved */
282};
283
284/*
285 * cp_class flags.
286 */
287#define FC_CPC_VALID 0x8000 /* class valid */
288#define FC_CPC_IMIX 0x4000 /* intermix mode */
289#define FC_CPC_SEQ 0x0800 /* sequential delivery */
290#define FC_CPC_CAMP 0x0200 /* camp-on */
291#define FC_CPC_PRI 0x0080 /* priority */
292
293/*
294 * cp_init flags.
295 * (TBD: not all flags defined here).
296 */
297#define FC_CPI_CSYN 0x0010 /* clock synch. capable */
298
299/*
300 * cp_recip flags.
301 */
302#define FC_CPR_CSYN 0x0008 /* clock synch. capable */
303
304/*
305 * NFC_ELS_FLOGI: Fabric login request.
306 * NFC_ELS_PLOGI: Port login request (same format).
307 */
308struct fc_els_flogi {
309 __u8 fl_cmd; /* command */
310 __u8 _fl_resvd[3]; /* must be zero */
311 struct fc_els_csp fl_csp; /* common service parameters */
312 __be64 fl_wwpn; /* port name */
313 __be64 fl_wwnn; /* node name */
314 struct fc_els_cssp fl_cssp[4]; /* class 1-4 service parameters */
315 __u8 fl_vend[16]; /* vendor version level */
316} __attribute__((__packed__));
317
318/*
319 * Process login service parameter page.
320 */
321struct fc_els_spp {
322 __u8 spp_type; /* type code or common service params */
323 __u8 spp_type_ext; /* type code extension */
324 __u8 spp_flags;
325 __u8 _spp_resvd;
326 __be32 spp_orig_pa; /* originator process associator */
327 __be32 spp_resp_pa; /* responder process associator */
328 __be32 spp_params; /* service parameters */
329};
330
331/*
332 * spp_flags.
333 */
334#define FC_SPP_OPA_VAL 0x80 /* originator proc. assoc. valid */
335#define FC_SPP_RPA_VAL 0x40 /* responder proc. assoc. valid */
336#define FC_SPP_EST_IMG_PAIR 0x20 /* establish image pair */
337#define FC_SPP_RESP_MASK 0x0f /* mask for response code (below) */
338
339/*
340 * SPP response code in spp_flags - lower 4 bits.
341 */
342enum fc_els_spp_resp {
343 FC_SPP_RESP_ACK = 1, /* request executed */
344 FC_SPP_RESP_RES = 2, /* unable due to lack of resources */
345 FC_SPP_RESP_INIT = 3, /* initialization not complete */
346 FC_SPP_RESP_NO_PA = 4, /* unknown process associator */
347 FC_SPP_RESP_CONF = 5, /* configuration precludes image pair */
348 FC_SPP_RESP_COND = 6, /* request completed conditionally */
349 FC_SPP_RESP_MULT = 7, /* unable to handle multiple SPPs */
350 FC_SPP_RESP_INVL = 8, /* SPP is invalid */
351};
352
353/*
354 * ELS_RRQ - Reinstate Recovery Qualifier
355 */
356struct fc_els_rrq {
357 __u8 rrq_cmd; /* command (0x12) */
358 __u8 rrq_zero[3]; /* specified as zero - part of cmd */
359 __u8 rrq_resvd; /* reserved */
360 __u8 rrq_s_id[3]; /* originator FID */
361 __be16 rrq_ox_id; /* originator exchange ID */
362 __be16 rrq_rx_id; /* responders exchange ID */
363};
364
365/*
366 * ELS_REC - Read exchange concise.
367 */
368struct fc_els_rec {
369 __u8 rec_cmd; /* command (0x13) */
370 __u8 rec_zero[3]; /* specified as zero - part of cmd */
371 __u8 rec_resvd; /* reserved */
372 __u8 rec_s_id[3]; /* originator FID */
373 __be16 rec_ox_id; /* originator exchange ID */
374 __be16 rec_rx_id; /* responders exchange ID */
375};
376
377/*
378 * ELS_REC LS_ACC payload.
379 */
380struct fc_els_rec_acc {
381 __u8 reca_cmd; /* accept (0x02) */
382 __u8 reca_zero[3]; /* specified as zero - part of cmd */
383 __be16 reca_ox_id; /* originator exchange ID */
384 __be16 reca_rx_id; /* responders exchange ID */
385 __u8 reca_resvd1; /* reserved */
386 __u8 reca_ofid[3]; /* originator FID */
387 __u8 reca_resvd2; /* reserved */
388 __u8 reca_rfid[3]; /* responder FID */
389 __be32 reca_fc4value; /* FC4 value */
390 __be32 reca_e_stat; /* ESB (exchange status block) status */
391};
392
393/*
394 * ELS_PRLI - Process login request and response.
395 */
396struct fc_els_prli {
397 __u8 prli_cmd; /* command */
398 __u8 prli_spp_len; /* length of each serv. parm. page */
399 __be16 prli_len; /* length of entire payload */
400 /* service parameter pages follow */
401};
402
403/*
404 * ELS_ADISC payload
405 */
406struct fc_els_adisc {
407 __u8 adisc_cmd;
408 __u8 adisc_resv[3];
409 __u8 adisc_resv1;
410 __u8 adisc_hard_addr[3];
411 __be64 adisc_wwpn;
412 __be64 adisc_wwnn;
413 __u8 adisc_resv2;
414 __u8 adisc_port_id[3];
415} __attribute__((__packed__));
416
417/*
418 * ELS_LOGO - process or fabric logout.
419 */
420struct fc_els_logo {
421 __u8 fl_cmd; /* command code */
422 __u8 fl_zero[3]; /* specified as zero - part of cmd */
423 __u8 fl_resvd; /* reserved */
424 __u8 fl_n_port_id[3];/* N port ID */
425 __be64 fl_n_port_wwn; /* port name */
426};
427
428/*
429 * ELS_RTV - read timeout value.
430 */
431struct fc_els_rtv {
432 __u8 rtv_cmd; /* command code 0x0e */
433 __u8 rtv_zero[3]; /* specified as zero - part of cmd */
434};
435
436/*
437 * LS_ACC for ELS_RTV - read timeout value.
438 */
439struct fc_els_rtv_acc {
440 __u8 rtv_cmd; /* command code 0x02 */
441 __u8 rtv_zero[3]; /* specified as zero - part of cmd */
442 __be32 rtv_r_a_tov; /* resource allocation timeout value */
443 __be32 rtv_e_d_tov; /* error detection timeout value */
444 __be32 rtv_toq; /* timeout qualifier (see below) */
445};
446
447/*
448 * rtv_toq bits.
449 */
450#define FC_ELS_RTV_EDRES (1 << 26) /* E_D_TOV resolution is nS else mS */
451#define FC_ELS_RTV_RTTOV (1 << 19) /* R_T_TOV is 100 uS else 100 mS */
452
453/*
454 * ELS_SCR - state change registration payload.
455 */
456struct fc_els_scr {
457 __u8 scr_cmd; /* command code */
458 __u8 scr_resv[6]; /* reserved */
459 __u8 scr_reg_func; /* registration function (see below) */
460};
461
462enum fc_els_scr_func {
463 ELS_SCRF_FAB = 1, /* fabric-detected registration */
464 ELS_SCRF_NPORT = 2, /* Nx_Port-detected registration */
465 ELS_SCRF_FULL = 3, /* full registration */
466 ELS_SCRF_CLEAR = 255, /* remove any current registrations */
467};
468
469/*
470 * ELS_RSCN - registered state change notification payload.
471 */
472struct fc_els_rscn {
473 __u8 rscn_cmd; /* RSCN opcode (0x61) */
474 __u8 rscn_page_len; /* page length (4) */
475 __be16 rscn_plen; /* payload length including this word */
476
477 /* followed by 4-byte generic affected Port_ID pages */
478};
479
480struct fc_els_rscn_page {
481 __u8 rscn_page_flags; /* event and address format */
482 __u8 rscn_fid[3]; /* fabric ID */
483};
484
485#define ELS_RSCN_EV_QUAL_BIT 2 /* shift count for event qualifier */
486#define ELS_RSCN_EV_QUAL_MASK 0xf /* mask for event qualifier */
487#define ELS_RSCN_ADDR_FMT_BIT 0 /* shift count for address format */
488#define ELS_RSCN_ADDR_FMT_MASK 0x3 /* mask for address format */
489
490enum fc_els_rscn_ev_qual {
491 ELS_EV_QUAL_NONE = 0, /* unspecified */
492 ELS_EV_QUAL_NS_OBJ = 1, /* changed name server object */
493 ELS_EV_QUAL_PORT_ATTR = 2, /* changed port attribute */
494 ELS_EV_QUAL_SERV_OBJ = 3, /* changed service object */
495 ELS_EV_QUAL_SW_CONFIG = 4, /* changed switch configuration */
496 ELS_EV_QUAL_REM_OBJ = 5, /* removed object */
497};
498
499enum fc_els_rscn_addr_fmt {
500 ELS_ADDR_FMT_PORT = 0, /* rscn_fid is a port address */
501 ELS_ADDR_FMT_AREA = 1, /* rscn_fid is a area address */
502 ELS_ADDR_FMT_DOM = 2, /* rscn_fid is a domain address */
503 ELS_ADDR_FMT_FAB = 3, /* anything on fabric may have changed */
504};
505
506/*
507 * ELS_RNID - request Node ID.
508 */
509struct fc_els_rnid {
510 __u8 rnid_cmd; /* RNID opcode (0x78) */
511 __u8 rnid_resv[3]; /* reserved */
512 __u8 rnid_fmt; /* data format */
513 __u8 rnid_resv2[3]; /* reserved */
514};
515
516/*
517 * Node Identification Data formats (rnid_fmt)
518 */
519enum fc_els_rnid_fmt {
520 ELS_RNIDF_NONE = 0, /* no specific identification data */
521 ELS_RNIDF_GEN = 0xdf, /* general topology discovery format */
522};
523
524/*
525 * ELS_RNID response.
526 */
527struct fc_els_rnid_resp {
528 __u8 rnid_cmd; /* response code (LS_ACC) */
529 __u8 rnid_resv[3]; /* reserved */
530 __u8 rnid_fmt; /* data format */
531 __u8 rnid_cid_len; /* common ID data length */
532 __u8 rnid_resv2; /* reserved */
533 __u8 rnid_sid_len; /* specific ID data length */
534};
535
536struct fc_els_rnid_cid {
537 __be64 rnid_wwpn; /* N port name */
538 __be64 rnid_wwnn; /* node name */
539};
540
541struct fc_els_rnid_gen {
542 __u8 rnid_vend_id[16]; /* vendor-unique ID */
543 __be32 rnid_atype; /* associated type (see below) */
544 __be32 rnid_phys_port; /* physical port number */
545 __be32 rnid_att_nodes; /* number of attached nodes */
546 __u8 rnid_node_mgmt; /* node management (see below) */
547 __u8 rnid_ip_ver; /* IP version (see below) */
548 __be16 rnid_prot_port; /* UDP / TCP port number */
549 __be32 rnid_ip_addr[4]; /* IP address */
550 __u8 rnid_resvd[2]; /* reserved */
551 __be16 rnid_vend_spec; /* vendor-specific field */
552};
553
554enum fc_els_rnid_atype {
555 ELS_RNIDA_UNK = 0x01, /* unknown */
556 ELS_RNIDA_OTHER = 0x02, /* none of the following */
557 ELS_RNIDA_HUB = 0x03,
558 ELS_RNIDA_SWITCH = 0x04,
559 ELS_RNIDA_GATEWAY = 0x05,
560 ELS_RNIDA_CONV = 0x06, /* Obsolete, do not use this value */
561 ELS_RNIDA_HBA = 0x07, /* Obsolete, do not use this value */
562 ELS_RNIDA_PROXY = 0x08, /* Obsolete, do not use this value */
563 ELS_RNIDA_STORAGE = 0x09,
564 ELS_RNIDA_HOST = 0x0a,
565 ELS_RNIDA_SUBSYS = 0x0b, /* storage subsystem (e.g., RAID) */
566 ELS_RNIDA_ACCESS = 0x0e, /* access device (e.g. media changer) */
567 ELS_RNIDA_NAS = 0x11, /* NAS server */
568 ELS_RNIDA_BRIDGE = 0x12, /* bridge */
569 ELS_RNIDA_VIRT = 0x13, /* virtualization device */
570 ELS_RNIDA_MF = 0xff, /* multifunction device (bits below) */
571 ELS_RNIDA_MF_HUB = 1UL << 31, /* hub */
572 ELS_RNIDA_MF_SW = 1UL << 30, /* switch */
573 ELS_RNIDA_MF_GW = 1UL << 29, /* gateway */
574 ELS_RNIDA_MF_ST = 1UL << 28, /* storage */
575 ELS_RNIDA_MF_HOST = 1UL << 27, /* host */
576 ELS_RNIDA_MF_SUB = 1UL << 26, /* storage subsystem */
577 ELS_RNIDA_MF_ACC = 1UL << 25, /* storage access dev */
578 ELS_RNIDA_MF_WDM = 1UL << 24, /* wavelength division mux */
579 ELS_RNIDA_MF_NAS = 1UL << 23, /* NAS server */
580 ELS_RNIDA_MF_BR = 1UL << 22, /* bridge */
581 ELS_RNIDA_MF_VIRT = 1UL << 21, /* virtualization device */
582};
583
584enum fc_els_rnid_mgmt {
585 ELS_RNIDM_SNMP = 0,
586 ELS_RNIDM_TELNET = 1,
587 ELS_RNIDM_HTTP = 2,
588 ELS_RNIDM_HTTPS = 3,
589 ELS_RNIDM_XML = 4, /* HTTP + XML */
590};
591
592enum fc_els_rnid_ipver {
593 ELS_RNIDIP_NONE = 0, /* no IP support or node mgmt. */
594 ELS_RNIDIP_V4 = 1, /* IPv4 */
595 ELS_RNIDIP_V6 = 2, /* IPv6 */
596};
597
598/*
599 * ELS RPL - Read Port List.
600 */
601struct fc_els_rpl {
602 __u8 rpl_cmd; /* command */
603 __u8 rpl_resv[5]; /* reserved - must be zero */
604 __be16 rpl_max_size; /* maximum response size or zero */
605 __u8 rpl_resv1; /* reserved - must be zero */
606 __u8 rpl_index[3]; /* starting index */
607};
608
609/*
610 * Port number block in RPL response.
611 */
612struct fc_els_pnb {
613 __be32 pnb_phys_pn; /* physical port number */
614 __u8 pnb_resv; /* reserved */
615 __u8 pnb_port_id[3]; /* port ID */
616 __be64 pnb_wwpn; /* port name */
617};
618
619/*
620 * RPL LS_ACC response.
621 */
622struct fc_els_rpl_resp {
623 __u8 rpl_cmd; /* ELS_LS_ACC */
624 __u8 rpl_resv1; /* reserved - must be zero */
625 __be16 rpl_plen; /* payload length */
626 __u8 rpl_resv2; /* reserved - must be zero */
627 __u8 rpl_llen[3]; /* list length */
628 __u8 rpl_resv3; /* reserved - must be zero */
629 __u8 rpl_index[3]; /* starting index */
630 struct fc_els_pnb rpl_pnb[1]; /* variable number of PNBs */
631};
632
633/*
634 * Link Error Status Block.
635 */
636struct fc_els_lesb {
637 __be32 lesb_link_fail; /* link failure count */
638 __be32 lesb_sync_loss; /* loss of synchronization count */
639 __be32 lesb_sig_loss; /* loss of signal count */
640 __be32 lesb_prim_err; /* primitive sequence error count */
641 __be32 lesb_inv_word; /* invalid transmission word count */
642 __be32 lesb_inv_crc; /* invalid CRC count */
643};
644
645/*
646 * ELS RPS - Read Port Status Block request.
647 */
648struct fc_els_rps {
649 __u8 rps_cmd; /* command */
650 __u8 rps_resv[2]; /* reserved - must be zero */
651 __u8 rps_flag; /* flag - see below */
652 __be64 rps_port_spec; /* port selection */
653};
654
655enum fc_els_rps_flag {
656 FC_ELS_RPS_DID = 0x00, /* port identified by D_ID of req. */
657 FC_ELS_RPS_PPN = 0x01, /* port_spec is physical port number */
658 FC_ELS_RPS_WWPN = 0x02, /* port_spec is port WWN */
659};
660
661/*
662 * ELS RPS LS_ACC response.
663 */
664struct fc_els_rps_resp {
665 __u8 rps_cmd; /* command - LS_ACC */
666 __u8 rps_resv[2]; /* reserved - must be zero */
667 __u8 rps_flag; /* flag - see below */
668 __u8 rps_resv2[2]; /* reserved */
669 __be16 rps_status; /* port status - see below */
670 struct fc_els_lesb rps_lesb; /* link error status block */
671};
672
673enum fc_els_rps_resp_flag {
674 FC_ELS_RPS_LPEV = 0x01, /* L_port extension valid */
675};
676
677enum fc_els_rps_resp_status {
678 FC_ELS_RPS_PTP = 1 << 5, /* point-to-point connection */
679 FC_ELS_RPS_LOOP = 1 << 4, /* loop mode */
680 FC_ELS_RPS_FAB = 1 << 3, /* fabric present */
681 FC_ELS_RPS_NO_SIG = 1 << 2, /* loss of signal */
682 FC_ELS_RPS_NO_SYNC = 1 << 1, /* loss of synchronization */
683 FC_ELS_RPS_RESET = 1 << 0, /* in link reset protocol */
684};
685
686/*
687 * ELS LIRR - Link Incident Record Registration request.
688 */
689struct fc_els_lirr {
690 __u8 lirr_cmd; /* command */
691 __u8 lirr_resv[3]; /* reserved - must be zero */
692 __u8 lirr_func; /* registration function */
693 __u8 lirr_fmt; /* FC-4 type of RLIR requested */
694 __u8 lirr_resv2[2]; /* reserved - must be zero */
695};
696
697enum fc_els_lirr_func {
698 ELS_LIRR_SET_COND = 0x01, /* set - conditionally receive */
699 ELS_LIRR_SET_UNCOND = 0x02, /* set - unconditionally receive */
700 ELS_LIRR_CLEAR = 0xff /* clear registration */
701};
702
703/*
704 * ELS SRL - Scan Remote Loop request.
705 */
706struct fc_els_srl {
707 __u8 srl_cmd; /* command */
708 __u8 srl_resv[3]; /* reserved - must be zero */
709 __u8 srl_flag; /* flag - see below */
710 __u8 srl_flag_param[3]; /* flag parameter */
711};
712
713enum fc_els_srl_flag {
714 FC_ELS_SRL_ALL = 0x00, /* scan all FL ports */
715 FC_ELS_SRL_ONE = 0x01, /* scan specified loop */
716 FC_ELS_SRL_EN_PER = 0x02, /* enable periodic scanning (param) */
717 FC_ELS_SRL_DIS_PER = 0x03, /* disable periodic scanning */
718};
719
720/*
721 * ELS RLS - Read Link Error Status Block request.
722 */
723struct fc_els_rls {
724 __u8 rls_cmd; /* command */
725 __u8 rls_resv[4]; /* reserved - must be zero */
726 __u8 rls_port_id[3]; /* port ID */
727};
728
729/*
730 * ELS RLS LS_ACC Response.
731 */
732struct fc_els_rls_resp {
733 __u8 rls_cmd; /* ELS_LS_ACC */
734 __u8 rls_resv[3]; /* reserved - must be zero */
735 struct fc_els_lesb rls_lesb; /* link error status block */
736};
737
738/*
739 * ELS RLIR - Registered Link Incident Report.
740 * This is followed by the CLIR and the CLID, described below.
741 */
742struct fc_els_rlir {
743 __u8 rlir_cmd; /* command */
744 __u8 rlir_resv[3]; /* reserved - must be zero */
745 __u8 rlir_fmt; /* format (FC4-type if type specific) */
746 __u8 rlir_clr_len; /* common link incident record length */
747 __u8 rlir_cld_len; /* common link incident desc. length */
748 __u8 rlir_slr_len; /* spec. link incident record length */
749};
750
751/*
752 * CLIR - Common Link Incident Record Data. - Sent via RLIR.
753 */
754struct fc_els_clir {
755 __be64 clir_wwpn; /* incident port name */
756 __be64 clir_wwnn; /* incident port node name */
757 __u8 clir_port_type; /* incident port type */
758 __u8 clir_port_id[3]; /* incident port ID */
759
760 __be64 clir_conn_wwpn; /* connected port name */
761 __be64 clir_conn_wwnn; /* connected node name */
762 __be64 clir_fab_name; /* fabric name */
763 __be32 clir_phys_port; /* physical port number */
764 __be32 clir_trans_id; /* transaction ID */
765 __u8 clir_resv[3]; /* reserved */
766 __u8 clir_ts_fmt; /* time stamp format */
767 __be64 clir_timestamp; /* time stamp */
768};
769
770/*
771 * CLIR clir_ts_fmt - time stamp format values.
772 */
773enum fc_els_clir_ts_fmt {
774 ELS_CLIR_TS_UNKNOWN = 0, /* time stamp field unknown */
775 ELS_CLIR_TS_SEC_FRAC = 1, /* time in seconds and fractions */
776 ELS_CLIR_TS_CSU = 2, /* time in clock synch update format */
777};
778
779/*
780 * Common Link Incident Descriptor - sent via RLIR.
781 */
782struct fc_els_clid {
783 __u8 clid_iq; /* incident qualifier flags */
784 __u8 clid_ic; /* incident code */
785 __be16 clid_epai; /* domain/area of ISL */
786};
787
788/*
789 * CLID incident qualifier flags.
790 */
791enum fc_els_clid_iq {
792 ELS_CLID_SWITCH = 0x20, /* incident port is a switch node */
793 ELS_CLID_E_PORT = 0x10, /* incident is an ISL (E) port */
794 ELS_CLID_SEV_MASK = 0x0c, /* severity 2-bit field mask */
795 ELS_CLID_SEV_INFO = 0x00, /* report is informational */
796 ELS_CLID_SEV_INOP = 0x08, /* link not operational */
797 ELS_CLID_SEV_DEG = 0x04, /* link degraded but operational */
798 ELS_CLID_LASER = 0x02, /* subassembly is a laser */
799 ELS_CLID_FRU = 0x01, /* format can identify a FRU */
800};
801
802/*
803 * CLID incident code.
804 */
805enum fc_els_clid_ic {
806 ELS_CLID_IC_IMPL = 1, /* implicit incident */
807 ELS_CLID_IC_BER = 2, /* bit-error-rate threshold exceeded */
808 ELS_CLID_IC_LOS = 3, /* loss of synch or signal */
809 ELS_CLID_IC_NOS = 4, /* non-operational primitive sequence */
810 ELS_CLID_IC_PST = 5, /* primitive sequence timeout */
811 ELS_CLID_IC_INVAL = 6, /* invalid primitive sequence */
812 ELS_CLID_IC_LOOP_TO = 7, /* loop initialization time out */
813 ELS_CLID_IC_LIP = 8, /* receiving LIP */
814};
815
816#endif /* _FC_ELS_H_ */
diff --git a/include/scsi/fc/fc_encaps.h b/include/scsi/fc/fc_encaps.h
new file mode 100644
index 000000000000..f180c3e16220
--- /dev/null
+++ b/include/scsi/fc/fc_encaps.h
@@ -0,0 +1,138 @@
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#ifndef _FC_ENCAPS_H_
20#define _FC_ENCAPS_H_
21
22/*
23 * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation.
24 *
25 * Note: The frame length field is the number of 32-bit words in
26 * the encapsulation including the fcip_encaps_header, CRC and EOF words.
27 * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64.
28 * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172.
29 */
30#define FC_ENCAPS_MIN_FRAME_LEN 64 /* min frame len (bytes) (see above) */
31#define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)
32
33#define FC_ENCAPS_VER 1 /* current version number */
34
35struct fc_encaps_hdr {
36 __u8 fc_proto; /* protocol number */
37 __u8 fc_ver; /* version of encapsulation */
38 __u8 fc_proto_n; /* ones complement of protocol */
39 __u8 fc_ver_n; /* ones complement of version */
40
41 unsigned char fc_proto_data[8]; /* protocol specific data */
42
43 __be16 fc_len_flags; /* 10-bit length/4 w/ 6 flag bits */
44 __be16 fc_len_flags_n; /* ones complement of length / flags */
45
46 /*
47 * Offset 0x10
48 */
49 __be32 fc_time[2]; /* time stamp: seconds and fraction */
50 __be32 fc_crc; /* CRC */
51 __be32 fc_sof; /* start of frame (see FC_SOF below) */
52
53 /* 0x20 - FC frame content followed by EOF word */
54};
55
56#define FCIP_ENCAPS_HDR_LEN 0x20 /* expected length for asserts */
57
58/*
59 * Macro's for making redundant copies of EOF and SOF.
60 */
61#define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff))
62#define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))
63#define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff)
64
65#define FC_SOF_ENCODE(n) FC_XYNN(n, n)
66#define FC_EOF_ENCODE(n) FC_XYNN(n, n)
67
68/*
69 * SOF / EOF bytes.
70 */
71enum fc_sof {
72 FC_SOF_F = 0x28, /* fabric */
73 FC_SOF_I4 = 0x29, /* initiate class 4 */
74 FC_SOF_I2 = 0x2d, /* initiate class 2 */
75 FC_SOF_I3 = 0x2e, /* initiate class 3 */
76 FC_SOF_N4 = 0x31, /* normal class 4 */
77 FC_SOF_N2 = 0x35, /* normal class 2 */
78 FC_SOF_N3 = 0x36, /* normal class 3 */
79 FC_SOF_C4 = 0x39, /* activate class 4 */
80} __attribute__((packed));
81
82enum fc_eof {
83 FC_EOF_N = 0x41, /* normal (not last frame of seq) */
84 FC_EOF_T = 0x42, /* terminate (last frame of sequence) */
85 FC_EOF_RT = 0x44,
86 FC_EOF_DT = 0x46, /* disconnect-terminate class-1 */
87 FC_EOF_NI = 0x49, /* normal-invalid */
88 FC_EOF_DTI = 0x4e, /* disconnect-terminate-invalid */
89 FC_EOF_RTI = 0x4f,
90 FC_EOF_A = 0x50, /* abort */
91} __attribute__((packed));
92
93#define FC_SOF_CLASS_MASK 0x06 /* mask for class of service in SOF */
94
95/*
96 * Define classes in terms of the SOF code (initial).
97 */
98enum fc_class {
99 FC_CLASS_NONE = 0, /* software value indicating no class */
100 FC_CLASS_2 = FC_SOF_I2,
101 FC_CLASS_3 = FC_SOF_I3,
102 FC_CLASS_4 = FC_SOF_I4,
103 FC_CLASS_F = FC_SOF_F,
104};
105
106/*
107 * Determine whether SOF code indicates the need for a BLS ACK.
108 */
109static inline int fc_sof_needs_ack(enum fc_sof sof)
110{
111 return (~sof) & 0x02; /* true for class 1, 2, 4, 6, or F */
112}
113
114/*
115 * Given an fc_class, return the normal (non-initial) SOF value.
116 */
117static inline enum fc_sof fc_sof_normal(enum fc_class class)
118{
119 return class + FC_SOF_N3 - FC_SOF_I3; /* diff is always 8 */
120}
121
122/*
123 * Compute class from SOF value.
124 */
125static inline enum fc_class fc_sof_class(enum fc_sof sof)
126{
127 return (sof & 0x7) | FC_SOF_F;
128}
129
130/*
131 * Determine whether SOF is for the initial frame of a sequence.
132 */
133static inline int fc_sof_is_init(enum fc_sof sof)
134{
135 return sof < 0x30;
136}
137
138#endif /* _FC_ENCAPS_H_ */
diff --git a/include/scsi/fc/fc_fc2.h b/include/scsi/fc/fc_fc2.h
new file mode 100644
index 000000000000..cff8a8c22f50
--- /dev/null
+++ b/include/scsi/fc/fc_fc2.h
@@ -0,0 +1,124 @@
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_FC2_H_
21#define _FC_FC2_H_
22
23/*
24 * Fibre Channel Exchanges and Sequences.
25 */
26#ifndef PACKED
27#define PACKED __attribute__ ((__packed__))
28#endif /* PACKED */
29
30
31/*
32 * Sequence Status Block.
33 * This format is set by the FC-FS standard and is sent over the wire.
34 * Note that the fields aren't all naturally aligned.
35 */
36struct fc_ssb {
37 __u8 ssb_seq_id; /* sequence ID */
38 __u8 _ssb_resvd;
39 __be16 ssb_low_seq_cnt; /* lowest SEQ_CNT */
40
41 __be16 ssb_high_seq_cnt; /* highest SEQ_CNT */
42 __be16 ssb_s_stat; /* sequence status flags */
43
44 __be16 ssb_err_seq_cnt; /* error SEQ_CNT */
45 __u8 ssb_fh_cs_ctl; /* frame header CS_CTL */
46 __be16 ssb_fh_ox_id; /* frame header OX_ID */
47 __be16 ssb_rx_id; /* responder's exchange ID */
48 __u8 _ssb_resvd2[2];
49} PACKED;
50
51/*
52 * The SSB should be 17 bytes. Since it's layout is somewhat strange,
53 * we define the size here so that code can ASSERT that the size comes out
54 * correct.
55 */
56#define FC_SSB_SIZE 17 /* length of fc_ssb for assert */
57
58/*
59 * ssb_s_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
60 */
61#define SSB_ST_RESP (1 << 15) /* sequence responder */
62#define SSB_ST_ACTIVE (1 << 14) /* sequence is active */
63#define SSB_ST_ABNORMAL (1 << 12) /* abnormal ending condition */
64
65#define SSB_ST_REQ_MASK (3 << 10) /* ACK, abort sequence condition */
66#define SSB_ST_REQ_CONT (0 << 10)
67#define SSB_ST_REQ_ABORT (1 << 10)
68#define SSB_ST_REQ_STOP (2 << 10)
69#define SSB_ST_REQ_RETRANS (3 << 10)
70
71#define SSB_ST_ABTS (1 << 9) /* ABTS protocol completed */
72#define SSB_ST_RETRANS (1 << 8) /* retransmission completed */
73#define SSB_ST_TIMEOUT (1 << 7) /* sequence timed out by recipient */
74#define SSB_ST_P_RJT (1 << 6) /* P_RJT transmitted */
75
76#define SSB_ST_CLASS_BIT 4 /* class of service field LSB */
77#define SSB_ST_CLASS_MASK 3 /* class of service mask */
78#define SSB_ST_ACK (1 << 3) /* ACK (EOFt or EOFdt) transmitted */
79
80/*
81 * Exchange Status Block.
82 * This format is set by the FC-FS standard and is sent over the wire.
83 * Note that the fields aren't all naturally aligned.
84 */
85struct fc_esb {
86 __u8 esb_cs_ctl; /* CS_CTL for frame header */
87 __be16 esb_ox_id; /* originator exchange ID */
88 __be16 esb_rx_id; /* responder exchange ID */
89 __be32 esb_orig_fid; /* fabric ID of originator */
90 __be32 esb_resp_fid; /* fabric ID of responder */
91 __be32 esb_e_stat; /* status */
92 __u8 _esb_resvd[4];
93 __u8 esb_service_params[112]; /* TBD */
94 __u8 esb_seq_status[8]; /* sequence statuses, 8 bytes each */
95} __attribute__((packed));;
96
97
98/*
99 * Define expected size for ASSERTs.
100 * See comments on FC_SSB_SIZE.
101 */
102#define FC_ESB_SIZE (1 + 5*4 + 112 + 8) /* expected size */
103
104/*
105 * esb_e_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
106 */
107#define ESB_ST_RESP (1 << 31) /* responder to exchange */
108#define ESB_ST_SEQ_INIT (1 << 30) /* port holds sequence initiaive */
109#define ESB_ST_COMPLETE (1 << 29) /* exchange is complete */
110#define ESB_ST_ABNORMAL (1 << 28) /* abnormal ending condition */
111#define ESB_ST_REC_QUAL (1 << 26) /* recovery qualifier active */
112
113#define ESB_ST_ERRP_BIT 24 /* LSB for error policy */
114#define ESB_ST_ERRP_MASK (3 << 24) /* mask for error policy */
115#define ESB_ST_ERRP_MULT (0 << 24) /* abort, discard multiple sequences */
116#define ESB_ST_ERRP_SING (1 << 24) /* abort, discard single sequence */
117#define ESB_ST_ERRP_INF (2 << 24) /* process with infinite buffers */
118#define ESB_ST_ERRP_IMM (3 << 24) /* discard mult. with immed. retran. */
119
120#define ESB_ST_OX_ID_INVL (1 << 23) /* originator XID invalid */
121#define ESB_ST_RX_ID_INVL (1 << 22) /* responder XID invalid */
122#define ESB_ST_PRI_INUSE (1 << 21) /* priority / preemption in use */
123
124#endif /* _FC_FC2_H_ */
diff --git a/include/scsi/fc/fc_fcoe.h b/include/scsi/fc/fc_fcoe.h
new file mode 100644
index 000000000000..57aaa8f0d613
--- /dev/null
+++ b/include/scsi/fc/fc_fcoe.h
@@ -0,0 +1,114 @@
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_FCOE_H_
21#define _FC_FCOE_H_
22
23/*
24 * FCoE - Fibre Channel over Ethernet.
25 */
26
27/*
28 * The FCoE ethertype eventually goes in net/if_ether.h.
29 */
30#ifndef ETH_P_FCOE
31#define ETH_P_FCOE 0x8906 /* FCOE ether type */
32#endif
33
34#ifndef ETH_P_8021Q
35#define ETH_P_8021Q 0x8100
36#endif
37
38/*
39 * FC_FCOE_OUI hasn't been standardized yet. XXX TBD.
40 */
41#ifndef FC_FCOE_OUI
42#define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE dest MAC TBD */
43#endif
44
45/*
46 * The destination MAC address for the fabric login may get a different OUI.
47 * This isn't standardized yet.
48 */
49#ifndef FC_FCOE_FLOGI_MAC
50/* gateway MAC - TBD */
51#define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
52#endif
53
54#define FC_FCOE_VER 0 /* version */
55
56/*
57 * Ethernet Addresses based on FC S_ID and D_ID.
58 * Generated by FC_FCOE_OUI | S_ID/D_ID
59 */
60#define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))
61#define FC_FCOE_DECAPS_ID(n) ((n) >> 24)
62
63/*
64 * FCoE frame header - 14 bytes
65 *
66 * This is the August 2007 version of the FCoE header as defined by T11.
67 * This follows the VLAN header, which includes the ethertype.
68 */
69struct fcoe_hdr {
70 __u8 fcoe_ver; /* version field - upper 4 bits */
71 __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */
72 __u8 fcoe_sof; /* start of frame per RFC 3643 */
73};
74
75#define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)
76#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
77
78/*
79 * FCoE CRC & EOF - 8 bytes.
80 */
81struct fcoe_crc_eof {
82 __le32 fcoe_crc32; /* CRC for FC packet */
83 __u8 fcoe_eof; /* EOF from RFC 3643 */
84 __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */
85} __attribute__((packed));
86
87/*
88 * Minimum FCoE + FC header length
89 * 14 bytes FCoE header + 24 byte FC header = 38 bytes
90 */
91#define FCOE_HEADER_LEN 38
92
93/*
94 * Minimum FCoE frame size
95 * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
96 */
97#define FCOE_MIN_FRAME 46
98
99/*
100 * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
101 * @mac: mac address to be set
102 * @did: fc dest id to use
103 */
104static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
105{
106 mac[0] = (u8) (FC_FCOE_OUI >> 16);
107 mac[1] = (u8) (FC_FCOE_OUI >> 8);
108 mac[2] = (u8) FC_FCOE_OUI;
109 mac[3] = did[0];
110 mac[4] = did[1];
111 mac[5] = did[2];
112}
113
114#endif /* _FC_FCOE_H_ */
diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h
new file mode 100644
index 000000000000..5d38f1989f37
--- /dev/null
+++ b/include/scsi/fc/fc_fcp.h
@@ -0,0 +1,199 @@
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_FCP_H_
21#define _FC_FCP_H_
22
23/*
24 * Fibre Channel Protocol for SCSI.
25 * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005.
26 */
27
28/*
29 * fc/fs.h defines FC_TYPE_FCP.
30 */
31
32/*
33 * Service parameter page parameters (word 3 bits) for Process Login.
34 */
35#define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */
36#define FCP_SPPF_RETRY 0x0100 /* retry supported */
37#define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */
38#define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */
39#define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */
40#define FCP_SPPF_TARG_FCN 0x0010 /* target function */
41#define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */
42#define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */
43
44/*
45 * FCP_CMND IU Payload.
46 */
47struct fcp_cmnd {
48 __u8 fc_lun[8]; /* logical unit number */
49 __u8 fc_cmdref; /* commmand reference number */
50 __u8 fc_pri_ta; /* priority and task attribute */
51 __u8 fc_tm_flags; /* task management flags */
52 __u8 fc_flags; /* additional len & flags */
53 __u8 fc_cdb[16]; /* base CDB */
54 __be32 fc_dl; /* data length (must follow fc_cdb) */
55};
56
57#define FCP_CMND_LEN 32 /* expected length of structure */
58
59struct fcp_cmnd32 {
60 __u8 fc_lun[8]; /* logical unit number */
61 __u8 fc_cmdref; /* commmand reference number */
62 __u8 fc_pri_ta; /* priority and task attribute */
63 __u8 fc_tm_flags; /* task management flags */
64 __u8 fc_flags; /* additional len & flags */
65 __u8 fc_cdb[32]; /* base CDB */
66 __be32 fc_dl; /* data length (must follow fc_cdb) */
67};
68
69#define FCP_CMND32_LEN 48 /* expected length of structure */
70#define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */
71
72/*
73 * fc_pri_ta.
74 */
75#define FCP_PTA_SIMPLE 0 /* simple task attribute */
76#define FCP_PTA_HEADQ 1 /* head of queue task attribute */
77#define FCP_PTA_ORDERED 2 /* ordered task attribute */
78#define FCP_PTA_ACA 4 /* auto. contigent allegiance */
79#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */
80#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */
81
82/*
83 * fc_tm_flags - task management flags field.
84 */
85#define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */
86#define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */
87#define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */
88#define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */
89
90/*
91 * fc_flags.
92 * Bits 7:2 are the additional FCP_CDB length / 4.
93 */
94#define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */
95#define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */
96#define FCP_CFL_RDDATA 0x02 /* read data */
97#define FCP_CFL_WRDATA 0x01 /* write data */
98
99/*
100 * FCP_TXRDY IU - transfer ready payload.
101 */
102struct fcp_txrdy {
103 __be32 ft_data_ro; /* data relative offset */
104 __be32 ft_burst_len; /* burst length */
105 __u8 _ft_resvd[4]; /* reserved */
106};
107
108#define FCP_TXRDY_LEN 12 /* expected length of structure */
109
110/*
111 * FCP_RESP IU - response payload.
112 *
113 * The response payload comes in three parts: the flags/status, the
114 * sense/response lengths and the sense data/response info section.
115 *
116 * From FCP3r04, note 6 of section 9.5.13:
117 *
118 * Some early implementations presented the FCP_RSP IU without the FCP_RESID,
119 * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER,
120 * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This
121 * non-standard behavior should be tolerated.
122 *
123 * All response frames will always contain the fcp_resp template. Some
124 * will also include the fcp_resp_len template.
125 */
126struct fcp_resp {
127 __u8 _fr_resvd[8]; /* reserved */
128 __be16 fr_retry_delay; /* retry delay timer */
129 __u8 fr_flags; /* flags */
130 __u8 fr_status; /* SCSI status code */
131};
132
133#define FCP_RESP_LEN 12 /* expected length of structure */
134
135struct fcp_resp_ext {
136 __be32 fr_resid; /* Residual value */
137 __be32 fr_sns_len; /* SCSI Sense length */
138 __be32 fr_rsp_len; /* Response Info length */
139
140 /*
141 * Optionally followed by RSP info and/or SNS info and/or
142 * bidirectional read residual length, if any.
143 */
144};
145
146#define FCP_RESP_EXT_LEN 12 /* expected length of the structure */
147
148struct fcp_resp_rsp_info {
149 __u8 _fr_resvd[3]; /* reserved */
150 __u8 rsp_code; /* Response Info Code */
151 __u8 _fr_resvd2[4]; /* reserved */
152};
153
154struct fcp_resp_with_ext {
155 struct fcp_resp resp;
156 struct fcp_resp_ext ext;
157};
158
159#define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN)
160
161/*
162 * fr_flags.
163 */
164#define FCP_BIDI_RSP 0x80 /* bidirectional read response */
165#define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */
166#define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */
167#define FCP_CONF_REQ 0x10 /* confirmation requested */
168#define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */
169#define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */
170#define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */
171#define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */
172
173/*
174 * rsp_codes
175 */
176enum fcp_resp_rsp_codes {
177 FCP_TMF_CMPL = 0,
178 FCP_DATA_LEN_INVALID = 1,
179 FCP_CMND_FIELDS_INVALID = 2,
180 FCP_DATA_PARAM_MISMATCH = 3,
181 FCP_TMF_REJECTED = 4,
182 FCP_TMF_FAILED = 5,
183 FCP_TMF_INVALID_LUN = 9,
184};
185
186/*
187 * FCP SRR Link Service request - Sequence Retransmission Request.
188 */
189struct fcp_srr {
190 __u8 srr_op; /* opcode ELS_SRR */
191 __u8 srr_resvd[3]; /* opcode / reserved - must be zero */
192 __be16 srr_ox_id; /* OX_ID of failed command */
193 __be16 srr_rx_id; /* RX_ID of failed command */
194 __be32 srr_rel_off; /* relative offset */
195 __u8 srr_r_ctl; /* r_ctl for the information unit */
196 __u8 srr_resvd2[3]; /* reserved */
197};
198
199#endif /* _FC_FCP_H_ */
diff --git a/include/scsi/fc/fc_fs.h b/include/scsi/fc/fc_fs.h
new file mode 100644
index 000000000000..3e4801d2bdbb
--- /dev/null
+++ b/include/scsi/fc/fc_fs.h
@@ -0,0 +1,340 @@
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 */
31struct 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 */
64enum 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 */
151enum fc_well_known_fid {
152 FC_FID_BCAST = 0xffffff, /* broadcast */
153 FC_FID_FLOGI = 0xfffffe, /* fabric login */
154 FC_FID_FCTRL = 0xfffffd, /* fabric controller */
155 FC_FID_DIR_SERV = 0xfffffc, /* directory server */
156 FC_FID_TIME_SERV = 0xfffffb, /* time server */
157 FC_FID_MGMT_SERV = 0xfffffa, /* management server */
158 FC_FID_QOS = 0xfffff9, /* QoS Facilitator */
159 FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */
160 FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */
161 FC_FID_CLOCK = 0xfffff6, /* clock synch server */
162 FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */
163};
164
165#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */
166#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */
167
168/*
169 * Other well-known addresses, outside the above contiguous range.
170 */
171#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */
172
173/*
174 * Fabric ID bytes.
175 */
176#define FC_FID_DOMAIN 0
177#define FC_FID_PORT 1
178#define FC_FID_LINK 2
179
180/*
181 * fh_type codes
182 */
183enum fc_fh_type {
184 FC_TYPE_BLS = 0x00, /* basic link service */
185 FC_TYPE_ELS = 0x01, /* extended link service */
186 FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */
187 FC_TYPE_FCP = 0x08, /* SCSI FCP */
188 FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */
189 FC_TYPE_ILS = 0x22, /* internal link service */
190};
191
192/*
193 * FC_TYPE names initializer.
194 * Please keep this matching the above definitions.
195 */
196#define FC_TYPE_NAMES_INIT { \
197 [FC_TYPE_BLS] = "BLS", \
198 [FC_TYPE_ELS] = "ELS", \
199 [FC_TYPE_IP] = "IP", \
200 [FC_TYPE_FCP] = "FCP", \
201 [FC_TYPE_CT] = "CT", \
202 [FC_TYPE_ILS] = "ILS", \
203}
204
205/*
206 * Exchange IDs.
207 */
208#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */
209#define FC_XID_MIN 0x0 /* supported min exchange ID */
210#define FC_XID_MAX 0xfffe /* supported max exchange ID */
211
212/*
213 * fh_f_ctl - Frame control flags.
214 */
215#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */
216#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */
217#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */
218#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */
219#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */
220#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */
221#define FC_FC_RES_B17 (1 << 17) /* reserved */
222#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */
223#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */
224#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */
225
226#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */
227#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */
228#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */
229
230#define FC_FC_RES_B11 (1 << 11) /* reserved */
231#define FC_FC_RES_B10 (1 << 10) /* reserved */
232#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */
233#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */
234#define FC_FC_CONT_SEQ(i) ((i) << 6)
235#define FC_FC_ABT_SEQ(i) ((i) << 4)
236#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */
237#define FC_FC_RES2 (1 << 2) /* reserved */
238#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */
239
240/*
241 * BA_ACC payload.
242 */
243struct fc_ba_acc {
244 __u8 ba_seq_id_val; /* SEQ_ID validity */
245#define FC_BA_SEQ_ID_VAL 0x80
246 __u8 ba_seq_id; /* SEQ_ID of seq last deliverable */
247 __u8 ba_resvd[2]; /* reserved */
248 __be16 ba_ox_id; /* OX_ID for aborted seq or exch */
249 __be16 ba_rx_id; /* RX_ID for aborted seq or exch */
250 __be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */
251 __be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
252};
253
254/*
255 * BA_RJT: Basic Reject payload.
256 */
257struct fc_ba_rjt {
258 __u8 br_resvd; /* reserved */
259 __u8 br_reason; /* reason code */
260 __u8 br_explan; /* reason explanation */
261 __u8 br_vendor; /* vendor unique code */
262};
263
264/*
265 * BA_RJT reason codes.
266 * From FS-2.
267 */
268enum fc_ba_rjt_reason {
269 FC_BA_RJT_NONE = 0, /* in software this means no reject */
270 FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */
271 FC_BA_RJT_LOG_ERR = 0x03, /* logical error */
272 FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */
273 FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */
274 FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */
275 FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */
276};
277
278/*
279 * BA_RJT reason code explanations.
280 */
281enum fc_ba_rjt_explan {
282 FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */
283 FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */
284 FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */
285};
286
287/*
288 * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
289 */
290struct fc_pf_rjt {
291 __u8 rj_action; /* reserved */
292 __u8 rj_reason; /* reason code */
293 __u8 rj_resvd; /* reserved */
294 __u8 rj_vendor; /* vendor unique code */
295};
296
297/*
298 * P_RJT and F_RJT reject reason codes.
299 */
300enum fc_pf_rjt_reason {
301 FC_RJT_NONE = 0, /* non-reject (reserved by standard) */
302 FC_RJT_INVL_DID = 0x01, /* invalid destination ID */
303 FC_RJT_INVL_SID = 0x02, /* invalid source ID */
304 FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */
305 FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */
306 FC_RJT_CLS_UNSUP = 0x05, /* class not supported */
307 FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */
308 FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */
309 FC_RJT_LINK_CTL = 0x08, /* invalid link control */
310 FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */
311 FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */
312 FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */
313 FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */
314 FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */
315 FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */
316 FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */
317 FC_RJT_PARAM = 0x10, /* invalid parameter field */
318 FC_RJT_EXCH_ERR = 0x11, /* exchange error */
319 FC_RJT_PROTO = 0x12, /* protocol error */
320 FC_RJT_LEN = 0x13, /* incorrect length */
321 FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */
322 FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */
323 FC_RJT_LOGI_REQ = 0x16, /* login required */
324 FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */
325 FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */
326 FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */
327 FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */
328 FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */
329 FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */
330 FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */
331 FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */
332 FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */
333 FC_RJT_MCAST_ERR = 0x22, /* multicast error */
334 FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */
335 FC_RJT_PRLI_REQ = 0x24, /* process login required */
336 FC_RJT_INVL_ATT = 0x25, /* invalid attachment */
337 FC_RJT_VENDOR = 0xff, /* vendor specific reject */
338};
339
340#endif /* _FC_FS_H_ */
diff --git a/include/scsi/fc/fc_gs.h b/include/scsi/fc/fc_gs.h
new file mode 100644
index 000000000000..ffab0272c65a
--- /dev/null
+++ b/include/scsi/fc/fc_gs.h
@@ -0,0 +1,93 @@
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_GS_H_
21#define _FC_GS_H_
22
23/*
24 * Fibre Channel Services - Common Transport.
25 * From T11.org FC-GS-2 Rev 5.3 November 1998.
26 */
27
28struct fc_ct_hdr {
29 __u8 ct_rev; /* revision */
30 __u8 ct_in_id[3]; /* N_Port ID of original requestor */
31 __u8 ct_fs_type; /* type of fibre channel service */
32 __u8 ct_fs_subtype; /* subtype */
33 __u8 ct_options;
34 __u8 _ct_resvd1;
35 __be16 ct_cmd; /* command / response code */
36 __be16 ct_mr_size; /* maximum / residual size */
37 __u8 _ct_resvd2;
38 __u8 ct_reason; /* reject reason */
39 __u8 ct_explan; /* reason code explanation */
40 __u8 ct_vendor; /* vendor unique data */
41};
42
43#define FC_CT_HDR_LEN 16 /* expected sizeof (struct fc_ct_hdr) */
44
45enum fc_ct_rev {
46 FC_CT_REV = 1 /* common transport revision */
47};
48
49/*
50 * ct_fs_type values.
51 */
52enum fc_ct_fs_type {
53 FC_FST_ALIAS = 0xf8, /* alias service */
54 FC_FST_MGMT = 0xfa, /* management service */
55 FC_FST_TIME = 0xfb, /* time service */
56 FC_FST_DIR = 0xfc, /* directory service */
57};
58
59/*
60 * ct_cmd: Command / response codes
61 */
62enum fc_ct_cmd {
63 FC_FS_RJT = 0x8001, /* reject */
64 FC_FS_ACC = 0x8002, /* accept */
65};
66
67/*
68 * FS_RJT reason codes.
69 */
70enum fc_ct_reason {
71 FC_FS_RJT_CMD = 0x01, /* invalid command code */
72 FC_FS_RJT_VER = 0x02, /* invalid version level */
73 FC_FS_RJT_LOG = 0x03, /* logical error */
74 FC_FS_RJT_IUSIZ = 0x04, /* invalid IU size */
75 FC_FS_RJT_BSY = 0x05, /* logical busy */
76 FC_FS_RJT_PROTO = 0x07, /* protocol error */
77 FC_FS_RJT_UNABL = 0x09, /* unable to perform command request */
78 FC_FS_RJT_UNSUP = 0x0b, /* command not supported */
79};
80
81/*
82 * FS_RJT reason code explanations.
83 */
84enum fc_ct_explan {
85 FC_FS_EXP_NONE = 0x00, /* no additional explanation */
86 FC_FS_EXP_PID = 0x01, /* port ID not registered */
87 FC_FS_EXP_PNAM = 0x02, /* port name not registered */
88 FC_FS_EXP_NNAM = 0x03, /* node name not registered */
89 FC_FS_EXP_COS = 0x04, /* class of service not registered */
90 /* definitions not complete */
91};
92
93#endif /* _FC_GS_H_ */
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h
new file mode 100644
index 000000000000..790d7b97d4bc
--- /dev/null
+++ b/include/scsi/fc/fc_ns.h
@@ -0,0 +1,159 @@
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_NS_H_
21#define _FC_NS_H_
22
23/*
24 * Fibre Channel Services - Name Service (dNS)
25 * From T11.org FC-GS-2 Rev 5.3 November 1998.
26 */
27
28/*
29 * Common-transport sub-type for Name Server.
30 */
31#define FC_NS_SUBTYPE 2 /* fs_ct_hdr.ct_fs_subtype */
32
33/*
34 * Name server Requests.
35 * Note: this is an incomplete list, some unused requests are omitted.
36 */
37enum fc_ns_req {
38 FC_NS_GA_NXT = 0x0100, /* get all next */
39 FC_NS_GI_A = 0x0101, /* get identifiers - scope */
40 FC_NS_GPN_ID = 0x0112, /* get port name by ID */
41 FC_NS_GNN_ID = 0x0113, /* get node name by ID */
42 FC_NS_GID_PN = 0x0121, /* get ID for port name */
43 FC_NS_GID_NN = 0x0131, /* get IDs for node name */
44 FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */
45 FC_NS_GPN_FT = 0x0172, /* get port names by FC4 type */
46 FC_NS_GID_PT = 0x01a1, /* get IDs by port type */
47 FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */
48 FC_NS_RPN_ID = 0x0212, /* reg port name for ID */
49 FC_NS_RNN_ID = 0x0213, /* reg node name for ID */
50};
51
52/*
53 * Port type values.
54 */
55enum fc_ns_pt {
56 FC_NS_UNID_PORT = 0x00, /* unidentified */
57 FC_NS_N_PORT = 0x01, /* N port */
58 FC_NS_NL_PORT = 0x02, /* NL port */
59 FC_NS_FNL_PORT = 0x03, /* F/NL port */
60 FC_NS_NX_PORT = 0x7f, /* Nx port */
61 FC_NS_F_PORT = 0x81, /* F port */
62 FC_NS_FL_PORT = 0x82, /* FL port */
63 FC_NS_E_PORT = 0x84, /* E port */
64 FC_NS_B_PORT = 0x85, /* B port */
65};
66
67/*
68 * Port type object.
69 */
70struct fc_ns_pt_obj {
71 __u8 pt_type;
72};
73
74/*
75 * Port ID object
76 */
77struct fc_ns_fid {
78 __u8 fp_flags; /* flags for responses only */
79 __u8 fp_fid[3];
80};
81
82/*
83 * fp_flags in port ID object, for responses only.
84 */
85#define FC_NS_FID_LAST 0x80 /* last object */
86
87/*
88 * FC4-types object.
89 */
90#define FC_NS_TYPES 256 /* number of possible FC-4 types */
91#define FC_NS_BPW 32 /* bits per word in bitmap */
92
93struct fc_ns_fts {
94 __be32 ff_type_map[FC_NS_TYPES / FC_NS_BPW]; /* bitmap of FC-4 types */
95};
96
97/*
98 * GID_PT request.
99 */
100struct fc_ns_gid_pt {
101 __u8 fn_pt_type;
102 __u8 fn_domain_id_scope;
103 __u8 fn_area_id_scope;
104 __u8 fn_resvd;
105};
106
107/*
108 * GID_FT or GPN_FT request.
109 */
110struct fc_ns_gid_ft {
111 __u8 fn_resvd;
112 __u8 fn_domain_id_scope;
113 __u8 fn_area_id_scope;
114 __u8 fn_fc4_type;
115};
116
117/*
118 * GPN_FT response.
119 */
120struct fc_gpn_ft_resp {
121 __u8 fp_flags; /* see fp_flags definitions above */
122 __u8 fp_fid[3]; /* port ID */
123 __be32 fp_resvd;
124 __be64 fp_wwpn; /* port name */
125};
126
127/*
128 * GID_PN request
129 */
130struct fc_ns_gid_pn {
131 __be64 fn_wwpn; /* port name */
132};
133
134/*
135 * GID_PN response
136 */
137struct fc_gid_pn_resp {
138 __u8 fp_resvd;
139 __u8 fp_fid[3]; /* port ID */
140};
141
142/*
143 * RFT_ID request - register FC-4 types for ID.
144 */
145struct fc_ns_rft_id {
146 struct fc_ns_fid fr_fid; /* port ID object */
147 struct fc_ns_fts fr_fts; /* FC-4 types object */
148};
149
150/*
151 * RPN_ID request - register port name for ID.
152 * RNN_ID request - register node name for ID.
153 */
154struct fc_ns_rn_id {
155 struct fc_ns_fid fr_fid; /* port ID object */
156 __be64 fr_wwn; /* node name or port name */
157} __attribute__((__packed__));
158
159#endif /* _FC_NS_H_ */