diff options
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 267 | ||||
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.h | 7 |
2 files changed, 158 insertions, 116 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 33b549e752c1..b0e58f196d90 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -96,8 +96,7 @@ isert_query_device(struct ib_device *ib_dev, struct ib_device_attr *devattr) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | static int | 98 | static int |
99 | isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id, | 99 | isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id) |
100 | u8 protection) | ||
101 | { | 100 | { |
102 | struct isert_device *device = isert_conn->conn_device; | 101 | struct isert_device *device = isert_conn->conn_device; |
103 | struct ib_qp_init_attr attr; | 102 | struct ib_qp_init_attr attr; |
@@ -132,7 +131,7 @@ isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id, | |||
132 | attr.cap.max_recv_sge = 1; | 131 | attr.cap.max_recv_sge = 1; |
133 | attr.sq_sig_type = IB_SIGNAL_REQ_WR; | 132 | attr.sq_sig_type = IB_SIGNAL_REQ_WR; |
134 | attr.qp_type = IB_QPT_RC; | 133 | attr.qp_type = IB_QPT_RC; |
135 | if (protection) | 134 | if (device->pi_capable) |
136 | attr.create_flags |= IB_QP_CREATE_SIGNATURE_EN; | 135 | attr.create_flags |= IB_QP_CREATE_SIGNATURE_EN; |
137 | 136 | ||
138 | pr_debug("isert_conn_setup_qp cma_id->device: %p\n", | 137 | pr_debug("isert_conn_setup_qp cma_id->device: %p\n", |
@@ -442,8 +441,68 @@ isert_conn_free_fastreg_pool(struct isert_conn *isert_conn) | |||
442 | } | 441 | } |
443 | 442 | ||
444 | static int | 443 | static int |
444 | isert_create_pi_ctx(struct fast_reg_descriptor *desc, | ||
445 | struct ib_device *device, | ||
446 | struct ib_pd *pd) | ||
447 | { | ||
448 | struct ib_mr_init_attr mr_init_attr; | ||
449 | struct pi_context *pi_ctx; | ||
450 | int ret; | ||
451 | |||
452 | pi_ctx = kzalloc(sizeof(*desc->pi_ctx), GFP_KERNEL); | ||
453 | if (!pi_ctx) { | ||
454 | pr_err("Failed to allocate pi context\n"); | ||
455 | return -ENOMEM; | ||
456 | } | ||
457 | |||
458 | pi_ctx->prot_frpl = ib_alloc_fast_reg_page_list(device, | ||
459 | ISCSI_ISER_SG_TABLESIZE); | ||
460 | if (IS_ERR(pi_ctx->prot_frpl)) { | ||
461 | pr_err("Failed to allocate prot frpl err=%ld\n", | ||
462 | PTR_ERR(pi_ctx->prot_frpl)); | ||
463 | ret = PTR_ERR(pi_ctx->prot_frpl); | ||
464 | goto err_pi_ctx; | ||
465 | } | ||
466 | |||
467 | pi_ctx->prot_mr = ib_alloc_fast_reg_mr(pd, ISCSI_ISER_SG_TABLESIZE); | ||
468 | if (IS_ERR(pi_ctx->prot_mr)) { | ||
469 | pr_err("Failed to allocate prot frmr err=%ld\n", | ||
470 | PTR_ERR(pi_ctx->prot_mr)); | ||
471 | ret = PTR_ERR(pi_ctx->prot_mr); | ||
472 | goto err_prot_frpl; | ||
473 | } | ||
474 | desc->ind |= ISERT_PROT_KEY_VALID; | ||
475 | |||
476 | memset(&mr_init_attr, 0, sizeof(mr_init_attr)); | ||
477 | mr_init_attr.max_reg_descriptors = 2; | ||
478 | mr_init_attr.flags |= IB_MR_SIGNATURE_EN; | ||
479 | pi_ctx->sig_mr = ib_create_mr(pd, &mr_init_attr); | ||
480 | if (IS_ERR(pi_ctx->sig_mr)) { | ||
481 | pr_err("Failed to allocate signature enabled mr err=%ld\n", | ||
482 | PTR_ERR(pi_ctx->sig_mr)); | ||
483 | ret = PTR_ERR(pi_ctx->sig_mr); | ||
484 | goto err_prot_mr; | ||
485 | } | ||
486 | |||
487 | desc->pi_ctx = pi_ctx; | ||
488 | desc->ind |= ISERT_SIG_KEY_VALID; | ||
489 | desc->ind &= ~ISERT_PROTECTED; | ||
490 | |||
491 | return 0; | ||
492 | |||
493 | err_prot_mr: | ||
494 | ib_dereg_mr(desc->pi_ctx->prot_mr); | ||
495 | err_prot_frpl: | ||
496 | ib_free_fast_reg_page_list(desc->pi_ctx->prot_frpl); | ||
497 | err_pi_ctx: | ||
498 | kfree(desc->pi_ctx); | ||
499 | |||
500 | return ret; | ||
501 | } | ||
502 | |||
503 | static int | ||
445 | isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd, | 504 | isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd, |
446 | struct fast_reg_descriptor *fr_desc, u8 protection) | 505 | struct fast_reg_descriptor *fr_desc) |
447 | { | 506 | { |
448 | int ret; | 507 | int ret; |
449 | 508 | ||
@@ -462,62 +521,12 @@ isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd, | |||
462 | ret = PTR_ERR(fr_desc->data_mr); | 521 | ret = PTR_ERR(fr_desc->data_mr); |
463 | goto err_data_frpl; | 522 | goto err_data_frpl; |
464 | } | 523 | } |
465 | pr_debug("Create fr_desc %p page_list %p\n", | ||
466 | fr_desc, fr_desc->data_frpl->page_list); | ||
467 | fr_desc->ind |= ISERT_DATA_KEY_VALID; | 524 | fr_desc->ind |= ISERT_DATA_KEY_VALID; |
468 | 525 | ||
469 | if (protection) { | 526 | pr_debug("Created fr_desc %p\n", fr_desc); |
470 | struct ib_mr_init_attr mr_init_attr = {0}; | ||
471 | struct pi_context *pi_ctx; | ||
472 | |||
473 | fr_desc->pi_ctx = kzalloc(sizeof(*fr_desc->pi_ctx), GFP_KERNEL); | ||
474 | if (!fr_desc->pi_ctx) { | ||
475 | pr_err("Failed to allocate pi context\n"); | ||
476 | ret = -ENOMEM; | ||
477 | goto err_data_mr; | ||
478 | } | ||
479 | pi_ctx = fr_desc->pi_ctx; | ||
480 | |||
481 | pi_ctx->prot_frpl = ib_alloc_fast_reg_page_list(ib_device, | ||
482 | ISCSI_ISER_SG_TABLESIZE); | ||
483 | if (IS_ERR(pi_ctx->prot_frpl)) { | ||
484 | pr_err("Failed to allocate prot frpl err=%ld\n", | ||
485 | PTR_ERR(pi_ctx->prot_frpl)); | ||
486 | ret = PTR_ERR(pi_ctx->prot_frpl); | ||
487 | goto err_pi_ctx; | ||
488 | } | ||
489 | |||
490 | pi_ctx->prot_mr = ib_alloc_fast_reg_mr(pd, ISCSI_ISER_SG_TABLESIZE); | ||
491 | if (IS_ERR(pi_ctx->prot_mr)) { | ||
492 | pr_err("Failed to allocate prot frmr err=%ld\n", | ||
493 | PTR_ERR(pi_ctx->prot_mr)); | ||
494 | ret = PTR_ERR(pi_ctx->prot_mr); | ||
495 | goto err_prot_frpl; | ||
496 | } | ||
497 | fr_desc->ind |= ISERT_PROT_KEY_VALID; | ||
498 | |||
499 | mr_init_attr.max_reg_descriptors = 2; | ||
500 | mr_init_attr.flags |= IB_MR_SIGNATURE_EN; | ||
501 | pi_ctx->sig_mr = ib_create_mr(pd, &mr_init_attr); | ||
502 | if (IS_ERR(pi_ctx->sig_mr)) { | ||
503 | pr_err("Failed to allocate signature enabled mr err=%ld\n", | ||
504 | PTR_ERR(pi_ctx->sig_mr)); | ||
505 | ret = PTR_ERR(pi_ctx->sig_mr); | ||
506 | goto err_prot_mr; | ||
507 | } | ||
508 | fr_desc->ind |= ISERT_SIG_KEY_VALID; | ||
509 | } | ||
510 | fr_desc->ind &= ~ISERT_PROTECTED; | ||
511 | 527 | ||
512 | return 0; | 528 | return 0; |
513 | err_prot_mr: | 529 | |
514 | ib_dereg_mr(fr_desc->pi_ctx->prot_mr); | ||
515 | err_prot_frpl: | ||
516 | ib_free_fast_reg_page_list(fr_desc->pi_ctx->prot_frpl); | ||
517 | err_pi_ctx: | ||
518 | kfree(fr_desc->pi_ctx); | ||
519 | err_data_mr: | ||
520 | ib_dereg_mr(fr_desc->data_mr); | ||
521 | err_data_frpl: | 530 | err_data_frpl: |
522 | ib_free_fast_reg_page_list(fr_desc->data_frpl); | 531 | ib_free_fast_reg_page_list(fr_desc->data_frpl); |
523 | 532 | ||
@@ -525,7 +534,7 @@ err_data_frpl: | |||
525 | } | 534 | } |
526 | 535 | ||
527 | static int | 536 | static int |
528 | isert_conn_create_fastreg_pool(struct isert_conn *isert_conn, u8 pi_support) | 537 | isert_conn_create_fastreg_pool(struct isert_conn *isert_conn) |
529 | { | 538 | { |
530 | struct fast_reg_descriptor *fr_desc; | 539 | struct fast_reg_descriptor *fr_desc; |
531 | struct isert_device *device = isert_conn->conn_device; | 540 | struct isert_device *device = isert_conn->conn_device; |
@@ -549,8 +558,7 @@ isert_conn_create_fastreg_pool(struct isert_conn *isert_conn, u8 pi_support) | |||
549 | } | 558 | } |
550 | 559 | ||
551 | ret = isert_create_fr_desc(device->ib_device, | 560 | ret = isert_create_fr_desc(device->ib_device, |
552 | isert_conn->conn_pd, fr_desc, | 561 | isert_conn->conn_pd, fr_desc); |
553 | pi_support); | ||
554 | if (ret) { | 562 | if (ret) { |
555 | pr_err("Failed to create fastreg descriptor err=%d\n", | 563 | pr_err("Failed to create fastreg descriptor err=%d\n", |
556 | ret); | 564 | ret); |
@@ -581,7 +589,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
581 | struct isert_device *device; | 589 | struct isert_device *device; |
582 | struct ib_device *ib_dev = cma_id->device; | 590 | struct ib_device *ib_dev = cma_id->device; |
583 | int ret = 0; | 591 | int ret = 0; |
584 | u8 pi_support; | ||
585 | 592 | ||
586 | spin_lock_bh(&np->np_thread_lock); | 593 | spin_lock_bh(&np->np_thread_lock); |
587 | if (!np->enabled) { | 594 | if (!np->enabled) { |
@@ -681,15 +688,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
681 | goto out_mr; | 688 | goto out_mr; |
682 | } | 689 | } |
683 | 690 | ||
684 | pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi; | 691 | ret = isert_conn_setup_qp(isert_conn, cma_id); |
685 | if (pi_support && !device->pi_capable) { | ||
686 | pr_err("Protection information requested but not supported, " | ||
687 | "rejecting connect request\n"); | ||
688 | ret = rdma_reject(cma_id, NULL, 0); | ||
689 | goto out_mr; | ||
690 | } | ||
691 | |||
692 | ret = isert_conn_setup_qp(isert_conn, cma_id, pi_support); | ||
693 | if (ret) | 692 | if (ret) |
694 | goto out_conn_dev; | 693 | goto out_conn_dev; |
695 | 694 | ||
@@ -1151,11 +1150,7 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, | |||
1151 | if (login->login_complete) { | 1150 | if (login->login_complete) { |
1152 | if (!conn->sess->sess_ops->SessionType && | 1151 | if (!conn->sess->sess_ops->SessionType && |
1153 | isert_conn->conn_device->use_fastreg) { | 1152 | isert_conn->conn_device->use_fastreg) { |
1154 | /* Normal Session and fastreg is used */ | 1153 | ret = isert_conn_create_fastreg_pool(isert_conn); |
1155 | u8 pi_support = login->np->tpg_np->tpg->tpg_attrib.t10_pi; | ||
1156 | |||
1157 | ret = isert_conn_create_fastreg_pool(isert_conn, | ||
1158 | pi_support); | ||
1159 | if (ret) { | 1154 | if (ret) { |
1160 | pr_err("Conn: %p failed to create" | 1155 | pr_err("Conn: %p failed to create" |
1161 | " fastreg pool\n", isert_conn); | 1156 | " fastreg pool\n", isert_conn); |
@@ -2771,10 +2766,10 @@ isert_set_prot_checks(u8 prot_checks) | |||
2771 | } | 2766 | } |
2772 | 2767 | ||
2773 | static int | 2768 | static int |
2774 | isert_reg_sig_mr(struct isert_conn *isert_conn, struct se_cmd *se_cmd, | 2769 | isert_reg_sig_mr(struct isert_conn *isert_conn, |
2775 | struct fast_reg_descriptor *fr_desc, | 2770 | struct se_cmd *se_cmd, |
2776 | struct ib_sge *data_sge, struct ib_sge *prot_sge, | 2771 | struct isert_rdma_wr *rdma_wr, |
2777 | struct ib_sge *sig_sge) | 2772 | struct fast_reg_descriptor *fr_desc) |
2778 | { | 2773 | { |
2779 | struct ib_send_wr sig_wr, inv_wr; | 2774 | struct ib_send_wr sig_wr, inv_wr; |
2780 | struct ib_send_wr *bad_wr, *wr = NULL; | 2775 | struct ib_send_wr *bad_wr, *wr = NULL; |
@@ -2804,13 +2799,13 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, struct se_cmd *se_cmd, | |||
2804 | memset(&sig_wr, 0, sizeof(sig_wr)); | 2799 | memset(&sig_wr, 0, sizeof(sig_wr)); |
2805 | sig_wr.opcode = IB_WR_REG_SIG_MR; | 2800 | sig_wr.opcode = IB_WR_REG_SIG_MR; |
2806 | sig_wr.wr_id = ISER_FASTREG_LI_WRID; | 2801 | sig_wr.wr_id = ISER_FASTREG_LI_WRID; |
2807 | sig_wr.sg_list = data_sge; | 2802 | sig_wr.sg_list = &rdma_wr->ib_sg[DATA]; |
2808 | sig_wr.num_sge = 1; | 2803 | sig_wr.num_sge = 1; |
2809 | sig_wr.wr.sig_handover.access_flags = IB_ACCESS_LOCAL_WRITE; | 2804 | sig_wr.wr.sig_handover.access_flags = IB_ACCESS_LOCAL_WRITE; |
2810 | sig_wr.wr.sig_handover.sig_attrs = &sig_attrs; | 2805 | sig_wr.wr.sig_handover.sig_attrs = &sig_attrs; |
2811 | sig_wr.wr.sig_handover.sig_mr = pi_ctx->sig_mr; | 2806 | sig_wr.wr.sig_handover.sig_mr = pi_ctx->sig_mr; |
2812 | if (se_cmd->t_prot_sg) | 2807 | if (se_cmd->t_prot_sg) |
2813 | sig_wr.wr.sig_handover.prot = prot_sge; | 2808 | sig_wr.wr.sig_handover.prot = &rdma_wr->ib_sg[PROT]; |
2814 | 2809 | ||
2815 | if (!wr) | 2810 | if (!wr) |
2816 | wr = &sig_wr; | 2811 | wr = &sig_wr; |
@@ -2824,34 +2819,93 @@ isert_reg_sig_mr(struct isert_conn *isert_conn, struct se_cmd *se_cmd, | |||
2824 | } | 2819 | } |
2825 | fr_desc->ind &= ~ISERT_SIG_KEY_VALID; | 2820 | fr_desc->ind &= ~ISERT_SIG_KEY_VALID; |
2826 | 2821 | ||
2827 | sig_sge->lkey = pi_ctx->sig_mr->lkey; | 2822 | rdma_wr->ib_sg[SIG].lkey = pi_ctx->sig_mr->lkey; |
2828 | sig_sge->addr = 0; | 2823 | rdma_wr->ib_sg[SIG].addr = 0; |
2829 | sig_sge->length = se_cmd->data_length; | 2824 | rdma_wr->ib_sg[SIG].length = se_cmd->data_length; |
2830 | if (se_cmd->prot_op != TARGET_PROT_DIN_STRIP && | 2825 | if (se_cmd->prot_op != TARGET_PROT_DIN_STRIP && |
2831 | se_cmd->prot_op != TARGET_PROT_DOUT_INSERT) | 2826 | se_cmd->prot_op != TARGET_PROT_DOUT_INSERT) |
2832 | /* | 2827 | /* |
2833 | * We have protection guards on the wire | 2828 | * We have protection guards on the wire |
2834 | * so we need to set a larget transfer | 2829 | * so we need to set a larget transfer |
2835 | */ | 2830 | */ |
2836 | sig_sge->length += se_cmd->prot_length; | 2831 | rdma_wr->ib_sg[SIG].length += se_cmd->prot_length; |
2837 | 2832 | ||
2838 | pr_debug("sig_sge: addr: 0x%llx length: %u lkey: %x\n", | 2833 | pr_debug("sig_sge: addr: 0x%llx length: %u lkey: %x\n", |
2839 | sig_sge->addr, sig_sge->length, | 2834 | rdma_wr->ib_sg[SIG].addr, rdma_wr->ib_sg[SIG].length, |
2840 | sig_sge->lkey); | 2835 | rdma_wr->ib_sg[SIG].lkey); |
2841 | err: | 2836 | err: |
2842 | return ret; | 2837 | return ret; |
2843 | } | 2838 | } |
2844 | 2839 | ||
2845 | static int | 2840 | static int |
2841 | isert_handle_prot_cmd(struct isert_conn *isert_conn, | ||
2842 | struct isert_cmd *isert_cmd, | ||
2843 | struct isert_rdma_wr *wr) | ||
2844 | { | ||
2845 | struct isert_device *device = isert_conn->conn_device; | ||
2846 | struct se_cmd *se_cmd = &isert_cmd->iscsi_cmd->se_cmd; | ||
2847 | int ret; | ||
2848 | |||
2849 | if (!wr->fr_desc->pi_ctx) { | ||
2850 | ret = isert_create_pi_ctx(wr->fr_desc, | ||
2851 | device->ib_device, | ||
2852 | isert_conn->conn_pd); | ||
2853 | if (ret) { | ||
2854 | pr_err("conn %p failed to allocate pi_ctx\n", | ||
2855 | isert_conn); | ||
2856 | return ret; | ||
2857 | } | ||
2858 | } | ||
2859 | |||
2860 | if (se_cmd->t_prot_sg) { | ||
2861 | ret = isert_map_data_buf(isert_conn, isert_cmd, | ||
2862 | se_cmd->t_prot_sg, | ||
2863 | se_cmd->t_prot_nents, | ||
2864 | se_cmd->prot_length, | ||
2865 | 0, wr->iser_ib_op, &wr->prot); | ||
2866 | if (ret) { | ||
2867 | pr_err("conn %p failed to map protection buffer\n", | ||
2868 | isert_conn); | ||
2869 | return ret; | ||
2870 | } | ||
2871 | |||
2872 | memset(&wr->ib_sg[PROT], 0, sizeof(wr->ib_sg[PROT])); | ||
2873 | ret = isert_fast_reg_mr(isert_conn, wr->fr_desc, &wr->prot, | ||
2874 | ISERT_PROT_KEY_VALID, &wr->ib_sg[PROT]); | ||
2875 | if (ret) { | ||
2876 | pr_err("conn %p failed to fast reg mr\n", | ||
2877 | isert_conn); | ||
2878 | goto unmap_prot_cmd; | ||
2879 | } | ||
2880 | } | ||
2881 | |||
2882 | ret = isert_reg_sig_mr(isert_conn, se_cmd, wr, wr->fr_desc); | ||
2883 | if (ret) { | ||
2884 | pr_err("conn %p failed to fast reg mr\n", | ||
2885 | isert_conn); | ||
2886 | goto unmap_prot_cmd; | ||
2887 | } | ||
2888 | wr->fr_desc->ind |= ISERT_PROTECTED; | ||
2889 | |||
2890 | return 0; | ||
2891 | |||
2892 | unmap_prot_cmd: | ||
2893 | if (se_cmd->t_prot_sg) | ||
2894 | isert_unmap_data_buf(isert_conn, &wr->prot); | ||
2895 | |||
2896 | return ret; | ||
2897 | } | ||
2898 | |||
2899 | static int | ||
2846 | isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | 2900 | isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, |
2847 | struct isert_rdma_wr *wr) | 2901 | struct isert_rdma_wr *wr) |
2848 | { | 2902 | { |
2849 | struct se_cmd *se_cmd = &cmd->se_cmd; | 2903 | struct se_cmd *se_cmd = &cmd->se_cmd; |
2850 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | 2904 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
2851 | struct isert_conn *isert_conn = conn->context; | 2905 | struct isert_conn *isert_conn = conn->context; |
2852 | struct ib_sge data_sge; | ||
2853 | struct ib_send_wr *send_wr; | ||
2854 | struct fast_reg_descriptor *fr_desc = NULL; | 2906 | struct fast_reg_descriptor *fr_desc = NULL; |
2907 | struct ib_send_wr *send_wr; | ||
2908 | struct ib_sge *ib_sg; | ||
2855 | u32 offset; | 2909 | u32 offset; |
2856 | int ret = 0; | 2910 | int ret = 0; |
2857 | unsigned long flags; | 2911 | unsigned long flags; |
@@ -2876,38 +2930,21 @@ isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2876 | } | 2930 | } |
2877 | 2931 | ||
2878 | ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->data, | 2932 | ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->data, |
2879 | ISERT_DATA_KEY_VALID, &data_sge); | 2933 | ISERT_DATA_KEY_VALID, &wr->ib_sg[DATA]); |
2880 | if (ret) | 2934 | if (ret) |
2881 | goto unmap_cmd; | 2935 | goto unmap_cmd; |
2882 | 2936 | ||
2883 | if (se_cmd->prot_op != TARGET_PROT_NORMAL) { | 2937 | if (se_cmd->prot_op != TARGET_PROT_NORMAL) { |
2884 | struct ib_sge prot_sge, sig_sge; | 2938 | ret = isert_handle_prot_cmd(isert_conn, isert_cmd, wr); |
2885 | |||
2886 | if (se_cmd->t_prot_sg) { | ||
2887 | ret = isert_map_data_buf(isert_conn, isert_cmd, | ||
2888 | se_cmd->t_prot_sg, | ||
2889 | se_cmd->t_prot_nents, | ||
2890 | se_cmd->prot_length, | ||
2891 | 0, wr->iser_ib_op, &wr->prot); | ||
2892 | if (ret) | ||
2893 | goto unmap_cmd; | ||
2894 | |||
2895 | ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->prot, | ||
2896 | ISERT_PROT_KEY_VALID, &prot_sge); | ||
2897 | if (ret) | ||
2898 | goto unmap_prot_cmd; | ||
2899 | } | ||
2900 | |||
2901 | ret = isert_reg_sig_mr(isert_conn, se_cmd, fr_desc, | ||
2902 | &data_sge, &prot_sge, &sig_sge); | ||
2903 | if (ret) | 2939 | if (ret) |
2904 | goto unmap_prot_cmd; | 2940 | goto unmap_cmd; |
2905 | 2941 | ||
2906 | fr_desc->ind |= ISERT_PROTECTED; | 2942 | ib_sg = &wr->ib_sg[SIG]; |
2907 | memcpy(&wr->s_ib_sge, &sig_sge, sizeof(sig_sge)); | 2943 | } else { |
2908 | } else | 2944 | ib_sg = &wr->ib_sg[DATA]; |
2909 | memcpy(&wr->s_ib_sge, &data_sge, sizeof(data_sge)); | 2945 | } |
2910 | 2946 | ||
2947 | memcpy(&wr->s_ib_sge, ib_sg, sizeof(*ib_sg)); | ||
2911 | wr->ib_sge = &wr->s_ib_sge; | 2948 | wr->ib_sge = &wr->s_ib_sge; |
2912 | wr->send_wr_num = 1; | 2949 | wr->send_wr_num = 1; |
2913 | memset(&wr->s_send_wr, 0, sizeof(*send_wr)); | 2950 | memset(&wr->s_send_wr, 0, sizeof(*send_wr)); |
@@ -2932,9 +2969,7 @@ isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
2932 | } | 2969 | } |
2933 | 2970 | ||
2934 | return 0; | 2971 | return 0; |
2935 | unmap_prot_cmd: | 2972 | |
2936 | if (se_cmd->t_prot_sg) | ||
2937 | isert_unmap_data_buf(isert_conn, &wr->prot); | ||
2938 | unmap_cmd: | 2973 | unmap_cmd: |
2939 | if (fr_desc) { | 2974 | if (fr_desc) { |
2940 | spin_lock_irqsave(&isert_conn->conn_lock, flags); | 2975 | spin_lock_irqsave(&isert_conn->conn_lock, flags); |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index 9372d4d4d14a..2e7868c5ad14 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
@@ -82,6 +82,12 @@ struct isert_data_buf { | |||
82 | enum dma_data_direction dma_dir; | 82 | enum dma_data_direction dma_dir; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | enum { | ||
86 | DATA = 0, | ||
87 | PROT = 1, | ||
88 | SIG = 2, | ||
89 | }; | ||
90 | |||
85 | struct isert_rdma_wr { | 91 | struct isert_rdma_wr { |
86 | struct list_head wr_list; | 92 | struct list_head wr_list; |
87 | struct isert_cmd *isert_cmd; | 93 | struct isert_cmd *isert_cmd; |
@@ -91,6 +97,7 @@ struct isert_rdma_wr { | |||
91 | int send_wr_num; | 97 | int send_wr_num; |
92 | struct ib_send_wr *send_wr; | 98 | struct ib_send_wr *send_wr; |
93 | struct ib_send_wr s_send_wr; | 99 | struct ib_send_wr s_send_wr; |
100 | struct ib_sge ib_sg[3]; | ||
94 | struct isert_data_buf data; | 101 | struct isert_data_buf data; |
95 | struct isert_data_buf prot; | 102 | struct isert_data_buf prot; |
96 | struct fast_reg_descriptor *fr_desc; | 103 | struct fast_reg_descriptor *fr_desc; |