]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Hannes Reinecke <hare@suse.de> |
2 | Date: Wed, 17 Sep 2008 16:23:43 +0200 | |
3 | Subject: FC protocol definition header files | |
4 | References: FATE#303913 | |
5 | ||
6 | Signed-off-by: Robert Love <robert.w.love@intel.com> | |
7 | Signed-off-by: Chris Leech <christopher.leech@intel.com> | |
8 | Signed-off-by: Vasu Dev <vasu.dev@intel.com> | |
9 | Signed-off-by: Yi Zou <yi.zou@intel.com> | |
10 | Signed-off-by: Steve Ma <steve.ma@intel.com> | |
11 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
12 | --- | |
13 | include/scsi/fc/fc_els.h | 802 +++++++++++++++++++++++++++++++++++++++++ | |
14 | include/scsi/fc/fc_encaps.h | 138 +++++++ | |
15 | include/scsi/fc/fc_fc2.h | 124 +++++++ | |
16 | include/scsi/fc/fc_fcoe.h | 108 ++++++ | |
17 | include/scsi/fc/fc_fcp.h | 199 ++++++++++ | |
18 | include/scsi/fc/fc_fs.h | 344 ++++++++++++++++++ | |
19 | include/scsi/fc/fc_gs.h | 93 +++++ | |
20 | include/scsi/fc/fc_ns.h | 159 ++++++++ | |
21 | include/scsi/libfc/fc_frame.h | 236 ++++++++++++ | |
22 | include/scsi/libfc/libfc.h | 760 ++++++++++++++++++++++++++++++++++++++ | |
23 | 10 files changed, 2963 insertions(+), 0 deletions(-) | |
24 | create mode 100644 include/scsi/fc/fc_els.h | |
25 | create mode 100644 include/scsi/fc/fc_encaps.h | |
26 | create mode 100644 include/scsi/fc/fc_fc2.h | |
27 | create mode 100644 include/scsi/fc/fc_fcoe.h | |
28 | create mode 100644 include/scsi/fc/fc_fcp.h | |
29 | create mode 100644 include/scsi/fc/fc_fs.h | |
30 | create mode 100644 include/scsi/fc/fc_gs.h | |
31 | create mode 100644 include/scsi/fc/fc_ns.h | |
32 | create mode 100644 include/scsi/libfc/fc_frame.h | |
33 | create mode 100644 include/scsi/libfc/libfc.h | |
34 | ||
35 | diff --git a/include/scsi/fc/fc_els.h b/include/scsi/fc/fc_els.h | |
36 | new file mode 100644 | |
37 | index 0000000..af4bf0c | |
38 | --- /dev/null | |
39 | +++ b/include/scsi/fc/fc_els.h | |
40 | @@ -0,0 +1,802 @@ | |
41 | +/* | |
42 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
43 | + * | |
44 | + * This program is free software; you can redistribute it and/or modify it | |
45 | + * under the terms and conditions of the GNU General Public License, | |
46 | + * version 2, as published by the Free Software Foundation. | |
47 | + * | |
48 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
49 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
50 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
51 | + * more details. | |
52 | + * | |
53 | + * You should have received a copy of the GNU General Public License along with | |
54 | + * this program; if not, write to the Free Software Foundation, Inc., | |
55 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
56 | + * | |
57 | + * Maintained at www.Open-FCoE.org | |
58 | + */ | |
59 | + | |
60 | +#ifndef _FC_ELS_H_ | |
61 | +#define _FC_ELS_H_ | |
62 | + | |
63 | +/* | |
64 | + * Fibre Channel Switch - Enhanced Link Services definitions. | |
65 | + * From T11 FC-LS Rev 1.2 June 7, 2005. | |
66 | + */ | |
67 | + | |
68 | +/* | |
69 | + * ELS Command codes - byte 0 of the frame payload | |
70 | + */ | |
71 | +enum fc_els_cmd { | |
72 | + ELS_LS_RJT = 0x01, /* ESL reject */ | |
73 | + ELS_LS_ACC = 0x02, /* ESL Accept */ | |
74 | + ELS_PLOGI = 0x03, /* N_Port login */ | |
75 | + ELS_FLOGI = 0x04, /* F_Port login */ | |
76 | + ELS_LOGO = 0x05, /* Logout */ | |
77 | + ELS_ABTX = 0x06, /* Abort exchange - obsolete */ | |
78 | + ELS_RCS = 0x07, /* read connection status */ | |
79 | + ELS_RES = 0x08, /* read exchange status block */ | |
80 | + ELS_RSS = 0x09, /* read sequence status block */ | |
81 | + ELS_RSI = 0x0a, /* read sequence initiative */ | |
82 | + ELS_ESTS = 0x0b, /* establish streaming */ | |
83 | + ELS_ESTC = 0x0c, /* estimate credit */ | |
84 | + ELS_ADVC = 0x0d, /* advise credit */ | |
85 | + ELS_RTV = 0x0e, /* read timeout value */ | |
86 | + ELS_RLS = 0x0f, /* read link error status block */ | |
87 | + ELS_ECHO = 0x10, /* echo */ | |
88 | + ELS_TEST = 0x11, /* test */ | |
89 | + ELS_RRQ = 0x12, /* reinstate recovery qualifier */ | |
90 | + ELS_REC = 0x13, /* read exchange concise */ | |
91 | + ELS_SRR = 0x14, /* sequence retransmission request */ | |
92 | + ELS_PRLI = 0x20, /* process login */ | |
93 | + ELS_PRLO = 0x21, /* process logout */ | |
94 | + ELS_SCN = 0x22, /* state change notification */ | |
95 | + ELS_TPLS = 0x23, /* test process login state */ | |
96 | + ELS_TPRLO = 0x24, /* third party process logout */ | |
97 | + ELS_LCLM = 0x25, /* login control list mgmt (obs) */ | |
98 | + ELS_GAID = 0x30, /* get alias_ID */ | |
99 | + ELS_FACT = 0x31, /* fabric activate alias_id */ | |
100 | + ELS_FDACDT = 0x32, /* fabric deactivate alias_id */ | |
101 | + ELS_NACT = 0x33, /* N-port activate alias_id */ | |
102 | + ELS_NDACT = 0x34, /* N-port deactivate alias_id */ | |
103 | + ELS_QOSR = 0x40, /* quality of service request */ | |
104 | + ELS_RVCS = 0x41, /* read virtual circuit status */ | |
105 | + ELS_PDISC = 0x50, /* discover N_port service params */ | |
106 | + ELS_FDISC = 0x51, /* discover F_port service params */ | |
107 | + ELS_ADISC = 0x52, /* discover address */ | |
108 | + ELS_RNC = 0x53, /* report node cap (obs) */ | |
109 | + ELS_FARP_REQ = 0x54, /* FC ARP request */ | |
110 | + ELS_FARP_REPL = 0x55, /* FC ARP reply */ | |
111 | + ELS_RPS = 0x56, /* read port status block */ | |
112 | + ELS_RPL = 0x57, /* read port list */ | |
113 | + ELS_RPBC = 0x58, /* read port buffer condition */ | |
114 | + ELS_FAN = 0x60, /* fabric address notification */ | |
115 | + ELS_RSCN = 0x61, /* registered state change notification */ | |
116 | + ELS_SCR = 0x62, /* state change registration */ | |
117 | + ELS_RNFT = 0x63, /* report node FC-4 types */ | |
118 | + ELS_CSR = 0x68, /* clock synch. request */ | |
119 | + ELS_CSU = 0x69, /* clock synch. update */ | |
120 | + ELS_LINIT = 0x70, /* loop initialize */ | |
121 | + ELS_LSTS = 0x72, /* loop status */ | |
122 | + ELS_RNID = 0x78, /* request node ID data */ | |
123 | + ELS_RLIR = 0x79, /* registered link incident report */ | |
124 | + ELS_LIRR = 0x7a, /* link incident record registration */ | |
125 | + ELS_SRL = 0x7b, /* scan remote loop */ | |
126 | + ELS_SBRP = 0x7c, /* set bit-error reporting params */ | |
127 | + ELS_RPSC = 0x7d, /* report speed capabilities */ | |
128 | + ELS_QSA = 0x7e, /* query security attributes */ | |
129 | + ELS_EVFP = 0x7f, /* exchange virt. fabrics params */ | |
130 | + ELS_LKA = 0x80, /* link keep-alive */ | |
131 | + ELS_AUTH_ELS = 0x90, /* authentication ELS */ | |
132 | +}; | |
133 | + | |
134 | +/* | |
135 | + * Initializer useful for decoding table. | |
136 | + * Please keep this in sync with the above definitions. | |
137 | + */ | |
138 | +#define FC_ELS_CMDS_INIT { \ | |
139 | + [ELS_LS_RJT] = "LS_RJT", \ | |
140 | + [ELS_LS_ACC] = "LS_ACC", \ | |
141 | + [ELS_PLOGI] = "PLOGI", \ | |
142 | + [ELS_FLOGI] = "FLOGI", \ | |
143 | + [ELS_LOGO] = "LOGO", \ | |
144 | + [ELS_ABTX] = "ABTX", \ | |
145 | + [ELS_RCS] = "RCS", \ | |
146 | + [ELS_RES] = "RES", \ | |
147 | + [ELS_RSS] = "RSS", \ | |
148 | + [ELS_RSI] = "RSI", \ | |
149 | + [ELS_ESTS] = "ESTS", \ | |
150 | + [ELS_ESTC] = "ESTC", \ | |
151 | + [ELS_ADVC] = "ADVC", \ | |
152 | + [ELS_RTV] = "RTV", \ | |
153 | + [ELS_RLS] = "RLS", \ | |
154 | + [ELS_ECHO] = "ECHO", \ | |
155 | + [ELS_TEST] = "TEST", \ | |
156 | + [ELS_RRQ] = "RRQ", \ | |
157 | + [ELS_REC] = "REC", \ | |
158 | + [ELS_SRR] = "SRR", \ | |
159 | + [ELS_PRLI] = "PRLI", \ | |
160 | + [ELS_PRLO] = "PRLO", \ | |
161 | + [ELS_SCN] = "SCN", \ | |
162 | + [ELS_TPLS] = "TPLS", \ | |
163 | + [ELS_TPRLO] = "TPRLO", \ | |
164 | + [ELS_LCLM] = "LCLM", \ | |
165 | + [ELS_GAID] = "GAID", \ | |
166 | + [ELS_FACT] = "FACT", \ | |
167 | + [ELS_FDACDT] = "FDACDT", \ | |
168 | + [ELS_NACT] = "NACT", \ | |
169 | + [ELS_NDACT] = "NDACT", \ | |
170 | + [ELS_QOSR] = "QOSR", \ | |
171 | + [ELS_RVCS] = "RVCS", \ | |
172 | + [ELS_PDISC] = "PDISC", \ | |
173 | + [ELS_FDISC] = "FDISC", \ | |
174 | + [ELS_ADISC] = "ADISC", \ | |
175 | + [ELS_RNC] = "RNC", \ | |
176 | + [ELS_FARP_REQ] = "FARP_REQ", \ | |
177 | + [ELS_FARP_REPL] = "FARP_REPL", \ | |
178 | + [ELS_RPS] = "RPS", \ | |
179 | + [ELS_RPL] = "RPL", \ | |
180 | + [ELS_RPBC] = "RPBC", \ | |
181 | + [ELS_FAN] = "FAN", \ | |
182 | + [ELS_RSCN] = "RSCN", \ | |
183 | + [ELS_SCR] = "SCR", \ | |
184 | + [ELS_RNFT] = "RNFT", \ | |
185 | + [ELS_CSR] = "CSR", \ | |
186 | + [ELS_CSU] = "CSU", \ | |
187 | + [ELS_LINIT] = "LINIT", \ | |
188 | + [ELS_LSTS] = "LSTS", \ | |
189 | + [ELS_RNID] = "RNID", \ | |
190 | + [ELS_RLIR] = "RLIR", \ | |
191 | + [ELS_LIRR] = "LIRR", \ | |
192 | + [ELS_SRL] = "SRL", \ | |
193 | + [ELS_SBRP] = "SBRP", \ | |
194 | + [ELS_RPSC] = "RPSC", \ | |
195 | + [ELS_QSA] = "QSA", \ | |
196 | + [ELS_EVFP] = "EVFP", \ | |
197 | + [ELS_LKA] = "LKA", \ | |
198 | + [ELS_AUTH_ELS] = "AUTH_ELS", \ | |
199 | +} | |
200 | + | |
201 | +/* | |
202 | + * LS_ACC payload. | |
203 | + */ | |
204 | +struct fc_els_ls_acc { | |
205 | + __u8 la_cmd; /* command code ELS_LS_ACC */ | |
206 | + __u8 la_resv[3]; /* reserved */ | |
207 | +}; | |
208 | + | |
209 | +/* | |
210 | + * ELS reject payload. | |
211 | + */ | |
212 | +struct fc_els_ls_rjt { | |
213 | + __u8 er_cmd; /* command code ELS_LS_RJT */ | |
214 | + __u8 er_resv[4]; /* reserved must be zero */ | |
215 | + __u8 er_reason; /* reason (enum fc_els_rjt_reason below) */ | |
216 | + __u8 er_explan; /* explanation (enum fc_els_rjt_explan below) */ | |
217 | + __u8 er_vendor; /* vendor specific code */ | |
218 | +}; | |
219 | + | |
220 | +/* | |
221 | + * ELS reject reason codes (er_reason). | |
222 | + */ | |
223 | +enum fc_els_rjt_reason { | |
224 | + ELS_RJT_NONE = 0, /* no reject - not to be sent */ | |
225 | + ELS_RJT_INVAL = 0x01, /* invalid ELS command code */ | |
226 | + ELS_RJT_LOGIC = 0x03, /* logical error */ | |
227 | + ELS_RJT_BUSY = 0x05, /* logical busy */ | |
228 | + ELS_RJT_PROT = 0x07, /* protocol error */ | |
229 | + ELS_RJT_UNAB = 0x09, /* unable to perform command request */ | |
230 | + ELS_RJT_UNSUP = 0x0b, /* command not supported */ | |
231 | + ELS_RJT_INPROG = 0x0e, /* command already in progress */ | |
232 | + ELS_RJT_VENDOR = 0xff, /* vendor specific error */ | |
233 | +}; | |
234 | + | |
235 | + | |
236 | +/* | |
237 | + * reason code explanation (er_explan). | |
238 | + */ | |
239 | +enum fc_els_rjt_explan { | |
240 | + ELS_EXPL_NONE = 0x00, /* No additional explanation */ | |
241 | + ELS_EXPL_SPP_OPT_ERR = 0x01, /* service parameter error - options */ | |
242 | + ELS_EXPL_SPP_ICTL_ERR = 0x03, /* service parm error - initiator ctl */ | |
243 | + ELS_EXPL_AH = 0x11, /* invalid association header */ | |
244 | + ELS_EXPL_AH_REQ = 0x13, /* association_header required */ | |
245 | + ELS_EXPL_SID = 0x15, /* invalid originator S_ID */ | |
246 | + ELS_EXPL_OXID_RXID = 0x17, /* invalid OX_ID-RX_ID combination */ | |
247 | + ELS_EXPL_INPROG = 0x19, /* Request already in progress */ | |
248 | + ELS_EXPL_PLOGI_REQD = 0x1e, /* N_Port login required */ | |
249 | + ELS_EXPL_INSUF_RES = 0x29, /* insufficient resources */ | |
250 | + ELS_EXPL_UNAB_DATA = 0x2a, /* unable to supply requested data */ | |
251 | + ELS_EXPL_UNSUPR = 0x2c, /* Request not supported */ | |
252 | + ELS_EXPL_INV_LEN = 0x2d, /* Invalid payload length */ | |
253 | + /* TBD - above definitions incomplete */ | |
254 | +}; | |
255 | + | |
256 | +/* | |
257 | + * Common service parameters (N ports). | |
258 | + */ | |
259 | +struct fc_els_csp { | |
260 | + __u8 sp_hi_ver; /* highest version supported (obs.) */ | |
261 | + __u8 sp_lo_ver; /* highest version supported (obs.) */ | |
262 | + __be16 sp_bb_cred; /* buffer-to-buffer credits */ | |
263 | + __be16 sp_features; /* common feature flags */ | |
264 | + __be16 sp_bb_data; /* b-b state number and data field sz */ | |
265 | + union { | |
266 | + struct { | |
267 | + __be16 _sp_tot_seq; /* total concurrent sequences */ | |
268 | + __be16 _sp_rel_off; /* rel. offset by info cat */ | |
269 | + } sp_plogi; | |
270 | + struct { | |
271 | + __be32 _sp_r_a_tov; /* resource alloc. timeout msec */ | |
272 | + } sp_flogi_acc; | |
273 | + } sp_u; | |
274 | + __be32 sp_e_d_tov; /* error detect timeout value */ | |
275 | +}; | |
276 | +#define sp_tot_seq sp_u.sp_plogi._sp_tot_seq | |
277 | +#define sp_rel_off sp_u.sp_plogi._sp_rel_off | |
278 | +#define sp_r_a_tov sp_u.sp_flogi_acc._sp_r_a_tov | |
279 | + | |
280 | +#define FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */ | |
281 | + | |
282 | +/* | |
283 | + * Minimum and maximum values for max data field size in service parameters. | |
284 | + */ | |
285 | +#define FC_SP_MIN_MAX_PAYLOAD FC_MIN_MAX_PAYLOAD | |
286 | +#define FC_SP_MAX_MAX_PAYLOAD FC_MAX_PAYLOAD | |
287 | + | |
288 | +/* | |
289 | + * sp_features | |
290 | + */ | |
291 | +#define FC_SP_FT_CIRO 0x8000 /* continuously increasing rel. off. */ | |
292 | +#define FC_SP_FT_CLAD 0x8000 /* clean address (in FLOGI LS_ACC) */ | |
293 | +#define FC_SP_FT_RAND 0x4000 /* random relative offset */ | |
294 | +#define FC_SP_FT_VAL 0x2000 /* valid vendor version level */ | |
295 | +#define FC_SP_FT_FPORT 0x1000 /* F port (1) vs. N port (0) */ | |
296 | +#define FC_SP_FT_ABB 0x0800 /* alternate BB_credit management */ | |
297 | +#define FC_SP_FT_EDTR 0x0400 /* E_D_TOV Resolution is nanoseconds */ | |
298 | +#define FC_SP_FT_MCAST 0x0200 /* multicast */ | |
299 | +#define FC_SP_FT_BCAST 0x0100 /* broadcast */ | |
300 | +#define FC_SP_FT_HUNT 0x0080 /* hunt group */ | |
301 | +#define FC_SP_FT_SIMP 0x0040 /* dedicated simplex */ | |
302 | +#define FC_SP_FT_SEC 0x0020 /* reserved for security */ | |
303 | +#define FC_SP_FT_CSYN 0x0010 /* clock synch. supported */ | |
304 | +#define FC_SP_FT_RTTOV 0x0008 /* R_T_TOV value 100 uS, else 100 mS */ | |
305 | +#define FC_SP_FT_HALF 0x0004 /* dynamic half duplex */ | |
306 | +#define FC_SP_FT_SEQC 0x0002 /* SEQ_CNT */ | |
307 | +#define FC_SP_FT_PAYL 0x0001 /* FLOGI payload length 256, else 116 */ | |
308 | + | |
309 | +/* | |
310 | + * Class-specific service parameters. | |
311 | + */ | |
312 | +struct fc_els_cssp { | |
313 | + __be16 cp_class; /* class flags */ | |
314 | + __be16 cp_init; /* initiator flags */ | |
315 | + __be16 cp_recip; /* recipient flags */ | |
316 | + __be16 cp_rdfs; /* receive data field size */ | |
317 | + __be16 cp_con_seq; /* concurrent sequences */ | |
318 | + __be16 cp_ee_cred; /* N-port end-to-end credit */ | |
319 | + __u8 cp_resv1; /* reserved */ | |
320 | + __u8 cp_open_seq; /* open sequences per exchange */ | |
321 | + __u8 _cp_resv2[2]; /* reserved */ | |
322 | +}; | |
323 | + | |
324 | +/* | |
325 | + * cp_class flags. | |
326 | + */ | |
327 | +#define FC_CPC_VALID 0x8000 /* class valid */ | |
328 | +#define FC_CPC_IMIX 0x4000 /* intermix mode */ | |
329 | +#define FC_CPC_SEQ 0x0800 /* sequential delivery */ | |
330 | +#define FC_CPC_CAMP 0x0200 /* camp-on */ | |
331 | +#define FC_CPC_PRI 0x0080 /* priority */ | |
332 | + | |
333 | +/* | |
334 | + * cp_init flags. | |
335 | + * (TBD: not all flags defined here). | |
336 | + */ | |
337 | +#define FC_CPI_CSYN 0x0010 /* clock synch. capable */ | |
338 | + | |
339 | +/* | |
340 | + * cp_recip flags. | |
341 | + */ | |
342 | +#define FC_CPR_CSYN 0x0008 /* clock synch. capable */ | |
343 | + | |
344 | +/* | |
345 | + * NFC_ELS_FLOGI: Fabric login request. | |
346 | + * NFC_ELS_PLOGI: Port login request (same format). | |
347 | + */ | |
348 | +struct fc_els_flogi { | |
349 | + __u8 fl_cmd; /* command */ | |
350 | + __u8 _fl_resvd[3]; /* must be zero */ | |
351 | + struct fc_els_csp fl_csp; /* common service parameters */ | |
352 | + __be64 fl_wwpn; /* port name */ | |
353 | + __be64 fl_wwnn; /* node name */ | |
354 | + struct fc_els_cssp fl_cssp[4]; /* class 1-4 service parameters */ | |
355 | + __u8 fl_vend[16]; /* vendor version level */ | |
356 | +} __attribute__((__packed__)); | |
357 | + | |
358 | +/* | |
359 | + * Process login service parameter page. | |
360 | + */ | |
361 | +struct fc_els_spp { | |
362 | + __u8 spp_type; /* type code or common service params */ | |
363 | + __u8 spp_type_ext; /* type code extension */ | |
364 | + __u8 spp_flags; | |
365 | + __u8 _spp_resvd; | |
366 | + __be32 spp_orig_pa; /* originator process associator */ | |
367 | + __be32 spp_resp_pa; /* responder process associator */ | |
368 | + __be32 spp_params; /* service parameters */ | |
369 | +}; | |
370 | + | |
371 | +/* | |
372 | + * spp_flags. | |
373 | + */ | |
374 | +#define FC_SPP_OPA_VAL 0x80 /* originator proc. assoc. valid */ | |
375 | +#define FC_SPP_RPA_VAL 0x40 /* responder proc. assoc. valid */ | |
376 | +#define FC_SPP_EST_IMG_PAIR 0x20 /* establish image pair */ | |
377 | +#define FC_SPP_RESP_MASK 0x0f /* mask for response code (below) */ | |
378 | + | |
379 | +/* | |
380 | + * SPP response code in spp_flags - lower 4 bits. | |
381 | + */ | |
382 | +enum fc_els_spp_resp { | |
383 | + FC_SPP_RESP_ACK = 1, /* request executed */ | |
384 | + FC_SPP_RESP_RES = 2, /* unable due to lack of resources */ | |
385 | + FC_SPP_RESP_INIT = 3, /* initialization not complete */ | |
386 | + FC_SPP_RESP_NO_PA = 4, /* unknown process associator */ | |
387 | + FC_SPP_RESP_CONF = 5, /* configuration precludes image pair */ | |
388 | + FC_SPP_RESP_COND = 6, /* request completed conditionally */ | |
389 | + FC_SPP_RESP_MULT = 7, /* unable to handle multiple SPPs */ | |
390 | + FC_SPP_RESP_INVL = 8, /* SPP is invalid */ | |
391 | +}; | |
392 | + | |
393 | +/* | |
394 | + * ELS_RRQ - Reinstate Recovery Qualifier | |
395 | + */ | |
396 | +struct fc_els_rrq { | |
397 | + __u8 rrq_cmd; /* command (0x12) */ | |
398 | + __u8 rrq_zero[3]; /* specified as zero - part of cmd */ | |
399 | + __u8 rrq_resvd; /* reserved */ | |
400 | + __u8 rrq_s_id[3]; /* originator FID */ | |
401 | + __be16 rrq_ox_id; /* originator exchange ID */ | |
402 | + __be16 rrq_rx_id; /* responders exchange ID */ | |
403 | +}; | |
404 | + | |
405 | +/* | |
406 | + * ELS_REC - Read exchange concise. | |
407 | + */ | |
408 | +struct fc_els_rec { | |
409 | + __u8 rec_cmd; /* command (0x13) */ | |
410 | + __u8 rec_zero[3]; /* specified as zero - part of cmd */ | |
411 | + __u8 rec_resvd; /* reserved */ | |
412 | + __u8 rec_s_id[3]; /* originator FID */ | |
413 | + __be16 rec_ox_id; /* originator exchange ID */ | |
414 | + __be16 rec_rx_id; /* responders exchange ID */ | |
415 | +}; | |
416 | + | |
417 | +/* | |
418 | + * ELS_REC LS_ACC payload. | |
419 | + */ | |
420 | +struct fc_els_rec_acc { | |
421 | + __u8 reca_cmd; /* accept (0x02) */ | |
422 | + __u8 reca_zero[3]; /* specified as zero - part of cmd */ | |
423 | + __be16 reca_ox_id; /* originator exchange ID */ | |
424 | + __be16 reca_rx_id; /* responders exchange ID */ | |
425 | + __u8 reca_resvd1; /* reserved */ | |
426 | + __u8 reca_ofid[3]; /* originator FID */ | |
427 | + __u8 reca_resvd2; /* reserved */ | |
428 | + __u8 reca_rfid[3]; /* responder FID */ | |
429 | + __be32 reca_fc4value; /* FC4 value */ | |
430 | + __be32 reca_e_stat; /* ESB (exchange status block) status */ | |
431 | +}; | |
432 | + | |
433 | +/* | |
434 | + * ELS_PRLI - Process login request and response. | |
435 | + */ | |
436 | +struct fc_els_prli { | |
437 | + __u8 prli_cmd; /* command */ | |
438 | + __u8 prli_spp_len; /* length of each serv. parm. page */ | |
439 | + __be16 prli_len; /* length of entire payload */ | |
440 | + /* service parameter pages follow */ | |
441 | +}; | |
442 | + | |
443 | +/* | |
444 | + * ELS_LOGO - process or fabric logout. | |
445 | + */ | |
446 | +struct fc_els_logo { | |
447 | + __u8 fl_cmd; /* command code */ | |
448 | + __u8 fl_zero[3]; /* specified as zero - part of cmd */ | |
449 | + __u8 fl_resvd; /* reserved */ | |
450 | + __u8 fl_n_port_id[3];/* N port ID */ | |
451 | + __be64 fl_n_port_wwn; /* port name */ | |
452 | +}; | |
453 | + | |
454 | +/* | |
455 | + * ELS_RTV - read timeout value. | |
456 | + */ | |
457 | +struct fc_els_rtv { | |
458 | + __u8 rtv_cmd; /* command code 0x0e */ | |
459 | + __u8 rtv_zero[3]; /* specified as zero - part of cmd */ | |
460 | +}; | |
461 | + | |
462 | +/* | |
463 | + * LS_ACC for ELS_RTV - read timeout value. | |
464 | + */ | |
465 | +struct fc_els_rtv_acc { | |
466 | + __u8 rtv_cmd; /* command code 0x02 */ | |
467 | + __u8 rtv_zero[3]; /* specified as zero - part of cmd */ | |
468 | + __be32 rtv_r_a_tov; /* resource allocation timeout value */ | |
469 | + __be32 rtv_e_d_tov; /* error detection timeout value */ | |
470 | + __be32 rtv_toq; /* timeout qualifier (see below) */ | |
471 | +}; | |
472 | + | |
473 | +/* | |
474 | + * rtv_toq bits. | |
475 | + */ | |
476 | +#define FC_ELS_RTV_EDRES (1 << 26) /* E_D_TOV resolution is nS else mS */ | |
477 | +#define FC_ELS_RTV_RTTOV (1 << 19) /* R_T_TOV is 100 uS else 100 mS */ | |
478 | + | |
479 | +/* | |
480 | + * ELS_SCR - state change registration payload. | |
481 | + */ | |
482 | +struct fc_els_scr { | |
483 | + __u8 scr_cmd; /* command code */ | |
484 | + __u8 scr_resv[6]; /* reserved */ | |
485 | + __u8 scr_reg_func; /* registration function (see below) */ | |
486 | +}; | |
487 | + | |
488 | +enum fc_els_scr_func { | |
489 | + ELS_SCRF_FAB = 1, /* fabric-detected registration */ | |
490 | + ELS_SCRF_NPORT = 2, /* Nx_Port-detected registration */ | |
491 | + ELS_SCRF_FULL = 3, /* full registration */ | |
492 | + ELS_SCRF_CLEAR = 255, /* remove any current registrations */ | |
493 | +}; | |
494 | + | |
495 | +/* | |
496 | + * ELS_RSCN - registered state change notification payload. | |
497 | + */ | |
498 | +struct fc_els_rscn { | |
499 | + __u8 rscn_cmd; /* RSCN opcode (0x61) */ | |
500 | + __u8 rscn_page_len; /* page length (4) */ | |
501 | + __be16 rscn_plen; /* payload length including this word */ | |
502 | + | |
503 | + /* followed by 4-byte generic affected Port_ID pages */ | |
504 | +}; | |
505 | + | |
506 | +struct fc_els_rscn_page { | |
507 | + __u8 rscn_page_flags; /* event and address format */ | |
508 | + __u8 rscn_fid[3]; /* fabric ID */ | |
509 | +}; | |
510 | + | |
511 | +#define ELS_RSCN_EV_QUAL_BIT 2 /* shift count for event qualifier */ | |
512 | +#define ELS_RSCN_EV_QUAL_MASK 0xf /* mask for event qualifier */ | |
513 | +#define ELS_RSCN_ADDR_FMT_BIT 0 /* shift count for address format */ | |
514 | +#define ELS_RSCN_ADDR_FMT_MASK 0x3 /* mask for address format */ | |
515 | + | |
516 | +enum fc_els_rscn_ev_qual { | |
517 | + ELS_EV_QUAL_NONE = 0, /* unspecified */ | |
518 | + ELS_EV_QUAL_NS_OBJ = 1, /* changed name server object */ | |
519 | + ELS_EV_QUAL_PORT_ATTR = 2, /* changed port attribute */ | |
520 | + ELS_EV_QUAL_SERV_OBJ = 3, /* changed service object */ | |
521 | + ELS_EV_QUAL_SW_CONFIG = 4, /* changed switch configuration */ | |
522 | + ELS_EV_QUAL_REM_OBJ = 5, /* removed object */ | |
523 | +}; | |
524 | + | |
525 | +enum fc_els_rscn_addr_fmt { | |
526 | + ELS_ADDR_FMT_PORT = 0, /* rscn_fid is a port address */ | |
527 | + ELS_ADDR_FMT_AREA = 1, /* rscn_fid is a area address */ | |
528 | + ELS_ADDR_FMT_DOM = 2, /* rscn_fid is a domain address */ | |
529 | + ELS_ADDR_FMT_FAB = 3, /* anything on fabric may have changed */ | |
530 | +}; | |
531 | + | |
532 | +/* | |
533 | + * ELS_RNID - request Node ID. | |
534 | + */ | |
535 | +struct fc_els_rnid { | |
536 | + __u8 rnid_cmd; /* RNID opcode (0x78) */ | |
537 | + __u8 rnid_resv[3]; /* reserved */ | |
538 | + __u8 rnid_fmt; /* data format */ | |
539 | + __u8 rnid_resv2[3]; /* reserved */ | |
540 | +}; | |
541 | + | |
542 | +/* | |
543 | + * Node Identification Data formats (rnid_fmt) | |
544 | + */ | |
545 | +enum fc_els_rnid_fmt { | |
546 | + ELS_RNIDF_NONE = 0, /* no specific identification data */ | |
547 | + ELS_RNIDF_GEN = 0xdf, /* general topology discovery format */ | |
548 | +}; | |
549 | + | |
550 | +/* | |
551 | + * ELS_RNID response. | |
552 | + */ | |
553 | +struct fc_els_rnid_resp { | |
554 | + __u8 rnid_cmd; /* response code (LS_ACC) */ | |
555 | + __u8 rnid_resv[3]; /* reserved */ | |
556 | + __u8 rnid_fmt; /* data format */ | |
557 | + __u8 rnid_cid_len; /* common ID data length */ | |
558 | + __u8 rnid_resv2; /* reserved */ | |
559 | + __u8 rnid_sid_len; /* specific ID data length */ | |
560 | +}; | |
561 | + | |
562 | +struct fc_els_rnid_cid { | |
563 | + __be64 rnid_wwpn; /* N port name */ | |
564 | + __be64 rnid_wwnn; /* node name */ | |
565 | +}; | |
566 | + | |
567 | +struct fc_els_rnid_gen { | |
568 | + __u8 rnid_vend_id[16]; /* vendor-unique ID */ | |
569 | + __be32 rnid_atype; /* associated type (see below) */ | |
570 | + __be32 rnid_phys_port; /* physical port number */ | |
571 | + __be32 rnid_att_nodes; /* number of attached nodes */ | |
572 | + __u8 rnid_node_mgmt; /* node management (see below) */ | |
573 | + __u8 rnid_ip_ver; /* IP version (see below) */ | |
574 | + __be16 rnid_prot_port; /* UDP / TCP port number */ | |
575 | + __be32 rnid_ip_addr[4]; /* IP address */ | |
576 | + __u8 rnid_resvd[2]; /* reserved */ | |
577 | + __be16 rnid_vend_spec; /* vendor-specific field */ | |
578 | +}; | |
579 | + | |
580 | +enum fc_els_rnid_atype { | |
581 | + ELS_RNIDA_UNK = 0x01, /* unknown */ | |
582 | + ELS_RNIDA_OTHER = 0x02, /* none of the following */ | |
583 | + ELS_RNIDA_HUB = 0x03, | |
584 | + ELS_RNIDA_SWITCH = 0x04, | |
585 | + ELS_RNIDA_GATEWAY = 0x05, | |
586 | + ELS_RNIDA_CONV = 0x06, /* Obsolete, do not use this value */ | |
587 | + ELS_RNIDA_HBA = 0x07, /* Obsolete, do not use this value */ | |
588 | + ELS_RNIDA_PROXY = 0x08, /* Obsolete, do not use this value */ | |
589 | + ELS_RNIDA_STORAGE = 0x09, | |
590 | + ELS_RNIDA_HOST = 0x0a, | |
591 | + ELS_RNIDA_SUBSYS = 0x0b, /* storage subsystem (e.g., RAID) */ | |
592 | + ELS_RNIDA_ACCESS = 0x0e, /* access device (e.g. media changer) */ | |
593 | + ELS_RNIDA_NAS = 0x11, /* NAS server */ | |
594 | + ELS_RNIDA_BRIDGE = 0x12, /* bridge */ | |
595 | + ELS_RNIDA_VIRT = 0x13, /* virtualization device */ | |
596 | + ELS_RNIDA_MF = 0xff, /* multifunction device (bits below) */ | |
597 | + ELS_RNIDA_MF_HUB = 1UL << 31, /* hub */ | |
598 | + ELS_RNIDA_MF_SW = 1UL << 30, /* switch */ | |
599 | + ELS_RNIDA_MF_GW = 1UL << 29, /* gateway */ | |
600 | + ELS_RNIDA_MF_ST = 1UL << 28, /* storage */ | |
601 | + ELS_RNIDA_MF_HOST = 1UL << 27, /* host */ | |
602 | + ELS_RNIDA_MF_SUB = 1UL << 26, /* storage subsystem */ | |
603 | + ELS_RNIDA_MF_ACC = 1UL << 25, /* storage access dev */ | |
604 | + ELS_RNIDA_MF_WDM = 1UL << 24, /* wavelength division mux */ | |
605 | + ELS_RNIDA_MF_NAS = 1UL << 23, /* NAS server */ | |
606 | + ELS_RNIDA_MF_BR = 1UL << 22, /* bridge */ | |
607 | + ELS_RNIDA_MF_VIRT = 1UL << 21, /* virtualization device */ | |
608 | +}; | |
609 | + | |
610 | +enum fc_els_rnid_mgmt { | |
611 | + ELS_RNIDM_SNMP = 0, | |
612 | + ELS_RNIDM_TELNET = 1, | |
613 | + ELS_RNIDM_HTTP = 2, | |
614 | + ELS_RNIDM_HTTPS = 3, | |
615 | + ELS_RNIDM_XML = 4, /* HTTP + XML */ | |
616 | +}; | |
617 | + | |
618 | +enum fc_els_rnid_ipver { | |
619 | + ELS_RNIDIP_NONE = 0, /* no IP support or node mgmt. */ | |
620 | + ELS_RNIDIP_V4 = 1, /* IPv4 */ | |
621 | + ELS_RNIDIP_V6 = 2, /* IPv6 */ | |
622 | +}; | |
623 | + | |
624 | +/* | |
625 | + * ELS RPL - Read Port List. | |
626 | + */ | |
627 | +struct fc_els_rpl { | |
628 | + __u8 rpl_cmd; /* command */ | |
629 | + __u8 rpl_resv[5]; /* reserved - must be zero */ | |
630 | + __be16 rpl_max_size; /* maximum response size or zero */ | |
631 | + __u8 rpl_resv1; /* reserved - must be zero */ | |
632 | + __u8 rpl_index[3]; /* starting index */ | |
633 | +}; | |
634 | + | |
635 | +/* | |
636 | + * Port number block in RPL response. | |
637 | + */ | |
638 | +struct fc_els_pnb { | |
639 | + __be32 pnb_phys_pn; /* physical port number */ | |
640 | + __u8 pnb_resv; /* reserved */ | |
641 | + __u8 pnb_port_id[3]; /* port ID */ | |
642 | + __be64 pnb_wwpn; /* port name */ | |
643 | +}; | |
644 | + | |
645 | +/* | |
646 | + * RPL LS_ACC response. | |
647 | + */ | |
648 | +struct fc_els_rpl_resp { | |
649 | + __u8 rpl_cmd; /* ELS_LS_ACC */ | |
650 | + __u8 rpl_resv1; /* reserved - must be zero */ | |
651 | + __be16 rpl_plen; /* payload length */ | |
652 | + __u8 rpl_resv2; /* reserved - must be zero */ | |
653 | + __u8 rpl_llen[3]; /* list length */ | |
654 | + __u8 rpl_resv3; /* reserved - must be zero */ | |
655 | + __u8 rpl_index[3]; /* starting index */ | |
656 | + struct fc_els_pnb rpl_pnb[1]; /* variable number of PNBs */ | |
657 | +}; | |
658 | + | |
659 | +/* | |
660 | + * Link Error Status Block. | |
661 | + */ | |
662 | +struct fc_els_lesb { | |
663 | + __be32 lesb_link_fail; /* link failure count */ | |
664 | + __be32 lesb_sync_loss; /* loss of synchronization count */ | |
665 | + __be32 lesb_sig_loss; /* loss of signal count */ | |
666 | + __be32 lesb_prim_err; /* primitive sequence error count */ | |
667 | + __be32 lesb_inv_word; /* invalid transmission word count */ | |
668 | + __be32 lesb_inv_crc; /* invalid CRC count */ | |
669 | +}; | |
670 | + | |
671 | +/* | |
672 | + * ELS RPS - Read Port Status Block request. | |
673 | + */ | |
674 | +struct fc_els_rps { | |
675 | + __u8 rps_cmd; /* command */ | |
676 | + __u8 rps_resv[2]; /* reserved - must be zero */ | |
677 | + __u8 rps_flag; /* flag - see below */ | |
678 | + __be64 rps_port_spec; /* port selection */ | |
679 | +}; | |
680 | + | |
681 | +enum fc_els_rps_flag { | |
682 | + FC_ELS_RPS_DID = 0x00, /* port identified by D_ID of req. */ | |
683 | + FC_ELS_RPS_PPN = 0x01, /* port_spec is physical port number */ | |
684 | + FC_ELS_RPS_WWPN = 0x02, /* port_spec is port WWN */ | |
685 | +}; | |
686 | + | |
687 | +/* | |
688 | + * ELS RPS LS_ACC response. | |
689 | + */ | |
690 | +struct fc_els_rps_resp { | |
691 | + __u8 rps_cmd; /* command - LS_ACC */ | |
692 | + __u8 rps_resv[2]; /* reserved - must be zero */ | |
693 | + __u8 rps_flag; /* flag - see below */ | |
694 | + __u8 rps_resv2[2]; /* reserved */ | |
695 | + __be16 rps_status; /* port status - see below */ | |
696 | + struct fc_els_lesb rps_lesb; /* link error status block */ | |
697 | +}; | |
698 | + | |
699 | +enum fc_els_rps_resp_flag { | |
700 | + FC_ELS_RPS_LPEV = 0x01, /* L_port extension valid */ | |
701 | +}; | |
702 | + | |
703 | +enum fc_els_rps_resp_status { | |
704 | + FC_ELS_RPS_PTP = 1 << 5, /* point-to-point connection */ | |
705 | + FC_ELS_RPS_LOOP = 1 << 4, /* loop mode */ | |
706 | + FC_ELS_RPS_FAB = 1 << 3, /* fabric present */ | |
707 | + FC_ELS_RPS_NO_SIG = 1 << 2, /* loss of signal */ | |
708 | + FC_ELS_RPS_NO_SYNC = 1 << 1, /* loss of synchronization */ | |
709 | + FC_ELS_RPS_RESET = 1 << 0, /* in link reset protocol */ | |
710 | +}; | |
711 | + | |
712 | +/* | |
713 | + * ELS LIRR - Link Incident Record Registration request. | |
714 | + */ | |
715 | +struct fc_els_lirr { | |
716 | + __u8 lirr_cmd; /* command */ | |
717 | + __u8 lirr_resv[3]; /* reserved - must be zero */ | |
718 | + __u8 lirr_func; /* registration function */ | |
719 | + __u8 lirr_fmt; /* FC-4 type of RLIR requested */ | |
720 | + __u8 lirr_resv2[2]; /* reserved - must be zero */ | |
721 | +}; | |
722 | + | |
723 | +enum fc_els_lirr_func { | |
724 | + ELS_LIRR_SET_COND = 0x01, /* set - conditionally receive */ | |
725 | + ELS_LIRR_SET_UNCOND = 0x02, /* set - unconditionally receive */ | |
726 | + ELS_LIRR_CLEAR = 0xff /* clear registration */ | |
727 | +}; | |
728 | + | |
729 | +/* | |
730 | + * ELS SRL - Scan Remote Loop request. | |
731 | + */ | |
732 | +struct fc_els_srl { | |
733 | + __u8 srl_cmd; /* command */ | |
734 | + __u8 srl_resv[3]; /* reserved - must be zero */ | |
735 | + __u8 srl_flag; /* flag - see below */ | |
736 | + __u8 srl_flag_param[3]; /* flag parameter */ | |
737 | +}; | |
738 | + | |
739 | +enum fc_els_srl_flag { | |
740 | + FC_ELS_SRL_ALL = 0x00, /* scan all FL ports */ | |
741 | + FC_ELS_SRL_ONE = 0x01, /* scan specified loop */ | |
742 | + FC_ELS_SRL_EN_PER = 0x02, /* enable periodic scanning (param) */ | |
743 | + FC_ELS_SRL_DIS_PER = 0x03, /* disable periodic scanning */ | |
744 | +}; | |
745 | + | |
746 | +/* | |
747 | + * ELS RLS - Read Link Error Status Block request. | |
748 | + */ | |
749 | +struct fc_els_rls { | |
750 | + __u8 rls_cmd; /* command */ | |
751 | + __u8 rls_resv[4]; /* reserved - must be zero */ | |
752 | + __u8 rls_port_id[3]; /* port ID */ | |
753 | +}; | |
754 | + | |
755 | +/* | |
756 | + * ELS RLS LS_ACC Response. | |
757 | + */ | |
758 | +struct fc_els_rls_resp { | |
759 | + __u8 rls_cmd; /* ELS_LS_ACC */ | |
760 | + __u8 rls_resv[3]; /* reserved - must be zero */ | |
761 | + struct fc_els_lesb rls_lesb; /* link error status block */ | |
762 | +}; | |
763 | + | |
764 | +/* | |
765 | + * ELS RLIR - Registered Link Incident Report. | |
766 | + * This is followed by the CLIR and the CLID, described below. | |
767 | + */ | |
768 | +struct fc_els_rlir { | |
769 | + __u8 rlir_cmd; /* command */ | |
770 | + __u8 rlir_resv[3]; /* reserved - must be zero */ | |
771 | + __u8 rlir_fmt; /* format (FC4-type if type specific) */ | |
772 | + __u8 rlir_clr_len; /* common link incident record length */ | |
773 | + __u8 rlir_cld_len; /* common link incident desc. length */ | |
774 | + __u8 rlir_slr_len; /* spec. link incident record length */ | |
775 | +}; | |
776 | + | |
777 | +/* | |
778 | + * CLIR - Common Link Incident Record Data. - Sent via RLIR. | |
779 | + */ | |
780 | +struct fc_els_clir { | |
781 | + __be64 clir_wwpn; /* incident port name */ | |
782 | + __be64 clir_wwnn; /* incident port node name */ | |
783 | + __u8 clir_port_type; /* incident port type */ | |
784 | + __u8 clir_port_id[3]; /* incident port ID */ | |
785 | + | |
786 | + __be64 clir_conn_wwpn; /* connected port name */ | |
787 | + __be64 clir_conn_wwnn; /* connected node name */ | |
788 | + __be64 clir_fab_name; /* fabric name */ | |
789 | + __be32 clir_phys_port; /* physical port number */ | |
790 | + __be32 clir_trans_id; /* transaction ID */ | |
791 | + __u8 clir_resv[3]; /* reserved */ | |
792 | + __u8 clir_ts_fmt; /* time stamp format */ | |
793 | + __be64 clir_timestamp; /* time stamp */ | |
794 | +}; | |
795 | + | |
796 | +/* | |
797 | + * CLIR clir_ts_fmt - time stamp format values. | |
798 | + */ | |
799 | +enum fc_els_clir_ts_fmt { | |
800 | + ELS_CLIR_TS_UNKNOWN = 0, /* time stamp field unknown */ | |
801 | + ELS_CLIR_TS_SEC_FRAC = 1, /* time in seconds and fractions */ | |
802 | + ELS_CLIR_TS_CSU = 2, /* time in clock synch update format */ | |
803 | +}; | |
804 | + | |
805 | +/* | |
806 | + * Common Link Incident Descriptor - sent via RLIR. | |
807 | + */ | |
808 | +struct fc_els_clid { | |
809 | + __u8 clid_iq; /* incident qualifier flags */ | |
810 | + __u8 clid_ic; /* incident code */ | |
811 | + __be16 clid_epai; /* domain/area of ISL */ | |
812 | +}; | |
813 | + | |
814 | +/* | |
815 | + * CLID incident qualifier flags. | |
816 | + */ | |
817 | +enum fc_els_clid_iq { | |
818 | + ELS_CLID_SWITCH = 0x20, /* incident port is a switch node */ | |
819 | + ELS_CLID_E_PORT = 0x10, /* incident is an ISL (E) port */ | |
820 | + ELS_CLID_SEV_MASK = 0x0c, /* severity 2-bit field mask */ | |
821 | + ELS_CLID_SEV_INFO = 0x00, /* report is informational */ | |
822 | + ELS_CLID_SEV_INOP = 0x08, /* link not operational */ | |
823 | + ELS_CLID_SEV_DEG = 0x04, /* link degraded but operational */ | |
824 | + ELS_CLID_LASER = 0x02, /* subassembly is a laser */ | |
825 | + ELS_CLID_FRU = 0x01, /* format can identify a FRU */ | |
826 | +}; | |
827 | + | |
828 | +/* | |
829 | + * CLID incident code. | |
830 | + */ | |
831 | +enum fc_els_clid_ic { | |
832 | + ELS_CLID_IC_IMPL = 1, /* implicit incident */ | |
833 | + ELS_CLID_IC_BER = 2, /* bit-error-rate threshold exceeded */ | |
834 | + ELS_CLID_IC_LOS = 3, /* loss of synch or signal */ | |
835 | + ELS_CLID_IC_NOS = 4, /* non-operational primitive sequence */ | |
836 | + ELS_CLID_IC_PST = 5, /* primitive sequence timeout */ | |
837 | + ELS_CLID_IC_INVAL = 6, /* invalid primitive sequence */ | |
838 | + ELS_CLID_IC_LOOP_TO = 7, /* loop initialization time out */ | |
839 | + ELS_CLID_IC_LIP = 8, /* receiving LIP */ | |
840 | +}; | |
841 | + | |
842 | +#endif /* _FC_ELS_H_ */ | |
843 | diff --git a/include/scsi/fc/fc_encaps.h b/include/scsi/fc/fc_encaps.h | |
844 | new file mode 100644 | |
845 | index 0000000..f180c3e | |
846 | --- /dev/null | |
847 | +++ b/include/scsi/fc/fc_encaps.h | |
848 | @@ -0,0 +1,138 @@ | |
849 | +/* | |
850 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
851 | + * | |
852 | + * This program is free software; you can redistribute it and/or modify it | |
853 | + * under the terms and conditions of the GNU General Public License, | |
854 | + * version 2, as published by the Free Software Foundation. | |
855 | + * | |
856 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
857 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
858 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
859 | + * more details. | |
860 | + * | |
861 | + * You should have received a copy of the GNU General Public License along with | |
862 | + * this program; if not, write to the Free Software Foundation, Inc., | |
863 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
864 | + * | |
865 | + * Maintained at www.Open-FCoE.org | |
866 | + */ | |
867 | +#ifndef _FC_ENCAPS_H_ | |
868 | +#define _FC_ENCAPS_H_ | |
869 | + | |
870 | +/* | |
871 | + * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation. | |
872 | + * | |
873 | + * Note: The frame length field is the number of 32-bit words in | |
874 | + * the encapsulation including the fcip_encaps_header, CRC and EOF words. | |
875 | + * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64. | |
876 | + * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172. | |
877 | + */ | |
878 | +#define FC_ENCAPS_MIN_FRAME_LEN 64 /* min frame len (bytes) (see above) */ | |
879 | +#define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD) | |
880 | + | |
881 | +#define FC_ENCAPS_VER 1 /* current version number */ | |
882 | + | |
883 | +struct fc_encaps_hdr { | |
884 | + __u8 fc_proto; /* protocol number */ | |
885 | + __u8 fc_ver; /* version of encapsulation */ | |
886 | + __u8 fc_proto_n; /* ones complement of protocol */ | |
887 | + __u8 fc_ver_n; /* ones complement of version */ | |
888 | + | |
889 | + unsigned char fc_proto_data[8]; /* protocol specific data */ | |
890 | + | |
891 | + __be16 fc_len_flags; /* 10-bit length/4 w/ 6 flag bits */ | |
892 | + __be16 fc_len_flags_n; /* ones complement of length / flags */ | |
893 | + | |
894 | + /* | |
895 | + * Offset 0x10 | |
896 | + */ | |
897 | + __be32 fc_time[2]; /* time stamp: seconds and fraction */ | |
898 | + __be32 fc_crc; /* CRC */ | |
899 | + __be32 fc_sof; /* start of frame (see FC_SOF below) */ | |
900 | + | |
901 | + /* 0x20 - FC frame content followed by EOF word */ | |
902 | +}; | |
903 | + | |
904 | +#define FCIP_ENCAPS_HDR_LEN 0x20 /* expected length for asserts */ | |
905 | + | |
906 | +/* | |
907 | + * Macro's for making redundant copies of EOF and SOF. | |
908 | + */ | |
909 | +#define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff)) | |
910 | +#define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y)) | |
911 | +#define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff) | |
912 | + | |
913 | +#define FC_SOF_ENCODE(n) FC_XYNN(n, n) | |
914 | +#define FC_EOF_ENCODE(n) FC_XYNN(n, n) | |
915 | + | |
916 | +/* | |
917 | + * SOF / EOF bytes. | |
918 | + */ | |
919 | +enum fc_sof { | |
920 | + FC_SOF_F = 0x28, /* fabric */ | |
921 | + FC_SOF_I4 = 0x29, /* initiate class 4 */ | |
922 | + FC_SOF_I2 = 0x2d, /* initiate class 2 */ | |
923 | + FC_SOF_I3 = 0x2e, /* initiate class 3 */ | |
924 | + FC_SOF_N4 = 0x31, /* normal class 4 */ | |
925 | + FC_SOF_N2 = 0x35, /* normal class 2 */ | |
926 | + FC_SOF_N3 = 0x36, /* normal class 3 */ | |
927 | + FC_SOF_C4 = 0x39, /* activate class 4 */ | |
928 | +} __attribute__((packed)); | |
929 | + | |
930 | +enum fc_eof { | |
931 | + FC_EOF_N = 0x41, /* normal (not last frame of seq) */ | |
932 | + FC_EOF_T = 0x42, /* terminate (last frame of sequence) */ | |
933 | + FC_EOF_RT = 0x44, | |
934 | + FC_EOF_DT = 0x46, /* disconnect-terminate class-1 */ | |
935 | + FC_EOF_NI = 0x49, /* normal-invalid */ | |
936 | + FC_EOF_DTI = 0x4e, /* disconnect-terminate-invalid */ | |
937 | + FC_EOF_RTI = 0x4f, | |
938 | + FC_EOF_A = 0x50, /* abort */ | |
939 | +} __attribute__((packed)); | |
940 | + | |
941 | +#define FC_SOF_CLASS_MASK 0x06 /* mask for class of service in SOF */ | |
942 | + | |
943 | +/* | |
944 | + * Define classes in terms of the SOF code (initial). | |
945 | + */ | |
946 | +enum fc_class { | |
947 | + FC_CLASS_NONE = 0, /* software value indicating no class */ | |
948 | + FC_CLASS_2 = FC_SOF_I2, | |
949 | + FC_CLASS_3 = FC_SOF_I3, | |
950 | + FC_CLASS_4 = FC_SOF_I4, | |
951 | + FC_CLASS_F = FC_SOF_F, | |
952 | +}; | |
953 | + | |
954 | +/* | |
955 | + * Determine whether SOF code indicates the need for a BLS ACK. | |
956 | + */ | |
957 | +static inline int fc_sof_needs_ack(enum fc_sof sof) | |
958 | +{ | |
959 | + return (~sof) & 0x02; /* true for class 1, 2, 4, 6, or F */ | |
960 | +} | |
961 | + | |
962 | +/* | |
963 | + * Given an fc_class, return the normal (non-initial) SOF value. | |
964 | + */ | |
965 | +static inline enum fc_sof fc_sof_normal(enum fc_class class) | |
966 | +{ | |
967 | + return class + FC_SOF_N3 - FC_SOF_I3; /* diff is always 8 */ | |
968 | +} | |
969 | + | |
970 | +/* | |
971 | + * Compute class from SOF value. | |
972 | + */ | |
973 | +static inline enum fc_class fc_sof_class(enum fc_sof sof) | |
974 | +{ | |
975 | + return (sof & 0x7) | FC_SOF_F; | |
976 | +} | |
977 | + | |
978 | +/* | |
979 | + * Determine whether SOF is for the initial frame of a sequence. | |
980 | + */ | |
981 | +static inline int fc_sof_is_init(enum fc_sof sof) | |
982 | +{ | |
983 | + return sof < 0x30; | |
984 | +} | |
985 | + | |
986 | +#endif /* _FC_ENCAPS_H_ */ | |
987 | diff --git a/include/scsi/fc/fc_fc2.h b/include/scsi/fc/fc_fc2.h | |
988 | new file mode 100644 | |
989 | index 0000000..cff8a8c | |
990 | --- /dev/null | |
991 | +++ b/include/scsi/fc/fc_fc2.h | |
992 | @@ -0,0 +1,124 @@ | |
993 | +/* | |
994 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
995 | + * | |
996 | + * This program is free software; you can redistribute it and/or modify it | |
997 | + * under the terms and conditions of the GNU General Public License, | |
998 | + * version 2, as published by the Free Software Foundation. | |
999 | + * | |
1000 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1001 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1002 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1003 | + * more details. | |
1004 | + * | |
1005 | + * You should have received a copy of the GNU General Public License along with | |
1006 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1007 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1008 | + * | |
1009 | + * Maintained at www.Open-FCoE.org | |
1010 | + */ | |
1011 | + | |
1012 | +#ifndef _FC_FC2_H_ | |
1013 | +#define _FC_FC2_H_ | |
1014 | + | |
1015 | +/* | |
1016 | + * Fibre Channel Exchanges and Sequences. | |
1017 | + */ | |
1018 | +#ifndef PACKED | |
1019 | +#define PACKED __attribute__ ((__packed__)) | |
1020 | +#endif /* PACKED */ | |
1021 | + | |
1022 | + | |
1023 | +/* | |
1024 | + * Sequence Status Block. | |
1025 | + * This format is set by the FC-FS standard and is sent over the wire. | |
1026 | + * Note that the fields aren't all naturally aligned. | |
1027 | + */ | |
1028 | +struct fc_ssb { | |
1029 | + __u8 ssb_seq_id; /* sequence ID */ | |
1030 | + __u8 _ssb_resvd; | |
1031 | + __be16 ssb_low_seq_cnt; /* lowest SEQ_CNT */ | |
1032 | + | |
1033 | + __be16 ssb_high_seq_cnt; /* highest SEQ_CNT */ | |
1034 | + __be16 ssb_s_stat; /* sequence status flags */ | |
1035 | + | |
1036 | + __be16 ssb_err_seq_cnt; /* error SEQ_CNT */ | |
1037 | + __u8 ssb_fh_cs_ctl; /* frame header CS_CTL */ | |
1038 | + __be16 ssb_fh_ox_id; /* frame header OX_ID */ | |
1039 | + __be16 ssb_rx_id; /* responder's exchange ID */ | |
1040 | + __u8 _ssb_resvd2[2]; | |
1041 | +} PACKED; | |
1042 | + | |
1043 | +/* | |
1044 | + * The SSB should be 17 bytes. Since it's layout is somewhat strange, | |
1045 | + * we define the size here so that code can ASSERT that the size comes out | |
1046 | + * correct. | |
1047 | + */ | |
1048 | +#define FC_SSB_SIZE 17 /* length of fc_ssb for assert */ | |
1049 | + | |
1050 | +/* | |
1051 | + * ssb_s_stat - flags from FC-FS-2 T11/1619-D Rev 0.90. | |
1052 | + */ | |
1053 | +#define SSB_ST_RESP (1 << 15) /* sequence responder */ | |
1054 | +#define SSB_ST_ACTIVE (1 << 14) /* sequence is active */ | |
1055 | +#define SSB_ST_ABNORMAL (1 << 12) /* abnormal ending condition */ | |
1056 | + | |
1057 | +#define SSB_ST_REQ_MASK (3 << 10) /* ACK, abort sequence condition */ | |
1058 | +#define SSB_ST_REQ_CONT (0 << 10) | |
1059 | +#define SSB_ST_REQ_ABORT (1 << 10) | |
1060 | +#define SSB_ST_REQ_STOP (2 << 10) | |
1061 | +#define SSB_ST_REQ_RETRANS (3 << 10) | |
1062 | + | |
1063 | +#define SSB_ST_ABTS (1 << 9) /* ABTS protocol completed */ | |
1064 | +#define SSB_ST_RETRANS (1 << 8) /* retransmission completed */ | |
1065 | +#define SSB_ST_TIMEOUT (1 << 7) /* sequence timed out by recipient */ | |
1066 | +#define SSB_ST_P_RJT (1 << 6) /* P_RJT transmitted */ | |
1067 | + | |
1068 | +#define SSB_ST_CLASS_BIT 4 /* class of service field LSB */ | |
1069 | +#define SSB_ST_CLASS_MASK 3 /* class of service mask */ | |
1070 | +#define SSB_ST_ACK (1 << 3) /* ACK (EOFt or EOFdt) transmitted */ | |
1071 | + | |
1072 | +/* | |
1073 | + * Exchange Status Block. | |
1074 | + * This format is set by the FC-FS standard and is sent over the wire. | |
1075 | + * Note that the fields aren't all naturally aligned. | |
1076 | + */ | |
1077 | +struct fc_esb { | |
1078 | + __u8 esb_cs_ctl; /* CS_CTL for frame header */ | |
1079 | + __be16 esb_ox_id; /* originator exchange ID */ | |
1080 | + __be16 esb_rx_id; /* responder exchange ID */ | |
1081 | + __be32 esb_orig_fid; /* fabric ID of originator */ | |
1082 | + __be32 esb_resp_fid; /* fabric ID of responder */ | |
1083 | + __be32 esb_e_stat; /* status */ | |
1084 | + __u8 _esb_resvd[4]; | |
1085 | + __u8 esb_service_params[112]; /* TBD */ | |
1086 | + __u8 esb_seq_status[8]; /* sequence statuses, 8 bytes each */ | |
1087 | +} __attribute__((packed));; | |
1088 | + | |
1089 | + | |
1090 | +/* | |
1091 | + * Define expected size for ASSERTs. | |
1092 | + * See comments on FC_SSB_SIZE. | |
1093 | + */ | |
1094 | +#define FC_ESB_SIZE (1 + 5*4 + 112 + 8) /* expected size */ | |
1095 | + | |
1096 | +/* | |
1097 | + * esb_e_stat - flags from FC-FS-2 T11/1619-D Rev 0.90. | |
1098 | + */ | |
1099 | +#define ESB_ST_RESP (1 << 31) /* responder to exchange */ | |
1100 | +#define ESB_ST_SEQ_INIT (1 << 30) /* port holds sequence initiaive */ | |
1101 | +#define ESB_ST_COMPLETE (1 << 29) /* exchange is complete */ | |
1102 | +#define ESB_ST_ABNORMAL (1 << 28) /* abnormal ending condition */ | |
1103 | +#define ESB_ST_REC_QUAL (1 << 26) /* recovery qualifier active */ | |
1104 | + | |
1105 | +#define ESB_ST_ERRP_BIT 24 /* LSB for error policy */ | |
1106 | +#define ESB_ST_ERRP_MASK (3 << 24) /* mask for error policy */ | |
1107 | +#define ESB_ST_ERRP_MULT (0 << 24) /* abort, discard multiple sequences */ | |
1108 | +#define ESB_ST_ERRP_SING (1 << 24) /* abort, discard single sequence */ | |
1109 | +#define ESB_ST_ERRP_INF (2 << 24) /* process with infinite buffers */ | |
1110 | +#define ESB_ST_ERRP_IMM (3 << 24) /* discard mult. with immed. retran. */ | |
1111 | + | |
1112 | +#define ESB_ST_OX_ID_INVL (1 << 23) /* originator XID invalid */ | |
1113 | +#define ESB_ST_RX_ID_INVL (1 << 22) /* responder XID invalid */ | |
1114 | +#define ESB_ST_PRI_INUSE (1 << 21) /* priority / preemption in use */ | |
1115 | + | |
1116 | +#endif /* _FC_FC2_H_ */ | |
1117 | diff --git a/include/scsi/fc/fc_fcoe.h b/include/scsi/fc/fc_fcoe.h | |
1118 | new file mode 100644 | |
1119 | index 0000000..b2e07ec | |
1120 | --- /dev/null | |
1121 | +++ b/include/scsi/fc/fc_fcoe.h | |
1122 | @@ -0,0 +1,108 @@ | |
1123 | +/* | |
1124 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
1125 | + * | |
1126 | + * This program is free software; you can redistribute it and/or modify it | |
1127 | + * under the terms and conditions of the GNU General Public License, | |
1128 | + * version 2, as published by the Free Software Foundation. | |
1129 | + * | |
1130 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1131 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1132 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1133 | + * more details. | |
1134 | + * | |
1135 | + * You should have received a copy of the GNU General Public License along with | |
1136 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1137 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1138 | + * | |
1139 | + * Maintained at www.Open-FCoE.org | |
1140 | + */ | |
1141 | + | |
1142 | +#ifndef _FC_FCOE_H_ | |
1143 | +#define _FC_FCOE_H_ | |
1144 | + | |
1145 | +/* | |
1146 | + * FCoE - Fibre Channel over Ethernet. | |
1147 | + */ | |
1148 | + | |
1149 | +/* | |
1150 | + * The FCoE ethertype eventually goes in net/if_ether.h. | |
1151 | + */ | |
1152 | +#ifndef ETH_P_FCOE | |
1153 | +#define ETH_P_FCOE 0x8906 /* FCOE ether type */ | |
1154 | +#endif | |
1155 | + | |
1156 | +/* | |
1157 | + * FC_FCOE_OUI hasn't been standardized yet. XXX TBD. | |
1158 | + */ | |
1159 | +#ifndef FC_FCOE_OUI | |
1160 | +#define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE dest MAC TBD */ | |
1161 | +#endif | |
1162 | + | |
1163 | +/* | |
1164 | + * The destination MAC address for the fabric login may get a different OUI. | |
1165 | + * This isn't standardized yet. | |
1166 | + */ | |
1167 | +#ifndef FC_FCOE_FLOGI_MAC | |
1168 | +/* gateway MAC - TBD */ | |
1169 | +#define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe } | |
1170 | +#endif | |
1171 | + | |
1172 | +#define FC_FCOE_VER 0 /* version */ | |
1173 | + | |
1174 | +/* | |
1175 | + * Ethernet Addresses based on FC S_ID and D_ID. | |
1176 | + * Generated by FC_FCOE_OUI | S_ID/D_ID | |
1177 | + */ | |
1178 | +#define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n)) | |
1179 | +#define FC_FCOE_DECAPS_ID(n) ((n) >> 24) | |
1180 | + | |
1181 | +/* | |
1182 | + * FCoE frame header - 14 bytes | |
1183 | + * | |
1184 | + * This is the August 2007 version of the FCoE header as defined by T11. | |
1185 | + * This follows the VLAN header, which includes the ethertype. | |
1186 | + */ | |
1187 | +struct fcoe_hdr { | |
1188 | + __u8 fcoe_ver; /* version field - upper 4 bits */ | |
1189 | + __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */ | |
1190 | + __u8 fcoe_sof; /* start of frame per RFC 3643 */ | |
1191 | +}; | |
1192 | + | |
1193 | +#define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4) | |
1194 | +#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4) | |
1195 | + | |
1196 | +/* | |
1197 | + * FCoE CRC & EOF - 8 bytes. | |
1198 | + */ | |
1199 | +struct fcoe_crc_eof { | |
1200 | + __le32 fcoe_crc32; /* CRC for FC packet */ | |
1201 | + __u8 fcoe_eof; /* EOF from RFC 3643 */ | |
1202 | + __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */ | |
1203 | +} __attribute__((packed)); | |
1204 | + | |
1205 | +/* | |
1206 | + * Store OUI + DID into MAC address field. | |
1207 | + */ | |
1208 | +static inline void fc_fcoe_set_mac(u8 *mac, u8 *did) | |
1209 | +{ | |
1210 | + mac[0] = (u8) (FC_FCOE_OUI >> 16); | |
1211 | + mac[1] = (u8) (FC_FCOE_OUI >> 8); | |
1212 | + mac[2] = (u8) FC_FCOE_OUI; | |
1213 | + mac[3] = did[0]; | |
1214 | + mac[4] = did[1]; | |
1215 | + mac[5] = did[2]; | |
1216 | +} | |
1217 | + | |
1218 | +/* | |
1219 | + * VLAN header. This is also defined in linux/if_vlan.h, but for kernels only. | |
1220 | + */ | |
1221 | +struct fcoe_vlan_hdr { | |
1222 | + __be16 vlan_tag; /* VLAN tag including priority */ | |
1223 | + __be16 vlan_ethertype; /* encapsulated ethertype ETH_P_FCOE */ | |
1224 | +}; | |
1225 | + | |
1226 | +#ifndef ETH_P_8021Q | |
1227 | +#define ETH_P_8021Q 0x8100 | |
1228 | +#endif | |
1229 | + | |
1230 | +#endif /* _FC_FCOE_H_ */ | |
1231 | diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h | |
1232 | new file mode 100644 | |
1233 | index 0000000..5d38f19 | |
1234 | --- /dev/null | |
1235 | +++ b/include/scsi/fc/fc_fcp.h | |
1236 | @@ -0,0 +1,199 @@ | |
1237 | +/* | |
1238 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
1239 | + * | |
1240 | + * This program is free software; you can redistribute it and/or modify it | |
1241 | + * under the terms and conditions of the GNU General Public License, | |
1242 | + * version 2, as published by the Free Software Foundation. | |
1243 | + * | |
1244 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1245 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1246 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1247 | + * more details. | |
1248 | + * | |
1249 | + * You should have received a copy of the GNU General Public License along with | |
1250 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1251 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1252 | + * | |
1253 | + * Maintained at www.Open-FCoE.org | |
1254 | + */ | |
1255 | + | |
1256 | +#ifndef _FC_FCP_H_ | |
1257 | +#define _FC_FCP_H_ | |
1258 | + | |
1259 | +/* | |
1260 | + * Fibre Channel Protocol for SCSI. | |
1261 | + * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005. | |
1262 | + */ | |
1263 | + | |
1264 | +/* | |
1265 | + * fc/fs.h defines FC_TYPE_FCP. | |
1266 | + */ | |
1267 | + | |
1268 | +/* | |
1269 | + * Service parameter page parameters (word 3 bits) for Process Login. | |
1270 | + */ | |
1271 | +#define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */ | |
1272 | +#define FCP_SPPF_RETRY 0x0100 /* retry supported */ | |
1273 | +#define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */ | |
1274 | +#define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */ | |
1275 | +#define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */ | |
1276 | +#define FCP_SPPF_TARG_FCN 0x0010 /* target function */ | |
1277 | +#define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */ | |
1278 | +#define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */ | |
1279 | + | |
1280 | +/* | |
1281 | + * FCP_CMND IU Payload. | |
1282 | + */ | |
1283 | +struct fcp_cmnd { | |
1284 | + __u8 fc_lun[8]; /* logical unit number */ | |
1285 | + __u8 fc_cmdref; /* commmand reference number */ | |
1286 | + __u8 fc_pri_ta; /* priority and task attribute */ | |
1287 | + __u8 fc_tm_flags; /* task management flags */ | |
1288 | + __u8 fc_flags; /* additional len & flags */ | |
1289 | + __u8 fc_cdb[16]; /* base CDB */ | |
1290 | + __be32 fc_dl; /* data length (must follow fc_cdb) */ | |
1291 | +}; | |
1292 | + | |
1293 | +#define FCP_CMND_LEN 32 /* expected length of structure */ | |
1294 | + | |
1295 | +struct fcp_cmnd32 { | |
1296 | + __u8 fc_lun[8]; /* logical unit number */ | |
1297 | + __u8 fc_cmdref; /* commmand reference number */ | |
1298 | + __u8 fc_pri_ta; /* priority and task attribute */ | |
1299 | + __u8 fc_tm_flags; /* task management flags */ | |
1300 | + __u8 fc_flags; /* additional len & flags */ | |
1301 | + __u8 fc_cdb[32]; /* base CDB */ | |
1302 | + __be32 fc_dl; /* data length (must follow fc_cdb) */ | |
1303 | +}; | |
1304 | + | |
1305 | +#define FCP_CMND32_LEN 48 /* expected length of structure */ | |
1306 | +#define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */ | |
1307 | + | |
1308 | +/* | |
1309 | + * fc_pri_ta. | |
1310 | + */ | |
1311 | +#define FCP_PTA_SIMPLE 0 /* simple task attribute */ | |
1312 | +#define FCP_PTA_HEADQ 1 /* head of queue task attribute */ | |
1313 | +#define FCP_PTA_ORDERED 2 /* ordered task attribute */ | |
1314 | +#define FCP_PTA_ACA 4 /* auto. contigent allegiance */ | |
1315 | +#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ | |
1316 | +#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ | |
1317 | + | |
1318 | +/* | |
1319 | + * fc_tm_flags - task management flags field. | |
1320 | + */ | |
1321 | +#define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */ | |
1322 | +#define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */ | |
1323 | +#define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */ | |
1324 | +#define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */ | |
1325 | + | |
1326 | +/* | |
1327 | + * fc_flags. | |
1328 | + * Bits 7:2 are the additional FCP_CDB length / 4. | |
1329 | + */ | |
1330 | +#define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */ | |
1331 | +#define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */ | |
1332 | +#define FCP_CFL_RDDATA 0x02 /* read data */ | |
1333 | +#define FCP_CFL_WRDATA 0x01 /* write data */ | |
1334 | + | |
1335 | +/* | |
1336 | + * FCP_TXRDY IU - transfer ready payload. | |
1337 | + */ | |
1338 | +struct fcp_txrdy { | |
1339 | + __be32 ft_data_ro; /* data relative offset */ | |
1340 | + __be32 ft_burst_len; /* burst length */ | |
1341 | + __u8 _ft_resvd[4]; /* reserved */ | |
1342 | +}; | |
1343 | + | |
1344 | +#define FCP_TXRDY_LEN 12 /* expected length of structure */ | |
1345 | + | |
1346 | +/* | |
1347 | + * FCP_RESP IU - response payload. | |
1348 | + * | |
1349 | + * The response payload comes in three parts: the flags/status, the | |
1350 | + * sense/response lengths and the sense data/response info section. | |
1351 | + * | |
1352 | + * From FCP3r04, note 6 of section 9.5.13: | |
1353 | + * | |
1354 | + * Some early implementations presented the FCP_RSP IU without the FCP_RESID, | |
1355 | + * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER, | |
1356 | + * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This | |
1357 | + * non-standard behavior should be tolerated. | |
1358 | + * | |
1359 | + * All response frames will always contain the fcp_resp template. Some | |
1360 | + * will also include the fcp_resp_len template. | |
1361 | + */ | |
1362 | +struct fcp_resp { | |
1363 | + __u8 _fr_resvd[8]; /* reserved */ | |
1364 | + __be16 fr_retry_delay; /* retry delay timer */ | |
1365 | + __u8 fr_flags; /* flags */ | |
1366 | + __u8 fr_status; /* SCSI status code */ | |
1367 | +}; | |
1368 | + | |
1369 | +#define FCP_RESP_LEN 12 /* expected length of structure */ | |
1370 | + | |
1371 | +struct fcp_resp_ext { | |
1372 | + __be32 fr_resid; /* Residual value */ | |
1373 | + __be32 fr_sns_len; /* SCSI Sense length */ | |
1374 | + __be32 fr_rsp_len; /* Response Info length */ | |
1375 | + | |
1376 | + /* | |
1377 | + * Optionally followed by RSP info and/or SNS info and/or | |
1378 | + * bidirectional read residual length, if any. | |
1379 | + */ | |
1380 | +}; | |
1381 | + | |
1382 | +#define FCP_RESP_EXT_LEN 12 /* expected length of the structure */ | |
1383 | + | |
1384 | +struct fcp_resp_rsp_info { | |
1385 | + __u8 _fr_resvd[3]; /* reserved */ | |
1386 | + __u8 rsp_code; /* Response Info Code */ | |
1387 | + __u8 _fr_resvd2[4]; /* reserved */ | |
1388 | +}; | |
1389 | + | |
1390 | +struct fcp_resp_with_ext { | |
1391 | + struct fcp_resp resp; | |
1392 | + struct fcp_resp_ext ext; | |
1393 | +}; | |
1394 | + | |
1395 | +#define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN) | |
1396 | + | |
1397 | +/* | |
1398 | + * fr_flags. | |
1399 | + */ | |
1400 | +#define FCP_BIDI_RSP 0x80 /* bidirectional read response */ | |
1401 | +#define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */ | |
1402 | +#define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */ | |
1403 | +#define FCP_CONF_REQ 0x10 /* confirmation requested */ | |
1404 | +#define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */ | |
1405 | +#define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */ | |
1406 | +#define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */ | |
1407 | +#define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */ | |
1408 | + | |
1409 | +/* | |
1410 | + * rsp_codes | |
1411 | + */ | |
1412 | +enum fcp_resp_rsp_codes { | |
1413 | + FCP_TMF_CMPL = 0, | |
1414 | + FCP_DATA_LEN_INVALID = 1, | |
1415 | + FCP_CMND_FIELDS_INVALID = 2, | |
1416 | + FCP_DATA_PARAM_MISMATCH = 3, | |
1417 | + FCP_TMF_REJECTED = 4, | |
1418 | + FCP_TMF_FAILED = 5, | |
1419 | + FCP_TMF_INVALID_LUN = 9, | |
1420 | +}; | |
1421 | + | |
1422 | +/* | |
1423 | + * FCP SRR Link Service request - Sequence Retransmission Request. | |
1424 | + */ | |
1425 | +struct fcp_srr { | |
1426 | + __u8 srr_op; /* opcode ELS_SRR */ | |
1427 | + __u8 srr_resvd[3]; /* opcode / reserved - must be zero */ | |
1428 | + __be16 srr_ox_id; /* OX_ID of failed command */ | |
1429 | + __be16 srr_rx_id; /* RX_ID of failed command */ | |
1430 | + __be32 srr_rel_off; /* relative offset */ | |
1431 | + __u8 srr_r_ctl; /* r_ctl for the information unit */ | |
1432 | + __u8 srr_resvd2[3]; /* reserved */ | |
1433 | +}; | |
1434 | + | |
1435 | +#endif /* _FC_FCP_H_ */ | |
1436 | diff --git a/include/scsi/fc/fc_fs.h b/include/scsi/fc/fc_fs.h | |
1437 | new file mode 100644 | |
1438 | index 0000000..ba6df64 | |
1439 | --- /dev/null | |
1440 | +++ b/include/scsi/fc/fc_fs.h | |
1441 | @@ -0,0 +1,344 @@ | |
1442 | +/* | |
1443 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
1444 | + * | |
1445 | + * This program is free software; you can redistribute it and/or modify it | |
1446 | + * under the terms and conditions of the GNU General Public License, | |
1447 | + * version 2, as published by the Free Software Foundation. | |
1448 | + * | |
1449 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1450 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1451 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1452 | + * more details. | |
1453 | + * | |
1454 | + * You should have received a copy of the GNU General Public License along with | |
1455 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1456 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1457 | + * | |
1458 | + * Maintained at www.Open-FCoE.org | |
1459 | + */ | |
1460 | + | |
1461 | +#ifndef _FC_FS_H_ | |
1462 | +#define _FC_FS_H_ | |
1463 | + | |
1464 | +/* | |
1465 | + * Fibre Channel Framing and Signalling definitions. | |
1466 | + * From T11 FC-FS-2 Rev 0.90 - 9 August 2005. | |
1467 | + */ | |
1468 | + | |
1469 | +/* | |
1470 | + * Frame header | |
1471 | + */ | |
1472 | +struct fc_frame_header { | |
1473 | + __u8 fh_r_ctl; /* routing control */ | |
1474 | + __u8 fh_d_id[3]; /* Destination ID */ | |
1475 | + | |
1476 | + __u8 fh_cs_ctl; /* class of service control / pri */ | |
1477 | + __u8 fh_s_id[3]; /* Source ID */ | |
1478 | + | |
1479 | + __u8 fh_type; /* see enum fc_fh_type below */ | |
1480 | + __u8 fh_f_ctl[3]; /* frame control */ | |
1481 | + | |
1482 | + __u8 fh_seq_id; /* sequence ID */ | |
1483 | + __u8 fh_df_ctl; /* data field control */ | |
1484 | + __be16 fh_seq_cnt; /* sequence count */ | |
1485 | + | |
1486 | + __be16 fh_ox_id; /* originator exchange ID */ | |
1487 | + __be16 fh_rx_id; /* responder exchange ID */ | |
1488 | + __be32 fh_parm_offset; /* parameter or relative offset */ | |
1489 | +}; | |
1490 | + | |
1491 | +#define FC_FRAME_HEADER_LEN 24 /* expected length of structure */ | |
1492 | + | |
1493 | +#define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */ | |
1494 | +#define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */ | |
1495 | + | |
1496 | +#define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN) | |
1497 | +#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN) | |
1498 | + | |
1499 | +/* | |
1500 | + * fh_r_ctl - Routing control definitions. | |
1501 | + */ | |
1502 | + /* | |
1503 | + * FC-4 device_data. | |
1504 | + */ | |
1505 | +enum fc_rctl { | |
1506 | + FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */ | |
1507 | + FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */ | |
1508 | + FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */ | |
1509 | + FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */ | |
1510 | + FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */ | |
1511 | + FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */ | |
1512 | + FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */ | |
1513 | + FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */ | |
1514 | + | |
1515 | +#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */ | |
1516 | +#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */ | |
1517 | + | |
1518 | + /* | |
1519 | + * Extended Link_Data | |
1520 | + */ | |
1521 | + FC_RCTL_ELS_REQ = 0x22, /* extended link services request */ | |
1522 | + FC_RCTL_ELS_REP = 0x23, /* extended link services reply */ | |
1523 | + FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */ | |
1524 | + FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */ | |
1525 | + /* | |
1526 | + * Basic Link Services fh_r_ctl values. | |
1527 | + */ | |
1528 | + FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */ | |
1529 | + FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */ | |
1530 | + FC_RCTL_BA_RMC = 0x82, /* remove connection */ | |
1531 | + FC_RCTL_BA_ACC = 0x84, /* basic accept */ | |
1532 | + FC_RCTL_BA_RJT = 0x85, /* basic reject */ | |
1533 | + FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */ | |
1534 | + /* | |
1535 | + * Link Control Information. | |
1536 | + */ | |
1537 | + FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */ | |
1538 | + FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */ | |
1539 | + FC_RCTL_P_RJT = 0xc2, /* port reject */ | |
1540 | + FC_RCTL_F_RJT = 0xc3, /* fabric reject */ | |
1541 | + FC_RCTL_P_BSY = 0xc4, /* port busy */ | |
1542 | + FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */ | |
1543 | + FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */ | |
1544 | + FC_RCTL_LCR = 0xc7, /* link credit reset */ | |
1545 | + FC_RCTL_END = 0xc9, /* end */ | |
1546 | +}; | |
1547 | + /* incomplete list of definitions */ | |
1548 | + | |
1549 | +/* | |
1550 | + * R_CTL names initializer. | |
1551 | + * Please keep this matching the above definitions. | |
1552 | + */ | |
1553 | +#define FC_RCTL_NAMES_INIT { \ | |
1554 | + [FC_RCTL_DD_UNCAT] = "uncat", \ | |
1555 | + [FC_RCTL_DD_SOL_DATA] = "sol data", \ | |
1556 | + [FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \ | |
1557 | + [FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \ | |
1558 | + [FC_RCTL_DD_UNSOL_DATA] = "unsol data", \ | |
1559 | + [FC_RCTL_DD_DATA_DESC] = "data desc", \ | |
1560 | + [FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \ | |
1561 | + [FC_RCTL_DD_CMD_STATUS] = "cmd status", \ | |
1562 | + [FC_RCTL_ELS_REQ] = "ELS req", \ | |
1563 | + [FC_RCTL_ELS_REP] = "ELS rep", \ | |
1564 | + [FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \ | |
1565 | + [FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \ | |
1566 | + [FC_RCTL_BA_NOP] = "BLS NOP", \ | |
1567 | + [FC_RCTL_BA_ABTS] = "BLS abort", \ | |
1568 | + [FC_RCTL_BA_RMC] = "BLS remove connection", \ | |
1569 | + [FC_RCTL_BA_ACC] = "BLS accept", \ | |
1570 | + [FC_RCTL_BA_RJT] = "BLS reject", \ | |
1571 | + [FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \ | |
1572 | + [FC_RCTL_ACK_1] = "LC ACK_1", \ | |
1573 | + [FC_RCTL_ACK_0] = "LC ACK_0", \ | |
1574 | + [FC_RCTL_P_RJT] = "LC port reject", \ | |
1575 | + [FC_RCTL_F_RJT] = "LC fabric reject", \ | |
1576 | + [FC_RCTL_P_BSY] = "LC port busy", \ | |
1577 | + [FC_RCTL_F_BSY] = "LC fabric busy to data frame", \ | |
1578 | + [FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\ | |
1579 | + [FC_RCTL_LCR] = "LC link credit reset", \ | |
1580 | + [FC_RCTL_END] = "LC end", \ | |
1581 | +} | |
1582 | + | |
1583 | +/* | |
1584 | + * Well-known fabric addresses. | |
1585 | + */ | |
1586 | +enum fc_well_known_fid { | |
1587 | + FC_FID_BCAST = 0xffffff, /* broadcast */ | |
1588 | + FC_FID_FLOGI = 0xfffffe, /* fabric login */ | |
1589 | + FC_FID_FCTRL = 0xfffffd, /* fabric controller */ | |
1590 | + FC_FID_DIR_SERV = 0xfffffc, /* directory server */ | |
1591 | + FC_FID_TIME_SERV = 0xfffffb, /* time server */ | |
1592 | + FC_FID_MGMT_SERV = 0xfffffa, /* management server */ | |
1593 | + FC_FID_QOS = 0xfffff9, /* QoS Facilitator */ | |
1594 | + FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */ | |
1595 | + FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */ | |
1596 | + FC_FID_CLOCK = 0xfffff6, /* clock synch server */ | |
1597 | + FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */ | |
1598 | +}; | |
1599 | + | |
1600 | +#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */ | |
1601 | +#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */ | |
1602 | + | |
1603 | +/* | |
1604 | + * Other well-known addresses, outside the above contiguous range. | |
1605 | + */ | |
1606 | +#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */ | |
1607 | + | |
1608 | +/* | |
1609 | + * Fabric ID bytes. | |
1610 | + */ | |
1611 | +#define FC_FID_DOMAIN 0 | |
1612 | +#define FC_FID_PORT 1 | |
1613 | +#define FC_FID_LINK 2 | |
1614 | + | |
1615 | +/* | |
1616 | + * fh_type codes | |
1617 | + */ | |
1618 | +enum fc_fh_type { | |
1619 | + FC_TYPE_BLS = 0x00, /* basic link service */ | |
1620 | + FC_TYPE_ELS = 0x01, /* extended link service */ | |
1621 | + FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */ | |
1622 | + FC_TYPE_FCP = 0x08, /* SCSI FCP */ | |
1623 | + FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */ | |
1624 | + FC_TYPE_ILS = 0x22, /* internal link service */ | |
1625 | +}; | |
1626 | + | |
1627 | +/* | |
1628 | + * FC_TYPE names initializer. | |
1629 | + * Please keep this matching the above definitions. | |
1630 | + */ | |
1631 | +#define FC_TYPE_NAMES_INIT { \ | |
1632 | + [FC_TYPE_BLS] = "BLS", \ | |
1633 | + [FC_TYPE_ELS] = "ELS", \ | |
1634 | + [FC_TYPE_IP] = "IP", \ | |
1635 | + [FC_TYPE_FCP] = "FCP", \ | |
1636 | + [FC_TYPE_CT] = "CT", \ | |
1637 | + [FC_TYPE_ILS] = "ILS", \ | |
1638 | +} | |
1639 | + | |
1640 | +/* | |
1641 | + * Exchange IDs. | |
1642 | + */ | |
1643 | +#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */ | |
1644 | + | |
1645 | +/* | |
1646 | + * fh_f_ctl - Frame control flags. | |
1647 | + */ | |
1648 | +#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */ | |
1649 | +#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */ | |
1650 | +#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */ | |
1651 | +#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */ | |
1652 | +#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */ | |
1653 | +#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */ | |
1654 | +#define FC_FC_RES_B17 (1 << 17) /* reserved */ | |
1655 | +#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */ | |
1656 | +#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */ | |
1657 | +#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */ | |
1658 | + | |
1659 | +#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */ | |
1660 | +#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */ | |
1661 | +#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */ | |
1662 | + | |
1663 | +#define FC_FC_RES_B11 (1 << 11) /* reserved */ | |
1664 | +#define FC_FC_RES_B10 (1 << 10) /* reserved */ | |
1665 | +#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */ | |
1666 | +#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */ | |
1667 | +#define FC_FC_CONT_SEQ(i) ((i) << 6) | |
1668 | +#define FC_FC_ABT_SEQ(i) ((i) << 4) | |
1669 | +#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */ | |
1670 | +#define FC_FC_RES2 (1 << 2) /* reserved */ | |
1671 | +#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */ | |
1672 | + | |
1673 | +/* | |
1674 | + * BA_ACC payload. | |
1675 | + */ | |
1676 | +struct fc_ba_acc { | |
1677 | + __u8 ba_seq_id_val; /* SEQ_ID validity */ | |
1678 | +#define FC_BA_SEQ_ID_VAL 0x80 | |
1679 | + __u8 ba_seq_id; /* SEQ_ID of seq last deliverable */ | |
1680 | + __u8 ba_resvd[2]; /* reserved */ | |
1681 | + __be16 ba_ox_id; /* OX_ID for aborted seq or exch */ | |
1682 | + __be16 ba_rx_id; /* RX_ID for aborted seq or exch */ | |
1683 | + __be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */ | |
1684 | + __be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */ | |
1685 | +}; | |
1686 | + | |
1687 | +/* | |
1688 | + * BA_RJT: Basic Reject payload. | |
1689 | + */ | |
1690 | +struct fc_ba_rjt { | |
1691 | + __u8 br_resvd; /* reserved */ | |
1692 | + __u8 br_reason; /* reason code */ | |
1693 | + __u8 br_explan; /* reason explanation */ | |
1694 | + __u8 br_vendor; /* vendor unique code */ | |
1695 | +}; | |
1696 | + | |
1697 | +/* | |
1698 | + * BA_RJT reason codes. | |
1699 | + * From FS-2. | |
1700 | + */ | |
1701 | +enum fc_ba_rjt_reason { | |
1702 | + FC_BA_RJT_NONE = 0, /* in software this means no reject */ | |
1703 | + FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */ | |
1704 | + FC_BA_RJT_LOG_ERR = 0x03, /* logical error */ | |
1705 | + FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */ | |
1706 | + FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */ | |
1707 | + FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */ | |
1708 | + FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */ | |
1709 | +}; | |
1710 | + | |
1711 | +/* | |
1712 | + * BA_RJT reason code explanations. | |
1713 | + */ | |
1714 | +enum fc_ba_rjt_explan { | |
1715 | + FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */ | |
1716 | + FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */ | |
1717 | + FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */ | |
1718 | +}; | |
1719 | + | |
1720 | +/* | |
1721 | + * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field. | |
1722 | + */ | |
1723 | +struct fc_pf_rjt { | |
1724 | + __u8 rj_action; /* reserved */ | |
1725 | + __u8 rj_reason; /* reason code */ | |
1726 | + __u8 rj_resvd; /* reserved */ | |
1727 | + __u8 rj_vendor; /* vendor unique code */ | |
1728 | +}; | |
1729 | + | |
1730 | +/* | |
1731 | + * P_RJT and F_RJT reject reason codes. | |
1732 | + */ | |
1733 | +enum fc_pf_rjt_reason { | |
1734 | + FC_RJT_NONE = 0, /* non-reject (reserved by standard) */ | |
1735 | + FC_RJT_INVL_DID = 0x01, /* invalid destination ID */ | |
1736 | + FC_RJT_INVL_SID = 0x02, /* invalid source ID */ | |
1737 | + FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */ | |
1738 | + FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */ | |
1739 | + FC_RJT_CLS_UNSUP = 0x05, /* class not supported */ | |
1740 | + FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */ | |
1741 | + FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */ | |
1742 | + FC_RJT_LINK_CTL = 0x08, /* invalid link control */ | |
1743 | + FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */ | |
1744 | + FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */ | |
1745 | + FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */ | |
1746 | + FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */ | |
1747 | + FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */ | |
1748 | + FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */ | |
1749 | + FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */ | |
1750 | + FC_RJT_PARAM = 0x10, /* invalid parameter field */ | |
1751 | + FC_RJT_EXCH_ERR = 0x11, /* exchange error */ | |
1752 | + FC_RJT_PROTO = 0x12, /* protocol error */ | |
1753 | + FC_RJT_LEN = 0x13, /* incorrect length */ | |
1754 | + FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */ | |
1755 | + FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */ | |
1756 | + FC_RJT_LOGI_REQ = 0x16, /* login required */ | |
1757 | + FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */ | |
1758 | + FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */ | |
1759 | + FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */ | |
1760 | + FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */ | |
1761 | + FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */ | |
1762 | + FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */ | |
1763 | + FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */ | |
1764 | + FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */ | |
1765 | + FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */ | |
1766 | + FC_RJT_MCAST_ERR = 0x22, /* multicast error */ | |
1767 | + FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */ | |
1768 | + FC_RJT_PRLI_REQ = 0x24, /* process login required */ | |
1769 | + FC_RJT_INVL_ATT = 0x25, /* invalid attachment */ | |
1770 | + FC_RJT_VENDOR = 0xff, /* vendor specific reject */ | |
1771 | +}; | |
1772 | + | |
1773 | +/* | |
1774 | + * Data descriptor format (R_CTL == FC_RCTL_DD_DATA_DESC). | |
1775 | + * This is used for FCP SCSI transfer ready. | |
1776 | + */ | |
1777 | +struct fc_data_desc { | |
1778 | + __be32 dd_offset; /* data relative offset in bytes */ | |
1779 | + __be32 dd_len; /* transfer buffer size in bytes */ | |
1780 | + __u8 _dd_resvd[4]; | |
1781 | +}; | |
1782 | + | |
1783 | +#define FC_DATA_DESC_LEN 12 /* expected length of structure */ | |
1784 | + | |
1785 | +#endif /* _FC_FS_H_ */ | |
1786 | diff --git a/include/scsi/fc/fc_gs.h b/include/scsi/fc/fc_gs.h | |
1787 | new file mode 100644 | |
1788 | index 0000000..ffab027 | |
1789 | --- /dev/null | |
1790 | +++ b/include/scsi/fc/fc_gs.h | |
1791 | @@ -0,0 +1,93 @@ | |
1792 | +/* | |
1793 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
1794 | + * | |
1795 | + * This program is free software; you can redistribute it and/or modify it | |
1796 | + * under the terms and conditions of the GNU General Public License, | |
1797 | + * version 2, as published by the Free Software Foundation. | |
1798 | + * | |
1799 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1800 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1801 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1802 | + * more details. | |
1803 | + * | |
1804 | + * You should have received a copy of the GNU General Public License along with | |
1805 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1806 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1807 | + * | |
1808 | + * Maintained at www.Open-FCoE.org | |
1809 | + */ | |
1810 | + | |
1811 | +#ifndef _FC_GS_H_ | |
1812 | +#define _FC_GS_H_ | |
1813 | + | |
1814 | +/* | |
1815 | + * Fibre Channel Services - Common Transport. | |
1816 | + * From T11.org FC-GS-2 Rev 5.3 November 1998. | |
1817 | + */ | |
1818 | + | |
1819 | +struct fc_ct_hdr { | |
1820 | + __u8 ct_rev; /* revision */ | |
1821 | + __u8 ct_in_id[3]; /* N_Port ID of original requestor */ | |
1822 | + __u8 ct_fs_type; /* type of fibre channel service */ | |
1823 | + __u8 ct_fs_subtype; /* subtype */ | |
1824 | + __u8 ct_options; | |
1825 | + __u8 _ct_resvd1; | |
1826 | + __be16 ct_cmd; /* command / response code */ | |
1827 | + __be16 ct_mr_size; /* maximum / residual size */ | |
1828 | + __u8 _ct_resvd2; | |
1829 | + __u8 ct_reason; /* reject reason */ | |
1830 | + __u8 ct_explan; /* reason code explanation */ | |
1831 | + __u8 ct_vendor; /* vendor unique data */ | |
1832 | +}; | |
1833 | + | |
1834 | +#define FC_CT_HDR_LEN 16 /* expected sizeof (struct fc_ct_hdr) */ | |
1835 | + | |
1836 | +enum fc_ct_rev { | |
1837 | + FC_CT_REV = 1 /* common transport revision */ | |
1838 | +}; | |
1839 | + | |
1840 | +/* | |
1841 | + * ct_fs_type values. | |
1842 | + */ | |
1843 | +enum fc_ct_fs_type { | |
1844 | + FC_FST_ALIAS = 0xf8, /* alias service */ | |
1845 | + FC_FST_MGMT = 0xfa, /* management service */ | |
1846 | + FC_FST_TIME = 0xfb, /* time service */ | |
1847 | + FC_FST_DIR = 0xfc, /* directory service */ | |
1848 | +}; | |
1849 | + | |
1850 | +/* | |
1851 | + * ct_cmd: Command / response codes | |
1852 | + */ | |
1853 | +enum fc_ct_cmd { | |
1854 | + FC_FS_RJT = 0x8001, /* reject */ | |
1855 | + FC_FS_ACC = 0x8002, /* accept */ | |
1856 | +}; | |
1857 | + | |
1858 | +/* | |
1859 | + * FS_RJT reason codes. | |
1860 | + */ | |
1861 | +enum fc_ct_reason { | |
1862 | + FC_FS_RJT_CMD = 0x01, /* invalid command code */ | |
1863 | + FC_FS_RJT_VER = 0x02, /* invalid version level */ | |
1864 | + FC_FS_RJT_LOG = 0x03, /* logical error */ | |
1865 | + FC_FS_RJT_IUSIZ = 0x04, /* invalid IU size */ | |
1866 | + FC_FS_RJT_BSY = 0x05, /* logical busy */ | |
1867 | + FC_FS_RJT_PROTO = 0x07, /* protocol error */ | |
1868 | + FC_FS_RJT_UNABL = 0x09, /* unable to perform command request */ | |
1869 | + FC_FS_RJT_UNSUP = 0x0b, /* command not supported */ | |
1870 | +}; | |
1871 | + | |
1872 | +/* | |
1873 | + * FS_RJT reason code explanations. | |
1874 | + */ | |
1875 | +enum fc_ct_explan { | |
1876 | + FC_FS_EXP_NONE = 0x00, /* no additional explanation */ | |
1877 | + FC_FS_EXP_PID = 0x01, /* port ID not registered */ | |
1878 | + FC_FS_EXP_PNAM = 0x02, /* port name not registered */ | |
1879 | + FC_FS_EXP_NNAM = 0x03, /* node name not registered */ | |
1880 | + FC_FS_EXP_COS = 0x04, /* class of service not registered */ | |
1881 | + /* definitions not complete */ | |
1882 | +}; | |
1883 | + | |
1884 | +#endif /* _FC_GS_H_ */ | |
1885 | diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h | |
1886 | new file mode 100644 | |
1887 | index 0000000..790d7b9 | |
1888 | --- /dev/null | |
1889 | +++ b/include/scsi/fc/fc_ns.h | |
1890 | @@ -0,0 +1,159 @@ | |
1891 | +/* | |
1892 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
1893 | + * | |
1894 | + * This program is free software; you can redistribute it and/or modify it | |
1895 | + * under the terms and conditions of the GNU General Public License, | |
1896 | + * version 2, as published by the Free Software Foundation. | |
1897 | + * | |
1898 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
1899 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
1900 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
1901 | + * more details. | |
1902 | + * | |
1903 | + * You should have received a copy of the GNU General Public License along with | |
1904 | + * this program; if not, write to the Free Software Foundation, Inc., | |
1905 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
1906 | + * | |
1907 | + * Maintained at www.Open-FCoE.org | |
1908 | + */ | |
1909 | + | |
1910 | +#ifndef _FC_NS_H_ | |
1911 | +#define _FC_NS_H_ | |
1912 | + | |
1913 | +/* | |
1914 | + * Fibre Channel Services - Name Service (dNS) | |
1915 | + * From T11.org FC-GS-2 Rev 5.3 November 1998. | |
1916 | + */ | |
1917 | + | |
1918 | +/* | |
1919 | + * Common-transport sub-type for Name Server. | |
1920 | + */ | |
1921 | +#define FC_NS_SUBTYPE 2 /* fs_ct_hdr.ct_fs_subtype */ | |
1922 | + | |
1923 | +/* | |
1924 | + * Name server Requests. | |
1925 | + * Note: this is an incomplete list, some unused requests are omitted. | |
1926 | + */ | |
1927 | +enum fc_ns_req { | |
1928 | + FC_NS_GA_NXT = 0x0100, /* get all next */ | |
1929 | + FC_NS_GI_A = 0x0101, /* get identifiers - scope */ | |
1930 | + FC_NS_GPN_ID = 0x0112, /* get port name by ID */ | |
1931 | + FC_NS_GNN_ID = 0x0113, /* get node name by ID */ | |
1932 | + FC_NS_GID_PN = 0x0121, /* get ID for port name */ | |
1933 | + FC_NS_GID_NN = 0x0131, /* get IDs for node name */ | |
1934 | + FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */ | |
1935 | + FC_NS_GPN_FT = 0x0172, /* get port names by FC4 type */ | |
1936 | + FC_NS_GID_PT = 0x01a1, /* get IDs by port type */ | |
1937 | + FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */ | |
1938 | + FC_NS_RPN_ID = 0x0212, /* reg port name for ID */ | |
1939 | + FC_NS_RNN_ID = 0x0213, /* reg node name for ID */ | |
1940 | +}; | |
1941 | + | |
1942 | +/* | |
1943 | + * Port type values. | |
1944 | + */ | |
1945 | +enum fc_ns_pt { | |
1946 | + FC_NS_UNID_PORT = 0x00, /* unidentified */ | |
1947 | + FC_NS_N_PORT = 0x01, /* N port */ | |
1948 | + FC_NS_NL_PORT = 0x02, /* NL port */ | |
1949 | + FC_NS_FNL_PORT = 0x03, /* F/NL port */ | |
1950 | + FC_NS_NX_PORT = 0x7f, /* Nx port */ | |
1951 | + FC_NS_F_PORT = 0x81, /* F port */ | |
1952 | + FC_NS_FL_PORT = 0x82, /* FL port */ | |
1953 | + FC_NS_E_PORT = 0x84, /* E port */ | |
1954 | + FC_NS_B_PORT = 0x85, /* B port */ | |
1955 | +}; | |
1956 | + | |
1957 | +/* | |
1958 | + * Port type object. | |
1959 | + */ | |
1960 | +struct fc_ns_pt_obj { | |
1961 | + __u8 pt_type; | |
1962 | +}; | |
1963 | + | |
1964 | +/* | |
1965 | + * Port ID object | |
1966 | + */ | |
1967 | +struct fc_ns_fid { | |
1968 | + __u8 fp_flags; /* flags for responses only */ | |
1969 | + __u8 fp_fid[3]; | |
1970 | +}; | |
1971 | + | |
1972 | +/* | |
1973 | + * fp_flags in port ID object, for responses only. | |
1974 | + */ | |
1975 | +#define FC_NS_FID_LAST 0x80 /* last object */ | |
1976 | + | |
1977 | +/* | |
1978 | + * FC4-types object. | |
1979 | + */ | |
1980 | +#define FC_NS_TYPES 256 /* number of possible FC-4 types */ | |
1981 | +#define FC_NS_BPW 32 /* bits per word in bitmap */ | |
1982 | + | |
1983 | +struct fc_ns_fts { | |
1984 | + __be32 ff_type_map[FC_NS_TYPES / FC_NS_BPW]; /* bitmap of FC-4 types */ | |
1985 | +}; | |
1986 | + | |
1987 | +/* | |
1988 | + * GID_PT request. | |
1989 | + */ | |
1990 | +struct fc_ns_gid_pt { | |
1991 | + __u8 fn_pt_type; | |
1992 | + __u8 fn_domain_id_scope; | |
1993 | + __u8 fn_area_id_scope; | |
1994 | + __u8 fn_resvd; | |
1995 | +}; | |
1996 | + | |
1997 | +/* | |
1998 | + * GID_FT or GPN_FT request. | |
1999 | + */ | |
2000 | +struct fc_ns_gid_ft { | |
2001 | + __u8 fn_resvd; | |
2002 | + __u8 fn_domain_id_scope; | |
2003 | + __u8 fn_area_id_scope; | |
2004 | + __u8 fn_fc4_type; | |
2005 | +}; | |
2006 | + | |
2007 | +/* | |
2008 | + * GPN_FT response. | |
2009 | + */ | |
2010 | +struct fc_gpn_ft_resp { | |
2011 | + __u8 fp_flags; /* see fp_flags definitions above */ | |
2012 | + __u8 fp_fid[3]; /* port ID */ | |
2013 | + __be32 fp_resvd; | |
2014 | + __be64 fp_wwpn; /* port name */ | |
2015 | +}; | |
2016 | + | |
2017 | +/* | |
2018 | + * GID_PN request | |
2019 | + */ | |
2020 | +struct fc_ns_gid_pn { | |
2021 | + __be64 fn_wwpn; /* port name */ | |
2022 | +}; | |
2023 | + | |
2024 | +/* | |
2025 | + * GID_PN response | |
2026 | + */ | |
2027 | +struct fc_gid_pn_resp { | |
2028 | + __u8 fp_resvd; | |
2029 | + __u8 fp_fid[3]; /* port ID */ | |
2030 | +}; | |
2031 | + | |
2032 | +/* | |
2033 | + * RFT_ID request - register FC-4 types for ID. | |
2034 | + */ | |
2035 | +struct fc_ns_rft_id { | |
2036 | + struct fc_ns_fid fr_fid; /* port ID object */ | |
2037 | + struct fc_ns_fts fr_fts; /* FC-4 types object */ | |
2038 | +}; | |
2039 | + | |
2040 | +/* | |
2041 | + * RPN_ID request - register port name for ID. | |
2042 | + * RNN_ID request - register node name for ID. | |
2043 | + */ | |
2044 | +struct fc_ns_rn_id { | |
2045 | + struct fc_ns_fid fr_fid; /* port ID object */ | |
2046 | + __be64 fr_wwn; /* node name or port name */ | |
2047 | +} __attribute__((__packed__)); | |
2048 | + | |
2049 | +#endif /* _FC_NS_H_ */ | |
2050 | diff --git a/include/scsi/libfc/fc_frame.h b/include/scsi/libfc/fc_frame.h | |
2051 | new file mode 100644 | |
2052 | index 0000000..c7a52bb | |
2053 | --- /dev/null | |
2054 | +++ b/include/scsi/libfc/fc_frame.h | |
2055 | @@ -0,0 +1,236 @@ | |
2056 | +/* | |
2057 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
2058 | + * | |
2059 | + * This program is free software; you can redistribute it and/or modify it | |
2060 | + * under the terms and conditions of the GNU General Public License, | |
2061 | + * version 2, as published by the Free Software Foundation. | |
2062 | + * | |
2063 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
2064 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
2065 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
2066 | + * more details. | |
2067 | + * | |
2068 | + * You should have received a copy of the GNU General Public License along with | |
2069 | + * this program; if not, write to the Free Software Foundation, Inc., | |
2070 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
2071 | + * | |
2072 | + * Maintained at www.Open-FCoE.org | |
2073 | + */ | |
2074 | + | |
2075 | +#ifndef _FC_FRAME_H_ | |
2076 | +#define _FC_FRAME_H_ | |
2077 | + | |
2078 | +#include <linux/scatterlist.h> | |
2079 | +#include <linux/skbuff.h> | |
2080 | + | |
2081 | +#include <scsi/fc/fc_fs.h> | |
2082 | +#include <scsi/fc/fc_encaps.h> | |
2083 | + | |
2084 | +/* | |
2085 | + * The fc_frame interface is used to pass frame data between functions. | |
2086 | + * The frame includes the data buffer, length, and SOF / EOF delimiter types. | |
2087 | + * A pointer to the port structure of the receiving port is also includeded. | |
2088 | + */ | |
2089 | + | |
2090 | +#define FC_FRAME_HEADROOM 32 /* headroom for VLAN + FCoE headers */ | |
2091 | +#define FC_FRAME_TAILROOM 8 /* trailer space for FCoE */ | |
2092 | + | |
2093 | +/* | |
2094 | + * Information about an individual fibre channel frame received or to be sent. | |
2095 | + * The buffer may be in up to 4 additional non-contiguous sections, | |
2096 | + * but the linear section must hold the frame header. | |
2097 | + */ | |
2098 | +#define FC_FRAME_SG_LEN 4 /* scatter/gather list maximum length */ | |
2099 | + | |
2100 | +#define fp_skb(fp) (&((fp)->skb)) | |
2101 | +#define fr_hdr(fp) ((fp)->skb.data) | |
2102 | +#define fr_len(fp) ((fp)->skb.len) | |
2103 | +#define fr_cb(fp) ((struct fcoe_rcv_info *)&((fp)->skb.cb[0])) | |
2104 | +#define fr_dev(fp) (fr_cb(fp)->fr_dev) | |
2105 | +#define fr_seq(fp) (fr_cb(fp)->fr_seq) | |
2106 | +#define fr_sof(fp) (fr_cb(fp)->fr_sof) | |
2107 | +#define fr_eof(fp) (fr_cb(fp)->fr_eof) | |
2108 | +#define fr_flags(fp) (fr_cb(fp)->fr_flags) | |
2109 | + | |
2110 | +struct fc_frame { | |
2111 | + struct sk_buff skb; | |
2112 | +}; | |
2113 | + | |
2114 | +struct fcoe_rcv_info { | |
2115 | + struct packet_type *ptype; | |
2116 | + struct fc_lport *fr_dev; /* transport layer private pointer */ | |
2117 | + struct fc_seq *fr_seq; /* for use with exchange manager */ | |
2118 | + enum fc_sof fr_sof; /* start of frame delimiter */ | |
2119 | + enum fc_eof fr_eof; /* end of frame delimiter */ | |
2120 | + u8 fr_flags; /* flags - see below */ | |
2121 | +}; | |
2122 | + | |
2123 | +/* | |
2124 | + * Get fc_frame pointer for an skb that's already been imported. | |
2125 | + */ | |
2126 | +static inline struct fcoe_rcv_info *fcoe_dev_from_skb(const struct sk_buff *skb) | |
2127 | +{ | |
2128 | + BUILD_BUG_ON(sizeof(struct fcoe_rcv_info) > sizeof(skb->cb)); | |
2129 | + return (struct fcoe_rcv_info *) skb->cb; | |
2130 | +} | |
2131 | + | |
2132 | +/* | |
2133 | + * fr_flags. | |
2134 | + */ | |
2135 | +#define FCPHF_CRC_UNCHECKED 0x01 /* CRC not computed, still appended */ | |
2136 | + | |
2137 | +/* | |
2138 | + * Initialize a frame. | |
2139 | + * We don't do a complete memset here for performance reasons. | |
2140 | + * The caller must set fr_free, fr_hdr, fr_len, fr_sof, and fr_eof eventually. | |
2141 | + */ | |
2142 | +static inline void fc_frame_init(struct fc_frame *fp) | |
2143 | +{ | |
2144 | + fr_dev(fp) = NULL; | |
2145 | + fr_seq(fp) = NULL; | |
2146 | + fr_flags(fp) = 0; | |
2147 | +} | |
2148 | + | |
2149 | +struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len); | |
2150 | + | |
2151 | +struct fc_frame *__fc_frame_alloc(size_t payload_len); | |
2152 | + | |
2153 | +/* | |
2154 | + * Get frame for sending via port. | |
2155 | + */ | |
2156 | +static inline struct fc_frame *_fc_frame_alloc(struct fc_lport *dev, | |
2157 | + size_t payload_len) | |
2158 | +{ | |
2159 | + return __fc_frame_alloc(payload_len); | |
2160 | +} | |
2161 | + | |
2162 | +/* | |
2163 | + * Allocate fc_frame structure and buffer. Set the initial length to | |
2164 | + * payload_size + sizeof (struct fc_frame_header). | |
2165 | + */ | |
2166 | +static inline struct fc_frame *fc_frame_alloc(struct fc_lport *dev, size_t len) | |
2167 | +{ | |
2168 | + struct fc_frame *fp; | |
2169 | + | |
2170 | + /* | |
2171 | + * Note: Since len will often be a constant multiple of 4, | |
2172 | + * this check will usually be evaluated and eliminated at compile time. | |
2173 | + */ | |
2174 | + if ((len % 4) != 0) | |
2175 | + fp = fc_frame_alloc_fill(dev, len); | |
2176 | + else | |
2177 | + fp = _fc_frame_alloc(dev, len); | |
2178 | + return fp; | |
2179 | +} | |
2180 | + | |
2181 | +/* | |
2182 | + * Free the fc_frame structure and buffer. | |
2183 | + */ | |
2184 | +static inline void fc_frame_free(struct fc_frame *fp) | |
2185 | +{ | |
2186 | + kfree_skb(fp_skb(fp)); | |
2187 | +} | |
2188 | + | |
2189 | +static inline int fc_frame_is_linear(struct fc_frame *fp) | |
2190 | +{ | |
2191 | + return !skb_is_nonlinear(fp_skb(fp)); | |
2192 | +} | |
2193 | + | |
2194 | +/* | |
2195 | + * Get frame header from message in fc_frame structure. | |
2196 | + * This hides a cast and provides a place to add some checking. | |
2197 | + */ | |
2198 | +static inline | |
2199 | +struct fc_frame_header *fc_frame_header_get(const struct fc_frame *fp) | |
2200 | +{ | |
2201 | + WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header)); | |
2202 | + return (struct fc_frame_header *) fr_hdr(fp); | |
2203 | +} | |
2204 | + | |
2205 | +/* | |
2206 | + * Get frame payload from message in fc_frame structure. | |
2207 | + * This hides a cast and provides a place to add some checking. | |
2208 | + * The len parameter is the minimum length for the payload portion. | |
2209 | + * Returns NULL if the frame is too short. | |
2210 | + * | |
2211 | + * This assumes the interesting part of the payload is in the first part | |
2212 | + * of the buffer for received data. This may not be appropriate to use for | |
2213 | + * buffers being transmitted. | |
2214 | + */ | |
2215 | +static inline void *fc_frame_payload_get(const struct fc_frame *fp, | |
2216 | + size_t len) | |
2217 | +{ | |
2218 | + void *pp = NULL; | |
2219 | + | |
2220 | + if (fr_len(fp) >= sizeof(struct fc_frame_header) + len) | |
2221 | + pp = fc_frame_header_get(fp) + 1; | |
2222 | + return pp; | |
2223 | +} | |
2224 | + | |
2225 | +/* | |
2226 | + * Get frame payload opcode (first byte) from message in fc_frame structure. | |
2227 | + * This hides a cast and provides a place to add some checking. Return 0 | |
2228 | + * if the frame has no payload. | |
2229 | + */ | |
2230 | +static inline u8 fc_frame_payload_op(const struct fc_frame *fp) | |
2231 | +{ | |
2232 | + u8 *cp; | |
2233 | + | |
2234 | + cp = fc_frame_payload_get(fp, sizeof(u8)); | |
2235 | + if (!cp) | |
2236 | + return 0; | |
2237 | + return *cp; | |
2238 | + | |
2239 | +} | |
2240 | + | |
2241 | +/* | |
2242 | + * Get FC class from frame. | |
2243 | + */ | |
2244 | +static inline enum fc_class fc_frame_class(const struct fc_frame *fp) | |
2245 | +{ | |
2246 | + return fc_sof_class(fr_sof(fp)); | |
2247 | +} | |
2248 | + | |
2249 | +/* | |
2250 | + * Set r_ctl and type in preparation for sending frame. | |
2251 | + * This also clears fh_parm_offset. | |
2252 | + */ | |
2253 | +static inline void fc_frame_setup(struct fc_frame *fp, enum fc_rctl r_ctl, | |
2254 | + enum fc_fh_type type) | |
2255 | +{ | |
2256 | + struct fc_frame_header *fh; | |
2257 | + | |
2258 | + fh = fc_frame_header_get(fp); | |
2259 | + WARN_ON(r_ctl == 0); | |
2260 | + fh->fh_r_ctl = r_ctl; | |
2261 | + fh->fh_type = type; | |
2262 | + fh->fh_parm_offset = htonl(0); | |
2263 | +} | |
2264 | + | |
2265 | +/* | |
2266 | + * Set offset in preparation for sending frame. | |
2267 | + */ | |
2268 | +static inline void | |
2269 | +fc_frame_set_offset(struct fc_frame *fp, u32 offset) | |
2270 | +{ | |
2271 | + struct fc_frame_header *fh; | |
2272 | + | |
2273 | + fh = fc_frame_header_get(fp); | |
2274 | + fh->fh_parm_offset = htonl(offset); | |
2275 | +} | |
2276 | + | |
2277 | +/* | |
2278 | + * Check the CRC in a frame. | |
2279 | + * The CRC immediately follows the last data item *AFTER* the length. | |
2280 | + * The return value is zero if the CRC matches. | |
2281 | + */ | |
2282 | +u32 fc_frame_crc_check(struct fc_frame *); | |
2283 | + | |
2284 | +/* | |
2285 | + * Check for leaks. | |
2286 | + * Print the frame header of any currently allocated frame, assuming there | |
2287 | + * should be none at this point. | |
2288 | + */ | |
2289 | +void fc_frame_leak_check(void); | |
2290 | + | |
2291 | +#endif /* _FC_FRAME_H_ */ | |
2292 | diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h | |
2293 | new file mode 100644 | |
2294 | index 0000000..b139aed | |
2295 | --- /dev/null | |
2296 | +++ b/include/scsi/libfc/libfc.h | |
2297 | @@ -0,0 +1,760 @@ | |
2298 | +/* | |
2299 | + * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
2300 | + * | |
2301 | + * This program is free software; you can redistribute it and/or modify it | |
2302 | + * under the terms and conditions of the GNU General Public License, | |
2303 | + * version 2, as published by the Free Software Foundation. | |
2304 | + * | |
2305 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
2306 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
2307 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
2308 | + * more details. | |
2309 | + * | |
2310 | + * You should have received a copy of the GNU General Public License along with | |
2311 | + * this program; if not, write to the Free Software Foundation, Inc., | |
2312 | + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
2313 | + * | |
2314 | + * Maintained at www.Open-FCoE.org | |
2315 | + */ | |
2316 | + | |
2317 | +#ifndef _LIBFC_H_ | |
2318 | +#define _LIBFC_H_ | |
2319 | + | |
2320 | +#include <linux/timer.h> | |
2321 | +#include <linux/if.h> | |
2322 | + | |
2323 | +#include <scsi/scsi_transport.h> | |
2324 | +#include <scsi/scsi_transport_fc.h> | |
2325 | + | |
2326 | +#include <scsi/fc/fc_fcp.h> | |
2327 | +#include <scsi/fc/fc_ns.h> | |
2328 | +#include <scsi/fc/fc_els.h> | |
2329 | + | |
2330 | +#include <scsi/libfc/fc_frame.h> | |
2331 | + | |
2332 | +#define LIBFC_DEBUG | |
2333 | + | |
2334 | +#ifdef LIBFC_DEBUG | |
2335 | +/* | |
2336 | + * Log message. | |
2337 | + */ | |
2338 | +#define FC_DBG(fmt, args...) \ | |
2339 | + do { \ | |
2340 | + printk(KERN_INFO "%s " fmt, __func__, ##args); \ | |
2341 | + } while (0) | |
2342 | +#else | |
2343 | +#define FC_DBG(fmt, args...) | |
2344 | +#endif | |
2345 | + | |
2346 | +/* | |
2347 | + * libfc error codes | |
2348 | + */ | |
2349 | +#define FC_NO_ERR 0 /* no error */ | |
2350 | +#define FC_EX_TIMEOUT 1 /* Exchange timeout */ | |
2351 | +#define FC_EX_CLOSED 2 /* Exchange closed */ | |
2352 | + | |
2353 | +/* some helpful macros */ | |
2354 | + | |
2355 | +#define ntohll(x) be64_to_cpu(x) | |
2356 | +#define htonll(x) cpu_to_be64(x) | |
2357 | + | |
2358 | +#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) | |
2359 | + | |
2360 | +#define hton24(p, v) do { \ | |
2361 | + p[0] = (((v) >> 16) & 0xFF); \ | |
2362 | + p[1] = (((v) >> 8) & 0xFF); \ | |
2363 | + p[2] = ((v) & 0xFF); \ | |
2364 | +} while (0) | |
2365 | + | |
2366 | +struct fc_exch_mgr; | |
2367 | + | |
2368 | +/* | |
2369 | + * tgt_flags | |
2370 | + */ | |
2371 | +#define FC_TGT_REC_SUPPORTED (1 << 0) | |
2372 | + | |
2373 | +/* | |
2374 | + * FC HBA status | |
2375 | + */ | |
2376 | +#define FC_PAUSE (1 << 1) | |
2377 | +#define FC_LINK_UP (1 << 0) | |
2378 | + | |
2379 | +/* for fc_softc */ | |
2380 | +#define FC_MAX_OUTSTANDING_COMMANDS 1024 | |
2381 | + | |
2382 | +/* | |
2383 | + * Transport Capabilities | |
2384 | + */ | |
2385 | +#define TRANS_C_SG (1 << 0) /* Scatter gather */ | |
2386 | + | |
2387 | +enum fc_lport_state { | |
2388 | + LPORT_ST_NONE = 0, | |
2389 | + LPORT_ST_FLOGI, | |
2390 | + LPORT_ST_DNS, | |
2391 | + LPORT_ST_REG_PN, | |
2392 | + LPORT_ST_REG_FT, | |
2393 | + LPORT_ST_SCR, | |
2394 | + LPORT_ST_READY, | |
2395 | + LPORT_ST_DNS_STOP, | |
2396 | + LPORT_ST_LOGO, | |
2397 | + LPORT_ST_RESET | |
2398 | +}; | |
2399 | + | |
2400 | +enum fc_rport_state { | |
2401 | + RPORT_ST_NONE = 0, | |
2402 | + RPORT_ST_INIT, /* initialized */ | |
2403 | + RPORT_ST_STARTED, /* started */ | |
2404 | + RPORT_ST_PLOGI, /* waiting for PLOGI completion */ | |
2405 | + RPORT_ST_PLOGI_RECV, /* received PLOGI (as target) */ | |
2406 | + RPORT_ST_PRLI, /* waiting for PRLI completion */ | |
2407 | + RPORT_ST_RTV, /* waiting for RTV completion */ | |
2408 | + RPORT_ST_ERROR, /* error */ | |
2409 | + RPORT_ST_READY, /* ready for use */ | |
2410 | + RPORT_ST_LOGO, /* port logout sent */ | |
2411 | +}; | |
2412 | + | |
2413 | +/** | |
2414 | + * struct fc_rport_libfc_priv - libfc internal information about a remote port | |
2415 | + * @local_port: Fibre Channel host port instance | |
2416 | + * @rp_state: state tracks progress of PLOGI, PRLI, and RTV exchanges | |
2417 | + * @flags: REC and RETRY supported flags | |
2418 | + * @max_seq: maximum number of concurrent sequences | |
2419 | + * @retries: retry count in current state | |
2420 | + * @e_d_tov: error detect timeout value (in msec) | |
2421 | + * @r_a_tov: resource allocation timeout value (in msec) | |
2422 | + * @rp_lock: lock protects state | |
2423 | + * @retry_work: | |
2424 | + */ | |
2425 | +struct fc_rport_libfc_priv { | |
2426 | + struct fc_lport *local_port; | |
2427 | + enum fc_rport_state rp_state; | |
2428 | + u16 flags; | |
2429 | + #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) | |
2430 | + #define FC_RP_FLAGS_RETRY (1 << 1) | |
2431 | + u16 max_seq; | |
2432 | + unsigned int retries; | |
2433 | + unsigned int e_d_tov; | |
2434 | + unsigned int r_a_tov; | |
2435 | + spinlock_t rp_lock; | |
2436 | + struct delayed_work retry_work; | |
2437 | +}; | |
2438 | + | |
2439 | +static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn) | |
2440 | +{ | |
2441 | + rport->node_name = wwnn; | |
2442 | + rport->port_name = wwpn; | |
2443 | +} | |
2444 | + | |
2445 | +/* | |
2446 | + * fcoe stats structure | |
2447 | + */ | |
2448 | +struct fcoe_dev_stats { | |
2449 | + u64 SecondsSinceLastReset; | |
2450 | + u64 TxFrames; | |
2451 | + u64 TxWords; | |
2452 | + u64 RxFrames; | |
2453 | + u64 RxWords; | |
2454 | + u64 ErrorFrames; | |
2455 | + u64 DumpedFrames; | |
2456 | + u64 LinkFailureCount; | |
2457 | + u64 LossOfSignalCount; | |
2458 | + u64 InvalidTxWordCount; | |
2459 | + u64 InvalidCRCCount; | |
2460 | + u64 InputRequests; | |
2461 | + u64 OutputRequests; | |
2462 | + u64 ControlRequests; | |
2463 | + u64 InputMegabytes; | |
2464 | + u64 OutputMegabytes; | |
2465 | +}; | |
2466 | + | |
2467 | +/* | |
2468 | + * els data is used for passing ELS respone specific | |
2469 | + * data to send ELS response mainly using infomation | |
2470 | + * in exchange and sequence in EM layer. | |
2471 | + */ | |
2472 | +struct fc_seq_els_data { | |
2473 | + struct fc_frame *fp; | |
2474 | + enum fc_els_rjt_reason reason; | |
2475 | + enum fc_els_rjt_explan explan; | |
2476 | +}; | |
2477 | + | |
2478 | +struct libfc_function_template { | |
2479 | + | |
2480 | + /** | |
2481 | + * Mandatory Fields | |
2482 | + * | |
2483 | + * These handlers must be implemented by the LLD. | |
2484 | + */ | |
2485 | + | |
2486 | + /* | |
2487 | + * Interface to send a FC frame | |
2488 | + */ | |
2489 | + int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); | |
2490 | + | |
2491 | + /** | |
2492 | + * Optional Fields | |
2493 | + * | |
2494 | + * The LLD may choose to implement any of the following handlers. | |
2495 | + * If LLD doesn't specify hander and leaves its pointer NULL then | |
2496 | + * the default libfc function will be used for that handler. | |
2497 | + */ | |
2498 | + | |
2499 | + /** | |
2500 | + * Exhance Manager interfaces | |
2501 | + */ | |
2502 | + | |
2503 | + /* | |
2504 | + * Send the FC frame payload using a new exchange and sequence. | |
2505 | + * | |
2506 | + * The frame pointer with some of the header's fields must be | |
2507 | + * filled before calling exch_seq_send(), those fields are, | |
2508 | + * | |
2509 | + * - routing control | |
2510 | + * - FC header type | |
2511 | + * - parameter or relative offset | |
2512 | + * | |
2513 | + * The exchange response handler is set in this routine to resp() | |
2514 | + * function pointer. It can be called in two scenarios: if a timeout | |
2515 | + * occurs or if a response frame is received for the exchange. The | |
2516 | + * fc_frame pointer in response handler will also indicate timeout | |
2517 | + * as error using IS_ERR related macros. | |
2518 | + * | |
2519 | + * The response handler argumemt resp_arg is passed back to resp | |
2520 | + * handler when it is invoked by EM layer in above mentioned | |
2521 | + * two scenarios. | |
2522 | + * | |
2523 | + * The timeout value (in msec) for an exchange is set if non zero | |
2524 | + * timer_msec argument is specified. The timer is canceled when | |
2525 | + * it fires or when the exchange is done. The exchange timeout handler | |
2526 | + * is registered by EM layer. | |
2527 | + * | |
2528 | + * The caller also need to specify FC sid, did and frame control field. | |
2529 | + */ | |
2530 | + struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, | |
2531 | + struct fc_frame *fp, | |
2532 | + void (*resp)(struct fc_seq *, | |
2533 | + struct fc_frame *fp, | |
2534 | + void *arg), | |
2535 | + void *resp_arg, unsigned int timer_msec, | |
2536 | + u32 sid, u32 did, u32 f_ctl); | |
2537 | + | |
2538 | + /* | |
2539 | + * send a frame using existing sequence and exchange. | |
2540 | + */ | |
2541 | + int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, | |
2542 | + struct fc_frame *fp, u32 f_ctl); | |
2543 | + | |
2544 | + /* | |
2545 | + * Send ELS response using mainly infomation | |
2546 | + * in exchange and sequence in EM layer. | |
2547 | + */ | |
2548 | + void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, | |
2549 | + struct fc_seq_els_data *els_data); | |
2550 | + | |
2551 | + /* | |
2552 | + * Abort an exchange and sequence. Generally called because of a | |
2553 | + * exchange timeout or an abort from the upper layer. | |
2554 | + * | |
2555 | + * A timer_msec can be specified for abort timeout, if non-zero | |
2556 | + * timer_msec value is specified then exchange resp handler | |
2557 | + * will be called with timeout error if no response to abort. | |
2558 | + */ | |
2559 | + int (*seq_exch_abort)(const struct fc_seq *req_sp, | |
2560 | + unsigned int timer_msec); | |
2561 | + | |
2562 | + /* | |
2563 | + * Indicate that an exchange/sequence tuple is complete and the memory | |
2564 | + * allocated for the related objects may be freed. | |
2565 | + */ | |
2566 | + void (*exch_done)(struct fc_seq *sp); | |
2567 | + | |
2568 | + /* | |
2569 | + * Assigns a EM and a free XID for an new exchange and then | |
2570 | + * allocates a new exchange and sequence pair. | |
2571 | + * The fp can be used to determine free XID. | |
2572 | + */ | |
2573 | + struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp); | |
2574 | + | |
2575 | + /* | |
2576 | + * Release previously assigned XID by exch_get API. | |
2577 | + * The LLD may implement this if XID is assigned by LLD | |
2578 | + * in exch_get(). | |
2579 | + */ | |
2580 | + void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp, | |
2581 | + u16 ex_id); | |
2582 | + | |
2583 | + /* | |
2584 | + * Start a new sequence on the same exchange/sequence tuple. | |
2585 | + */ | |
2586 | + struct fc_seq *(*seq_start_next)(struct fc_seq *sp); | |
2587 | + | |
2588 | + /* | |
2589 | + * Reset an exchange manager, completing all sequences and exchanges. | |
2590 | + * If s_id is non-zero, reset only exchanges originating from that FID. | |
2591 | + * If d_id is non-zero, reset only exchanges sending to that FID. | |
2592 | + */ | |
2593 | + void (*exch_mgr_reset)(struct fc_exch_mgr *, | |
2594 | + u32 s_id, u32 d_id); | |
2595 | + | |
2596 | + /* | |
2597 | + * Get exchange Ids of a sequence | |
2598 | + */ | |
2599 | + void (*seq_get_xids)(struct fc_seq *sp, u16 *oxid, u16 *rxid); | |
2600 | + | |
2601 | + /* | |
2602 | + * Set REC data to a sequence | |
2603 | + */ | |
2604 | + void (*seq_set_rec_data)(struct fc_seq *sp, u32 rec_data); | |
2605 | + | |
2606 | + /** | |
2607 | + * Local Port interfaces | |
2608 | + */ | |
2609 | + | |
2610 | + /* | |
2611 | + * Receive a frame to a local port. | |
2612 | + */ | |
2613 | + void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, | |
2614 | + struct fc_frame *fp); | |
2615 | + | |
2616 | + int (*lport_login)(struct fc_lport *); | |
2617 | + int (*lport_reset)(struct fc_lport *); | |
2618 | + int (*lport_logout)(struct fc_lport *); | |
2619 | + | |
2620 | + /** | |
2621 | + * Remote Port interfaces | |
2622 | + */ | |
2623 | + | |
2624 | + /* | |
2625 | + * Initiates the RP state machine. It is called from the LP module. | |
2626 | + * This function will issue the following commands to the N_Port | |
2627 | + * identified by the FC ID provided. | |
2628 | + * | |
2629 | + * - PLOGI | |
2630 | + * - PRLI | |
2631 | + * - RTV | |
2632 | + */ | |
2633 | + int (*rport_login)(struct fc_rport *rport); | |
2634 | + | |
2635 | + /* | |
2636 | + * Logs the specified local port out of a N_Port identified | |
2637 | + * by the ID provided. | |
2638 | + */ | |
2639 | + int (*rport_logout)(struct fc_rport *rport); | |
2640 | + | |
2641 | + void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, | |
2642 | + struct fc_rport *); | |
2643 | + | |
2644 | + struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); | |
2645 | + | |
2646 | + struct fc_rport *(*rport_create)(struct fc_lport *, | |
2647 | + struct fc_rport_identifiers *); | |
2648 | + | |
2649 | + void (*rport_reset)(struct fc_rport *); | |
2650 | + | |
2651 | + void (*rport_reset_list)(struct fc_lport *); | |
2652 | + | |
2653 | + /** | |
2654 | + * SCSI interfaces | |
2655 | + */ | |
2656 | + | |
2657 | + /* | |
2658 | + * Used at least durring linkdown and reset | |
2659 | + */ | |
2660 | + void (*scsi_cleanup)(struct fc_lport *); | |
2661 | + | |
2662 | + /* | |
2663 | + * Abort all I/O on a local port | |
2664 | + */ | |
2665 | + void (*scsi_abort_io)(struct fc_lport *); | |
2666 | + | |
2667 | + /** | |
2668 | + * Discovery interfaces | |
2669 | + */ | |
2670 | + | |
2671 | + void (*disc_recv_req)(struct fc_seq *, | |
2672 | + struct fc_frame *, struct fc_lport *); | |
2673 | + | |
2674 | + /* | |
2675 | + * Start discovery for a local port. | |
2676 | + */ | |
2677 | + int (*disc_start)(struct fc_lport *); | |
2678 | + | |
2679 | + void (*dns_register)(struct fc_lport *); | |
2680 | + void (*disc_stop)(struct fc_lport *); | |
2681 | +}; | |
2682 | + | |
2683 | +struct fc_lport { | |
2684 | + struct list_head list; | |
2685 | + | |
2686 | + /* Associations */ | |
2687 | + struct Scsi_Host *host; | |
2688 | + struct fc_exch_mgr *emp; | |
2689 | + struct fc_rport *dns_rp; | |
2690 | + struct fc_rport *ptp_rp; | |
2691 | + void *scsi_priv; | |
2692 | + | |
2693 | + /* Operational Information */ | |
2694 | + struct libfc_function_template tt; | |
2695 | + u16 link_status; | |
2696 | + u8 ns_disc_done; | |
2697 | + enum fc_lport_state state; | |
2698 | + unsigned long boot_time; | |
2699 | + | |
2700 | + struct fc_host_statistics host_stats; | |
2701 | + struct fcoe_dev_stats *dev_stats[NR_CPUS]; | |
2702 | + | |
2703 | + u64 wwpn; | |
2704 | + u64 wwnn; | |
2705 | + u32 fid; | |
2706 | + u8 retry_count; | |
2707 | + unsigned char ns_disc_retry_count; | |
2708 | + unsigned char ns_disc_delay; | |
2709 | + unsigned char ns_disc_pending; | |
2710 | + unsigned char ns_disc_requested; | |
2711 | + unsigned short ns_disc_seq_count; | |
2712 | + unsigned char ns_disc_buf_len; | |
2713 | + | |
2714 | + /* Capabilities */ | |
2715 | + char ifname[IFNAMSIZ]; | |
2716 | + u32 capabilities; | |
2717 | + u32 mfs; /* max FC payload size */ | |
2718 | + unsigned int service_params; | |
2719 | + unsigned int e_d_tov; | |
2720 | + unsigned int r_a_tov; | |
2721 | + u8 max_retry_count; | |
2722 | + u16 link_speed; | |
2723 | + u16 link_supported_speeds; | |
2724 | + struct fc_ns_fts fcts; /* FC-4 type masks */ | |
2725 | + struct fc_els_rnid_gen rnid_gen; /* RNID information */ | |
2726 | + | |
2727 | + /* Locks */ | |
2728 | + spinlock_t state_lock; /* serializes state changes */ | |
2729 | + | |
2730 | + /* Miscellaneous */ | |
2731 | + struct fc_gpn_ft_resp ns_disc_buf; /* partial name buffer */ | |
2732 | + struct timer_list state_timer; /* timer for state events */ | |
2733 | + struct delayed_work ns_disc_work; | |
2734 | + | |
2735 | + void *drv_priv; | |
2736 | +}; | |
2737 | + | |
2738 | +/** | |
2739 | + * FC_LPORT HELPER FUNCTIONS | |
2740 | + *****************************/ | |
2741 | + | |
2742 | +static inline int fc_lport_test_ready(struct fc_lport *lp) | |
2743 | +{ | |
2744 | + return lp->state == LPORT_ST_READY; | |
2745 | +} | |
2746 | + | |
2747 | +static inline u32 fc_lport_get_fid(const struct fc_lport *lp) | |
2748 | +{ | |
2749 | + return lp->fid; | |
2750 | +} | |
2751 | + | |
2752 | +static inline void fc_set_wwnn(struct fc_lport *lp, u64 wwnn) | |
2753 | +{ | |
2754 | + lp->wwnn = wwnn; | |
2755 | +} | |
2756 | + | |
2757 | +static inline void fc_set_wwpn(struct fc_lport *lp, u64 wwnn) | |
2758 | +{ | |
2759 | + lp->wwpn = wwnn; | |
2760 | +} | |
2761 | + | |
2762 | +static inline int fc_lport_locked(struct fc_lport *lp) | |
2763 | +{ | |
2764 | +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | |
2765 | + return spin_is_locked(&lp->state_lock); | |
2766 | +#else | |
2767 | + return 1; | |
2768 | +#endif /* CONFIG_SMP || CONFIG_DEBUG_SPINLOCK */ | |
2769 | +} | |
2770 | + | |
2771 | +/* | |
2772 | + * Locking code. | |
2773 | + */ | |
2774 | +static inline void fc_lport_lock(struct fc_lport *lp) | |
2775 | +{ | |
2776 | + spin_lock_bh(&lp->state_lock); | |
2777 | +} | |
2778 | + | |
2779 | +static inline void fc_lport_unlock(struct fc_lport *lp) | |
2780 | +{ | |
2781 | + spin_unlock_bh(&lp->state_lock); | |
2782 | +} | |
2783 | + | |
2784 | +static inline void fc_lport_state_enter(struct fc_lport *lp, | |
2785 | + enum fc_lport_state state) | |
2786 | +{ | |
2787 | + WARN_ON(!fc_lport_locked(lp)); | |
2788 | + del_timer(&lp->state_timer); | |
2789 | + if (state != lp->state) | |
2790 | + lp->retry_count = 0; | |
2791 | + lp->state = state; | |
2792 | +} | |
2793 | + | |
2794 | + | |
2795 | +/** | |
2796 | + * LOCAL PORT LAYER | |
2797 | + *****************************/ | |
2798 | +int fc_lport_init(struct fc_lport *lp); | |
2799 | + | |
2800 | +/* | |
2801 | + * Destroy the specified local port by finding and freeing all | |
2802 | + * fc_rports associated with it and then by freeing the fc_lport | |
2803 | + * itself. | |
2804 | + */ | |
2805 | +int fc_lport_destroy(struct fc_lport *lp); | |
2806 | + | |
2807 | +/* | |
2808 | + * Logout the specified local port from the fabric | |
2809 | + */ | |
2810 | +int fc_fabric_logoff(struct fc_lport *lp); | |
2811 | + | |
2812 | +/* | |
2813 | + * Initiate the LP state machine. This handler will use fc_host_attr | |
2814 | + * to store the FLOGI service parameters, so fc_host_attr must be | |
2815 | + * initialized before calling this handler. | |
2816 | + */ | |
2817 | +int fc_fabric_login(struct fc_lport *lp); | |
2818 | + | |
2819 | +/* | |
2820 | + * The link is up for the given local port. | |
2821 | + */ | |
2822 | +void fc_linkup(struct fc_lport *); | |
2823 | + | |
2824 | +/* | |
2825 | + * Link is down for the given local port. | |
2826 | + */ | |
2827 | +void fc_linkdown(struct fc_lport *); | |
2828 | + | |
2829 | +/* | |
2830 | + * Pause and unpause traffic. | |
2831 | + */ | |
2832 | +void fc_pause(struct fc_lport *); | |
2833 | +void fc_unpause(struct fc_lport *); | |
2834 | + | |
2835 | +/* | |
2836 | + * Configure the local port. | |
2837 | + */ | |
2838 | +int fc_lport_config(struct fc_lport *); | |
2839 | + | |
2840 | +/* | |
2841 | + * Reset the local port. | |
2842 | + */ | |
2843 | +int fc_lport_enter_reset(struct fc_lport *); | |
2844 | + | |
2845 | +/* | |
2846 | + * Set the mfs or reset | |
2847 | + */ | |
2848 | +int fc_set_mfs(struct fc_lport *lp, u32 mfs); | |
2849 | + | |
2850 | + | |
2851 | +/** | |
2852 | + * REMOTE PORT LAYER | |
2853 | + *****************************/ | |
2854 | +int fc_rport_init(struct fc_lport *lp); | |
2855 | + | |
2856 | + | |
2857 | +/** | |
2858 | + * DISCOVERY LAYER | |
2859 | + *****************************/ | |
2860 | +int fc_ns_init(struct fc_lport *lp); | |
2861 | + | |
2862 | + | |
2863 | +/** | |
2864 | + * SCSI LAYER | |
2865 | + *****************************/ | |
2866 | +/* | |
2867 | + * Initialize the SCSI block of libfc | |
2868 | + */ | |
2869 | +int fc_fcp_init(struct fc_lport *); | |
2870 | + | |
2871 | +/* | |
2872 | + * This section provides an API which allows direct interaction | |
2873 | + * with the SCSI-ml. Each of these functions satisfies a function | |
2874 | + * pointer defined in Scsi_Host and therefore is always called | |
2875 | + * directly from the SCSI-ml. | |
2876 | + */ | |
2877 | +int fc_queuecommand(struct scsi_cmnd *sc_cmd, | |
2878 | + void (*done)(struct scsi_cmnd *)); | |
2879 | + | |
2880 | +/* | |
2881 | + * Send an ABTS frame to the target device. The sc_cmd argument | |
2882 | + * is a pointer to the SCSI command to be aborted. | |
2883 | + */ | |
2884 | +int fc_eh_abort(struct scsi_cmnd *sc_cmd); | |
2885 | + | |
2886 | +/* | |
2887 | + * Reset a LUN by sending send the tm cmd to the target. | |
2888 | + */ | |
2889 | +int fc_eh_device_reset(struct scsi_cmnd *sc_cmd); | |
2890 | + | |
2891 | +/* | |
2892 | + * Reset the host adapter. | |
2893 | + */ | |
2894 | +int fc_eh_host_reset(struct scsi_cmnd *sc_cmd); | |
2895 | + | |
2896 | +/* | |
2897 | + * Check rport status. | |
2898 | + */ | |
2899 | +int fc_slave_alloc(struct scsi_device *sdev); | |
2900 | + | |
2901 | +/* | |
2902 | + * Adjust the queue depth. | |
2903 | + */ | |
2904 | +int fc_change_queue_depth(struct scsi_device *sdev, int qdepth); | |
2905 | + | |
2906 | +/* | |
2907 | + * Change the tag type. | |
2908 | + */ | |
2909 | +int fc_change_queue_type(struct scsi_device *sdev, int tag_type); | |
2910 | + | |
2911 | +/* | |
2912 | + * Free memory pools used by the FCP layer. | |
2913 | + */ | |
2914 | +void fc_fcp_destroy(struct fc_lport *); | |
2915 | + | |
2916 | + | |
2917 | +/** | |
2918 | + * EXCHANGE MANAGER LAYER | |
2919 | + *****************************/ | |
2920 | +/* | |
2921 | + * Initializes Exchange Manager related | |
2922 | + * function pointers in struct libfc_function_template. | |
2923 | + */ | |
2924 | +int fc_exch_init(struct fc_lport *lp); | |
2925 | + | |
2926 | +/* | |
2927 | + * Allocates an Exchange Manager (EM). | |
2928 | + * | |
2929 | + * The EM manages exchanges for their allocation and | |
2930 | + * free, also allows exchange lookup for received | |
2931 | + * frame. | |
2932 | + * | |
2933 | + * The class is used for initializing FC class of | |
2934 | + * allocated exchange from EM. | |
2935 | + * | |
2936 | + * The min_xid and max_xid will limit new | |
2937 | + * exchange ID (XID) within this range for | |
2938 | + * a new exchange. | |
2939 | + * The LLD may choose to have multiple EMs, | |
2940 | + * e.g. one EM instance per CPU receive thread in LLD. | |
2941 | + * The LLD can use exch_get() of struct libfc_function_template | |
2942 | + * to specify XID for a new exchange within | |
2943 | + * a specified EM instance. | |
2944 | + * | |
2945 | + * The em_idx to uniquely identify an EM instance. | |
2946 | + */ | |
2947 | +struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | |
2948 | + enum fc_class class, | |
2949 | + u16 min_xid, | |
2950 | + u16 max_xid); | |
2951 | + | |
2952 | +/* | |
2953 | + * Free an exchange manager. | |
2954 | + */ | |
2955 | +void fc_exch_mgr_free(struct fc_exch_mgr *mp); | |
2956 | + | |
2957 | +/* | |
2958 | + * Receive a frame on specified local port and exchange manager. | |
2959 | + */ | |
2960 | +void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp, | |
2961 | + struct fc_frame *fp); | |
2962 | + | |
2963 | +/* | |
2964 | + * This function is for exch_seq_send function pointer in | |
2965 | + * struct libfc_function_template, see comment block on | |
2966 | + * exch_seq_send for description of this function. | |
2967 | + */ | |
2968 | +struct fc_seq *fc_exch_seq_send(struct fc_lport *lp, | |
2969 | + struct fc_frame *fp, | |
2970 | + void (*resp)(struct fc_seq *, | |
2971 | + struct fc_frame *fp, | |
2972 | + void *arg), | |
2973 | + void *resp_arg, u32 timer_msec, | |
2974 | + u32 sid, u32 did, u32 f_ctl); | |
2975 | + | |
2976 | +/* | |
2977 | + * send a frame using existing sequence and exchange. | |
2978 | + */ | |
2979 | +int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, | |
2980 | + struct fc_frame *fp, u32 f_ctl); | |
2981 | + | |
2982 | +/* | |
2983 | + * Send ELS response using mainly infomation | |
2984 | + * in exchange and sequence in EM layer. | |
2985 | + */ | |
2986 | +void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, | |
2987 | + struct fc_seq_els_data *els_data); | |
2988 | + | |
2989 | +/* | |
2990 | + * This function is for seq_exch_abort function pointer in | |
2991 | + * struct libfc_function_template, see comment block on | |
2992 | + * seq_exch_abort for description of this function. | |
2993 | + */ | |
2994 | +int fc_seq_exch_abort(const struct fc_seq *req_sp, unsigned int timer_msec); | |
2995 | + | |
2996 | +/* | |
2997 | + * Indicate that an exchange/sequence tuple is complete and the memory | |
2998 | + * allocated for the related objects may be freed. | |
2999 | + */ | |
3000 | +void fc_exch_done(struct fc_seq *sp); | |
3001 | + | |
3002 | +/* | |
3003 | + * Assigns a EM and XID for a frame and then allocates | |
3004 | + * a new exchange and sequence pair. | |
3005 | + * The fp can be used to determine free XID. | |
3006 | + */ | |
3007 | +struct fc_exch *fc_exch_get(struct fc_lport *lp, struct fc_frame *fp); | |
3008 | + | |
3009 | +/* | |
3010 | + * Allocate a new exchange and sequence pair. | |
3011 | + * if ex_id is zero then next free exchange id | |
3012 | + * from specified exchange manger mp will be assigned. | |
3013 | + */ | |
3014 | +struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp, u16 ex_id); | |
3015 | + | |
3016 | +/* | |
3017 | + * Start a new sequence on the same exchange as the supplied sequence. | |
3018 | + */ | |
3019 | +struct fc_seq *fc_seq_start_next(struct fc_seq *sp); | |
3020 | + | |
3021 | +/* | |
3022 | + * Reset an exchange manager, completing all sequences and exchanges. | |
3023 | + * If s_id is non-zero, reset only exchanges originating from that FID. | |
3024 | + * If d_id is non-zero, reset only exchanges sending to that FID. | |
3025 | + */ | |
3026 | +void fc_exch_mgr_reset(struct fc_exch_mgr *, u32 s_id, u32 d_id); | |
3027 | + | |
3028 | +/* | |
3029 | + * Get exchange Ids of a sequence | |
3030 | + */ | |
3031 | +void fc_seq_get_xids(struct fc_seq *sp, u16 *oxid, u16 *rxid); | |
3032 | + | |
3033 | +/* | |
3034 | + * Set REC data to a sequence | |
3035 | + */ | |
3036 | +void fc_seq_set_rec_data(struct fc_seq *sp, u32 rec_data); | |
3037 | + | |
3038 | +/** | |
3039 | + * fc_functions_template | |
3040 | + *****************************/ | |
3041 | +void fc_attr_init(struct fc_lport *); | |
3042 | +void fc_get_host_port_id(struct Scsi_Host *shost); | |
3043 | +void fc_get_host_speed(struct Scsi_Host *shost); | |
3044 | +void fc_get_host_port_type(struct Scsi_Host *shost); | |
3045 | +void fc_get_host_port_state(struct Scsi_Host *shost); | |
3046 | +void fc_get_host_fabric_name(struct Scsi_Host *shost); | |
3047 | +void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout); | |
3048 | +struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); | |
3049 | + | |
3050 | +/* | |
3051 | + * module setup functions. | |
3052 | + */ | |
3053 | +int fc_setup_exch_mgr(void); | |
3054 | +void fc_destroy_exch_mgr(void); | |
3055 | + | |
3056 | + | |
3057 | +#endif /* _LIBFC_H_ */ | |
3058 | -- | |
3059 | 1.5.2.4 | |
3060 |