IB/core: Change port_attr.lid size from 16 to 32 bits
authorDasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Thu, 8 Jun 2017 17:37:47 +0000 (13:37 -0400)
committerDoug Ledford <dledford@redhat.com>
Tue, 8 Aug 2017 18:50:25 +0000 (14:50 -0400)
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.

Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Don Hiatt <don.hiatt@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/core_priv.h
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/hw/mlx4/alias_GUID.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mthca/mthca_mad.c
include/rdma/ib_verbs.h
include/rdma/opa_addr.h

index 11ae67514e13946a26c54d8da8c4d8078aa59596..6b54280530c9bbc632df704916979e8e311056a4 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/cgroup_rdma.h>
 
 #include <rdma/ib_verbs.h>
+#include <rdma/opa_addr.h>
 #include <rdma/ib_mad.h>
 #include "mad_priv.h"
 
index 2c98533a0203b084fb198a3eb8088a0bac59522c..eef2623406ccb941c660ec31d53c69ad2dd9953a 100644 (file)
@@ -275,8 +275,11 @@ 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;
+       if (rdma_cap_opa_ah(ib_dev, cmd.port_num))
+               resp.lid  = OPA_TO_IB_UCAST_LID(attr.lid);
+       else
+               resp.lid     = (u16)attr.lid;
        resp.lmc             = attr.lmc;
        resp.max_vl_num      = attr.max_vl_num;
        resp.sm_sl           = attr.sm_sl;
index ea24230ea0d49956ff8311e6c310dd46dbdfc7ec..5a897b0106a93e51754513a4aaaee57b51efb40e 100644 (file)
@@ -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 = cpu_to_be16((u16)attr.lid);
        guid_info_rec.block_num = index;
 
        memcpy(guid_info_rec.guid_info_list, rec_det->all_recs,
index 21d31cb1325f5fc0271f093e5ec069641b8b9ffe..00f057033cb91c15a1b596e595b892110efa00c9 100644 (file)
@@ -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 = (u16)pattr.lid;
 
        err = mlx4_MAD_IFC(to_mdev(ibdev),
                           (mad_flags & IB_MAD_IGNORE_MKEY ? MLX4_MAD_IFC_IGNORE_MKEY : 0) |
index 7df3db71777a5132b4c6e74e04c9a1dd9056d965..617531f1bfc66c7327f41f58f67bc7016b96dafe 100644 (file)
@@ -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 = (u16)pattr.lid;
 
        err = mthca_MAD_IFC(to_mdev(ibdev),
                            mad_flags & IB_MAD_IGNORE_MKEY,
index b5732432bb297dbf6067ae34b16c00073cb2949d..4fa94e69b1fcf1226c9df892b0a6a832db484855 100644 (file)
@@ -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;
index eace28f1555d958a896677977232b814c4642568..46d0567fffeac31da1be067eeafc023e43ef1d91 100644 (file)
@@ -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