summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2014-03-17 11:52:18 +0100
committerNicholas Bellinger <nab@linux-iscsi.org>2014-04-07 10:48:49 +0200
commit96b7973e1c59e9ddde27bca882411c3980125330 (patch)
tree6103864aba97f59cbd73c88e83a6cf3789bb9178
parentTarget/iser: Consider DIF and RDMA_READ completions when calculating post_sen... (diff)
downloadlinux-96b7973e1c59e9ddde27bca882411c3980125330.tar.xz
linux-96b7973e1c59e9ddde27bca882411c3980125330.zip
Target/iser: Move check signature status to a function
Remove code duplication from RDMA_READ and RDMA_WRITE completions that do basically the same check. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c115
1 files changed, 50 insertions, 65 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index faec22404da5..e2d48a9d828a 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -1657,6 +1657,50 @@ isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
isert_put_cmd(isert_cmd);
}
+static int
+isert_check_pi_status(struct se_cmd *se_cmd, struct ib_mr *sig_mr)
+{
+ struct ib_mr_status mr_status;
+ int ret;
+
+ ret = ib_check_mr_status(sig_mr, IB_MR_CHECK_SIG_STATUS, &mr_status);
+ if (ret) {
+ pr_err("ib_check_mr_status failed, ret %d\n", ret);
+ goto fail_mr_status;
+ }
+
+ if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
+ u64 sec_offset_err;
+ u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
+
+ switch (mr_status.sig_err.err_type) {
+ case IB_SIG_BAD_GUARD:
+ se_cmd->pi_err = TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
+ break;
+ case IB_SIG_BAD_REFTAG:
+ se_cmd->pi_err = TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED;
+ break;
+ case IB_SIG_BAD_APPTAG:
+ se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
+ break;
+ }
+ sec_offset_err = mr_status.sig_err.sig_err_offset;
+ do_div(sec_offset_err, block_size);
+ se_cmd->bad_sector = sec_offset_err + se_cmd->t_task_lba;
+
+ pr_err("isert: PI error found type %d at sector 0x%llx "
+ "expected 0x%x vs actual 0x%x\n",
+ mr_status.sig_err.err_type,
+ (unsigned long long)se_cmd->bad_sector,
+ mr_status.sig_err.expected,
+ mr_status.sig_err.actual);
+ ret = 1;
+ }
+
+fail_mr_status:
+ return ret;
+}
+
static void
isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
struct isert_cmd *isert_cmd)
@@ -1666,44 +1710,14 @@ isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
struct se_cmd *se_cmd = &cmd->se_cmd;
struct isert_conn *isert_conn = isert_cmd->conn;
struct isert_device *device = isert_conn->conn_device;
- struct ib_mr_status mr_status;
int ret = 0;
if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
- ret = ib_check_mr_status(wr->fr_desc->pi_ctx->sig_mr,
- IB_MR_CHECK_SIG_STATUS, &mr_status);
- if (ret) {
- pr_err("ib_check_mr_status failed, ret %d\n", ret);
- goto fail_mr_status;
- }
- if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
- u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
-
- switch (mr_status.sig_err.err_type) {
- case IB_SIG_BAD_GUARD:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
- break;
- case IB_SIG_BAD_REFTAG:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED;
- break;
- case IB_SIG_BAD_APPTAG:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
- break;
- }
- se_cmd->bad_sector = mr_status.sig_err.sig_err_offset;
- do_div(se_cmd->bad_sector, block_size);
-
- pr_err("isert: PI error found type %d at sector 0x%llx "
- "expected 0x%x vs actual 0x%x\n",
- mr_status.sig_err.err_type,
- (unsigned long long)se_cmd->bad_sector,
- mr_status.sig_err.expected,
- mr_status.sig_err.actual);
- ret = 1;
- }
+ ret = isert_check_pi_status(se_cmd,
+ wr->fr_desc->pi_ctx->sig_mr);
+ wr->fr_desc->ind &= ~ISERT_PROTECTED;
}
-fail_mr_status:
device->unreg_rdma_mem(isert_cmd, isert_conn);
wr->send_wr_num = 0;
if (ret)
@@ -1722,43 +1736,14 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc,
struct se_cmd *se_cmd = &cmd->se_cmd;
struct isert_conn *isert_conn = isert_cmd->conn;
struct isert_device *device = isert_conn->conn_device;
- struct ib_mr_status mr_status;
int ret;
if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
- ret = ib_check_mr_status(wr->fr_desc->pi_ctx->sig_mr,
- IB_MR_CHECK_SIG_STATUS, &mr_status);
- if (ret) {
- pr_err("ib_check_mr_status failed, ret %d\n", ret);
- goto fail_mr_status;
- }
- if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
- u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
-
- switch (mr_status.sig_err.err_type) {
- case IB_SIG_BAD_GUARD:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
- break;
- case IB_SIG_BAD_REFTAG:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED;
- break;
- case IB_SIG_BAD_APPTAG:
- se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
- break;
- }
- se_cmd->bad_sector = mr_status.sig_err.sig_err_offset;
- do_div(se_cmd->bad_sector, block_size);
-
- pr_err("isert: PI error found type %d at sector 0x%llx "
- "expected 0x%x vs actual 0x%x\n",
- mr_status.sig_err.err_type,
- (unsigned long long)se_cmd->bad_sector,
- mr_status.sig_err.expected,
- mr_status.sig_err.actual);
- }
+ ret = isert_check_pi_status(se_cmd,
+ wr->fr_desc->pi_ctx->sig_mr);
+ wr->fr_desc->ind &= ~ISERT_PROTECTED;
}
-fail_mr_status:
iscsit_stop_dataout_timer(cmd);
device->unreg_rdma_mem(isert_cmd, isert_conn);
cmd->write_data_done = wr->data.len;