| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2016, Avago Technologies |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 6 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #ifndef _NVME_FC_DRIVER_H |
|---|
| 15 | 7 | #define _NVME_FC_DRIVER_H 1 |
|---|
| 8 | + |
|---|
| 9 | +#include <linux/scatterlist.h> |
|---|
| 10 | + |
|---|
| 11 | + |
|---|
| 12 | +/* |
|---|
| 13 | + * ********************** FC-NVME LS API ******************** |
|---|
| 14 | + * |
|---|
| 15 | + * Data structures used by both FC-NVME hosts and FC-NVME |
|---|
| 16 | + * targets to perform FC-NVME LS requests or transmit |
|---|
| 17 | + * responses. |
|---|
| 18 | + * |
|---|
| 19 | + * *********************************************************** |
|---|
| 20 | + */ |
|---|
| 21 | + |
|---|
| 22 | +/** |
|---|
| 23 | + * struct nvmefc_ls_req - Request structure passed from the transport |
|---|
| 24 | + * to the LLDD to perform a NVME-FC LS request and obtain |
|---|
| 25 | + * a response. |
|---|
| 26 | + * Used by nvme-fc transport (host) to send LS's such as |
|---|
| 27 | + * Create Association, Create Connection and Disconnect |
|---|
| 28 | + * Association. |
|---|
| 29 | + * Used by the nvmet-fc transport (controller) to send |
|---|
| 30 | + * LS's such as Disconnect Association. |
|---|
| 31 | + * |
|---|
| 32 | + * Values set by the requestor prior to calling the LLDD ls_req entrypoint: |
|---|
| 33 | + * @rqstaddr: pointer to request buffer |
|---|
| 34 | + * @rqstdma: PCI DMA address of request buffer |
|---|
| 35 | + * @rqstlen: Length, in bytes, of request buffer |
|---|
| 36 | + * @rspaddr: pointer to response buffer |
|---|
| 37 | + * @rspdma: PCI DMA address of response buffer |
|---|
| 38 | + * @rsplen: Length, in bytes, of response buffer |
|---|
| 39 | + * @timeout: Maximum amount of time, in seconds, to wait for the LS response. |
|---|
| 40 | + * If timeout exceeded, LLDD to abort LS exchange and complete |
|---|
| 41 | + * LS request with error status. |
|---|
| 42 | + * @private: pointer to memory allocated alongside the ls request structure |
|---|
| 43 | + * that is specifically for the LLDD to use while processing the |
|---|
| 44 | + * request. The length of the buffer corresponds to the |
|---|
| 45 | + * lsrqst_priv_sz value specified in the xxx_template supplied |
|---|
| 46 | + * by the LLDD. |
|---|
| 47 | + * @done: The callback routine the LLDD is to invoke upon completion of |
|---|
| 48 | + * the LS request. req argument is the pointer to the original LS |
|---|
| 49 | + * request structure. Status argument must be 0 upon success, a |
|---|
| 50 | + * negative errno on failure (example: -ENXIO). |
|---|
| 51 | + */ |
|---|
| 52 | +struct nvmefc_ls_req { |
|---|
| 53 | + void *rqstaddr; |
|---|
| 54 | + dma_addr_t rqstdma; |
|---|
| 55 | + u32 rqstlen; |
|---|
| 56 | + void *rspaddr; |
|---|
| 57 | + dma_addr_t rspdma; |
|---|
| 58 | + u32 rsplen; |
|---|
| 59 | + u32 timeout; |
|---|
| 60 | + |
|---|
| 61 | + void *private; |
|---|
| 62 | + |
|---|
| 63 | + void (*done)(struct nvmefc_ls_req *req, int status); |
|---|
| 64 | + |
|---|
| 65 | +} __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ |
|---|
| 66 | + |
|---|
| 67 | + |
|---|
| 68 | +/** |
|---|
| 69 | + * struct nvmefc_ls_rsp - Structure passed from the transport to the LLDD |
|---|
| 70 | + * to request the transmit the NVME-FC LS response to a |
|---|
| 71 | + * NVME-FC LS request. The structure originates in the LLDD |
|---|
| 72 | + * and is given to the transport via the xxx_rcv_ls_req() |
|---|
| 73 | + * transport routine. As such, the structure represents the |
|---|
| 74 | + * FC exchange context for the NVME-FC LS request that was |
|---|
| 75 | + * received and which the response is to be sent for. |
|---|
| 76 | + * Used by the LLDD to pass the nvmet-fc transport (controller) |
|---|
| 77 | + * received LS's such as Create Association, Create Connection |
|---|
| 78 | + * and Disconnect Association. |
|---|
| 79 | + * Used by the LLDD to pass the nvme-fc transport (host) |
|---|
| 80 | + * received LS's such as Disconnect Association or Disconnect |
|---|
| 81 | + * Connection. |
|---|
| 82 | + * |
|---|
| 83 | + * The structure is allocated by the LLDD whenever a LS Request is received |
|---|
| 84 | + * from the FC link. The address of the structure is passed to the nvmet-fc |
|---|
| 85 | + * or nvme-fc layer via the xxx_rcv_ls_req() transport routines. |
|---|
| 86 | + * |
|---|
| 87 | + * The address of the structure is to be passed back to the LLDD |
|---|
| 88 | + * when the response is to be transmit. The LLDD will use the address to |
|---|
| 89 | + * map back to the LLDD exchange structure which maintains information such |
|---|
| 90 | + * the remote N_Port that sent the LS as well as any FC exchange context. |
|---|
| 91 | + * Upon completion of the LS response transmit, the LLDD will pass the |
|---|
| 92 | + * address of the structure back to the transport LS rsp done() routine, |
|---|
| 93 | + * allowing the transport release dma resources. Upon completion of |
|---|
| 94 | + * the done() routine, no further access to the structure will be made by |
|---|
| 95 | + * the transport and the LLDD can de-allocate the structure. |
|---|
| 96 | + * |
|---|
| 97 | + * Field initialization: |
|---|
| 98 | + * At the time of the xxx_rcv_ls_req() call, there is no content that |
|---|
| 99 | + * is valid in the structure. |
|---|
| 100 | + * |
|---|
| 101 | + * When the structure is used for the LLDD->xmt_ls_rsp() call, the |
|---|
| 102 | + * transport layer will fully set the fields in order to specify the |
|---|
| 103 | + * response payload buffer and its length as well as the done routine |
|---|
| 104 | + * to be called upon completion of the transmit. The transport layer |
|---|
| 105 | + * will also set a private pointer for its own use in the done routine. |
|---|
| 106 | + * |
|---|
| 107 | + * Values set by the transport layer prior to calling the LLDD xmt_ls_rsp |
|---|
| 108 | + * entrypoint: |
|---|
| 109 | + * @rspbuf: pointer to the LS response buffer |
|---|
| 110 | + * @rspdma: PCI DMA address of the LS response buffer |
|---|
| 111 | + * @rsplen: Length, in bytes, of the LS response buffer |
|---|
| 112 | + * @done: The callback routine the LLDD is to invoke upon completion of |
|---|
| 113 | + * transmitting the LS response. req argument is the pointer to |
|---|
| 114 | + * the original ls request. |
|---|
| 115 | + * @nvme_fc_private: pointer to an internal transport-specific structure |
|---|
| 116 | + * used as part of the transport done() processing. The LLDD is |
|---|
| 117 | + * not to access this pointer. |
|---|
| 118 | + */ |
|---|
| 119 | +struct nvmefc_ls_rsp { |
|---|
| 120 | + void *rspbuf; |
|---|
| 121 | + dma_addr_t rspdma; |
|---|
| 122 | + u16 rsplen; |
|---|
| 123 | + |
|---|
| 124 | + void (*done)(struct nvmefc_ls_rsp *rsp); |
|---|
| 125 | + void *nvme_fc_private; /* LLDD is not to access !! */ |
|---|
| 126 | +}; |
|---|
| 127 | + |
|---|
| 16 | 128 | |
|---|
| 17 | 129 | |
|---|
| 18 | 130 | /* |
|---|
| .. | .. |
|---|
| 22 | 134 | * |
|---|
| 23 | 135 | * ****************************************************************** |
|---|
| 24 | 136 | */ |
|---|
| 25 | | - |
|---|
| 26 | | - |
|---|
| 27 | | - |
|---|
| 28 | | -/* FC Port role bitmask - can merge with FC Port Roles in fc transport */ |
|---|
| 29 | | -#define FC_PORT_ROLE_NVME_INITIATOR 0x10 |
|---|
| 30 | | -#define FC_PORT_ROLE_NVME_TARGET 0x20 |
|---|
| 31 | | -#define FC_PORT_ROLE_NVME_DISCOVERY 0x40 |
|---|
| 32 | 137 | |
|---|
| 33 | 138 | |
|---|
| 34 | 139 | /** |
|---|
| .. | .. |
|---|
| 54 | 159 | u32 port_id; |
|---|
| 55 | 160 | u32 dev_loss_tmo; |
|---|
| 56 | 161 | }; |
|---|
| 57 | | - |
|---|
| 58 | | - |
|---|
| 59 | | -/** |
|---|
| 60 | | - * struct nvmefc_ls_req - Request structure passed from NVME-FC transport |
|---|
| 61 | | - * to LLDD in order to perform a NVME FC-4 LS |
|---|
| 62 | | - * request and obtain a response. |
|---|
| 63 | | - * |
|---|
| 64 | | - * Values set by the NVME-FC layer prior to calling the LLDD ls_req |
|---|
| 65 | | - * entrypoint. |
|---|
| 66 | | - * @rqstaddr: pointer to request buffer |
|---|
| 67 | | - * @rqstdma: PCI DMA address of request buffer |
|---|
| 68 | | - * @rqstlen: Length, in bytes, of request buffer |
|---|
| 69 | | - * @rspaddr: pointer to response buffer |
|---|
| 70 | | - * @rspdma: PCI DMA address of response buffer |
|---|
| 71 | | - * @rsplen: Length, in bytes, of response buffer |
|---|
| 72 | | - * @timeout: Maximum amount of time, in seconds, to wait for the LS response. |
|---|
| 73 | | - * If timeout exceeded, LLDD to abort LS exchange and complete |
|---|
| 74 | | - * LS request with error status. |
|---|
| 75 | | - * @private: pointer to memory allocated alongside the ls request structure |
|---|
| 76 | | - * that is specifically for the LLDD to use while processing the |
|---|
| 77 | | - * request. The length of the buffer corresponds to the |
|---|
| 78 | | - * lsrqst_priv_sz value specified in the nvme_fc_port_template |
|---|
| 79 | | - * supplied by the LLDD. |
|---|
| 80 | | - * @done: The callback routine the LLDD is to invoke upon completion of |
|---|
| 81 | | - * the LS request. req argument is the pointer to the original LS |
|---|
| 82 | | - * request structure. Status argument must be 0 upon success, a |
|---|
| 83 | | - * negative errno on failure (example: -ENXIO). |
|---|
| 84 | | - */ |
|---|
| 85 | | -struct nvmefc_ls_req { |
|---|
| 86 | | - void *rqstaddr; |
|---|
| 87 | | - dma_addr_t rqstdma; |
|---|
| 88 | | - u32 rqstlen; |
|---|
| 89 | | - void *rspaddr; |
|---|
| 90 | | - dma_addr_t rspdma; |
|---|
| 91 | | - u32 rsplen; |
|---|
| 92 | | - u32 timeout; |
|---|
| 93 | | - |
|---|
| 94 | | - void *private; |
|---|
| 95 | | - |
|---|
| 96 | | - void (*done)(struct nvmefc_ls_req *req, int status); |
|---|
| 97 | | - |
|---|
| 98 | | -} __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ |
|---|
| 99 | | - |
|---|
| 100 | 162 | |
|---|
| 101 | 163 | enum nvmefc_fcp_datadir { |
|---|
| 102 | 164 | NVMEFC_FCP_NODATA, /* payload_length and sg_cnt will be zero */ |
|---|
| .. | .. |
|---|
| 349 | 411 | * indicating an FC transport Aborted status. |
|---|
| 350 | 412 | * Entrypoint is Mandatory. |
|---|
| 351 | 413 | * |
|---|
| 414 | + * @xmt_ls_rsp: Called to transmit the response to a FC-NVME FC-4 LS service. |
|---|
| 415 | + * The nvmefc_ls_rsp structure is the same LLDD-supplied exchange |
|---|
| 416 | + * structure specified in the nvme_fc_rcv_ls_req() call made when |
|---|
| 417 | + * the LS request was received. The structure will fully describe |
|---|
| 418 | + * the buffers for the response payload and the dma address of the |
|---|
| 419 | + * payload. The LLDD is to transmit the response (or return a |
|---|
| 420 | + * non-zero errno status), and upon completion of the transmit, call |
|---|
| 421 | + * the "done" routine specified in the nvmefc_ls_rsp structure |
|---|
| 422 | + * (argument to done is the address of the nvmefc_ls_rsp structure |
|---|
| 423 | + * itself). Upon the completion of the done routine, the LLDD shall |
|---|
| 424 | + * consider the LS handling complete and the nvmefc_ls_rsp structure |
|---|
| 425 | + * may be freed/released. |
|---|
| 426 | + * Entrypoint is mandatory if the LLDD calls the nvme_fc_rcv_ls_req() |
|---|
| 427 | + * entrypoint. |
|---|
| 428 | + * |
|---|
| 352 | 429 | * @max_hw_queues: indicates the maximum number of hw queues the LLDD |
|---|
| 353 | 430 | * supports for cpu affinitization. |
|---|
| 354 | 431 | * Value is Mandatory. Must be at least 1. |
|---|
| .. | .. |
|---|
| 383 | 460 | * @lsrqst_priv_sz: The LLDD sets this field to the amount of additional |
|---|
| 384 | 461 | * memory that it would like fc nvme layer to allocate on the LLDD's |
|---|
| 385 | 462 | * behalf whenever a ls request structure is allocated. The additional |
|---|
| 386 | | - * memory area solely for the of the LLDD and its location is |
|---|
| 463 | + * memory area is solely for use by the LLDD and its location is |
|---|
| 387 | 464 | * specified by the ls_request->private pointer. |
|---|
| 388 | 465 | * Value is Mandatory. Allowed to be zero. |
|---|
| 389 | 466 | * |
|---|
| .. | .. |
|---|
| 403 | 480 | void **handle); |
|---|
| 404 | 481 | void (*delete_queue)(struct nvme_fc_local_port *, |
|---|
| 405 | 482 | unsigned int qidx, void *handle); |
|---|
| 406 | | - void (*poll_queue)(struct nvme_fc_local_port *, void *handle); |
|---|
| 407 | 483 | int (*ls_req)(struct nvme_fc_local_port *, |
|---|
| 408 | 484 | struct nvme_fc_remote_port *, |
|---|
| 409 | 485 | struct nvmefc_ls_req *); |
|---|
| .. | .. |
|---|
| 418 | 494 | struct nvme_fc_remote_port *, |
|---|
| 419 | 495 | void *hw_queue_handle, |
|---|
| 420 | 496 | struct nvmefc_fcp_req *); |
|---|
| 497 | + int (*xmt_ls_rsp)(struct nvme_fc_local_port *localport, |
|---|
| 498 | + struct nvme_fc_remote_port *rport, |
|---|
| 499 | + struct nvmefc_ls_rsp *ls_rsp); |
|---|
| 421 | 500 | |
|---|
| 422 | 501 | u32 max_hw_queues; |
|---|
| 423 | 502 | u16 max_sgl_segments; |
|---|
| .. | .. |
|---|
| 454 | 533 | int nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *remoteport, |
|---|
| 455 | 534 | u32 dev_loss_tmo); |
|---|
| 456 | 535 | |
|---|
| 536 | +/* |
|---|
| 537 | + * Routine called to pass a NVME-FC LS request, received by the lldd, |
|---|
| 538 | + * to the nvme-fc transport. |
|---|
| 539 | + * |
|---|
| 540 | + * If the return value is zero: the LS was successfully accepted by the |
|---|
| 541 | + * transport. |
|---|
| 542 | + * If the return value is non-zero: the transport has not accepted the |
|---|
| 543 | + * LS. The lldd should ABTS-LS the LS. |
|---|
| 544 | + * |
|---|
| 545 | + * Note: if the LLDD receives and ABTS for the LS prior to the transport |
|---|
| 546 | + * calling the ops->xmt_ls_rsp() routine to transmit a response, the LLDD |
|---|
| 547 | + * shall mark the LS as aborted, and when the xmt_ls_rsp() is called: the |
|---|
| 548 | + * response shall not be transmit and the struct nvmefc_ls_rsp() done |
|---|
| 549 | + * routine shall be called. The LLDD may transmit the ABTS response as |
|---|
| 550 | + * soon as the LS was marked or can delay until the xmt_ls_rsp() call is |
|---|
| 551 | + * made. |
|---|
| 552 | + * Note: if an RCV LS was successfully posted to the transport and the |
|---|
| 553 | + * remoteport is then unregistered before xmt_ls_rsp() was called for |
|---|
| 554 | + * the lsrsp structure, the transport will still call xmt_ls_rsp() |
|---|
| 555 | + * afterward to cleanup the outstanding lsrsp structure. The LLDD should |
|---|
| 556 | + * noop the transmission of the rsp and call the lsrsp->done() routine |
|---|
| 557 | + * to allow the lsrsp structure to be released. |
|---|
| 558 | + */ |
|---|
| 559 | +int nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *remoteport, |
|---|
| 560 | + struct nvmefc_ls_rsp *lsrsp, |
|---|
| 561 | + void *lsreqbuf, u32 lsreqbuf_len); |
|---|
| 562 | + |
|---|
| 563 | + |
|---|
| 457 | 564 | |
|---|
| 458 | 565 | /* |
|---|
| 459 | 566 | * *************** LLDD FC-NVME Target/Subsystem API *************** |
|---|
| .. | .. |
|---|
| 482 | 589 | u32 port_id; |
|---|
| 483 | 590 | }; |
|---|
| 484 | 591 | |
|---|
| 485 | | - |
|---|
| 486 | | -/** |
|---|
| 487 | | - * struct nvmefc_tgt_ls_req - Structure used between LLDD and NVMET-FC |
|---|
| 488 | | - * layer to represent the exchange context for |
|---|
| 489 | | - * a FC-NVME Link Service (LS). |
|---|
| 490 | | - * |
|---|
| 491 | | - * The structure is allocated by the LLDD whenever a LS Request is received |
|---|
| 492 | | - * from the FC link. The address of the structure is passed to the nvmet-fc |
|---|
| 493 | | - * layer via the nvmet_fc_rcv_ls_req() call. The address of the structure |
|---|
| 494 | | - * will be passed back to the LLDD when the response is to be transmit. |
|---|
| 495 | | - * The LLDD is to use the address to map back to the LLDD exchange structure |
|---|
| 496 | | - * which maintains information such as the targetport the LS was received |
|---|
| 497 | | - * on, the remote FC NVME initiator that sent the LS, and any FC exchange |
|---|
| 498 | | - * context. Upon completion of the LS response transmit, the address of the |
|---|
| 499 | | - * structure will be passed back to the LS rsp done() routine, allowing the |
|---|
| 500 | | - * nvmet-fc layer to release dma resources. Upon completion of the done() |
|---|
| 501 | | - * routine, no further access will be made by the nvmet-fc layer and the |
|---|
| 502 | | - * LLDD can de-allocate the structure. |
|---|
| 503 | | - * |
|---|
| 504 | | - * Field initialization: |
|---|
| 505 | | - * At the time of the nvmet_fc_rcv_ls_req() call, there is no content that |
|---|
| 506 | | - * is valid in the structure. |
|---|
| 507 | | - * |
|---|
| 508 | | - * When the structure is used for the LLDD->xmt_ls_rsp() call, the nvmet-fc |
|---|
| 509 | | - * layer will fully set the fields in order to specify the response |
|---|
| 510 | | - * payload buffer and its length as well as the done routine to be called |
|---|
| 511 | | - * upon compeletion of the transmit. The nvmet-fc layer will also set a |
|---|
| 512 | | - * private pointer for its own use in the done routine. |
|---|
| 513 | | - * |
|---|
| 514 | | - * Values set by the NVMET-FC layer prior to calling the LLDD xmt_ls_rsp |
|---|
| 515 | | - * entrypoint. |
|---|
| 516 | | - * @rspbuf: pointer to the LS response buffer |
|---|
| 517 | | - * @rspdma: PCI DMA address of the LS response buffer |
|---|
| 518 | | - * @rsplen: Length, in bytes, of the LS response buffer |
|---|
| 519 | | - * @done: The callback routine the LLDD is to invoke upon completion of |
|---|
| 520 | | - * transmitting the LS response. req argument is the pointer to |
|---|
| 521 | | - * the original ls request. |
|---|
| 522 | | - * @nvmet_fc_private: pointer to an internal NVMET-FC layer structure used |
|---|
| 523 | | - * as part of the NVMET-FC processing. The LLDD is not to access |
|---|
| 524 | | - * this pointer. |
|---|
| 525 | | - */ |
|---|
| 526 | | -struct nvmefc_tgt_ls_req { |
|---|
| 527 | | - void *rspbuf; |
|---|
| 528 | | - dma_addr_t rspdma; |
|---|
| 529 | | - u16 rsplen; |
|---|
| 530 | | - |
|---|
| 531 | | - void (*done)(struct nvmefc_tgt_ls_req *req); |
|---|
| 532 | | - void *nvmet_fc_private; /* LLDD is not to access !! */ |
|---|
| 533 | | -}; |
|---|
| 534 | 592 | |
|---|
| 535 | 593 | /* Operations that NVME-FC layer may request the LLDD to perform for FCP */ |
|---|
| 536 | 594 | enum { |
|---|
| .. | .. |
|---|
| 614 | 672 | * Values set by the LLDD indicating completion status of the FCP operation. |
|---|
| 615 | 673 | * Must be set prior to calling the done() callback. |
|---|
| 616 | 674 | * @transferred_length: amount of DATA_OUT payload data received by a |
|---|
| 617 | | - * a WRITEDATA operation. If not a WRITEDATA operation, value must |
|---|
| 675 | + * WRITEDATA operation. If not a WRITEDATA operation, value must |
|---|
| 618 | 676 | * be set to 0. Should equal transfer_length on success. |
|---|
| 619 | 677 | * @fcp_error: status of the FCP operation. Must be 0 on success; on failure |
|---|
| 620 | 678 | * must be a NVME_SC_FC_xxxx value. |
|---|
| .. | .. |
|---|
| 648 | 706 | * sends (the last) Read Data sequence followed by the RSP |
|---|
| 649 | 707 | * sequence in one LLDD operation. Errors during Data |
|---|
| 650 | 708 | * sequence transmit must not allow RSP sequence to be sent. |
|---|
| 651 | | - */ |
|---|
| 652 | | - NVMET_FCTGTFEAT_CMD_IN_ISR = (1 << 1), |
|---|
| 653 | | - /* Bit 2: When 0, the LLDD is calling the cmd rcv handler |
|---|
| 654 | | - * in a non-isr context, allowing the transport to finish |
|---|
| 655 | | - * op completion in the calling context. When 1, the LLDD |
|---|
| 656 | | - * is calling the cmd rcv handler in an ISR context, |
|---|
| 657 | | - * requiring the transport to transition to a workqueue |
|---|
| 658 | | - * for op completion. |
|---|
| 659 | | - */ |
|---|
| 660 | | - NVMET_FCTGTFEAT_OPDONE_IN_ISR = (1 << 2), |
|---|
| 661 | | - /* Bit 3: When 0, the LLDD is calling the op done handler |
|---|
| 662 | | - * in a non-isr context, allowing the transport to finish |
|---|
| 663 | | - * op completion in the calling context. When 1, the LLDD |
|---|
| 664 | | - * is calling the op done handler in an ISR context, |
|---|
| 665 | | - * requiring the transport to transition to a workqueue |
|---|
| 666 | | - * for op completion. |
|---|
| 667 | 709 | */ |
|---|
| 668 | 710 | }; |
|---|
| 669 | 711 | |
|---|
| .. | .. |
|---|
| 722 | 764 | * Entrypoint is Mandatory. |
|---|
| 723 | 765 | * |
|---|
| 724 | 766 | * @xmt_ls_rsp: Called to transmit the response to a FC-NVME FC-4 LS service. |
|---|
| 725 | | - * The nvmefc_tgt_ls_req structure is the same LLDD-supplied exchange |
|---|
| 767 | + * The nvmefc_ls_rsp structure is the same LLDD-supplied exchange |
|---|
| 726 | 768 | * structure specified in the nvmet_fc_rcv_ls_req() call made when |
|---|
| 727 | | - * the LS request was received. The structure will fully describe |
|---|
| 769 | + * the LS request was received. The structure will fully describe |
|---|
| 728 | 770 | * the buffers for the response payload and the dma address of the |
|---|
| 729 | | - * payload. The LLDD is to transmit the response (or return a non-zero |
|---|
| 730 | | - * errno status), and upon completion of the transmit, call the |
|---|
| 731 | | - * "done" routine specified in the nvmefc_tgt_ls_req structure |
|---|
| 732 | | - * (argument to done is the ls reqwuest structure itself). |
|---|
| 733 | | - * After calling the done routine, the LLDD shall consider the |
|---|
| 734 | | - * LS handling complete and the nvmefc_tgt_ls_req structure may |
|---|
| 735 | | - * be freed/released. |
|---|
| 771 | + * payload. The LLDD is to transmit the response (or return a |
|---|
| 772 | + * non-zero errno status), and upon completion of the transmit, call |
|---|
| 773 | + * the "done" routine specified in the nvmefc_ls_rsp structure |
|---|
| 774 | + * (argument to done is the address of the nvmefc_ls_rsp structure |
|---|
| 775 | + * itself). Upon the completion of the done() routine, the LLDD shall |
|---|
| 776 | + * consider the LS handling complete and the nvmefc_ls_rsp structure |
|---|
| 777 | + * may be freed/released. |
|---|
| 778 | + * The transport will always call the xmt_ls_rsp() routine for any |
|---|
| 779 | + * LS received. |
|---|
| 736 | 780 | * Entrypoint is Mandatory. |
|---|
| 737 | 781 | * |
|---|
| 738 | 782 | * @fcp_op: Called to perform a data transfer or transmit a response. |
|---|
| .. | .. |
|---|
| 822 | 866 | * nvmefc_tgt_fcp_req. |
|---|
| 823 | 867 | * Entrypoint is Optional. |
|---|
| 824 | 868 | * |
|---|
| 869 | + * @discovery_event: Called by the transport to generate an RSCN |
|---|
| 870 | + * change notifications to NVME initiators. The RSCN notifications |
|---|
| 871 | + * should cause the initiator to rescan the discovery controller |
|---|
| 872 | + * on the targetport. |
|---|
| 873 | + * |
|---|
| 874 | + * @ls_req: Called to issue a FC-NVME FC-4 LS service request. |
|---|
| 875 | + * The nvme_fc_ls_req structure will fully describe the buffers for |
|---|
| 876 | + * the request payload and where to place the response payload. |
|---|
| 877 | + * The targetport that is to issue the LS request is identified by |
|---|
| 878 | + * the targetport argument. The remote port that is to receive the |
|---|
| 879 | + * LS request is identified by the hosthandle argument. The nvmet-fc |
|---|
| 880 | + * transport is only allowed to issue FC-NVME LS's on behalf of an |
|---|
| 881 | + * association that was created prior by a Create Association LS. |
|---|
| 882 | + * The hosthandle will originate from the LLDD in the struct |
|---|
| 883 | + * nvmefc_ls_rsp structure for the Create Association LS that |
|---|
| 884 | + * was delivered to the transport. The transport will save the |
|---|
| 885 | + * hosthandle as an attribute of the association. If the LLDD |
|---|
| 886 | + * loses connectivity with the remote port, it must call the |
|---|
| 887 | + * nvmet_fc_invalidate_host() routine to remove any references to |
|---|
| 888 | + * the remote port in the transport. |
|---|
| 889 | + * The LLDD is to allocate an exchange, issue the LS request, obtain |
|---|
| 890 | + * the LS response, and call the "done" routine specified in the |
|---|
| 891 | + * request structure (argument to done is the ls request structure |
|---|
| 892 | + * itself). |
|---|
| 893 | + * Entrypoint is Optional - but highly recommended. |
|---|
| 894 | + * |
|---|
| 895 | + * @ls_abort: called to request the LLDD to abort the indicated ls request. |
|---|
| 896 | + * The call may return before the abort has completed. After aborting |
|---|
| 897 | + * the request, the LLDD must still call the ls request done routine |
|---|
| 898 | + * indicating an FC transport Aborted status. |
|---|
| 899 | + * Entrypoint is Mandatory if the ls_req entry point is specified. |
|---|
| 900 | + * |
|---|
| 901 | + * @host_release: called to inform the LLDD that the request to invalidate |
|---|
| 902 | + * the host port indicated by the hosthandle has been fully completed. |
|---|
| 903 | + * No associations exist with the host port and there will be no |
|---|
| 904 | + * further references to hosthandle. |
|---|
| 905 | + * Entrypoint is Mandatory if the lldd calls nvmet_fc_invalidate_host(). |
|---|
| 906 | + * |
|---|
| 825 | 907 | * @max_hw_queues: indicates the maximum number of hw queues the LLDD |
|---|
| 826 | 908 | * supports for cpu affinitization. |
|---|
| 827 | 909 | * Value is Mandatory. Must be at least 1. |
|---|
| .. | .. |
|---|
| 850 | 932 | * area solely for the of the LLDD and its location is specified by |
|---|
| 851 | 933 | * the targetport->private pointer. |
|---|
| 852 | 934 | * Value is Mandatory. Allowed to be zero. |
|---|
| 935 | + * |
|---|
| 936 | + * @lsrqst_priv_sz: The LLDD sets this field to the amount of additional |
|---|
| 937 | + * memory that it would like nvmet-fc layer to allocate on the LLDD's |
|---|
| 938 | + * behalf whenever a ls request structure is allocated. The additional |
|---|
| 939 | + * memory area is solely for use by the LLDD and its location is |
|---|
| 940 | + * specified by the ls_request->private pointer. |
|---|
| 941 | + * Value is Mandatory. Allowed to be zero. |
|---|
| 942 | + * |
|---|
| 853 | 943 | */ |
|---|
| 854 | 944 | struct nvmet_fc_target_template { |
|---|
| 855 | 945 | void (*targetport_delete)(struct nvmet_fc_target_port *tgtport); |
|---|
| 856 | 946 | int (*xmt_ls_rsp)(struct nvmet_fc_target_port *tgtport, |
|---|
| 857 | | - struct nvmefc_tgt_ls_req *tls_req); |
|---|
| 947 | + struct nvmefc_ls_rsp *ls_rsp); |
|---|
| 858 | 948 | int (*fcp_op)(struct nvmet_fc_target_port *tgtport, |
|---|
| 859 | 949 | struct nvmefc_tgt_fcp_req *fcpreq); |
|---|
| 860 | 950 | void (*fcp_abort)(struct nvmet_fc_target_port *tgtport, |
|---|
| .. | .. |
|---|
| 863 | 953 | struct nvmefc_tgt_fcp_req *fcpreq); |
|---|
| 864 | 954 | void (*defer_rcv)(struct nvmet_fc_target_port *tgtport, |
|---|
| 865 | 955 | struct nvmefc_tgt_fcp_req *fcpreq); |
|---|
| 956 | + void (*discovery_event)(struct nvmet_fc_target_port *tgtport); |
|---|
| 957 | + int (*ls_req)(struct nvmet_fc_target_port *targetport, |
|---|
| 958 | + void *hosthandle, struct nvmefc_ls_req *lsreq); |
|---|
| 959 | + void (*ls_abort)(struct nvmet_fc_target_port *targetport, |
|---|
| 960 | + void *hosthandle, struct nvmefc_ls_req *lsreq); |
|---|
| 961 | + void (*host_release)(void *hosthandle); |
|---|
| 866 | 962 | |
|---|
| 867 | 963 | u32 max_hw_queues; |
|---|
| 868 | 964 | u16 max_sgl_segments; |
|---|
| .. | .. |
|---|
| 871 | 967 | |
|---|
| 872 | 968 | u32 target_features; |
|---|
| 873 | 969 | |
|---|
| 970 | + /* sizes of additional private data for data structures */ |
|---|
| 874 | 971 | u32 target_priv_sz; |
|---|
| 972 | + u32 lsrqst_priv_sz; |
|---|
| 875 | 973 | }; |
|---|
| 876 | 974 | |
|---|
| 877 | 975 | |
|---|
| .. | .. |
|---|
| 882 | 980 | |
|---|
| 883 | 981 | int nvmet_fc_unregister_targetport(struct nvmet_fc_target_port *tgtport); |
|---|
| 884 | 982 | |
|---|
| 983 | +/* |
|---|
| 984 | + * Routine called to pass a NVME-FC LS request, received by the lldd, |
|---|
| 985 | + * to the nvmet-fc transport. |
|---|
| 986 | + * |
|---|
| 987 | + * If the return value is zero: the LS was successfully accepted by the |
|---|
| 988 | + * transport. |
|---|
| 989 | + * If the return value is non-zero: the transport has not accepted the |
|---|
| 990 | + * LS. The lldd should ABTS-LS the LS. |
|---|
| 991 | + * |
|---|
| 992 | + * Note: if the LLDD receives and ABTS for the LS prior to the transport |
|---|
| 993 | + * calling the ops->xmt_ls_rsp() routine to transmit a response, the LLDD |
|---|
| 994 | + * shall mark the LS as aborted, and when the xmt_ls_rsp() is called: the |
|---|
| 995 | + * response shall not be transmit and the struct nvmefc_ls_rsp() done |
|---|
| 996 | + * routine shall be called. The LLDD may transmit the ABTS response as |
|---|
| 997 | + * soon as the LS was marked or can delay until the xmt_ls_rsp() call is |
|---|
| 998 | + * made. |
|---|
| 999 | + * Note: if an RCV LS was successfully posted to the transport and the |
|---|
| 1000 | + * targetport is then unregistered before xmt_ls_rsp() was called for |
|---|
| 1001 | + * the lsrsp structure, the transport will still call xmt_ls_rsp() |
|---|
| 1002 | + * afterward to cleanup the outstanding lsrsp structure. The LLDD should |
|---|
| 1003 | + * noop the transmission of the rsp and call the lsrsp->done() routine |
|---|
| 1004 | + * to allow the lsrsp structure to be released. |
|---|
| 1005 | + */ |
|---|
| 885 | 1006 | int nvmet_fc_rcv_ls_req(struct nvmet_fc_target_port *tgtport, |
|---|
| 886 | | - struct nvmefc_tgt_ls_req *lsreq, |
|---|
| 1007 | + void *hosthandle, |
|---|
| 1008 | + struct nvmefc_ls_rsp *rsp, |
|---|
| 887 | 1009 | void *lsreqbuf, u32 lsreqbuf_len); |
|---|
| 888 | 1010 | |
|---|
| 1011 | +/* |
|---|
| 1012 | + * Routine called by the LLDD whenever it has a logout or loss of |
|---|
| 1013 | + * connectivity to a NVME-FC host port which there had been active |
|---|
| 1014 | + * NVMe controllers for. The host port is indicated by the |
|---|
| 1015 | + * hosthandle. The hosthandle is given to the nvmet-fc transport |
|---|
| 1016 | + * when a NVME LS was received, typically to create a new association. |
|---|
| 1017 | + * The nvmet-fc transport will cache the hostport value with the |
|---|
| 1018 | + * association for use in LS requests for the association. |
|---|
| 1019 | + * When the LLDD calls this routine, the nvmet-fc transport will |
|---|
| 1020 | + * immediately terminate all associations that were created with |
|---|
| 1021 | + * the hosthandle host port. |
|---|
| 1022 | + * The LLDD, after calling this routine and having control returned, |
|---|
| 1023 | + * must assume the transport may subsequently utilize hosthandle as |
|---|
| 1024 | + * part of sending LS's to terminate the association. The LLDD |
|---|
| 1025 | + * should reject the LS's if they are attempted. |
|---|
| 1026 | + * Once the last association has terminated for the hosthandle host |
|---|
| 1027 | + * port, the nvmet-fc transport will call the ops->host_release() |
|---|
| 1028 | + * callback. As of the callback, the nvmet-fc transport will no |
|---|
| 1029 | + * longer reference hosthandle. |
|---|
| 1030 | + */ |
|---|
| 1031 | +void nvmet_fc_invalidate_host(struct nvmet_fc_target_port *tgtport, |
|---|
| 1032 | + void *hosthandle); |
|---|
| 1033 | + |
|---|
| 1034 | +/* |
|---|
| 1035 | + * If nvmet_fc_rcv_fcp_req returns non-zero, the transport has not accepted |
|---|
| 1036 | + * the FCP cmd. The lldd should ABTS-LS the cmd. |
|---|
| 1037 | + */ |
|---|
| 889 | 1038 | int nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *tgtport, |
|---|
| 890 | 1039 | struct nvmefc_tgt_fcp_req *fcpreq, |
|---|
| 891 | 1040 | void *cmdiubuf, u32 cmdiubuf_len); |
|---|