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