Skip to content

Commit 24cad9a

Browse files
haggaiedledford
authored andcommitted
IB/cm: Expose BTH P_Key in CM and SIDR request events
The rdma_cm module will later use the P_Key from the BTH to de-mux requests. See discussion at: http://www.spinics.net/lists/netdev/msg336067.html Cc: Jason Gunthorpe <[email protected]> Cc: Liran Liss <[email protected]> Signed-off-by: Haggai Eran <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent aac978e commit 24cad9a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/infiniband/core/cm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,24 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
14041404
}
14051405
}
14061406

1407+
static u16 cm_get_bth_pkey(struct cm_work *work)
1408+
{
1409+
struct ib_device *ib_dev = work->port->cm_dev->ib_device;
1410+
u8 port_num = work->port->port_num;
1411+
u16 pkey_index = work->mad_recv_wc->wc->pkey_index;
1412+
u16 pkey;
1413+
int ret;
1414+
1415+
ret = ib_get_cached_pkey(ib_dev, port_num, pkey_index, &pkey);
1416+
if (ret) {
1417+
dev_warn_ratelimited(&ib_dev->dev, "ib_cm: Couldn't retrieve pkey for incoming request (port %d, pkey index %d). %d\n",
1418+
port_num, pkey_index, ret);
1419+
return 0;
1420+
}
1421+
1422+
return pkey;
1423+
}
1424+
14071425
static void cm_format_req_event(struct cm_work *work,
14081426
struct cm_id_private *cm_id_priv,
14091427
struct ib_cm_id *listen_id)
@@ -1414,6 +1432,7 @@ static void cm_format_req_event(struct cm_work *work,
14141432
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
14151433
param = &work->cm_event.param.req_rcvd;
14161434
param->listen_id = listen_id;
1435+
param->bth_pkey = cm_get_bth_pkey(work);
14171436
param->port = cm_id_priv->av.port->port_num;
14181437
param->primary_path = &work->path[0];
14191438
if (req_msg->alt_local_lid)
@@ -3105,6 +3124,7 @@ static void cm_format_sidr_req_event(struct cm_work *work,
31053124
param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
31063125
param->listen_id = listen_id;
31073126
param->service_id = sidr_req_msg->service_id;
3127+
param->bth_pkey = cm_get_bth_pkey(work);
31083128
param->port = work->port->port_num;
31093129
work->cm_event.private_data = &sidr_req_msg->private_data;
31103130
}

include/rdma/ib_cm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ struct ib_cm_id;
113113

114114
struct ib_cm_req_event_param {
115115
struct ib_cm_id *listen_id;
116+
117+
/* P_Key that was used by the GMP's BTH header */
118+
u16 bth_pkey;
119+
116120
u8 port;
117121

118122
struct ib_sa_path_rec *primary_path;
@@ -224,6 +228,8 @@ struct ib_cm_apr_event_param {
224228
struct ib_cm_sidr_req_event_param {
225229
struct ib_cm_id *listen_id;
226230
__be64 service_id;
231+
/* P_Key that was used by the GMP's BTH header */
232+
u16 bth_pkey;
227233
u8 port;
228234
u16 pkey;
229235
};

0 commit comments

Comments
 (0)