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