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