diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 2a2c35236..b82abb709 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #if defined(CONFIG_SCST_PROC) #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) @@ -1122,7 +1123,14 @@ static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp) attr->qp_state = IB_QPS_INIT; attr->port_num = ch->sport->port; - attr->pkey_index = ch->pkey_index; + + ret = ib_find_cached_pkey(ch->sport->sdev->device, ch->sport->port, + ch->pkey, &attr->pkey_index); + if (ret < 0) { + attr->pkey_index = 0; + PRINT_ERROR("Translating pkey %#x failed (%d) - using index 0", + ch->pkey, ret); + } ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PORT | @@ -2489,14 +2497,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, } kref_init(&ch->kref); - ret = ib_find_pkey(sdev->device, sport->port, - be16_to_cpu(param->primary_path->pkey), - &ch->pkey_index); - if (ret < 0) { - ch->pkey_index = 0; - PRINT_ERROR("Translating pkey %#x failed (%d) - using index 0", - be16_to_cpu(param->primary_path->pkey), ret); - } + ch->pkey = be16_to_cpu(param->primary_path->pkey); ch->nexus = nexus; ch->sport = sport; ch->srpt_tgt = srpt_tgt; diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 621ca3926..f10e4583c 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -327,7 +327,7 @@ enum rdma_ch_state { * @cmd_wait_list: list of SCST commands that arrived before the RTU event. This * list contains struct srpt_ioctx elements and is protected * against concurrent modification by the cm_id spinlock. - * @pkey_index: P_Key index of the IB partition for this SRP channel. + * @pkey: P_Key of the IB partition for this SRP channel. * @scst_sess: SCST session information associated with this SRP channel. * @sess_name: SCST session name. */ @@ -354,7 +354,7 @@ struct srpt_rdma_ch { enum rdma_ch_state state; struct list_head list; struct list_head cmd_wait_list; - uint16_t pkey_index; + uint16_t pkey; bool processing_wait_list; struct scst_session *scst_sess;