Commit 10633c37 authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Nicholas Bellinger

iser-target: Remove code duplication

- Fall-through in switch case instead in do_control_comp.
- Move rkey invalidation to a function.
Signed-off-by: default avatarSagi Grimberg <sagig@mellanox.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 4c22e07f
...@@ -1869,11 +1869,8 @@ isert_do_control_comp(struct work_struct *work) ...@@ -1869,11 +1869,8 @@ isert_do_control_comp(struct work_struct *work)
switch (cmd->i_state) { switch (cmd->i_state) {
case ISTATE_SEND_TASKMGTRSP: case ISTATE_SEND_TASKMGTRSP:
iscsit_tmr_post_handler(cmd, cmd->conn); iscsit_tmr_post_handler(cmd, cmd->conn);
cmd->i_state = ISTATE_SENT_STATUS; case ISTATE_SEND_REJECT: /* FALLTHRU */
isert_completion_put(&isert_cmd->tx_desc, isert_cmd, case ISTATE_SEND_TEXTRSP: /* FALLTHRU */
ib_dev, false);
break;
case ISTATE_SEND_REJECT:
cmd->i_state = ISTATE_SENT_STATUS; cmd->i_state = ISTATE_SENT_STATUS;
isert_completion_put(&isert_cmd->tx_desc, isert_cmd, isert_completion_put(&isert_cmd->tx_desc, isert_cmd,
ib_dev, false); ib_dev, false);
...@@ -1881,11 +1878,6 @@ isert_do_control_comp(struct work_struct *work) ...@@ -1881,11 +1878,6 @@ isert_do_control_comp(struct work_struct *work)
case ISTATE_SEND_LOGOUTRSP: case ISTATE_SEND_LOGOUTRSP:
iscsit_logout_post_handler(cmd, cmd->conn); iscsit_logout_post_handler(cmd, cmd->conn);
break; break;
case ISTATE_SEND_TEXTRSP:
cmd->i_state = ISTATE_SENT_STATUS;
isert_completion_put(&isert_cmd->tx_desc, isert_cmd,
ib_dev, false);
break;
default: default:
isert_err("Unknown i_state %d\n", cmd->i_state); isert_err("Unknown i_state %d\n", cmd->i_state);
dump_stack(); dump_stack();
...@@ -2459,6 +2451,21 @@ isert_map_fr_pagelist(struct ib_device *ib_dev, ...@@ -2459,6 +2451,21 @@ isert_map_fr_pagelist(struct ib_device *ib_dev,
return n_pages; return n_pages;
} }
static inline void
isert_inv_rkey(struct ib_send_wr *inv_wr, struct ib_mr *mr)
{
u32 rkey;
memset(inv_wr, 0, sizeof(*inv_wr));
inv_wr->wr_id = ISER_FASTREG_LI_WRID;
inv_wr->opcode = IB_WR_LOCAL_INV;
inv_wr->ex.invalidate_rkey = mr->rkey;
/* Bump the key */
rkey = ib_inc_rkey(mr->rkey);
ib_update_fast_reg_key(mr, rkey);
}
static int static int
isert_fast_reg_mr(struct isert_conn *isert_conn, isert_fast_reg_mr(struct isert_conn *isert_conn,
struct fast_reg_descriptor *fr_desc, struct fast_reg_descriptor *fr_desc,
...@@ -2473,7 +2480,6 @@ isert_fast_reg_mr(struct isert_conn *isert_conn, ...@@ -2473,7 +2480,6 @@ isert_fast_reg_mr(struct isert_conn *isert_conn,
struct ib_send_wr *bad_wr, *wr = NULL; struct ib_send_wr *bad_wr, *wr = NULL;
int ret, pagelist_len; int ret, pagelist_len;
u32 page_off; u32 page_off;
u8 key;
if (mem->dma_nents == 1) { if (mem->dma_nents == 1) {
sge->lkey = isert_conn->conn_mr->lkey; sge->lkey = isert_conn->conn_mr->lkey;
...@@ -2502,15 +2508,9 @@ isert_fast_reg_mr(struct isert_conn *isert_conn, ...@@ -2502,15 +2508,9 @@ isert_fast_reg_mr(struct isert_conn *isert_conn,
pagelist_len = isert_map_fr_pagelist(ib_dev, mem->sg, mem->nents, pagelist_len = isert_map_fr_pagelist(ib_dev, mem->sg, mem->nents,
&frpl->page_list[0]); &frpl->page_list[0]);
if (!(fr_desc->ind & ISERT_DATA_KEY_VALID)) { if (!(fr_desc->ind & ind)) {
memset(&inv_wr, 0, sizeof(inv_wr)); isert_inv_rkey(&inv_wr, mr);
inv_wr.wr_id = ISER_FASTREG_LI_WRID;
inv_wr.opcode = IB_WR_LOCAL_INV;
inv_wr.ex.invalidate_rkey = mr->rkey;
wr = &inv_wr; wr = &inv_wr;
/* Bump the key */
key = (u8)(mr->rkey & 0x000000FF);
ib_update_fast_reg_key(mr, ++key);
} }
/* Prepare FASTREG WR */ /* Prepare FASTREG WR */
...@@ -2614,7 +2614,6 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, ...@@ -2614,7 +2614,6 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
struct pi_context *pi_ctx = fr_desc->pi_ctx; struct pi_context *pi_ctx = fr_desc->pi_ctx;
struct ib_sig_attrs sig_attrs; struct ib_sig_attrs sig_attrs;
int ret; int ret;
u32 key;
memset(&sig_attrs, 0, sizeof(sig_attrs)); memset(&sig_attrs, 0, sizeof(sig_attrs));
ret = isert_set_sig_attrs(se_cmd, &sig_attrs); ret = isert_set_sig_attrs(se_cmd, &sig_attrs);
...@@ -2624,14 +2623,8 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, ...@@ -2624,14 +2623,8 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks); sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks);
if (!(fr_desc->ind & ISERT_SIG_KEY_VALID)) { if (!(fr_desc->ind & ISERT_SIG_KEY_VALID)) {
memset(&inv_wr, 0, sizeof(inv_wr)); isert_inv_rkey(&inv_wr, pi_ctx->sig_mr);
inv_wr.opcode = IB_WR_LOCAL_INV;
inv_wr.wr_id = ISER_FASTREG_LI_WRID;
inv_wr.ex.invalidate_rkey = pi_ctx->sig_mr->rkey;
wr = &inv_wr; wr = &inv_wr;
/* Bump the key */
key = (u8)(pi_ctx->sig_mr->rkey & 0x000000FF);
ib_update_fast_reg_key(pi_ctx->sig_mr, ++key);
} }
memset(&sig_wr, 0, sizeof(sig_wr)); memset(&sig_wr, 0, sizeof(sig_wr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment