The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=687057e712edbbc31e33613d99d9f8cc436cfa1f

commit 687057e712edbbc31e33613d99d9f8cc436cfa1f
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-06-24 19:30:55 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-06-24 19:30:55 +0000

    OFED: Various changes from Linux 4.14
    
    This contains changes from the following Linux commits:
    
    1cb2fc0db764 IB/mad: Change slid in RMPP recv from 16 to 32 bits
    7e93e2cb835c IB/IPoIB: Increase local_lid to 32 bits
    d541e45500bd IB/core: Convert ah_attr from OPA to IB when copying to user
    6b3c0e6e6d5a IB/CM: Create appropriate path records when handling CM request
    e92aa00a5189 IB/CM: Add OPA Path record support to CM
    7db20ecd1d97 IB/core: Change wc.slid from 16 to 32 bits
    db58540b021a IB/core: Change port_attr.sm_lid from 16 to 32 bits
    582faf3150f5 IB/core: Change port_attr.lid size from 16 to 32 bits
    ac3a949fb2ff IB/CM: Set appropriate slid and dlid when handling CM request
    06f8174a9782 IB/core: Protect sysfs entry on ib_unregister_device
    62ede7779904 Add OPA extended LID support
    13c19222889d IB/rdmavt, hfi1, qib: Modify check_ah() to account for 
extended LIDs
    d98bb7f7e6fa IB/hfi1: Determine 9B/16B L2 header type based on Address 
handle
    dcc9881e6767 RDMA/(core, ulp): Convert register/unregister event handler to 
be void
    f808c13fd373 lib/interval_tree: fast overlap detection
    
    Tested by:      Wafa Hamzah <[email protected]> (mlx5_ib)
    Tested by:      John Baldwin <[email protected]> (iw_cxgbe)
    Sponsored by:   Chelsio Communications
---
 sys/dev/iser/iser_verbs.c                          |   8 +-
 sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c          |   2 +-
 sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c                 |  10 +-
 sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c                 |   2 +-
 sys/dev/mthca/mthca_cmd.c                          |   4 +-
 sys/dev/mthca/mthca_mad.c                          |   4 +-
 sys/ofed/drivers/infiniband/core/core_priv.h       |   1 +
 sys/ofed/drivers/infiniband/core/ib_cache.c        |  23 ++-
 sys/ofed/drivers/infiniband/core/ib_cm.c           | 159 +++++++++++++++++----
 sys/ofed/drivers/infiniband/core/ib_device.c       |  11 +-
 sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c     |   2 +-
 sys/ofed/drivers/infiniband/core/ib_sa_query.c     |  24 ++--
 sys/ofed/drivers/infiniband/core/ib_ucm.c          |   2 +-
 sys/ofed/drivers/infiniband/core/ib_ucma.c         |  10 +-
 sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c  |   4 +-
 sys/ofed/drivers/infiniband/core/ib_user_mad.c     |   2 +-
 sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c   |   7 +-
 .../drivers/infiniband/core/ib_uverbs_marshall.c   |  48 ++++++-
 .../infiniband/core/ib_uverbs_std_types_device.c   |  11 +-
 sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h      |   2 +-
 sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c |  11 +-
 sys/ofed/include/rdma/ib_marshall.h                |   6 +-
 sys/ofed/include/rdma/ib_umem_odp.h                |  11 +-
 sys/ofed/include/rdma/ib_verbs.h                   |  51 ++++++-
 sys/ofed/include/rdma/opa_addr.h                   |  41 +++++-
 25 files changed, 341 insertions(+), 115 deletions(-)

diff --git a/sys/dev/iser/iser_verbs.c b/sys/dev/iser/iser_verbs.c
index f0c7e524ccf0..405ef4738eb5 100644
--- a/sys/dev/iser/iser_verbs.c
+++ b/sys/dev/iser/iser_verbs.c
@@ -258,9 +258,7 @@ iser_create_device_ib_res(struct iser_device *device)
 
        INIT_IB_EVENT_HANDLER(&device->event_handler, device->ib_device,
                                iser_event_handler);
-       if (ib_register_event_handler(&device->event_handler))
-               goto tq_err;
-
+       ib_register_event_handler(&device->event_handler);
        return (0);
 
 tq_err:
@@ -299,8 +297,8 @@ iser_free_device_ib_res(struct iser_device *device)
                comp->cq = NULL;
        }
 
-       (void)ib_unregister_event_handler(&device->event_handler);
-       (void)ib_dealloc_pd(device->pd);
+       ib_unregister_event_handler(&device->event_handler);
+       ib_dealloc_pd(device->pd);
 
        free(device->comps, M_ISER_VERBS);
        device->comps = NULL;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c 
b/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
index 91d240b45583..add29e1f8807 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
@@ -530,7 +530,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,
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c 
b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
index 85015d310133..b519fb9d7b79 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
@@ -167,7 +167,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,
@@ -797,7 +797,7 @@ static int ib_process_mad(struct ib_device *ibdev, int 
mad_flags, u8 port_num,
        if (in_wc && in_wc->qp->qp_num) {
                pr_debug("received MAD: slid:%d sqpn:%d "
                        "dlid_bits:%d dqpn:%d wc_flags:0x%x, cls %x, mtd %x, 
atr %x\n",
-                       in_wc->slid, in_wc->src_qp,
+                       ib_lid_cpu16(in_wc->slid), in_wc->src_qp,
                        in_wc->dlid_path_bits,
                        in_wc->qp->qp_num,
                        in_wc->wc_flags,
@@ -813,7 +813,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);
@@ -847,7 +847,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) |
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c 
b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
index 4bb44470a426..9493f8e552ce 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
@@ -61,7 +61,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;
diff --git a/sys/dev/mthca/mthca_cmd.c b/sys/dev/mthca/mthca_cmd.c
index 6924348e72e4..97ceb2fe4202 100644
--- a/sys/dev/mthca/mthca_cmd.c
+++ b/sys/dev/mthca/mthca_cmd.c
@@ -1918,7 +1918,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)
@@ -1926,7 +1926,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,
diff --git a/sys/dev/mthca/mthca_mad.c b/sys/dev/mthca/mthca_mad.c
index c495c24c432a..ffb7061aeeb8 100644
--- a/sys/dev/mthca/mthca_mad.c
+++ b/sys/dev/mthca/mthca_mad.c
@@ -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;
@@ -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,
diff --git a/sys/ofed/drivers/infiniband/core/core_priv.h 
b/sys/ofed/drivers/infiniband/core/core_priv.h
index e8c70de4fac0..508119e9259d 100644
--- a/sys/ofed/drivers/infiniband/core/core_priv.h
+++ b/sys/ofed/drivers/infiniband/core/core_priv.h
@@ -39,6 +39,7 @@
 #include <linux/spinlock.h>
 
 #include <rdma/ib_verbs.h>
+#include <rdma/opa_addr.h>
 
 #include <net/if_vlan_var.h>
 
diff --git a/sys/ofed/drivers/infiniband/core/ib_cache.c 
b/sys/ofed/drivers/infiniband/core/ib_cache.c
index d8960825427c..a11b36f06c86 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cache.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cache.c
@@ -1179,30 +1179,23 @@ int ib_cache_setup_one(struct ib_device *device)
        device->cache.ports =
                kzalloc(sizeof(*device->cache.ports) *
                        (rdma_end_port(device) - rdma_start_port(device) + 1), 
GFP_KERNEL);
-       if (!device->cache.ports) {
-               err = -ENOMEM;
-               goto out;
-       }
+       if (!device->cache.ports)
+               return -ENOMEM;
 
        err = gid_table_setup_one(device);
-       if (err)
-               goto out;
+       if (err) {
+               kfree(device->cache.ports);
+               device->cache.ports = NULL;
+               return err;
+       }
 
        for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p)
                ib_cache_update(device, p + rdma_start_port(device));
 
        INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
                              device, ib_cache_event);
-       err = ib_register_event_handler(&device->cache.event_handler);
-       if (err)
-               goto err;
-
+       ib_register_event_handler(&device->cache.event_handler);
        return 0;
-
-err:
-       gid_table_cleanup_one(device);
-out:
-       return err;
 }
 
 void ib_cache_release_one(struct ib_device *device)
diff --git a/sys/ofed/drivers/infiniband/core/ib_cm.c 
b/sys/ofed/drivers/infiniband/core/ib_cm.c
index 1528907be9fe..17d483f565ce 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cm.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cm.c
@@ -1230,6 +1230,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));
@@ -1257,18 +1262,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;
@@ -1280,17 +1291,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);
@@ -1452,16 +1475,63 @@ static int cm_issue_rej(struct cm_port *port,
        return ret;
 }
 
+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_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;
@@ -1478,13 +1548,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);
        primary_path->service_id = 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;
@@ -1501,6 +1567,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);
                alt_path->service_id = 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)
@@ -1751,7 +1818,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);
                }
 
@@ -1761,7 +1828,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);
                }
 
@@ -1833,9 +1900,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]);
@@ -1860,16 +1930,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) {
@@ -2896,6 +2969,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));
        lap_msg->local_comm_id = cm_id_priv->id.local_id;
@@ -2909,6 +2987,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;
@@ -2977,16 +3061,29 @@ out:    spin_unlock_irqrestore(&cm_id_priv->lock, 
flags);
 }
 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)
 {
-       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)));
-       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 +3097,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)
@@ -3025,6 +3123,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;
diff --git a/sys/ofed/drivers/infiniband/core/ib_device.c 
b/sys/ofed/drivers/infiniband/core/ib_device.c
index 51e3908c3c9f..7aae715657fb 100644
--- a/sys/ofed/drivers/infiniband/core/ib_device.c
+++ b/sys/ofed/drivers/infiniband/core/ib_device.c
@@ -419,9 +419,10 @@ void ib_unregister_device(struct ib_device *device)
        }
        up_read(&lists_rwsem);
 
+       ib_device_unregister_sysfs(device);
+
        mutex_unlock(&device_mutex);
 
-       ib_device_unregister_sysfs(device);
        ib_cache_cleanup_one(device);
 
        down_write(&lists_rwsem);
@@ -589,7 +590,7 @@ EXPORT_SYMBOL(ib_set_client_data);
  * chapter 11 of the InfiniBand Architecture Specification).  This
  * callback may occur in interrupt context.
  */
-int ib_register_event_handler  (struct ib_event_handler *event_handler)
+void ib_register_event_handler(struct ib_event_handler *event_handler)
 {
        unsigned long flags;
 
@@ -597,8 +598,6 @@ int ib_register_event_handler  (struct ib_event_handler 
*event_handler)
        list_add_tail(&event_handler->list,
                      &event_handler->device->event_handler_list);
        spin_unlock_irqrestore(&event_handler->device->event_handler_lock, 
flags);
-
-       return 0;
 }
 EXPORT_SYMBOL(ib_register_event_handler);
 
@@ -609,15 +608,13 @@ EXPORT_SYMBOL(ib_register_event_handler);
  * Unregister an event handler registered with
  * ib_register_event_handler().
  */
-int ib_unregister_event_handler(struct ib_event_handler *event_handler)
+void ib_unregister_event_handler(struct ib_event_handler *event_handler)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
        list_del(&event_handler->list);
        spin_unlock_irqrestore(&event_handler->device->event_handler_lock, 
flags);
-
-       return 0;
 }
 EXPORT_SYMBOL(ib_unregister_event_handler);
 
diff --git a/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c 
b/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c
index a8a6f9d29408..f300a74af840 100644
--- a/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c
+++ b/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c
@@ -67,7 +67,7 @@ struct mad_rmpp_recv {
 
        __be64 tid;
        u32 src_qp;
-       u16 slid;
+       u32 slid;
        u8 mgmt_class;
        u8 class_version;
        u8 method;
diff --git a/sys/ofed/drivers/infiniband/core/ib_sa_query.c 
b/sys/ofed/drivers/infiniband/core/ib_sa_query.c
index c61c9883a5aa..c8e1af4bd2f2 100644
--- a/sys/ofed/drivers/infiniband/core/ib_sa_query.c
+++ b/sys/ofed/drivers/infiniband/core/ib_sa_query.c
@@ -50,6 +50,7 @@
 #include <rdma/ib_user_sa.h>
 #include <rdma/ib_marshall.h>
 #include <rdma/ib_addr.h>
+#include <rdma/opa_addr.h>
 #include "sa.h"
 #include "core_priv.h"
 
@@ -802,6 +803,11 @@ int ib_init_ah_from_path(struct ib_device *device, u8 
port_num,
        ah_attr->type = rdma_ah_find_type(device, port_num);
 
        rdma_ah_set_dlid(ah_attr, be32_to_cpu(sa_path_get_dlid(rec)));
+
+       if ((ah_attr->type == RDMA_AH_ATTR_TYPE_OPA) &&
+           (rdma_ah_get_dlid(ah_attr) == be16_to_cpu(IB_LID_PERMISSIVE)))
+               rdma_ah_set_make_grd(ah_attr, true);
+
        rdma_ah_set_sl(ah_attr, rec->sl);
        rdma_ah_set_path_bits(ah_attr, be32_to_cpu(sa_path_get_slid(rec)) &
                              get_src_path_mask(device, port_num));
@@ -1840,12 +1846,15 @@ static void update_sm_ah(struct work_struct *work)
        rdma_ah_set_sl(&ah_attr, port_attr.sm_sl);
        rdma_ah_set_port_num(&ah_attr, port->port_num);
        if (port_attr.grh_required) {
-               rdma_ah_set_ah_flags(&ah_attr, IB_AH_GRH);
-
-               rdma_ah_set_subnet_prefix(&ah_attr,
-                                         cpu_to_be64(port_attr.subnet_prefix));
-               rdma_ah_set_interface_id(&ah_attr,
-                                        cpu_to_be64(IB_SA_WELL_KNOWN_GUID));
+               if (ah_attr.type == RDMA_AH_ATTR_TYPE_OPA) {
+                       rdma_ah_set_make_grd(&ah_attr, true);
+               } else {
+                       rdma_ah_set_ah_flags(&ah_attr, IB_AH_GRH);
+                       rdma_ah_set_subnet_prefix(&ah_attr,
+                                                 
cpu_to_be64(port_attr.subnet_prefix));
+                       rdma_ah_set_interface_id(&ah_attr,
+                                                
cpu_to_be64(IB_SA_WELL_KNOWN_GUID));
+               }
        }
 
        new_ah->ah = rdma_create_ah(port->agent->qp->pd, &ah_attr,
@@ -1961,8 +1970,7 @@ static void ib_sa_add_one(struct ib_device *device)
         */
 
        INIT_IB_EVENT_HANDLER(&sa_dev->event_handler, device, ib_sa_event);
-       if (ib_register_event_handler(&sa_dev->event_handler))
-               goto err;
+       ib_register_event_handler(&sa_dev->event_handler);
 
        for (i = 0; i <= e - s; ++i) {
                if (rdma_cap_ib_sa(device, i + 1))
diff --git a/sys/ofed/drivers/infiniband/core/ib_ucm.c 
b/sys/ofed/drivers/infiniband/core/ib_ucm.c
index 1a66eb8f2cdf..5d199b2b0262 100644
--- a/sys/ofed/drivers/infiniband/core/ib_ucm.c
+++ b/sys/ofed/drivers/infiniband/core/ib_ucm.c
@@ -619,7 +619,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)))
diff --git a/sys/ofed/drivers/infiniband/core/ib_ucma.c 
b/sys/ofed/drivers/infiniband/core/ib_ucma.c
index d21a7fd948de..4d17b8285012 100644
--- a/sys/ofed/drivers/infiniband/core/ib_ucma.c
+++ b/sys/ofed/drivers/infiniband/core/ib_ucma.c
@@ -256,14 +256,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;
 }
@@ -343,7 +344,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);
@@ -1175,7 +1177,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;
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c 
b/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
index 47d4b34861fc..8025a14c2e4c 100644
--- a/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
+++ b/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
@@ -74,7 +74,7 @@ INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, 
__subtree_last,
 /* @last is not a part of the interval. See comment for function
  * node_last.
  */
-int rbt_ib_umem_for_each_in_range(struct rb_root *root,
+int rbt_ib_umem_for_each_in_range(struct rb_root_cached *root,
                                  u64 start, u64 last,
                                  umem_call_back cb,
                                  void *cookie)
@@ -97,7 +97,7 @@ int rbt_ib_umem_for_each_in_range(struct rb_root *root,
 }
 EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range);
 
-struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root *root,
+struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root,
                                       u64 addr, u64 length)
 {
        struct umem_odp_node *node;
diff --git a/sys/ofed/drivers/infiniband/core/ib_user_mad.c 
b/sys/ofed/drivers/infiniband/core/ib_user_mad.c
index 2cceb313364c..3b7f6f67c185 100644
--- a/sys/ofed/drivers/infiniband/core/ib_user_mad.c
+++ b/sys/ofed/drivers/infiniband/core/ib_user_mad.c
@@ -231,7 +231,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;
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c 
b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
index 940626ddc17c..711c73c18115 100644
--- a/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
@@ -1154,7 +1154,10 @@ static int copy_wc_to_user(struct ib_device *ib_dev, 
void __user *dest,
        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;
@@ -1756,6 +1759,7 @@ static void copy_ah_attr_from_uverbs(struct ib_device 
*dev,
        rdma_ah_set_path_bits(rdma_attr, uverb_attr->src_path_bits);
        rdma_ah_set_static_rate(rdma_attr, uverb_attr->static_rate);
        rdma_ah_set_port_num(rdma_attr, uverb_attr->port_num);
+       rdma_ah_set_make_grd(rdma_attr, false);
 }
 
 static int modify_qp(struct uverbs_attr_bundle *attrs,
@@ -2424,6 +2428,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle 
*attrs)
        }
 
        attr.type = rdma_ah_find_type(ib_dev, cmd.attr.port_num);
+       rdma_ah_set_make_grd(&attr, false);
        rdma_ah_set_dlid(&attr, cmd.attr.dlid);
        rdma_ah_set_sl(&attr, cmd.attr.sl);
        rdma_ah_set_path_bits(&attr, cmd.attr.src_path_bits);
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c 
b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
index ea7e197e8aec..f7c4a221aa88 100644
--- a/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
@@ -35,10 +35,47 @@
 #include <sys/cdefs.h>
 #include <rdma/ib_marshall.h>
 
-void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
-                            struct rdma_ah_attr *src)
+#define OPA_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
+static int rdma_ah_conv_opa_to_ib(struct ib_device *dev,
+                                 struct rdma_ah_attr *ib,
+                                 struct rdma_ah_attr *opa)
 {
+       struct ib_port_attr port_attr;
+       int ret = 0;
+
+       /* Do structure copy and the over-write fields */
+       *ib = *opa;
+
+       ib->type = RDMA_AH_ATTR_TYPE_IB;
+       rdma_ah_set_grh(ib, NULL, 0, 0, 1, 0);
+
+       if (ib_query_port(dev, opa->port_num, &port_attr)) {
+               /* Set to default subnet to indicate error */
+               rdma_ah_set_subnet_prefix(ib, OPA_DEFAULT_GID_PREFIX);
+               ret = -EINVAL;
+       } else {
+               rdma_ah_set_subnet_prefix(ib,
+                                         cpu_to_be64(port_attr.subnet_prefix));
+       }
+       rdma_ah_set_interface_id(ib, OPA_MAKE_ID(rdma_ah_get_dlid(opa)));
+       return ret;
+}
+
+void ib_copy_ah_attr_to_user(struct ib_device *device,
+                            struct ib_uverbs_ah_attr *dst,
+                            struct rdma_ah_attr *ah_attr)
+{
+       struct rdma_ah_attr *src = ah_attr;
+       struct rdma_ah_attr conv_ah;
+
        memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
+
+       if ((ah_attr->type == RDMA_AH_ATTR_TYPE_OPA) &&
+           (rdma_ah_get_dlid(ah_attr) >=
+            be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
+           (!rdma_ah_conv_opa_to_ib(device, &conv_ah, ah_attr)))
+               src = &conv_ah;
+
        dst->dlid                  = rdma_ah_get_dlid(src);
        dst->sl                    = rdma_ah_get_sl(src);
        dst->src_path_bits         = rdma_ah_get_path_bits(src);
@@ -59,7 +96,8 @@ void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
 }
 EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
 
-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)
 {
        dst->qp_state           = src->qp_state;
@@ -78,8 +116,8 @@ void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
        dst->max_recv_sge       = src->cap.max_recv_sge;
        dst->max_inline_data    = src->cap.max_inline_data;
 
-       ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
-       ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
+       ib_copy_ah_attr_to_user(device, &dst->ah_attr, &src->ah_attr);
+       ib_copy_ah_attr_to_user(device, &dst->alt_ah_attr, &src->alt_ah_attr);
 
        dst->pkey_index         = src->pkey_index;
        dst->alt_pkey_index     = src->alt_pkey_index;
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_std_types_device.c 
b/sys/ofed/drivers/infiniband/core/ib_uverbs_std_types_device.c
index a245cbdd440e..22a835e1af3d 100644
--- a/sys/ofed/drivers/infiniband/core/ib_uverbs_std_types_device.c
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_std_types_device.c
@@ -7,6 +7,7 @@
 #include "rdma_core.h"
 #include "uverbs.h"
 #include <rdma/uverbs_ioctl.h>
+#include <rdma/opa_addr.h>
 
 /*
  * This ioctl method allows calling any defined write or write_ex
@@ -145,8 +146,14 @@ void copy_port_attr_to_resp(struct ib_port_attr *attr,
        if (attr->grh_required)
                resp->flags |= IB_UVERBS_QPF_GRH_REQUIRED;
 
-       resp->lid = (u16)attr->lid;
-       resp->sm_lid = (u16)attr->sm_lid;
+       if (rdma_cap_opa_ah(ib_dev, port_num)) {
+               resp->lid = OPA_TO_IB_UCAST_LID(attr->lid);
+               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;
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h 
b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
index 5a5b811d8adf..b695e55d42bc 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -357,7 +357,7 @@ struct ipoib_dev_priv {
        u32               qkey;
 
        union ib_gid local_gid;
-       u16          local_lid;
+       u32          local_lid;
 
        unsigned int admin_mtu;         /* User selected MTU, no GRH. */
        unsigned int mcast_mtu;         /* Minus GRH bytes, from mcast group. */
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c 
b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
index ea2ec144bc92..90243707f692 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1028,22 +1028,13 @@ ipoib_add_port(const char *format, struct ib_device 
*hca, u8 port)
 
        INIT_IB_EVENT_HANDLER(&priv->event_handler,
                              priv->ca, ipoib_event);
-       result = ib_register_event_handler(&priv->event_handler);
-       if (result < 0) {
-               printk(KERN_WARNING "%s: ib_register_event_handler failed for "
-                      "port %d (ret = %d)\n",
-                      hca->name, port, result);
-               goto event_failed;
-       }
+       ib_register_event_handler(&priv->event_handler);
        if_printf(priv->dev, "Attached to %s port %d\n", hca->name, port);
 
        priv->gone = 0; /* ready */
 
        return priv->dev;
 
-event_failed:
-       ipoib_dev_cleanup(priv);
-
 device_init_failed:
        ipoib_ifdetach(priv);
        ipoib_detach(priv);
diff --git a/sys/ofed/include/rdma/ib_marshall.h 
b/sys/ofed/include/rdma/ib_marshall.h
index 4787e371848c..660aa2268489 100644
--- a/sys/ofed/include/rdma/ib_marshall.h
+++ b/sys/ofed/include/rdma/ib_marshall.h
@@ -40,10 +40,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,
diff --git a/sys/ofed/include/rdma/ib_umem_odp.h 
b/sys/ofed/include/rdma/ib_umem_odp.h
index cd7db300ef95..5affdc6427d9 100644
--- a/sys/ofed/include/rdma/ib_umem_odp.h
+++ b/sys/ofed/include/rdma/ib_umem_odp.h
@@ -114,22 +114,25 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 
start_offset, u64 bcnt,
 void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset,
                                 u64 bound);
 
-void rbt_ib_umem_insert(struct umem_odp_node *node, struct rb_root *root);
-void rbt_ib_umem_remove(struct umem_odp_node *node, struct rb_root *root);
+void rbt_ib_umem_insert(struct umem_odp_node *node,
+                       struct rb_root_cached *root);
+void rbt_ib_umem_remove(struct umem_odp_node *node,
+                       struct rb_root_cached *root);
 typedef int (*umem_call_back)(struct ib_umem *item, u64 start, u64 end,
                              void *cookie);
*** 182 LINES SKIPPED ***

Reply via email to