iser_initiator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * Copyright (c) 2004, 2005, 2006 Voltaire, Inc. All rights reserved.
  3. * Copyright (c) 2013 Mellanox Technologies. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/slab.h>
  35. #include <linux/mm.h>
  36. #include <linux/scatterlist.h>
  37. #include <linux/kfifo.h>
  38. #include <scsi/scsi_cmnd.h>
  39. #include <scsi/scsi_host.h>
  40. #include "iscsi_iser.h"
  41. /* Register user buffer memory and initialize passive rdma
  42. * dto descriptor. Total data size is stored in
  43. * iser_task->data[ISER_DIR_IN].data_len
  44. */
  45. static int iser_prepare_read_cmd(struct iscsi_task *task,
  46. unsigned int edtl)
  47. {
  48. struct iscsi_iser_task *iser_task = task->dd_data;
  49. struct iser_regd_buf *regd_buf;
  50. int err;
  51. struct iser_hdr *hdr = &iser_task->desc.iser_header;
  52. struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN];
  53. err = iser_dma_map_task_data(iser_task,
  54. buf_in,
  55. ISER_DIR_IN,
  56. DMA_FROM_DEVICE);
  57. if (err)
  58. return err;
  59. if (edtl > iser_task->data[ISER_DIR_IN].data_len) {
  60. iser_err("Total data length: %ld, less than EDTL: "
  61. "%d, in READ cmd BHS itt: %d, conn: 0x%p\n",
  62. iser_task->data[ISER_DIR_IN].data_len, edtl,
  63. task->itt, iser_task->iser_conn);
  64. return -EINVAL;
  65. }
  66. err = iser_reg_rdma_mem(iser_task,ISER_DIR_IN);
  67. if (err) {
  68. iser_err("Failed to set up Data-IN RDMA\n");
  69. return err;
  70. }
  71. regd_buf = &iser_task->rdma_regd[ISER_DIR_IN];
  72. hdr->flags |= ISER_RSV;
  73. hdr->read_stag = cpu_to_be32(regd_buf->reg.rkey);
  74. hdr->read_va = cpu_to_be64(regd_buf->reg.va);
  75. iser_dbg("Cmd itt:%d READ tags RKEY:%#.4X VA:%#llX\n",
  76. task->itt, regd_buf->reg.rkey,
  77. (unsigned long long)regd_buf->reg.va);
  78. return 0;
  79. }
  80. /* Register user buffer memory and initialize passive rdma
  81. * dto descriptor. Total data size is stored in
  82. * task->data[ISER_DIR_OUT].data_len
  83. */
  84. static int
  85. iser_prepare_write_cmd(struct iscsi_task *task,
  86. unsigned int imm_sz,
  87. unsigned int unsol_sz,
  88. unsigned int edtl)
  89. {
  90. struct iscsi_iser_task *iser_task = task->dd_data;
  91. struct iser_regd_buf *regd_buf;
  92. int err;
  93. struct iser_hdr *hdr = &iser_task->desc.iser_header;
  94. struct iser_data_buf *buf_out = &iser_task->data[ISER_DIR_OUT];
  95. struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1];
  96. err = iser_dma_map_task_data(iser_task,
  97. buf_out,
  98. ISER_DIR_OUT,
  99. DMA_TO_DEVICE);
  100. if (err)
  101. return err;
  102. if (edtl > iser_task->data[ISER_DIR_OUT].data_len) {
  103. iser_err("Total data length: %ld, less than EDTL: %d, "
  104. "in WRITE cmd BHS itt: %d, conn: 0x%p\n",
  105. iser_task->data[ISER_DIR_OUT].data_len,
  106. edtl, task->itt, task->conn);
  107. return -EINVAL;
  108. }
  109. err = iser_reg_rdma_mem(iser_task,ISER_DIR_OUT);
  110. if (err != 0) {
  111. iser_err("Failed to register write cmd RDMA mem\n");
  112. return err;
  113. }
  114. regd_buf = &iser_task->rdma_regd[ISER_DIR_OUT];
  115. if (unsol_sz < edtl) {
  116. hdr->flags |= ISER_WSV;
  117. hdr->write_stag = cpu_to_be32(regd_buf->reg.rkey);
  118. hdr->write_va = cpu_to_be64(regd_buf->reg.va + unsol_sz);
  119. iser_dbg("Cmd itt:%d, WRITE tags, RKEY:%#.4X "
  120. "VA:%#llX + unsol:%d\n",
  121. task->itt, regd_buf->reg.rkey,
  122. (unsigned long long)regd_buf->reg.va, unsol_sz);
  123. }
  124. if (imm_sz > 0) {
  125. iser_dbg("Cmd itt:%d, WRITE, adding imm.data sz: %d\n",
  126. task->itt, imm_sz);
  127. tx_dsg->addr = regd_buf->reg.va;
  128. tx_dsg->length = imm_sz;
  129. tx_dsg->lkey = regd_buf->reg.lkey;
  130. iser_task->desc.num_sge = 2;
  131. }
  132. return 0;
  133. }
  134. /* creates a new tx descriptor and adds header regd buffer */
  135. static void iser_create_send_desc(struct iser_conn *ib_conn,
  136. struct iser_tx_desc *tx_desc)
  137. {
  138. struct iser_device *device = ib_conn->device;
  139. ib_dma_sync_single_for_cpu(device->ib_device,
  140. tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE);
  141. memset(&tx_desc->iser_header, 0, sizeof(struct iser_hdr));
  142. tx_desc->iser_header.flags = ISER_VER;
  143. tx_desc->num_sge = 1;
  144. if (tx_desc->tx_sg[0].lkey != device->mr->lkey) {
  145. tx_desc->tx_sg[0].lkey = device->mr->lkey;
  146. iser_dbg("sdesc %p lkey mismatch, fixing\n", tx_desc);
  147. }
  148. }
  149. int iser_alloc_rx_descriptors(struct iser_conn *ib_conn)
  150. {
  151. int i, j;
  152. u64 dma_addr;
  153. struct iser_rx_desc *rx_desc;
  154. struct ib_sge *rx_sg;
  155. struct iser_device *device = ib_conn->device;
  156. ib_conn->rx_descs = kmalloc(ISER_QP_MAX_RECV_DTOS *
  157. sizeof(struct iser_rx_desc), GFP_KERNEL);
  158. if (!ib_conn->rx_descs)
  159. goto rx_desc_alloc_fail;
  160. rx_desc = ib_conn->rx_descs;
  161. for (i = 0; i < ISER_QP_MAX_RECV_DTOS; i++, rx_desc++) {
  162. dma_addr = ib_dma_map_single(device->ib_device, (void *)rx_desc,
  163. ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
  164. if (ib_dma_mapping_error(device->ib_device, dma_addr))
  165. goto rx_desc_dma_map_failed;
  166. rx_desc->dma_addr = dma_addr;
  167. rx_sg = &rx_desc->rx_sg;
  168. rx_sg->addr = rx_desc->dma_addr;
  169. rx_sg->length = ISER_RX_PAYLOAD_SIZE;
  170. rx_sg->lkey = device->mr->lkey;
  171. }
  172. ib_conn->rx_desc_head = 0;
  173. return 0;
  174. rx_desc_dma_map_failed:
  175. rx_desc = ib_conn->rx_descs;
  176. for (j = 0; j < i; j++, rx_desc++)
  177. ib_dma_unmap_single(device->ib_device, rx_desc->dma_addr,
  178. ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
  179. kfree(ib_conn->rx_descs);
  180. ib_conn->rx_descs = NULL;
  181. rx_desc_alloc_fail:
  182. iser_err("failed allocating rx descriptors / data buffers\n");
  183. return -ENOMEM;
  184. }
  185. void iser_free_rx_descriptors(struct iser_conn *ib_conn)
  186. {
  187. int i;
  188. struct iser_rx_desc *rx_desc;
  189. struct iser_device *device = ib_conn->device;
  190. if (!ib_conn->rx_descs)
  191. return;
  192. rx_desc = ib_conn->rx_descs;
  193. for (i = 0; i < ISER_QP_MAX_RECV_DTOS; i++, rx_desc++)
  194. ib_dma_unmap_single(device->ib_device, rx_desc->dma_addr,
  195. ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
  196. kfree(ib_conn->rx_descs);
  197. }
  198. static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
  199. {
  200. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  201. iser_dbg("req op %x flags %x\n", req->opcode, req->flags);
  202. /* check if this is the last login - going to full feature phase */
  203. if ((req->flags & ISCSI_FULL_FEATURE_PHASE) != ISCSI_FULL_FEATURE_PHASE)
  204. return 0;
  205. /*
  206. * Check that there is one posted recv buffer (for the last login
  207. * response) and no posted send buffers left - they must have been
  208. * consumed during previous login phases.
  209. */
  210. WARN_ON(iser_conn->ib_conn->post_recv_buf_count != 1);
  211. WARN_ON(atomic_read(&iser_conn->ib_conn->post_send_buf_count) != 0);
  212. iser_dbg("Initially post: %d\n", ISER_MIN_POSTED_RX);
  213. /* Initial post receive buffers */
  214. if (iser_post_recvm(iser_conn->ib_conn, ISER_MIN_POSTED_RX))
  215. return -ENOMEM;
  216. return 0;
  217. }
  218. /**
  219. * iser_send_command - send command PDU
  220. */
  221. int iser_send_command(struct iscsi_conn *conn,
  222. struct iscsi_task *task)
  223. {
  224. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  225. struct iscsi_iser_task *iser_task = task->dd_data;
  226. unsigned long edtl;
  227. int err;
  228. struct iser_data_buf *data_buf;
  229. struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)task->hdr;
  230. struct scsi_cmnd *sc = task->sc;
  231. struct iser_tx_desc *tx_desc = &iser_task->desc;
  232. edtl = ntohl(hdr->data_length);
  233. /* build the tx desc regd header and add it to the tx desc dto */
  234. tx_desc->type = ISCSI_TX_SCSI_COMMAND;
  235. iser_create_send_desc(iser_conn->ib_conn, tx_desc);
  236. if (hdr->flags & ISCSI_FLAG_CMD_READ)
  237. data_buf = &iser_task->data[ISER_DIR_IN];
  238. else
  239. data_buf = &iser_task->data[ISER_DIR_OUT];
  240. if (scsi_sg_count(sc)) { /* using a scatter list */
  241. data_buf->buf = scsi_sglist(sc);
  242. data_buf->size = scsi_sg_count(sc);
  243. }
  244. data_buf->data_len = scsi_bufflen(sc);
  245. if (hdr->flags & ISCSI_FLAG_CMD_READ) {
  246. err = iser_prepare_read_cmd(task, edtl);
  247. if (err)
  248. goto send_command_error;
  249. }
  250. if (hdr->flags & ISCSI_FLAG_CMD_WRITE) {
  251. err = iser_prepare_write_cmd(task,
  252. task->imm_count,
  253. task->imm_count +
  254. task->unsol_r2t.data_length,
  255. edtl);
  256. if (err)
  257. goto send_command_error;
  258. }
  259. iser_task->status = ISER_TASK_STATUS_STARTED;
  260. err = iser_post_send(iser_conn->ib_conn, tx_desc);
  261. if (!err)
  262. return 0;
  263. send_command_error:
  264. iser_err("conn %p failed task->itt %d err %d\n",conn, task->itt, err);
  265. return err;
  266. }
  267. /**
  268. * iser_send_data_out - send data out PDU
  269. */
  270. int iser_send_data_out(struct iscsi_conn *conn,
  271. struct iscsi_task *task,
  272. struct iscsi_data *hdr)
  273. {
  274. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  275. struct iscsi_iser_task *iser_task = task->dd_data;
  276. struct iser_tx_desc *tx_desc = NULL;
  277. struct iser_regd_buf *regd_buf;
  278. unsigned long buf_offset;
  279. unsigned long data_seg_len;
  280. uint32_t itt;
  281. int err = 0;
  282. struct ib_sge *tx_dsg;
  283. itt = (__force uint32_t)hdr->itt;
  284. data_seg_len = ntoh24(hdr->dlength);
  285. buf_offset = ntohl(hdr->offset);
  286. iser_dbg("%s itt %d dseg_len %d offset %d\n",
  287. __func__,(int)itt,(int)data_seg_len,(int)buf_offset);
  288. tx_desc = kmem_cache_zalloc(ig.desc_cache, GFP_ATOMIC);
  289. if (tx_desc == NULL) {
  290. iser_err("Failed to alloc desc for post dataout\n");
  291. return -ENOMEM;
  292. }
  293. tx_desc->type = ISCSI_TX_DATAOUT;
  294. tx_desc->iser_header.flags = ISER_VER;
  295. memcpy(&tx_desc->iscsi_header, hdr, sizeof(struct iscsi_hdr));
  296. /* build the tx desc */
  297. iser_initialize_task_headers(task, tx_desc);
  298. regd_buf = &iser_task->rdma_regd[ISER_DIR_OUT];
  299. tx_dsg = &tx_desc->tx_sg[1];
  300. tx_dsg->addr = regd_buf->reg.va + buf_offset;
  301. tx_dsg->length = data_seg_len;
  302. tx_dsg->lkey = regd_buf->reg.lkey;
  303. tx_desc->num_sge = 2;
  304. if (buf_offset + data_seg_len > iser_task->data[ISER_DIR_OUT].data_len) {
  305. iser_err("Offset:%ld & DSL:%ld in Data-Out "
  306. "inconsistent with total len:%ld, itt:%d\n",
  307. buf_offset, data_seg_len,
  308. iser_task->data[ISER_DIR_OUT].data_len, itt);
  309. err = -EINVAL;
  310. goto send_data_out_error;
  311. }
  312. iser_dbg("data-out itt: %d, offset: %ld, sz: %ld\n",
  313. itt, buf_offset, data_seg_len);
  314. err = iser_post_send(iser_conn->ib_conn, tx_desc);
  315. if (!err)
  316. return 0;
  317. send_data_out_error:
  318. kmem_cache_free(ig.desc_cache, tx_desc);
  319. iser_err("conn %p failed err %d\n",conn, err);
  320. return err;
  321. }
  322. int iser_send_control(struct iscsi_conn *conn,
  323. struct iscsi_task *task)
  324. {
  325. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  326. struct iscsi_iser_task *iser_task = task->dd_data;
  327. struct iser_tx_desc *mdesc = &iser_task->desc;
  328. unsigned long data_seg_len;
  329. int err = 0;
  330. struct iser_device *device;
  331. struct iser_conn *ib_conn = iser_conn->ib_conn;
  332. /* build the tx desc regd header and add it to the tx desc dto */
  333. mdesc->type = ISCSI_TX_CONTROL;
  334. iser_create_send_desc(iser_conn->ib_conn, mdesc);
  335. device = iser_conn->ib_conn->device;
  336. data_seg_len = ntoh24(task->hdr->dlength);
  337. if (data_seg_len > 0) {
  338. struct ib_sge *tx_dsg = &mdesc->tx_sg[1];
  339. if (task != conn->login_task) {
  340. iser_err("data present on non login task!!!\n");
  341. goto send_control_error;
  342. }
  343. ib_dma_sync_single_for_cpu(device->ib_device,
  344. ib_conn->login_req_dma, task->data_count,
  345. DMA_TO_DEVICE);
  346. memcpy(iser_conn->ib_conn->login_req_buf, task->data,
  347. task->data_count);
  348. ib_dma_sync_single_for_device(device->ib_device,
  349. ib_conn->login_req_dma, task->data_count,
  350. DMA_TO_DEVICE);
  351. tx_dsg->addr = iser_conn->ib_conn->login_req_dma;
  352. tx_dsg->length = task->data_count;
  353. tx_dsg->lkey = device->mr->lkey;
  354. mdesc->num_sge = 2;
  355. }
  356. if (task == conn->login_task) {
  357. err = iser_post_recvl(iser_conn->ib_conn);
  358. if (err)
  359. goto send_control_error;
  360. err = iser_post_rx_bufs(conn, task->hdr);
  361. if (err)
  362. goto send_control_error;
  363. }
  364. err = iser_post_send(iser_conn->ib_conn, mdesc);
  365. if (!err)
  366. return 0;
  367. send_control_error:
  368. iser_err("conn %p failed err %d\n",conn, err);
  369. return err;
  370. }
  371. /**
  372. * iser_rcv_dto_completion - recv DTO completion
  373. */
  374. void iser_rcv_completion(struct iser_rx_desc *rx_desc,
  375. unsigned long rx_xfer_len,
  376. struct iser_conn *ib_conn)
  377. {
  378. struct iscsi_iser_conn *conn = ib_conn->iser_conn;
  379. struct iscsi_hdr *hdr;
  380. u64 rx_dma;
  381. int rx_buflen, outstanding, count, err;
  382. /* differentiate between login to all other PDUs */
  383. if ((char *)rx_desc == ib_conn->login_resp_buf) {
  384. rx_dma = ib_conn->login_resp_dma;
  385. rx_buflen = ISER_RX_LOGIN_SIZE;
  386. } else {
  387. rx_dma = rx_desc->dma_addr;
  388. rx_buflen = ISER_RX_PAYLOAD_SIZE;
  389. }
  390. ib_dma_sync_single_for_cpu(ib_conn->device->ib_device, rx_dma,
  391. rx_buflen, DMA_FROM_DEVICE);
  392. hdr = &rx_desc->iscsi_header;
  393. iser_dbg("op 0x%x itt 0x%x dlen %d\n", hdr->opcode,
  394. hdr->itt, (int)(rx_xfer_len - ISER_HEADERS_LEN));
  395. iscsi_iser_recv(conn->iscsi_conn, hdr,
  396. rx_desc->data, rx_xfer_len - ISER_HEADERS_LEN);
  397. ib_dma_sync_single_for_device(ib_conn->device->ib_device, rx_dma,
  398. rx_buflen, DMA_FROM_DEVICE);
  399. /* decrementing conn->post_recv_buf_count only --after-- freeing the *
  400. * task eliminates the need to worry on tasks which are completed in *
  401. * parallel to the execution of iser_conn_term. So the code that waits *
  402. * for the posted rx bufs refcount to become zero handles everything */
  403. conn->ib_conn->post_recv_buf_count--;
  404. if (rx_dma == ib_conn->login_resp_dma)
  405. return;
  406. outstanding = ib_conn->post_recv_buf_count;
  407. if (outstanding + ISER_MIN_POSTED_RX <= ISER_QP_MAX_RECV_DTOS) {
  408. count = min(ISER_QP_MAX_RECV_DTOS - outstanding,
  409. ISER_MIN_POSTED_RX);
  410. err = iser_post_recvm(ib_conn, count);
  411. if (err)
  412. iser_err("posting %d rx bufs err %d\n", count, err);
  413. }
  414. }
  415. void iser_snd_completion(struct iser_tx_desc *tx_desc,
  416. struct iser_conn *ib_conn)
  417. {
  418. struct iscsi_task *task;
  419. struct iser_device *device = ib_conn->device;
  420. if (tx_desc->type == ISCSI_TX_DATAOUT) {
  421. ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr,
  422. ISER_HEADERS_LEN, DMA_TO_DEVICE);
  423. kmem_cache_free(ig.desc_cache, tx_desc);
  424. }
  425. atomic_dec(&ib_conn->post_send_buf_count);
  426. if (tx_desc->type == ISCSI_TX_CONTROL) {
  427. /* this arithmetic is legal by libiscsi dd_data allocation */
  428. task = (void *) ((long)(void *)tx_desc -
  429. sizeof(struct iscsi_task));
  430. if (task->hdr->itt == RESERVED_ITT)
  431. iscsi_put_task(task);
  432. }
  433. }
  434. void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
  435. {
  436. iser_task->status = ISER_TASK_STATUS_INIT;
  437. iser_task->dir[ISER_DIR_IN] = 0;
  438. iser_task->dir[ISER_DIR_OUT] = 0;
  439. iser_task->data[ISER_DIR_IN].data_len = 0;
  440. iser_task->data[ISER_DIR_OUT].data_len = 0;
  441. memset(&iser_task->rdma_regd[ISER_DIR_IN], 0,
  442. sizeof(struct iser_regd_buf));
  443. memset(&iser_task->rdma_regd[ISER_DIR_OUT], 0,
  444. sizeof(struct iser_regd_buf));
  445. }
  446. void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
  447. {
  448. int is_rdma_aligned = 1;
  449. struct iser_regd_buf *regd;
  450. /* if we were reading, copy back to unaligned sglist,
  451. * anyway dma_unmap and free the copy
  452. */
  453. if (iser_task->data_copy[ISER_DIR_IN].copy_buf != NULL) {
  454. is_rdma_aligned = 0;
  455. iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_IN);
  456. }
  457. if (iser_task->data_copy[ISER_DIR_OUT].copy_buf != NULL) {
  458. is_rdma_aligned = 0;
  459. iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT);
  460. }
  461. if (iser_task->dir[ISER_DIR_IN]) {
  462. regd = &iser_task->rdma_regd[ISER_DIR_IN];
  463. if (regd->reg.is_fmr)
  464. iser_unreg_mem(&regd->reg);
  465. }
  466. if (iser_task->dir[ISER_DIR_OUT]) {
  467. regd = &iser_task->rdma_regd[ISER_DIR_OUT];
  468. if (regd->reg.is_fmr)
  469. iser_unreg_mem(&regd->reg);
  470. }
  471. /* if the data was unaligned, it was already unmapped and then copied */
  472. if (is_rdma_aligned)
  473. iser_dma_unmap_task_data(iser_task);
  474. }