1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright 2008 Cisco Systems, Inc. All rights reserved. 4 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 5 */ 6 #ifndef _FCPIO_H_ 7 #define _FCPIO_H_ 8 9 #include <linux/if_ether.h> 10 11 /* 12 * This header file includes all of the data structures used for 13 * communication by the host driver to the fcp firmware. 14 */ 15 16 /* 17 * Exchange and sequence id space allocated to the host driver 18 */ 19 #define FCPIO_HOST_EXCH_RANGE_START 0x1000 20 #define FCPIO_HOST_EXCH_RANGE_END 0x1fff 21 #define FCPIO_HOST_SEQ_ID_RANGE_START 0x80 22 #define FCPIO_HOST_SEQ_ID_RANGE_END 0xff 23 24 struct fnic_nvme_io_event { 25 struct list_head links; 26 struct work_struct io_work; 27 void *arg1; 28 }; 29 30 struct fnic_io_event_s { 31 struct list_head links; 32 struct work_struct io_work; 33 void *arg1; 34 }; 35 36 /* 37 * Command entry type 38 */ 39 enum fcpio_type { 40 /* 41 * Initiator request types 42 */ 43 FCPIO_ICMND_16 = 0x1, 44 FCPIO_ICMND_32, 45 FCPIO_ICMND_CMPL, 46 FCPIO_ITMF, 47 FCPIO_ITMF_CMPL, 48 FCPIO_NVME_CMD, 49 FCPIO_NVME_ERSP_HW_CMPL, 50 FCPIO_NVME_ERSP_FW_CMPL, 51 52 /* 53 * Target request types 54 */ 55 FCPIO_TCMND_16 = 0x11, 56 FCPIO_TCMND_32, 57 FCPIO_TDATA, 58 FCPIO_TXRDY, 59 FCPIO_TRSP, 60 FCPIO_TDRSP_CMPL, 61 FCPIO_TTMF, 62 FCPIO_TTMF_ACK, 63 FCPIO_TABORT, 64 FCPIO_TABORT_CMPL, 65 66 /* 67 * Misc request types 68 */ 69 FCPIO_ACK = 0x20, 70 FCPIO_RESET, 71 FCPIO_RESET_CMPL, 72 FCPIO_FLOGI_REG, 73 FCPIO_FLOGI_REG_CMPL, 74 FCPIO_ECHO, 75 FCPIO_ECHO_CMPL, 76 FCPIO_LUNMAP_CHNG, 77 FCPIO_LUNMAP_REQ, 78 FCPIO_LUNMAP_REQ_CMPL, 79 FCPIO_FLOGI_FIP_REG, 80 FCPIO_FLOGI_FIP_REG_CMPL, 81 }; 82 83 /* 84 * Header status codes from the firmware 85 */ 86 enum fcpio_status { 87 FCPIO_SUCCESS = 0, /* request was successful */ 88 89 /* 90 * If a request to the firmware is rejected, the original request 91 * header will be returned with the status set to one of the following: 92 */ 93 FCPIO_INVALID_HEADER, /* header contains invalid data */ 94 FCPIO_OUT_OF_RESOURCE, /* out of resources to complete request */ 95 FCPIO_INVALID_PARAM, /* some parameter in request is invalid */ 96 FCPIO_REQ_NOT_SUPPORTED, /* request type is not supported */ 97 FCPIO_IO_NOT_FOUND, /* requested I/O was not found */ 98 99 /* 100 * Once a request is processed, the firmware will usually return 101 * a cmpl message type. In cases where errors occurred, 102 * the header status field would be filled in with one of the following: 103 */ 104 FCPIO_ABORTED = 0x41, /* request was aborted */ 105 FCPIO_TIMEOUT, /* request was timed out */ 106 FCPIO_SGL_INVALID, /* request was aborted due to sgl error */ 107 FCPIO_MSS_INVALID, /* request was aborted due to mss error */ 108 FCPIO_DATA_CNT_MISMATCH, /* recv/sent more/less data than exp. */ 109 FCPIO_FW_ERR, /* request was terminated due to fw error */ 110 FCPIO_ITMF_REJECTED, /* itmf req was rejected by remote node */ 111 FCPIO_ITMF_FAILED, /* itmf req was failed by remote node */ 112 FCPIO_ITMF_INCORRECT_LUN, /* itmf req targeted incorrect LUN */ 113 FCPIO_CMND_REJECTED, /* request was invalid and rejected */ 114 FCPIO_NO_PATH_AVAIL, /* no paths to the lun was available */ 115 FCPIO_PATH_FAILED, /* i/o sent to current path failed */ 116 FCPIO_LUNMAP_CHNG_PEND, /* i/o rejected due to lunmap change */ 117 }; 118 119 /* 120 * The header command tag. All host requests will use the "tag" field 121 * to mark commands with a unique tag. When the firmware responds to 122 * a host request, it will copy the tag field into the response. 123 * 124 * The only firmware requests that will use the rx_id/ox_id fields instead 125 * of the tag field will be the target command and target task management 126 * requests. These two requests do not have corresponding host requests 127 * since they come directly from the FC initiator on the network. 128 */ 129 struct fcpio_tag { 130 union { 131 u32 req_id; 132 struct { 133 u16 rx_id; 134 u16 ox_id; 135 } ex_id; 136 } u; 137 }; 138 139 static inline void 140 fcpio_tag_id_enc(struct fcpio_tag *tag, u32 id) 141 { 142 tag->u.req_id = id; 143 } 144 145 static inline void 146 fcpio_tag_id_dec(struct fcpio_tag *tag, u32 *id) 147 { 148 *id = tag->u.req_id; 149 } 150 151 static inline void 152 fcpio_tag_exid_enc(struct fcpio_tag *tag, u16 ox_id, u16 rx_id) 153 { 154 tag->u.ex_id.rx_id = rx_id; 155 tag->u.ex_id.ox_id = ox_id; 156 } 157 158 static inline void 159 fcpio_tag_exid_dec(struct fcpio_tag *tag, u16 *ox_id, u16 *rx_id) 160 { 161 *rx_id = tag->u.ex_id.rx_id; 162 *ox_id = tag->u.ex_id.ox_id; 163 } 164 165 /* 166 * The header for an fcpio request, whether from the firmware or from the 167 * host driver 168 */ 169 struct fcpio_header { 170 u8 type; /* enum fcpio_type */ 171 u8 status; /* header status entry */ 172 u16 _resvd; /* reserved */ 173 struct fcpio_tag tag; /* header tag */ 174 }; 175 176 static inline void 177 fcpio_header_enc(struct fcpio_header *hdr, 178 u8 type, u8 status, 179 struct fcpio_tag tag) 180 { 181 hdr->type = type; 182 hdr->status = status; 183 hdr->_resvd = 0; 184 hdr->tag = tag; 185 } 186 187 static inline void 188 fcpio_header_dec(struct fcpio_header *hdr, 189 u8 *type, u8 *status, 190 struct fcpio_tag *tag) 191 { 192 *type = hdr->type; 193 *status = hdr->status; 194 *tag = hdr->tag; 195 } 196 197 #define NVME_CMD_SZ 96 198 #define CDB_16 16 199 #define CDB_32 32 200 #define LUN_ADDRESS 8 201 202 struct fcpio_nvme_cmnd { 203 uint8_t d_id[3]; 204 u_int8_t flags; /* command flags */ 205 u_int32_t sgl_cnt; /* scatter-gather list count */ 206 u_int64_t sgl_addr; /* scatter-gather list addr */ 207 u_int16_t cmd_len; 208 u_int16_t _resvd1; /* reserved: should be 0 */ 209 u_int32_t data_len; /* length of data expected */ 210 u_int8_t nvme_cmnd[NVME_CMD_SZ]; /* NVME command */ 211 }; 212 213 /* 214 * fcpio_icmnd_16: host -> firmware request 215 * 216 * used for sending out an initiator SCSI 16-byte command 217 */ 218 struct fcpio_icmnd_16 { 219 u32 lunmap_id; /* index into lunmap table */ 220 u8 special_req_flags; /* special exchange request flags */ 221 u8 _resvd0[3]; /* reserved */ 222 u32 sgl_cnt; /* scatter-gather list count */ 223 u32 sense_len; /* sense buffer length */ 224 u64 sgl_addr; /* scatter-gather list addr */ 225 u64 sense_addr; /* sense buffer address */ 226 u8 crn; /* SCSI Command Reference No. */ 227 u8 pri_ta; /* SCSI Priority and Task attribute */ 228 u8 _resvd1; /* reserved: should be 0 */ 229 u8 flags; /* command flags */ 230 u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */ 231 u32 data_len; /* length of data expected */ 232 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 233 u8 _resvd2; /* reserved */ 234 u8 d_id[3]; /* FC vNIC only: Target D_ID */ 235 u16 mss; /* FC vNIC only: max burst */ 236 u16 _resvd3; /* reserved */ 237 u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */ 238 u32 e_d_tov; /* FC vNIC only: Err Detect Timeout */ 239 }; 240 241 /* 242 * Special request flags 243 */ 244 #define FCPIO_ICMND_SRFLAG_RETRY 0x01 /* Enable Retry handling on exchange */ 245 246 /* 247 * Priority/Task Attribute settings 248 */ 249 #define FCPIO_ICMND_PTA_SIMPLE 0 /* simple task attribute */ 250 #define FCPIO_ICMND_PTA_HEADQ 1 /* head of queue task attribute */ 251 #define FCPIO_ICMND_PTA_ORDERED 2 /* ordered task attribute */ 252 #define FCPIO_ICMND_PTA_ACA 4 /* auto contingent allegiance */ 253 #define FCPIO_ICMND_PRI_SHIFT 3 /* priority field starts in bit 3 */ 254 255 /* 256 * Command flags 257 */ 258 #define FCPIO_ICMND_RDDATA 0x02 /* read data */ 259 #define FCPIO_ICMND_WRDATA 0x01 /* write data */ 260 261 /* 262 * fcpio_icmnd_32: host -> firmware request 263 * 264 * used for sending out an initiator SCSI 32-byte command 265 */ 266 struct fcpio_icmnd_32 { 267 u32 lunmap_id; /* index into lunmap table */ 268 u8 special_req_flags; /* special exchange request flags */ 269 u8 _resvd0[3]; /* reserved */ 270 u32 sgl_cnt; /* scatter-gather list count */ 271 u32 sense_len; /* sense buffer length */ 272 u64 sgl_addr; /* scatter-gather list addr */ 273 u64 sense_addr; /* sense buffer address */ 274 u8 crn; /* SCSI Command Reference No. */ 275 u8 pri_ta; /* SCSI Priority and Task attribute */ 276 u8 _resvd1; /* reserved: should be 0 */ 277 u8 flags; /* command flags */ 278 u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */ 279 u32 data_len; /* length of data expected */ 280 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 281 u8 _resvd2; /* reserved */ 282 u8 d_id[3]; /* FC vNIC only: Target D_ID */ 283 u16 mss; /* FC vNIC only: max burst */ 284 u16 _resvd3; /* reserved */ 285 u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */ 286 u32 e_d_tov; /* FC vNIC only: Error Detect Timeout */ 287 }; 288 289 /* 290 * fcpio_itmf: host -> firmware request 291 * 292 * used for requesting the firmware to abort a request and/or send out 293 * a task management function 294 * 295 * The t_tag field is only needed when the request type is ABT_TASK. 296 */ 297 struct fcpio_itmf { 298 u32 lunmap_id; /* index into lunmap table */ 299 u32 tm_req; /* SCSI Task Management request */ 300 u32 t_tag; /* header tag of fcpio to be aborted */ 301 u32 _resvd; /* _reserved */ 302 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 303 u8 _resvd1; /* reserved */ 304 u8 d_id[3]; /* FC vNIC only: Target D_ID */ 305 u32 r_a_tov; /* FC vNIC only: R_A_TOV in msec */ 306 u32 e_d_tov; /* FC vNIC only: E_D_TOV in msec */ 307 }; 308 309 /* 310 * Task Management request 311 */ 312 enum fcpio_itmf_tm_req_type { 313 FCPIO_ITMF_ABT_TASK_TERM = 0x01, /* abort task and terminate */ 314 FCPIO_ITMF_ABT_TASK, /* abort task and issue abts */ 315 FCPIO_ITMF_ABT_TASK_SET, /* abort task set */ 316 FCPIO_ITMF_CLR_TASK_SET, /* clear task set */ 317 FCPIO_ITMF_LUN_RESET, /* logical unit reset task mgmt */ 318 FCPIO_ITMF_CLR_ACA, /* Clear ACA condition */ 319 }; 320 321 /* 322 * fcpio_tdata: host -> firmware request 323 * 324 * used for requesting the firmware to send out a read data transfer for a 325 * target command 326 */ 327 struct fcpio_tdata { 328 u16 rx_id; /* FC rx_id of target command */ 329 u16 flags; /* command flags */ 330 u32 rel_offset; /* data sequence relative offset */ 331 u32 sgl_cnt; /* scatter-gather list count */ 332 u32 data_len; /* length of data expected to send */ 333 u64 sgl_addr; /* scatter-gather list address */ 334 }; 335 336 /* 337 * Command flags 338 */ 339 #define FCPIO_TDATA_SCSI_RSP 0x01 /* send a scsi resp. after last frame */ 340 341 /* 342 * fcpio_txrdy: host -> firmware request 343 * 344 * used for requesting the firmware to send out a write data transfer for a 345 * target command 346 */ 347 struct fcpio_txrdy { 348 u16 rx_id; /* FC rx_id of target command */ 349 u16 _resvd0; /* reserved */ 350 u32 rel_offset; /* data sequence relative offset */ 351 u32 sgl_cnt; /* scatter-gather list count */ 352 u32 data_len; /* length of data expected to send */ 353 u64 sgl_addr; /* scatter-gather list address */ 354 }; 355 356 /* 357 * fcpio_trsp: host -> firmware request 358 * 359 * used for requesting the firmware to send out a response for a target 360 * command 361 */ 362 struct fcpio_trsp { 363 u16 rx_id; /* FC rx_id of target command */ 364 u16 _resvd0; /* reserved */ 365 u32 sense_len; /* sense data buffer length */ 366 u64 sense_addr; /* sense data buffer address */ 367 u16 _resvd1; /* reserved */ 368 u8 flags; /* response request flags */ 369 u8 scsi_status; /* SCSI status */ 370 u32 residual; /* SCSI data residual value of I/O */ 371 }; 372 373 /* 374 * resposnse request flags 375 */ 376 #define FCPIO_TRSP_RESID_UNDER 0x08 /* residual is valid and is underflow */ 377 #define FCPIO_TRSP_RESID_OVER 0x04 /* residual is valid and is overflow */ 378 379 /* 380 * fcpio_ttmf_ack: host -> firmware response 381 * 382 * used by the host to indicate to the firmware it has received and processed 383 * the target tmf request 384 */ 385 struct fcpio_ttmf_ack { 386 u16 rx_id; /* FC rx_id of target command */ 387 u16 _resvd0; /* reserved */ 388 u32 tmf_status; /* SCSI task management status */ 389 }; 390 391 /* 392 * fcpio_tabort: host -> firmware request 393 * 394 * used by the host to request the firmware to abort a target request that was 395 * received by the firmware 396 */ 397 struct fcpio_tabort { 398 u16 rx_id; /* rx_id of the target request */ 399 }; 400 401 /* 402 * fcpio_reset: host -> firmware request 403 * 404 * used by the host to signal a reset of the driver to the firmware 405 * and to request firmware to clean up all outstanding I/O 406 */ 407 struct fcpio_reset { 408 u32 _resvd; 409 }; 410 411 enum fcpio_flogi_reg_format_type { 412 FCPIO_FLOGI_REG_DEF_DEST = 0, /* Use the oui | s_id mac format */ 413 FCPIO_FLOGI_REG_GW_DEST, /* Use the fixed gateway mac */ 414 }; 415 416 /* 417 * fcpio_flogi_reg: host -> firmware request 418 * 419 * fc vnic only 420 * used by the host to notify the firmware of the lif's s_id 421 * and destination mac address format 422 */ 423 struct fcpio_flogi_reg { 424 u8 format; 425 u8 s_id[3]; /* FC vNIC only: Source S_ID */ 426 u8 gateway_mac[ETH_ALEN]; /* Destination gateway mac */ 427 u16 _resvd; 428 u32 r_a_tov; /* R_A_TOV in msec */ 429 u32 e_d_tov; /* E_D_TOV in msec */ 430 }; 431 432 /* 433 * fcpio_echo: host -> firmware request 434 * 435 * sends a heartbeat echo request to the firmware 436 */ 437 struct fcpio_echo { 438 u32 _resvd; 439 }; 440 441 /* 442 * fcpio_lunmap_req: host -> firmware request 443 * 444 * scsi vnic only 445 * sends a request to retrieve the lunmap table for scsi vnics 446 */ 447 struct fcpio_lunmap_req { 448 u64 addr; /* address of the buffer */ 449 u32 len; /* len of the buffer */ 450 }; 451 452 /* 453 * fcpio_flogi_fip_reg: host -> firmware request 454 * 455 * fc vnic only 456 * used by the host to notify the firmware of the lif's s_id 457 * and destination mac address format 458 */ 459 struct fcpio_flogi_fip_reg { 460 u8 _resvd0; 461 u8 s_id[3]; /* FC vNIC only: Source S_ID */ 462 u8 fcf_mac[ETH_ALEN]; /* FCF Target destination mac */ 463 u16 _resvd1; 464 u32 r_a_tov; /* R_A_TOV in msec */ 465 u32 e_d_tov; /* E_D_TOV in msec */ 466 u8 ha_mac[ETH_ALEN]; /* Host adapter source mac */ 467 u16 _resvd2; 468 }; 469 470 /* 471 * Basic structure for all fcpio structures that are sent from the host to the 472 * firmware. They are 128 bytes per structure. 473 */ 474 #define FCPIO_HOST_REQ_LEN 128 /* expected length of host requests */ 475 476 struct fcpio_host_req { 477 struct fcpio_header hdr; 478 479 union { 480 /* 481 * Defines space needed for request 482 */ 483 u8 buf[FCPIO_HOST_REQ_LEN - sizeof(struct fcpio_header)]; 484 485 /* 486 * Initiator host requests 487 */ 488 struct fcpio_nvme_cmnd nvcmnd; 489 struct fcpio_icmnd_16 icmnd_16; 490 struct fcpio_icmnd_32 icmnd_32; 491 struct fcpio_itmf itmf; 492 493 /* 494 * Target host requests 495 */ 496 struct fcpio_tdata tdata; 497 struct fcpio_txrdy txrdy; 498 struct fcpio_trsp trsp; 499 struct fcpio_ttmf_ack ttmf_ack; 500 struct fcpio_tabort tabort; 501 502 /* 503 * Misc requests 504 */ 505 struct fcpio_reset reset; 506 struct fcpio_flogi_reg flogi_reg; 507 struct fcpio_echo echo; 508 struct fcpio_lunmap_req lunmap_req; 509 struct fcpio_flogi_fip_reg flogi_fip_reg; 510 } u; 511 }; 512 513 struct fcpio_nvme_cmpl { 514 uint8_t resp_size; 515 uint8_t resvd[3]; 516 uint8_t resp_bytes[32]; 517 }; 518 519 /* 520 * fcpio_icmnd_cmpl: firmware -> host response 521 * 522 * used for sending the host a response to an initiator command 523 */ 524 struct fcpio_icmnd_cmpl { 525 u8 _resvd0[6]; /* reserved */ 526 u8 flags; /* response flags */ 527 u8 scsi_status; /* SCSI status */ 528 u32 residual; /* SCSI data residual length */ 529 u32 sense_len; /* SCSI sense length */ 530 }; 531 532 /* 533 * response flags 534 */ 535 #define FCPIO_ICMND_CMPL_RESID_UNDER 0x08 /* resid under and valid */ 536 #define FCPIO_ICMND_CMPL_RESID_OVER 0x04 /* resid over and valid */ 537 538 /* 539 * fcpio_itmf_cmpl: firmware -> host response 540 * 541 * used for sending the host a response for a itmf request 542 */ 543 struct fcpio_itmf_cmpl { 544 u32 _resvd; /* reserved */ 545 }; 546 547 /* 548 * fcpio_tcmnd_16: firmware -> host request 549 * 550 * used by the firmware to notify the host of an incoming target SCSI 16-Byte 551 * request 552 */ 553 struct fcpio_tcmnd_16 { 554 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 555 u8 crn; /* SCSI Command Reference No. */ 556 u8 pri_ta; /* SCSI Priority and Task attribute */ 557 u8 _resvd2; /* reserved: should be 0 */ 558 u8 flags; /* command flags */ 559 u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */ 560 u32 data_len; /* length of data expected */ 561 u8 _resvd1; /* reserved */ 562 u8 s_id[3]; /* FC vNIC only: Source S_ID */ 563 }; 564 565 /* 566 * Priority/Task Attribute settings 567 */ 568 #define FCPIO_TCMND_PTA_SIMPLE 0 /* simple task attribute */ 569 #define FCPIO_TCMND_PTA_HEADQ 1 /* head of queue task attribute */ 570 #define FCPIO_TCMND_PTA_ORDERED 2 /* ordered task attribute */ 571 #define FCPIO_TCMND_PTA_ACA 4 /* auto contingent allegiance */ 572 #define FCPIO_TCMND_PRI_SHIFT 3 /* priority field starts in bit 3 */ 573 574 /* 575 * Command flags 576 */ 577 #define FCPIO_TCMND_RDDATA 0x02 /* read data */ 578 #define FCPIO_TCMND_WRDATA 0x01 /* write data */ 579 580 /* 581 * fcpio_tcmnd_32: firmware -> host request 582 * 583 * used by the firmware to notify the host of an incoming target SCSI 32-Byte 584 * request 585 */ 586 struct fcpio_tcmnd_32 { 587 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 588 u8 crn; /* SCSI Command Reference No. */ 589 u8 pri_ta; /* SCSI Priority and Task attribute */ 590 u8 _resvd2; /* reserved: should be 0 */ 591 u8 flags; /* command flags */ 592 u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */ 593 u32 data_len; /* length of data expected */ 594 u8 _resvd0; /* reserved */ 595 u8 s_id[3]; /* FC vNIC only: Source S_ID */ 596 }; 597 598 /* 599 * fcpio_tdrsp_cmpl: firmware -> host response 600 * 601 * used by the firmware to notify the host of a response to a host target 602 * command 603 */ 604 struct fcpio_tdrsp_cmpl { 605 u16 rx_id; /* rx_id of the target request */ 606 u16 _resvd0; /* reserved */ 607 }; 608 609 /* 610 * fcpio_ttmf: firmware -> host request 611 * 612 * used by the firmware to notify the host of an incoming task management 613 * function request 614 */ 615 struct fcpio_ttmf { 616 u8 _resvd0; /* reserved */ 617 u8 s_id[3]; /* FC vNIC only: Source S_ID */ 618 u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ 619 u8 crn; /* SCSI Command Reference No. */ 620 u8 _resvd2[3]; /* reserved */ 621 u32 tmf_type; /* task management request type */ 622 }; 623 624 /* 625 * Task Management request 626 */ 627 #define FCPIO_TTMF_CLR_ACA 0x40 /* Clear ACA condition */ 628 #define FCPIO_TTMF_LUN_RESET 0x10 /* logical unit reset task mgmt */ 629 #define FCPIO_TTMF_CLR_TASK_SET 0x04 /* clear task set */ 630 #define FCPIO_TTMF_ABT_TASK_SET 0x02 /* abort task set */ 631 #define FCPIO_TTMF_ABT_TASK 0x01 /* abort task */ 632 633 /* 634 * fcpio_tabort_cmpl: firmware -> host response 635 * 636 * used by the firmware to respond to a host's tabort request 637 */ 638 struct fcpio_tabort_cmpl { 639 u16 rx_id; /* rx_id of the target request */ 640 u16 _resvd0; /* reserved */ 641 }; 642 643 /* 644 * fcpio_ack: firmware -> host response 645 * 646 * used by firmware to notify the host of the last work request received 647 */ 648 struct fcpio_ack { 649 u16 request_out; /* last host entry received */ 650 u16 _resvd; 651 }; 652 653 /* 654 * fcpio_reset_cmpl: firmware -> host response 655 * 656 * use by firmware to respond to the host's reset request 657 */ 658 struct fcpio_reset_cmpl { 659 u16 vnic_id; 660 }; 661 662 /* 663 * fcpio_flogi_reg_cmpl: firmware -> host response 664 * 665 * fc vnic only 666 * response to the fcpio_flogi_reg request 667 */ 668 struct fcpio_flogi_reg_cmpl { 669 u32 _resvd; 670 }; 671 672 /* 673 * fcpio_echo_cmpl: firmware -> host response 674 * 675 * response to the fcpio_echo request 676 */ 677 struct fcpio_echo_cmpl { 678 u32 _resvd; 679 }; 680 681 /* 682 * fcpio_lunmap_chng: firmware -> host notification 683 * 684 * scsi vnic only 685 * notifies the host that the lunmap tables have changed 686 */ 687 struct fcpio_lunmap_chng { 688 u32 _resvd; 689 }; 690 691 /* 692 * fcpio_lunmap_req_cmpl: firmware -> host response 693 * 694 * scsi vnic only 695 * response for lunmap table request from the host 696 */ 697 struct fcpio_lunmap_req_cmpl { 698 u32 _resvd; 699 }; 700 701 /* 702 * Basic structure for all fcpio structures that are sent from the firmware to 703 * the host. They are 64 bytes per structure. 704 */ 705 #define FCPIO_FW_REQ_LEN 64 /* expected length of fw requests */ 706 struct fcpio_fw_req { 707 struct fcpio_header hdr; 708 709 union { 710 /* 711 * Defines space needed for request 712 */ 713 u8 buf[FCPIO_FW_REQ_LEN - sizeof(struct fcpio_header)]; 714 715 /* 716 * Initiator firmware responses 717 */ 718 struct fcpio_icmnd_cmpl icmnd_cmpl; 719 struct fcpio_nvme_cmpl nvme_cmpl; 720 struct fcpio_itmf_cmpl itmf_cmpl; 721 722 /* 723 * Target firmware new requests 724 */ 725 struct fcpio_tcmnd_16 tcmnd_16; 726 struct fcpio_tcmnd_32 tcmnd_32; 727 728 /* 729 * Target firmware responses 730 */ 731 struct fcpio_tdrsp_cmpl tdrsp_cmpl; 732 struct fcpio_ttmf ttmf; 733 struct fcpio_tabort_cmpl tabort_cmpl; 734 735 /* 736 * Firmware response to work received 737 */ 738 struct fcpio_ack ack; 739 740 /* 741 * Misc requests 742 */ 743 struct fcpio_reset_cmpl reset_cmpl; 744 struct fcpio_flogi_reg_cmpl flogi_reg_cmpl; 745 struct fcpio_echo_cmpl echo_cmpl; 746 struct fcpio_lunmap_chng lunmap_chng; 747 struct fcpio_lunmap_req_cmpl lunmap_req_cmpl; 748 } u; 749 }; 750 751 /* 752 * Access routines to encode and decode the color bit, which is the most 753 * significant bit of the MSB of the structure 754 */ 755 static inline void fcpio_color_enc(struct fcpio_fw_req *fw_req, u8 color) 756 { 757 u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1; 758 759 if (color) 760 *c |= 0x80; 761 else 762 *c &= ~0x80; 763 } 764 765 static inline void fcpio_color_dec(struct fcpio_fw_req *fw_req, u8 *color) 766 { 767 u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1; 768 769 *color = *c >> 7; 770 771 /* 772 * Make sure color bit is read from desc *before* other fields 773 * are read from desc. Hardware guarantees color bit is last 774 * bit (byte) written. Adding the rmb() prevents the compiler 775 * and/or CPU from reordering the reads which would potentially 776 * result in reading stale values. 777 */ 778 779 rmb(); 780 781 } 782 783 /* 784 * Lunmap table entry for scsi vnics 785 */ 786 #define FCPIO_LUNMAP_TABLE_SIZE 256 787 #define FCPIO_FLAGS_LUNMAP_VALID 0x80 788 #define FCPIO_FLAGS_BOOT 0x01 789 struct fcpio_lunmap_entry { 790 u8 bus; 791 u8 target; 792 u8 lun; 793 u8 path_cnt; 794 u16 flags; 795 u16 update_cnt; 796 }; 797 798 struct fcpio_lunmap_tbl { 799 u32 update_cnt; 800 struct fcpio_lunmap_entry lunmaps[FCPIO_LUNMAP_TABLE_SIZE]; 801 }; 802 803 #endif /* _FCPIO_H_ */ 804