Commit 24cad9a7 authored by Haggai Eran's avatar Haggai Eran Committed by Doug Ledford

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 <jgunthorpe@obsidianresearch.com>
Cc: Liran Liss <liranl@mellanox.com>
Signed-off-by: default avatarHaggai Eran <haggaie@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent aac978e1
...@@ -1404,6 +1404,24 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg, ...@@ -1404,6 +1404,24 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
} }
} }
static u16 cm_get_bth_pkey(struct cm_work *work)
{
struct ib_device *ib_dev = work->port->cm_dev->ib_device;
u8 port_num = work->port->port_num;
u16 pkey_index = work->mad_recv_wc->wc->pkey_index;
u16 pkey;
int ret;
ret = ib_get_cached_pkey(ib_dev, port_num, pkey_index, &pkey);
if (ret) {
dev_warn_ratelimited(&ib_dev->dev, "ib_cm: Couldn't retrieve pkey for incoming request (port %d, pkey index %d). %d\n",
port_num, pkey_index, ret);
return 0;
}
return pkey;
}
static void cm_format_req_event(struct cm_work *work, static void cm_format_req_event(struct cm_work *work,
struct cm_id_private *cm_id_priv, struct cm_id_private *cm_id_priv,
struct ib_cm_id *listen_id) struct ib_cm_id *listen_id)
...@@ -1414,6 +1432,7 @@ static void cm_format_req_event(struct cm_work *work, ...@@ -1414,6 +1432,7 @@ static void cm_format_req_event(struct cm_work *work,
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
param = &work->cm_event.param.req_rcvd; param = &work->cm_event.param.req_rcvd;
param->listen_id = listen_id; param->listen_id = listen_id;
param->bth_pkey = cm_get_bth_pkey(work);
param->port = cm_id_priv->av.port->port_num; param->port = cm_id_priv->av.port->port_num;
param->primary_path = &work->path[0]; param->primary_path = &work->path[0];
if (req_msg->alt_local_lid) if (req_msg->alt_local_lid)
...@@ -3105,6 +3124,7 @@ static void cm_format_sidr_req_event(struct cm_work *work, ...@@ -3105,6 +3124,7 @@ static void cm_format_sidr_req_event(struct cm_work *work,
param->pkey = __be16_to_cpu(sidr_req_msg->pkey); param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
param->listen_id = listen_id; param->listen_id = listen_id;
param->service_id = sidr_req_msg->service_id; param->service_id = sidr_req_msg->service_id;
param->bth_pkey = cm_get_bth_pkey(work);
param->port = work->port->port_num; param->port = work->port->port_num;
work->cm_event.private_data = &sidr_req_msg->private_data; work->cm_event.private_data = &sidr_req_msg->private_data;
} }
......
...@@ -113,6 +113,10 @@ struct ib_cm_id; ...@@ -113,6 +113,10 @@ struct ib_cm_id;
struct ib_cm_req_event_param { struct ib_cm_req_event_param {
struct ib_cm_id *listen_id; struct ib_cm_id *listen_id;
/* P_Key that was used by the GMP's BTH header */
u16 bth_pkey;
u8 port; u8 port;
struct ib_sa_path_rec *primary_path; struct ib_sa_path_rec *primary_path;
...@@ -224,6 +228,8 @@ struct ib_cm_apr_event_param { ...@@ -224,6 +228,8 @@ struct ib_cm_apr_event_param {
struct ib_cm_sidr_req_event_param { struct ib_cm_sidr_req_event_param {
struct ib_cm_id *listen_id; struct ib_cm_id *listen_id;
__be64 service_id; __be64 service_id;
/* P_Key that was used by the GMP's BTH header */
u16 bth_pkey;
u8 port; u8 port;
u16 pkey; u16 pkey;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment