提交 d158d713 编写于 作者: Y Yangyang Li 提交者: Zheng Zengkai

RDMA/hns: Use IDA interface to manage srq index

mainline inclusion
from mainline-v5.15-rc1
commit c4f11b36
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4QOTS
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/commit/?id=c4f11b36f817cf76d58a86b2aadcd8e66eda6047

---------------------------------------------------------------------

Switch srq index allocation and release from hns' own bitmap interface to
IDA interface.

Link: https://lore.kernel.org/r/1629336980-17499-3-git-send-email-liangwenpeng@huawei.comSigned-off-by: NYangyang Li <liyangyang20@huawei.com>
Signed-off-by: NWenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
sigend-off-by: NGuofeng Yue <yueguofeng@hisilicon.com>
Reviewed-by: NYixing Liu <liuyixing1@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 bc9c5246
...@@ -256,7 +256,7 @@ void hns_roce_cleanup_bitmap(struct hns_roce_dev *hr_dev) ...@@ -256,7 +256,7 @@ void hns_roce_cleanup_bitmap(struct hns_roce_dev *hr_dev)
ida_destroy(&hr_dev->xrcd_ida.ida); ida_destroy(&hr_dev->xrcd_ida.ida);
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ)
hns_roce_cleanup_srq_table(hr_dev); ida_destroy(&hr_dev->srq_table.srq_ida.ida);
hns_roce_cleanup_qp_table(hr_dev); hns_roce_cleanup_qp_table(hr_dev);
hns_roce_cleanup_cq_table(hr_dev); hns_roce_cleanup_cq_table(hr_dev);
ida_destroy(&hr_dev->mr_table.mtpt_ida.ida); ida_destroy(&hr_dev->mr_table.mtpt_ida.ida);
......
...@@ -494,7 +494,7 @@ struct hns_roce_cq_table { ...@@ -494,7 +494,7 @@ struct hns_roce_cq_table {
}; };
struct hns_roce_srq_table { struct hns_roce_srq_table {
struct hns_roce_bitmap bitmap; struct hns_roce_ida srq_ida;
struct xarray xa; struct xarray xa;
struct hns_roce_hem_table table; struct hns_roce_hem_table table;
}; };
...@@ -1100,13 +1100,12 @@ void hns_roce_init_pd_table(struct hns_roce_dev *hr_dev); ...@@ -1100,13 +1100,12 @@ void hns_roce_init_pd_table(struct hns_roce_dev *hr_dev);
void hns_roce_init_mr_table(struct hns_roce_dev *hr_dev); void hns_roce_init_mr_table(struct hns_roce_dev *hr_dev);
void hns_roce_init_cq_table(struct hns_roce_dev *hr_dev); void hns_roce_init_cq_table(struct hns_roce_dev *hr_dev);
void hns_roce_init_qp_table(struct hns_roce_dev *hr_dev); void hns_roce_init_qp_table(struct hns_roce_dev *hr_dev);
int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev); void hns_roce_init_srq_table(struct hns_roce_dev *hr_dev);
void hns_roce_init_xrcd_table(struct hns_roce_dev *hr_dev); void hns_roce_init_xrcd_table(struct hns_roce_dev *hr_dev);
void hns_roce_cleanup_eq_table(struct hns_roce_dev *hr_dev); void hns_roce_cleanup_eq_table(struct hns_roce_dev *hr_dev);
void hns_roce_cleanup_cq_table(struct hns_roce_dev *hr_dev); void hns_roce_cleanup_cq_table(struct hns_roce_dev *hr_dev);
void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev); void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev);
void hns_roce_cleanup_srq_table(struct hns_roce_dev *hr_dev);
int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj); int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj);
void hns_roce_bitmap_free(struct hns_roce_bitmap *bitmap, unsigned long obj); void hns_roce_bitmap_free(struct hns_roce_bitmap *bitmap, unsigned long obj);
......
...@@ -867,26 +867,11 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) ...@@ -867,26 +867,11 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)
hns_roce_init_qp_table(hr_dev); hns_roce_init_qp_table(hr_dev);
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) { if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) {
ret = hns_roce_init_srq_table(hr_dev); hns_roce_init_srq_table(hr_dev);
if (ret) {
dev_err(dev,
"Failed to init share receive queue table.\n");
goto err_qp_table_free;
}
} }
return 0; return 0;
err_qp_table_free:
hns_roce_cleanup_qp_table(hr_dev);
hns_roce_cleanup_cq_table(hr_dev);
ida_destroy(&hr_dev->mr_table.mtpt_ida.ida);
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_XRC)
ida_destroy(&hr_dev->xrcd_ida.ida);
ida_destroy(&hr_dev->pd_ida.ida);
err_uar_table_free: err_uar_table_free:
ida_destroy(&hr_dev->uar_ida.ida); ida_destroy(&hr_dev->uar_ida.ida);
return ret; return ret;
......
...@@ -80,15 +80,19 @@ static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev, ...@@ -80,15 +80,19 @@ static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev,
static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
{ {
struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; struct hns_roce_srq_table *srq_table = &hr_dev->srq_table;
struct hns_roce_ida *srq_ida = &hr_dev->srq_table.srq_ida;
struct ib_device *ibdev = &hr_dev->ib_dev; struct ib_device *ibdev = &hr_dev->ib_dev;
struct hns_roce_cmd_mailbox *mailbox; struct hns_roce_cmd_mailbox *mailbox;
int ret; int ret;
int id;
ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn); id = ida_alloc_range(&srq_ida->ida, srq_ida->min, srq_ida->max,
if (ret) { GFP_KERNEL);
ibdev_err(ibdev, "failed to alloc SRQ number.\n"); if (id < 0) {
ibdev_err(ibdev, "failed to alloc srq(%d).\n", id);
return -ENOMEM; return -ENOMEM;
} }
srq->srqn = (unsigned long)id;
ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn); ret = hns_roce_table_get(hr_dev, &srq_table->table, srq->srqn);
if (ret) { if (ret) {
...@@ -132,7 +136,7 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) ...@@ -132,7 +136,7 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
err_put: err_put:
hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn);
err_out: err_out:
hns_roce_bitmap_free(&srq_table->bitmap, srq->srqn); ida_free(&srq_ida->ida, id);
return ret; return ret;
} }
...@@ -154,7 +158,7 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) ...@@ -154,7 +158,7 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
wait_for_completion(&srq->free); wait_for_completion(&srq->free);
hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn);
hns_roce_bitmap_free(&srq_table->bitmap, srq->srqn); ida_free(&srq_table->srq_ida.ida, (int)srq->srqn);
} }
static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq,
...@@ -440,18 +444,14 @@ int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -440,18 +444,14 @@ int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
return 0; return 0;
} }
int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev) void hns_roce_init_srq_table(struct hns_roce_dev *hr_dev)
{ {
struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; struct hns_roce_srq_table *srq_table = &hr_dev->srq_table;
struct hns_roce_ida *srq_ida = &srq_table->srq_ida;
xa_init(&srq_table->xa); xa_init(&srq_table->xa);
return hns_roce_bitmap_init(&srq_table->bitmap, hr_dev->caps.num_srqs, ida_init(&srq_ida->ida);
hr_dev->caps.num_srqs - 1, srq_ida->max = hr_dev->caps.num_srqs - 1;
hr_dev->caps.reserved_srqs, 0); srq_ida->min = hr_dev->caps.reserved_srqs;
}
void hns_roce_cleanup_srq_table(struct hns_roce_dev *hr_dev)
{
hns_roce_bitmap_cleanup(&hr_dev->srq_table.bitmap);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册