Skip to content

Commit

Permalink
Merge pull request #1411 from hginjgerx/bugfix
Browse files Browse the repository at this point in the history
Bugfixes and improvements for libhns
  • Loading branch information
rleon committed Dec 17, 2023
2 parents 482b7fb + 886cf76 commit 9016f34
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 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 */
31 changes: 17 additions & 14 deletions providers/hns/hns_roce_u_hw_v2.c
Expand Up @@ -362,7 +362,7 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,

static int hns_roce_flush_cqe(struct hns_roce_qp *hr_qp, uint8_t status)
{
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int attr_mask;

if (status != HNS_ROCE_V2_CQE_WR_FLUSH_ERR) {
Expand Down Expand Up @@ -1260,8 +1260,8 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
struct hns_roce_qp *qp = to_hr_qp(ibvqp);
struct hns_roce_sge_info sge_info = {};
struct hns_roce_rc_sq_wqe *wqe;
struct ibv_qp_attr attr = {};
unsigned int wqe_idx, nreq;
struct ibv_qp_attr attr;
int ret;

ret = check_qp_send(ibvqp);
Expand Down Expand Up @@ -1411,7 +1411,7 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
struct hns_roce_context *ctx = to_hr_ctx(ibvqp->context);
struct hns_roce_qp *qp = to_hr_qp(ibvqp);
unsigned int wqe_idx, nreq, max_sge;
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int ret;

ret = check_qp_recv(ibvqp);
Expand Down Expand Up @@ -1467,20 +1467,21 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
static void __hns_roce_v2_cq_clean(struct hns_roce_cq *cq, uint32_t qpn,
struct hns_roce_srq *srq)
{
int nfreed = 0;
bool is_recv_cqe;
uint8_t owner_bit;
uint16_t wqe_index;
uint32_t prod_index;
struct hns_roce_v2_cqe *cqe, *dest;
struct hns_roce_context *ctx = to_hr_ctx(cq->verbs_cq.cq.context);
uint64_t cons_index = cq->cons_index;
uint64_t prod_index = cq->cons_index;
struct hns_roce_v2_cqe *cqe, *dest;
uint16_t wqe_index;
uint8_t owner_bit;
bool is_recv_cqe;
int nfreed = 0;

for (prod_index = cq->cons_index; get_sw_cqe_v2(cq, prod_index);
++prod_index)
if (prod_index > cq->cons_index + cq->verbs_cq.cq.cqe)
for (; get_sw_cqe_v2(cq, prod_index); ++prod_index)
if (prod_index > cons_index + cq->verbs_cq.cq.cqe)
break;

while ((int) --prod_index - (int) cq->cons_index >= 0) {
while (prod_index - cons_index > 0) {
prod_index--;
cqe = get_cqe_v2(cq, prod_index & cq->verbs_cq.cq.cqe);
if (hr_reg_read(cqe, CQE_LCL_QPN) == qpn) {
is_recv_cqe = hr_reg_read(cqe, CQE_S_R);
Expand Down Expand Up @@ -1551,6 +1552,8 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd));

if (flag) {
if (!ret)
qp->state = IBV_QPS_ERR;
pthread_spin_unlock(&hr_qp->rq.lock);
pthread_spin_unlock(&hr_qp->sq.lock);
}
Expand Down Expand Up @@ -2551,7 +2554,7 @@ static int wr_complete(struct ibv_qp_ex *ibv_qp)
struct hns_roce_context *ctx = to_hr_ctx(ibv_qp->qp_base.context);
struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base);
unsigned int nreq = qp->sq.head - qp->rb_sq_head;
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int err = qp->err;

if (err) {
Expand Down
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 9016f34

Please sign in to comment.