Skip to contentSkip to conversation

Add OPA extended LID support

PATCH In review Don Hiatt 3 participants 12 messages Aug 10, 2017 – Aug 11, 2017 3 messages not in the archive

Subsystems (6)
lore
Share & tools
lore

Don Hiatt

author
#0 lore raw

v4 cover Add OPA extended LID support

This patch series primarily increases sizes of variables that hold lid values from 16 to 32 bits. Additionally, it adds a check in the IB mad stack to verify a properly formatted MAD when OPA extended LIDs are used.

Changes from v3:
---------------
* Add 'IB/core: Add functions to convert 32 bit lids to 16 bits' and use them in place of casts.

Changes from v2:
---------------
* Remove 'IB/mad: Ensure DR MADs are correctly specified when using OPA devices' as this will be handled in a lower layer.

Changes from v1:
---------------
* Remove extraneous slid set.
* Replace slid casts with helper function.
* Return default subnet prefix on rdma_ah_conv_opa_to_ib() failure.

The patches are origanized as follows:

* Patch 1 converts an OPA ah_attr to an IB ah_attr when copying from kernel to user. Since OPA ah_attr is only defined in the kernel, the function takes care of adding OPA GIDs that contain the extended LID before copying to user.
* Patch 2 increases the lid and sm_lid variables in srpt to 32 bits.
* Patch 3 increases the local_lid variable in IPoIB to 32 bits.
* Patch 4 increases the slid variable in MAD RMPP to 32 bits.
* Patch 5 Adds functions to convert 32 bit lids to 16 bits.
* Patch 6 increases the lid field in struct ib_port_attr from 16 to 32 bits.
* Patch 7 increases the sm_lid field in struct ib_port_attr from 16 to 32 bits.
* Patch 8 increases the slid field in struct ib_wc from 16 to 32 bits.

Dasaratharaman Chandramouli (6):
IB/core: Convert ah_attr from OPA to IB when copying to user IB/srpt: Increase lid and sm_lid to 32 bits IB/IPoIB: Increase local_lid to 32 bits
IB/mad: Change slid in RMPP recv from 16 to 32 bits IB/core: Change port_attr.lid size from 16 to 32 bits IB/core: Change port_attr.sm_lid from 16 to 32 bits

Don Hiatt (2):
IB/core: Add functions to convert 32 bit lids to 16 bits IB/core: Change wc.slid from 16 to 32 bits

 drivers/infiniband/core/cm.c              |  4 ++--
 drivers/infiniband/core/core_priv.h       |  1 +
 drivers/infiniband/core/mad_rmpp.c        |  2 +-
 drivers/infiniband/core/ucm.c             |  2 +-
 drivers/infiniband/core/ucma.c            | 10 +++++----
 drivers/infiniband/core/user_mad.c        |  2 +-
 drivers/infiniband/core/uverbs_cmd.c      | 26 +++++++++++++++++-----
 drivers/infiniband/core/uverbs_marshall.c | 48 ++++++++++++++++++++++++++++++++++++-----
 drivers/infiniband/hw/hfi1/mad.c          |  2 +-
 drivers/infiniband/hw/mlx4/alias_GUID.c   |  2 +-
 drivers/infiniband/hw/mlx4/mad.c          |  8 +++----
 drivers/infiniband/hw/mlx5/mad.c          |  2 +-
 drivers/infiniband/hw/mthca/mthca_cmd.c   |  4 ++--
 drivers/infiniband/hw/mthca/mthca_mad.c   |  4 ++--
 drivers/infiniband/sw/rdmavt/cq.c         |  2 +-
 drivers/infiniband/ulp/ipoib/ipoib.h      |  2 +-
 drivers/infiniband/ulp/srpt/ib_srpt.h     |  4 ++--
 include/rdma/ib_marshall.h                |  6 ++++--
 include/rdma/ib_verbs.h                   | 18 +++++++++++++---
 include/rdma/opa_addr.h                   |  3 ++-
 20 files changed, 112 insertions(+), 40 deletions(-)
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

A message that is not in the archive (sent off-list or not yet received): 1502388268-20687-1-git-send-email-don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

author
#2 lore raw

PATCH v4 1/8 IB/core: Convert ah_attr from OPA to IB when copying to user

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

OPA address handle atttibutes that have 32 bit LIDs would have to be converted to IB address handle attribute with the LID field programmed in the GID before copying to user space.

---
 drivers/infiniband/core/ucm.c             |  2 +-
 drivers/infiniband/core/ucma.c            | 10 ++++---
 drivers/infiniband/core/uverbs_marshall.c | 48 +++++++++++++++++++++++++++----
 include/rdma/ib_marshall.h                |  6 ++--
 4 files changed, 54 insertions(+), 12 deletions(-)
drivers/infiniband/core/ucm.c +1 -1
index 112099c..f2a7f62 100644
@@ -618,7 +618,7 @@ static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file,
 	if (result)
 		goto out;
 
-	ib_copy_qp_attr_to_user(&resp, &qp_attr);
+	ib_copy_qp_attr_to_user(ctx->cm_id->device, &resp, &qp_attr);
 
 	if (copy_to_user((void __user *)(unsigned long)cmd.response,
 			 &resp, sizeof(resp)))
drivers/infiniband/core/ucma.c +6 -4
index 276f0ef..eb85b54 100644
@@ -248,14 +248,15 @@ static void ucma_copy_conn_event(struct rdma_ucm_conn_param *dst,
 	dst->qp_num = src->qp_num;
 }
 
-static void ucma_copy_ud_event(struct rdma_ucm_ud_param *dst,
+static void ucma_copy_ud_event(struct ib_device *device,
+			       struct rdma_ucm_ud_param *dst,
 			       struct rdma_ud_param *src)
 {
 	if (src->private_data_len)
 		memcpy(dst->private_data, src->private_data,
 		       src->private_data_len);
 	dst->private_data_len = src->private_data_len;
-	ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
+	ib_copy_ah_attr_to_user(device, &dst->ah_attr, &src->ah_attr);
 	dst->qp_num = src->qp_num;
 	dst->qkey = src->qkey;
 }
@@ -335,7 +336,8 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
 	uevent->resp.event = event->event;
 	uevent->resp.status = event->status;
 	if (cm_id->qp_type == IB_QPT_UD)
-		ucma_copy_ud_event(&uevent->resp.param.ud, &event->param.ud);
+		ucma_copy_ud_event(cm_id->device, &uevent->resp.param.ud,
+				   &event->param.ud);
 	else
 		ucma_copy_conn_event(&uevent->resp.param.conn,
 				     &event->param.conn);
@@ -1157,7 +1159,7 @@ static ssize_t ucma_init_qp_attr(struct ucma_file *file,
 	if (ret)
 		goto out;
 
-	ib_copy_qp_attr_to_user(&resp, &qp_attr);
+	ib_copy_qp_attr_to_user(ctx->cm_id->device, &resp, &qp_attr);
 	if (copy_to_user((void __user *)(unsigned long)cmd.response,
 			 &resp, sizeof(resp)))
 		ret = -EFAULT;
drivers/infiniband/core/uverbs_marshall.c +43 -5

68 lines not on this page · raw message

include/rdma/ib_marshall.h +4 -2
index 68cef3b..8ebf84a 100644
@@ -38,10 +38,12 @@
 #include <rdma/ib_user_verbs.h>
 #include <rdma/ib_user_sa.h>
 
-void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
+void ib_copy_qp_attr_to_user(struct ib_device *device,
+			     struct ib_uverbs_qp_attr *dst,
 			     struct ib_qp_attr *src);
 
-void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
+void ib_copy_ah_attr_to_user(struct ib_device *device,
+			     struct ib_uverbs_ah_attr *dst,
 			     struct rdma_ah_attr *src);
 
 void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
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
author
#3 lore raw

PATCH v4 2/8 IB/srpt: Increase lid and sm_lid to 32 bits

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

srpt contains lid and sm_lid fields which are 16 bits in length, increase them to 32 bits.

---
 drivers/infiniband/ulp/srpt/ib_srpt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.h +2 -2
index cc118385..1b817e5 100644
@@ -328,8 +328,8 @@ struct srpt_port {
 	u8			port_guid[24];
 	u8			port_gid[64];
 	u8			port;
-	u16			sm_lid;
-	u16			lid;
+	u32			sm_lid;
+	u32			lid;
 	union ib_gid		gid;
 	struct work_struct	work;
 	struct se_portal_group	port_guid_tpg;
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
author
#4 lore raw

PATCH v4 3/8 IB/IPoIB: Increase local_lid to 32 bits

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

IPoIB contains local_lid field which is 16 bits in length, increase it to 32 bits.

---
 drivers/infiniband/ulp/ipoib/ipoib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/ipoib/ipoib.h +1 -1
index ff50a7b..9e73810 100644
@@ -366,7 +366,7 @@ struct ipoib_dev_priv {
 	u32		  qkey;
 
 	union ib_gid local_gid;
-	u16	     local_lid;
+	u32	     local_lid;
 
 	unsigned int admin_mtu;
 	unsigned int mcast_mtu;
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
author
#5 lore raw

PATCH v4 4/8 IB/mad: Change slid in RMPP recv from 16 to 32 bits

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

MAD RMPP contains slid field which is 16 bits in
length, increase it to 32 bits.

---
 drivers/infiniband/core/mad_rmpp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/mad_rmpp.c +1 -1
index 0d3cca0..e5cf09c 100644
@@ -64,7 +64,7 @@ struct mad_rmpp_recv {
 
 	__be64 tid;
 	u32 src_qp;
-	u16 slid;
+	u32 slid;
 	u8 mgmt_class;
 	u8 class_version;
 	u8 method;
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
author
#6 lore raw

PATCH v4 5/8 IB/core: Add functions to convert 32 bit lids to 16 bits

In reply to a message not in the archive

Add two helper functions (ib_lid_cpu16(), ib_lid_be16()) to convert 32 bit lids to 16 bits.

---
 include/rdma/ib_verbs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/rdma/ib_verbs.h +12 -0
index a7d6990..3875ea5d 100644
@@ -3710,4 +3710,16 @@ static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev,
 	else
 		return RDMA_AH_ATTR_TYPE_IB;
 }
+
+/* Return lid in 16bit CPU encoding */
+static inline u16 ib_lid_cpu16(u32 lid)
+{
+	return (u16)lid;
+}
+
+/* Return lid in 16bit BE encoding */
+static inline u16 ib_lid_be16(u32 lid)
+{
+	return cpu_to_be16((u16)lid);
+}
 #endif /* IB_VERBS_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

A message that is not in the archive (sent off-list or not yet received): 1502388268-20687-6-git-send-email-don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#8 lore raw

Re: [PATCH rdma-next v4 5/8] IB/core: Add functions to convert 32 bit lids to 16 bits

Quoted 19 lines · Don Hiatt

Add two helper functions (ib_lid_cpu16(), ib_lid_be16()) to convert 32 bit lids to 16 bits.

---
 include/rdma/ib_verbs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/rdma/ib_verbs.h +2 -0
index a7d6990..3875ea5d 100644
@@ -3710,4 +3710,16 @@ static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev,
 	else
 		return RDMA_AH_ATTR_TYPE_IB;
 }
+
+/* Return lid in 16bit CPU encoding */

include/rdma/ib_verbs.h static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev, · line 3724

Quoted 10 lines
include/rdma/ib_verbs.h +10 -0
+static inline u16 ib_lid_cpu16(u32 lid)
+{
+	return (u16)lid;
+}
+
+/* Return lid in 16bit BE encoding */
+static inline u16 ib_lid_be16(u32 lid)
+{
+	return cpu_to_be16((u16)lid);
+}

Please add comments to these functions, with the description when and why we are doing this conversion, and I think that it is worth to add here WARN_ON_ONCE(lid && 0xFFFF0000) to catch possible bad flows.

Quoted 8 lines
include/rdma/ib_verbs.h +0 -1
 #endif /* IB_VERBS_H */
--

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

author
#9 lore raw

PATCH v4 6/8 IB/core: Change port_attr.lid size from 16 to 32 bits

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

lid field in struct ib_port_attr is increased to 32 bits. This enables core components to use larger LIDs if needed.

The user ABI is unchanged and return 16 bit values when queried.

---
 drivers/infiniband/core/core_priv.h     |  1 +
 drivers/infiniband/core/uverbs_cmd.c    | 12 +++++++++++-
 drivers/infiniband/hw/mlx4/alias_GUID.c |  2 +-
 drivers/infiniband/hw/mlx4/mad.c        |  2 +-
 drivers/infiniband/hw/mthca/mthca_mad.c |  2 +-
 include/rdma/ib_verbs.h                 |  2 +-
 include/rdma/opa_addr.h                 |  3 ++-
 7 files changed, 18 insertions(+), 6 deletions(-)
drivers/infiniband/core/core_priv.h +1 -0
index 11ae675..9d4f17f 100644
@@ -39,6 +39,7 @@
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_mad.h>
+#include <rdma/opa_addr.h>
 #include "mad_priv.h"
 
 struct pkey_index_qp_list {
drivers/infiniband/core/uverbs_cmd.c +11 -1
index 2c98533..e693b8b 100644
@@ -275,8 +275,18 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
 	resp.bad_pkey_cntr   = attr.bad_pkey_cntr;
 	resp.qkey_viol_cntr  = attr.qkey_viol_cntr;
 	resp.pkey_tbl_len    = attr.pkey_tbl_len;
-	resp.lid 	     = attr.lid;
 	resp.sm_lid 	     = attr.sm_lid;
+
+	/*
+	 * In the current implementation the only way to get
+	 * the 32bit lid is from other sources for OPA.
+	 * For IB, lids will always be 16bits so cast the
+	 * value accordingly.
+	 */
+	if (rdma_cap_opa_ah(ib_dev, cmd.port_num))
+		resp.lid     = OPA_TO_IB_UCAST_LID(attr.lid);
+	else
+		resp.lid     = ib_lid_cpu16(attr.lid);
 	resp.lmc 	     = attr.lmc;
 	resp.max_vl_num      = attr.max_vl_num;
 	resp.sm_sl 	     = attr.sm_sl;
drivers/infiniband/hw/mlx4/alias_GUID.c +1 -1
index ea24230..0e4f60c 100644
@@ -528,7 +528,7 @@ static int set_guid_rec(struct ib_device *ibdev,
 
 	memset(&guid_info_rec, 0, sizeof (struct ib_sa_guidinfo_rec));
 
-	guid_info_rec.lid = cpu_to_be16(attr.lid);
+	guid_info_rec.lid = ib_lid_be16(attr.lid);
 	guid_info_rec.block_num = index;
 
 	memcpy(guid_info_rec.guid_info_list, rec_det->all_recs,
drivers/infiniband/hw/mlx4/mad.c +1 -1
index 21d31cb..e6731cd 100644
@@ -860,7 +860,7 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	    in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
 	    in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
 	    !ib_query_port(ibdev, port_num, &pattr))
-		prev_lid = pattr.lid;
+		prev_lid = ib_lid_cpu16(pattr.lid);
 
 	err = mlx4_MAD_IFC(to_mdev(ibdev),
 			   (mad_flags & IB_MAD_IGNORE_MKEY ? MLX4_MAD_IFC_IGNORE_MKEY : 0) |
drivers/infiniband/hw/mthca/mthca_mad.c +1 -1
index 7df3db7..16c5b7f 100644
@@ -256,7 +256,7 @@ int mthca_process_mad(struct ib_device *ibdev,
 	    in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
 	    in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
 	    !ib_query_port(ibdev, port_num, &pattr))
-		prev_lid = pattr.lid;
+		prev_lid = ib_lid_cpu16(pattr.lid);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev),
 			    mad_flags & IB_MAD_IGNORE_MKEY,
include/rdma/ib_verbs.h +1 -1
index 3875ea5d..0826a66 100644
@@ -549,8 +549,8 @@ struct ib_port_attr {
 	u32			bad_pkey_cntr;
 	u32			qkey_viol_cntr;
 	u16			pkey_tbl_len;
-	u16			lid;
 	u16			sm_lid;
+	u32			lid;
 	u8			lmc;
 	u8			max_vl_num;
 	u8			sm_sl;
include/rdma/opa_addr.h +2 -1
index eace28f..46d0567 100644
@@ -50,7 +50,8 @@
 
 #define	OPA_SPECIAL_OUI		(0x00066AULL)
 #define OPA_MAKE_ID(x)          (cpu_to_be64(OPA_SPECIAL_OUI << 40 | (x)))
-
+#define OPA_TO_IB_UCAST_LID(x) (((x) >= be16_to_cpu(IB_MULTICAST_LID_BASE)) \
+				? 0 : x)
 /**
  * ib_is_opa_gid: Returns true if the top 24 bits of the gid
  * contains the OPA_STL_OUI identifier. This identifies that
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
author
#10 lore raw

PATCH v4 7/8 IB/core: Change port_attr.sm_lid from 16 to 32 bits

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

sm_lid field in struct ib_port_attr is increased to 32 bits. This enables core components to use larger LIDs if needed. The user ABI is unchanged and return 16 bit values when queried.

---
 drivers/infiniband/core/uverbs_cmd.c | 8 +++++---
 include/rdma/ib_verbs.h              | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +5 -3
index e693b8b..13484ea 100644
@@ -275,7 +275,6 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
 	resp.bad_pkey_cntr   = attr.bad_pkey_cntr;
 	resp.qkey_viol_cntr  = attr.qkey_viol_cntr;
 	resp.pkey_tbl_len    = attr.pkey_tbl_len;
-	resp.sm_lid 	     = attr.sm_lid;
 
 	/*
 	 * In the current implementation the only way to get
@@ -283,10 +282,13 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
 	 * For IB, lids will always be 16bits so cast the
 	 * value accordingly.
 	 */
-	if (rdma_cap_opa_ah(ib_dev, cmd.port_num))
+	if (rdma_cap_opa_ah(ib_dev, cmd.port_num)) {
 		resp.lid     = OPA_TO_IB_UCAST_LID(attr.lid);
-	else
+		resp.sm_lid  = OPA_TO_IB_UCAST_LID(attr.sm_lid);
+	} else {
 		resp.lid     = ib_lid_cpu16(attr.lid);
+		resp.sm_lid  = ib_lid_cpu16(attr.sm_lid);
+	}
 	resp.lmc 	     = attr.lmc;
 	resp.max_vl_num      = attr.max_vl_num;
 	resp.sm_sl 	     = attr.sm_sl;
include/rdma/ib_verbs.h +1 -1
index 0826a66..c92b98b 100644
@@ -549,7 +549,7 @@ struct ib_port_attr {
 	u32			bad_pkey_cntr;
 	u32			qkey_viol_cntr;
 	u16			pkey_tbl_len;
-	u16			sm_lid;
+	u32			sm_lid;
 	u32			lid;
 	u8			lmc;
 	u8			max_vl_num;
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
author
#11 lore raw

PATCH v4 8/8 IB/core: Change wc.slid from 16 to 32 bits

In reply to a message not in the archive

slid field in struct ib_wc is increased to 32 bits. This enables core components to use larger LIDs if needed. The user ABI is unchanged and return 16 bit values when queried.

---
 drivers/infiniband/core/cm.c            |  4 ++--
 drivers/infiniband/core/user_mad.c      |  2 +-
 drivers/infiniband/core/uverbs_cmd.c    | 10 +++++++---
 drivers/infiniband/hw/hfi1/mad.c        |  2 +-
 drivers/infiniband/hw/mlx4/mad.c        |  6 +++---
 drivers/infiniband/hw/mlx5/mad.c        |  2 +-
 drivers/infiniband/hw/mthca/mthca_cmd.c |  4 ++--
 drivers/infiniband/hw/mthca/mthca_mad.c |  2 +-
 drivers/infiniband/sw/rdmavt/cq.c       |  2 +-
 include/rdma/ib_verbs.h                 |  2 +-
 10 files changed, 20 insertions(+), 16 deletions(-)
drivers/infiniband/core/cm.c +2 -2
index 2b4d613..2960242 100644
@@ -1703,7 +1703,7 @@ static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
 {
 	if (!cm_req_get_primary_subnet_local(req_msg)) {
 		if (req_msg->primary_local_lid == IB_LID_PERMISSIVE) {
-			req_msg->primary_local_lid = cpu_to_be16(wc->slid);
+			req_msg->primary_local_lid = ib_lid_be16(wc->slid);
 			cm_req_set_primary_sl(req_msg, wc->sl);
 		}
 
@@ -1713,7 +1713,7 @@ static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
 
 	if (!cm_req_get_alt_subnet_local(req_msg)) {
 		if (req_msg->alt_local_lid == IB_LID_PERMISSIVE) {
-			req_msg->alt_local_lid = cpu_to_be16(wc->slid);
+			req_msg->alt_local_lid = ib_lid_be16(wc->slid);
 			cm_req_set_alt_sl(req_msg, wc->sl);
 		}
 
drivers/infiniband/core/user_mad.c +1 -1
index 36a6f5c..c1696e6 100644
@@ -229,7 +229,7 @@ static void recv_handler(struct ib_mad_agent *agent,
 	packet->mad.hdr.status	   = 0;
 	packet->mad.hdr.length	   = hdr_size(file) + mad_recv_wc->mad_len;
 	packet->mad.hdr.qpn	   = cpu_to_be32(mad_recv_wc->wc->src_qp);
-	packet->mad.hdr.lid	   = cpu_to_be16(mad_recv_wc->wc->slid);
+	packet->mad.hdr.lid	   = ib_lid_be16(mad_recv_wc->wc->slid);
 	packet->mad.hdr.sl	   = mad_recv_wc->wc->sl;
 	packet->mad.hdr.path_bits  = mad_recv_wc->wc->dlid_path_bits;
 	packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index;
drivers/infiniband/core/uverbs_cmd.c +7 -3
index 13484ea..4aeda0e 100644
@@ -1197,7 +1197,8 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
 	return ret ? ret : in_len;
 }
 
-static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
+static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest,
+			   struct ib_wc *wc)
 {
 	struct ib_uverbs_wc tmp;
 
@@ -1211,7 +1212,10 @@ static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
 	tmp.src_qp		= wc->src_qp;
 	tmp.wc_flags		= wc->wc_flags;
 	tmp.pkey_index		= wc->pkey_index;
-	tmp.slid		= wc->slid;
+	if (rdma_cap_opa_ah(ib_dev, wc->port_num))
+		tmp.slid	= OPA_TO_IB_UCAST_LID(wc->slid);
+	else
+		tmp.slid	= ib_lid_cpu16(wc->slid);
 	tmp.sl			= wc->sl;
 	tmp.dlid_path_bits	= wc->dlid_path_bits;
 	tmp.port_num		= wc->port_num;
@@ -1255,7 +1259,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
 		if (!ret)
 			break;
 
-		ret = copy_wc_to_user(data_ptr, &wc);
+		ret = copy_wc_to_user(ib_dev, data_ptr, &wc);
 		if (ret)
 			goto out_put;
 
drivers/infiniband/hw/hfi1/mad.c +1 -1
index 885d9fd..cd1f6f8 100644
@@ -4216,7 +4216,7 @@ static int opa_local_smp_check(struct hfi1_ibport *ibp,
 			       const struct ib_wc *in_wc)
 {
 	struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
-	u16 slid = in_wc->slid;
+	u16 slid = ib_lid_cpu16(in_wc->slid);
 	u16 pkey;
 
 	if (in_wc->pkey_index >= ARRAY_SIZE(ppd->pkeys))
drivers/infiniband/hw/mlx4/mad.c +3 -3
index e6731cd..0793a21 100644
@@ -169,7 +169,7 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
 
 		op_modifier |= 0x4;
 
-		in_modifier |= in_wc->slid << 16;
+		in_modifier |= ib_lid_cpu16(in_wc->slid) << 16;
 	}
 
 	err = mlx4_cmd_box(dev->dev, inmailbox->dma, outmailbox->dma, in_modifier,
@@ -625,7 +625,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
 		memcpy((char *)&tun_mad->hdr.slid_mac_47_32, &(wc->smac[4]), 2);
 	} else {
 		tun_mad->hdr.sl_vid = cpu_to_be16(((u16)(wc->sl)) << 12);
-		tun_mad->hdr.slid_mac_47_32 = cpu_to_be16(wc->slid);
+		tun_mad->hdr.slid_mac_47_32 = ib_lid_be16(wc->slid);
 	}
 
 	ib_dma_sync_single_for_device(&dev->ib_dev,
@@ -826,7 +826,7 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 		}
 	}
 
-	slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+	slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 
 	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0) {
 		forward_trap(to_mdev(ibdev), port_num, in_mad);
drivers/infiniband/hw/mlx5/mad.c +1 -1
index 95db929..18cfe5b 100644
@@ -78,7 +78,7 @@ static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
 	u16 slid;
 	int err;
 
-	slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+	slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 
 	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0)
 		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
drivers/infiniband/hw/mthca/mthca_cmd.c +2 -2
index 9d83a53..d0f062f 100644
@@ -1921,7 +1921,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
 			(in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
 		MTHCA_PUT(inbox, val,               MAD_IFC_G_PATH_OFFSET);
 
-		MTHCA_PUT(inbox, in_wc->slid,       MAD_IFC_RLID_OFFSET);
+		MTHCA_PUT(inbox, ib_lid_cpu16(in_wc->slid), MAD_IFC_RLID_OFFSET);
 		MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
 
 		if (in_grh)
@@ -1929,7 +1929,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
 
 		op_modifier |= 0x4;
 
-		in_modifier |= in_wc->slid << 16;
+		in_modifier |= ib_lid_cpu16(in_wc->slid) << 16;
 	}
 
 	err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma,
drivers/infiniband/hw/mthca/mthca_mad.c +1 -1
index 16c5b7f..093f775 100644
@@ -205,7 +205,7 @@ int mthca_process_mad(struct ib_device *ibdev,
 		      u16 *out_mad_pkey_index)
 {
 	int err;
-	u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+	u16 slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
 	u16 prev_lid = 0;
 	struct ib_port_attr pattr;
 	const struct ib_mad *in_mad = (const struct ib_mad *)in;
drivers/infiniband/sw/rdmavt/cq.c +1 -1
index 0ae2ff8..97d71e4 100644
@@ -107,7 +107,7 @@ void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited)
 		wc->uqueue[head].src_qp = entry->src_qp;
 		wc->uqueue[head].wc_flags = entry->wc_flags;
 		wc->uqueue[head].pkey_index = entry->pkey_index;
-		wc->uqueue[head].slid = entry->slid;
+		wc->uqueue[head].slid = ib_lid_cpu16(entry->slid);
 		wc->uqueue[head].sl = entry->sl;
 		wc->uqueue[head].dlid_path_bits = entry->dlid_path_bits;
 		wc->uqueue[head].port_num = entry->port_num;
include/rdma/ib_verbs.h +1 -1
index c92b98b..ab2fffb 100644
@@ -951,7 +951,7 @@ struct ib_wc {
 	u32			src_qp;
 	int			wc_flags;
 	u16			pkey_index;
-	u16			slid;
+	u32			slid;
 	u8			sl;
 	u8			dlid_path_bits;
 	u8			port_num;	/* valid only for DR SMPs on switches */
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
#12 lore raw
In reply to a message not in the archive
Quoted 9 lines · Don Hiatt

This patch series primarily increases sizes of variables that hold lid values from 16 to 32 bits. Additionally, it adds a check in the IB mad stack to verify a properly formatted MAD when OPA extended LIDs are used.

Changes from v3:
---------------
* Add 'IB/core: Add functions to convert 32 bit lids to 16 bits' and use them in place of casts.

Hi Don,

I've already taken v3 (was going to email it out today, but I pulled it into a branch 2 days ago and it passed 0day overnight, I was just waiting to merge three different branches together and then send out the notifications for them all once done, and v3 of this was one of the three). Please prepare an incremental patch to get me up to v4 and submit that to the list. Thanks.

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#14 lore raw
Quoted 10 lines · Doug Ledford
Quoted 9 lines · Don Hiatt

This patch series primarily increases sizes of variables that hold lid values from 16 to 32 bits. Additionally, it adds a check in the IB mad stack to verify a properly formatted MAD when OPA extended LIDs are used.

Changes from v3:
---------------
* Add 'IB/core: Add functions to convert 32 bit lids to 16 bits' and use them in place of casts.

Quoted 9 lines

Hi Don,

I've already taken v3 (was going to email it out today, but I pulled it into a branch 2 days ago and it passed 0day overnight, I was just waiting to merge three different branches together and then send out the notifications for them all once done, and v3 of this was one of the three). Please prepare an incremental patch to get me up to v4 and submit that to the list. Thanks.

Hi Doug,

Leon had a minor suggestion to put a comment on the helper functions so I'll make a v5 and submit an incremental patch of v2-->v5.

Thanks.

don

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