The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=85893a8399bce2dd66e8693037395e1979277967

commit 85893a8399bce2dd66e8693037395e1979277967
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.15
    
    This contains changes from the following Linux commits:
    
    c0b64f58e8d4 RDMA/cma: Avoid triggering undefined behavior
    c0348eb06968 IB: Let ib_core resolve destination mac address
    5a3dc3237243 IB/cm: Fix memory corruption in handling CM request
    fec99ededf6b RDMA/umem: Avoid partial declaration of non-static function
    19b57c6c4499 IB/core: Convert OPA AH to IB for Extended LIDs only
    e08ce2e82b2f RDMA/core: Make function rdma_copy_addr return void
    4190b4e96954 RDMA/core: Rename kernel modify_cq to better describe its usage
    
    Tested by:      Wafa Hamzah <[email protected]> (mlx5_ib)
    Tested by:      John Baldwin <[email protected]> (iw_cxgbe)
    Sponsored by:   Chelsio Communications
---
 sys/dev/bnxt/bnxt_re/bnxt_re.h                     |  14 ---
 sys/dev/bnxt/bnxt_re/ib_verbs.c                    |  70 +------------
 sys/dev/bnxt/bnxt_re/ib_verbs.h                    |   1 -
 sys/dev/bnxt/bnxt_re/main.c                        |  22 ----
 sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c                  |   8 +-
 sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c                  |   4 -
 sys/ofed/drivers/infiniband/core/ib_addr.c         |  22 ++--
 sys/ofed/drivers/infiniband/core/ib_cm.c           |  11 +-
 sys/ofed/drivers/infiniband/core/ib_cma.c          |  19 ++--
 sys/ofed/drivers/infiniband/core/ib_umem_odp.c     |  72 +++++++++++++
 sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c  | 111 ---------------------
 sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c   |   2 +-
 .../drivers/infiniband/core/ib_uverbs_marshall.c   |   3 +-
 sys/ofed/drivers/infiniband/core/ib_verbs.c        |  12 ++-
 .../drivers/infiniband/ulp/ipoib/ipoib_ethtool.c   |   5 +-
 sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c     |   2 +-
 sys/ofed/include/rdma/ib_addr.h                    |   5 +-
 sys/ofed/include/rdma/ib_umem_odp.h                |   4 -
 sys/ofed/include/rdma/ib_verbs.h                   |   7 +-
 19 files changed, 123 insertions(+), 271 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_re/bnxt_re.h b/sys/dev/bnxt/bnxt_re/bnxt_re.h
index 8c78d78e742a..2e7f027380be 100644
--- a/sys/dev/bnxt/bnxt_re/bnxt_re.h
+++ b/sys/dev/bnxt/bnxt_re/bnxt_re.h
@@ -558,8 +558,6 @@ struct bnxt_re_dev {
        struct dentry                   *pdev_debug_dir;
        struct dentry                   *pdev_qpinfo_dir;
        struct bnxt_re_debug_entries    *dbg_ent;
-       struct workqueue_struct         *resolve_wq;
-       struct list_head                mac_wq_list;
        struct workqueue_struct         *dcb_wq;
        struct workqueue_struct         *aer_wq;
        u32                             event_bitmap[3];
@@ -608,16 +606,6 @@ struct bnxt_re_dev {
        unsigned char   *dev_addr; /* For netdev->dev_addr */
 };
 
-#define BNXT_RE_RESOLVE_RETRY_COUNT_US 5000000 /* 5 sec */
-struct bnxt_re_resolve_dmac_work{
-       struct work_struct      work;
-       struct list_head        list;
-       struct bnxt_re_dev      *rdev;
-       struct rdma_ah_attr     *ah_attr;
-       struct bnxt_re_ah_info *ah_info;
-       atomic_t                status_wait;
-};
-
 static inline u8 bnxt_re_get_prio(u8 prio_map)
 {
        u8 prio = 0xFF;
@@ -727,8 +715,6 @@ int bnxt_re_schedule_work(struct bnxt_re_dev *rdev, 
unsigned long event,
 void bnxt_re_get_link_speed(struct bnxt_re_dev *rdev);
 int _bnxt_re_ib_init(struct bnxt_re_dev *rdev);
 int _bnxt_re_ib_init2(struct bnxt_re_dev *rdev);
-void bnxt_re_init_resolve_wq(struct bnxt_re_dev *rdev);
-void bnxt_re_uninit_resolve_wq(struct bnxt_re_dev *rdev);
 
 /* The rdev ref_count is to protect immature removal of the device */
 static inline void bnxt_re_hold(struct bnxt_re_dev *rdev)
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.c b/sys/dev/bnxt/bnxt_re/ib_verbs.c
index 55d8d8b5b04a..eacd5c1abab5 100644
--- a/sys/dev/bnxt/bnxt_re/ib_verbs.c
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.c
@@ -49,23 +49,6 @@ static inline void bnxt_re_peer_mem_release(struct ib_umem 
*umem)
        ib_umem_release(umem);
 }
 
-void bnxt_re_resolve_dmac_task(struct work_struct *work)
-{
-       int rc = -1;
-       struct bnxt_re_dev *rdev;
-       struct rdma_ah_attr     *ah_attr;
-       struct bnxt_re_resolve_dmac_work *dmac_work =
-                       container_of(work, struct bnxt_re_resolve_dmac_work, 
work);
-
-       rdev = dmac_work->rdev;
-       ah_attr = dmac_work->ah_attr;
-       rc = ib_resolve_eth_dmac(&rdev->ibdev, ah_attr);
-       if (rc)
-               dev_err(rdev_to_dev(dmac_work->rdev),
-                       "Failed to resolve dest mac rc = %d\n", rc);
-       atomic_set(&dmac_work->status_wait, rc << 8);
-}
-
 static int __from_ib_access_flags(int iflags)
 {
        int qflags = 0;
@@ -999,52 +982,6 @@ static u8 _get_sgid_index(struct bnxt_re_dev *rdev, u8 
gindx)
        return gindx;
 }
 
-static int bnxt_re_init_dmac(struct bnxt_re_dev *rdev, struct rdma_ah_attr 
*ah_attr,
-                            struct bnxt_re_ah_info *ah_info, bool is_user,
-                            struct bnxt_re_ah *ah)
-{
-       const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
-       int rc = 0;
-       u8 *dmac;
-
-       if (is_user && !rdma_is_multicast_addr((struct in6_addr *)
-                                               grh->dgid.raw) &&
-           !rdma_link_local_addr((struct in6_addr *)grh->dgid.raw)) {
-
-               u32 retry_count = BNXT_RE_RESOLVE_RETRY_COUNT_US;
-               struct bnxt_re_resolve_dmac_work *resolve_dmac_work;
-
-
-               resolve_dmac_work = kzalloc(sizeof(*resolve_dmac_work), 
GFP_ATOMIC);
-
-               resolve_dmac_work->rdev = rdev;
-               resolve_dmac_work->ah_attr = ah_attr;
-               resolve_dmac_work->ah_info = ah_info;
-
-               atomic_set(&resolve_dmac_work->status_wait, 1);
-               INIT_WORK(&resolve_dmac_work->work, bnxt_re_resolve_dmac_task);
-               queue_work(rdev->resolve_wq, &resolve_dmac_work->work);
-
-               do {
-                       rc = atomic_read(&resolve_dmac_work->status_wait) & 
0xFF;
-                       if (!rc)
-                               break;
-                       udelay(1);
-               } while (--retry_count);
-               if (atomic_read(&resolve_dmac_work->status_wait)) {
-                       INIT_LIST_HEAD(&resolve_dmac_work->list);
-                       list_add_tail(&resolve_dmac_work->list,
-                                       &rdev->mac_wq_list);
-                       return -EFAULT;
-               }
-               kfree(resolve_dmac_work);
-       }
-       dmac = ROCE_DMAC(ah_attr);
-       if (dmac)
-               memcpy(ah->qplib_ah.dmac, dmac, ETH_ALEN);
-       return rc;
-}
-
 int bnxt_re_create_ah(struct ib_ah *ah_in, struct rdma_ah_attr *attr,
                      u32 flags, struct ib_udata *udata)
 {
@@ -1057,7 +994,6 @@ int bnxt_re_create_ah(struct ib_ah *ah_in, struct 
rdma_ah_attr *attr,
        const struct ib_global_route *grh = rdma_ah_read_grh(attr);
        struct bnxt_re_ah_info ah_info;
        u32 max_ah_count;
-       bool is_user;
        int rc;
        bool block = true;
        struct rdma_ah_attr *ah_attr = attr;
@@ -1068,7 +1004,6 @@ int bnxt_re_create_ah(struct ib_ah *ah_in, struct 
rdma_ah_attr *attr,
 
        ah->rdev = rdev;
        ah->qplib_ah.pd = &pd->qplib_pd;
-       is_user = ib_pd->uobject ? true : false;
 
        /* Supply the configuration for the HW */
        memcpy(ah->qplib_ah.dgid.data, grh->dgid.raw,
@@ -1088,10 +1023,7 @@ int bnxt_re_create_ah(struct ib_ah *ah_in, struct 
rdma_ah_attr *attr,
        if (rc)
                goto fail;
        ah->qplib_ah.nw_type = ah_info.nw_type;
-
-       rc = bnxt_re_init_dmac(rdev, ah_attr, &ah_info, is_user, ah);
-       if (rc)
-               goto fail;
+       memcpy(ah->qplib_ah.dmac, ROCE_DMAC(ah_attr), ETH_ALEN);
 
        rc = bnxt_qplib_create_ah(&rdev->qplib_res, &ah->qplib_ah, block);
        if (rc) {
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.h b/sys/dev/bnxt/bnxt_re/ib_verbs.h
index 7dd8f6ece12f..332c88e07a3d 100644
--- a/sys/dev/bnxt/bnxt_re/ib_verbs.h
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.h
@@ -398,7 +398,6 @@ struct ib_umem *ib_umem_get_flags_compat(struct bnxt_re_dev 
*rdev,
                                         size_t size, int access, int dmasync);
 static inline size_t ib_umem_num_pages_compat(struct ib_umem *umem);
 static inline void bnxt_re_peer_mem_release(struct ib_umem *umem);
-void bnxt_re_resolve_dmac_task(struct work_struct *work);
 
 static inline enum ib_qp_type  __from_hw_to_ib_qp_type(u8 type)
 {
diff --git a/sys/dev/bnxt/bnxt_re/main.c b/sys/dev/bnxt/bnxt_re/main.c
index 5b1fe2ae0faa..991931bdd396 100644
--- a/sys/dev/bnxt/bnxt_re/main.c
+++ b/sys/dev/bnxt/bnxt_re/main.c
@@ -137,26 +137,6 @@ void bnxt_re_set_dma_device(struct ib_device *ibdev, 
struct bnxt_re_dev *rdev)
        ibdev->dma_device = &rdev->en_dev->pdev->dev;
 }
 
-void bnxt_re_init_resolve_wq(struct bnxt_re_dev *rdev)
-{
-       rdev->resolve_wq = create_singlethread_workqueue("bnxt_re_resolve_wq");
-        INIT_LIST_HEAD(&rdev->mac_wq_list);
-}
-
-void bnxt_re_uninit_resolve_wq(struct bnxt_re_dev *rdev)
-{
-       struct bnxt_re_resolve_dmac_work *tmp_work = NULL, *tmp_st;
-       if (!rdev->resolve_wq)
-               return;
-       flush_workqueue(rdev->resolve_wq);
-       list_for_each_entry_safe(tmp_work, tmp_st, &rdev->mac_wq_list, list) {
-                       list_del(&tmp_work->list);
-                       kfree(tmp_work);
-       }
-       destroy_workqueue(rdev->resolve_wq);
-       rdev->resolve_wq = NULL;
-}
-
 u32 readl_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx)
 {
 
@@ -3534,7 +3514,6 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, 
u8 op_type)
                mutex_unlock(&bnxt_re_dev_lock);
        }
 
-       bnxt_re_uninit_resolve_wq(rdev);
        bnxt_re_uninit_dcb_wq(rdev);
        bnxt_re_uninit_aer_wq(rdev);
 
@@ -3804,7 +3783,6 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 
op_type)
 
        bnxt_re_init_dcb_wq(rdev);
        bnxt_re_init_aer_wq(rdev);
-       bnxt_re_init_resolve_wq(rdev);
        mutex_lock(&bnxt_re_dev_lock);
        list_add_tail_rcu(&rdev->list, &bnxt_re_dev_list);
        /* Added to the list, not in progress anymore */
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c 
b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
index 6bb17975143f..e31c223c27e6 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
@@ -90,12 +90,10 @@ static int create_iboe_ah(struct ib_ah *ib_ah, struct 
rdma_ah_attr *ah_attr)
        int ret;
 
        memcpy(&in6, grh->dgid.raw, sizeof(in6));
-       if (rdma_is_multicast_addr(&in6)) {
+       if (rdma_is_multicast_addr(&in6))
                is_mcast = 1;
-               rdma_get_mcast_mac(&in6, ah->av.eth.mac);
-       } else {
-               memcpy(ah->av.eth.mac, ah_attr->roce.dmac, ETH_ALEN);
-       }
+
+       memcpy(ah->av.eth.mac, ah_attr->roce.dmac, ETH_ALEN);
        ret = ib_get_cached_gid(pd->device, rdma_ah_get_port_num(ah_attr),
                                grh->sgid_index, &sgid, &gid_attr);
        if (ret)
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c 
b/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
index c42126241050..7439ec3fa4ea 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
@@ -83,10 +83,6 @@ int mlx5_ib_create_ah(struct ib_ah *ibah, struct 
rdma_ah_attr *ah_attr,
 
                resp.response_length = min_resp_len;
 
-               err = ib_resolve_eth_dmac(&dev->ib_dev, ah_attr);
-               if (err)
-                       return err;
-
                memcpy(resp.dmac, ah_attr->roce.dmac, ETH_ALEN);
                err = ib_copy_to_udata(udata, &resp, resp.response_length);
                if (err)
diff --git a/sys/ofed/drivers/infiniband/core/ib_addr.c 
b/sys/ofed/drivers/infiniband/core/ib_addr.c
index c953ca604588..ecacfd6a43dd 100644
--- a/sys/ofed/drivers/infiniband/core/ib_addr.c
+++ b/sys/ofed/drivers/infiniband/core/ib_addr.c
@@ -139,8 +139,9 @@ rdma_copy_addr_sub(u8 *dst, const u8 *src, unsigned min, 
unsigned max)
        memset(dst + min, 0, max - min);
 }
 
-int rdma_copy_addr(struct rdma_dev_addr *dev_addr, if_t dev,
-                    const unsigned char *dst_dev_addr)
+void rdma_copy_addr(struct rdma_dev_addr *dev_addr,
+                   const if_t dev,
+                   const unsigned char *dst_dev_addr)
 {
        int dev_type = if_gettype(dev);
 
@@ -151,7 +152,7 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, if_t dev,
                memset(dev_addr->broadcast, 0, MAX_ADDR_LEN);
                memset(dev_addr->dst_dev_addr, 0, MAX_ADDR_LEN);
                dev_addr->bound_dev_if = if_getindex(dev);
-               return (0);
+               return;
        } else if (dev_type == IFT_INFINIBAND)
                dev_addr->dev_type = ARPHRD_INFINIBAND;
        else if (dev_type == IFT_ETHER || dev_type == IFT_L2VLAN)
@@ -167,7 +168,6 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, if_t dev,
                                   if_getaddrlen(dev), MAX_ADDR_LEN);
        }
        dev_addr->bound_dev_if = if_getindex(dev);
-       return 0;
 }
 EXPORT_SYMBOL(rdma_copy_addr);
 
@@ -175,7 +175,7 @@ int rdma_translate_ip(const struct sockaddr *addr,
                      struct rdma_dev_addr *dev_addr)
 {
        if_t dev;
-       int ret;
+       int ret = 0;
 
        if (dev_addr->bound_dev_if) {
                dev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
@@ -202,7 +202,7 @@ int rdma_translate_ip(const struct sockaddr *addr,
                if (if_getflags(dev) & IFF_LOOPBACK)
                        ret = -EINVAL;
                else
-                       ret = rdma_copy_addr(dev_addr, dev, NULL);
+                       rdma_copy_addr(dev_addr, dev, NULL);
                dev_put(dev);
        } else {
                ret = -ENODEV;
@@ -655,10 +655,14 @@ static int addr_resolve_neigh(if_t dev,
        }
 
        /* If the device doesn't do ARP internally */
-       if (!(if_getflags(dev) & IFF_NOARP))
-               return rdma_copy_addr(addr, dev, edst);
+       if (!(if_getflags(dev) & IFF_NOARP)) {
+               rdma_copy_addr(addr, dev, edst);
+                return 0;
+        }
 
-       return rdma_copy_addr(addr, dev, NULL);
+       rdma_copy_addr(addr, dev, NULL);
+
+       return 0;
 }
 
 static int addr_resolve(struct sockaddr *src_in,
diff --git a/sys/ofed/drivers/infiniband/core/ib_cm.c 
b/sys/ofed/drivers/infiniband/core/ib_cm.c
index 17d483f565ce..be29881c73c9 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cm.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cm.c
@@ -1601,7 +1601,7 @@ static void cm_format_req_event(struct cm_work *work,
        param->bth_pkey = cm_get_bth_pkey(work);
        param->port = cm_id_priv->av.port->port_num;
        param->primary_path = &work->path[0];
-       if (req_msg->alt_local_lid)
+       if (cm_req_has_alt_path(req_msg))
                param->alternate_path = &work->path[1];
        else
                param->alternate_path = NULL;
@@ -1884,7 +1884,8 @@ static int cm_req_handler(struct cm_work *work)
        cm_process_routed_req(req_msg, work->mad_recv_wc->wc);
 
        memset(&work->path[0], 0, sizeof(work->path[0]));
-       memset(&work->path[1], 0, sizeof(work->path[1]));
+       if (cm_req_has_alt_path(req_msg))
+               memset(&work->path[1], 0, sizeof(work->path[1]));
        grh = rdma_ah_read_grh(&cm_id_priv->av.ah_attr);
        ret = ib_get_cached_gid(work->port->cm_dev->ib_device,
                                work->port->port_num,
@@ -3868,14 +3869,16 @@ static void cm_recv_handler(struct ib_mad_agent 
*mad_agent,
        struct cm_port *port = mad_agent->context;
        struct cm_work *work;
        enum ib_cm_event_type event;
+       bool alt_path = false;
        u16 attr_id;
        int paths = 0;
        int going_down = 0;
 
        switch (mad_recv_wc->recv_buf.mad->mad_hdr.attr_id) {
        case CM_REQ_ATTR_ID:
-               paths = 1 + (((struct cm_req_msg *) mad_recv_wc->recv_buf.mad)->
-                                                   alt_local_lid != 0);
+               alt_path = cm_req_has_alt_path((struct cm_req_msg *)
+                                               mad_recv_wc->recv_buf.mad);
+               paths = 1 + (alt_path != 0);
                event = IB_CM_REQ_RECEIVED;
                break;
        case CM_MRA_ATTR_ID:
diff --git a/sys/ofed/drivers/infiniband/core/ib_cma.c 
b/sys/ofed/drivers/infiniband/core/ib_cma.c
index ee7c47863aff..33a4189804e1 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cma.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cma.c
@@ -1823,7 +1823,7 @@ there_is_no_net_dev:
        return id_priv;
 }
 
-static inline int cma_user_data_offset(struct rdma_id_private *id_priv)
+static inline u8 cma_user_data_offset(struct rdma_id_private *id_priv)
 {
        if (cma_family(id_priv) == AF_IB)
                return 0;
@@ -2144,9 +2144,7 @@ static struct rdma_id_private *cma_new_conn_id(struct 
rdma_cm_id *listen_id,
                rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
 
        if (net_dev) {
-               ret = rdma_copy_addr(&rt->addr.dev_addr, net_dev, NULL);
-               if (ret)
-                       goto err;
+               rdma_copy_addr(&rt->addr.dev_addr, net_dev, NULL);
        } else {
                if (!cma_protocol_roce(listen_id) &&
                    cma_any_addr(vnet, cma_src_addr(id_priv))) {
@@ -2192,9 +2190,7 @@ static struct rdma_id_private *cma_new_udp_id(struct 
rdma_cm_id *listen_id,
                goto err;
 
        if (net_dev) {
-               ret = rdma_copy_addr(&id->route.addr.dev_addr, net_dev, NULL);
-               if (ret)
-                       goto err;
+               rdma_copy_addr(&id->route.addr.dev_addr, net_dev, NULL);
        } else {
                if (!cma_any_addr(vnet, cma_src_addr(id_priv))) {
                        ret = cma_translate_addr(cma_src_addr(id_priv),
@@ -2240,7 +2236,8 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct 
ib_cm_event *ib_event)
        struct rdma_id_private *listen_id, *conn_id = NULL;
        struct rdma_cm_event event;
        if_t net_dev;
-       int offset, ret;
+       u8 offset;
+       int ret;
 
        listen_id = cma_id_from_event(cm_id, ib_event, &net_dev);
        if (IS_ERR(listen_id))
@@ -3788,7 +3785,8 @@ static int cma_resolve_ib_udp(struct rdma_id_private 
*id_priv,
        struct ib_cm_sidr_req_param req;
        struct ib_cm_id *id;
        void *private_data;
-       int offset, ret;
+       u8 offset;
+       int ret;
 
        memset(&req, 0, sizeof req);
        offset = cma_user_data_offset(id_priv);
@@ -3845,7 +3843,8 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
        struct rdma_route *route;
        void *private_data;
        struct ib_cm_id *id;
-       int offset, ret;
+       u8 offset;
+       int ret;
 
        memset(&req, 0, sizeof req);
        offset = cma_user_data_offset(id_priv);
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem_odp.c 
b/sys/ofed/drivers/infiniband/core/ib_umem_odp.c
index 9e15a5bfa981..1b469f0a086e 100644
--- a/sys/ofed/drivers/infiniband/core/ib_umem_odp.c
+++ b/sys/ofed/drivers/infiniband/core/ib_umem_odp.c
@@ -38,11 +38,44 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/hugetlb.h>
+#include <linux/interval_tree_generic.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_umem.h>
 #include <rdma/ib_umem_odp.h>
 
+/*
+ * The ib_umem list keeps track of memory regions for which the HW
+ * device request to receive notification when the related memory
+ * mapping is changed.
+ *
+ * ib_umem_lock protects the list.
+ */
+
+static u64 node_start(struct umem_odp_node *n)
+{
+       struct ib_umem_odp *umem_odp =
+                       container_of(n, struct ib_umem_odp, interval_tree);
+
+       return ib_umem_start(umem_odp->umem);
+}
+
+/* Note that the representation of the intervals in the interval tree
+ * considers the ending point as contained in the interval, while the
+ * function ib_umem_end returns the first address which is not contained
+ * in the umem.
+ */
+static u64 node_last(struct umem_odp_node *n)
+{
+       struct ib_umem_odp *umem_odp =
+                       container_of(n, struct ib_umem_odp, interval_tree);
+
+       return ib_umem_end(umem_odp->umem) - 1;
+}
+
+INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last,
+                    node_start, node_last, static, rbt_ib_umem)
+
 static void ib_umem_notifier_start_account(struct ib_umem *item)
 {
        mutex_lock(&item->odp_data->umem_mutex);
@@ -747,3 +780,42 @@ void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 
virt,
        mutex_unlock(&umem->odp_data->umem_mutex);
 }
 EXPORT_SYMBOL(ib_umem_odp_unmap_dma_pages);
+
+/* @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_cached *root,
+                                 u64 start, u64 last,
+                                 umem_call_back cb,
+                                 void *cookie)
+{
+       int ret_val = 0;
+       struct umem_odp_node *node, *next;
+       struct ib_umem_odp *umem;
+
+       if (unlikely(start == last))
+               return ret_val;
+
+       for (node = rbt_ib_umem_iter_first(root, start, last - 1);
+                       node; node = next) {
+               next = rbt_ib_umem_iter_next(node, start, last - 1);
+               umem = container_of(node, struct ib_umem_odp, interval_tree);
+               ret_val = cb(umem->umem, start, last, cookie) || ret_val;
+       }
+
+       return ret_val;
+}
+EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range);
+
+struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root,
+                                      u64 addr, u64 length)
+{
+       struct umem_odp_node *node;
+
+       node = rbt_ib_umem_iter_first(root, addr, addr + length - 1);
+       if (node)
+               return container_of(node, struct ib_umem_odp, interval_tree);
+       return NULL;
+
+}
+EXPORT_SYMBOL(rbt_ib_umem_lookup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c 
b/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
deleted file mode 100644
index 8025a14c2e4c..000000000000
--- a/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
- *
- * Copyright (c) 2014 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <sys/cdefs.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/gfp.h>
-#include <rdma/ib_umem_odp.h>
-
-/*
- * The ib_umem list keeps track of memory regions for which the HW
- * device request to receive notification when the related memory
- * mapping is changed.
- *
- * ib_umem_lock protects the list.
- */
-
-static inline u64 node_start(struct umem_odp_node *n)
-{
-       struct ib_umem_odp *umem_odp =
-                       container_of(n, struct ib_umem_odp, interval_tree);
-
-       return ib_umem_start(umem_odp->umem);
-}
-
-/* Note that the representation of the intervals in the interval tree
- * considers the ending point as contained in the interval, while the
- * function ib_umem_end returns the first address which is not contained
- * in the umem.
- */
-static inline u64 node_last(struct umem_odp_node *n)
-{
-       struct ib_umem_odp *umem_odp =
-                       container_of(n, struct ib_umem_odp, interval_tree);
-
-       return ib_umem_end(umem_odp->umem) - 1;
-}
-
-INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last,
-                    node_start, node_last, , rbt_ib_umem)
-
-/* @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_cached *root,
-                                 u64 start, u64 last,
-                                 umem_call_back cb,
-                                 void *cookie)
-{
-       int ret_val = 0;
-       struct umem_odp_node *node, *next;
-       struct ib_umem_odp *umem;
-
-       if (unlikely(start == last))
-               return ret_val;
-
-       for (node = rbt_ib_umem_iter_first(root, start, last - 1);
-                       node; node = next) {
-               next = rbt_ib_umem_iter_next(node, start, last - 1);
-               umem = container_of(node, struct ib_umem_odp, interval_tree);
-               ret_val = cb(umem->umem, start, last, cookie) || ret_val;
-       }
-
-       return ret_val;
-}
-EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range);
-
-struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root,
-                                      u64 addr, u64 length)
-{
-       struct umem_odp_node *node;
-
-       node = rbt_ib_umem_iter_first(root, addr, addr + length - 1);
-       if (node)
-               return container_of(node, struct ib_umem_odp, interval_tree);
-       return NULL;
-
-}
-EXPORT_SYMBOL(rbt_ib_umem_lookup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c 
b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
index 711c73c18115..a581d3c10b49 100644
--- a/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
@@ -3714,7 +3714,7 @@ static int ib_uverbs_ex_modify_cq(struct 
uverbs_attr_bundle *attrs)
        if (!cq)
                return -EINVAL;
 
-       ret = ib_modify_cq(cq, cmd.attr.cq_count, cmd.attr.cq_period);
+       ret = rdma_set_cq_moderation(cq, cmd.attr.cq_count, cmd.attr.cq_period);
 
        rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
                                UVERBS_LOOKUP_READ);
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c 
b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
index f7c4a221aa88..f74ecbf9cf96 100644
--- a/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
@@ -71,8 +71,7 @@ void ib_copy_ah_attr_to_user(struct ib_device *device,
        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_get_dlid(ah_attr) > be16_to_cpu(IB_LID_PERMISSIVE)) &&
            (!rdma_ah_conv_opa_to_ib(device, &conv_ah, ah_attr)))
                src = &conv_ah;
 
diff --git a/sys/ofed/drivers/infiniband/core/ib_verbs.c 
b/sys/ofed/drivers/infiniband/core/ib_verbs.c
index ef65aeefd8f4..b0cdf8a318d9 100644
--- a/sys/ofed/drivers/infiniband/core/ib_verbs.c
+++ b/sys/ofed/drivers/infiniband/core/ib_verbs.c
@@ -58,6 +58,9 @@
 
 #include "core_priv.h"
 
+static int ib_resolve_eth_dmac(struct ib_device *device,
+                              struct rdma_ah_attr *ah_attr);
+
 static const char * const ib_events[] = {
        [IB_EVENT_CQ_ERR]               = "CQ error",
        [IB_EVENT_QP_FATAL]             = "QP fatal error",
@@ -1289,8 +1292,8 @@ bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum 
ib_qp_state next_state,
 }
 EXPORT_SYMBOL(ib_modify_qp_is_ok);
 
-int ib_resolve_eth_dmac(struct ib_device *device,
-                       struct rdma_ah_attr *ah_attr)
+static int ib_resolve_eth_dmac(struct ib_device *device,
+                              struct rdma_ah_attr *ah_attr)
 {
        struct ib_gid_attr sgid_attr;
        union ib_gid sgid;
@@ -1336,7 +1339,6 @@ int ib_resolve_eth_dmac(struct ib_device *device,
        grh->hop_limit = hop_limit;
        return ret;
 }
-EXPORT_SYMBOL(ib_resolve_eth_dmac);
 
 static bool is_qp_type_connected(const struct ib_qp *qp)
 {
@@ -1566,12 +1568,12 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
 }
 EXPORT_SYMBOL(__ib_create_cq);
 
-int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
+int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period)
 {
        return cq->device->modify_cq ?
                cq->device->modify_cq(cq, cq_count, cq_period) : -ENOSYS;
 }
-EXPORT_SYMBOL(ib_modify_cq);
+EXPORT_SYMBOL(rdma_set_cq_moderation);
 
 int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)
 {
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c 
b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index 841326bd958d..10cc5be661b5 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
@@ -87,8 +87,9 @@ static int ipoib_set_coalesce(if_t dev,
                        coal->rx_coalesce_usecs = 0xffff;
        }
 
-       ret = ib_modify_cq(priv->recv_cq, coal->rx_max_coalesced_frames,
-                          coal->rx_coalesce_usecs);
+       ret = rdma_set_cq_moderation(priv->recv_cq,
+                                    coal->rx_max_coalesced_frames,
+                                    coal->rx_coalesce_usecs);
        if (ret && ret != -ENOSYS) {
                ipoib_warn(priv, "failed modifying CQ (%d)\n", ret);
                return ret;
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c 
b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
index cfc2390db02e..fd45e9961353 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
@@ -1682,7 +1682,7 @@ sdp_set_default_moderation(struct sdp_sock *ssk)
 {
        if (sdp_mod_count <= 0 || sdp_mod_usec <= 0)
                return;
-       ib_modify_cq(ssk->rx_ring.cq, sdp_mod_count, sdp_mod_usec);
+       rdma_set_cq_moderation(ssk->rx_ring.cq, sdp_mod_count, sdp_mod_usec);
 }
 
 static void
diff --git a/sys/ofed/include/rdma/ib_addr.h b/sys/ofed/include/rdma/ib_addr.h
index fc938afabd05..b59d4a7bd572 100644
--- a/sys/ofed/include/rdma/ib_addr.h
+++ b/sys/ofed/include/rdma/ib_addr.h
@@ -140,8 +140,9 @@ int rdma_resolve_ip_route(struct sockaddr *src_addr,
 
 void rdma_addr_cancel(struct rdma_dev_addr *addr);
 
-int rdma_copy_addr(struct rdma_dev_addr *dev_addr, if_t dev,
-             const unsigned char *dst_dev_addr);
+void rdma_copy_addr(struct rdma_dev_addr *dev_addr,
+                   const if_t dev,
+                   const unsigned char *dst_dev_addr);
 
 int rdma_addr_size(struct sockaddr *addr);
 int rdma_addr_size_in6(struct sockaddr_in6 *addr);
diff --git a/sys/ofed/include/rdma/ib_umem_odp.h 
b/sys/ofed/include/rdma/ib_umem_odp.h
index 5affdc6427d9..99a6127a562e 100644
--- a/sys/ofed/include/rdma/ib_umem_odp.h
+++ b/sys/ofed/include/rdma/ib_umem_odp.h
@@ -114,10 +114,6 @@ 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_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);
 /*
diff --git a/sys/ofed/include/rdma/ib_verbs.h b/sys/ofed/include/rdma/ib_verbs.h
index d526054a29c5..45c7d238de68 100644
--- a/sys/ofed/include/rdma/ib_verbs.h
+++ b/sys/ofed/include/rdma/ib_verbs.h
@@ -3420,13 +3420,13 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
 int ib_resize_cq(struct ib_cq *cq, int cqe);
 
 /**
- * ib_modify_cq - Modifies moderation params of the CQ
+ * rdma_set_cq_moderation - Modifies moderation params of the CQ
  * @cq: The CQ to modify.
  * @cq_count: number of CQEs that will trigger an event
  * @cq_period: max period of time in usec before triggering an event
  *
  */
-int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
+int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period);
 
 /**
  * ib_destroy_cq_user - Destroys the specified CQ.
@@ -3943,9 +3943,6 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct 
ib_uverbs_file *ufile);
 
 int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs);
 
-int ib_resolve_eth_dmac(struct ib_device *device,
-                       struct rdma_ah_attr *ah_attr);
-
 static inline u8 *rdma_ah_retrieve_dmac(struct rdma_ah_attr *attr)
 {
        if (attr->type == RDMA_AH_ATTR_TYPE_ROCE)

Reply via email to