nvme-fc-driver.h 47 KB

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