git: 774a6620632f - main - OFED: Various changes from Linux 4.12
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Jun 2026 19:51:10 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=774a6620632ff621bd840c6945b705420efcd55d
commit 774a6620632ff621bd840c6945b705420efcd55d
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-06-24 19:30:55 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-06-24 19:30:55 +0000
OFED: Various changes from Linux 4.12
Most of the changes involve renaming InfiBand address handles (AH) to
RDMA address handles including renaming various types and functions.
Address handles now also include type-specific fields and a set of
wrapper accessor functions for getting and setting fields. For some
of the type and function renames, drivers in sys/dev had to be updated
directly (typically via sed).
This contains changes from the following Linux commits:
f039f44fc331 IB/core: Add support for draining IB_POLL_DIRECT completion queues
fedd9e1f7582 IB/cq: Don't process more than the given budget
403cd12e2cf7 IB/umem: Add contiguous ODP support
0008b84ea9af IB/umem: Add support to huge ODP
3e7e1193e28a IB: Replace ib_umem page_size by page_shift
cb8637660ae8 IB/SA: Move functions update_sm_ah() and ib_sa_event()
680562b56939 IB/SA: Remove unwanted braces
dbb6c91fd8e0 IB/SA: Add braces when using sizeof
f96a31871449 IB/SA: Fix lines longer than 80 columns
94d595c56077 IB/core: Add rdma_cap_opa_ah to expose opa address handles
ee1c60b1bff8 IB/SA: Modify SA to implicitly cache Class Port info
aa4656d9a429 IB/core: Move opa_class_port_info definition to header file
2196f2716292 IB/SA: Add support to query opa classport info.
64b4646eaf3d IB/core: Define 'opa' rdma_ah_attr type
44c58487d51a IB/core: Define 'ib' and 'roce' rdma_ah_attr types
d8966fcd4c25 IB/core: Use rdma_ah_attr accessor functions
2224c47ace23 IB/core: Add accessor functions for rdma_ah_attr fields
365231593409 IB/core: Rename ib_destroy_ah to rdma_destroy_ah
bfbfd661c9ea IB/core: Rename ib_query_ah to rdma_query_ah
67b985b6c755 IB/core: Rename ib_modify_ah to rdma_modify_ah
0a18cfe4f6d7 IB/core: Rename ib_create_ah to rdma_create_ah
766b7f6cf0c0 IB/mthca: Rename to_ib_ah_attr to to_rdma_ah_attr
38349389fece IB/mlx5: Rename to_ib_ah_attr to to_rdma_ah_attr
71d53ab47ee6 IB/mlx4: Rename to_ib_ah_attr to to_rdma_ah_attr
90898850ec4e IB/core: Rename struct ib_ah_attr to rdma_ah_attr
4ba66093bdc6 IB/core: Check for global flag when using ah_attr
cf0b9395d084 IB/core: Add braces when using sizeof
cfd519358f50 IB/IPoIB: Remove 'else' when the 'if' has a return.
82ffc226483c IB/CM: Add braces when using sizeof
dfa834e1d97e IB/SA: Introduce path record specific types
c2f8fc4ec440 IB/SA: Rename ib_sa_path_rec to sa_path_rec
9fdca4da4d8c IB/SA: Split struct sa_path_rec based on IB and ROCE specific fields
4c33bd1926cc IB/SA: Add support to query OPA path records
57520751445b IB/SA: Add OPA path record type
87f0faadc685 IB/SA: Add OPA addr header
eed7624552ca RDMA/mlx4: Fix MAD tunneling when SRIOV is enabled
f937d93a9122 RDMA/uverbs: Declare local function static and add brackets to sizeof
d3957b86a406 RDMA/SA: Fix kernel panic in CMA request handler flow
The IPoIB portions of ee1c60b1bff8 were already present in FreeBSD
from an earlier sync with OFED. Likewise, the ib_uverbs_cmd.c
changes from 4ba66093bdc6 were also already present.
Tested by: Wafa Hamzah <wafah@nvidia.com> (mlx5_ib)
Tested by: John Baldwin <jhb@FreeBSD.org> (iw_cxgbe)
Sponsored by: Chelsio Communications
---
sys/dev/bnxt/bnxt_re/bnxt_re.h | 2 +-
sys/dev/bnxt/bnxt_re/ib_verbs.c | 102 +--
sys/dev/bnxt/bnxt_re/ib_verbs.h | 10 +-
sys/dev/cxgbe/iw_cxgbe/mem.c | 4 +-
sys/dev/cxgbe/iw_cxgbe/provider.c | 2 +-
sys/dev/irdma/fbsd_kcompat.h | 6 +-
sys/dev/irdma/irdma_kcompat.c | 18 +-
sys/dev/irdma/irdma_verbs.c | 31 +-
sys/dev/irdma/irdma_verbs.h | 2 +-
sys/dev/irdma/osdep.h | 2 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib.h | 8 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c | 126 +--
sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c | 2 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c | 70 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c | 8 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c | 6 +-
sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c | 102 ++-
sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c | 2 +-
sys/dev/mlx5/mlx5_ib/mlx5_ib.h | 4 +-
sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c | 72 +-
sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c | 2 +-
sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c | 100 +--
sys/dev/mthca/mthca_av.c | 68 +-
sys/dev/mthca/mthca_dev.h | 4 +-
sys/dev/mthca/mthca_mad.c | 19 +-
sys/dev/mthca/mthca_provider.c | 7 +-
sys/dev/mthca/mthca_qp.c | 88 +-
sys/dev/qlnx/qlnxr/qlnxr_cm.c | 10 +-
sys/dev/qlnx/qlnxr/qlnxr_def.h | 13 +-
sys/dev/qlnx/qlnxr/qlnxr_verbs.c | 60 +-
sys/dev/qlnx/qlnxr/qlnxr_verbs.h | 6 +-
sys/ofed/drivers/infiniband/core/ib_agent.c | 4 +-
sys/ofed/drivers/infiniband/core/ib_cm.c | 115 ++-
sys/ofed/drivers/infiniband/core/ib_cma.c | 124 +--
sys/ofed/drivers/infiniband/core/ib_cq.c | 12 +-
sys/ofed/drivers/infiniband/core/ib_mad.c | 25 +-
sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c | 17 +-
sys/ofed/drivers/infiniband/core/ib_multicast.c | 27 +-
sys/ofed/drivers/infiniband/core/ib_sa_query.c | 887 ++++++++++++++++-----
sys/ofed/drivers/infiniband/core/ib_ucm.c | 6 +-
sys/ofed/drivers/infiniband/core/ib_ucma.c | 24 +-
sys/ofed/drivers/infiniband/core/ib_umem.c | 17 +-
sys/ofed/drivers/infiniband/core/ib_umem_odp.c | 80 +-
sys/ofed/drivers/infiniband/core/ib_user_mad.c | 44 +-
sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c | 83 +-
.../drivers/infiniband/core/ib_uverbs_marshall.c | 85 +-
.../drivers/infiniband/core/ib_uverbs_std_types.c | 6 +-
sys/ofed/drivers/infiniband/core/ib_verbs.c | 130 +--
sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h | 4 +-
sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c | 6 +-
sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c | 6 +-
sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c | 6 +-
sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c | 22 +-
.../drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 64 +-
sys/ofed/include/rdma/ib_cm.h | 14 +-
sys/ofed/include/rdma/ib_mad.h | 38 +
sys/ofed/include/rdma/ib_marshall.h | 6 +-
sys/ofed/include/rdma/ib_sa.h | 293 ++++++-
sys/ofed/include/rdma/ib_umem.h | 8 +-
sys/ofed/include/rdma/ib_umem_odp.h | 6 +-
sys/ofed/include/rdma/ib_verbs.h | 243 +++++-
sys/ofed/include/rdma/opa_addr.h | 79 ++
sys/ofed/include/rdma/rdma_cm.h | 4 +-
sys/ofed/include/rdma/rdma_cm_ib.h | 2 +-
sys/ofed/include/rdma/rdma_vt.h | 8 +-
sys/ofed/include/rdma/rdmavt_qp.h | 4 +-
66 files changed, 2287 insertions(+), 1168 deletions(-)
diff --git a/sys/dev/bnxt/bnxt_re/bnxt_re.h b/sys/dev/bnxt/bnxt_re/bnxt_re.h
index 0afc8566c020..8c78d78e742a 100644
--- a/sys/dev/bnxt/bnxt_re/bnxt_re.h
+++ b/sys/dev/bnxt/bnxt_re/bnxt_re.h
@@ -613,7 +613,7 @@ struct bnxt_re_resolve_dmac_work{
struct work_struct work;
struct list_head list;
struct bnxt_re_dev *rdev;
- struct ib_ah_attr *ah_attr;
+ struct rdma_ah_attr *ah_attr;
struct bnxt_re_ah_info *ah_info;
atomic_t status_wait;
};
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.c b/sys/dev/bnxt/bnxt_re/ib_verbs.c
index 9e6887a7c6e1..55d8d8b5b04a 100644
--- a/sys/dev/bnxt/bnxt_re/ib_verbs.c
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.c
@@ -53,7 +53,7 @@ void bnxt_re_resolve_dmac_task(struct work_struct *work)
{
int rc = -1;
struct bnxt_re_dev *rdev;
- struct ib_ah_attr *ah_attr;
+ struct rdma_ah_attr *ah_attr;
struct bnxt_re_resolve_dmac_work *dmac_work =
container_of(work, struct bnxt_re_resolve_dmac_work, work);
@@ -943,7 +943,7 @@ static u8 _to_bnxt_re_nw_type(enum rdma_network_type ntype)
static inline int
bnxt_re_get_cached_gid(struct ib_device *dev, u8 port_num, int index,
union ib_gid *sgid, struct ib_gid_attr **sgid_attr,
- struct ib_global_route *grh, struct ib_ah *ah)
+ const struct ib_global_route *grh, struct ib_ah *ah)
{
int ret = 0;
@@ -959,20 +959,21 @@ bnxt_re_gid_to_network_type(struct ib_gid_attr *sgid_attr,
}
static int bnxt_re_get_ah_info(struct bnxt_re_dev *rdev,
- struct ib_ah_attr *ah_attr,
+ struct rdma_ah_attr *ah_attr,
struct bnxt_re_ah_info *ah_info)
{
struct ib_gid_attr *gattr;
enum rdma_network_type ib_ntype;
u8 ntype;
union ib_gid *gid;
+ const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
int rc = 0;
gid = &ah_info->sgid;
gattr = &ah_info->sgid_attr;
- rc = bnxt_re_get_cached_gid(&rdev->ibdev, 1, ah_attr->grh.sgid_index,
- gid, &gattr, &ah_attr->grh, NULL);
+ rc = bnxt_re_get_cached_gid(&rdev->ibdev, 1, grh->sgid_index,
+ gid, &gattr, grh, NULL);
if (rc)
return rc;
@@ -998,16 +999,17 @@ 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 ib_ah_attr *ah_attr,
+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 *)
- ah_attr->grh.dgid.raw) &&
- !rdma_link_local_addr((struct in6_addr *)ah_attr->grh.dgid.raw)) {
+ 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;
@@ -1043,7 +1045,7 @@ static int bnxt_re_init_dmac(struct bnxt_re_dev *rdev, struct ib_ah_attr *ah_att
return rc;
}
-int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
+int bnxt_re_create_ah(struct ib_ah *ah_in, struct rdma_ah_attr *attr,
u32 flags, struct ib_udata *udata)
{
@@ -1052,15 +1054,16 @@ int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
struct bnxt_re_ah *ah = container_of(ib_ah, struct bnxt_re_ah, ibah);
struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ibpd);
struct bnxt_re_dev *rdev = pd->rdev;
+ 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 ib_ah_attr *ah_attr = attr;
+ struct rdma_ah_attr *ah_attr = attr;
block = !(flags & RDMA_CREATE_AH_SLEEPABLE);
- if (!(ah_attr->ah_flags & IB_AH_GRH))
+ if (!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH))
dev_err(rdev_to_dev(rdev), "ah_attr->ah_flags GRH is not set\n");
ah->rdev = rdev;
@@ -1068,19 +1071,19 @@ int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
is_user = ib_pd->uobject ? true : false;
/* Supply the configuration for the HW */
- memcpy(ah->qplib_ah.dgid.data, ah_attr->grh.dgid.raw,
+ memcpy(ah->qplib_ah.dgid.data, grh->dgid.raw,
sizeof(union ib_gid));
- ah->qplib_ah.sgid_index = _get_sgid_index(rdev, ah_attr->grh.sgid_index);
+ ah->qplib_ah.sgid_index = _get_sgid_index(rdev, grh->sgid_index);
if (ah->qplib_ah.sgid_index == 0xFF) {
dev_err(rdev_to_dev(rdev), "invalid sgid_index!\n");
rc = -EINVAL;
goto fail;
}
- ah->qplib_ah.host_sgid_index = ah_attr->grh.sgid_index;
- ah->qplib_ah.traffic_class = ah_attr->grh.traffic_class;
- ah->qplib_ah.flow_label = ah_attr->grh.flow_label;
- ah->qplib_ah.hop_limit = ah_attr->grh.hop_limit;
- ah->qplib_ah.sl = ah_attr->sl;
+ ah->qplib_ah.host_sgid_index = grh->sgid_index;
+ ah->qplib_ah.traffic_class = grh->traffic_class;
+ ah->qplib_ah.flow_label = grh->flow_label;
+ ah->qplib_ah.hop_limit = grh->hop_limit;
+ ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr);
rc = bnxt_re_get_ah_info(rdev, ah_attr, &ah_info);
if (rc)
goto fail;
@@ -1121,25 +1124,24 @@ fail:
return rc;
}
-int bnxt_re_modify_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+int bnxt_re_modify_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
{
return 0;
}
-int bnxt_re_query_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+int bnxt_re_query_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
{
struct bnxt_re_ah *ah = to_bnxt_re(ib_ah, struct bnxt_re_ah, ibah);
- memcpy(ah_attr->grh.dgid.raw, ah->qplib_ah.dgid.data,
- sizeof(union ib_gid));
- ah_attr->grh.sgid_index = ah->qplib_ah.host_sgid_index;
- ah_attr->grh.traffic_class = ah->qplib_ah.traffic_class;
- ah_attr->sl = ah->qplib_ah.sl;
+ ah_attr->type = ib_ah->type;
+ rdma_ah_set_sl(ah_attr, ah->qplib_ah.sl);
memcpy(ROCE_DMAC(ah_attr), ah->qplib_ah.dmac, ETH_ALEN);
- ah_attr->ah_flags = IB_AH_GRH;
- ah_attr->port_num = 1;
- ah_attr->static_rate = 0;
-
+ rdma_ah_set_grh(ah_attr, NULL, 0,
+ ah->qplib_ah.host_sgid_index,
+ 0, ah->qplib_ah.traffic_class);
+ rdma_ah_set_dgid_raw(ah_attr, ah->qplib_ah.dgid.data);
+ rdma_ah_set_port_num(ah_attr, 1);
+ rdma_ah_set_static_rate(ah_attr, 0);
return 0;
}
@@ -2719,6 +2721,9 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
qp->qplib_qp.qkey = qp_attr->qkey;
}
if (qp_attr_mask & IB_QP_AV) {
+ const struct ib_global_route *grh =
+ rdma_ah_read_grh(&qp_attr->ah_attr);
+
qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_DGID |
CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL |
CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX |
@@ -2726,22 +2731,21 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS |
CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC |
CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID;
- memcpy(qp->qplib_qp.ah.dgid.data, qp_attr->ah_attr.grh.dgid.raw,
+ memcpy(qp->qplib_qp.ah.dgid.data, grh->dgid.raw,
sizeof(qp->qplib_qp.ah.dgid.data));
- qp->qplib_qp.ah.flow_label = qp_attr->ah_attr.grh.flow_label;
+ qp->qplib_qp.ah.flow_label = grh->flow_label;
qp->qplib_qp.ah.sgid_index = _get_sgid_index(rdev,
- qp_attr->ah_attr.grh.sgid_index);
- qp->qplib_qp.ah.host_sgid_index = qp_attr->ah_attr.grh.sgid_index;
- qp->qplib_qp.ah.hop_limit = qp_attr->ah_attr.grh.hop_limit;
- qp->qplib_qp.ah.traffic_class =
- qp_attr->ah_attr.grh.traffic_class;
- qp->qplib_qp.ah.sl = qp_attr->ah_attr.sl;
+ grh->sgid_index);
+ qp->qplib_qp.ah.host_sgid_index = grh->sgid_index;
+ qp->qplib_qp.ah.hop_limit = grh->hop_limit;
+ qp->qplib_qp.ah.traffic_class = grh->traffic_class;
+ qp->qplib_qp.ah.sl = rdma_ah_get_sl(&qp_attr->ah_attr);
ether_addr_copy(qp->qplib_qp.ah.dmac, ROCE_DMAC(&qp_attr->ah_attr));
sgid_attr = &gid_attr;
status = bnxt_re_get_cached_gid(&rdev->ibdev, 1,
- qp_attr->ah_attr.grh.sgid_index,
+ grh->sgid_index,
&sgid, &sgid_attr,
- &qp_attr->ah_attr.grh, NULL);
+ grh, NULL);
if (!status)
if_rele(sgid_attr->ndev);
gid_ptr = &sgid;
@@ -2949,13 +2953,13 @@ int bnxt_re_query_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
qp_attr->qp_access_flags = __to_ib_access_flags(qplib_qp->access);
qp_attr->pkey_index = qplib_qp->pkey_index;
qp_attr->qkey = qplib_qp->qkey;
- memcpy(qp_attr->ah_attr.grh.dgid.raw, qplib_qp->ah.dgid.data,
- sizeof(qplib_qp->ah.dgid.data));
- qp_attr->ah_attr.grh.flow_label = qplib_qp->ah.flow_label;
- qp_attr->ah_attr.grh.sgid_index = qplib_qp->ah.host_sgid_index;
- qp_attr->ah_attr.grh.hop_limit = qplib_qp->ah.hop_limit;
- qp_attr->ah_attr.grh.traffic_class = qplib_qp->ah.traffic_class;
- qp_attr->ah_attr.sl = qplib_qp->ah.sl;
+ qp_attr->ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE;
+ rdma_ah_set_grh(&qp_attr->ah_attr, NULL, qplib_qp->ah.flow_label,
+ qplib_qp->ah.host_sgid_index,
+ qplib_qp->ah.hop_limit,
+ qplib_qp->ah.traffic_class);
+ rdma_ah_set_dgid_raw(&qp_attr->ah_attr, qplib_qp->ah.dgid.data);
+ rdma_ah_set_sl(&qp_attr->ah_attr, qplib_qp->ah.sl);
ether_addr_copy(ROCE_DMAC(&qp_attr->ah_attr), qplib_qp->ah.dmac);
qp_attr->path_mtu = __to_ib_mtu(qplib_qp->path_mtu);
qp_attr->timeout = qplib_qp->timeout;
@@ -5108,11 +5112,7 @@ static int bnxt_re_page_size_ok(int page_shift)
static int bnxt_re_get_page_shift(struct ib_umem *umem,
u64 va, u64 st, u64 cmask)
{
- int pgshft;
-
- pgshft = ilog2(umem->page_size);
-
- return pgshft;
+ return umem->page_shift;
}
static int bnxt_re_get_num_pages(struct ib_umem *umem, u64 start, u64 length, int page_shift)
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.h b/sys/dev/bnxt/bnxt_re/ib_verbs.h
index 66d15dd2b767..7dd8f6ece12f 100644
--- a/sys/dev/bnxt/bnxt_re/ib_verbs.h
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.h
@@ -104,7 +104,7 @@ struct bnxt_re_dev;
#define RDMA_NETWORK_IPV4 1
#define RDMA_NETWORK_IPV6 2
-#define ROCE_DMAC(x) (x)->dmac
+#define ROCE_DMAC(x) (x)->roce.dmac
#define dma_rmb() rmb()
@@ -307,11 +307,11 @@ enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
int bnxt_re_alloc_pd(struct ib_pd *pd_in, struct ib_udata *udata);
void bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata);
-int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
+int bnxt_re_create_ah(struct ib_ah *ah_in, struct rdma_ah_attr *attr,
u32 flags, struct ib_udata *udata);
-int bnxt_re_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
-int bnxt_re_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
+int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
+int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
void bnxt_re_destroy_ah(struct ib_ah *ib_ah, u32 flags);
int bnxt_re_create_srq(struct ib_srq *srq_in,
@@ -380,7 +380,7 @@ void bnxt_re_handle_cqn(struct bnxt_qplib_cq *cq);
static inline int
bnxt_re_get_cached_gid(struct ib_device *dev, u8 port_num, int index,
union ib_gid *sgid, struct ib_gid_attr **sgid_attr,
- struct ib_global_route *grh, struct ib_ah *ah);
+ const struct ib_global_route *grh, struct ib_ah *ah);
static inline enum rdma_network_type
bnxt_re_gid_to_network_type(struct ib_gid_attr *sgid_attr,
union ib_gid *sgid);
diff --git a/sys/dev/cxgbe/iw_cxgbe/mem.c b/sys/dev/cxgbe/iw_cxgbe/mem.c
index ae0aa0edc17a..0a2b5e3cb4ba 100644
--- a/sys/dev/cxgbe/iw_cxgbe/mem.c
+++ b/sys/dev/cxgbe/iw_cxgbe/mem.c
@@ -425,7 +425,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
return ERR_PTR(err);
}
- shift = ffs(mhp->umem->page_size) - 1;
+ shift = mhp->umem->page_shift;
n = mhp->umem->nmap;
err = alloc_pbl(mhp, n);
@@ -443,7 +443,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
len = sg_dma_len(sg) >> shift;
for (k = 0; k < len; ++k) {
pages[i++] = cpu_to_be64(sg_dma_address(sg) +
- mhp->umem->page_size * k);
+ (k << shift));
if (i == PAGE_SIZE / sizeof *pages) {
err = write_pbl(&mhp->rhp->rdev,
pages,
diff --git a/sys/dev/cxgbe/iw_cxgbe/provider.c b/sys/dev/cxgbe/iw_cxgbe/provider.c
index 20803cb022d9..010ae9d9b426 100644
--- a/sys/dev/cxgbe/iw_cxgbe/provider.c
+++ b/sys/dev/cxgbe/iw_cxgbe/provider.c
@@ -57,7 +57,7 @@ static int c4iw_modify_port(struct ib_device *ibdev,
}
static int c4iw_ah_create(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr, u32 flags,
+ struct rdma_ah_attr *ah_attr, u32 flags,
struct ib_udata *udata)
{
return -ENOSYS;
diff --git a/sys/dev/irdma/fbsd_kcompat.h b/sys/dev/irdma/fbsd_kcompat.h
index cc51f1e7933a..8dcbbd8e5144 100644
--- a/sys/dev/irdma/fbsd_kcompat.h
+++ b/sys/dev/irdma/fbsd_kcompat.h
@@ -137,12 +137,12 @@ struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata);
int irdma_create_ah(struct ib_ah *ib_ah,
- struct ib_ah_attr *attr, u32 flags,
+ struct rdma_ah_attr *attr, u32 flags,
struct ib_udata *udata);
int irdma_create_ah_stub(struct ib_ah *ib_ah,
- struct ib_ah_attr *attr, u32 flags,
+ struct rdma_ah_attr *attr, u32 flags,
struct ib_udata *udata);
-void irdma_ether_copy(u8 *dmac, struct ib_ah_attr *attr);
+void irdma_ether_copy(u8 *dmac, struct rdma_ah_attr *attr);
void irdma_destroy_ah(struct ib_ah *ibah, u32 flags);
void irdma_destroy_ah_stub(struct ib_ah *ibah, u32 flags);
int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
diff --git a/sys/dev/irdma/irdma_kcompat.c b/sys/dev/irdma/irdma_kcompat.c
index 0cf4b6b0c64e..a320d614d127 100644
--- a/sys/dev/irdma/irdma_kcompat.c
+++ b/sys/dev/irdma/irdma_kcompat.c
@@ -527,7 +527,7 @@ irdma_create_ah_wait(struct irdma_pci_f *rf,
static int
irdma_create_sleepable_ah(struct ib_ah *ib_ah,
- struct ib_ah_attr *attr, u32 flags,
+ struct rdma_ah_attr *attr, u32 flags,
struct ib_udata *udata)
{
struct irdma_pd *pd = to_iwpd(ib_ah->pd);
@@ -591,7 +591,7 @@ irdma_create_sleepable_ah(struct ib_ah *ib_ah,
ah_info->tc_tos = attr->grh.traffic_class;
}
- ether_addr_copy(dmac, attr->dmac);
+ ether_addr_copy(dmac, attr->roce.dmac);
irdma_fill_ah_info(if_getvnet(iwdev->netdev), ah_info, &sgid_attr, &sgid_addr, &dgid_addr,
dmac, ah->av.net_type);
@@ -639,21 +639,21 @@ err_gid_l2:
*/
int
irdma_create_ah(struct ib_ah *ib_ah,
- struct ib_ah_attr *attr, u32 flags,
+ struct rdma_ah_attr *attr, u32 flags,
struct ib_udata *udata)
{
return irdma_create_sleepable_ah(ib_ah, attr, flags, udata);
}
void
-irdma_ether_copy(u8 *dmac, struct ib_ah_attr *attr)
+irdma_ether_copy(u8 *dmac, struct rdma_ah_attr *attr)
{
- ether_addr_copy(dmac, attr->dmac);
+ ether_addr_copy(dmac, attr->roce.dmac);
}
int
irdma_create_ah_stub(struct ib_ah *ib_ah,
- struct ib_ah_attr *attr, u32 flags,
+ struct rdma_ah_attr *attr, u32 flags,
struct ib_udata *udata)
{
return -ENOSYS;
@@ -1402,9 +1402,11 @@ kc_irdma_set_roce_cm_info(struct irdma_qp *iwqp, struct ib_qp_attr *attr,
union ib_gid sgid;
struct ib_gid_attr sgid_attr;
struct irdma_av *av = &iwqp->roce_ah.av;
+ const struct ib_global_route *grh = rdma_ah_read_grh(&attr->ah_attr);
- ret = ib_get_cached_gid(iwqp->ibqp.device, attr->ah_attr.port_num,
- attr->ah_attr.grh.sgid_index, &sgid,
+ ret = ib_get_cached_gid(iwqp->ibqp.device,
+ rdma_ah_get_port_num(&attr->ah_attr),
+ grh->sgid_index, &sgid,
&sgid_attr);
if (ret)
return ret;
diff --git a/sys/dev/irdma/irdma_verbs.c b/sys/dev/irdma/irdma_verbs.c
index a131286d1d37..eea241873522 100644
--- a/sys/dev/irdma/irdma_verbs.c
+++ b/sys/dev/irdma/irdma_verbs.c
@@ -879,15 +879,18 @@ irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
ctx_info->roce_info->pd_id = iwpd->sc_pd.pd_id;
if (attr_mask & IB_QP_AV) {
+ const struct ib_global_route *grh =
+ rdma_ah_read_grh(&attr->ah_attr);
struct irdma_av *av = &iwqp->roce_ah.av;
u16 vlan_id = VLAN_N_VID;
u32 local_ip[4] = {};
memset(&iwqp->roce_ah, 0, sizeof(iwqp->roce_ah));
- if (attr->ah_attr.ah_flags & IB_AH_GRH) {
- udp_info->ttl = attr->ah_attr.grh.hop_limit;
- udp_info->flow_label = attr->ah_attr.grh.flow_label;
- udp_info->tos = attr->ah_attr.grh.traffic_class;
+ if (rdma_ah_get_ah_flags(&attr->ah_attr) & IB_AH_GRH) {
+
+ udp_info->ttl = grh->hop_limit;
+ udp_info->flow_label = grh->flow_label;
+ udp_info->tos = grh->traffic_class;
udp_info->src_port = kc_rdma_get_udp_sport(udp_info->flow_label,
ibqp->qp_num,
@@ -920,7 +923,7 @@ irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
}
av->attrs = attr->ah_attr;
- rdma_gid2ip((struct sockaddr *)&av->dgid_addr, &attr->ah_attr.grh.dgid);
+ rdma_gid2ip((struct sockaddr *)&av->dgid_addr, &grh->dgid);
if (av->net_type == RDMA_NETWORK_IPV6) {
__be32 *daddr =
av->dgid_addr.saddr_in6.sin6_addr.__u6_addr.__u6_addr32;
@@ -3232,20 +3235,18 @@ irdma_detach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid)
* @ah_attr: address handle attributes
*/
static int
-irdma_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
+irdma_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
{
struct irdma_ah *ah = to_iwah(ibah);
memset(ah_attr, 0, sizeof(*ah_attr));
- if (ah->av.attrs.ah_flags & IB_AH_GRH) {
- ah_attr->ah_flags = IB_AH_GRH;
- ah_attr->grh.flow_label = ah->sc_ah.ah_info.flow_label;
- ah_attr->grh.traffic_class = ah->sc_ah.ah_info.tc_tos;
- ah_attr->grh.hop_limit = ah->sc_ah.ah_info.hop_ttl;
- ah_attr->grh.sgid_index = ah->sgid_index;
- ah_attr->grh.sgid_index = ah->sgid_index;
- memcpy(&ah_attr->grh.dgid, &ah->dgid,
- sizeof(ah_attr->grh.dgid));
+ ah_attr->type = ibah->type;
+ if (rdma_ah_get_ah_flags(&ah->av.attrs) & IB_AH_GRH) {
+ rdma_ah_set_grh(ah_attr, &ah->dgid,
+ ah->sc_ah.ah_info.flow_label,
+ ah->sgid_index,
+ ah->sc_ah.ah_info.hop_ttl,
+ ah->sc_ah.ah_info.tc_tos);
}
return 0;
diff --git a/sys/dev/irdma/irdma_verbs.h b/sys/dev/irdma/irdma_verbs.h
index d3f240783c3d..1064b5f4e092 100644
--- a/sys/dev/irdma/irdma_verbs.h
+++ b/sys/dev/irdma/irdma_verbs.h
@@ -76,7 +76,7 @@ union irdma_sockaddr {
struct irdma_av {
u8 macaddr[16];
- struct ib_ah_attr attrs;
+ struct rdma_ah_attr attrs;
union irdma_sockaddr sgid_addr;
union irdma_sockaddr dgid_addr;
u8 net_type;
diff --git a/sys/dev/irdma/osdep.h b/sys/dev/irdma/osdep.h
index eb73ffbd30e2..757175ab762a 100644
--- a/sys/dev/irdma/osdep.h
+++ b/sys/dev/irdma/osdep.h
@@ -179,7 +179,7 @@ struct irdma_dev_ctx {
#define mdelay(x) DELAY((x) * 1000)
#define rt_tos2priority(tos) (tos >> 5)
-#define ah_attr_to_dmac(attr) ((attr).dmac)
+#define ah_attr_to_dmac(attr) ((attr).roce.dmac)
#define irdma_del_timer_compat(tt) del_timer((tt))
#define IRDMA_TAILQ_FOREACH CK_STAILQ_FOREACH
#define IRDMA_TAILQ_FOREACH_SAFE CK_STAILQ_FOREACH_SAFE
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib.h b/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
index 9b107e8b4b2d..9a5306ca1a30 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
@@ -739,11 +739,11 @@ int mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq);
void mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq);
-int mlx4_ib_create_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr, u32 flags,
+int mlx4_ib_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags,
struct ib_udata *udata);
-int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct ib_ah_attr *ah_attr,
+int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct rdma_ah_attr *ah_attr,
int slave_sgid_index, u8 *s_mac, u16 vlan_tag);
-int mlx4_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr);
+int mlx4_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
void mlx4_ib_destroy_ah(struct ib_ah *ah, u32 flags);
int mlx4_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr,
@@ -831,7 +831,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
enum ib_qp_type dest_qpt, u16 pkey_index, u32 remote_qpn,
- u32 qkey, struct ib_ah_attr *attr, u8 *s_mac,
+ u32 qkey, struct rdma_ah_attr *attr, u8 *s_mac,
u16 vlan_id, struct ib_mad *mad);
__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx);
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
index 4e5bf4c04d8e..6bb17975143f 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
@@ -42,28 +42,32 @@
#include "mlx4_ib.h"
-static int create_ib_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+static int create_ib_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
{
struct ib_pd *pd = ib_ah->pd;
struct mlx4_ib_ah *ah = to_mah(ib_ah);
struct mlx4_dev *dev = to_mdev(ib_ah->device)->dev;
- ah->av.ib.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
- ah->av.ib.g_slid = ah_attr->src_path_bits;
- ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
- if (ah_attr->ah_flags & IB_AH_GRH) {
+ ah->av.ib.port_pd = cpu_to_be32(to_mpd(pd)->pdn |
+ (rdma_ah_get_port_num(ah_attr) << 24));
+ ah->av.ib.g_slid = rdma_ah_get_path_bits(ah_attr);
+ ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(rdma_ah_get_sl(ah_attr) << 28);
+ if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
+ const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
+
ah->av.ib.g_slid |= 0x80;
- ah->av.ib.gid_index = ah_attr->grh.sgid_index;
- ah->av.ib.hop_limit = ah_attr->grh.hop_limit;
+ ah->av.ib.gid_index = grh->sgid_index;
+ ah->av.ib.hop_limit = grh->hop_limit;
ah->av.ib.sl_tclass_flowlabel |=
- cpu_to_be32((ah_attr->grh.traffic_class << 20) |
- ah_attr->grh.flow_label);
- memcpy(ah->av.ib.dgid, ah_attr->grh.dgid.raw, 16);
+ cpu_to_be32((grh->traffic_class << 20) |
+ grh->flow_label);
+ memcpy(ah->av.ib.dgid, grh->dgid.raw, 16);
}
- ah->av.ib.dlid = cpu_to_be16(ah_attr->dlid);
- if (ah_attr->static_rate) {
- ah->av.ib.stat_rate = ah_attr->static_rate + MLX4_STAT_RATE_OFFSET;
+ ah->av.ib.dlid = cpu_to_be16(rdma_ah_get_dlid(ah_attr));
+ if (rdma_ah_get_static_rate(ah_attr)) {
+ ah->av.ib.stat_rate = rdma_ah_get_static_rate(ah_attr) +
+ MLX4_STAT_RATE_OFFSET;
while (ah->av.ib.stat_rate > IB_RATE_2_5_GBPS + MLX4_STAT_RATE_OFFSET &&
!(1 << ah->av.ib.stat_rate & dev->caps.stat_rate_support))
--ah->av.ib.stat_rate;
@@ -71,12 +75,13 @@ static int create_ib_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
return 0;
}
-static int create_iboe_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+static int create_iboe_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
{
struct ib_pd *pd = ib_ah->pd;
struct mlx4_ib_dev *ibdev = to_mdev(ib_ah->device);
struct mlx4_ib_ah *ah = to_mah(ib_ah);
struct mlx4_dev *dev = ibdev->dev;
+ const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
int is_mcast = 0;
struct in6_addr in6;
u16 vlan_tag = 0xffff;
@@ -84,15 +89,15 @@ static int create_iboe_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
struct ib_gid_attr gid_attr;
int ret;
- memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
+ memcpy(&in6, grh->dgid.raw, sizeof(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->dmac, ETH_ALEN);
+ memcpy(ah->av.eth.mac, ah_attr->roce.dmac, ETH_ALEN);
}
- ret = ib_get_cached_gid(pd->device, ah_attr->port_num,
- ah_attr->grh.sgid_index, &sgid, &gid_attr);
+ ret = ib_get_cached_gid(pd->device, rdma_ah_get_port_num(ah_attr),
+ grh->sgid_index, &sgid, &gid_attr);
if (ret)
return ret;
eth_zero_addr(ah->av.eth.s_mac);
@@ -102,16 +107,19 @@ static int create_iboe_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
if_rele(gid_attr.ndev);
}
if (vlan_tag < 0x1000)
- vlan_tag |= (ah_attr->sl & 7) << 13;
- ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
- ret = mlx4_ib_gid_index_to_real_index(ibdev, ah_attr->port_num, ah_attr->grh.sgid_index);
+ vlan_tag |= (rdma_ah_get_sl(ah_attr) & 7) << 13;
+ ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn |
+ (rdma_ah_get_port_num(ah_attr) << 24));
+ ret = mlx4_ib_gid_index_to_real_index(ibdev,
+ rdma_ah_get_port_num(ah_attr), grh->sgid_index);
if (ret < 0)
return ret;
ah->av.eth.gid_index = ret;
ah->av.eth.vlan = cpu_to_be16(vlan_tag);
- ah->av.eth.hop_limit = ah_attr->grh.hop_limit;
- if (ah_attr->static_rate) {
- ah->av.eth.stat_rate = ah_attr->static_rate + MLX4_STAT_RATE_OFFSET;
+ ah->av.eth.hop_limit = grh->hop_limit;
+ if (rdma_ah_get_static_rate(ah_attr)) {
+ ah->av.eth.stat_rate = rdma_ah_get_static_rate(ah_attr) +
+ MLX4_STAT_RATE_OFFSET;
while (ah->av.eth.stat_rate > IB_RATE_2_5_GBPS + MLX4_STAT_RATE_OFFSET &&
!(1 << ah->av.eth.stat_rate & dev->caps.stat_rate_support))
--ah->av.eth.stat_rate;
@@ -123,17 +131,18 @@ static int create_iboe_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
if (is_mcast)
ah->av.ib.dlid = cpu_to_be16(0xc000);
- memcpy(ah->av.eth.dgid, ah_attr->grh.dgid.raw, 16);
- ah->av.eth.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 29);
+ memcpy(ah->av.eth.dgid, grh->dgid.raw, 16);
+ ah->av.eth.sl_tclass_flowlabel =
+ cpu_to_be32(rdma_ah_get_sl(ah_attr) << 29);
return 0;
}
-int mlx4_ib_create_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr,
+int mlx4_ib_create_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr,
u32 flags, struct ib_udata *udata)
{
- if (rdma_port_get_link_layer(ib_ah->pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
- if (!(ah_attr->ah_flags & IB_AH_GRH)) {
+ if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
+ if (!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) {
return -EINVAL;
} else {
/*
@@ -150,10 +159,10 @@ int mlx4_ib_create_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr,
return create_ib_ah(ib_ah, ah_attr);
}
-int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct ib_ah_attr *ah_attr,
+int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct rdma_ah_attr *ah_attr,
int slave_sgid_index, u8 *s_mac, u16 vlan_tag)
{
- struct ib_ah_attr slave_attr = *ah_attr;
+ struct rdma_ah_attr slave_attr = *ah_attr;
struct mlx4_ib_ah *mah = to_mah(ah);
int ret;
@@ -162,47 +171,54 @@ int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct ib_ah_attr *ah_attr,
if (ret)
return ret;
+ ah->type = ah_attr->type;
+
/* get rid of force-loopback bit */
mah->av.ib.port_pd &= cpu_to_be32(0x7FFFFFFF);
- if (rdma_port_get_link_layer(ah->pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET)
+ if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE)
memcpy(mah->av.eth.s_mac, s_mac, 6);
if (vlan_tag < 0x1000)
- vlan_tag |= (ah_attr->sl & 7) << 13;
+ vlan_tag |= (rdma_ah_get_sl(ah_attr) & 7) << 13;
mah->av.eth.vlan = cpu_to_be16(vlan_tag);
return 0;
}
-int mlx4_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
+int mlx4_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
{
struct mlx4_ib_ah *ah = to_mah(ibah);
- enum rdma_link_layer ll;
+ int port_num = be32_to_cpu(ah->av.ib.port_pd) >> 24;
memset(ah_attr, 0, sizeof *ah_attr);
- ah_attr->port_num = be32_to_cpu(ah->av.ib.port_pd) >> 24;
- ll = rdma_port_get_link_layer(ibah->device, ah_attr->port_num);
- if (ll == IB_LINK_LAYER_ETHERNET)
- ah_attr->sl = be32_to_cpu(ah->av.eth.sl_tclass_flowlabel) >> 29;
- else
- ah_attr->sl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 28;
-
- ah_attr->dlid = ll == IB_LINK_LAYER_INFINIBAND ? be16_to_cpu(ah->av.ib.dlid) : 0;
- if (ah->av.ib.stat_rate)
- ah_attr->static_rate = ah->av.ib.stat_rate - MLX4_STAT_RATE_OFFSET;
- ah_attr->src_path_bits = ah->av.ib.g_slid & 0x7F;
+ ah_attr->type = ibah->type;
+
+ if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
+ rdma_ah_set_dlid(ah_attr, 0);
+ rdma_ah_set_sl(ah_attr,
+ be32_to_cpu(ah->av.eth.sl_tclass_flowlabel)
+ >> 29);
+ } else {
+ rdma_ah_set_dlid(ah_attr, be16_to_cpu(ah->av.ib.dlid));
+ rdma_ah_set_sl(ah_attr,
+ be32_to_cpu(ah->av.ib.sl_tclass_flowlabel)
+ >> 28);
+ }
+ rdma_ah_set_port_num(ah_attr, port_num);
+ if (ah->av.ib.stat_rate)
+ rdma_ah_set_static_rate(ah_attr,
+ ah->av.ib.stat_rate -
+ MLX4_STAT_RATE_OFFSET);
+ rdma_ah_set_path_bits(ah_attr, ah->av.ib.g_slid & 0x7F);
if (mlx4_ib_ah_grh_present(ah)) {
- ah_attr->ah_flags = IB_AH_GRH;
-
- ah_attr->grh.traffic_class =
- be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 20;
- ah_attr->grh.flow_label =
- be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) & 0xfffff;
- ah_attr->grh.hop_limit = ah->av.ib.hop_limit;
- ah_attr->grh.sgid_index = ah->av.ib.gid_index;
- memcpy(ah_attr->grh.dgid.raw, ah->av.ib.dgid, 16);
+ u32 tc_fl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel);
+
+ rdma_ah_set_grh(ah_attr, NULL, tc_fl & 0xfffff,
+ ah->av.ib.gid_index, ah->av.ib.hop_limit,
+ tc_fl >> 20);
+ rdma_ah_set_dgid_raw(ah_attr, ah->av.ib.dgid);
}
return 0;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
index c4e9e2e600cd..aec8f43313c9 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
@@ -151,7 +151,7 @@ static int mlx4_ib_get_cq_umem(struct mlx4_ib_dev *dev, struct ib_udata *udata,
return PTR_ERR(*umem);
err = mlx4_mtt_init(dev->dev, ib_umem_page_count(*umem),
- ilog2((*umem)->page_size), &buf->mtt);
+ (*umem)->page_shift, &buf->mtt);
if (err)
goto err_buf;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
index 65d13d1947ea..85015d310133 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
@@ -187,25 +187,26 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
{
struct ib_ah *new_ah;
- struct ib_ah_attr ah_attr;
+ struct rdma_ah_attr ah_attr;
unsigned long flags;
if (!dev->send_agent[port_num - 1][0])
return;
memset(&ah_attr, 0, sizeof ah_attr);
- ah_attr.dlid = lid;
- ah_attr.sl = sl;
- ah_attr.port_num = port_num;
+ ah_attr.type = rdma_ah_find_type(&dev->ib_dev, port_num);
+ rdma_ah_set_dlid(&ah_attr, lid);
+ rdma_ah_set_sl(&ah_attr, sl);
+ rdma_ah_set_port_num(&ah_attr, port_num);
- new_ah = ib_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
- &ah_attr, 0);
+ new_ah = rdma_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
+ &ah_attr, 0);
if (IS_ERR(new_ah))
return;
spin_lock_irqsave(&dev->sm_lock, flags);
if (dev->sm_ah[port_num - 1])
- ib_destroy_ah(dev->sm_ah[port_num - 1], 0);
+ rdma_destroy_ah(dev->sm_ah[port_num - 1], 0);
dev->sm_ah[port_num - 1] = new_ah;
spin_unlock_irqrestore(&dev->sm_lock, flags);
}
@@ -506,7 +507,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
struct mlx4_ib_demux_pv_ctx *tun_ctx;
struct mlx4_ib_demux_pv_qp *tun_qp;
struct mlx4_rcv_tunnel_mad *tun_mad;
- struct ib_ah_attr attr;
+ struct rdma_ah_attr attr;
struct ib_ah *ah;
struct ib_qp *src_qp = NULL;
unsigned tun_tx_ix = 0;
@@ -552,15 +553,19 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
/* create ah. Just need an empty one with the port num for the post send.
* The driver will set the force loopback bit in post_send */
memset(&attr, 0, sizeof attr);
- attr.port_num = port;
+ attr.type = rdma_ah_find_type(&dev->ib_dev, port);
+
+ rdma_ah_set_port_num(&attr, port);
if (is_eth) {
union ib_gid sgid;
+ union ib_gid dgid;
- if (get_gids_from_l3_hdr(grh, &sgid, &attr.grh.dgid))
+ if (get_gids_from_l3_hdr(grh, &sgid, &dgid))
return -EINVAL;
attr.ah_flags = IB_AH_GRH;
+ rdma_ah_set_grh(&attr, &dgid, 0, 0, 0, 0);
}
- ah = ib_create_ah(tun_ctx->pd, &attr, 0);
+ ah = rdma_create_ah(tun_ctx->pd, &attr, 0);
if (IS_ERR(ah))
return -ENOMEM;
@@ -577,7 +582,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
tun_mad = (struct mlx4_rcv_tunnel_mad *) (tun_qp->tx_ring[tun_tx_ix].buf.addr);
if (tun_qp->tx_ring[tun_tx_ix].ah)
- ib_destroy_ah(tun_qp->tx_ring[tun_tx_ix].ah, 0);
+ rdma_destroy_ah(tun_qp->tx_ring[tun_tx_ix].ah, 0);
tun_qp->tx_ring[tun_tx_ix].ah = ah;
ib_dma_sync_single_for_cpu(&dev->ib_dev,
tun_qp->tx_ring[tun_tx_ix].buf.map,
@@ -652,7 +657,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
spin_unlock(&tun_qp->tx_lock);
tun_qp->tx_ring[tun_tx_ix].ah = NULL;
end:
- ib_destroy_ah(ah, 0);
+ rdma_destroy_ah(ah, 0);
return ret;
}
@@ -1006,7 +1011,7 @@ static void send_handler(struct ib_mad_agent *agent,
struct ib_mad_send_wc *mad_send_wc)
*** 5766 LINES SKIPPED ***