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