Skip to content

Commit

Permalink
libhns: Get dmac from kernel driver
Browse files Browse the repository at this point in the history
As dmac is already resolved in kernel while creating AH, there is no
need to repeat the resolving in userspace. Prioritize getting dmac
from kernel driver, unless kernel driver didn't response one.

Signed-off-by: Junxian Huang <[email protected]>
  • Loading branch information
Junxian Huang authored and Junxian Huang committed Dec 8, 2023
1 parent 4a2b064 commit bf49669
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions providers/hns/hns_roce_u_abi.h
Expand Up @@ -61,4 +61,7 @@ DECLARE_DRV_CMD(hns_roce_create_srq, IB_USER_VERBS_CMD_CREATE_SRQ,
DECLARE_DRV_CMD(hns_roce_create_srq_ex, IB_USER_VERBS_CMD_CREATE_XSRQ,
hns_roce_ib_create_srq, hns_roce_ib_create_srq_resp);

DECLARE_DRV_CMD(hns_roce_create_ah, IB_USER_VERBS_CMD_CREATE_AH, empty,
hns_roce_ib_create_ah_resp);

#endif /* _HNS_ROCE_U_ABI_H */
10 changes: 7 additions & 3 deletions providers/hns/hns_roce_u_verbs.c
Expand Up @@ -1448,7 +1448,7 @@ static int get_tclass(struct ibv_context *context, struct ibv_ah_attr *attr,
struct ibv_ah *hns_roce_u_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
{
struct hns_roce_device *hr_dev = to_hr_dev(pd->context->device);
struct ib_uverbs_create_ah_resp resp = {};
struct hns_roce_create_ah_resp resp = {};
struct hns_roce_ah *ah;

/* HIP08 don't support create ah */
Expand Down Expand Up @@ -1476,10 +1476,14 @@ struct ibv_ah *hns_roce_u_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
memcpy(ah->av.dgid, attr->grh.dgid.raw, ARRAY_SIZE(ah->av.dgid));
}

if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp, sizeof(resp)))
if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp.ibv_resp,
sizeof(resp)))
goto err;

if (ibv_resolve_eth_l2_from_gid(pd->context, attr, ah->av.mac, NULL))
if (memcmp(ah->av.mac, resp.dmac, ETH_ALEN))
memcpy(ah->av.mac, resp.dmac, ETH_ALEN);
else if (ibv_resolve_eth_l2_from_gid(pd->context, attr,
ah->av.mac, NULL))
goto err;

ah->av.udp_sport = get_ah_udp_sport(attr);
Expand Down

0 comments on commit bf49669

Please sign in to comment.