STRUCT NVMET_FC_TARGET_TEMPLATE(9)
π struct nvmet_fc_target_template(9) β Kernel API Manual
okay bestie, buckle up, because this is the page where the NVME-FC target template gets its whole moment β¨ The manual name is struct nvmet_fc_target_template(9) and it lives in the Kernel API Manual, and yes we're doing the whole thing, every last field, no skipping π«Ά
π NAME π
struct nvmet_fc_target_template β a structure holding the static entrypoints plus operational parameters for an LLDD that supports NVME subsystem behavior. It gets passed by reference in port registrations. The NVME-FC transport literally remembers the template reference and may access it during runtime operation. iykyk π
β¨ SYNOPSIS β¨
struct nvmet_fc_target_template {
void (*targetport_delete)(struct nvmet_fc_target_port *tgtport);
int (*xmt_ls_rsp)(struct nvmet_fc_target_port *tgtport, struct nvmefc_ls_rsp *ls_rsp);
int (*fcp_op)(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *fcpreq);
void (*fcp_abort)(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *fcpreq);
void (*fcp_req_release)(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *fcpreq);
void (*defer_rcv)(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *fcpreq);
void (*discovery_event)(struct nvmet_fc_target_port *tgtport);
int (*ls_req)(struct nvmet_fc_target_port *targetport, void *hosthandle, struct nvmefc_ls_req *lsreq);
void (*ls_abort)(struct nvmet_fc_target_port *targetport, void *hosthandle, struct nvmefc_ls_req *lsreq);
void (*host_release)(void *hosthandle);
int (*host_traddr)(void *hosthandle, u64 *wwnn, u64 *wwpn);
u32 max_hw_queues;
u16 max_sgl_segments;
u16 max_dif_sgl_segments;
u64 dma_boundary;
u32 target_features;
u32 target_priv_sz;
u32 lsrqst_priv_sz;
};
πΈ Members πΈ
okay so this is the big one, every single member, let's go π¦
targetport_deleteβ The LLDD kicks off deletion of a targetport throughnvmet_fc_unregister_targetport. But plot twist: the teardown is asynchronous π So this routine gets called once the teardown completes, to let the LLDD know the targetport has officially been deleted. Entrypoint is Mandatory.xmt_ls_rspβ Called to transmit the response to a FC-NVME FC-4 LS service. Thenvmefc_ls_rspstructure is the same LLDD-supplied exchange structure you specified in thenvmet_fc_rcv_ls_reqcall made when the LS request came in. The structure fully describes the buffers for the response payload and the dma address of the payload. The LLDD is to transmit the response (or return a non-zero errno status), and on completion of the transmit, call the "done" routine specified in thenvmefc_ls_rspstructure β the argument to done is the address of thenvmefc_ls_rspstructure itself, no cap. Once the done routine completes, the LLDD shall consider the LS handling complete and thenvmefc_ls_rspstructure may be freed/released. The transport will always call thexmt_ls_rsproutine for any LS received. Entrypoint is Mandatory.fcp_opβ Called to perform a data transfer or transmit a response. Thenvmefc_tgt_fcp_reqstructure is the same LLDD-supplied exchange structure you specified in thenvmet_fc_rcv_fcp_reqcall made when the FCP CMD IU was received. Theopfield in the structure shall indicate the operation for the LLDD to perform relative to the io. π«NVMET_FCOP_READDATAoperation: the LLDD is to send the payload data (described bysglist) to the host in 1 or more FC sequences (preferrably 1). Note: the fc-nvme layer may call the READDATA operation multiple times for longer payloads.NVMET_FCOP_WRITEDATAoperation: the LLDD is to receive the payload data (described bysglist) from the host via 1 or more FC sequences (preferrably 1). The LLDD is to generate theXFER_RDYIU(s) corresponding to the data being requested.
fcp_abortβ Called by the transport to abort an active command. The command may be in-between operations (nothing active in LLDD) or may have an active WRITEDATA operation pending. The LLDD is to initiate the ABTS process for the command and return from the callback. The ABTS does not need to be complete on the command. Thefcp_abortcallback inherently cannot fail. After thefcp_abortcallback completes, the transport will wait for any outstanding operation (if there was one) to complete, then will call thefcp_req_releasecallback to return the command's exchange context back to the LLDD. Entrypoint is Mandatory.fcp_req_releaseβ Called by the transport to return anvmefc_tgt_fcp_reqback to the LLDD after all operations on the fcp operation are complete. This may be because the command completed, or on completion of abort cleanup. Entrypoint is Mandatory.defer_rcvβ Called by the transport to signal the LLLD that it has begun processing of a previously received NVME CMD IU. The LLDD is now free to re-use the rcv buffer associated with thenvmefc_tgt_fcp_req. Entrypoint is Optional.discovery_eventβ Called by the transport to generate RSCN change notifications to NVME initiators. Those RSCN notifications should cause the initiator to rescan the discovery controller on the targetport. πls_reqβ Called to issue a FC-NVME FC-4 LS service request. Thenvme_fc_ls_reqstructure fully describes the buffers for the request payload and where to place the response payload. The targetport that's going to issue the LS request is identified by the targetport argument. The remote port that's going to receive the LS request is identified by the hosthandle argument. The nvmet-fc transport is only allowed to issue FC-NVME LS's on behalf of an association that was created earlier by a Create Association LS. The hosthandle will originate from the LLDD in thestruct nvmefc_ls_rspstructure for the Create Association LS that was delivered to the transport. The transport will save the hosthandle as an attribute of the association. If the LLDD loses connectivity with the remote port, it must call thenvmet_fc_invalidate_hostroutine to remove any references to the remote port in the transport. The LLDD is to allocate an exchange, issue the LS request, obtain the LS response, and call the "done" routine specified in the request structure (the argument to done is the ls request structure itself). Entrypoint is Optional - but highly recommended. πls_abortβ called to request the LLDD abort the indicated ls request. The call may return before the abort has completed. After aborting the request, the LLDD must still call the ls request done routine indicating an FC transport Aborted status. Entrypoint is Mandatory if thels_reqentry point is specified.host_releaseβ called to inform the LLDD that the request to invalidate the host port indicated by the hosthandle has been fully completed. No associations exist with the host port and there will be no further references to hosthandle. Entrypoint is Mandatory if the lldd callsnvmet_fc_invalidate_host.host_traddrβ called by the transport to retrieve the node name and port name of the host port address. πmax_hw_queuesβ indicates the maximum number of hw queues the LLDD supports for cpu affinitization. Value is Mandatory. Must be at least 1.max_sgl_segmentsβ indicates the maximum number of sgl segments supported by the LLDD. Value is Mandatory. Must be at least 1. Recommend at least 256.max_dif_sgl_segmentsβ indicates the maximum number of sgl segments supported by the LLDD for DIF operations. Value is Mandatory. Must be at least 1. Recommend at least 256.dma_boundaryβ indicates the dma address boundary where dma mappings will be split across. Value is Mandatory. Typical value is0xFFFFFFFFto split across 4Gig address boundarys.target_featuresβ The LLDD sets bits in this field to correspond to optional features that are supported by the LLDD. Refer to theNVMET_FCTGTFEAT_xxxvalues. Value is Mandatory. Allowed to be zero.target_priv_szβ The LLDD sets this field to the amount of additional memory that it would like the fc nvme layer to allocate on the LLDD's behalf whenever a targetport is allocated. The additional memory area is solely for the of the LLDD and its location is specified by thetargetport->privatepointer. Value is Mandatory. Allowed to be zero.lsrqst_priv_szβ The LLDD sets this field to the amount of additional memory that it would like the nvmet-fc layer to allocate on the LLDD's behalf whenever a ls request structure is allocated. The additional memory area is solely for use by the LLDD and its location is specified by thels_request->privatepointer. Value is Mandatory. Allowed to be zero.
π Description π
Subsystem/Target Transport Entrypoints/Parameters:
...and that's where part 1 wraps, bestie β more coming, don't you dare close the tab π
Note: okay bestie, the FC-NVME layer may call the WRITEDATA operation multiple times for longer payloads. Not a one-and-done vibe. π
NVMET_FCOP_READDATA_RSPoperation: the LLDD is to send the payload data (described bysglist) to the host in 1 or more FC sequences (preferrably 1). If an error occurs during payload data transmission, the LLDD is to set thenvmefc_tgt_fcp_reqfcp_errorandtransferred_lengthfield, then consider the operation complete. On error, the LLDD is to not transmit the FCP_RSP iu. If all payload data is transferred successfully, the LLDD is to update thenvmefc_tgt_fcp_reqtransferred_lengthfield and may subsequently transmit the FCP_RSP iu payload (described byrspbuf,rspdma,rsplen). IfFCP_CONFis supported, the LLDD is to awaitFCP_CONFreception to confirm the RSP reception by the host. The LLDD may retramsit the FCP_RSP iu if necessary per FC-NVME. Upon transmission of the FCP_RSP iu ifFCP_CONFis not supported, or upon success/failure ofFCP_CONFif it is supported, the LLDD is to set thenvmefc_tgt_fcp_reqfcp_errorfield and consider the operation complete. β¨NVMET_FCOP_RSP: the LLDD is to transmit the FCP_RSP iu payload (described byrspbuf,rspdma,rsplen). IfFCP_CONFis supported, the LLDD is to awaitFCP_CONFreception to confirm the RSP reception by the host. The LLDD may retramsit the FCP_RSP iu ifFCP_CONFis not received per FC-NVME. Upon transmission of the FCP_RSP iu ifFCP_CONFis not supported, or upon success/failure ofFCP_CONFif it is supported, the LLDD is to set thenvmefc_tgt_fcp_reqfcp_errorfield and consider the operation complete. π«Ά
Upon completing the indicated operation, the LLDD is to set the status fields for the operation (tranferred_length and fcp_error status) in the request, then call the "done" routine indicated in the fcp request. After the operation completes, regardless of whether the FCP_RSP iu was successfully transmit, the LLDD-supplied exchange structure must remain valid until the transport calls the fcp_req_release callback to return ownership of the exchange structure back to the LLDD so that it may be used for another fcp command. π
When calling the done routine for READDATA or WRITEDATA operations, the fc-nvme layer may immediate convert, in the same thread and before returning to the LLDD, the fcp operation to the next operation for the fcp io and call the LLDDs fcp_op call again. If fields in the fcp request are to be accessed post the done call, the LLDD should save their values prior to calling the done routine, and inspect the save values after the done routine. π
Returns 0 on success, -<errno> on failure (Ex: -EIO). Entrypoint is Mandatory. periodt. π
π SEE ALSO π
- Kernel file:
./include/linux/nvme-fc-driver.h struct nvmefc_ls_req(9)struct nvmefc_ls_rsp(9)struct nvme_fc_port_info(9)struct nvmefc_fcp_req(9)struct nvme_fc_local_port(9)struct nvme_fc_remote_port(9)struct nvme_fc_port_template(9)struct nvmet_fc_port_info(9)struct nvmefc_tgt_fcp_req(9)struct nvmet_fc_target_port(9)
Thatβs the whole tea β: this page lives under ./include/linux, itβs stamped October 2026, and the page is struct nvme...get_template(9). Mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms