Enhance IB CM to support OPA extended LIDs
v3 cover Enhance IB CM to support OPA extended LIDs
This patch series adds enhancements to support extended LIDs in the IB CM protocol. The core idea is to trasmit extended LIDs as OPA GIDs on the wire in the primary_local_gid, primary_remote_gid, alternate_local_gid and alternate_remote_gid fields of a CM request. On the receiving side, the extended LID is retrieved from these gids when processing the connection request.
Changes from v2:
---------------
* Replace repeated record type logic with cm_path_set_rec_type().
Changes from v1:
---------------
* Replace 'IB/CM: Convert OPA Path record to IB during CM request' with Patch 1 to add OPA path record support to CM.
* Remove 'IB/CM: Change sgid to IB GID when handling CM request' as it is no longer need with the introduction of Patch 1.
The patches are organized as follows:
* Patch 1 adds OPA path record support to the Connection Manager.
* Patch 2 creates OPA path records when handling a connection request if the request contained OPA GIDs.
* Patch 3 'extracts' the OPA extended LIDs from the GID fields when handling the connection request
Please note that these patches apply on top of the previously submmitted patch set with subject: "[PATCH rdma-next 0/8] Add OPA extended LID support"
Dasaratharaman Chandramouli (2):
IB/CM: Create appropriate path records when handling CM request IB/CM: Set appropriate slid and dlid when handling CM request
Don Hiatt (1):
IB/CM: Add OPA Path record support to CM
drivers/infiniband/core/cm.c | 155 +++++++++++++++++++++++++++++++++++-------- include/rdma/opa_addr.h | 18 +++++ 2 files changed, 147 insertions(+), 26 deletions(-)
Signature · 5 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1496943484-44065-1-git-send-email-don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH v3 1/3 IB/CM: Add OPA Path record support to CM
Add OPA path record support to the Connection Manager.
--- drivers/infiniband/core/cm.c | 50 +++++++++++++++++++++++++++++++++++++------- include/rdma/opa_addr.h | 18 ++++++++++++++++ 2 files changed, 60 insertions(+), 8 deletions(-)
drivers/infiniband/core/cm.c +42 -8
@@ -1175,6 +1175,11 @@ static void cm_format_req(struct cm_req_msg *req_msg, {struct sa_path_rec *pri_path = param->primary_path;struct sa_path_rec *alt_path = param->alternate_path; +bool pri_ext = false; + +if (pri_path->rec_type ==SA_PATH_REC_TYPE_OPA ) + pri_ext =opa_is_extended_lid (pri_path->opa.dlid, + pri_path->opa.slid);cm_format_mad_hdr (&req_msg->hdr,CM_REQ_ATTR_ID ,cm_form_tid (cm_id_priv,CM_MSG_SEQUENCE_REQ ));
@@ -1202,18 +1207,24 @@ static void cm_format_req(struct cm_req_msg *req_msg,cm_req_set_srq (req_msg, param->srq); } + req_msg->primary_local_gid = pri_path->sgid; + req_msg->primary_remote_gid = pri_path->dgid; +if (pri_ext) { + req_msg->primary_local_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (pri_path->opa.slid)); + req_msg->primary_remote_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (pri_path->opa.dlid)); + }if (pri_path->hop_limit <=1 ) { - req_msg->primary_local_lid = + req_msg->primary_local_lid = pri_ext ?0 :htons (ntohl (sa_path_get_slid (pri_path))); - req_msg->primary_remote_lid = + req_msg->primary_remote_lid = pri_ext ?0 :htons (ntohl (sa_path_get_dlid (pri_path))); }else {/* Work-around until there's a way to obtain remote LID info */ req_msg->primary_local_lid =IB_LID_PERMISSIVE ; req_msg->primary_remote_lid =IB_LID_PERMISSIVE ; } - req_msg->primary_local_gid = pri_path->sgid; - req_msg->primary_remote_gid = pri_path->dgid;cm_req_set_primary_flow_label (req_msg, pri_path->flow_label);cm_req_set_primary_packet_rate (req_msg, pri_path->rate); req_msg->primary_traffic_class = pri_path->traffic_class;
@@ -1225,17 +1236,29 @@ static void cm_format_req(struct cm_req_msg *req_msg, pri_path->packet_life_time));if (alt_path) { +bool alt_ext = false; + +if (alt_path->rec_type ==SA_PATH_REC_TYPE_OPA ) + alt_ext =opa_is_extended_lid (alt_path->opa.dlid, + alt_path->opa.slid); + + req_msg->alt_local_gid = alt_path->sgid; + req_msg->alt_remote_gid = alt_path->dgid; +if (alt_ext) { + req_msg->alt_local_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (alt_path->opa.slid)); + req_msg->alt_remote_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (alt_path->opa.dlid)); + }if (alt_path->hop_limit <=1 ) { - req_msg->alt_local_lid = + req_msg->alt_local_lid = alt_ext ?0 :htons (ntohl (sa_path_get_slid (alt_path))); - req_msg->alt_remote_lid = + req_msg->alt_remote_lid = alt_ext ?0 :htons (ntohl (sa_path_get_dlid (alt_path))); }else { req_msg->alt_local_lid =IB_LID_PERMISSIVE ; req_msg->alt_remote_lid =IB_LID_PERMISSIVE ; } - req_msg->alt_local_gid = alt_path->sgid; - req_msg->alt_remote_gid = alt_path->dgid;cm_req_set_alt_flow_label (req_msg, alt_path->flow_label);cm_req_set_alt_packet_rate (req_msg, alt_path->rate);
@@ -2843,6 +2866,11 @@ static void cm_format_lap(struct cm_lap_msg *lap_msg,const void *private_data, u8 private_data_len) { + bool alt_ext = false; + +if (alternate_path->rec_type ==SA_PATH_REC_TYPE_OPA ) + alt_ext =opa_is_extended_lid (alternate_path->opa.dlid, + alternate_path->opa.slid);cm_format_mad_hdr (&lap_msg->hdr,CM_LAP_ATTR_ID ,cm_form_tid (cm_id_priv,CM_MSG_SEQUENCE_LAP )); lap_msg->local_comm_id = cm_id_priv->id.local_id;
@@ -2856,6 +2884,12 @@ static void cm_format_lap(struct cm_lap_msg *lap_msg,htons (ntohl (sa_path_get_dlid (alternate_path))); lap_msg->alt_local_gid = alternate_path->sgid; lap_msg->alt_remote_gid = alternate_path->dgid; +if (alt_ext) { + lap_msg->alt_local_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (alternate_path->opa.slid)); + lap_msg->alt_remote_gid.global.interface_id + =OPA_MAKE_ID (be32_to_cpu (alternate_path->opa.dlid)); + }cm_lap_set_flow_label (lap_msg, alternate_path->flow_label);cm_lap_set_traffic_class (lap_msg, alternate_path->traffic_class); lap_msg->alt_hop_limit = alternate_path->hop_limit;
include/rdma/opa_addr.h +18 -0
@@ -77,4 +77,22 @@ static inline u32 opa_get_lid_from_gid(union ib_gid *gid) {return be64_to_cpu (gid->global.interface_id) &0xFFFFFFFF ; } + +/** +* opa_is_extended_lid: Returns true if dlid or slid are +* extended. +* +* @dlid: The DLID +* @slid: The SLID +*/ +static inline bool opa_is_extended_lid (u32 dlid,u32 slid) +{ +if ((be32_to_cpu (dlid) >= +be16_to_cpu (IB_MULTICAST_LID_BASE )) || + (be32_to_cpu (slid) >= +be16_to_cpu (IB_MULTICAST_LID_BASE ))) +return true; +else +return false; +}#endif /* OPA_ADDR_H */
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/3 IB/CM: Create appropriate path records when handling CM request
In reply to a message not in the archiveFrom: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
When handling an incoming conection request, ib_cm creates either an IB or an OPA path record based on the gid field in the request.
--- drivers/infiniband/core/cm.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-)
drivers/infiniband/core/cm.c +31 -7
@@ -1428,6 +1428,21 @@ static inline int cm_is_active_peer(__be64 local_ca_guid, __be64 remote_ca_guid, (be32_to_cpu(local_qpn) > be32_to_cpu(remote_qpn)))); } +static bool cm_req_has_alt_path (struct cm_req_msg *req_msg) +{ +return ((req_msg->alt_local_lid) || + (ib_is_opa_gid (&req_msg->alt_local_gid))); +} + +static void cm_path_set_rec_type (struct ib_device *ib_device,u8 port_num, +struct sa_path_rec *path,union ib_gid *gid) +{ +if (ib_is_opa_gid (gid) &&rdma_cap_opa_ah (ib_device, port_num)) + path->rec_type =SA_PATH_REC_TYPE_OPA ; +else + path->rec_type =SA_PATH_REC_TYPE_IB ; +} +static void cm_format_paths_from_req (struct cm_req_msg *req_msg,struct sa_path_rec *primary_path,struct sa_path_rec *alt_path)
@@ -1807,9 +1822,12 @@ static int cm_req_handler(struct cm_work *work) dev_net(gid_attr.ndev));dev_put (gid_attr.ndev); }else { - work->path[0 ].rec_type =SA_PATH_REC_TYPE_IB ; +cm_path_set_rec_type (work->port->cm_dev->ib_device, + work->port->port_num, + &work->path[0 ], + &req_msg->primary_local_gid); } -if (req_msg->alt_local_lid) +if (cm_req_has_alt_path (req_msg)) work->path[1 ].rec_type = work->path[0 ].rec_type;cm_format_paths_from_req (req_msg, &work->path[0 ], &work->path[1 ]);
@@ -1834,16 +1852,19 @@ static int cm_req_handler(struct cm_work *work) dev_net(gid_attr.ndev));dev_put (gid_attr.ndev); }else { - work->path[0 ].rec_type =SA_PATH_REC_TYPE_IB ; +cm_path_set_rec_type (work->port->cm_dev->ib_device, + work->port->port_num, + &work->path[0 ], + &req_msg->primary_local_gid); } -if (req_msg->alt_local_lid) +if (cm_req_has_alt_path (req_msg)) work->path[1 ].rec_type = work->path[0 ].rec_type;ib_send_cm_rej (cm_id,IB_CM_REJ_INVALID_GID , &work->path[0 ].sgid,sizeof work->path[0 ].sgid,NULL ,0 ); goto rejected; } -if (req_msg->alt_local_lid) { +if (cm_req_has_alt_path (req_msg)) { ret =cm_init_av_by_path (&work->path[1 ], &cm_id_priv->alt_av, cm_id_priv);if (ret) {
@@ -2962,8 +2983,6 @@ static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,struct sa_path_rec *path, struct cm_lap_msg *lap_msg) { - memset(path, 0, sizeof *path); - path->rec_type =SA_PATH_REC_TYPE_IB ; path->dgid = lap_msg->alt_local_gid; path->sgid = lap_msg->alt_remote_gid;sa_path_set_dlid (path,htonl (ntohs (lap_msg->alt_local_lid)));
@@ -2999,6 +3018,11 @@ static int cm_lap_handler(struct cm_work *work)return -EINVAL ; param = &work->cm_event.param.lap_rcvd; +memset (&work->path[0 ],0 ,sizeof (work->path[1 ])); +cm_path_set_rec_type (work->port->cm_dev->ib_device, + work->port->port_num, + &work->path[0 ], + &lap_msg->alt_local_gid); param->alternate_path = &work->path[0 ];cm_format_path_from_lap (cm_id_priv, param->alternate_path, lap_msg); work->cm_event.private_data = &lap_msg->private_data;
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/3 IB/CM: Set appropriate slid and dlid when handling CM request
In reply to a message not in the archiveFrom: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
If extended LIDs are being used, a connection request contains OPA GIDs in them. Extract the lids from the OPA gids and populate slid/dlid fields in the path records that are created when handling a connection request.
--- drivers/infiniband/core/cm.c | 67 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 11 deletions(-)
drivers/infiniband/core/cm.c +56 -11
@@ -1443,16 +1443,48 @@ static void cm_path_set_rec_type(struct ib_device *ib_device, u8 port_num, path->rec_type =SA_PATH_REC_TYPE_IB ; } +static void cm_format_path_lid_from_req (struct cm_req_msg *req_msg, +struct sa_path_rec *primary_path, +struct sa_path_rec *alt_path) +{ +u32 lid; + +if (primary_path->rec_type !=SA_PATH_REC_TYPE_OPA ) { +sa_path_set_dlid (primary_path, +htonl (ntohs (req_msg->primary_local_lid))); +sa_path_set_slid (primary_path, +htonl (ntohs (req_msg->primary_remote_lid))); + }else { + lid =opa_get_lid_from_gid (&req_msg->primary_local_gid); +sa_path_set_dlid (primary_path,cpu_to_be32 (lid)); + + lid =opa_get_lid_from_gid (&req_msg->primary_remote_gid); +sa_path_set_slid (primary_path,cpu_to_be32 (lid)); + } + +if (!cm_req_has_alt_path (req_msg)) +return ; + +if (alt_path->rec_type !=SA_PATH_REC_TYPE_OPA ) { +sa_path_set_dlid (alt_path, +htonl (ntohs (req_msg->alt_local_lid))); +sa_path_set_slid (alt_path, +htonl (ntohs (req_msg->alt_remote_lid))); + }else { + lid =opa_get_lid_from_gid (&req_msg->alt_local_gid); +sa_path_set_dlid (alt_path,cpu_to_be32 (lid)); + + lid =opa_get_lid_from_gid (&req_msg->alt_remote_gid); +sa_path_set_slid (alt_path,cpu_to_be32 (lid)); + } +} +static void cm_format_paths_from_req (struct cm_req_msg *req_msg,struct sa_path_rec *primary_path,struct sa_path_rec *alt_path) { primary_path->dgid = req_msg->primary_local_gid; primary_path->sgid = req_msg->primary_remote_gid; -sa_path_set_dlid (primary_path, -htonl (ntohs (req_msg->primary_local_lid))); -sa_path_set_slid (primary_path, -htonl (ntohs (req_msg->primary_remote_lid))); primary_path->flow_label =cm_req_get_primary_flow_label (req_msg); primary_path->hop_limit = req_msg->primary_hop_limit; primary_path->traffic_class = req_msg->primary_traffic_class;
@@ -1469,13 +1501,9 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg, primary_path->packet_life_time -= (primary_path->packet_life_time >0 );sa_path_set_service_id (primary_path, req_msg->service_id); -if (req_msg->alt_local_lid) { +if (cm_req_has_alt_path (req_msg)) { alt_path->dgid = req_msg->alt_local_gid; alt_path->sgid = req_msg->alt_remote_gid; -sa_path_set_dlid (alt_path, -htonl (ntohs (req_msg->alt_local_lid))); -sa_path_set_slid (alt_path, -htonl (ntohs (req_msg->alt_remote_lid))); alt_path->flow_label =cm_req_get_alt_flow_label (req_msg); alt_path->hop_limit = req_msg->alt_hop_limit; alt_path->traffic_class = req_msg->alt_traffic_class;
@@ -1492,6 +1520,7 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg, alt_path->packet_life_time -= (alt_path->packet_life_time >0 );sa_path_set_service_id (alt_path, req_msg->service_id); } +cm_format_path_lid_from_req (req_msg, primary_path, alt_path); }static u16 cm_get_bth_pkey (struct cm_work *work)
@@ -2979,14 +3008,29 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id, }EXPORT_SYMBOL (ib_send_cm_lap); +static void cm_format_path_lid_from_lap (struct cm_lap_msg *lap_msg, +struct sa_path_rec *path) +{ +u32 lid; + +if (path->rec_type !=SA_PATH_REC_TYPE_OPA ) { +sa_path_set_dlid (path,htonl (ntohs (lap_msg->alt_local_lid))); +sa_path_set_slid (path,htonl (ntohs (lap_msg->alt_remote_lid))); + }else { + lid =opa_get_lid_from_gid (&lap_msg->alt_local_gid); +sa_path_set_dlid (path,cpu_to_be32 (lid)); + + lid =opa_get_lid_from_gid (&lap_msg->alt_remote_gid); +sa_path_set_slid (path,cpu_to_be32 (lid)); + } +} +static void cm_format_path_from_lap (struct cm_id_private *cm_id_priv,struct sa_path_rec *path,struct cm_lap_msg *lap_msg) { path->dgid = lap_msg->alt_local_gid; path->sgid = lap_msg->alt_remote_gid; -sa_path_set_dlid (path,htonl (ntohs (lap_msg->alt_local_lid))); -sa_path_set_slid (path,htonl (ntohs (lap_msg->alt_remote_lid))); path->flow_label =cm_lap_get_flow_label (lap_msg); path->hop_limit = lap_msg->alt_hop_limit; path->traffic_class =cm_lap_get_traffic_class (lap_msg);
@@ -3000,6 +3044,7 @@ static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv, path->packet_life_time_selector =IB_SA_EQ ; path->packet_life_time =cm_lap_get_local_ack_timeout (lap_msg); path->packet_life_time -= (path->packet_life_time >0 ); +cm_format_path_lid_from_lap (lap_msg, path); }static int cm_lap_handler (struct cm_work *work)
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Don Hiatt
This patch series adds enhancements to support extended LIDs in the IB CM protocol. The core idea is to trasmit extended LIDs as OPA GIDs on the wire in the
primary_local_gid,primary_remote_gid,alternate_local_gidandalternate_remote_gidfields of a CM request. On the receiving side, the extended LID is retrieved from these gids when processing the connection request.
Hi Don,
Thanks, series applied.
Signature · 8 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html