xref: /linux/include/uapi/scsi/fc/fc_els.h (revision 6fdcba32711044c35c0e1b094cbd8f3f0b4472c9)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Copyright(c) 2007 Intel Corporation. All rights reserved.
4  *
5  * Maintained at www.Open-FCoE.org
6  */
7 
8 #ifndef _FC_ELS_H_
9 #define	_FC_ELS_H_
10 
11 #include <linux/types.h>
12 
13 /*
14  * Fibre Channel Switch - Enhanced Link Services definitions.
15  * From T11 FC-LS Rev 1.2 June 7, 2005.
16  */
17 
18 /*
19  * ELS Command codes - byte 0 of the frame payload
20  */
21 enum fc_els_cmd {
22 	ELS_LS_RJT =	0x01,	/* ESL reject */
23 	ELS_LS_ACC =	0x02,	/* ESL Accept */
24 	ELS_PLOGI =	0x03,	/* N_Port login */
25 	ELS_FLOGI =	0x04,	/* F_Port login */
26 	ELS_LOGO =	0x05,	/* Logout */
27 	ELS_ABTX =	0x06,	/* Abort exchange - obsolete */
28 	ELS_RCS =	0x07,	/* read connection status */
29 	ELS_RES =	0x08,	/* read exchange status block */
30 	ELS_RSS =	0x09,	/* read sequence status block */
31 	ELS_RSI =	0x0a,	/* read sequence initiative */
32 	ELS_ESTS =	0x0b,	/* establish streaming */
33 	ELS_ESTC =	0x0c,	/* estimate credit */
34 	ELS_ADVC =	0x0d,	/* advise credit */
35 	ELS_RTV =	0x0e,	/* read timeout value */
36 	ELS_RLS =	0x0f,	/* read link error status block */
37 	ELS_ECHO =	0x10,	/* echo */
38 	ELS_TEST =	0x11,	/* test */
39 	ELS_RRQ =	0x12,	/* reinstate recovery qualifier */
40 	ELS_REC =	0x13,	/* read exchange concise */
41 	ELS_SRR =	0x14,	/* sequence retransmission request */
42 	ELS_FPIN =	0x16,	/* Fabric Performance Impact Notification */
43 	ELS_PRLI =	0x20,	/* process login */
44 	ELS_PRLO =	0x21,	/* process logout */
45 	ELS_SCN =	0x22,	/* state change notification */
46 	ELS_TPLS =	0x23,	/* test process login state */
47 	ELS_TPRLO =	0x24,	/* third party process logout */
48 	ELS_LCLM =	0x25,	/* login control list mgmt (obs) */
49 	ELS_GAID =	0x30,	/* get alias_ID */
50 	ELS_FACT =	0x31,	/* fabric activate alias_id */
51 	ELS_FDACDT =	0x32,	/* fabric deactivate alias_id */
52 	ELS_NACT =	0x33,	/* N-port activate alias_id */
53 	ELS_NDACT =	0x34,	/* N-port deactivate alias_id */
54 	ELS_QOSR =	0x40,	/* quality of service request */
55 	ELS_RVCS =	0x41,	/* read virtual circuit status */
56 	ELS_PDISC =	0x50,	/* discover N_port service params */
57 	ELS_FDISC =	0x51,	/* discover F_port service params */
58 	ELS_ADISC =	0x52,	/* discover address */
59 	ELS_RNC =	0x53,	/* report node cap (obs) */
60 	ELS_FARP_REQ =	0x54,	/* FC ARP request */
61 	ELS_FARP_REPL =	0x55,	/* FC ARP reply */
62 	ELS_RPS =	0x56,	/* read port status block */
63 	ELS_RPL =	0x57,	/* read port list */
64 	ELS_RPBC =	0x58,	/* read port buffer condition */
65 	ELS_FAN =	0x60,	/* fabric address notification */
66 	ELS_RSCN =	0x61,	/* registered state change notification */
67 	ELS_SCR =	0x62,	/* state change registration */
68 	ELS_RNFT =	0x63,	/* report node FC-4 types */
69 	ELS_CSR =	0x68,	/* clock synch. request */
70 	ELS_CSU =	0x69,	/* clock synch. update */
71 	ELS_LINIT =	0x70,	/* loop initialize */
72 	ELS_LSTS =	0x72,	/* loop status */
73 	ELS_RNID =	0x78,	/* request node ID data */
74 	ELS_RLIR =	0x79,	/* registered link incident report */
75 	ELS_LIRR =	0x7a,	/* link incident record registration */
76 	ELS_SRL =	0x7b,	/* scan remote loop */
77 	ELS_SBRP =	0x7c,	/* set bit-error reporting params */
78 	ELS_RPSC =	0x7d,	/* report speed capabilities */
79 	ELS_QSA =	0x7e,	/* query security attributes */
80 	ELS_EVFP =	0x7f,	/* exchange virt. fabrics params */
81 	ELS_LKA =	0x80,	/* link keep-alive */
82 	ELS_AUTH_ELS =	0x90,	/* authentication ELS */
83 };
84 
85 /*
86  * Initializer useful for decoding table.
87  * Please keep this in sync with the above definitions.
88  */
89 #define	FC_ELS_CMDS_INIT {			\
90 	[ELS_LS_RJT] =	"LS_RJT",		\
91 	[ELS_LS_ACC] =	"LS_ACC",		\
92 	[ELS_PLOGI] =	"PLOGI",		\
93 	[ELS_FLOGI] =	"FLOGI",		\
94 	[ELS_LOGO] =	"LOGO",			\
95 	[ELS_ABTX] =	"ABTX",			\
96 	[ELS_RCS] =	"RCS",			\
97 	[ELS_RES] =	"RES",			\
98 	[ELS_RSS] =	"RSS",			\
99 	[ELS_RSI] =	"RSI",			\
100 	[ELS_ESTS] =	"ESTS",			\
101 	[ELS_ESTC] =	"ESTC",			\
102 	[ELS_ADVC] =	"ADVC",			\
103 	[ELS_RTV] =	"RTV",			\
104 	[ELS_RLS] =	"RLS",			\
105 	[ELS_ECHO] =	"ECHO",			\
106 	[ELS_TEST] =	"TEST",			\
107 	[ELS_RRQ] =	"RRQ",			\
108 	[ELS_REC] =	"REC",			\
109 	[ELS_SRR] =	"SRR",			\
110 	[ELS_FPIN] =	"FPIN",			\
111 	[ELS_PRLI] =	"PRLI",			\
112 	[ELS_PRLO] =	"PRLO",			\
113 	[ELS_SCN] =	"SCN",			\
114 	[ELS_TPLS] =	"TPLS",			\
115 	[ELS_TPRLO] =	"TPRLO",		\
116 	[ELS_LCLM] =	"LCLM",			\
117 	[ELS_GAID] =	"GAID",			\
118 	[ELS_FACT] =	"FACT",			\
119 	[ELS_FDACDT] =	"FDACDT",		\
120 	[ELS_NACT] =	"NACT",			\
121 	[ELS_NDACT] =	"NDACT",		\
122 	[ELS_QOSR] =	"QOSR",			\
123 	[ELS_RVCS] =	"RVCS",			\
124 	[ELS_PDISC] =	"PDISC",		\
125 	[ELS_FDISC] =	"FDISC",		\
126 	[ELS_ADISC] =	"ADISC",		\
127 	[ELS_RNC] =	"RNC",			\
128 	[ELS_FARP_REQ] = "FARP_REQ",		\
129 	[ELS_FARP_REPL] =  "FARP_REPL",		\
130 	[ELS_RPS] =	"RPS",			\
131 	[ELS_RPL] =	"RPL",			\
132 	[ELS_RPBC] =	"RPBC",			\
133 	[ELS_FAN] =	"FAN",			\
134 	[ELS_RSCN] =	"RSCN",			\
135 	[ELS_SCR] =	"SCR",			\
136 	[ELS_RNFT] =	"RNFT",			\
137 	[ELS_CSR] =	"CSR",			\
138 	[ELS_CSU] =	"CSU",			\
139 	[ELS_LINIT] =	"LINIT",		\
140 	[ELS_LSTS] =	"LSTS",			\
141 	[ELS_RNID] =	"RNID",			\
142 	[ELS_RLIR] =	"RLIR",			\
143 	[ELS_LIRR] =	"LIRR",			\
144 	[ELS_SRL] =	"SRL",			\
145 	[ELS_SBRP] =	"SBRP",			\
146 	[ELS_RPSC] =	"RPSC",			\
147 	[ELS_QSA] =	"QSA",			\
148 	[ELS_EVFP] =	"EVFP",			\
149 	[ELS_LKA] =	"LKA",			\
150 	[ELS_AUTH_ELS] = "AUTH_ELS",		\
151 }
152 
153 /*
154  * LS_ACC payload.
155  */
156 struct fc_els_ls_acc {
157 	__u8          la_cmd;		/* command code ELS_LS_ACC */
158 	__u8          la_resv[3];	/* reserved */
159 };
160 
161 /*
162  * ELS reject payload.
163  */
164 struct fc_els_ls_rjt {
165 	__u8	er_cmd;		/* command code ELS_LS_RJT */
166 	__u8	er_resv[4];	/* reserved must be zero */
167 	__u8	er_reason;	/* reason (enum fc_els_rjt_reason below) */
168 	__u8	er_explan;	/* explanation (enum fc_els_rjt_explan below) */
169 	__u8	er_vendor;	/* vendor specific code */
170 };
171 
172 /*
173  * ELS reject reason codes (er_reason).
174  */
175 enum fc_els_rjt_reason {
176 	ELS_RJT_NONE =		0,	/* no reject - not to be sent */
177 	ELS_RJT_INVAL =		0x01,	/* invalid ELS command code */
178 	ELS_RJT_LOGIC =		0x03,	/* logical error */
179 	ELS_RJT_BUSY =		0x05,	/* logical busy */
180 	ELS_RJT_PROT =		0x07,	/* protocol error */
181 	ELS_RJT_UNAB =		0x09,	/* unable to perform command request */
182 	ELS_RJT_UNSUP =		0x0b,	/* command not supported */
183 	ELS_RJT_INPROG =	0x0e,	/* command already in progress */
184 	ELS_RJT_FIP =		0x20,	/* FIP error */
185 	ELS_RJT_VENDOR =	0xff,	/* vendor specific error */
186 };
187 
188 
189 /*
190  * reason code explanation (er_explan).
191  */
192 enum fc_els_rjt_explan {
193 	ELS_EXPL_NONE =		0x00,	/* No additional explanation */
194 	ELS_EXPL_SPP_OPT_ERR =	0x01,	/* service parameter error - options */
195 	ELS_EXPL_SPP_ICTL_ERR =	0x03,	/* service parm error - initiator ctl */
196 	ELS_EXPL_AH =		0x11,	/* invalid association header */
197 	ELS_EXPL_AH_REQ =	0x13,	/* association_header required */
198 	ELS_EXPL_SID =		0x15,	/* invalid originator S_ID */
199 	ELS_EXPL_OXID_RXID =	0x17,	/* invalid OX_ID-RX_ID combination */
200 	ELS_EXPL_INPROG =	0x19,	/* Request already in progress */
201 	ELS_EXPL_PLOGI_REQD =	0x1e,	/* N_Port login required */
202 	ELS_EXPL_INSUF_RES =	0x29,	/* insufficient resources */
203 	ELS_EXPL_UNAB_DATA =	0x2a,	/* unable to supply requested data */
204 	ELS_EXPL_UNSUPR =	0x2c,	/* Request not supported */
205 	ELS_EXPL_INV_LEN =	0x2d,	/* Invalid payload length */
206 	ELS_EXPL_NOT_NEIGHBOR = 0x62,	/* VN2VN_Port not in neighbor set */
207 	/* TBD - above definitions incomplete */
208 };
209 
210 /*
211  * Common service parameters (N ports).
212  */
213 struct fc_els_csp {
214 	__u8		sp_hi_ver;	/* highest version supported (obs.) */
215 	__u8		sp_lo_ver;	/* highest version supported (obs.) */
216 	__be16		sp_bb_cred;	/* buffer-to-buffer credits */
217 	__be16		sp_features;	/* common feature flags */
218 	__be16		sp_bb_data;	/* b-b state number and data field sz */
219 	union {
220 		struct {
221 			__be16	_sp_tot_seq; /* total concurrent sequences */
222 			__be16	_sp_rel_off; /* rel. offset by info cat */
223 		} sp_plogi;
224 		struct {
225 			__be32	_sp_r_a_tov; /* resource alloc. timeout msec */
226 		} sp_flogi_acc;
227 	} sp_u;
228 	__be32		sp_e_d_tov;	/* error detect timeout value */
229 };
230 #define	sp_tot_seq	sp_u.sp_plogi._sp_tot_seq
231 #define	sp_rel_off	sp_u.sp_plogi._sp_rel_off
232 #define	sp_r_a_tov	sp_u.sp_flogi_acc._sp_r_a_tov
233 
234 #define	FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */
235 
236 /*
237  * Minimum and maximum values for max data field size in service parameters.
238  */
239 #define	FC_SP_MIN_MAX_PAYLOAD	FC_MIN_MAX_PAYLOAD
240 #define	FC_SP_MAX_MAX_PAYLOAD	FC_MAX_PAYLOAD
241 
242 /*
243  * sp_features
244  */
245 #define	FC_SP_FT_NPIV	0x8000	/* multiple N_Port_ID support (FLOGI) */
246 #define	FC_SP_FT_CIRO	0x8000	/* continuously increasing rel off (PLOGI) */
247 #define	FC_SP_FT_CLAD	0x8000	/* clean address (in FLOGI LS_ACC) */
248 #define	FC_SP_FT_RAND	0x4000	/* random relative offset */
249 #define	FC_SP_FT_VAL	0x2000	/* valid vendor version level */
250 #define	FC_SP_FT_NPIV_ACC	0x2000	/* NPIV assignment (FLOGI LS_ACC) */
251 #define	FC_SP_FT_FPORT	0x1000	/* F port (1) vs. N port (0) */
252 #define	FC_SP_FT_ABB	0x0800	/* alternate BB_credit management */
253 #define	FC_SP_FT_EDTR	0x0400	/* E_D_TOV Resolution is nanoseconds */
254 #define	FC_SP_FT_MCAST	0x0200	/* multicast */
255 #define	FC_SP_FT_BCAST	0x0100	/* broadcast */
256 #define	FC_SP_FT_HUNT	0x0080	/* hunt group */
257 #define	FC_SP_FT_SIMP	0x0040	/* dedicated simplex */
258 #define	FC_SP_FT_SEC	0x0020	/* reserved for security */
259 #define	FC_SP_FT_CSYN	0x0010	/* clock synch. supported */
260 #define	FC_SP_FT_RTTOV	0x0008	/* R_T_TOV value 100 uS, else 100 mS */
261 #define	FC_SP_FT_HALF	0x0004	/* dynamic half duplex */
262 #define	FC_SP_FT_SEQC	0x0002	/* SEQ_CNT */
263 #define	FC_SP_FT_PAYL	0x0001	/* FLOGI payload length 256, else 116 */
264 
265 /*
266  * Class-specific service parameters.
267  */
268 struct fc_els_cssp {
269 	__be16		cp_class;	/* class flags */
270 	__be16		cp_init;	/* initiator flags */
271 	__be16		cp_recip;	/* recipient flags */
272 	__be16		cp_rdfs;	/* receive data field size */
273 	__be16		cp_con_seq;	/* concurrent sequences */
274 	__be16		cp_ee_cred;	/* N-port end-to-end credit */
275 	__u8		cp_resv1;	/* reserved */
276 	__u8		cp_open_seq;	/* open sequences per exchange */
277 	__u8		_cp_resv2[2];	/* reserved */
278 };
279 
280 /*
281  * cp_class flags.
282  */
283 #define	FC_CPC_VALID	0x8000		/* class valid */
284 #define	FC_CPC_IMIX	0x4000		/* intermix mode */
285 #define	FC_CPC_SEQ	0x0800		/* sequential delivery */
286 #define	FC_CPC_CAMP	0x0200		/* camp-on */
287 #define	FC_CPC_PRI	0x0080		/* priority */
288 
289 /*
290  * cp_init flags.
291  * (TBD: not all flags defined here).
292  */
293 #define	FC_CPI_CSYN	0x0010		/* clock synch. capable */
294 
295 /*
296  * cp_recip flags.
297  */
298 #define	FC_CPR_CSYN	0x0008		/* clock synch. capable */
299 
300 /*
301  * NFC_ELS_FLOGI: Fabric login request.
302  * NFC_ELS_PLOGI: Port login request (same format).
303  */
304 struct fc_els_flogi {
305 	__u8		fl_cmd;		/* command */
306 	__u8		_fl_resvd[3];	/* must be zero */
307 	struct fc_els_csp fl_csp;	/* common service parameters */
308 	__be64		fl_wwpn;	/* port name */
309 	__be64		fl_wwnn;	/* node name */
310 	struct fc_els_cssp fl_cssp[4];	/* class 1-4 service parameters */
311 	__u8		fl_vend[16];	/* vendor version level */
312 } __attribute__((__packed__));
313 
314 /*
315  * Process login service parameter page.
316  */
317 struct fc_els_spp {
318 	__u8		spp_type;	/* type code or common service params */
319 	__u8		spp_type_ext;	/* type code extension */
320 	__u8		spp_flags;
321 	__u8		_spp_resvd;
322 	__be32		spp_orig_pa;	/* originator process associator */
323 	__be32		spp_resp_pa;	/* responder process associator */
324 	__be32		spp_params;	/* service parameters */
325 };
326 
327 /*
328  * spp_flags.
329  */
330 #define	FC_SPP_OPA_VAL	    0x80	/* originator proc. assoc. valid */
331 #define	FC_SPP_RPA_VAL	    0x40	/* responder proc. assoc. valid */
332 #define	FC_SPP_EST_IMG_PAIR 0x20	/* establish image pair */
333 #define	FC_SPP_RESP_MASK    0x0f	/* mask for response code (below) */
334 
335 /*
336  * SPP response code in spp_flags - lower 4 bits.
337  */
338 enum fc_els_spp_resp {
339 	FC_SPP_RESP_ACK	=	1,	/* request executed */
340 	FC_SPP_RESP_RES =	2,	/* unable due to lack of resources */
341 	FC_SPP_RESP_INIT =	3,	/* initialization not complete */
342 	FC_SPP_RESP_NO_PA = 	4,	/* unknown process associator */
343 	FC_SPP_RESP_CONF = 	5,	/* configuration precludes image pair */
344 	FC_SPP_RESP_COND = 	6,	/* request completed conditionally */
345 	FC_SPP_RESP_MULT = 	7,	/* unable to handle multiple SPPs */
346 	FC_SPP_RESP_INVL = 	8,	/* SPP is invalid */
347 };
348 
349 /*
350  * ELS_RRQ - Reinstate Recovery Qualifier
351  */
352 struct fc_els_rrq {
353 	__u8		rrq_cmd;	/* command (0x12) */
354 	__u8		rrq_zero[3];	/* specified as zero - part of cmd */
355 	__u8		rrq_resvd;	/* reserved */
356 	__u8		rrq_s_id[3];	/* originator FID */
357 	__be16		rrq_ox_id;	/* originator exchange ID */
358 	__be16		rrq_rx_id;	/* responders exchange ID */
359 };
360 
361 /*
362  * ELS_REC - Read exchange concise.
363  */
364 struct fc_els_rec {
365 	__u8		rec_cmd;	/* command (0x13) */
366 	__u8		rec_zero[3];	/* specified as zero - part of cmd */
367 	__u8		rec_resvd;	/* reserved */
368 	__u8		rec_s_id[3];	/* originator FID */
369 	__be16		rec_ox_id;	/* originator exchange ID */
370 	__be16		rec_rx_id;	/* responders exchange ID */
371 };
372 
373 /*
374  * ELS_REC LS_ACC payload.
375  */
376 struct fc_els_rec_acc {
377 	__u8		reca_cmd;	/* accept (0x02) */
378 	__u8		reca_zero[3];	/* specified as zero - part of cmd */
379 	__be16		reca_ox_id;	/* originator exchange ID */
380 	__be16		reca_rx_id;	/* responders exchange ID */
381 	__u8		reca_resvd1;	/* reserved */
382 	__u8		reca_ofid[3];	/* originator FID */
383 	__u8		reca_resvd2;	/* reserved */
384 	__u8		reca_rfid[3];	/* responder FID */
385 	__be32		reca_fc4value;	/* FC4 value */
386 	__be32		reca_e_stat;	/* ESB (exchange status block) status */
387 };
388 
389 /*
390  * ELS_PRLI - Process login request and response.
391  */
392 struct fc_els_prli {
393 	__u8		prli_cmd;	/* command */
394 	__u8		prli_spp_len;	/* length of each serv. parm. page */
395 	__be16		prli_len;	/* length of entire payload */
396 	/* service parameter pages follow */
397 };
398 
399 /*
400  * ELS_PRLO - Process logout request and response.
401  */
402 struct fc_els_prlo {
403 	__u8            prlo_cmd;       /* command */
404 	__u8            prlo_obs;       /* obsolete, but shall be set to 10h */
405 	__be16          prlo_len;       /* payload length */
406 };
407 
408 /*
409  * ELS_ADISC payload
410  */
411 struct fc_els_adisc {
412 	__u8		adisc_cmd;
413 	__u8		adisc_resv[3];
414 	__u8            adisc_resv1;
415 	__u8            adisc_hard_addr[3];
416 	__be64          adisc_wwpn;
417 	__be64          adisc_wwnn;
418 	__u8            adisc_resv2;
419 	__u8            adisc_port_id[3];
420 } __attribute__((__packed__));
421 
422 /*
423  * ELS_LOGO - process or fabric logout.
424  */
425 struct fc_els_logo {
426 	__u8		fl_cmd;		/* command code */
427 	__u8		fl_zero[3];	/* specified as zero - part of cmd */
428 	__u8		fl_resvd;	/* reserved */
429 	__u8		fl_n_port_id[3];/* N port ID */
430 	__be64		fl_n_port_wwn;	/* port name */
431 };
432 
433 /*
434  * ELS_RTV - read timeout value.
435  */
436 struct fc_els_rtv {
437 	__u8		rtv_cmd;	/* command code 0x0e */
438 	__u8		rtv_zero[3];	/* specified as zero - part of cmd */
439 };
440 
441 /*
442  * LS_ACC for ELS_RTV - read timeout value.
443  */
444 struct fc_els_rtv_acc {
445 	__u8		rtv_cmd;	/* command code 0x02 */
446 	__u8		rtv_zero[3];	/* specified as zero - part of cmd */
447 	__be32		rtv_r_a_tov;	/* resource allocation timeout value */
448 	__be32		rtv_e_d_tov;	/* error detection timeout value */
449 	__be32		rtv_toq;	/* timeout qualifier (see below) */
450 };
451 
452 /*
453  * rtv_toq bits.
454  */
455 #define	FC_ELS_RTV_EDRES (1 << 26)	/* E_D_TOV resolution is nS else mS */
456 #define	FC_ELS_RTV_RTTOV (1 << 19)	/* R_T_TOV is 100 uS else 100 mS */
457 
458 /*
459  * ELS_SCR - state change registration payload.
460  */
461 struct fc_els_scr {
462 	__u8		scr_cmd;	/* command code */
463 	__u8		scr_resv[6];	/* reserved */
464 	__u8		scr_reg_func;	/* registration function (see below) */
465 };
466 
467 enum fc_els_scr_func {
468 	ELS_SCRF_FAB =	1,	/* fabric-detected registration */
469 	ELS_SCRF_NPORT = 2,	/* Nx_Port-detected registration */
470 	ELS_SCRF_FULL =	3,	/* full registration */
471 	ELS_SCRF_CLEAR = 255,	/* remove any current registrations */
472 };
473 
474 /*
475  * ELS_RSCN - registered state change notification payload.
476  */
477 struct fc_els_rscn {
478 	__u8		rscn_cmd;	/* RSCN opcode (0x61) */
479 	__u8		rscn_page_len;	/* page length (4) */
480 	__be16		rscn_plen;	/* payload length including this word */
481 
482 	/* followed by 4-byte generic affected Port_ID pages */
483 };
484 
485 struct fc_els_rscn_page {
486 	__u8		rscn_page_flags; /* event and address format */
487 	__u8		rscn_fid[3];	/* fabric ID */
488 };
489 
490 #define	ELS_RSCN_EV_QUAL_BIT	2	/* shift count for event qualifier */
491 #define	ELS_RSCN_EV_QUAL_MASK	0xf	/* mask for event qualifier */
492 #define	ELS_RSCN_ADDR_FMT_BIT	0	/* shift count for address format */
493 #define	ELS_RSCN_ADDR_FMT_MASK	0x3	/* mask for address format */
494 
495 enum fc_els_rscn_ev_qual {
496 	ELS_EV_QUAL_NONE = 0,		/* unspecified */
497 	ELS_EV_QUAL_NS_OBJ = 1,		/* changed name server object */
498 	ELS_EV_QUAL_PORT_ATTR = 2,	/* changed port attribute */
499 	ELS_EV_QUAL_SERV_OBJ = 3,	/* changed service object */
500 	ELS_EV_QUAL_SW_CONFIG = 4,	/* changed switch configuration */
501 	ELS_EV_QUAL_REM_OBJ = 5,	/* removed object */
502 };
503 
504 enum fc_els_rscn_addr_fmt {
505 	ELS_ADDR_FMT_PORT = 0,	/* rscn_fid is a port address */
506 	ELS_ADDR_FMT_AREA = 1,	/* rscn_fid is a area address */
507 	ELS_ADDR_FMT_DOM = 2,	/* rscn_fid is a domain address */
508 	ELS_ADDR_FMT_FAB = 3,	/* anything on fabric may have changed */
509 };
510 
511 /*
512  * ELS_RNID - request Node ID.
513  */
514 struct fc_els_rnid {
515 	__u8		rnid_cmd;	/* RNID opcode (0x78) */
516 	__u8		rnid_resv[3];	/* reserved */
517 	__u8		rnid_fmt;	/* data format */
518 	__u8		rnid_resv2[3];	/* reserved */
519 };
520 
521 /*
522  * Node Identification Data formats (rnid_fmt)
523  */
524 enum fc_els_rnid_fmt {
525 	ELS_RNIDF_NONE = 0,		/* no specific identification data */
526 	ELS_RNIDF_GEN = 0xdf,		/* general topology discovery format */
527 };
528 
529 /*
530  * ELS_RNID response.
531  */
532 struct fc_els_rnid_resp {
533 	__u8		rnid_cmd;	/* response code (LS_ACC) */
534 	__u8		rnid_resv[3];	/* reserved */
535 	__u8		rnid_fmt;	/* data format */
536 	__u8		rnid_cid_len;	/* common ID data length */
537 	__u8		rnid_resv2;	/* reserved */
538 	__u8		rnid_sid_len;	/* specific ID data length */
539 };
540 
541 struct fc_els_rnid_cid {
542 	__be64		rnid_wwpn;	/* N port name */
543 	__be64		rnid_wwnn;	/* node name */
544 };
545 
546 struct fc_els_rnid_gen {
547 	__u8		rnid_vend_id[16]; /* vendor-unique ID */
548 	__be32		rnid_atype;	/* associated type (see below) */
549 	__be32		rnid_phys_port;	/* physical port number */
550 	__be32		rnid_att_nodes;	/* number of attached nodes */
551 	__u8		rnid_node_mgmt;	/* node management (see below) */
552 	__u8		rnid_ip_ver;	/* IP version (see below) */
553 	__be16		rnid_prot_port;	/* UDP / TCP port number */
554 	__be32		rnid_ip_addr[4]; /* IP address */
555 	__u8		rnid_resvd[2];	/* reserved */
556 	__be16		rnid_vend_spec;	/* vendor-specific field */
557 };
558 
559 enum fc_els_rnid_atype {
560 	ELS_RNIDA_UNK =		0x01,	/* unknown */
561 	ELS_RNIDA_OTHER =	0x02,	/* none of the following */
562 	ELS_RNIDA_HUB =		0x03,
563 	ELS_RNIDA_SWITCH =	0x04,
564 	ELS_RNIDA_GATEWAY =	0x05,
565 	ELS_RNIDA_CONV =	0x06,   /* Obsolete, do not use this value */
566 	ELS_RNIDA_HBA =	        0x07,   /* Obsolete, do not use this value */
567 	ELS_RNIDA_PROXY =       0x08,   /* Obsolete, do not use this value */
568 	ELS_RNIDA_STORAGE =	0x09,
569 	ELS_RNIDA_HOST =	0x0a,
570 	ELS_RNIDA_SUBSYS =	0x0b,	/* storage subsystem (e.g., RAID) */
571 	ELS_RNIDA_ACCESS =	0x0e,	/* access device (e.g. media changer) */
572 	ELS_RNIDA_NAS =		0x11,	/* NAS server */
573 	ELS_RNIDA_BRIDGE =	0x12,	/* bridge */
574 	ELS_RNIDA_VIRT =	0x13,	/* virtualization device */
575 	ELS_RNIDA_MF =		0xff,	/* multifunction device (bits below) */
576 	ELS_RNIDA_MF_HUB =	1UL << 31, 	/* hub */
577 	ELS_RNIDA_MF_SW =	1UL << 30, 	/* switch */
578 	ELS_RNIDA_MF_GW =	1UL << 29,	/* gateway */
579 	ELS_RNIDA_MF_ST =	1UL << 28,	/* storage */
580 	ELS_RNIDA_MF_HOST =	1UL << 27,	/* host */
581 	ELS_RNIDA_MF_SUB =	1UL << 26,	/* storage subsystem */
582 	ELS_RNIDA_MF_ACC =	1UL << 25,	/* storage access dev */
583 	ELS_RNIDA_MF_WDM =	1UL << 24,	/* wavelength division mux */
584 	ELS_RNIDA_MF_NAS =	1UL << 23,	/* NAS server */
585 	ELS_RNIDA_MF_BR =	1UL << 22,	/* bridge */
586 	ELS_RNIDA_MF_VIRT =	1UL << 21,	/* virtualization device */
587 };
588 
589 enum fc_els_rnid_mgmt {
590 	ELS_RNIDM_SNMP =	0,
591 	ELS_RNIDM_TELNET =	1,
592 	ELS_RNIDM_HTTP =	2,
593 	ELS_RNIDM_HTTPS =	3,
594 	ELS_RNIDM_XML =		4,	/* HTTP + XML */
595 };
596 
597 enum fc_els_rnid_ipver {
598 	ELS_RNIDIP_NONE =	0,	/* no IP support or node mgmt. */
599 	ELS_RNIDIP_V4 =		1,	/* IPv4 */
600 	ELS_RNIDIP_V6 =		2,	/* IPv6 */
601 };
602 
603 /*
604  * ELS RPL - Read Port List.
605  */
606 struct fc_els_rpl {
607 	__u8		rpl_cmd;	/* command */
608 	__u8		rpl_resv[5];	/* reserved - must be zero */
609 	__be16		rpl_max_size;	/* maximum response size or zero */
610 	__u8		rpl_resv1;	/* reserved - must be zero */
611 	__u8		rpl_index[3];	/* starting index */
612 };
613 
614 /*
615  * Port number block in RPL response.
616  */
617 struct fc_els_pnb {
618 	__be32		pnb_phys_pn;	/* physical port number */
619 	__u8		pnb_resv;	/* reserved */
620 	__u8		pnb_port_id[3];	/* port ID */
621 	__be64		pnb_wwpn;	/* port name */
622 };
623 
624 /*
625  * RPL LS_ACC response.
626  */
627 struct fc_els_rpl_resp {
628 	__u8		rpl_cmd;	/* ELS_LS_ACC */
629 	__u8		rpl_resv1;	/* reserved - must be zero */
630 	__be16		rpl_plen;	/* payload length */
631 	__u8		rpl_resv2;	/* reserved - must be zero */
632 	__u8		rpl_llen[3];	/* list length */
633 	__u8		rpl_resv3;	/* reserved - must be zero */
634 	__u8		rpl_index[3];	/* starting index */
635 	struct fc_els_pnb rpl_pnb[1];	/* variable number of PNBs */
636 };
637 
638 /*
639  * Link Error Status Block.
640  */
641 struct fc_els_lesb {
642 	__be32		lesb_link_fail;	/* link failure count */
643 	__be32		lesb_sync_loss;	/* loss of synchronization count */
644 	__be32		lesb_sig_loss;	/* loss of signal count */
645 	__be32		lesb_prim_err;	/* primitive sequence error count */
646 	__be32		lesb_inv_word;	/* invalid transmission word count */
647 	__be32		lesb_inv_crc;	/* invalid CRC count */
648 };
649 
650 /*
651  * ELS RPS - Read Port Status Block request.
652  */
653 struct fc_els_rps {
654 	__u8		rps_cmd;	/* command */
655 	__u8		rps_resv[2];	/* reserved - must be zero */
656 	__u8		rps_flag;	/* flag - see below */
657 	__be64		rps_port_spec;	/* port selection */
658 };
659 
660 enum fc_els_rps_flag {
661 	FC_ELS_RPS_DID =	0x00,	/* port identified by D_ID of req. */
662 	FC_ELS_RPS_PPN =	0x01,	/* port_spec is physical port number */
663 	FC_ELS_RPS_WWPN =	0x02,	/* port_spec is port WWN */
664 };
665 
666 /*
667  * ELS RPS LS_ACC response.
668  */
669 struct fc_els_rps_resp {
670 	__u8		rps_cmd;	/* command - LS_ACC */
671 	__u8		rps_resv[2];	/* reserved - must be zero */
672 	__u8		rps_flag;	/* flag - see below */
673 	__u8		rps_resv2[2];	/* reserved */
674 	__be16		rps_status;	/* port status - see below */
675 	struct fc_els_lesb rps_lesb;	/* link error status block */
676 };
677 
678 enum fc_els_rps_resp_flag {
679 	FC_ELS_RPS_LPEV =	0x01,	/* L_port extension valid */
680 };
681 
682 enum fc_els_rps_resp_status {
683 	FC_ELS_RPS_PTP =	1 << 5,	/* point-to-point connection */
684 	FC_ELS_RPS_LOOP =	1 << 4,	/* loop mode */
685 	FC_ELS_RPS_FAB =	1 << 3,	/* fabric present */
686 	FC_ELS_RPS_NO_SIG =	1 << 2,	/* loss of signal */
687 	FC_ELS_RPS_NO_SYNC =	1 << 1,	/* loss of synchronization */
688 	FC_ELS_RPS_RESET =	1 << 0,	/* in link reset protocol */
689 };
690 
691 /*
692  * ELS LIRR - Link Incident Record Registration request.
693  */
694 struct fc_els_lirr {
695 	__u8		lirr_cmd;	/* command */
696 	__u8		lirr_resv[3];	/* reserved - must be zero */
697 	__u8		lirr_func;	/* registration function */
698 	__u8		lirr_fmt;	/* FC-4 type of RLIR requested */
699 	__u8		lirr_resv2[2];	/* reserved - must be zero */
700 };
701 
702 enum fc_els_lirr_func {
703 	ELS_LIRR_SET_COND = 	0x01,	/* set - conditionally receive */
704 	ELS_LIRR_SET_UNCOND = 	0x02,	/* set - unconditionally receive */
705 	ELS_LIRR_CLEAR = 	0xff	/* clear registration */
706 };
707 
708 /*
709  * ELS SRL - Scan Remote Loop request.
710  */
711 struct fc_els_srl {
712 	__u8		srl_cmd;	/* command */
713 	__u8		srl_resv[3];	/* reserved - must be zero */
714 	__u8		srl_flag;	/* flag - see below */
715 	__u8		srl_flag_param[3];	/* flag parameter */
716 };
717 
718 enum fc_els_srl_flag {
719 	FC_ELS_SRL_ALL =	0x00,	/* scan all FL ports */
720 	FC_ELS_SRL_ONE =	0x01,	/* scan specified loop */
721 	FC_ELS_SRL_EN_PER =	0x02,	/* enable periodic scanning (param) */
722 	FC_ELS_SRL_DIS_PER =	0x03,	/* disable periodic scanning */
723 };
724 
725 /*
726  * ELS RLS - Read Link Error Status Block request.
727  */
728 struct fc_els_rls {
729 	__u8		rls_cmd;	/* command */
730 	__u8		rls_resv[4];	/* reserved - must be zero */
731 	__u8		rls_port_id[3];	/* port ID */
732 };
733 
734 /*
735  * ELS RLS LS_ACC Response.
736  */
737 struct fc_els_rls_resp {
738 	__u8		rls_cmd;	/* ELS_LS_ACC */
739 	__u8		rls_resv[3];	/* reserved - must be zero */
740 	struct fc_els_lesb rls_lesb;	/* link error status block */
741 };
742 
743 /*
744  * ELS RLIR - Registered Link Incident Report.
745  * This is followed by the CLIR and the CLID, described below.
746  */
747 struct fc_els_rlir {
748 	__u8		rlir_cmd;	/* command */
749 	__u8		rlir_resv[3];	/* reserved - must be zero */
750 	__u8		rlir_fmt;	/* format (FC4-type if type specific) */
751 	__u8		rlir_clr_len;	/* common link incident record length */
752 	__u8		rlir_cld_len;	/* common link incident desc. length */
753 	__u8		rlir_slr_len;	/* spec. link incident record length */
754 };
755 
756 /*
757  * CLIR - Common Link Incident Record Data. - Sent via RLIR.
758  */
759 struct fc_els_clir {
760 	__be64		clir_wwpn;	/* incident port name */
761 	__be64		clir_wwnn;	/* incident port node name */
762 	__u8		clir_port_type;	/* incident port type */
763 	__u8		clir_port_id[3];	/* incident port ID */
764 
765 	__be64		clir_conn_wwpn;	/* connected port name */
766 	__be64		clir_conn_wwnn;	/* connected node name */
767 	__be64		clir_fab_name;	/* fabric name */
768 	__be32		clir_phys_port;	/* physical port number */
769 	__be32		clir_trans_id;	/* transaction ID */
770 	__u8		clir_resv[3];	/* reserved */
771 	__u8		clir_ts_fmt;	/* time stamp format */
772 	__be64		clir_timestamp;	/* time stamp */
773 };
774 
775 /*
776  * CLIR clir_ts_fmt - time stamp format values.
777  */
778 enum fc_els_clir_ts_fmt {
779 	ELS_CLIR_TS_UNKNOWN = 	0,	/* time stamp field unknown */
780 	ELS_CLIR_TS_SEC_FRAC = 	1,	/* time in seconds and fractions */
781 	ELS_CLIR_TS_CSU =	2,	/* time in clock synch update format */
782 };
783 
784 /*
785  * Common Link Incident Descriptor - sent via RLIR.
786  */
787 struct fc_els_clid {
788 	__u8		clid_iq;	/* incident qualifier flags */
789 	__u8		clid_ic;	/* incident code */
790 	__be16		clid_epai;	/* domain/area of ISL */
791 };
792 
793 /*
794  * CLID incident qualifier flags.
795  */
796 enum fc_els_clid_iq {
797 	ELS_CLID_SWITCH =	0x20,	/* incident port is a switch node */
798 	ELS_CLID_E_PORT =	0x10,	/* incident is an ISL (E) port */
799 	ELS_CLID_SEV_MASK =	0x0c,	/* severity 2-bit field mask */
800 	ELS_CLID_SEV_INFO =	0x00,	/* report is informational */
801 	ELS_CLID_SEV_INOP =	0x08,	/* link not operational */
802 	ELS_CLID_SEV_DEG =	0x04,	/* link degraded but operational */
803 	ELS_CLID_LASER =	0x02,	/* subassembly is a laser */
804 	ELS_CLID_FRU =		0x01,	/* format can identify a FRU */
805 };
806 
807 /*
808  * CLID incident code.
809  */
810 enum fc_els_clid_ic {
811 	ELS_CLID_IC_IMPL =	1,	/* implicit incident */
812 	ELS_CLID_IC_BER =	2,	/* bit-error-rate threshold exceeded */
813 	ELS_CLID_IC_LOS =	3,	/* loss of synch or signal */
814 	ELS_CLID_IC_NOS =	4,	/* non-operational primitive sequence */
815 	ELS_CLID_IC_PST =	5,	/* primitive sequence timeout */
816 	ELS_CLID_IC_INVAL =	6,	/* invalid primitive sequence */
817 	ELS_CLID_IC_LOOP_TO =	7,	/* loop initialization time out */
818 	ELS_CLID_IC_LIP =	8,	/* receiving LIP */
819 };
820 
821 
822 /*
823  * Fabric Notification Descriptor Tag values
824  */
825 enum fc_fn_dtag {
826 	ELS_FN_DTAG_LNK_INTEGRITY =	0x00020001,	/* Link Integrity */
827 	ELS_FN_DTAG_PEER_CONGEST =	0x00020003,	/* Peer Congestion */
828 	ELS_FN_DTAG_CONGESTION =	0x00020004,	/* Congestion */
829 };
830 
831 /*
832  * Fabric Notification Descriptor
833  */
834 struct fc_fn_desc {
835 	__be32		fn_desc_tag;	/* Notification Descriptor Tag */
836 	__be32		fn_desc_value_len; /* Length of Descriptor Value field
837 					    * (in bytes)
838 					    */
839 	__u8		fn_desc_value[0];  /* Descriptor Value */
840 };
841 
842 /*
843  * ELS_FPIN - Fabric Performance Impact Notification
844  */
845 struct fc_els_fpin {
846 	__u8		fpin_cmd;	/* command (0x16) */
847 	__u8		fpin_zero[3];	/* specified as zero - part of cmd */
848 	__be32		fpin_desc_cnt;	/* count of descriptors */
849 	struct fc_fn_desc	fpin_desc[0];	/* Descriptor list */
850 };
851 
852 #endif /* _FC_ELS_H_ */
853