1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 2016, Avago Technologies 4*4882a593Smuzhiyun */ 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun #ifndef _NVME_FC_DRIVER_H 7*4882a593Smuzhiyun #define _NVME_FC_DRIVER_H 1 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #include <linux/scatterlist.h> 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun /* 13*4882a593Smuzhiyun * ********************** FC-NVME LS API ******************** 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * Data structures used by both FC-NVME hosts and FC-NVME 16*4882a593Smuzhiyun * targets to perform FC-NVME LS requests or transmit 17*4882a593Smuzhiyun * responses. 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * *********************************************************** 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /** 23*4882a593Smuzhiyun * struct nvmefc_ls_req - Request structure passed from the transport 24*4882a593Smuzhiyun * to the LLDD to perform a NVME-FC LS request and obtain 25*4882a593Smuzhiyun * a response. 26*4882a593Smuzhiyun * Used by nvme-fc transport (host) to send LS's such as 27*4882a593Smuzhiyun * Create Association, Create Connection and Disconnect 28*4882a593Smuzhiyun * Association. 29*4882a593Smuzhiyun * Used by the nvmet-fc transport (controller) to send 30*4882a593Smuzhiyun * LS's such as Disconnect Association. 31*4882a593Smuzhiyun * 32*4882a593Smuzhiyun * Values set by the requestor prior to calling the LLDD ls_req entrypoint: 33*4882a593Smuzhiyun * @rqstaddr: pointer to request buffer 34*4882a593Smuzhiyun * @rqstdma: PCI DMA address of request buffer 35*4882a593Smuzhiyun * @rqstlen: Length, in bytes, of request buffer 36*4882a593Smuzhiyun * @rspaddr: pointer to response buffer 37*4882a593Smuzhiyun * @rspdma: PCI DMA address of response buffer 38*4882a593Smuzhiyun * @rsplen: Length, in bytes, of response buffer 39*4882a593Smuzhiyun * @timeout: Maximum amount of time, in seconds, to wait for the LS response. 40*4882a593Smuzhiyun * If timeout exceeded, LLDD to abort LS exchange and complete 41*4882a593Smuzhiyun * LS request with error status. 42*4882a593Smuzhiyun * @private: pointer to memory allocated alongside the ls request structure 43*4882a593Smuzhiyun * that is specifically for the LLDD to use while processing the 44*4882a593Smuzhiyun * request. The length of the buffer corresponds to the 45*4882a593Smuzhiyun * lsrqst_priv_sz value specified in the xxx_template supplied 46*4882a593Smuzhiyun * by the LLDD. 47*4882a593Smuzhiyun * @done: The callback routine the LLDD is to invoke upon completion of 48*4882a593Smuzhiyun * the LS request. req argument is the pointer to the original LS 49*4882a593Smuzhiyun * request structure. Status argument must be 0 upon success, a 50*4882a593Smuzhiyun * negative errno on failure (example: -ENXIO). 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun struct nvmefc_ls_req { 53*4882a593Smuzhiyun void *rqstaddr; 54*4882a593Smuzhiyun dma_addr_t rqstdma; 55*4882a593Smuzhiyun u32 rqstlen; 56*4882a593Smuzhiyun void *rspaddr; 57*4882a593Smuzhiyun dma_addr_t rspdma; 58*4882a593Smuzhiyun u32 rsplen; 59*4882a593Smuzhiyun u32 timeout; 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun void *private; 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun void (*done)(struct nvmefc_ls_req *req, int status); 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun } __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun /** 69*4882a593Smuzhiyun * struct nvmefc_ls_rsp - Structure passed from the transport to the LLDD 70*4882a593Smuzhiyun * to request the transmit the NVME-FC LS response to a 71*4882a593Smuzhiyun * NVME-FC LS request. The structure originates in the LLDD 72*4882a593Smuzhiyun * and is given to the transport via the xxx_rcv_ls_req() 73*4882a593Smuzhiyun * transport routine. As such, the structure represents the 74*4882a593Smuzhiyun * FC exchange context for the NVME-FC LS request that was 75*4882a593Smuzhiyun * received and which the response is to be sent for. 76*4882a593Smuzhiyun * Used by the LLDD to pass the nvmet-fc transport (controller) 77*4882a593Smuzhiyun * received LS's such as Create Association, Create Connection 78*4882a593Smuzhiyun * and Disconnect Association. 79*4882a593Smuzhiyun * Used by the LLDD to pass the nvme-fc transport (host) 80*4882a593Smuzhiyun * received LS's such as Disconnect Association or Disconnect 81*4882a593Smuzhiyun * Connection. 82*4882a593Smuzhiyun * 83*4882a593Smuzhiyun * The structure is allocated by the LLDD whenever a LS Request is received 84*4882a593Smuzhiyun * from the FC link. The address of the structure is passed to the nvmet-fc 85*4882a593Smuzhiyun * or nvme-fc layer via the xxx_rcv_ls_req() transport routines. 86*4882a593Smuzhiyun * 87*4882a593Smuzhiyun * The address of the structure is to be passed back to the LLDD 88*4882a593Smuzhiyun * when the response is to be transmit. The LLDD will use the address to 89*4882a593Smuzhiyun * map back to the LLDD exchange structure which maintains information such 90*4882a593Smuzhiyun * the remote N_Port that sent the LS as well as any FC exchange context. 91*4882a593Smuzhiyun * Upon completion of the LS response transmit, the LLDD will pass the 92*4882a593Smuzhiyun * address of the structure back to the transport LS rsp done() routine, 93*4882a593Smuzhiyun * allowing the transport release dma resources. Upon completion of 94*4882a593Smuzhiyun * the done() routine, no further access to the structure will be made by 95*4882a593Smuzhiyun * the transport and the LLDD can de-allocate the structure. 96*4882a593Smuzhiyun * 97*4882a593Smuzhiyun * Field initialization: 98*4882a593Smuzhiyun * At the time of the xxx_rcv_ls_req() call, there is no content that 99*4882a593Smuzhiyun * is valid in the structure. 100*4882a593Smuzhiyun * 101*4882a593Smuzhiyun * When the structure is used for the LLDD->xmt_ls_rsp() call, the 102*4882a593Smuzhiyun * transport layer will fully set the fields in order to specify the 103*4882a593Smuzhiyun * response payload buffer and its length as well as the done routine 104*4882a593Smuzhiyun * to be called upon completion of the transmit. The transport layer 105*4882a593Smuzhiyun * will also set a private pointer for its own use in the done routine. 106*4882a593Smuzhiyun * 107*4882a593Smuzhiyun * Values set by the transport layer prior to calling the LLDD xmt_ls_rsp 108*4882a593Smuzhiyun * entrypoint: 109*4882a593Smuzhiyun * @rspbuf: pointer to the LS response buffer 110*4882a593Smuzhiyun * @rspdma: PCI DMA address of the LS response buffer 111*4882a593Smuzhiyun * @rsplen: Length, in bytes, of the LS response buffer 112*4882a593Smuzhiyun * @done: The callback routine the LLDD is to invoke upon completion of 113*4882a593Smuzhiyun * transmitting the LS response. req argument is the pointer to 114*4882a593Smuzhiyun * the original ls request. 115*4882a593Smuzhiyun * @nvme_fc_private: pointer to an internal transport-specific structure 116*4882a593Smuzhiyun * used as part of the transport done() processing. The LLDD is 117*4882a593Smuzhiyun * not to access this pointer. 118*4882a593Smuzhiyun */ 119*4882a593Smuzhiyun struct nvmefc_ls_rsp { 120*4882a593Smuzhiyun void *rspbuf; 121*4882a593Smuzhiyun dma_addr_t rspdma; 122*4882a593Smuzhiyun u16 rsplen; 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun void (*done)(struct nvmefc_ls_rsp *rsp); 125*4882a593Smuzhiyun void *nvme_fc_private; /* LLDD is not to access !! */ 126*4882a593Smuzhiyun }; 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /* 131*4882a593Smuzhiyun * ********************** LLDD FC-NVME Host API ******************** 132*4882a593Smuzhiyun * 133*4882a593Smuzhiyun * For FC LLDD's that are the NVME Host role. 134*4882a593Smuzhiyun * 135*4882a593Smuzhiyun * ****************************************************************** 136*4882a593Smuzhiyun */ 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun /** 140*4882a593Smuzhiyun * struct nvme_fc_port_info - port-specific ids and FC connection-specific 141*4882a593Smuzhiyun * data element used during NVME Host role 142*4882a593Smuzhiyun * registrations 143*4882a593Smuzhiyun * 144*4882a593Smuzhiyun * Static fields describing the port being registered: 145*4882a593Smuzhiyun * @node_name: FC WWNN for the port 146*4882a593Smuzhiyun * @port_name: FC WWPN for the port 147*4882a593Smuzhiyun * @port_role: What NVME roles are supported (see FC_PORT_ROLE_xxx) 148*4882a593Smuzhiyun * @dev_loss_tmo: maximum delay for reconnects to an association on 149*4882a593Smuzhiyun * this device. Used only on a remoteport. 150*4882a593Smuzhiyun * 151*4882a593Smuzhiyun * Initialization values for dynamic port fields: 152*4882a593Smuzhiyun * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must 153*4882a593Smuzhiyun * be set to 0. 154*4882a593Smuzhiyun */ 155*4882a593Smuzhiyun struct nvme_fc_port_info { 156*4882a593Smuzhiyun u64 node_name; 157*4882a593Smuzhiyun u64 port_name; 158*4882a593Smuzhiyun u32 port_role; 159*4882a593Smuzhiyun u32 port_id; 160*4882a593Smuzhiyun u32 dev_loss_tmo; 161*4882a593Smuzhiyun }; 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun enum nvmefc_fcp_datadir { 164*4882a593Smuzhiyun NVMEFC_FCP_NODATA, /* payload_length and sg_cnt will be zero */ 165*4882a593Smuzhiyun NVMEFC_FCP_WRITE, 166*4882a593Smuzhiyun NVMEFC_FCP_READ, 167*4882a593Smuzhiyun }; 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun /** 171*4882a593Smuzhiyun * struct nvmefc_fcp_req - Request structure passed from NVME-FC transport 172*4882a593Smuzhiyun * to LLDD in order to perform a NVME FCP IO operation. 173*4882a593Smuzhiyun * 174*4882a593Smuzhiyun * Values set by the NVME-FC layer prior to calling the LLDD fcp_io 175*4882a593Smuzhiyun * entrypoint. 176*4882a593Smuzhiyun * @cmdaddr: pointer to the FCP CMD IU buffer 177*4882a593Smuzhiyun * @rspaddr: pointer to the FCP RSP IU buffer 178*4882a593Smuzhiyun * @cmddma: PCI DMA address of the FCP CMD IU buffer 179*4882a593Smuzhiyun * @rspdma: PCI DMA address of the FCP RSP IU buffer 180*4882a593Smuzhiyun * @cmdlen: Length, in bytes, of the FCP CMD IU buffer 181*4882a593Smuzhiyun * @rsplen: Length, in bytes, of the FCP RSP IU buffer 182*4882a593Smuzhiyun * @payload_length: Length of DATA_IN or DATA_OUT payload data to transfer 183*4882a593Smuzhiyun * @sg_table: scatter/gather structure for payload data 184*4882a593Smuzhiyun * @first_sgl: memory for 1st scatter/gather list segment for payload data 185*4882a593Smuzhiyun * @sg_cnt: number of elements in the scatter/gather list 186*4882a593Smuzhiyun * @io_dir: direction of the FCP request (see NVMEFC_FCP_xxx) 187*4882a593Smuzhiyun * @sqid: The nvme SQID the command is being issued on 188*4882a593Smuzhiyun * @done: The callback routine the LLDD is to invoke upon completion of 189*4882a593Smuzhiyun * the FCP operation. req argument is the pointer to the original 190*4882a593Smuzhiyun * FCP IO operation. 191*4882a593Smuzhiyun * @private: pointer to memory allocated alongside the FCP operation 192*4882a593Smuzhiyun * request structure that is specifically for the LLDD to use 193*4882a593Smuzhiyun * while processing the operation. The length of the buffer 194*4882a593Smuzhiyun * corresponds to the fcprqst_priv_sz value specified in the 195*4882a593Smuzhiyun * nvme_fc_port_template supplied by the LLDD. 196*4882a593Smuzhiyun * 197*4882a593Smuzhiyun * Values set by the LLDD indicating completion status of the FCP operation. 198*4882a593Smuzhiyun * Must be set prior to calling the done() callback. 199*4882a593Smuzhiyun * @transferred_length: amount of payload data, in bytes, that were 200*4882a593Smuzhiyun * transferred. Should equal payload_length on success. 201*4882a593Smuzhiyun * @rcv_rsplen: length, in bytes, of the FCP RSP IU received. 202*4882a593Smuzhiyun * @status: Completion status of the FCP operation. must be 0 upon success, 203*4882a593Smuzhiyun * negative errno value upon failure (ex: -EIO). Note: this is 204*4882a593Smuzhiyun * NOT a reflection of the NVME CQE completion status. Only the 205*4882a593Smuzhiyun * status of the FCP operation at the NVME-FC level. 206*4882a593Smuzhiyun */ 207*4882a593Smuzhiyun struct nvmefc_fcp_req { 208*4882a593Smuzhiyun void *cmdaddr; 209*4882a593Smuzhiyun void *rspaddr; 210*4882a593Smuzhiyun dma_addr_t cmddma; 211*4882a593Smuzhiyun dma_addr_t rspdma; 212*4882a593Smuzhiyun u16 cmdlen; 213*4882a593Smuzhiyun u16 rsplen; 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun u32 payload_length; 216*4882a593Smuzhiyun struct sg_table sg_table; 217*4882a593Smuzhiyun struct scatterlist *first_sgl; 218*4882a593Smuzhiyun int sg_cnt; 219*4882a593Smuzhiyun enum nvmefc_fcp_datadir io_dir; 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun __le16 sqid; 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun void (*done)(struct nvmefc_fcp_req *req); 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun void *private; 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun u32 transferred_length; 228*4882a593Smuzhiyun u16 rcv_rsplen; 229*4882a593Smuzhiyun u32 status; 230*4882a593Smuzhiyun } __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun 233*4882a593Smuzhiyun /* 234*4882a593Smuzhiyun * Direct copy of fc_port_state enum. For later merging 235*4882a593Smuzhiyun */ 236*4882a593Smuzhiyun enum nvme_fc_obj_state { 237*4882a593Smuzhiyun FC_OBJSTATE_UNKNOWN, 238*4882a593Smuzhiyun FC_OBJSTATE_NOTPRESENT, 239*4882a593Smuzhiyun FC_OBJSTATE_ONLINE, 240*4882a593Smuzhiyun FC_OBJSTATE_OFFLINE, /* User has taken Port Offline */ 241*4882a593Smuzhiyun FC_OBJSTATE_BLOCKED, 242*4882a593Smuzhiyun FC_OBJSTATE_BYPASSED, 243*4882a593Smuzhiyun FC_OBJSTATE_DIAGNOSTICS, 244*4882a593Smuzhiyun FC_OBJSTATE_LINKDOWN, 245*4882a593Smuzhiyun FC_OBJSTATE_ERROR, 246*4882a593Smuzhiyun FC_OBJSTATE_LOOPBACK, 247*4882a593Smuzhiyun FC_OBJSTATE_DELETED, 248*4882a593Smuzhiyun }; 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun /** 252*4882a593Smuzhiyun * struct nvme_fc_local_port - structure used between NVME-FC transport and 253*4882a593Smuzhiyun * a LLDD to reference a local NVME host port. 254*4882a593Smuzhiyun * Allocated/created by the nvme_fc_register_localport() 255*4882a593Smuzhiyun * transport interface. 256*4882a593Smuzhiyun * 257*4882a593Smuzhiyun * Fields with static values for the port. Initialized by the 258*4882a593Smuzhiyun * port_info struct supplied to the registration call. 259*4882a593Smuzhiyun * @port_num: NVME-FC transport host port number 260*4882a593Smuzhiyun * @port_role: NVME roles are supported on the port (see FC_PORT_ROLE_xxx) 261*4882a593Smuzhiyun * @node_name: FC WWNN for the port 262*4882a593Smuzhiyun * @port_name: FC WWPN for the port 263*4882a593Smuzhiyun * @private: pointer to memory allocated alongside the local port 264*4882a593Smuzhiyun * structure that is specifically for the LLDD to use. 265*4882a593Smuzhiyun * The length of the buffer corresponds to the local_priv_sz 266*4882a593Smuzhiyun * value specified in the nvme_fc_port_template supplied by 267*4882a593Smuzhiyun * the LLDD. 268*4882a593Smuzhiyun * @dev_loss_tmo: maximum delay for reconnects to an association on 269*4882a593Smuzhiyun * this device. To modify, lldd must call 270*4882a593Smuzhiyun * nvme_fc_set_remoteport_devloss(). 271*4882a593Smuzhiyun * 272*4882a593Smuzhiyun * Fields with dynamic values. Values may change base on link state. LLDD 273*4882a593Smuzhiyun * may reference fields directly to change them. Initialized by the 274*4882a593Smuzhiyun * port_info struct supplied to the registration call. 275*4882a593Smuzhiyun * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must 276*4882a593Smuzhiyun * be set to 0. 277*4882a593Smuzhiyun * @port_state: Operational state of the port. 278*4882a593Smuzhiyun */ 279*4882a593Smuzhiyun struct nvme_fc_local_port { 280*4882a593Smuzhiyun /* static/read-only fields */ 281*4882a593Smuzhiyun u32 port_num; 282*4882a593Smuzhiyun u32 port_role; 283*4882a593Smuzhiyun u64 node_name; 284*4882a593Smuzhiyun u64 port_name; 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun void *private; 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun /* dynamic fields */ 289*4882a593Smuzhiyun u32 port_id; 290*4882a593Smuzhiyun enum nvme_fc_obj_state port_state; 291*4882a593Smuzhiyun } __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ 292*4882a593Smuzhiyun 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun /** 295*4882a593Smuzhiyun * struct nvme_fc_remote_port - structure used between NVME-FC transport and 296*4882a593Smuzhiyun * a LLDD to reference a remote NVME subsystem port. 297*4882a593Smuzhiyun * Allocated/created by the nvme_fc_register_remoteport() 298*4882a593Smuzhiyun * transport interface. 299*4882a593Smuzhiyun * 300*4882a593Smuzhiyun * Fields with static values for the port. Initialized by the 301*4882a593Smuzhiyun * port_info struct supplied to the registration call. 302*4882a593Smuzhiyun * @port_num: NVME-FC transport remote subsystem port number 303*4882a593Smuzhiyun * @port_role: NVME roles are supported on the port (see FC_PORT_ROLE_xxx) 304*4882a593Smuzhiyun * @node_name: FC WWNN for the port 305*4882a593Smuzhiyun * @port_name: FC WWPN for the port 306*4882a593Smuzhiyun * @localport: pointer to the NVME-FC local host port the subsystem is 307*4882a593Smuzhiyun * connected to. 308*4882a593Smuzhiyun * @private: pointer to memory allocated alongside the remote port 309*4882a593Smuzhiyun * structure that is specifically for the LLDD to use. 310*4882a593Smuzhiyun * The length of the buffer corresponds to the remote_priv_sz 311*4882a593Smuzhiyun * value specified in the nvme_fc_port_template supplied by 312*4882a593Smuzhiyun * the LLDD. 313*4882a593Smuzhiyun * 314*4882a593Smuzhiyun * Fields with dynamic values. Values may change base on link or login 315*4882a593Smuzhiyun * state. LLDD may reference fields directly to change them. Initialized by 316*4882a593Smuzhiyun * the port_info struct supplied to the registration call. 317*4882a593Smuzhiyun * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must 318*4882a593Smuzhiyun * be set to 0. 319*4882a593Smuzhiyun * @port_state: Operational state of the remote port. Valid values are 320*4882a593Smuzhiyun * ONLINE or UNKNOWN. 321*4882a593Smuzhiyun */ 322*4882a593Smuzhiyun struct nvme_fc_remote_port { 323*4882a593Smuzhiyun /* static fields */ 324*4882a593Smuzhiyun u32 port_num; 325*4882a593Smuzhiyun u32 port_role; 326*4882a593Smuzhiyun u64 node_name; 327*4882a593Smuzhiyun u64 port_name; 328*4882a593Smuzhiyun struct nvme_fc_local_port *localport; 329*4882a593Smuzhiyun void *private; 330*4882a593Smuzhiyun u32 dev_loss_tmo; 331*4882a593Smuzhiyun 332*4882a593Smuzhiyun /* dynamic fields */ 333*4882a593Smuzhiyun u32 port_id; 334*4882a593Smuzhiyun enum nvme_fc_obj_state port_state; 335*4882a593Smuzhiyun } __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun 338*4882a593Smuzhiyun /** 339*4882a593Smuzhiyun * struct nvme_fc_port_template - structure containing static entrypoints and 340*4882a593Smuzhiyun * operational parameters for an LLDD that supports NVME host 341*4882a593Smuzhiyun * behavior. Passed by reference in port registrations. 342*4882a593Smuzhiyun * NVME-FC transport remembers template reference and may 343*4882a593Smuzhiyun * access it during runtime operation. 344*4882a593Smuzhiyun * 345*4882a593Smuzhiyun * Host/Initiator Transport Entrypoints/Parameters: 346*4882a593Smuzhiyun * 347*4882a593Smuzhiyun * @localport_delete: The LLDD initiates deletion of a localport via 348*4882a593Smuzhiyun * nvme_fc_deregister_localport(). However, the teardown is 349*4882a593Smuzhiyun * asynchronous. This routine is called upon the completion of the 350*4882a593Smuzhiyun * teardown to inform the LLDD that the localport has been deleted. 351*4882a593Smuzhiyun * Entrypoint is Mandatory. 352*4882a593Smuzhiyun * 353*4882a593Smuzhiyun * @remoteport_delete: The LLDD initiates deletion of a remoteport via 354*4882a593Smuzhiyun * nvme_fc_deregister_remoteport(). However, the teardown is 355*4882a593Smuzhiyun * asynchronous. This routine is called upon the completion of the 356*4882a593Smuzhiyun * teardown to inform the LLDD that the remoteport has been deleted. 357*4882a593Smuzhiyun * Entrypoint is Mandatory. 358*4882a593Smuzhiyun * 359*4882a593Smuzhiyun * @create_queue: Upon creating a host<->controller association, queues are 360*4882a593Smuzhiyun * created such that they can be affinitized to cpus/cores. This 361*4882a593Smuzhiyun * callback into the LLDD to notify that a controller queue is being 362*4882a593Smuzhiyun * created. The LLDD may choose to allocate an associated hw queue 363*4882a593Smuzhiyun * or map it onto a shared hw queue. Upon return from the call, the 364*4882a593Smuzhiyun * LLDD specifies a handle that will be given back to it for any 365*4882a593Smuzhiyun * command that is posted to the controller queue. The handle can 366*4882a593Smuzhiyun * be used by the LLDD to map quickly to the proper hw queue for 367*4882a593Smuzhiyun * command execution. The mask of cpu's that will map to this queue 368*4882a593Smuzhiyun * at the block-level is also passed in. The LLDD should use the 369*4882a593Smuzhiyun * queue id and/or cpu masks to ensure proper affinitization of the 370*4882a593Smuzhiyun * controller queue to the hw queue. 371*4882a593Smuzhiyun * Entrypoint is Optional. 372*4882a593Smuzhiyun * 373*4882a593Smuzhiyun * @delete_queue: This is the inverse of the crete_queue. During 374*4882a593Smuzhiyun * host<->controller association teardown, this routine is called 375*4882a593Smuzhiyun * when a controller queue is being terminated. Any association with 376*4882a593Smuzhiyun * a hw queue should be termined. If there is a unique hw queue, the 377*4882a593Smuzhiyun * hw queue should be torn down. 378*4882a593Smuzhiyun * Entrypoint is Optional. 379*4882a593Smuzhiyun * 380*4882a593Smuzhiyun * @poll_queue: Called to poll for the completion of an io on a blk queue. 381*4882a593Smuzhiyun * Entrypoint is Optional. 382*4882a593Smuzhiyun * 383*4882a593Smuzhiyun * @ls_req: Called to issue a FC-NVME FC-4 LS service request. 384*4882a593Smuzhiyun * The nvme_fc_ls_req structure will fully describe the buffers for 385*4882a593Smuzhiyun * the request payload and where to place the response payload. The 386*4882a593Smuzhiyun * LLDD is to allocate an exchange, issue the LS request, obtain the 387*4882a593Smuzhiyun * LS response, and call the "done" routine specified in the request 388*4882a593Smuzhiyun * structure (argument to done is the ls request structure itself). 389*4882a593Smuzhiyun * Entrypoint is Mandatory. 390*4882a593Smuzhiyun * 391*4882a593Smuzhiyun * @fcp_io: called to issue a FC-NVME I/O request. The I/O may be for 392*4882a593Smuzhiyun * an admin queue or an i/o queue. The nvmefc_fcp_req structure will 393*4882a593Smuzhiyun * fully describe the io: the buffer containing the FC-NVME CMD IU 394*4882a593Smuzhiyun * (which contains the SQE), the sg list for the payload if applicable, 395*4882a593Smuzhiyun * and the buffer to place the FC-NVME RSP IU into. The LLDD will 396*4882a593Smuzhiyun * complete the i/o, indicating the amount of data transferred or 397*4882a593Smuzhiyun * any transport error, and call the "done" routine specified in the 398*4882a593Smuzhiyun * request structure (argument to done is the fcp request structure 399*4882a593Smuzhiyun * itself). 400*4882a593Smuzhiyun * Entrypoint is Mandatory. 401*4882a593Smuzhiyun * 402*4882a593Smuzhiyun * @ls_abort: called to request the LLDD to abort the indicated ls request. 403*4882a593Smuzhiyun * The call may return before the abort has completed. After aborting 404*4882a593Smuzhiyun * the request, the LLDD must still call the ls request done routine 405*4882a593Smuzhiyun * indicating an FC transport Aborted status. 406*4882a593Smuzhiyun * Entrypoint is Mandatory. 407*4882a593Smuzhiyun * 408*4882a593Smuzhiyun * @fcp_abort: called to request the LLDD to abort the indicated fcp request. 409*4882a593Smuzhiyun * The call may return before the abort has completed. After aborting 410*4882a593Smuzhiyun * the request, the LLDD must still call the fcp request done routine 411*4882a593Smuzhiyun * indicating an FC transport Aborted status. 412*4882a593Smuzhiyun * Entrypoint is Mandatory. 413*4882a593Smuzhiyun * 414*4882a593Smuzhiyun * @xmt_ls_rsp: Called to transmit the response to a FC-NVME FC-4 LS service. 415*4882a593Smuzhiyun * The nvmefc_ls_rsp structure is the same LLDD-supplied exchange 416*4882a593Smuzhiyun * structure specified in the nvme_fc_rcv_ls_req() call made when 417*4882a593Smuzhiyun * the LS request was received. The structure will fully describe 418*4882a593Smuzhiyun * the buffers for the response payload and the dma address of the 419*4882a593Smuzhiyun * payload. The LLDD is to transmit the response (or return a 420*4882a593Smuzhiyun * non-zero errno status), and upon completion of the transmit, call 421*4882a593Smuzhiyun * the "done" routine specified in the nvmefc_ls_rsp structure 422*4882a593Smuzhiyun * (argument to done is the address of the nvmefc_ls_rsp structure 423*4882a593Smuzhiyun * itself). Upon the completion of the done routine, the LLDD shall 424*4882a593Smuzhiyun * consider the LS handling complete and the nvmefc_ls_rsp structure 425*4882a593Smuzhiyun * may be freed/released. 426*4882a593Smuzhiyun * Entrypoint is mandatory if the LLDD calls the nvme_fc_rcv_ls_req() 427*4882a593Smuzhiyun * entrypoint. 428*4882a593Smuzhiyun * 429*4882a593Smuzhiyun * @max_hw_queues: indicates the maximum number of hw queues the LLDD 430*4882a593Smuzhiyun * supports for cpu affinitization. 431*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. 432*4882a593Smuzhiyun * 433*4882a593Smuzhiyun * @max_sgl_segments: indicates the maximum number of sgl segments supported 434*4882a593Smuzhiyun * by the LLDD 435*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. Recommend at least 256. 436*4882a593Smuzhiyun * 437*4882a593Smuzhiyun * @max_dif_sgl_segments: indicates the maximum number of sgl segments 438*4882a593Smuzhiyun * supported by the LLDD for DIF operations. 439*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. Recommend at least 256. 440*4882a593Smuzhiyun * 441*4882a593Smuzhiyun * @dma_boundary: indicates the dma address boundary where dma mappings 442*4882a593Smuzhiyun * will be split across. 443*4882a593Smuzhiyun * Value is Mandatory. Typical value is 0xFFFFFFFF to split across 444*4882a593Smuzhiyun * 4Gig address boundarys 445*4882a593Smuzhiyun * 446*4882a593Smuzhiyun * @local_priv_sz: The LLDD sets this field to the amount of additional 447*4882a593Smuzhiyun * memory that it would like fc nvme layer to allocate on the LLDD's 448*4882a593Smuzhiyun * behalf whenever a localport is allocated. The additional memory 449*4882a593Smuzhiyun * area solely for the of the LLDD and its location is specified by 450*4882a593Smuzhiyun * the localport->private pointer. 451*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 452*4882a593Smuzhiyun * 453*4882a593Smuzhiyun * @remote_priv_sz: The LLDD sets this field to the amount of additional 454*4882a593Smuzhiyun * memory that it would like fc nvme layer to allocate on the LLDD's 455*4882a593Smuzhiyun * behalf whenever a remoteport is allocated. The additional memory 456*4882a593Smuzhiyun * area solely for the of the LLDD and its location is specified by 457*4882a593Smuzhiyun * the remoteport->private pointer. 458*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 459*4882a593Smuzhiyun * 460*4882a593Smuzhiyun * @lsrqst_priv_sz: The LLDD sets this field to the amount of additional 461*4882a593Smuzhiyun * memory that it would like fc nvme layer to allocate on the LLDD's 462*4882a593Smuzhiyun * behalf whenever a ls request structure is allocated. The additional 463*4882a593Smuzhiyun * memory area is solely for use by the LLDD and its location is 464*4882a593Smuzhiyun * specified by the ls_request->private pointer. 465*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 466*4882a593Smuzhiyun * 467*4882a593Smuzhiyun * @fcprqst_priv_sz: The LLDD sets this field to the amount of additional 468*4882a593Smuzhiyun * memory that it would like fc nvme layer to allocate on the LLDD's 469*4882a593Smuzhiyun * behalf whenever a fcp request structure is allocated. The additional 470*4882a593Smuzhiyun * memory area solely for the of the LLDD and its location is 471*4882a593Smuzhiyun * specified by the fcp_request->private pointer. 472*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 473*4882a593Smuzhiyun */ 474*4882a593Smuzhiyun struct nvme_fc_port_template { 475*4882a593Smuzhiyun /* initiator-based functions */ 476*4882a593Smuzhiyun void (*localport_delete)(struct nvme_fc_local_port *); 477*4882a593Smuzhiyun void (*remoteport_delete)(struct nvme_fc_remote_port *); 478*4882a593Smuzhiyun int (*create_queue)(struct nvme_fc_local_port *, 479*4882a593Smuzhiyun unsigned int qidx, u16 qsize, 480*4882a593Smuzhiyun void **handle); 481*4882a593Smuzhiyun void (*delete_queue)(struct nvme_fc_local_port *, 482*4882a593Smuzhiyun unsigned int qidx, void *handle); 483*4882a593Smuzhiyun int (*ls_req)(struct nvme_fc_local_port *, 484*4882a593Smuzhiyun struct nvme_fc_remote_port *, 485*4882a593Smuzhiyun struct nvmefc_ls_req *); 486*4882a593Smuzhiyun int (*fcp_io)(struct nvme_fc_local_port *, 487*4882a593Smuzhiyun struct nvme_fc_remote_port *, 488*4882a593Smuzhiyun void *hw_queue_handle, 489*4882a593Smuzhiyun struct nvmefc_fcp_req *); 490*4882a593Smuzhiyun void (*ls_abort)(struct nvme_fc_local_port *, 491*4882a593Smuzhiyun struct nvme_fc_remote_port *, 492*4882a593Smuzhiyun struct nvmefc_ls_req *); 493*4882a593Smuzhiyun void (*fcp_abort)(struct nvme_fc_local_port *, 494*4882a593Smuzhiyun struct nvme_fc_remote_port *, 495*4882a593Smuzhiyun void *hw_queue_handle, 496*4882a593Smuzhiyun struct nvmefc_fcp_req *); 497*4882a593Smuzhiyun int (*xmt_ls_rsp)(struct nvme_fc_local_port *localport, 498*4882a593Smuzhiyun struct nvme_fc_remote_port *rport, 499*4882a593Smuzhiyun struct nvmefc_ls_rsp *ls_rsp); 500*4882a593Smuzhiyun 501*4882a593Smuzhiyun u32 max_hw_queues; 502*4882a593Smuzhiyun u16 max_sgl_segments; 503*4882a593Smuzhiyun u16 max_dif_sgl_segments; 504*4882a593Smuzhiyun u64 dma_boundary; 505*4882a593Smuzhiyun 506*4882a593Smuzhiyun /* sizes of additional private data for data structures */ 507*4882a593Smuzhiyun u32 local_priv_sz; 508*4882a593Smuzhiyun u32 remote_priv_sz; 509*4882a593Smuzhiyun u32 lsrqst_priv_sz; 510*4882a593Smuzhiyun u32 fcprqst_priv_sz; 511*4882a593Smuzhiyun }; 512*4882a593Smuzhiyun 513*4882a593Smuzhiyun 514*4882a593Smuzhiyun /* 515*4882a593Smuzhiyun * Initiator/Host functions 516*4882a593Smuzhiyun */ 517*4882a593Smuzhiyun 518*4882a593Smuzhiyun int nvme_fc_register_localport(struct nvme_fc_port_info *pinfo, 519*4882a593Smuzhiyun struct nvme_fc_port_template *template, 520*4882a593Smuzhiyun struct device *dev, 521*4882a593Smuzhiyun struct nvme_fc_local_port **lport_p); 522*4882a593Smuzhiyun 523*4882a593Smuzhiyun int nvme_fc_unregister_localport(struct nvme_fc_local_port *localport); 524*4882a593Smuzhiyun 525*4882a593Smuzhiyun int nvme_fc_register_remoteport(struct nvme_fc_local_port *localport, 526*4882a593Smuzhiyun struct nvme_fc_port_info *pinfo, 527*4882a593Smuzhiyun struct nvme_fc_remote_port **rport_p); 528*4882a593Smuzhiyun 529*4882a593Smuzhiyun int nvme_fc_unregister_remoteport(struct nvme_fc_remote_port *remoteport); 530*4882a593Smuzhiyun 531*4882a593Smuzhiyun void nvme_fc_rescan_remoteport(struct nvme_fc_remote_port *remoteport); 532*4882a593Smuzhiyun 533*4882a593Smuzhiyun int nvme_fc_set_remoteport_devloss(struct nvme_fc_remote_port *remoteport, 534*4882a593Smuzhiyun u32 dev_loss_tmo); 535*4882a593Smuzhiyun 536*4882a593Smuzhiyun /* 537*4882a593Smuzhiyun * Routine called to pass a NVME-FC LS request, received by the lldd, 538*4882a593Smuzhiyun * to the nvme-fc transport. 539*4882a593Smuzhiyun * 540*4882a593Smuzhiyun * If the return value is zero: the LS was successfully accepted by the 541*4882a593Smuzhiyun * transport. 542*4882a593Smuzhiyun * If the return value is non-zero: the transport has not accepted the 543*4882a593Smuzhiyun * LS. The lldd should ABTS-LS the LS. 544*4882a593Smuzhiyun * 545*4882a593Smuzhiyun * Note: if the LLDD receives and ABTS for the LS prior to the transport 546*4882a593Smuzhiyun * calling the ops->xmt_ls_rsp() routine to transmit a response, the LLDD 547*4882a593Smuzhiyun * shall mark the LS as aborted, and when the xmt_ls_rsp() is called: the 548*4882a593Smuzhiyun * response shall not be transmit and the struct nvmefc_ls_rsp() done 549*4882a593Smuzhiyun * routine shall be called. The LLDD may transmit the ABTS response as 550*4882a593Smuzhiyun * soon as the LS was marked or can delay until the xmt_ls_rsp() call is 551*4882a593Smuzhiyun * made. 552*4882a593Smuzhiyun * Note: if an RCV LS was successfully posted to the transport and the 553*4882a593Smuzhiyun * remoteport is then unregistered before xmt_ls_rsp() was called for 554*4882a593Smuzhiyun * the lsrsp structure, the transport will still call xmt_ls_rsp() 555*4882a593Smuzhiyun * afterward to cleanup the outstanding lsrsp structure. The LLDD should 556*4882a593Smuzhiyun * noop the transmission of the rsp and call the lsrsp->done() routine 557*4882a593Smuzhiyun * to allow the lsrsp structure to be released. 558*4882a593Smuzhiyun */ 559*4882a593Smuzhiyun int nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *remoteport, 560*4882a593Smuzhiyun struct nvmefc_ls_rsp *lsrsp, 561*4882a593Smuzhiyun void *lsreqbuf, u32 lsreqbuf_len); 562*4882a593Smuzhiyun 563*4882a593Smuzhiyun 564*4882a593Smuzhiyun 565*4882a593Smuzhiyun /* 566*4882a593Smuzhiyun * *************** LLDD FC-NVME Target/Subsystem API *************** 567*4882a593Smuzhiyun * 568*4882a593Smuzhiyun * For FC LLDD's that are the NVME Subsystem role 569*4882a593Smuzhiyun * 570*4882a593Smuzhiyun * ****************************************************************** 571*4882a593Smuzhiyun */ 572*4882a593Smuzhiyun 573*4882a593Smuzhiyun /** 574*4882a593Smuzhiyun * struct nvmet_fc_port_info - port-specific ids and FC connection-specific 575*4882a593Smuzhiyun * data element used during NVME Subsystem role 576*4882a593Smuzhiyun * registrations 577*4882a593Smuzhiyun * 578*4882a593Smuzhiyun * Static fields describing the port being registered: 579*4882a593Smuzhiyun * @node_name: FC WWNN for the port 580*4882a593Smuzhiyun * @port_name: FC WWPN for the port 581*4882a593Smuzhiyun * 582*4882a593Smuzhiyun * Initialization values for dynamic port fields: 583*4882a593Smuzhiyun * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must 584*4882a593Smuzhiyun * be set to 0. 585*4882a593Smuzhiyun */ 586*4882a593Smuzhiyun struct nvmet_fc_port_info { 587*4882a593Smuzhiyun u64 node_name; 588*4882a593Smuzhiyun u64 port_name; 589*4882a593Smuzhiyun u32 port_id; 590*4882a593Smuzhiyun }; 591*4882a593Smuzhiyun 592*4882a593Smuzhiyun 593*4882a593Smuzhiyun /* Operations that NVME-FC layer may request the LLDD to perform for FCP */ 594*4882a593Smuzhiyun enum { 595*4882a593Smuzhiyun NVMET_FCOP_READDATA = 1, /* xmt data to initiator */ 596*4882a593Smuzhiyun NVMET_FCOP_WRITEDATA = 2, /* xmt data from initiator */ 597*4882a593Smuzhiyun NVMET_FCOP_READDATA_RSP = 3, /* xmt data to initiator and send 598*4882a593Smuzhiyun * rsp as well 599*4882a593Smuzhiyun */ 600*4882a593Smuzhiyun NVMET_FCOP_RSP = 4, /* send rsp frame */ 601*4882a593Smuzhiyun }; 602*4882a593Smuzhiyun 603*4882a593Smuzhiyun /** 604*4882a593Smuzhiyun * struct nvmefc_tgt_fcp_req - Structure used between LLDD and NVMET-FC 605*4882a593Smuzhiyun * layer to represent the exchange context and 606*4882a593Smuzhiyun * the specific FC-NVME IU operation(s) to perform 607*4882a593Smuzhiyun * for a FC-NVME FCP IO. 608*4882a593Smuzhiyun * 609*4882a593Smuzhiyun * Structure used between LLDD and nvmet-fc layer to represent the exchange 610*4882a593Smuzhiyun * context for a FC-NVME FCP I/O operation (e.g. a nvme sqe, the sqe-related 611*4882a593Smuzhiyun * memory transfers, and its assocated cqe transfer). 612*4882a593Smuzhiyun * 613*4882a593Smuzhiyun * The structure is allocated by the LLDD whenever a FCP CMD IU is received 614*4882a593Smuzhiyun * from the FC link. The address of the structure is passed to the nvmet-fc 615*4882a593Smuzhiyun * layer via the nvmet_fc_rcv_fcp_req() call. The address of the structure 616*4882a593Smuzhiyun * will be passed back to the LLDD for the data operations and transmit of 617*4882a593Smuzhiyun * the response. The LLDD is to use the address to map back to the LLDD 618*4882a593Smuzhiyun * exchange structure which maintains information such as the targetport 619*4882a593Smuzhiyun * the FCP I/O was received on, the remote FC NVME initiator that sent the 620*4882a593Smuzhiyun * FCP I/O, and any FC exchange context. Upon completion of the FCP target 621*4882a593Smuzhiyun * operation, the address of the structure will be passed back to the FCP 622*4882a593Smuzhiyun * op done() routine, allowing the nvmet-fc layer to release dma resources. 623*4882a593Smuzhiyun * Upon completion of the done() routine for either RSP or ABORT ops, no 624*4882a593Smuzhiyun * further access will be made by the nvmet-fc layer and the LLDD can 625*4882a593Smuzhiyun * de-allocate the structure. 626*4882a593Smuzhiyun * 627*4882a593Smuzhiyun * Field initialization: 628*4882a593Smuzhiyun * At the time of the nvmet_fc_rcv_fcp_req() call, there is no content that 629*4882a593Smuzhiyun * is valid in the structure. 630*4882a593Smuzhiyun * 631*4882a593Smuzhiyun * When the structure is used for an FCP target operation, the nvmet-fc 632*4882a593Smuzhiyun * layer will fully set the fields in order to specify the scattergather 633*4882a593Smuzhiyun * list, the transfer length, as well as the done routine to be called 634*4882a593Smuzhiyun * upon compeletion of the operation. The nvmet-fc layer will also set a 635*4882a593Smuzhiyun * private pointer for its own use in the done routine. 636*4882a593Smuzhiyun * 637*4882a593Smuzhiyun * Values set by the NVMET-FC layer prior to calling the LLDD fcp_op 638*4882a593Smuzhiyun * entrypoint. 639*4882a593Smuzhiyun * @op: Indicates the FCP IU operation to perform (see NVMET_FCOP_xxx) 640*4882a593Smuzhiyun * @hwqid: Specifies the hw queue index (0..N-1, where N is the 641*4882a593Smuzhiyun * max_hw_queues value from the LLD's nvmet_fc_target_template) 642*4882a593Smuzhiyun * that the operation is to use. 643*4882a593Smuzhiyun * @offset: Indicates the DATA_OUT/DATA_IN payload offset to be tranferred. 644*4882a593Smuzhiyun * Field is only valid on WRITEDATA, READDATA, or READDATA_RSP ops. 645*4882a593Smuzhiyun * @timeout: amount of time, in seconds, to wait for a response from the NVME 646*4882a593Smuzhiyun * host. A value of 0 is an infinite wait. 647*4882a593Smuzhiyun * Valid only for the following ops: 648*4882a593Smuzhiyun * WRITEDATA: caps the wait for data reception 649*4882a593Smuzhiyun * READDATA_RSP & RSP: caps wait for FCP_CONF reception (if used) 650*4882a593Smuzhiyun * @transfer_length: the length, in bytes, of the DATA_OUT or DATA_IN payload 651*4882a593Smuzhiyun * that is to be transferred. 652*4882a593Smuzhiyun * Valid only for the WRITEDATA, READDATA, or READDATA_RSP ops. 653*4882a593Smuzhiyun * @ba_rjt: Contains the BA_RJT payload that is to be transferred. 654*4882a593Smuzhiyun * Valid only for the NVMET_FCOP_BA_RJT op. 655*4882a593Smuzhiyun * @sg: Scatter/gather list for the DATA_OUT/DATA_IN payload data. 656*4882a593Smuzhiyun * Valid only for the WRITEDATA, READDATA, or READDATA_RSP ops. 657*4882a593Smuzhiyun * @sg_cnt: Number of valid entries in the scatter/gather list. 658*4882a593Smuzhiyun * Valid only for the WRITEDATA, READDATA, or READDATA_RSP ops. 659*4882a593Smuzhiyun * @rspaddr: pointer to the FCP RSP IU buffer to be transmit 660*4882a593Smuzhiyun * Used by RSP and READDATA_RSP ops 661*4882a593Smuzhiyun * @rspdma: PCI DMA address of the FCP RSP IU buffer 662*4882a593Smuzhiyun * Used by RSP and READDATA_RSP ops 663*4882a593Smuzhiyun * @rsplen: Length, in bytes, of the FCP RSP IU buffer 664*4882a593Smuzhiyun * Used by RSP and READDATA_RSP ops 665*4882a593Smuzhiyun * @done: The callback routine the LLDD is to invoke upon completion of 666*4882a593Smuzhiyun * the operation. req argument is the pointer to the original 667*4882a593Smuzhiyun * FCP subsystem op request. 668*4882a593Smuzhiyun * @nvmet_fc_private: pointer to an internal NVMET-FC layer structure used 669*4882a593Smuzhiyun * as part of the NVMET-FC processing. The LLDD is not to 670*4882a593Smuzhiyun * reference this field. 671*4882a593Smuzhiyun * 672*4882a593Smuzhiyun * Values set by the LLDD indicating completion status of the FCP operation. 673*4882a593Smuzhiyun * Must be set prior to calling the done() callback. 674*4882a593Smuzhiyun * @transferred_length: amount of DATA_OUT payload data received by a 675*4882a593Smuzhiyun * WRITEDATA operation. If not a WRITEDATA operation, value must 676*4882a593Smuzhiyun * be set to 0. Should equal transfer_length on success. 677*4882a593Smuzhiyun * @fcp_error: status of the FCP operation. Must be 0 on success; on failure 678*4882a593Smuzhiyun * must be a NVME_SC_FC_xxxx value. 679*4882a593Smuzhiyun */ 680*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req { 681*4882a593Smuzhiyun u8 op; 682*4882a593Smuzhiyun u16 hwqid; 683*4882a593Smuzhiyun u32 offset; 684*4882a593Smuzhiyun u32 timeout; 685*4882a593Smuzhiyun u32 transfer_length; 686*4882a593Smuzhiyun struct fc_ba_rjt ba_rjt; 687*4882a593Smuzhiyun struct scatterlist *sg; 688*4882a593Smuzhiyun int sg_cnt; 689*4882a593Smuzhiyun void *rspaddr; 690*4882a593Smuzhiyun dma_addr_t rspdma; 691*4882a593Smuzhiyun u16 rsplen; 692*4882a593Smuzhiyun 693*4882a593Smuzhiyun void (*done)(struct nvmefc_tgt_fcp_req *); 694*4882a593Smuzhiyun 695*4882a593Smuzhiyun void *nvmet_fc_private; /* LLDD is not to access !! */ 696*4882a593Smuzhiyun 697*4882a593Smuzhiyun u32 transferred_length; 698*4882a593Smuzhiyun int fcp_error; 699*4882a593Smuzhiyun }; 700*4882a593Smuzhiyun 701*4882a593Smuzhiyun 702*4882a593Smuzhiyun /* Target Features (Bit fields) LLDD supports */ 703*4882a593Smuzhiyun enum { 704*4882a593Smuzhiyun NVMET_FCTGTFEAT_READDATA_RSP = (1 << 0), 705*4882a593Smuzhiyun /* Bit 0: supports the NVMET_FCPOP_READDATA_RSP op, which 706*4882a593Smuzhiyun * sends (the last) Read Data sequence followed by the RSP 707*4882a593Smuzhiyun * sequence in one LLDD operation. Errors during Data 708*4882a593Smuzhiyun * sequence transmit must not allow RSP sequence to be sent. 709*4882a593Smuzhiyun */ 710*4882a593Smuzhiyun }; 711*4882a593Smuzhiyun 712*4882a593Smuzhiyun 713*4882a593Smuzhiyun /** 714*4882a593Smuzhiyun * struct nvmet_fc_target_port - structure used between NVME-FC transport and 715*4882a593Smuzhiyun * a LLDD to reference a local NVME subsystem port. 716*4882a593Smuzhiyun * Allocated/created by the nvme_fc_register_targetport() 717*4882a593Smuzhiyun * transport interface. 718*4882a593Smuzhiyun * 719*4882a593Smuzhiyun * Fields with static values for the port. Initialized by the 720*4882a593Smuzhiyun * port_info struct supplied to the registration call. 721*4882a593Smuzhiyun * @port_num: NVME-FC transport subsytem port number 722*4882a593Smuzhiyun * @node_name: FC WWNN for the port 723*4882a593Smuzhiyun * @port_name: FC WWPN for the port 724*4882a593Smuzhiyun * @private: pointer to memory allocated alongside the local port 725*4882a593Smuzhiyun * structure that is specifically for the LLDD to use. 726*4882a593Smuzhiyun * The length of the buffer corresponds to the target_priv_sz 727*4882a593Smuzhiyun * value specified in the nvme_fc_target_template supplied by 728*4882a593Smuzhiyun * the LLDD. 729*4882a593Smuzhiyun * 730*4882a593Smuzhiyun * Fields with dynamic values. Values may change base on link state. LLDD 731*4882a593Smuzhiyun * may reference fields directly to change them. Initialized by the 732*4882a593Smuzhiyun * port_info struct supplied to the registration call. 733*4882a593Smuzhiyun * @port_id: FC N_Port_ID currently assigned the port. Upper 8 bits must 734*4882a593Smuzhiyun * be set to 0. 735*4882a593Smuzhiyun * @port_state: Operational state of the port. 736*4882a593Smuzhiyun */ 737*4882a593Smuzhiyun struct nvmet_fc_target_port { 738*4882a593Smuzhiyun /* static/read-only fields */ 739*4882a593Smuzhiyun u32 port_num; 740*4882a593Smuzhiyun u64 node_name; 741*4882a593Smuzhiyun u64 port_name; 742*4882a593Smuzhiyun 743*4882a593Smuzhiyun void *private; 744*4882a593Smuzhiyun 745*4882a593Smuzhiyun /* dynamic fields */ 746*4882a593Smuzhiyun u32 port_id; 747*4882a593Smuzhiyun enum nvme_fc_obj_state port_state; 748*4882a593Smuzhiyun } __aligned(sizeof(u64)); /* alignment for other things alloc'd with */ 749*4882a593Smuzhiyun 750*4882a593Smuzhiyun 751*4882a593Smuzhiyun /** 752*4882a593Smuzhiyun * struct nvmet_fc_target_template - structure containing static entrypoints 753*4882a593Smuzhiyun * and operational parameters for an LLDD that supports NVME 754*4882a593Smuzhiyun * subsystem behavior. Passed by reference in port 755*4882a593Smuzhiyun * registrations. NVME-FC transport remembers template 756*4882a593Smuzhiyun * reference and may access it during runtime operation. 757*4882a593Smuzhiyun * 758*4882a593Smuzhiyun * Subsystem/Target Transport Entrypoints/Parameters: 759*4882a593Smuzhiyun * 760*4882a593Smuzhiyun * @targetport_delete: The LLDD initiates deletion of a targetport via 761*4882a593Smuzhiyun * nvmet_fc_unregister_targetport(). However, the teardown is 762*4882a593Smuzhiyun * asynchronous. This routine is called upon the completion of the 763*4882a593Smuzhiyun * teardown to inform the LLDD that the targetport has been deleted. 764*4882a593Smuzhiyun * Entrypoint is Mandatory. 765*4882a593Smuzhiyun * 766*4882a593Smuzhiyun * @xmt_ls_rsp: Called to transmit the response to a FC-NVME FC-4 LS service. 767*4882a593Smuzhiyun * The nvmefc_ls_rsp structure is the same LLDD-supplied exchange 768*4882a593Smuzhiyun * structure specified in the nvmet_fc_rcv_ls_req() call made when 769*4882a593Smuzhiyun * the LS request was received. The structure will fully describe 770*4882a593Smuzhiyun * the buffers for the response payload and the dma address of the 771*4882a593Smuzhiyun * payload. The LLDD is to transmit the response (or return a 772*4882a593Smuzhiyun * non-zero errno status), and upon completion of the transmit, call 773*4882a593Smuzhiyun * the "done" routine specified in the nvmefc_ls_rsp structure 774*4882a593Smuzhiyun * (argument to done is the address of the nvmefc_ls_rsp structure 775*4882a593Smuzhiyun * itself). Upon the completion of the done() routine, the LLDD shall 776*4882a593Smuzhiyun * consider the LS handling complete and the nvmefc_ls_rsp structure 777*4882a593Smuzhiyun * may be freed/released. 778*4882a593Smuzhiyun * The transport will always call the xmt_ls_rsp() routine for any 779*4882a593Smuzhiyun * LS received. 780*4882a593Smuzhiyun * Entrypoint is Mandatory. 781*4882a593Smuzhiyun * 782*4882a593Smuzhiyun * @fcp_op: Called to perform a data transfer or transmit a response. 783*4882a593Smuzhiyun * The nvmefc_tgt_fcp_req structure is the same LLDD-supplied 784*4882a593Smuzhiyun * exchange structure specified in the nvmet_fc_rcv_fcp_req() call 785*4882a593Smuzhiyun * made when the FCP CMD IU was received. The op field in the 786*4882a593Smuzhiyun * structure shall indicate the operation for the LLDD to perform 787*4882a593Smuzhiyun * relative to the io. 788*4882a593Smuzhiyun * NVMET_FCOP_READDATA operation: the LLDD is to send the 789*4882a593Smuzhiyun * payload data (described by sglist) to the host in 1 or 790*4882a593Smuzhiyun * more FC sequences (preferrably 1). Note: the fc-nvme layer 791*4882a593Smuzhiyun * may call the READDATA operation multiple times for longer 792*4882a593Smuzhiyun * payloads. 793*4882a593Smuzhiyun * NVMET_FCOP_WRITEDATA operation: the LLDD is to receive the 794*4882a593Smuzhiyun * payload data (described by sglist) from the host via 1 or 795*4882a593Smuzhiyun * more FC sequences (preferrably 1). The LLDD is to generate 796*4882a593Smuzhiyun * the XFER_RDY IU(s) corresponding to the data being requested. 797*4882a593Smuzhiyun * Note: the FC-NVME layer may call the WRITEDATA operation 798*4882a593Smuzhiyun * multiple times for longer payloads. 799*4882a593Smuzhiyun * NVMET_FCOP_READDATA_RSP operation: the LLDD is to send the 800*4882a593Smuzhiyun * payload data (described by sglist) to the host in 1 or 801*4882a593Smuzhiyun * more FC sequences (preferrably 1). If an error occurs during 802*4882a593Smuzhiyun * payload data transmission, the LLDD is to set the 803*4882a593Smuzhiyun * nvmefc_tgt_fcp_req fcp_error and transferred_length field, then 804*4882a593Smuzhiyun * consider the operation complete. On error, the LLDD is to not 805*4882a593Smuzhiyun * transmit the FCP_RSP iu. If all payload data is transferred 806*4882a593Smuzhiyun * successfully, the LLDD is to update the nvmefc_tgt_fcp_req 807*4882a593Smuzhiyun * transferred_length field and may subsequently transmit the 808*4882a593Smuzhiyun * FCP_RSP iu payload (described by rspbuf, rspdma, rsplen). 809*4882a593Smuzhiyun * If FCP_CONF is supported, the LLDD is to await FCP_CONF 810*4882a593Smuzhiyun * reception to confirm the RSP reception by the host. The LLDD 811*4882a593Smuzhiyun * may retramsit the FCP_RSP iu if necessary per FC-NVME. Upon 812*4882a593Smuzhiyun * transmission of the FCP_RSP iu if FCP_CONF is not supported, 813*4882a593Smuzhiyun * or upon success/failure of FCP_CONF if it is supported, the 814*4882a593Smuzhiyun * LLDD is to set the nvmefc_tgt_fcp_req fcp_error field and 815*4882a593Smuzhiyun * consider the operation complete. 816*4882a593Smuzhiyun * NVMET_FCOP_RSP: the LLDD is to transmit the FCP_RSP iu payload 817*4882a593Smuzhiyun * (described by rspbuf, rspdma, rsplen). If FCP_CONF is 818*4882a593Smuzhiyun * supported, the LLDD is to await FCP_CONF reception to confirm 819*4882a593Smuzhiyun * the RSP reception by the host. The LLDD may retramsit the 820*4882a593Smuzhiyun * FCP_RSP iu if FCP_CONF is not received per FC-NVME. Upon 821*4882a593Smuzhiyun * transmission of the FCP_RSP iu if FCP_CONF is not supported, 822*4882a593Smuzhiyun * or upon success/failure of FCP_CONF if it is supported, the 823*4882a593Smuzhiyun * LLDD is to set the nvmefc_tgt_fcp_req fcp_error field and 824*4882a593Smuzhiyun * consider the operation complete. 825*4882a593Smuzhiyun * Upon completing the indicated operation, the LLDD is to set the 826*4882a593Smuzhiyun * status fields for the operation (tranferred_length and fcp_error 827*4882a593Smuzhiyun * status) in the request, then call the "done" routine 828*4882a593Smuzhiyun * indicated in the fcp request. After the operation completes, 829*4882a593Smuzhiyun * regardless of whether the FCP_RSP iu was successfully transmit, 830*4882a593Smuzhiyun * the LLDD-supplied exchange structure must remain valid until the 831*4882a593Smuzhiyun * transport calls the fcp_req_release() callback to return ownership 832*4882a593Smuzhiyun * of the exchange structure back to the LLDD so that it may be used 833*4882a593Smuzhiyun * for another fcp command. 834*4882a593Smuzhiyun * Note: when calling the done routine for READDATA or WRITEDATA 835*4882a593Smuzhiyun * operations, the fc-nvme layer may immediate convert, in the same 836*4882a593Smuzhiyun * thread and before returning to the LLDD, the fcp operation to 837*4882a593Smuzhiyun * the next operation for the fcp io and call the LLDDs fcp_op 838*4882a593Smuzhiyun * call again. If fields in the fcp request are to be accessed post 839*4882a593Smuzhiyun * the done call, the LLDD should save their values prior to calling 840*4882a593Smuzhiyun * the done routine, and inspect the save values after the done 841*4882a593Smuzhiyun * routine. 842*4882a593Smuzhiyun * Returns 0 on success, -<errno> on failure (Ex: -EIO) 843*4882a593Smuzhiyun * Entrypoint is Mandatory. 844*4882a593Smuzhiyun * 845*4882a593Smuzhiyun * @fcp_abort: Called by the transport to abort an active command. 846*4882a593Smuzhiyun * The command may be in-between operations (nothing active in LLDD) 847*4882a593Smuzhiyun * or may have an active WRITEDATA operation pending. The LLDD is to 848*4882a593Smuzhiyun * initiate the ABTS process for the command and return from the 849*4882a593Smuzhiyun * callback. The ABTS does not need to be complete on the command. 850*4882a593Smuzhiyun * The fcp_abort callback inherently cannot fail. After the 851*4882a593Smuzhiyun * fcp_abort() callback completes, the transport will wait for any 852*4882a593Smuzhiyun * outstanding operation (if there was one) to complete, then will 853*4882a593Smuzhiyun * call the fcp_req_release() callback to return the command's 854*4882a593Smuzhiyun * exchange context back to the LLDD. 855*4882a593Smuzhiyun * Entrypoint is Mandatory. 856*4882a593Smuzhiyun * 857*4882a593Smuzhiyun * @fcp_req_release: Called by the transport to return a nvmefc_tgt_fcp_req 858*4882a593Smuzhiyun * to the LLDD after all operations on the fcp operation are complete. 859*4882a593Smuzhiyun * This may be due to the command completing or upon completion of 860*4882a593Smuzhiyun * abort cleanup. 861*4882a593Smuzhiyun * Entrypoint is Mandatory. 862*4882a593Smuzhiyun * 863*4882a593Smuzhiyun * @defer_rcv: Called by the transport to signal the LLLD that it has 864*4882a593Smuzhiyun * begun processing of a previously received NVME CMD IU. The LLDD 865*4882a593Smuzhiyun * is now free to re-use the rcv buffer associated with the 866*4882a593Smuzhiyun * nvmefc_tgt_fcp_req. 867*4882a593Smuzhiyun * Entrypoint is Optional. 868*4882a593Smuzhiyun * 869*4882a593Smuzhiyun * @discovery_event: Called by the transport to generate an RSCN 870*4882a593Smuzhiyun * change notifications to NVME initiators. The RSCN notifications 871*4882a593Smuzhiyun * should cause the initiator to rescan the discovery controller 872*4882a593Smuzhiyun * on the targetport. 873*4882a593Smuzhiyun * 874*4882a593Smuzhiyun * @ls_req: Called to issue a FC-NVME FC-4 LS service request. 875*4882a593Smuzhiyun * The nvme_fc_ls_req structure will fully describe the buffers for 876*4882a593Smuzhiyun * the request payload and where to place the response payload. 877*4882a593Smuzhiyun * The targetport that is to issue the LS request is identified by 878*4882a593Smuzhiyun * the targetport argument. The remote port that is to receive the 879*4882a593Smuzhiyun * LS request is identified by the hosthandle argument. The nvmet-fc 880*4882a593Smuzhiyun * transport is only allowed to issue FC-NVME LS's on behalf of an 881*4882a593Smuzhiyun * association that was created prior by a Create Association LS. 882*4882a593Smuzhiyun * The hosthandle will originate from the LLDD in the struct 883*4882a593Smuzhiyun * nvmefc_ls_rsp structure for the Create Association LS that 884*4882a593Smuzhiyun * was delivered to the transport. The transport will save the 885*4882a593Smuzhiyun * hosthandle as an attribute of the association. If the LLDD 886*4882a593Smuzhiyun * loses connectivity with the remote port, it must call the 887*4882a593Smuzhiyun * nvmet_fc_invalidate_host() routine to remove any references to 888*4882a593Smuzhiyun * the remote port in the transport. 889*4882a593Smuzhiyun * The LLDD is to allocate an exchange, issue the LS request, obtain 890*4882a593Smuzhiyun * the LS response, and call the "done" routine specified in the 891*4882a593Smuzhiyun * request structure (argument to done is the ls request structure 892*4882a593Smuzhiyun * itself). 893*4882a593Smuzhiyun * Entrypoint is Optional - but highly recommended. 894*4882a593Smuzhiyun * 895*4882a593Smuzhiyun * @ls_abort: called to request the LLDD to abort the indicated ls request. 896*4882a593Smuzhiyun * The call may return before the abort has completed. After aborting 897*4882a593Smuzhiyun * the request, the LLDD must still call the ls request done routine 898*4882a593Smuzhiyun * indicating an FC transport Aborted status. 899*4882a593Smuzhiyun * Entrypoint is Mandatory if the ls_req entry point is specified. 900*4882a593Smuzhiyun * 901*4882a593Smuzhiyun * @host_release: called to inform the LLDD that the request to invalidate 902*4882a593Smuzhiyun * the host port indicated by the hosthandle has been fully completed. 903*4882a593Smuzhiyun * No associations exist with the host port and there will be no 904*4882a593Smuzhiyun * further references to hosthandle. 905*4882a593Smuzhiyun * Entrypoint is Mandatory if the lldd calls nvmet_fc_invalidate_host(). 906*4882a593Smuzhiyun * 907*4882a593Smuzhiyun * @max_hw_queues: indicates the maximum number of hw queues the LLDD 908*4882a593Smuzhiyun * supports for cpu affinitization. 909*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. 910*4882a593Smuzhiyun * 911*4882a593Smuzhiyun * @max_sgl_segments: indicates the maximum number of sgl segments supported 912*4882a593Smuzhiyun * by the LLDD 913*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. Recommend at least 256. 914*4882a593Smuzhiyun * 915*4882a593Smuzhiyun * @max_dif_sgl_segments: indicates the maximum number of sgl segments 916*4882a593Smuzhiyun * supported by the LLDD for DIF operations. 917*4882a593Smuzhiyun * Value is Mandatory. Must be at least 1. Recommend at least 256. 918*4882a593Smuzhiyun * 919*4882a593Smuzhiyun * @dma_boundary: indicates the dma address boundary where dma mappings 920*4882a593Smuzhiyun * will be split across. 921*4882a593Smuzhiyun * Value is Mandatory. Typical value is 0xFFFFFFFF to split across 922*4882a593Smuzhiyun * 4Gig address boundarys 923*4882a593Smuzhiyun * 924*4882a593Smuzhiyun * @target_features: The LLDD sets bits in this field to correspond to 925*4882a593Smuzhiyun * optional features that are supported by the LLDD. 926*4882a593Smuzhiyun * Refer to the NVMET_FCTGTFEAT_xxx values. 927*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 928*4882a593Smuzhiyun * 929*4882a593Smuzhiyun * @target_priv_sz: The LLDD sets this field to the amount of additional 930*4882a593Smuzhiyun * memory that it would like fc nvme layer to allocate on the LLDD's 931*4882a593Smuzhiyun * behalf whenever a targetport is allocated. The additional memory 932*4882a593Smuzhiyun * area solely for the of the LLDD and its location is specified by 933*4882a593Smuzhiyun * the targetport->private pointer. 934*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 935*4882a593Smuzhiyun * 936*4882a593Smuzhiyun * @lsrqst_priv_sz: The LLDD sets this field to the amount of additional 937*4882a593Smuzhiyun * memory that it would like nvmet-fc layer to allocate on the LLDD's 938*4882a593Smuzhiyun * behalf whenever a ls request structure is allocated. The additional 939*4882a593Smuzhiyun * memory area is solely for use by the LLDD and its location is 940*4882a593Smuzhiyun * specified by the ls_request->private pointer. 941*4882a593Smuzhiyun * Value is Mandatory. Allowed to be zero. 942*4882a593Smuzhiyun * 943*4882a593Smuzhiyun */ 944*4882a593Smuzhiyun struct nvmet_fc_target_template { 945*4882a593Smuzhiyun void (*targetport_delete)(struct nvmet_fc_target_port *tgtport); 946*4882a593Smuzhiyun int (*xmt_ls_rsp)(struct nvmet_fc_target_port *tgtport, 947*4882a593Smuzhiyun struct nvmefc_ls_rsp *ls_rsp); 948*4882a593Smuzhiyun int (*fcp_op)(struct nvmet_fc_target_port *tgtport, 949*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq); 950*4882a593Smuzhiyun void (*fcp_abort)(struct nvmet_fc_target_port *tgtport, 951*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq); 952*4882a593Smuzhiyun void (*fcp_req_release)(struct nvmet_fc_target_port *tgtport, 953*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq); 954*4882a593Smuzhiyun void (*defer_rcv)(struct nvmet_fc_target_port *tgtport, 955*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq); 956*4882a593Smuzhiyun void (*discovery_event)(struct nvmet_fc_target_port *tgtport); 957*4882a593Smuzhiyun int (*ls_req)(struct nvmet_fc_target_port *targetport, 958*4882a593Smuzhiyun void *hosthandle, struct nvmefc_ls_req *lsreq); 959*4882a593Smuzhiyun void (*ls_abort)(struct nvmet_fc_target_port *targetport, 960*4882a593Smuzhiyun void *hosthandle, struct nvmefc_ls_req *lsreq); 961*4882a593Smuzhiyun void (*host_release)(void *hosthandle); 962*4882a593Smuzhiyun 963*4882a593Smuzhiyun u32 max_hw_queues; 964*4882a593Smuzhiyun u16 max_sgl_segments; 965*4882a593Smuzhiyun u16 max_dif_sgl_segments; 966*4882a593Smuzhiyun u64 dma_boundary; 967*4882a593Smuzhiyun 968*4882a593Smuzhiyun u32 target_features; 969*4882a593Smuzhiyun 970*4882a593Smuzhiyun /* sizes of additional private data for data structures */ 971*4882a593Smuzhiyun u32 target_priv_sz; 972*4882a593Smuzhiyun u32 lsrqst_priv_sz; 973*4882a593Smuzhiyun }; 974*4882a593Smuzhiyun 975*4882a593Smuzhiyun 976*4882a593Smuzhiyun int nvmet_fc_register_targetport(struct nvmet_fc_port_info *portinfo, 977*4882a593Smuzhiyun struct nvmet_fc_target_template *template, 978*4882a593Smuzhiyun struct device *dev, 979*4882a593Smuzhiyun struct nvmet_fc_target_port **tgtport_p); 980*4882a593Smuzhiyun 981*4882a593Smuzhiyun int nvmet_fc_unregister_targetport(struct nvmet_fc_target_port *tgtport); 982*4882a593Smuzhiyun 983*4882a593Smuzhiyun /* 984*4882a593Smuzhiyun * Routine called to pass a NVME-FC LS request, received by the lldd, 985*4882a593Smuzhiyun * to the nvmet-fc transport. 986*4882a593Smuzhiyun * 987*4882a593Smuzhiyun * If the return value is zero: the LS was successfully accepted by the 988*4882a593Smuzhiyun * transport. 989*4882a593Smuzhiyun * If the return value is non-zero: the transport has not accepted the 990*4882a593Smuzhiyun * LS. The lldd should ABTS-LS the LS. 991*4882a593Smuzhiyun * 992*4882a593Smuzhiyun * Note: if the LLDD receives and ABTS for the LS prior to the transport 993*4882a593Smuzhiyun * calling the ops->xmt_ls_rsp() routine to transmit a response, the LLDD 994*4882a593Smuzhiyun * shall mark the LS as aborted, and when the xmt_ls_rsp() is called: the 995*4882a593Smuzhiyun * response shall not be transmit and the struct nvmefc_ls_rsp() done 996*4882a593Smuzhiyun * routine shall be called. The LLDD may transmit the ABTS response as 997*4882a593Smuzhiyun * soon as the LS was marked or can delay until the xmt_ls_rsp() call is 998*4882a593Smuzhiyun * made. 999*4882a593Smuzhiyun * Note: if an RCV LS was successfully posted to the transport and the 1000*4882a593Smuzhiyun * targetport is then unregistered before xmt_ls_rsp() was called for 1001*4882a593Smuzhiyun * the lsrsp structure, the transport will still call xmt_ls_rsp() 1002*4882a593Smuzhiyun * afterward to cleanup the outstanding lsrsp structure. The LLDD should 1003*4882a593Smuzhiyun * noop the transmission of the rsp and call the lsrsp->done() routine 1004*4882a593Smuzhiyun * to allow the lsrsp structure to be released. 1005*4882a593Smuzhiyun */ 1006*4882a593Smuzhiyun int nvmet_fc_rcv_ls_req(struct nvmet_fc_target_port *tgtport, 1007*4882a593Smuzhiyun void *hosthandle, 1008*4882a593Smuzhiyun struct nvmefc_ls_rsp *rsp, 1009*4882a593Smuzhiyun void *lsreqbuf, u32 lsreqbuf_len); 1010*4882a593Smuzhiyun 1011*4882a593Smuzhiyun /* 1012*4882a593Smuzhiyun * Routine called by the LLDD whenever it has a logout or loss of 1013*4882a593Smuzhiyun * connectivity to a NVME-FC host port which there had been active 1014*4882a593Smuzhiyun * NVMe controllers for. The host port is indicated by the 1015*4882a593Smuzhiyun * hosthandle. The hosthandle is given to the nvmet-fc transport 1016*4882a593Smuzhiyun * when a NVME LS was received, typically to create a new association. 1017*4882a593Smuzhiyun * The nvmet-fc transport will cache the hostport value with the 1018*4882a593Smuzhiyun * association for use in LS requests for the association. 1019*4882a593Smuzhiyun * When the LLDD calls this routine, the nvmet-fc transport will 1020*4882a593Smuzhiyun * immediately terminate all associations that were created with 1021*4882a593Smuzhiyun * the hosthandle host port. 1022*4882a593Smuzhiyun * The LLDD, after calling this routine and having control returned, 1023*4882a593Smuzhiyun * must assume the transport may subsequently utilize hosthandle as 1024*4882a593Smuzhiyun * part of sending LS's to terminate the association. The LLDD 1025*4882a593Smuzhiyun * should reject the LS's if they are attempted. 1026*4882a593Smuzhiyun * Once the last association has terminated for the hosthandle host 1027*4882a593Smuzhiyun * port, the nvmet-fc transport will call the ops->host_release() 1028*4882a593Smuzhiyun * callback. As of the callback, the nvmet-fc transport will no 1029*4882a593Smuzhiyun * longer reference hosthandle. 1030*4882a593Smuzhiyun */ 1031*4882a593Smuzhiyun void nvmet_fc_invalidate_host(struct nvmet_fc_target_port *tgtport, 1032*4882a593Smuzhiyun void *hosthandle); 1033*4882a593Smuzhiyun 1034*4882a593Smuzhiyun /* 1035*4882a593Smuzhiyun * If nvmet_fc_rcv_fcp_req returns non-zero, the transport has not accepted 1036*4882a593Smuzhiyun * the FCP cmd. The lldd should ABTS-LS the cmd. 1037*4882a593Smuzhiyun */ 1038*4882a593Smuzhiyun int nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *tgtport, 1039*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq, 1040*4882a593Smuzhiyun void *cmdiubuf, u32 cmdiubuf_len); 1041*4882a593Smuzhiyun 1042*4882a593Smuzhiyun void nvmet_fc_rcv_fcp_abort(struct nvmet_fc_target_port *tgtport, 1043*4882a593Smuzhiyun struct nvmefc_tgt_fcp_req *fcpreq); 1044*4882a593Smuzhiyun 1045*4882a593Smuzhiyun #endif /* _NVME_FC_DRIVER_H */ 1046