Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libhns: Cleanup and Bugfixes #1579

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions providers/hns/hns_roce_u.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ struct hns_roce_wq {
unsigned long *wrid;
struct hns_roce_spinlock hr_lock;
unsigned int wqe_cnt;
int max_post;
unsigned int max_post;
unsigned int head;
unsigned int tail;
unsigned int max_gs;
Expand Down Expand Up @@ -335,7 +335,7 @@ struct hns_roce_sge_ex {
struct hns_roce_qp {
struct verbs_qp verbs_qp;
struct hns_roce_buf buf;
int max_inline_data;
unsigned int max_inline_data;
int buf_size;
unsigned int sq_signal_bits;
struct hns_roce_wq sq;
Expand Down
15 changes: 8 additions & 7 deletions providers/hns/hns_roce_u_hw_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static enum ibv_wc_status get_wc_status(uint8_t status)
{ HNS_ROCE_V2_CQE_XRC_VIOLATION_ERR, IBV_WC_REM_INV_RD_REQ_ERR },
};

for (int i = 0; i < ARRAY_SIZE(map); i++) {
for (unsigned int i = 0; i < ARRAY_SIZE(map); i++) {
if (status == map[i].cqe_status)
return map[i].wc_status;
}
Expand Down Expand Up @@ -896,7 +896,7 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp,
unsigned int sge_mask = qp->ex_sge.sge_cnt - 1;
void *dst_addr, *src_addr, *tail_bound_addr;
uint32_t src_len, tail_len;
int i;
uint32_t i;

if (sge_info->total_len > qp->sq.ext_sge_cnt * HNS_ROCE_SGE_SIZE)
return EINVAL;
Expand Down Expand Up @@ -966,7 +966,7 @@ static void fill_ud_inn_inl_data(const struct ibv_send_wr *wr,

static bool check_inl_data_len(struct hns_roce_qp *qp, unsigned int len)
{
int mtu = mtu_enum_to_int(qp->path_mtu);
unsigned int mtu = mtu_enum_to_int(qp->path_mtu);

return (len <= qp->max_inline_data && len <= mtu);
}
Expand Down Expand Up @@ -1370,7 +1370,8 @@ static void fill_recv_sge_to_wqe(struct ibv_recv_wr *wr, void *wqe,
unsigned int max_sge, bool rsv)
{
struct hns_roce_v2_wqe_data_seg *dseg = wqe;
unsigned int i, cnt;
unsigned int cnt;
int i;

for (i = 0, cnt = 0; i < wr->num_sge; i++) {
/* Skip zero-length sge */
Expand Down Expand Up @@ -1398,7 +1399,7 @@ static void fill_recv_inl_buf(struct hns_roce_rinl_buf *rinl_buf,
unsigned int wqe_idx, struct ibv_recv_wr *wr)
{
struct ibv_sge *sge_list;
unsigned int i;
int i;

if (!rinl_buf->wqe_cnt)
return;
Expand Down Expand Up @@ -1712,7 +1713,7 @@ static int check_post_srq_valid(struct hns_roce_srq *srq,
static int get_wqe_idx(struct hns_roce_srq *srq, unsigned int *wqe_idx)
{
struct hns_roce_idx_que *idx_que = &srq->idx_que;
int bit_num;
unsigned int bit_num;
int i;

/* bitmap[i] is set zero if all bits are allocated */
Expand Down Expand Up @@ -2071,7 +2072,7 @@ static void set_sgl_rc(struct hns_roce_v2_wqe_data_seg *dseg,
unsigned int mask = qp->ex_sge.sge_cnt - 1;
unsigned int msg_len = 0;
unsigned int cnt = 0;
int i;
unsigned int i;

for (i = 0; i < num_sge; i++) {
if (!sge[i].length)
Expand Down
20 changes: 14 additions & 6 deletions providers/hns/hns_roce_u_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static int verify_cq_create_attr(struct ibv_cq_init_attr_ex *attr,
{
struct hns_roce_pad *pad = to_hr_pad(attr->parent_domain);

if (!attr->cqe || attr->cqe > context->max_cqe) {
if (!attr->cqe || attr->cqe > (uint32_t)context->max_cqe) {
verbs_err(&context->ibv_ctx, "unsupported cq depth %u.\n",
attr->cqe);
return EINVAL;
Expand Down Expand Up @@ -984,7 +984,7 @@ static int check_hnsdv_qp_attr(struct hns_roce_context *ctx,
return 0;

if (!check_comp_mask(hns_attr->comp_mask, HNSDV_QP_SUP_COMP_MASK)) {
verbs_err(&ctx->ibv_ctx, "invalid hnsdv comp_mask 0x%x.\n",
verbs_err(&ctx->ibv_ctx, "invalid hnsdv comp_mask 0x%llx.\n",
hns_attr->comp_mask);
return EINVAL;
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ static int alloc_recv_rinl_buf(uint32_t max_sge,
struct hns_roce_rinl_buf *rinl_buf)
{
unsigned int cnt;
int i;
unsigned int i;

cnt = rinl_buf->wqe_cnt;
rinl_buf->wqe_list = calloc(cnt, sizeof(struct hns_roce_rinl_wqe));
Expand Down Expand Up @@ -1291,6 +1291,16 @@ static unsigned int get_sge_num_from_max_inl_data(bool is_ud,
return inline_sge;
}

static uint32_t get_max_inline_data(struct hns_roce_context *ctx,
struct ibv_qp_cap *cap)
{
if (cap->max_inline_data)
return min_t(uint32_t, roundup_pow_of_two(cap->max_inline_data),
ctx->max_inline_data);

return 0;
}

static void set_ext_sge_param(struct hns_roce_context *ctx,
struct ibv_qp_init_attr_ex *attr,
struct hns_roce_qp *qp, unsigned int wr_cnt)
Expand All @@ -1307,9 +1317,7 @@ static void set_ext_sge_param(struct hns_roce_context *ctx,
attr->cap.max_send_sge);

if (ctx->config & HNS_ROCE_RSP_EXSGE_FLAGS) {
attr->cap.max_inline_data = min_t(uint32_t, roundup_pow_of_two(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use min3() instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use min3() instead.

Sorry I don't get it. Only two values ​​are compared here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min3(attr->cap.max_inline_data, roundup_pow_of_two(attr->cap.max_inline_data), ctx->max_inline_data)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min3(attr->cap.max_inline_data, roundup_pow_of_two(attr->cap.max_inline_data), ctx->max_inline_data)

This is wrong when attr->cap.max_inline_data is not power of 2

attr->cap.max_inline_data),
ctx->max_inline_data);
attr->cap.max_inline_data = get_max_inline_data(ctx, &attr->cap);

inline_ext_sge = max(ext_wqe_sge_cnt,
get_sge_num_from_max_inl_data(is_ud,
Expand Down