RDMA/hns: Response dmac to userspace
authorJunxian Huang <huangjunxian6@hisilicon.com>
Thu, 7 Dec 2023 11:42:28 +0000 (19:42 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 7 Dec 2023 13:09:16 +0000 (15:09 +0200)
While creating AH, dmac is already resolved in kernel. Response dmac
to userspace so that userspace doesn't need to resolve dmac repeatedly.

Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20231207114231.2872104-3-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_ah.c
include/uapi/rdma/hns-abi.h

index fbf046982374492ed4cbd4465676b3ea9d3d9814..b4209b6aed8d79241809926a0ef7038285a7e5e6 100644 (file)
@@ -57,6 +57,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
        struct rdma_ah_attr *ah_attr = init_attr->ah_attr;
        const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
        struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device);
+       struct hns_roce_ib_create_ah_resp resp = {};
        struct hns_roce_ah *ah = to_hr_ah(ibah);
        int ret = 0;
        u32 max_sl;
@@ -97,6 +98,12 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
                ah->av.vlan_en = ah->av.vlan_id < VLAN_N_VID;
        }
 
+       if (udata) {
+               memcpy(resp.dmac, ah_attr->roce.dmac, ETH_ALEN);
+               ret = ib_copy_to_udata(udata, &resp,
+                                      min(udata->outlen, sizeof(resp)));
+       }
+
 err_out:
        if (ret)
                atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_AH_CREATE_ERR_CNT]);
index ce0f37f83416e78bcba3a271d23ff00662f68b8f..c996e151081eb845b42734df878d1216d4418db8 100644 (file)
@@ -125,4 +125,9 @@ struct hns_roce_ib_alloc_pd_resp {
        __u32 pdn;
 };
 
+struct hns_roce_ib_create_ah_resp {
+       __u8 dmac[6];
+       __u8 reserved[2];
+};
+
 #endif /* HNS_ABI_USER_H */