iser_initiator.c 16 KB

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