diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2014-12-07 06:12:04 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-12-13 02:32:35 -0500 |
commit | 10633c37bf461b246491f6587f9efe09260893f9 (patch) | |
tree | 999e8972dd6ce10a1532c2dbc8fe7afdd1d2fbfc /drivers/infiniband | |
parent | 4c22e07ffdc947be61085c2a55bf564b9a8d50ee (diff) |
iser-target: Remove code duplication
- Fall-through in switch case instead in do_control_comp.
- Move rkey invalidation to a function.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 0de507c40c5c..2964f210d6e6 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -1869,11 +1869,8 @@ isert_do_control_comp(struct work_struct *work) | |||
1869 | switch (cmd->i_state) { | 1869 | switch (cmd->i_state) { |
1870 | case ISTATE_SEND_TASKMGTRSP: | 1870 | case ISTATE_SEND_TASKMGTRSP: |
1871 | iscsit_tmr_post_handler(cmd, cmd->conn); | 1871 | iscsit_tmr_post_handler(cmd, cmd->conn); |
1872 | cmd->i_state = ISTATE_SENT_STATUS; | 1872 | case ISTATE_SEND_REJECT: /* FALLTHRU */ |
1873 | isert_completion_put(&isert_cmd->tx_desc, isert_cmd, | 1873 | case ISTATE_SEND_TEXTRSP: /* FALLTHRU */ |
1874 | ib_dev, false); | ||
1875 | break; | ||
1876 | case ISTATE_SEND_REJECT: | ||
1877 | cmd->i_state = ISTATE_SENT_STATUS; | 1874 | cmd->i_state = ISTATE_SENT_STATUS; |
1878 | isert_completion_put(&isert_cmd->tx_desc, isert_cmd, | 1875 | isert_completion_put(&isert_cmd->tx_desc, isert_cmd, |
1879 | ib_dev, false); | 1876 | ib_dev, false); |
@@ -1881,11 +1878,6 @@ isert_do_control_comp(struct work_struct *work) | |||
1881 | case ISTATE_SEND_LOGOUTRSP: | 1878 | case ISTATE_SEND_LOGOUTRSP: |
1882 | iscsit_logout_post_handler(cmd, cmd->conn); | 1879 | iscsit_logout_post_handler(cmd, cmd->conn); |
1883 | break; | 1880 | break; |
1884 | case ISTATE_SEND_TEXTRSP: | ||
1885 | cmd->i_state = ISTATE_SENT_STATUS; | ||
1886 | isert_completion_put(&isert_cmd->tx_desc, isert_cmd, | ||
1887 | ib_dev, false); | ||
1888 | break; | ||
1889 | default: | 1881 | default: |
1890 | isert_err("Unknown i_state %d\n", cmd->i_state); | 1882 | isert_err("Unknown i_state %d\n", cmd->i_state); |
1891 | dump_stack(); | 1883 | dump_stack(); |
@@ -2459,6 +2451,21 @@ isert_map_fr_pagelist(struct ib_device *ib_dev, | |||
2459 | return n_pages; | 2451 | return n_pages; |
2460 | } | 2452 | } |
2461 | 2453 | ||
2454 | static inline void | ||
2455 | isert_inv_rkey(struct ib_send_wr *inv_wr, struct ib_mr *mr) | ||
2456 | { | ||
2457 | u32 rkey; | ||
2458 | |||
2459 | memset(inv_wr, 0, sizeof(*inv_wr)); | ||
2460 | inv_wr->wr_id = ISER_FASTREG_LI_WRID; | ||
2461 | inv_wr->opcode = IB_WR_LOCAL_INV; | ||
2462 | inv_wr->ex.invalidate_rkey = mr->rkey; | ||
2463 | |||
2464 | /* Bump the key */ | ||
2465 | rkey = ib_inc_rkey(mr->rkey); | ||
2466 | ib_update_fast_reg_key(mr, rkey); | ||
2467 | } | ||
2468 | |||
2462 | static int | 2469 | static int |
2463 | isert_fast_reg_mr(struct isert_conn *isert_conn, | 2470 | isert_fast_reg_mr(struct isert_conn *isert_conn, |
2464 | struct fast_reg_descriptor *fr_desc, | 2471 | struct fast_reg_descriptor *fr_desc, |
@@ -2473,7 +2480,6 @@ isert_fast_reg_mr(struct isert_conn *isert_conn, | |||
2473 | struct ib_send_wr *bad_wr, *wr = NULL; | 2480 | struct ib_send_wr *bad_wr, *wr = NULL; |
2474 | int ret, pagelist_len; | 2481 | int ret, pagelist_len; |
2475 | u32 page_off; | 2482 | u32 page_off; |
2476 | u8 key; | ||
2477 | 2483 | ||
2478 | if (mem->dma_nents == 1) { | 2484 | if (mem->dma_nents == 1) { |
2479 | sge->lkey = isert_conn->conn_mr->lkey; | 2485 | sge->lkey = isert_conn->conn_mr->lkey; |
@@ -2502,15 +2508,9 @@ isert_fast_reg_mr(struct isert_conn *isert_conn, | |||
2502 | pagelist_len = isert_map_fr_pagelist(ib_dev, mem->sg, mem->nents, | 2508 | pagelist_len = isert_map_fr_pagelist(ib_dev, mem->sg, mem->nents, |
2503 | &frpl->page_list[0]); | 2509 | &frpl->page_list[0]); |
2504 | 2510 | ||
2505 | if (!(fr_desc->ind & ISERT_DATA_KEY_VALID)) { | 2511 | if (!(fr_desc->ind & ind)) { |
2506 | memset(&inv_wr, 0, sizeof(inv_wr)); | 2512 | isert_inv_rkey(&inv_wr, mr); |
2507 | inv_wr.wr_id = ISER_FASTREG_LI_WRID; | ||
2508 | inv_wr.opcode = IB_WR_LOCAL_INV; | ||
2509 | inv_wr.ex.invalidate_rkey = mr->rkey; | ||
2510 | wr = &inv_wr; | 2513 | wr = &inv_wr; |
2511 | /* Bump the key */ | ||
2512 | key = (u8)(mr->rkey & 0x000000FF); | ||
2513 | ib_update_fast_reg_key(mr, ++key); | ||
2514 | } | 2514 | } |
2515 | 2515 | ||
2516 | /* Prepare FASTREG WR */ | 2516 | /* Prepare FASTREG WR */ |
@@ -2614,7 +2614,6 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, | |||
2614 | struct pi_context *pi_ctx = fr_desc->pi_ctx; | 2614 | struct pi_context *pi_ctx = fr_desc->pi_ctx; |
2615 | struct ib_sig_attrs sig_attrs; | 2615 | struct ib_sig_attrs sig_attrs; |
2616 | int ret; | 2616 | int ret; |
2617 | u32 key; | ||
2618 | 2617 | ||
2619 | memset(&sig_attrs, 0, sizeof(sig_attrs)); | 2618 | memset(&sig_attrs, 0, sizeof(sig_attrs)); |
2620 | ret = isert_set_sig_attrs(se_cmd, &sig_attrs); | 2619 | ret = isert_set_sig_attrs(se_cmd, &sig_attrs); |
@@ -2624,14 +2623,8 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, | |||
2624 | sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks); | 2623 | sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks); |
2625 | 2624 | ||
2626 | if (!(fr_desc->ind & ISERT_SIG_KEY_VALID)) { | 2625 | if (!(fr_desc->ind & ISERT_SIG_KEY_VALID)) { |
2627 | memset(&inv_wr, 0, sizeof(inv_wr)); | 2626 | isert_inv_rkey(&inv_wr, pi_ctx->sig_mr); |
2628 | inv_wr.opcode = IB_WR_LOCAL_INV; | ||
2629 | inv_wr.wr_id = ISER_FASTREG_LI_WRID; | ||
2630 | inv_wr.ex.invalidate_rkey = pi_ctx->sig_mr->rkey; | ||
2631 | wr = &inv_wr; | 2627 | wr = &inv_wr; |
2632 | /* Bump the key */ | ||
2633 | key = (u8)(pi_ctx->sig_mr->rkey & 0x000000FF); | ||
2634 | ib_update_fast_reg_key(pi_ctx->sig_mr, ++key); | ||
2635 | } | 2628 | } |
2636 | 2629 | ||
2637 | memset(&sig_wr, 0, sizeof(sig_wr)); | 2630 | memset(&sig_wr, 0, sizeof(sig_wr)); |