1 /*- 2 * Copyright (c) 2017 Broadcom. All rights reserved. 3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /** 33 * @file 34 * Define Fibre Channel types and structures. 35 */ 36 37 #ifndef _OCS_FCP_H 38 #define _OCS_FCP_H 39 40 #define FC_ELS_CMD_RJT 0x01 41 #define FC_ELS_CMD_ACC 0x02 42 #define FC_ELS_CMD_PLOGI 0x03 43 #define FC_ELS_CMD_FLOGI 0x04 44 #define FC_ELS_CMD_LOGO 0x05 45 #define FC_ELS_CMD_RRQ 0x12 46 #define FC_ELS_CMD_PRLI 0x20 47 #define FC_ELS_CMD_PRLO 0x21 48 #define FC_ELS_CMD_PDISC 0x50 49 #define FC_ELS_CMD_FDISC 0x51 50 #define FC_ELS_CMD_ADISC 0x52 51 #define FC_ELS_CMD_RSCN 0x61 52 #define FC_ELS_CMD_SCR 0x62 53 54 #define FC_TYPE_BASIC_LINK 0 55 #define FC_TYPE_FCP 0x08 56 #define FC_TYPE_GS 0x20 57 #define FC_TYPE_SW 0x22 58 59 #define FC_ADDR_FABRIC 0xfffffe /** well known fabric address */ 60 #define FC_ADDR_CONTROLLER 0xfffffd /** well known fabric controller address */ 61 #define FC_ADDR_IS_DOMAIN_CTRL(x) (((x) & 0xffff00) == 0xfffc00) /** is well known domain controller */ 62 #define FC_ADDR_GET_DOMAIN_CTRL(x) ((x) & 0x0000ff) /** get domain controller number */ 63 #define FC_ADDR_NAMESERVER 0xfffffc /** well known directory server address */ 64 65 #define FC_GS_TYPE_ALIAS_SERVICE 0xf8 66 #define FC_GS_TYPE_MANAGEMENT_SERVICE 0xfa 67 #define FC_GS_TYPE_DIRECTORY_SERVICE 0xfc 68 69 #define FC_GS_SUBTYPE_NAME_SERVER 0x02 70 71 /** 72 * Generic Services FC Type Bit mask macros: 73 */ 74 #define FC_GS_TYPE_WORD(type) ((type) >> 5) 75 #define FC_GS_TYPE_BIT(type) ((type) & 0x1f) 76 77 /** 78 * Generic Services Name Server Request Command codes: 79 */ 80 #define FC_GS_NAMESERVER_GPN_ID 0x0112 81 #define FC_GS_NAMESERVER_GNN_ID 0x0113 82 #define FC_GS_NAMESERVER_GFPN_ID 0x011c 83 #define FC_GS_NAMESERVER_GFF_ID 0x011f 84 #define FC_GS_NAMESERVER_GID_FT 0x0171 85 #define FC_GS_NAMESERVER_GID_PT 0x01a1 86 #define FC_GS_NAMESERVER_RHBA 0x0200 87 #define FC_GS_NAMESERVER_RPA 0x0211 88 #define FC_GS_NAMESERVER_RPN_ID 0x0212 89 #define FC_GS_NAMESERVER_RNN_ID 0x0213 90 #define FC_GS_NAMESERVER_RCS_ID 0x0214 91 #define FC_GS_NAMESERVER_RFT_ID 0x0217 92 #define FC_GS_NAMESERVER_RFF_ID 0x021f 93 #define FC_GS_NAMESERVER_RSNN_NN 0x0239 94 #define FC_GS_NAMESERVER_RSPN_ID 0x0218 95 96 #define FC_GS_REVISION 0x03 97 98 #define FC_GS_IO_PARAMS { .fc_ct.r_ctl = 0x02, \ 99 .fc_ct.type = FC_TYPE_GS, \ 100 .fc_ct.df_ctl = 0x00 } 101 102 typedef struct fc_vft_header_s { 103 uint32_t :1, 104 vf_id:12, 105 priority:3, 106 e:1, 107 :1, 108 type:4, 109 ver:2, 110 r_ctl:8; 111 uint32_t :24, 112 hopct:8; 113 } fc_vft_header_t; 114 115 #if BYTE_ORDER == LITTLE_ENDIAN 116 static inline uint32_t fc_be24toh(uint32_t x) { return (ocs_be32toh(x) >> 8); } 117 #else 118 static inline uint32_t fc_be24toh(uint32_t x) { } 119 #endif 120 static inline uint32_t fc_htobe24(uint32_t x) { return fc_be24toh(x); } 121 122 #define FC_SOFI3 0x2e 123 #define FC_SOFn3 0x36 124 #define FC_EOFN 0x41 125 #define FC_EOFT 0x42 126 127 /** 128 * @brief FC header in big-endian order 129 */ 130 typedef struct fc_header_s { 131 uint32_t info:4, 132 r_ctl:4, 133 d_id:24; 134 uint32_t cs_ctl:8, 135 s_id:24; 136 uint32_t type:8, 137 f_ctl:24; 138 uint32_t seq_id:8, 139 df_ctl:8, 140 seq_cnt:16; 141 uint32_t ox_id:16, 142 rx_id:16; 143 uint32_t parameter; 144 } fc_header_t; 145 146 /** 147 * @brief FC header in little-endian order 148 */ 149 typedef struct fc_header_le_s { 150 #if BYTE_ORDER == LITTLE_ENDIAN 151 uint32_t d_id:24, 152 info:4, 153 r_ctl:4; 154 uint32_t s_id:24, 155 cs_ctl:8; 156 uint32_t f_ctl:24, 157 type:8; 158 uint32_t seq_cnt:16, 159 df_ctl:8, 160 seq_id:8; 161 uint32_t rx_id:16, 162 ox_id:16; 163 uint32_t parameter; 164 #else 165 #error big endian version not defined 166 #endif 167 } fc_header_le_t; 168 169 /** 170 * @brief FC VM header in big-endian order 171 */ 172 typedef struct fc_vm_header_s { 173 uint32_t dst_vmid; 174 uint32_t src_vmid; 175 uint32_t rsvd0; 176 uint32_t rsvd1; 177 } fc_vm_header_t; 178 179 #define FC_DFCTL_DEVICE_HDR_16_MASK 0x1 180 #define FC_DFCTL_NETWORK_HDR_MASK 0x20 181 #define FC_DFCTL_ESP_HDR_MASK 0x40 182 #define FC_DFCTL_NETWORK_HDR_SIZE 16 183 #define FC_DFCTL_ESP_HDR_SIZE 0 //FIXME 184 185 #define FC_RCTL_FC4_DATA 0 186 #define FC_RCTL_ELS 2 187 #define FC_RCTL_BLS 8 188 189 #define FC_RCTL_INFO_UNCAT 0 190 #define FC_RCTL_INFO_SOL_DATA 1 191 #define FC_RCTL_INFO_UNSOL_CTRL 2 192 #define FC_RCTL_INFO_SOL_CTRL 3 193 #define FC_RCTL_INFO_UNSOL_DATA 4 194 #define FC_RCTL_INFO_DATA_DESC 5 195 #define FC_RCTL_INFO_UNSOL_CMD 6 196 #define FC_RCTL_INFO_CMD_STATUS 7 197 198 #define FC_FCTL_EXCHANGE_RESPONDER 0x800000 199 #define FC_FCTL_SEQUENCE_CONTEXT 0x400000 200 #define FC_FCTL_FIRST_SEQUENCE 0x200000 201 #define FC_FCTL_LAST_SEQUENCE 0x100000 202 #define FC_FCTL_END_SEQUENCE 0x080000 203 #define FC_FCTL_END_CONNECTION 0x040000 204 #define FC_FCTL_PRIORITY_ENABLE 0x020000 205 #define FC_FCTL_SEQUENCE_INITIATIVE 0x010000 206 #define FC_FCTL_FILL_DATA_BYTES_MASK 0x000003 207 208 /** 209 * Common BLS definitions: 210 */ 211 #define FC_INFO_NOP 0x0 212 #define FC_INFO_ABTS 0x1 213 #define FC_INFO_RMC 0x2 214 /* reserved 0x3 */ 215 #define FC_INFO_BA_ACC 0x4 216 #define FC_INFO_BA_RJT 0x5 217 #define FC_INFO_PRMT 0x6 218 219 /* (FC-LS) LS_RJT Reason Codes */ 220 #define FC_REASON_INVALID_COMMAND_CODE 0x01 221 #define FC_REASON_LOGICAL_ERROR 0x03 222 #define FC_REASON_LOGICAL_BUSY 0x05 223 #define FC_REASON_PROTOCOL_ERROR 0x07 224 #define FC_REASON_UNABLE_TO_PERFORM 0x09 225 #define FC_REASON_COMMAND_NOT_SUPPORTED 0x0b 226 #define FC_REASON_COMMAND_IN_PROGRESS 0x0e 227 #define FC_REASON_VENDOR_SPECIFIC 0xff 228 229 /* (FC-LS) LS_RJT Reason Codes Explanations */ 230 #define FC_EXPL_NO_ADDITIONAL 0x00 231 #define FC_EXPL_SPARAM_OPTIONS 0x01 232 #define FC_EXPL_SPARAM_INITIATOR 0x03 233 #define FC_EXPL_SPARAM_RECPIENT 0x05 234 #define FC_EXPL_SPARM_DATA_SIZE 0x07 235 #define FC_EXPL_SPARM_CONCURRENT 0x09 236 #define FC_EXPL_SPARM_CREDIT 0x0b 237 #define FC_EXPL_INV_PORT_NAME 0x0d 238 #define FC_EXPL_INV_NODE_NAME 0x0e 239 #define FC_EXPL_INV_COMMON_SPARAMS 0x0f 240 #define FC_EXPL_INV_ASSOC_HEADER 0x11 241 #define FC_EXPL_ASSOC_HDR_REQUIRED 0x13 242 #define FC_EXPL_INV_ORIGINATOR_S_ID 0x15 243 #define FC_EXPL_INV_X_ID_COMBINATION 0x17 244 #define FC_EXPL_COMMAND_IN_PROGRESS 0x19 245 #define FC_EXPL_NPORT_LOGIN_REQUIRED 0x1e 246 #define FC_EXPL_N_PORT_ID 0x1f 247 #define FC_EXPL_INSUFFICIENT_RESOURCES 0x29 248 #define FC_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a 249 #define FC_EXPL_REQUEST_NOT_SUPPORTED 0x2c 250 #define FC_EXPL_INV_PAYLOAD_LEN 0x1d 251 #define FC_EXPL_INV_PORT_NODE_NAME 0x44 252 #define FC_EXPL_LOGIN_EXT_NOT_SUPPORTED 0x46 253 #define FC_EXPL_AUTH_REQUIRED 0x48 254 #define FC_EXPL_SCAN_VALUE_NOT_ALLOWED 0x50 255 #define FC_EXPL_SCAN_VALUE_NOT_SUPPORTED 0x51 256 #define FC_EXPL_NO_RESOURCES_ASSIGNED 0x52 257 #define FC_EXPL_MAC_ADDR_MODE_NOT_SUPPORTED 0x60 258 #define FC_EXPL_MAC_ADDR_INCORRECTLY_FORMED 0x61 259 #define FC_EXPL_VN2VN_PORT_NOT_IN_NEIGHBOR_SET 0x62 260 261 #define FC_EXPL_INV_X_ID 0x03 /* invalid OX_ID - RX_ID combination */ 262 #define FC_EXPL_SEQUENCE_ABORTED 0x05 263 264 typedef struct fc_ba_acc_payload_s { 265 #define FC_SEQ_ID_VALID 0x80 266 #define FC_SEQ_ID_INVALID 0x00 267 uint32_t seq_id_validity:8, 268 seq_id:8, 269 :16; 270 uint32_t ox_id:16, 271 rx_id:16; 272 uint32_t low_seq_cnt:16, 273 high_seq_cnt:16; 274 } fc_ba_acc_payload_t; 275 276 typedef struct fc_ba_rjt_payload_s { 277 uint32_t vendor_unique:8, 278 reason_explanation:8, 279 reason_code:8, 280 :8; 281 } fc_ba_rjt_payload_t; 282 283 typedef struct fc_els_gen_s { 284 uint32_t command_code: 8, 285 resv1: 24; 286 } fc_els_gen_t; 287 288 typedef struct fc_plogi_playload_s { 289 uint32_t command_code: 8, 290 resv1: 24; 291 uint32_t common_service_parameters[4]; 292 uint32_t port_name_hi; 293 uint32_t port_name_lo; 294 uint32_t node_name_hi; 295 uint32_t node_name_lo; 296 uint32_t class1_service_parameters[4]; 297 uint32_t class2_service_parameters[4]; 298 uint32_t class3_service_parameters[4]; 299 uint32_t class4_service_parameters[4]; 300 uint32_t vendor_version_level[4]; 301 } fc_plogi_payload_t; 302 303 typedef fc_plogi_payload_t fc_sparms_t; 304 305 typedef struct fc_logo_payload_s { 306 uint32_t command_code: 8, 307 resv1:24; 308 uint32_t :8, 309 port_id:24; 310 uint32_t port_name_hi; 311 uint32_t port_name_lo; 312 } fc_logo_payload_t; 313 314 typedef struct fc_acc_payload_s { 315 uint32_t command_code: 8, 316 resv1:24; 317 } fc_acc_payload_t; 318 319 typedef struct fc_ls_rjt_payload_s { 320 uint32_t command_code:8, 321 resv1:24; 322 uint32_t resv2:8, 323 reason_code:8, 324 reason_code_exp:8, 325 vendor_unique:8; 326 } fc_ls_rjt_payload_t; 327 328 typedef struct fc_prli_payload_s { 329 uint32_t command_code:8, 330 page_length:8, 331 payload_length:16; 332 uint32_t type:8, 333 type_ext:8, 334 flags:16; 335 uint32_t originator_pa; 336 uint32_t responder_pa; 337 uint32_t :16, 338 service_params:16; 339 } fc_prli_payload_t; 340 341 typedef struct fc_prlo_payload_s { 342 uint32_t command_code:8, 343 page_length:8, 344 payload_length:16; 345 uint32_t type:8, 346 type_ext:8, 347 :16; 348 uint32_t :32; 349 uint32_t :32; 350 uint32_t :32; 351 } fc_prlo_payload_t; 352 353 typedef struct fc_prlo_acc_payload_s { 354 uint32_t command_code:8, 355 page_length:8, 356 payload_length:16; 357 uint32_t type:8, 358 type_ext:8, 359 :4, 360 response_code:4, 361 :8; 362 uint32_t :32; 363 uint32_t :32; 364 uint32_t :32; 365 } fc_prlo_acc_payload_t; 366 367 typedef struct fc_adisc_payload_s { 368 uint32_t command_code:8, 369 payload_length:24; 370 uint32_t :8, 371 hard_address:24; 372 uint32_t port_name_hi; 373 uint32_t port_name_lo; 374 uint32_t node_name_hi; 375 uint32_t node_name_lo; 376 uint32_t :8, 377 port_id:24; 378 } fc_adisc_payload_t; 379 380 /* PRLI flags */ 381 #define FC_PRLI_ORIGINATOR_PA_VALID 0x8000 382 #define FC_PRLI_RESPONDER_PA_VALID 0x4000 383 #define FC_PRLI_ESTABLISH_IMAGE_PAIR 0x2000 384 #define FC_PRLI_SERVICE_PARAM_INVALID 0x0800 385 #define FC_PRLI_REQUEST_EXECUTED 0x0100 386 387 /* PRLI Service Parameters */ 388 #define FC_PRLI_REC_SUPPORT 0x0400 389 #define FC_PRLI_TASK_RETRY_ID_REQ 0x0200 390 #define FC_PRLI_RETRY 0x0100 391 #define FC_PRLI_CONFIRMED_COMPLETION 0x0080 392 #define FC_PRLI_DATA_OVERLAY 0x0040 393 #define FC_PRLI_INITIATOR_FUNCTION 0x0020 394 #define FC_PRLI_TARGET_FUNCTION 0x0010 395 #define FC_PRLI_READ_XRDY_DISABLED 0x0002 396 #define FC_PRLI_WRITE_XRDY_DISABLED 0x0001 397 398 /* PRLO Logout flags */ 399 #define FC_PRLO_REQUEST_EXECUTED 0x0001 400 401 typedef struct fc_scr_payload_s { 402 uint32_t command_code:8, 403 :24; 404 uint32_t :24, 405 function:8; 406 } fc_scr_payload_t; 407 408 #define FC_SCR_REG_FABRIC 1 409 #define FC_SCR_REG_NPORT 2 410 #define FC_SCR_REG_FULL 3 411 412 typedef struct { 413 uint32_t :2, 414 rscn_event_qualifier:4, 415 address_format:2, 416 port_id:24; 417 } fc_rscn_affected_port_id_page_t; 418 419 typedef struct fc_rscn_payload_s { 420 uint32_t command_code:8, 421 page_length:8, 422 payload_length:16; 423 fc_rscn_affected_port_id_page_t port_list[1]; 424 } fc_rscn_payload_t; 425 426 typedef struct fcct_iu_header_s { 427 #if BYTE_ORDER == LITTLE_ENDIAN 428 uint32_t revision:8, 429 in_id:24; 430 uint32_t gs_type:8, 431 gs_subtype:8, 432 options:8, 433 resv1:8; 434 uint32_t cmd_rsp_code:16, 435 max_residual_size:16; 436 uint32_t fragment_id:8, 437 reason_code:8, 438 reason_code_explanation:8, 439 vendor_specific:8; 440 #else 441 #error big endian version not defined 442 #endif 443 } fcct_iu_header_t; 444 445 #define FCCT_REJECT_INVALID_COMMAND_CODE 1 446 #define FCCT_REJECT_INVALID_VERSION_LEVEL 2 447 #define FCCT_LOGICAL_ERROR 3 448 #define FCCT_INVALID_CT_IU_SIZE 4 449 #define FCCT_LOGICAL_BUSY 5 450 #define FCCT_PROTOCOL_ERROR 7 451 #define FCCT_UNABLE_TO_PERFORM 9 452 #define FCCT_COMMAND_NOT_SUPPORTED 0x0b 453 #define FCCT_FABRIC_PORT_NAME_NOT_REGISTERED 0x0c 454 #define FCCT_SERVER_NOT_AVAILABLE 0x0d 455 #define FCCT_SESSION_COULD_NOT_BE_ESTABLISHED 0x0e 456 #define FCCT_VENDOR_SPECIFIC_ERROR 0xff 457 458 #define FCCT_NO_ADDITIONAL_EXPLANATION 0 459 #define FCCT_AUTHORIZATION_EXCEPTION 0xf0 460 #define FCCT_AUTHENTICATION_EXCEPTION 0xf1 461 #define FCCT_DATA_BASE_FULL 0xf2 462 #define FCCT_DATA_BASE_EMPTY 0xf3 463 #define FCCT_PROCESSING_REQUEST 0xf4 464 #define FCCT_UNABLE_TO_VERIFY_CONNECTION 0xf5 465 #define FCCT_DEVICES_NOT_IN_COMMON_ZONE 0xf6 466 467 typedef struct { 468 fcct_iu_header_t hdr; 469 #if BYTE_ORDER == LITTLE_ENDIAN 470 uint32_t port_id; 471 uint32_t fc4_types; 472 #else 473 #error big endian version not defined 474 #endif 475 } fcgs_rft_id_t; 476 477 typedef struct { 478 fcct_iu_header_t hdr; 479 #if BYTE_ORDER == LITTLE_ENDIAN 480 uint32_t port_id; 481 uint32_t :16, 482 fc4_features:8, 483 type_code:8; 484 #else 485 #error big endian version not defined 486 #endif 487 } fcgs_rff_id_t; 488 489 #pragma pack(1) 490 typedef struct { 491 fcct_iu_header_t hdr; 492 #if BYTE_ORDER == LITTLE_ENDIAN 493 uint32_t port_id; 494 uint64_t port_name; 495 #else 496 #error big endian version not defined 497 #endif 498 } fcgs_rpn_id_t; 499 #pragma pack() 500 501 #pragma pack(1) 502 typedef struct { 503 fcct_iu_header_t hdr; 504 #if BYTE_ORDER == LITTLE_ENDIAN 505 uint32_t port_id; 506 uint64_t node_name; 507 #else 508 #error big endian version not defined 509 #endif 510 } fcgs_rnn_id_t; 511 #pragma pack() 512 513 #define FCCT_CLASS_OF_SERVICE_F 0x1 514 #define FCCT_CLASS_OF_SERVICE_2 0x4 515 #define FCCT_CLASS_OF_SERVICE_3 0x8 516 #pragma pack(1) 517 typedef struct { 518 fcct_iu_header_t hdr; 519 #if BYTE_ORDER == LITTLE_ENDIAN 520 uint32_t port_id; 521 uint32_t class_of_srvc; 522 #else 523 #error big endian version not defined 524 #endif 525 } fcgs_rcs_id_t; 526 #pragma pack() 527 528 #pragma pack(1) 529 typedef struct { 530 fcct_iu_header_t hdr; 531 #if BYTE_ORDER == LITTLE_ENDIAN 532 uint64_t node_name; 533 uint8_t name_len; 534 char sym_node_name[1]; 535 /*TODO: need name length and symbolic name */ 536 #else 537 #error big endian version not defined 538 #endif 539 } fcgs_rsnn_nn_t; 540 #pragma pack() 541 542 #define FCCT_HDR_CMDRSP_ACCEPT 0x8002 543 #define FCCT_HDR_CMDRSP_REJECT 0x8001 544 545 static inline void fcct_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint16_t max_size) 546 { 547 /* use old rev (1) to accommodate older switches */ 548 hdr->revision = 1; 549 hdr->in_id = 0; 550 hdr->gs_type = FC_GS_TYPE_DIRECTORY_SERVICE; 551 hdr->gs_subtype = FC_GS_SUBTYPE_NAME_SERVER; 552 hdr->options = 0; 553 hdr->resv1 = 0; 554 hdr->cmd_rsp_code = ocs_htobe16(cmd); 555 hdr->max_residual_size = ocs_htobe16(max_size/(sizeof(uint32_t))); /* words */ 556 hdr->fragment_id = 0; 557 hdr->reason_code = 0; 558 hdr->reason_code_explanation = 0; 559 hdr->vendor_specific = 0; 560 } 561 562 typedef struct fcct_rftid_req_s { 563 fcct_iu_header_t hdr; 564 uint32_t port_id; 565 uint32_t fc4_types[8]; 566 } fcct_rftid_req_t; 567 568 #define FC4_FEATURE_TARGET (1U << 0) 569 #define FC4_FEATURE_INITIATOR (1U << 1) 570 571 typedef struct fcct_rffid_req_s { 572 fcct_iu_header_t hdr; 573 uint32_t port_id; 574 uint32_t :16, 575 fc4_feature_bits:8, 576 type:8; 577 } fcct_rffid_req_t; 578 579 typedef struct fcct_gnnid_req_s { 580 fcct_iu_header_t hdr; 581 uint32_t :8, 582 port_id:24; 583 } fcct_gnnid_req_t; 584 585 typedef struct fcct_gpnid_req_s { 586 fcct_iu_header_t hdr; 587 uint32_t :8, 588 port_id:24; 589 } fcct_gpnid_req_t; 590 591 typedef struct fcct_gffid_req_s { 592 fcct_iu_header_t hdr; 593 uint32_t :8, 594 port_id:24; 595 } fcct_gffid_req_t; 596 597 typedef struct fcct_gidft_req_s { 598 fcct_iu_header_t hdr; 599 uint32_t :8, 600 domain_id_scope:8, 601 area_id_scope:8, 602 type:8; 603 } fcct_gidft_req_t; 604 605 typedef struct fcct_gidpt_req_s { 606 fcct_iu_header_t hdr; 607 uint32_t port_type:8, 608 domain_id_scope:8, 609 area_id_scope:8, 610 flags:8; 611 } fcct_gidpt_req_t; 612 613 typedef struct fcct_gnnid_acc_s { 614 fcct_iu_header_t hdr; 615 uint64_t node_name; 616 } fcct_gnnid_acc_t; 617 618 typedef struct fcct_gpnid_acc_s { 619 fcct_iu_header_t hdr; 620 uint64_t port_name; 621 } fcct_gpnid_acc_t; 622 623 typedef struct fcct_gffid_acc_s { 624 fcct_iu_header_t hdr; 625 uint8_t fc4_feature_bits; 626 } fcct_gffid_acc_t; 627 628 typedef struct fcct_gidft_acc_s { 629 fcct_iu_header_t hdr; 630 struct { 631 uint32_t ctl:8, 632 port_id:24; 633 } port_list[1]; 634 } fcct_gidft_acc_t; 635 636 typedef struct fcct_gidpt_acc_s { 637 fcct_iu_header_t hdr; 638 struct { 639 uint32_t ctl:8, 640 port_id:24; 641 } port_list[1]; 642 } fcct_gidpt_acc_t; 643 644 #define FCCT_GID_PT_LAST_ID 0x80 645 #define FCCT_GIDPT_ID_MASK 0x00ffffff 646 647 typedef struct fcp_cmnd_iu_s { 648 uint8_t fcp_lun[8]; 649 uint8_t command_reference_number; 650 uint8_t task_attribute:3, 651 command_priority:4, 652 :1; 653 uint8_t task_management_flags; 654 uint8_t wrdata:1, 655 rddata:1, 656 additional_fcp_cdb_length:6; 657 uint8_t fcp_cdb[16]; 658 uint8_t fcp_cdb_and_dl[20]; /* < May contain up to 16 bytes of CDB, followed by fcp_dl */ 659 } fcp_cmnd_iu_t; 660 661 #define FCP_LUN_ADDRESS_METHOD_SHIFT 6 662 #define FCP_LUN_ADDRESS_METHOD_MASK 0xc0 663 #define FCP_LUN_ADDR_METHOD_PERIPHERAL 0x0 664 #define FCP_LUN_ADDR_METHOD_FLAT 0x1 665 #define FCP_LUN_ADDR_METHOD_LOGICAL 0x2 666 #define FCP_LUN_ADDR_METHOD_EXTENDED 0x3 667 668 #define FCP_LUN_ADDR_SIMPLE_MAX 0xff 669 #define FCP_LUN_ADDR_FLAT_MAX 0x3fff 670 671 #define FCP_TASK_ATTR_SIMPLE 0x0 672 #define FCP_TASK_ATTR_HEAD_OF_QUEUE 0x1 673 #define FCP_TASK_ATTR_ORDERED 0x2 674 #define FCP_TASK_ATTR_ACA 0x4 675 #define FCP_TASK_ATTR_UNTAGGED 0x5 676 677 #define FCP_QUERY_TASK_SET BIT(0) 678 #define FCP_ABORT_TASK_SET BIT(1) 679 #define FCP_CLEAR_TASK_SET BIT(2) 680 #define FCP_QUERY_ASYNCHRONOUS_EVENT BIT(3) 681 #define FCP_LOGICAL_UNIT_RESET BIT(4) 682 #define FCP_TARGET_RESET BIT(5) 683 #define FCP_CLEAR_ACA BIT(6) 684 685 /* SPC-4 says that the maximum length of sense data is 252 bytes */ 686 #define FCP_MAX_SENSE_LEN 252 687 #define FCP_MAX_RSP_LEN 8 688 /* 689 * FCP_RSP buffer will either have sense or response data, but not both 690 * so pick the larger. 691 */ 692 #define FCP_MAX_RSP_INFO_LEN FCP_MAX_SENSE_LEN 693 694 typedef struct fcp_rsp_iu_s { 695 uint8_t rsvd[8]; 696 uint8_t status_qualifier[2]; 697 uint8_t flags; 698 uint8_t scsi_status; 699 uint8_t fcp_resid[4]; 700 uint8_t fcp_sns_len[4]; 701 uint8_t fcp_rsp_len[4]; 702 uint8_t data[FCP_MAX_RSP_INFO_LEN]; 703 } fcp_rsp_iu_t; 704 705 /** Flag field defines: */ 706 #define FCP_RSP_LEN_VALID BIT(0) 707 #define FCP_SNS_LEN_VALID BIT(1) 708 #define FCP_RESID_OVER BIT(2) 709 #define FCP_RESID_UNDER BIT(3) 710 #define FCP_CONF_REQ BIT(4) 711 #define FCP_BIDI_READ_RESID_OVER BIT(5) 712 #define FCP_BIDI_READ_RESID_UNDER BIT(6) 713 #define FCP_BIDI_RSP BIT(7) 714 715 /** Status values: */ 716 #define FCP_TMF_COMPLETE 0x00 717 #define FCP_DATA_LENGTH_MISMATCH 0x01 718 #define FCP_INVALID_FIELD 0x02 719 #define FCP_DATA_RO_MISMATCH 0x03 720 #define FCP_TMF_REJECTED 0x04 721 #define FCP_TMF_FAILED 0x05 722 #define FCP_TMF_SUCCEEDED 0x08 723 #define FCP_TMF_INCORRECT_LUN 0x09 724 725 /** FCP-4 Table 28, TMF response information: */ 726 typedef struct fc_rsp_info_s { 727 uint8_t addl_rsp_info[3]; 728 uint8_t rsp_code; 729 uint32_t :32; 730 } fcp_rsp_info_t; 731 732 typedef struct fcp_xfer_rdy_iu_s { 733 uint8_t fcp_data_ro[4]; 734 uint8_t fcp_burst_len[4]; 735 uint8_t rsvd[4]; 736 } fcp_xfer_rdy_iu_t; 737 738 #define MAX_ACC_REJECT_PAYLOAD (sizeof(fc_ls_rjt_payload_t) > sizeof(fc_acc_payload_t) ? sizeof(fc_ls_rjt_payload_t) : sizeof(fc_acc_payload_t)) 739 740 #endif /* !_OCS_FCP_H */ 741