diff options
author | Christoph Hellwig <hch@lst.de> | 2016-02-24 12:24:07 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-11 00:48:49 -0500 |
commit | d1ca2ed7dcf859dcb7fc642d4d3ed42c1693d20c (patch) | |
tree | 4d1ff5dfbeda3ec715e3d117646d419403b6ccba /drivers/infiniband/ulp/isert/ib_isert.c | |
parent | 9679cc51eb138137bcc96560bf4e04cc047fcd20 (diff) |
iser-target: Kill struct isert_rdma_wr
There is exactly one instance per struct isert_cmd, so merge the two to
simplify everyones life.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband/ulp/isert/ib_isert.c')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 219 |
1 files changed, 107 insertions, 112 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 4269f22ccfbf..b432a29e46a8 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -49,13 +49,11 @@ static struct workqueue_struct *isert_release_wq; | |||
49 | static void | 49 | static void |
50 | isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn); | 50 | isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn); |
51 | static int | 51 | static int |
52 | isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | 52 | isert_map_rdma(struct isert_cmd *isert_cmd, struct iscsi_conn *conn); |
53 | struct isert_rdma_wr *wr); | ||
54 | static void | 53 | static void |
55 | isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn); | 54 | isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn); |
56 | static int | 55 | static int |
57 | isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | 56 | isert_reg_rdma(struct isert_cmd *isert_cmd, struct iscsi_conn *conn); |
58 | struct isert_rdma_wr *wr); | ||
59 | static int | 57 | static int |
60 | isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd); | 58 | isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd); |
61 | static int | 59 | static int |
@@ -1084,7 +1082,7 @@ isert_init_send_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | |||
1084 | { | 1082 | { |
1085 | struct iser_tx_desc *tx_desc = &isert_cmd->tx_desc; | 1083 | struct iser_tx_desc *tx_desc = &isert_cmd->tx_desc; |
1086 | 1084 | ||
1087 | isert_cmd->rdma_wr.iser_ib_op = ISER_IB_SEND; | 1085 | isert_cmd->iser_ib_op = ISER_IB_SEND; |
1088 | tx_desc->tx_cqe.done = isert_send_done; | 1086 | tx_desc->tx_cqe.done = isert_send_done; |
1089 | send_wr->wr_cqe = &tx_desc->tx_cqe; | 1087 | send_wr->wr_cqe = &tx_desc->tx_cqe; |
1090 | 1088 | ||
@@ -1684,54 +1682,50 @@ isert_unmap_data_buf(struct isert_conn *isert_conn, struct isert_data_buf *data) | |||
1684 | static void | 1682 | static void |
1685 | isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) | 1683 | isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) |
1686 | { | 1684 | { |
1687 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
1688 | |||
1689 | isert_dbg("Cmd %p\n", isert_cmd); | 1685 | isert_dbg("Cmd %p\n", isert_cmd); |
1690 | 1686 | ||
1691 | if (wr->data.sg) { | 1687 | if (isert_cmd->data.sg) { |
1692 | isert_dbg("Cmd %p unmap_sg op\n", isert_cmd); | 1688 | isert_dbg("Cmd %p unmap_sg op\n", isert_cmd); |
1693 | isert_unmap_data_buf(isert_conn, &wr->data); | 1689 | isert_unmap_data_buf(isert_conn, &isert_cmd->data); |
1694 | } | 1690 | } |
1695 | 1691 | ||
1696 | if (wr->rdma_wr) { | 1692 | if (isert_cmd->rdma_wr) { |
1697 | isert_dbg("Cmd %p free send_wr\n", isert_cmd); | 1693 | isert_dbg("Cmd %p free send_wr\n", isert_cmd); |
1698 | kfree(wr->rdma_wr); | 1694 | kfree(isert_cmd->rdma_wr); |
1699 | wr->rdma_wr = NULL; | 1695 | isert_cmd->rdma_wr = NULL; |
1700 | } | 1696 | } |
1701 | 1697 | ||
1702 | if (wr->ib_sge) { | 1698 | if (isert_cmd->ib_sge) { |
1703 | isert_dbg("Cmd %p free ib_sge\n", isert_cmd); | 1699 | isert_dbg("Cmd %p free ib_sge\n", isert_cmd); |
1704 | kfree(wr->ib_sge); | 1700 | kfree(isert_cmd->ib_sge); |
1705 | wr->ib_sge = NULL; | 1701 | isert_cmd->ib_sge = NULL; |
1706 | } | 1702 | } |
1707 | } | 1703 | } |
1708 | 1704 | ||
1709 | static void | 1705 | static void |
1710 | isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) | 1706 | isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) |
1711 | { | 1707 | { |
1712 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
1713 | |||
1714 | isert_dbg("Cmd %p\n", isert_cmd); | 1708 | isert_dbg("Cmd %p\n", isert_cmd); |
1715 | 1709 | ||
1716 | if (wr->fr_desc) { | 1710 | if (isert_cmd->fr_desc) { |
1717 | isert_dbg("Cmd %p free fr_desc %p\n", isert_cmd, wr->fr_desc); | 1711 | isert_dbg("Cmd %p free fr_desc %p\n", isert_cmd, isert_cmd->fr_desc); |
1718 | if (wr->fr_desc->ind & ISERT_PROTECTED) { | 1712 | if (isert_cmd->fr_desc->ind & ISERT_PROTECTED) { |
1719 | isert_unmap_data_buf(isert_conn, &wr->prot); | 1713 | isert_unmap_data_buf(isert_conn, &isert_cmd->prot); |
1720 | wr->fr_desc->ind &= ~ISERT_PROTECTED; | 1714 | isert_cmd->fr_desc->ind &= ~ISERT_PROTECTED; |
1721 | } | 1715 | } |
1722 | spin_lock_bh(&isert_conn->pool_lock); | 1716 | spin_lock_bh(&isert_conn->pool_lock); |
1723 | list_add_tail(&wr->fr_desc->list, &isert_conn->fr_pool); | 1717 | list_add_tail(&isert_cmd->fr_desc->list, &isert_conn->fr_pool); |
1724 | spin_unlock_bh(&isert_conn->pool_lock); | 1718 | spin_unlock_bh(&isert_conn->pool_lock); |
1725 | wr->fr_desc = NULL; | 1719 | isert_cmd->fr_desc = NULL; |
1726 | } | 1720 | } |
1727 | 1721 | ||
1728 | if (wr->data.sg) { | 1722 | if (isert_cmd->data.sg) { |
1729 | isert_dbg("Cmd %p unmap_sg op\n", isert_cmd); | 1723 | isert_dbg("Cmd %p unmap_sg op\n", isert_cmd); |
1730 | isert_unmap_data_buf(isert_conn, &wr->data); | 1724 | isert_unmap_data_buf(isert_conn, &isert_cmd->data); |
1731 | } | 1725 | } |
1732 | 1726 | ||
1733 | wr->ib_sge = NULL; | 1727 | isert_cmd->ib_sge = NULL; |
1734 | wr->rdma_wr = NULL; | 1728 | isert_cmd->rdma_wr = NULL; |
1735 | } | 1729 | } |
1736 | 1730 | ||
1737 | static void | 1731 | static void |
@@ -1889,7 +1883,6 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1889 | struct isert_device *device = isert_conn->device; | 1883 | struct isert_device *device = isert_conn->device; |
1890 | struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); | 1884 | struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); |
1891 | struct isert_cmd *isert_cmd = desc->isert_cmd; | 1885 | struct isert_cmd *isert_cmd = desc->isert_cmd; |
1892 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
1893 | struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd; | 1886 | struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd; |
1894 | int ret = 0; | 1887 | int ret = 0; |
1895 | 1888 | ||
@@ -1903,13 +1896,14 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1903 | 1896 | ||
1904 | isert_dbg("Cmd %p\n", isert_cmd); | 1897 | isert_dbg("Cmd %p\n", isert_cmd); |
1905 | 1898 | ||
1906 | if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) { | 1899 | if (isert_cmd->fr_desc && isert_cmd->fr_desc->ind & ISERT_PROTECTED) { |
1907 | ret = isert_check_pi_status(cmd, wr->fr_desc->pi_ctx->sig_mr); | 1900 | ret = isert_check_pi_status(cmd, |
1908 | wr->fr_desc->ind &= ~ISERT_PROTECTED; | 1901 | isert_cmd->fr_desc->pi_ctx->sig_mr); |
1902 | isert_cmd->fr_desc->ind &= ~ISERT_PROTECTED; | ||
1909 | } | 1903 | } |
1910 | 1904 | ||
1911 | device->unreg_rdma_mem(isert_cmd, isert_conn); | 1905 | device->unreg_rdma_mem(isert_cmd, isert_conn); |
1912 | wr->rdma_wr_num = 0; | 1906 | isert_cmd->rdma_wr_num = 0; |
1913 | if (ret) | 1907 | if (ret) |
1914 | transport_send_check_condition_and_sense(cmd, cmd->pi_err, 0); | 1908 | transport_send_check_condition_and_sense(cmd, cmd->pi_err, 0); |
1915 | else | 1909 | else |
@@ -1923,7 +1917,6 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1923 | struct isert_device *device = isert_conn->device; | 1917 | struct isert_device *device = isert_conn->device; |
1924 | struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); | 1918 | struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); |
1925 | struct isert_cmd *isert_cmd = desc->isert_cmd; | 1919 | struct isert_cmd *isert_cmd = desc->isert_cmd; |
1926 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
1927 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; | 1920 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1928 | struct se_cmd *se_cmd = &cmd->se_cmd; | 1921 | struct se_cmd *se_cmd = &cmd->se_cmd; |
1929 | int ret = 0; | 1922 | int ret = 0; |
@@ -1938,16 +1931,16 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1938 | 1931 | ||
1939 | isert_dbg("Cmd %p\n", isert_cmd); | 1932 | isert_dbg("Cmd %p\n", isert_cmd); |
1940 | 1933 | ||
1941 | if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) { | 1934 | if (isert_cmd->fr_desc && isert_cmd->fr_desc->ind & ISERT_PROTECTED) { |
1942 | ret = isert_check_pi_status(se_cmd, | 1935 | ret = isert_check_pi_status(se_cmd, |
1943 | wr->fr_desc->pi_ctx->sig_mr); | 1936 | isert_cmd->fr_desc->pi_ctx->sig_mr); |
1944 | wr->fr_desc->ind &= ~ISERT_PROTECTED; | 1937 | isert_cmd->fr_desc->ind &= ~ISERT_PROTECTED; |
1945 | } | 1938 | } |
1946 | 1939 | ||
1947 | iscsit_stop_dataout_timer(cmd); | 1940 | iscsit_stop_dataout_timer(cmd); |
1948 | device->unreg_rdma_mem(isert_cmd, isert_conn); | 1941 | device->unreg_rdma_mem(isert_cmd, isert_conn); |
1949 | cmd->write_data_done = wr->data.len; | 1942 | cmd->write_data_done = isert_cmd->data.len; |
1950 | wr->rdma_wr_num = 0; | 1943 | isert_cmd->rdma_wr_num = 0; |
1951 | 1944 | ||
1952 | isert_dbg("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); | 1945 | isert_dbg("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); |
1953 | spin_lock_bh(&cmd->istate_lock); | 1946 | spin_lock_bh(&cmd->istate_lock); |
@@ -2335,13 +2328,12 @@ isert_build_rdma_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, | |||
2335 | } | 2328 | } |
2336 | 2329 | ||
2337 | static int | 2330 | static int |
2338 | isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | 2331 | isert_map_rdma(struct isert_cmd *isert_cmd, struct iscsi_conn *conn) |
2339 | struct isert_rdma_wr *wr) | ||
2340 | { | 2332 | { |
2333 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; | ||
2341 | struct se_cmd *se_cmd = &cmd->se_cmd; | 2334 | struct se_cmd *se_cmd = &cmd->se_cmd; |
2342 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | ||
2343 | struct isert_conn *isert_conn = conn->context; | 2335 | struct isert_conn *isert_conn = conn->context; |
2344 | struct isert_data_buf *data = &wr->data; | 2336 | struct isert_data_buf *data = &isert_cmd->data; |
2345 | struct ib_rdma_wr *rdma_wr; | 2337 | struct ib_rdma_wr *rdma_wr; |
2346 | struct ib_sge *ib_sge; | 2338 | struct ib_sge *ib_sge; |
2347 | u32 offset, data_len, data_left, rdma_write_max, va_offset = 0; | 2339 | u32 offset, data_len, data_left, rdma_write_max, va_offset = 0; |
@@ -2349,10 +2341,12 @@ isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2349 | 2341 | ||
2350 | isert_cmd->tx_desc.isert_cmd = isert_cmd; | 2342 | isert_cmd->tx_desc.isert_cmd = isert_cmd; |
2351 | 2343 | ||
2352 | offset = wr->iser_ib_op == ISER_IB_RDMA_READ ? cmd->write_data_done : 0; | 2344 | offset = isert_cmd->iser_ib_op == ISER_IB_RDMA_READ ? |
2345 | cmd->write_data_done : 0; | ||
2353 | ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg, | 2346 | ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg, |
2354 | se_cmd->t_data_nents, se_cmd->data_length, | 2347 | se_cmd->t_data_nents, se_cmd->data_length, |
2355 | offset, wr->iser_ib_op, &wr->data); | 2348 | offset, isert_cmd->iser_ib_op, |
2349 | &isert_cmd->data); | ||
2356 | if (ret) | 2350 | if (ret) |
2357 | return ret; | 2351 | return ret; |
2358 | 2352 | ||
@@ -2365,45 +2359,44 @@ isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2365 | ret = -ENOMEM; | 2359 | ret = -ENOMEM; |
2366 | goto unmap_cmd; | 2360 | goto unmap_cmd; |
2367 | } | 2361 | } |
2368 | wr->ib_sge = ib_sge; | 2362 | isert_cmd->ib_sge = ib_sge; |
2369 | 2363 | ||
2370 | wr->rdma_wr_num = DIV_ROUND_UP(data->nents, isert_conn->max_sge); | 2364 | isert_cmd->rdma_wr_num = DIV_ROUND_UP(data->nents, isert_conn->max_sge); |
2371 | wr->rdma_wr = kzalloc(sizeof(struct ib_rdma_wr) * wr->rdma_wr_num, | 2365 | isert_cmd->rdma_wr = kzalloc(sizeof(struct ib_rdma_wr) * |
2372 | GFP_KERNEL); | 2366 | isert_cmd->rdma_wr_num, GFP_KERNEL); |
2373 | if (!wr->rdma_wr) { | 2367 | if (!isert_cmd->rdma_wr) { |
2374 | isert_dbg("Unable to allocate wr->rdma_wr\n"); | 2368 | isert_dbg("Unable to allocate isert_cmd->rdma_wr\n"); |
2375 | ret = -ENOMEM; | 2369 | ret = -ENOMEM; |
2376 | goto unmap_cmd; | 2370 | goto unmap_cmd; |
2377 | } | 2371 | } |
2378 | 2372 | ||
2379 | wr->isert_cmd = isert_cmd; | ||
2380 | rdma_write_max = isert_conn->max_sge * PAGE_SIZE; | 2373 | rdma_write_max = isert_conn->max_sge * PAGE_SIZE; |
2381 | 2374 | ||
2382 | for (i = 0; i < wr->rdma_wr_num; i++) { | 2375 | for (i = 0; i < isert_cmd->rdma_wr_num; i++) { |
2383 | rdma_wr = &isert_cmd->rdma_wr.rdma_wr[i]; | 2376 | rdma_wr = &isert_cmd->rdma_wr[i]; |
2384 | data_len = min(data_left, rdma_write_max); | 2377 | data_len = min(data_left, rdma_write_max); |
2385 | 2378 | ||
2386 | rdma_wr->wr.send_flags = 0; | 2379 | rdma_wr->wr.send_flags = 0; |
2387 | if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { | 2380 | if (isert_cmd->iser_ib_op == ISER_IB_RDMA_WRITE) { |
2388 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_write_done; | 2381 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_write_done; |
2389 | 2382 | ||
2390 | rdma_wr->wr.opcode = IB_WR_RDMA_WRITE; | 2383 | rdma_wr->wr.opcode = IB_WR_RDMA_WRITE; |
2391 | rdma_wr->remote_addr = isert_cmd->read_va + offset; | 2384 | rdma_wr->remote_addr = isert_cmd->read_va + offset; |
2392 | rdma_wr->rkey = isert_cmd->read_stag; | 2385 | rdma_wr->rkey = isert_cmd->read_stag; |
2393 | if (i + 1 == wr->rdma_wr_num) | 2386 | if (i + 1 == isert_cmd->rdma_wr_num) |
2394 | rdma_wr->wr.next = &isert_cmd->tx_desc.send_wr; | 2387 | rdma_wr->wr.next = &isert_cmd->tx_desc.send_wr; |
2395 | else | 2388 | else |
2396 | rdma_wr->wr.next = &wr->rdma_wr[i + 1].wr; | 2389 | rdma_wr->wr.next = &isert_cmd->rdma_wr[i + 1].wr; |
2397 | } else { | 2390 | } else { |
2398 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_read_done; | 2391 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_read_done; |
2399 | 2392 | ||
2400 | rdma_wr->wr.opcode = IB_WR_RDMA_READ; | 2393 | rdma_wr->wr.opcode = IB_WR_RDMA_READ; |
2401 | rdma_wr->remote_addr = isert_cmd->write_va + va_offset; | 2394 | rdma_wr->remote_addr = isert_cmd->write_va + va_offset; |
2402 | rdma_wr->rkey = isert_cmd->write_stag; | 2395 | rdma_wr->rkey = isert_cmd->write_stag; |
2403 | if (i + 1 == wr->rdma_wr_num) | 2396 | if (i + 1 == isert_cmd->rdma_wr_num) |
2404 | rdma_wr->wr.send_flags = IB_SEND_SIGNALED; | 2397 | rdma_wr->wr.send_flags = IB_SEND_SIGNALED; |
2405 | else | 2398 | else |
2406 | rdma_wr->wr.next = &wr->rdma_wr[i + 1].wr; | 2399 | rdma_wr->wr.next = &isert_cmd->rdma_wr[i + 1].wr; |
2407 | } | 2400 | } |
2408 | 2401 | ||
2409 | ib_sge_cnt = isert_build_rdma_wr(isert_conn, isert_cmd, ib_sge, | 2402 | ib_sge_cnt = isert_build_rdma_wr(isert_conn, isert_cmd, ib_sge, |
@@ -2571,10 +2564,10 @@ isert_set_prot_checks(u8 prot_checks) | |||
2571 | 2564 | ||
2572 | static int | 2565 | static int |
2573 | isert_reg_sig_mr(struct isert_conn *isert_conn, | 2566 | isert_reg_sig_mr(struct isert_conn *isert_conn, |
2574 | struct se_cmd *se_cmd, | 2567 | struct isert_cmd *isert_cmd, |
2575 | struct isert_rdma_wr *rdma_wr, | ||
2576 | struct fast_reg_descriptor *fr_desc) | 2568 | struct fast_reg_descriptor *fr_desc) |
2577 | { | 2569 | { |
2570 | struct se_cmd *se_cmd = &isert_cmd->iscsi_cmd->se_cmd; | ||
2578 | struct ib_sig_handover_wr sig_wr; | 2571 | struct ib_sig_handover_wr sig_wr; |
2579 | struct ib_send_wr inv_wr, *bad_wr, *wr = NULL; | 2572 | struct ib_send_wr inv_wr, *bad_wr, *wr = NULL; |
2580 | struct pi_context *pi_ctx = fr_desc->pi_ctx; | 2573 | struct pi_context *pi_ctx = fr_desc->pi_ctx; |
@@ -2596,13 +2589,13 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, | |||
2596 | memset(&sig_wr, 0, sizeof(sig_wr)); | 2589 | memset(&sig_wr, 0, sizeof(sig_wr)); |
2597 | sig_wr.wr.opcode = IB_WR_REG_SIG_MR; | 2590 | sig_wr.wr.opcode = IB_WR_REG_SIG_MR; |
2598 | sig_wr.wr.wr_cqe = NULL; | 2591 | sig_wr.wr.wr_cqe = NULL; |
2599 | sig_wr.wr.sg_list = &rdma_wr->ib_sg[DATA]; | 2592 | sig_wr.wr.sg_list = &isert_cmd->ib_sg[DATA]; |
2600 | sig_wr.wr.num_sge = 1; | 2593 | sig_wr.wr.num_sge = 1; |
2601 | sig_wr.access_flags = IB_ACCESS_LOCAL_WRITE; | 2594 | sig_wr.access_flags = IB_ACCESS_LOCAL_WRITE; |
2602 | sig_wr.sig_attrs = &sig_attrs; | 2595 | sig_wr.sig_attrs = &sig_attrs; |
2603 | sig_wr.sig_mr = pi_ctx->sig_mr; | 2596 | sig_wr.sig_mr = pi_ctx->sig_mr; |
2604 | if (se_cmd->t_prot_sg) | 2597 | if (se_cmd->t_prot_sg) |
2605 | sig_wr.prot = &rdma_wr->ib_sg[PROT]; | 2598 | sig_wr.prot = &isert_cmd->ib_sg[PROT]; |
2606 | 2599 | ||
2607 | if (!wr) | 2600 | if (!wr) |
2608 | wr = &sig_wr.wr; | 2601 | wr = &sig_wr.wr; |
@@ -2616,35 +2609,34 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, | |||
2616 | } | 2609 | } |
2617 | fr_desc->ind &= ~ISERT_SIG_KEY_VALID; | 2610 | fr_desc->ind &= ~ISERT_SIG_KEY_VALID; |
2618 | 2611 | ||
2619 | rdma_wr->ib_sg[SIG].lkey = pi_ctx->sig_mr->lkey; | 2612 | isert_cmd->ib_sg[SIG].lkey = pi_ctx->sig_mr->lkey; |
2620 | rdma_wr->ib_sg[SIG].addr = 0; | 2613 | isert_cmd->ib_sg[SIG].addr = 0; |
2621 | rdma_wr->ib_sg[SIG].length = se_cmd->data_length; | 2614 | isert_cmd->ib_sg[SIG].length = se_cmd->data_length; |
2622 | if (se_cmd->prot_op != TARGET_PROT_DIN_STRIP && | 2615 | if (se_cmd->prot_op != TARGET_PROT_DIN_STRIP && |
2623 | se_cmd->prot_op != TARGET_PROT_DOUT_INSERT) | 2616 | se_cmd->prot_op != TARGET_PROT_DOUT_INSERT) |
2624 | /* | 2617 | /* |
2625 | * We have protection guards on the wire | 2618 | * We have protection guards on the wire |
2626 | * so we need to set a larget transfer | 2619 | * so we need to set a larget transfer |
2627 | */ | 2620 | */ |
2628 | rdma_wr->ib_sg[SIG].length += se_cmd->prot_length; | 2621 | isert_cmd->ib_sg[SIG].length += se_cmd->prot_length; |
2629 | 2622 | ||
2630 | isert_dbg("sig_sge: addr: 0x%llx length: %u lkey: %x\n", | 2623 | isert_dbg("sig_sge: addr: 0x%llx length: %u lkey: %x\n", |
2631 | rdma_wr->ib_sg[SIG].addr, rdma_wr->ib_sg[SIG].length, | 2624 | isert_cmd->ib_sg[SIG].addr, isert_cmd->ib_sg[SIG].length, |
2632 | rdma_wr->ib_sg[SIG].lkey); | 2625 | isert_cmd->ib_sg[SIG].lkey); |
2633 | err: | 2626 | err: |
2634 | return ret; | 2627 | return ret; |
2635 | } | 2628 | } |
2636 | 2629 | ||
2637 | static int | 2630 | static int |
2638 | isert_handle_prot_cmd(struct isert_conn *isert_conn, | 2631 | isert_handle_prot_cmd(struct isert_conn *isert_conn, |
2639 | struct isert_cmd *isert_cmd, | 2632 | struct isert_cmd *isert_cmd) |
2640 | struct isert_rdma_wr *wr) | ||
2641 | { | 2633 | { |
2642 | struct isert_device *device = isert_conn->device; | 2634 | struct isert_device *device = isert_conn->device; |
2643 | struct se_cmd *se_cmd = &isert_cmd->iscsi_cmd->se_cmd; | 2635 | struct se_cmd *se_cmd = &isert_cmd->iscsi_cmd->se_cmd; |
2644 | int ret; | 2636 | int ret; |
2645 | 2637 | ||
2646 | if (!wr->fr_desc->pi_ctx) { | 2638 | if (!isert_cmd->fr_desc->pi_ctx) { |
2647 | ret = isert_create_pi_ctx(wr->fr_desc, | 2639 | ret = isert_create_pi_ctx(isert_cmd->fr_desc, |
2648 | device->ib_device, | 2640 | device->ib_device, |
2649 | device->pd); | 2641 | device->pd); |
2650 | if (ret) { | 2642 | if (ret) { |
@@ -2659,16 +2651,20 @@ isert_handle_prot_cmd(struct isert_conn *isert_conn, | |||
2659 | se_cmd->t_prot_sg, | 2651 | se_cmd->t_prot_sg, |
2660 | se_cmd->t_prot_nents, | 2652 | se_cmd->t_prot_nents, |
2661 | se_cmd->prot_length, | 2653 | se_cmd->prot_length, |
2662 | 0, wr->iser_ib_op, &wr->prot); | 2654 | 0, |
2655 | isert_cmd->iser_ib_op, | ||
2656 | &isert_cmd->prot); | ||
2663 | if (ret) { | 2657 | if (ret) { |
2664 | isert_err("conn %p failed to map protection buffer\n", | 2658 | isert_err("conn %p failed to map protection buffer\n", |
2665 | isert_conn); | 2659 | isert_conn); |
2666 | return ret; | 2660 | return ret; |
2667 | } | 2661 | } |
2668 | 2662 | ||
2669 | memset(&wr->ib_sg[PROT], 0, sizeof(wr->ib_sg[PROT])); | 2663 | memset(&isert_cmd->ib_sg[PROT], 0, sizeof(isert_cmd->ib_sg[PROT])); |
2670 | ret = isert_fast_reg_mr(isert_conn, wr->fr_desc, &wr->prot, | 2664 | ret = isert_fast_reg_mr(isert_conn, isert_cmd->fr_desc, |
2671 | ISERT_PROT_KEY_VALID, &wr->ib_sg[PROT]); | 2665 | &isert_cmd->prot, |
2666 | ISERT_PROT_KEY_VALID, | ||
2667 | &isert_cmd->ib_sg[PROT]); | ||
2672 | if (ret) { | 2668 | if (ret) { |
2673 | isert_err("conn %p failed to fast reg mr\n", | 2669 | isert_err("conn %p failed to fast reg mr\n", |
2674 | isert_conn); | 2670 | isert_conn); |
@@ -2676,29 +2672,28 @@ isert_handle_prot_cmd(struct isert_conn *isert_conn, | |||
2676 | } | 2672 | } |
2677 | } | 2673 | } |
2678 | 2674 | ||
2679 | ret = isert_reg_sig_mr(isert_conn, se_cmd, wr, wr->fr_desc); | 2675 | ret = isert_reg_sig_mr(isert_conn, isert_cmd, isert_cmd->fr_desc); |
2680 | if (ret) { | 2676 | if (ret) { |
2681 | isert_err("conn %p failed to fast reg mr\n", | 2677 | isert_err("conn %p failed to fast reg mr\n", |
2682 | isert_conn); | 2678 | isert_conn); |
2683 | goto unmap_prot_cmd; | 2679 | goto unmap_prot_cmd; |
2684 | } | 2680 | } |
2685 | wr->fr_desc->ind |= ISERT_PROTECTED; | 2681 | isert_cmd->fr_desc->ind |= ISERT_PROTECTED; |
2686 | 2682 | ||
2687 | return 0; | 2683 | return 0; |
2688 | 2684 | ||
2689 | unmap_prot_cmd: | 2685 | unmap_prot_cmd: |
2690 | if (se_cmd->t_prot_sg) | 2686 | if (se_cmd->t_prot_sg) |
2691 | isert_unmap_data_buf(isert_conn, &wr->prot); | 2687 | isert_unmap_data_buf(isert_conn, &isert_cmd->prot); |
2692 | 2688 | ||
2693 | return ret; | 2689 | return ret; |
2694 | } | 2690 | } |
2695 | 2691 | ||
2696 | static int | 2692 | static int |
2697 | isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | 2693 | isert_reg_rdma(struct isert_cmd *isert_cmd, struct iscsi_conn *conn) |
2698 | struct isert_rdma_wr *wr) | ||
2699 | { | 2694 | { |
2695 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; | ||
2700 | struct se_cmd *se_cmd = &cmd->se_cmd; | 2696 | struct se_cmd *se_cmd = &cmd->se_cmd; |
2701 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | ||
2702 | struct isert_conn *isert_conn = conn->context; | 2697 | struct isert_conn *isert_conn = conn->context; |
2703 | struct fast_reg_descriptor *fr_desc = NULL; | 2698 | struct fast_reg_descriptor *fr_desc = NULL; |
2704 | struct ib_rdma_wr *rdma_wr; | 2699 | struct ib_rdma_wr *rdma_wr; |
@@ -2709,49 +2704,51 @@ isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2709 | 2704 | ||
2710 | isert_cmd->tx_desc.isert_cmd = isert_cmd; | 2705 | isert_cmd->tx_desc.isert_cmd = isert_cmd; |
2711 | 2706 | ||
2712 | offset = wr->iser_ib_op == ISER_IB_RDMA_READ ? cmd->write_data_done : 0; | 2707 | offset = isert_cmd->iser_ib_op == ISER_IB_RDMA_READ ? |
2708 | cmd->write_data_done : 0; | ||
2713 | ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg, | 2709 | ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg, |
2714 | se_cmd->t_data_nents, se_cmd->data_length, | 2710 | se_cmd->t_data_nents, se_cmd->data_length, |
2715 | offset, wr->iser_ib_op, &wr->data); | 2711 | offset, isert_cmd->iser_ib_op, |
2712 | &isert_cmd->data); | ||
2716 | if (ret) | 2713 | if (ret) |
2717 | return ret; | 2714 | return ret; |
2718 | 2715 | ||
2719 | if (wr->data.dma_nents != 1 || isert_prot_cmd(isert_conn, se_cmd)) { | 2716 | if (isert_cmd->data.dma_nents != 1 || |
2717 | isert_prot_cmd(isert_conn, se_cmd)) { | ||
2720 | spin_lock_irqsave(&isert_conn->pool_lock, flags); | 2718 | spin_lock_irqsave(&isert_conn->pool_lock, flags); |
2721 | fr_desc = list_first_entry(&isert_conn->fr_pool, | 2719 | fr_desc = list_first_entry(&isert_conn->fr_pool, |
2722 | struct fast_reg_descriptor, list); | 2720 | struct fast_reg_descriptor, list); |
2723 | list_del(&fr_desc->list); | 2721 | list_del(&fr_desc->list); |
2724 | spin_unlock_irqrestore(&isert_conn->pool_lock, flags); | 2722 | spin_unlock_irqrestore(&isert_conn->pool_lock, flags); |
2725 | wr->fr_desc = fr_desc; | 2723 | isert_cmd->fr_desc = fr_desc; |
2726 | } | 2724 | } |
2727 | 2725 | ||
2728 | ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->data, | 2726 | ret = isert_fast_reg_mr(isert_conn, fr_desc, &isert_cmd->data, |
2729 | ISERT_DATA_KEY_VALID, &wr->ib_sg[DATA]); | 2727 | ISERT_DATA_KEY_VALID, &isert_cmd->ib_sg[DATA]); |
2730 | if (ret) | 2728 | if (ret) |
2731 | goto unmap_cmd; | 2729 | goto unmap_cmd; |
2732 | 2730 | ||
2733 | if (isert_prot_cmd(isert_conn, se_cmd)) { | 2731 | if (isert_prot_cmd(isert_conn, se_cmd)) { |
2734 | ret = isert_handle_prot_cmd(isert_conn, isert_cmd, wr); | 2732 | ret = isert_handle_prot_cmd(isert_conn, isert_cmd); |
2735 | if (ret) | 2733 | if (ret) |
2736 | goto unmap_cmd; | 2734 | goto unmap_cmd; |
2737 | 2735 | ||
2738 | ib_sg = &wr->ib_sg[SIG]; | 2736 | ib_sg = &isert_cmd->ib_sg[SIG]; |
2739 | } else { | 2737 | } else { |
2740 | ib_sg = &wr->ib_sg[DATA]; | 2738 | ib_sg = &isert_cmd->ib_sg[DATA]; |
2741 | } | 2739 | } |
2742 | 2740 | ||
2743 | memcpy(&wr->s_ib_sge, ib_sg, sizeof(*ib_sg)); | 2741 | memcpy(&isert_cmd->s_ib_sge, ib_sg, sizeof(*ib_sg)); |
2744 | wr->ib_sge = &wr->s_ib_sge; | 2742 | isert_cmd->ib_sge = &isert_cmd->s_ib_sge; |
2745 | wr->rdma_wr_num = 1; | 2743 | isert_cmd->rdma_wr_num = 1; |
2746 | memset(&wr->s_rdma_wr, 0, sizeof(wr->s_rdma_wr)); | 2744 | memset(&isert_cmd->s_rdma_wr, 0, sizeof(isert_cmd->s_rdma_wr)); |
2747 | wr->rdma_wr = &wr->s_rdma_wr; | 2745 | isert_cmd->rdma_wr = &isert_cmd->s_rdma_wr; |
2748 | wr->isert_cmd = isert_cmd; | ||
2749 | 2746 | ||
2750 | rdma_wr = &isert_cmd->rdma_wr.s_rdma_wr; | 2747 | rdma_wr = &isert_cmd->s_rdma_wr; |
2751 | rdma_wr->wr.sg_list = &wr->s_ib_sge; | 2748 | rdma_wr->wr.sg_list = &isert_cmd->s_ib_sge; |
2752 | rdma_wr->wr.num_sge = 1; | 2749 | rdma_wr->wr.num_sge = 1; |
2753 | rdma_wr->wr.wr_cqe = &isert_cmd->tx_desc.tx_cqe; | 2750 | rdma_wr->wr.wr_cqe = &isert_cmd->tx_desc.tx_cqe; |
2754 | if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { | 2751 | if (isert_cmd->iser_ib_op == ISER_IB_RDMA_WRITE) { |
2755 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_write_done; | 2752 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_write_done; |
2756 | 2753 | ||
2757 | rdma_wr->wr.opcode = IB_WR_RDMA_WRITE; | 2754 | rdma_wr->wr.opcode = IB_WR_RDMA_WRITE; |
@@ -2776,7 +2773,7 @@ unmap_cmd: | |||
2776 | list_add_tail(&fr_desc->list, &isert_conn->fr_pool); | 2773 | list_add_tail(&fr_desc->list, &isert_conn->fr_pool); |
2777 | spin_unlock_irqrestore(&isert_conn->pool_lock, flags); | 2774 | spin_unlock_irqrestore(&isert_conn->pool_lock, flags); |
2778 | } | 2775 | } |
2779 | isert_unmap_data_buf(isert_conn, &wr->data); | 2776 | isert_unmap_data_buf(isert_conn, &isert_cmd->data); |
2780 | 2777 | ||
2781 | return ret; | 2778 | return ret; |
2782 | } | 2779 | } |
@@ -2786,7 +2783,6 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
2786 | { | 2783 | { |
2787 | struct se_cmd *se_cmd = &cmd->se_cmd; | 2784 | struct se_cmd *se_cmd = &cmd->se_cmd; |
2788 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | 2785 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
2789 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
2790 | struct isert_conn *isert_conn = conn->context; | 2786 | struct isert_conn *isert_conn = conn->context; |
2791 | struct isert_device *device = isert_conn->device; | 2787 | struct isert_device *device = isert_conn->device; |
2792 | struct ib_send_wr *wr_failed; | 2788 | struct ib_send_wr *wr_failed; |
@@ -2795,8 +2791,8 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
2795 | isert_dbg("Cmd: %p RDMA_WRITE data_length: %u\n", | 2791 | isert_dbg("Cmd: %p RDMA_WRITE data_length: %u\n", |
2796 | isert_cmd, se_cmd->data_length); | 2792 | isert_cmd, se_cmd->data_length); |
2797 | 2793 | ||
2798 | wr->iser_ib_op = ISER_IB_RDMA_WRITE; | 2794 | isert_cmd->iser_ib_op = ISER_IB_RDMA_WRITE; |
2799 | rc = device->reg_rdma_mem(conn, cmd, wr); | 2795 | rc = device->reg_rdma_mem(isert_cmd, conn); |
2800 | if (rc) { | 2796 | if (rc) { |
2801 | isert_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); | 2797 | isert_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); |
2802 | return rc; | 2798 | return rc; |
@@ -2813,8 +2809,8 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
2813 | isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); | 2809 | isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); |
2814 | isert_init_send_wr(isert_conn, isert_cmd, | 2810 | isert_init_send_wr(isert_conn, isert_cmd, |
2815 | &isert_cmd->tx_desc.send_wr); | 2811 | &isert_cmd->tx_desc.send_wr); |
2816 | isert_cmd->rdma_wr.s_rdma_wr.wr.next = &isert_cmd->tx_desc.send_wr; | 2812 | isert_cmd->s_rdma_wr.wr.next = &isert_cmd->tx_desc.send_wr; |
2817 | wr->rdma_wr_num += 1; | 2813 | isert_cmd->rdma_wr_num += 1; |
2818 | 2814 | ||
2819 | rc = isert_post_recv(isert_conn, isert_cmd->rx_desc); | 2815 | rc = isert_post_recv(isert_conn, isert_cmd->rx_desc); |
2820 | if (rc) { | 2816 | if (rc) { |
@@ -2823,7 +2819,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
2823 | } | 2819 | } |
2824 | } | 2820 | } |
2825 | 2821 | ||
2826 | rc = ib_post_send(isert_conn->qp, &wr->rdma_wr->wr, &wr_failed); | 2822 | rc = ib_post_send(isert_conn->qp, &isert_cmd->rdma_wr->wr, &wr_failed); |
2827 | if (rc) | 2823 | if (rc) |
2828 | isert_warn("ib_post_send() failed for IB_WR_RDMA_WRITE\n"); | 2824 | isert_warn("ib_post_send() failed for IB_WR_RDMA_WRITE\n"); |
2829 | 2825 | ||
@@ -2842,7 +2838,6 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) | |||
2842 | { | 2838 | { |
2843 | struct se_cmd *se_cmd = &cmd->se_cmd; | 2839 | struct se_cmd *se_cmd = &cmd->se_cmd; |
2844 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | 2840 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
2845 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | ||
2846 | struct isert_conn *isert_conn = conn->context; | 2841 | struct isert_conn *isert_conn = conn->context; |
2847 | struct isert_device *device = isert_conn->device; | 2842 | struct isert_device *device = isert_conn->device; |
2848 | struct ib_send_wr *wr_failed; | 2843 | struct ib_send_wr *wr_failed; |
@@ -2850,14 +2845,14 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) | |||
2850 | 2845 | ||
2851 | isert_dbg("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", | 2846 | isert_dbg("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", |
2852 | isert_cmd, se_cmd->data_length, cmd->write_data_done); | 2847 | isert_cmd, se_cmd->data_length, cmd->write_data_done); |
2853 | wr->iser_ib_op = ISER_IB_RDMA_READ; | 2848 | isert_cmd->iser_ib_op = ISER_IB_RDMA_READ; |
2854 | rc = device->reg_rdma_mem(conn, cmd, wr); | 2849 | rc = device->reg_rdma_mem(isert_cmd, conn); |
2855 | if (rc) { | 2850 | if (rc) { |
2856 | isert_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); | 2851 | isert_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); |
2857 | return rc; | 2852 | return rc; |
2858 | } | 2853 | } |
2859 | 2854 | ||
2860 | rc = ib_post_send(isert_conn->qp, &wr->rdma_wr->wr, &wr_failed); | 2855 | rc = ib_post_send(isert_conn->qp, &isert_cmd->rdma_wr->wr, &wr_failed); |
2861 | if (rc) | 2856 | if (rc) |
2862 | isert_warn("ib_post_send() failed for IB_WR_RDMA_READ\n"); | 2857 | isert_warn("ib_post_send() failed for IB_WR_RDMA_READ\n"); |
2863 | 2858 | ||