diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 2a1dc0b4e..c52f3aeea 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -1155,7 +1155,7 @@ static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp) attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE; attr->port_num = ch->sport->port; - attr->pkey_index = 0; + attr->pkey_index = ch->pkey_index; ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PORT | @@ -2515,6 +2515,14 @@ 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); + } memcpy(ch->i_port_id, req->initiator_port_id, 16); memcpy(ch->t_port_id, req->target_port_id, 16); ch->sport = sport; diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 21554d223..529edc4c9 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -314,6 +314,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. * @scst_sess: SCST session information associated with this SRP channel. * @sess_name: SCST session name. */ @@ -341,6 +342,7 @@ struct srpt_rdma_ch { enum rdma_ch_state state; struct list_head list; struct list_head cmd_wait_list; + uint16_t pkey_index; bool dreq_received; bool last_wqe_received;