iser_initiator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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->rx_descs)
  190. return;
  191. rx_desc = ib_conn->rx_descs;
  192. for (i = 0; i < ISER_QP_MAX_RECV_DTOS; i++, rx_desc++)
  193. ib_dma_unmap_single(device->ib_device, rx_desc->dma_addr,
  194. ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
  195. kfree(ib_conn->rx_descs);
  196. }
  197. static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
  198. {
  199. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  200. iser_dbg("req op %x flags %x\n", req->opcode, req->flags);
  201. /* check if this is the last login - going to full feature phase */
  202. if ((req->flags & ISCSI_FULL_FEATURE_PHASE) != ISCSI_FULL_FEATURE_PHASE)
  203. return 0;
  204. /*
  205. * Check that there is one posted recv buffer (for the last login
  206. * response) and no posted send buffers left - they must have been
  207. * consumed during previous login phases.
  208. */
  209. WARN_ON(iser_conn->ib_conn->post_recv_buf_count != 1);
  210. WARN_ON(atomic_read(&iser_conn->ib_conn->post_send_buf_count) != 0);
  211. iser_dbg("Initially post: %d\n", ISER_MIN_POSTED_RX);
  212. /* Initial post receive buffers */
  213. if (iser_post_recvm(iser_conn->ib_conn, ISER_MIN_POSTED_RX))
  214. return -ENOMEM;
  215. return 0;
  216. }
  217. /**
  218. * iser_send_command - send command PDU
  219. */
  220. int iser_send_command(struct iscsi_conn *conn,
  221. struct iscsi_task *task)
  222. {
  223. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  224. struct iscsi_iser_task *iser_task = task->dd_data;
  225. unsigned long edtl;
  226. int err;
  227. struct iser_data_buf *data_buf;
  228. struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)task->hdr;
  229. struct scsi_cmnd *sc = task->sc;
  230. struct iser_tx_desc *tx_desc = &iser_task->desc;
  231. edtl = ntohl(hdr->data_length);
  232. /* build the tx desc regd header and add it to the tx desc dto */
  233. tx_desc->type = ISCSI_TX_SCSI_COMMAND;
  234. iser_create_send_desc(iser_conn->ib_conn, tx_desc);
  235. if (hdr->flags & ISCSI_FLAG_CMD_READ)
  236. data_buf = &iser_task->data[ISER_DIR_IN];
  237. else
  238. data_buf = &iser_task->data[ISER_DIR_OUT];
  239. if (scsi_sg_count(sc)) { /* using a scatter list */
  240. data_buf->buf = scsi_sglist(sc);
  241. data_buf->size = scsi_sg_count(sc);
  242. }
  243. data_buf->data_len = scsi_bufflen(sc);
  244. if (hdr->flags & ISCSI_FLAG_CMD_READ) {
  245. err = iser_prepare_read_cmd(task, edtl);
  246. if (err)
  247. goto send_command_error;
  248. }
  249. if (hdr->flags & ISCSI_FLAG_CMD_WRITE) {
  250. err = iser_prepare_write_cmd(task,
  251. task->imm_count,
  252. task->imm_count +
  253. task->unsol_r2t.data_length,
  254. edtl);
  255. if (err)
  256. goto send_command_error;
  257. }
  258. iser_task->status = ISER_TASK_STATUS_STARTED;
  259. err = iser_post_send(iser_conn->ib_conn, tx_desc);
  260. if (!err)
  261. return 0;
  262. send_command_error:
  263. iser_err("conn %p failed task->itt %d err %d\n",conn, task->itt, err);
  264. return err;
  265. }
  266. /**
  267. * iser_send_data_out - send data out PDU
  268. */
  269. int iser_send_data_out(struct iscsi_conn *conn,
  270. struct iscsi_task *task,
  271. struct iscsi_data *hdr)
  272. {
  273. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  274. struct iscsi_iser_task *iser_task = task->dd_data;
  275. struct iser_tx_desc *tx_desc = NULL;
  276. struct iser_regd_buf *regd_buf;
  277. unsigned long buf_offset;
  278. unsigned long data_seg_len;
  279. uint32_t itt;
  280. int err = 0;
  281. struct ib_sge *tx_dsg;
  282. itt = (__force uint32_t)hdr->itt;
  283. data_seg_len = ntoh24(hdr->dlength);
  284. buf_offset = ntohl(hdr->offset);
  285. iser_dbg("%s itt %d dseg_len %d offset %d\n",
  286. __func__,(int)itt,(int)data_seg_len,(int)buf_offset);
  287. tx_desc = kmem_cache_zalloc(ig.desc_cache, GFP_ATOMIC);
  288. if (tx_desc == NULL) {
  289. iser_err("Failed to alloc desc for post dataout\n");
  290. return -ENOMEM;
  291. }
  292. tx_desc->type = ISCSI_TX_DATAOUT;
  293. tx_desc->iser_header.flags = ISER_VER;
  294. memcpy(&tx_desc->iscsi_header, hdr, sizeof(struct iscsi_hdr));
  295. /* build the tx desc */
  296. iser_initialize_task_headers(task, tx_desc);
  297. regd_buf = &iser_task->rdma_regd[ISER_DIR_OUT];
  298. tx_dsg = &tx_desc->tx_sg[1];
  299. tx_dsg->addr = regd_buf->reg.va + buf_offset;
  300. tx_dsg->length = data_seg_len;
  301. tx_dsg->lkey = regd_buf->reg.lkey;
  302. tx_desc->num_sge = 2;
  303. if (buf_offset + data_seg_len > iser_task->data[ISER_DIR_OUT].data_len) {
  304. iser_err("Offset:%ld & DSL:%ld in Data-Out "
  305. "inconsistent with total len:%ld, itt:%d\n",
  306. buf_offset, data_seg_len,
  307. iser_task->data[ISER_DIR_OUT].data_len, itt);
  308. err = -EINVAL;
  309. goto send_data_out_error;
  310. }
  311. iser_dbg("data-out itt: %d, offset: %ld, sz: %ld\n",
  312. itt, buf_offset, data_seg_len);
  313. err = iser_post_send(iser_conn->ib_conn, tx_desc);
  314. if (!err)
  315. return 0;
  316. send_data_out_error:
  317. kmem_cache_free(ig.desc_cache, tx_desc);
  318. iser_err("conn %p failed err %d\n",conn, err);
  319. return err;
  320. }
  321. int iser_send_control(struct iscsi_conn *conn,
  322. struct iscsi_task *task)
  323. {
  324. struct iscsi_iser_conn *iser_conn = conn->dd_data;
  325. struct iscsi_iser_task *iser_task = task->dd_data;
  326. struct iser_tx_desc *mdesc = &iser_task->desc;
  327. unsigned long data_seg_len;
  328. int err = 0;
  329. struct iser_device *device;
  330. struct iser_conn *ib_conn = iser_conn->ib_conn;
  331. /* build the tx desc regd header and add it to the tx desc dto */
  332. mdesc->type = ISCSI_TX_CONTROL;
  333. iser_create_send_desc(iser_conn->ib_conn, mdesc);
  334. device = iser_conn->ib_conn->device;
  335. data_seg_len = ntoh24(task->hdr->dlength);
  336. if (data_seg_len > 0) {
  337. struct ib_sge *tx_dsg = &mdesc->tx_sg[1];
  338. if (task != conn->login_task) {
  339. iser_err("data present on non login task!!!\n");
  340. goto send_control_error;
  341. }
  342. ib_dma_sync_single_for_cpu(device->ib_device,
  343. ib_conn->login_req_dma, task->data_count,
  344. DMA_TO_DEVICE);
  345. memcpy(iser_conn->ib_conn->login_req_buf, task->data,
  346. task->data_count);
  347. ib_dma_sync_single_for_device(device->ib_device,
  348. ib_conn->login_req_dma, task->data_count,
  349. DMA_TO_DEVICE);
  350. tx_dsg->addr = iser_conn->ib_conn->login_req_dma;
  351. tx_dsg->length = task->data_count;
  352. tx_dsg->lkey = device->mr->lkey;
  353. mdesc->num_sge = 2;
  354. }
  355. if (task == conn->login_task) {
  356. err = iser_post_recvl(iser_conn->ib_conn);
  357. if (err)
  358. goto send_control_error;
  359. err = iser_post_rx_bufs(conn, task->hdr);
  360. if (err)
  361. goto send_control_error;
  362. }
  363. err = iser_post_send(iser_conn->ib_conn, mdesc);
  364. if (!err)
  365. return 0;
  366. send_control_error:
  367. iser_err("conn %p failed err %d\n",conn, err);
  368. return err;
  369. }
  370. /**
  371. * iser_rcv_dto_completion - recv DTO completion
  372. */
  373. void iser_rcv_completion(struct iser_rx_desc *rx_desc,
  374. unsigned long rx_xfer_len,
  375. struct iser_conn *ib_conn)
  376. {
  377. struct iscsi_iser_conn *conn = ib_conn->iser_conn;
  378. struct iscsi_hdr *hdr;
  379. u64 rx_dma;
  380. int rx_buflen, outstanding, count, err;
  381. /* differentiate between login to all other PDUs */
  382. if ((char *)rx_desc == ib_conn->login_resp_buf) {
  383. rx_dma = ib_conn->login_resp_dma;
  384. rx_buflen = ISER_RX_LOGIN_SIZE;
  385. } else {
  386. rx_dma = rx_desc->dma_addr;
  387. rx_buflen = ISER_RX_PAYLOAD_SIZE;
  388. }
  389. ib_dma_sync_single_for_cpu(ib_conn->device->ib_device, rx_dma,
  390. rx_buflen, DMA_FROM_DEVICE);
  391. hdr = &rx_desc->iscsi_header;
  392. iser_dbg("op 0x%x itt 0x%x dlen %d\n", hdr->opcode,
  393. hdr->itt, (int)(rx_xfer_len - ISER_HEADERS_LEN));
  394. iscsi_iser_recv(conn->iscsi_conn, hdr,
  395. rx_desc->data, rx_xfer_len - ISER_HEADERS_LEN);
  396. ib_dma_sync_single_for_device(ib_conn->device->ib_device, rx_dma,
  397. rx_buflen, DMA_FROM_DEVICE);
  398. /* decrementing conn->post_recv_buf_count only --after-- freeing the *
  399. * task eliminates the need to worry on tasks which are completed in *
  400. * parallel to the execution of iser_conn_term. So the code that waits *
  401. * for the posted rx bufs refcount to become zero handles everything */
  402. conn->ib_conn->post_recv_buf_count--;
  403. if (rx_dma == ib_conn->login_resp_dma)
  404. return;
  405. outstanding = ib_conn->post_recv_buf_count;
  406. if (outstanding + ISER_MIN_POSTED_RX <= ISER_QP_MAX_RECV_DTOS) {
  407. count = min(ISER_QP_MAX_RECV_DTOS - outstanding,
  408. ISER_MIN_POSTED_RX);
  409. err = iser_post_recvm(ib_conn, count);
  410. if (err)
  411. iser_err("posting %d rx bufs err %d\n", count, err);
  412. }
  413. }
  414. void iser_snd_completion(struct iser_tx_desc *tx_desc,
  415. struct iser_conn *ib_conn)
  416. {
  417. struct iscsi_task *task;
  418. struct iser_device *device = ib_conn->device;
  419. if (tx_desc->type == ISCSI_TX_DATAOUT) {
  420. ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr,
  421. ISER_HEADERS_LEN, DMA_TO_DEVICE);
  422. kmem_cache_free(ig.desc_cache, tx_desc);
  423. }
  424. atomic_dec(&ib_conn->post_send_buf_count);
  425. if (tx_desc->type == ISCSI_TX_CONTROL) {
  426. /* this arithmetic is legal by libiscsi dd_data allocation */
  427. task = (void *) ((long)(void *)tx_desc -
  428. sizeof(struct iscsi_task));
  429. if (task->hdr->itt == RESERVED_ITT)
  430. iscsi_put_task(task);
  431. }
  432. }
  433. void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
  434. {
  435. iser_task->status = ISER_TASK_STATUS_INIT;
  436. iser_task->dir[ISER_DIR_IN] = 0;
  437. iser_task->dir[ISER_DIR_OUT] = 0;
  438. iser_task->data[ISER_DIR_IN].data_len = 0;
  439. iser_task->data[ISER_DIR_OUT].data_len = 0;
  440. memset(&iser_task->rdma_regd[ISER_DIR_IN], 0,
  441. sizeof(struct iser_regd_buf));
  442. memset(&iser_task->rdma_regd[ISER_DIR_OUT], 0,
  443. sizeof(struct iser_regd_buf));
  444. }
  445. void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
  446. {
  447. int is_rdma_aligned = 1;
  448. struct iser_regd_buf *regd;
  449. /* if we were reading, copy back to unaligned sglist,
  450. * anyway dma_unmap and free the copy
  451. */
  452. if (iser_task->data_copy[ISER_DIR_IN].copy_buf != NULL) {
  453. is_rdma_aligned = 0;
  454. iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_IN);
  455. }
  456. if (iser_task->data_copy[ISER_DIR_OUT].copy_buf != NULL) {
  457. is_rdma_aligned = 0;
  458. iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT);
  459. }
  460. if (iser_task->dir[ISER_DIR_IN]) {
  461. regd = &iser_task->rdma_regd[ISER_DIR_IN];
  462. if (regd->reg.is_fmr)
  463. iser_unreg_mem(&regd->reg);
  464. }
  465. if (iser_task->dir[ISER_DIR_OUT]) {
  466. regd = &iser_task->rdma_regd[ISER_DIR_OUT];
  467. if (regd->reg.is_fmr)
  468. iser_unreg_mem(&regd->reg);
  469. }
  470. /* if the data was unaligned, it was already unmapped and then copied */
  471. if (is_rdma_aligned)
  472. iser_dma_unmap_task_data(iser_task);
  473. }