aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2026-06-24 19:30:56 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2026-06-24 19:30:56 +0000
commit45c0d87c57298599397204179c2c4fa0f580a5d9 (patch)
treed09637ae6f8f4b2f38f538a4352457fb07dbafe4 /sys/dev
parent4726b80d9379cdefd00ae77d0b91973bde573790 (diff)
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/bnxt/bnxt_re/ib_verbs.c21
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c8
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c6
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c8
4 files changed, 27 insertions, 16 deletions
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.c b/sys/dev/bnxt/bnxt_re/ib_verbs.c
index 0162c130d23e..48be755b78a0 100644
--- a/sys/dev/bnxt/bnxt_re/ib_verbs.c
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.c
@@ -517,8 +517,10 @@ int bnxt_re_add_gid(const struct ib_gid_attr *attr, void **context)
struct bnxt_re_gid_ctx *ctx, **ctx_tbl;
struct bnxt_re_dev *rdev = to_bnxt_re_dev(attr->device, ibdev);
struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl;
- if ((attr->ndev) && is_vlan_dev(attr->ndev))
- vlan_id = vlan_dev_vlan_id(attr->ndev);
+
+ rc = rdma_read_gid_l2_fields(attr, &vlan_id, NULL);
+ if (rc)
+ return rc;
rc = bnxt_qplib_add_sgid(sgid_tbl, &attr->gid,
rdev->dev_addr,
@@ -936,13 +938,11 @@ static int bnxt_re_get_ah_info(struct bnxt_re_dev *rdev,
ah_info->sgid = gattr->gid;
/* Get vlan tag */
- if (gattr->ndev) {
- if (is_vlan_dev(gattr->ndev))
- ah_info->vlan_tag = vlan_dev_vlan_id(gattr->ndev);
- }
+ rc = rdma_read_gid_l2_fields(gattr, &ah_info->vlan_tag, NULL);
+ if (rc)
+ return rc;
/* Get network header type for this GID */
-
ib_ntype = rdma_gid_attr_network_type(gattr);
ntype = _to_bnxt_re_nw_type(ib_ntype);
ah_info->nw_type = ntype;
@@ -2649,8 +2649,11 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
sgid_attr = grh->sgid_attr;
gid_ptr = &sgid_attr->gid;
if (sgid_attr->ndev) {
- memcpy(qp->qplib_qp.smac, rdev->dev_addr,
- ETH_ALEN);
+ rc = rdma_read_gid_l2_fields(sgid_attr, NULL,
+ &qp->qplib_qp.smac[0]);
+ if (rc)
+ return rc;
+
nw_type = rdma_gid_attr_network_type(sgid_attr);
dev_dbg(rdev_to_dev(rdev),
"Connection using the nw_type %d\n", nw_type);
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
index babdd234e45b..4ae31c59c2cf 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
@@ -95,9 +95,11 @@ static int create_iboe_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
memcpy(ah->av.eth.mac, ah_attr->roce.dmac, ETH_ALEN);
eth_zero_addr(ah->av.eth.s_mac);
gid_attr = ah_attr->grh.sgid_attr;
- vlan_tag = rdma_vlan_dev_vlan_id(gid_attr->ndev);
- memcpy(ah->av.eth.s_mac, if_getlladdr(gid_attr->ndev), ETH_ALEN);
-
+ ret = rdma_read_gid_l2_fields(gid_attr, &vlan_tag,
+ &ah->av.eth.s_mac[0]);
+ if (ret)
+ return ret;
+
if (vlan_tag < 0x1000)
vlan_tag |= (rdma_ah_get_sl(ah_attr) & 7) << 13;
ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn |
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
index fb98bdcd48f9..a411bd2c48ee 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
@@ -1780,8 +1780,10 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
if (is_eth) {
gid_attr = attr->ah_attr.grh.sgid_attr;
- vlan = rdma_vlan_dev_vlan_id(gid_attr->ndev);
- memcpy(smac, if_getlladdr(gid_attr->ndev), ETH_ALEN);
+ err = rdma_read_gid_l2_fields(gid_attr, &vlan,
+ &smac[0]);
+ if (err)
+ goto out;
}
if (mlx4_set_path(dev, attr, attr_mask, qp, &context->pri_path,
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
index 90b886d635f1..53ccf68e4077 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
@@ -368,12 +368,16 @@ static void ib_gid_to_mlx5_roce_addr(const union ib_gid *gid,
void *mlx5_addr_mac = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
source_mac_47_32);
u16 vlan_id;
+ int ret;
if (!gid)
return;
- ether_addr_copy(mlx5_addr_mac, if_getlladdr(attr->ndev));
- vlan_id = rdma_vlan_dev_vlan_id(attr->ndev);
+
+ ret = rdma_read_gid_l2_fields(attr, &vlan_id, mlx5_addr_mac);
+ if (ret != 0)
+ return;
+
if (vlan_id != 0xffff) {
MLX5_SET_RA(mlx5_addr, vlan_valid, 1);
MLX5_SET_RA(mlx5_addr, vlan_id, vlan_id);