ib_srpt: Cache P_Key lookups

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5426 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-04-16 08:23:11 +00:00
parent 5b7e52b654
commit 4acf8e249f
2 changed files with 12 additions and 11 deletions

View File

@@ -41,6 +41,7 @@
#include <linux/kthread.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <rdma/ib_cache.h>
#include <asm/atomic.h>
#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;

View File

@@ -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;