Skip to content

Commit 86188a8

Browse files
Yixian Liudledford
authored andcommitted
RDMA/hns: Support cq record doorbell for kernel space
This patch updates to support cq record doorbell for the kernel space. Signed-off-by: Yixian Liu <[email protected]> Signed-off-by: Lijun Ou <[email protected]> Signed-off-by: Wei Hu (Xavier) <[email protected]> Signed-off-by: Shaobo Xu <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 472bc0f commit 86188a8

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

drivers/infiniband/hw/hns/hns_roce_cq.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,21 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
358358
/* Get user space parameters */
359359
uar = &to_hr_ucontext(context)->uar;
360360
} else {
361+
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) {
362+
ret = hns_roce_alloc_db(hr_dev, &hr_cq->db, 1);
363+
if (ret)
364+
goto err_cq;
365+
366+
hr_cq->set_ci_db = hr_cq->db.db_record;
367+
*hr_cq->set_ci_db = 0;
368+
}
369+
361370
/* Init mmt table and write buff address to mtt table */
362371
ret = hns_roce_ib_alloc_cq_buf(hr_dev, &hr_cq->hr_buf,
363372
cq_entries);
364373
if (ret) {
365374
dev_err(dev, "Failed to alloc_cq_buf.\n");
366-
goto err_cq;
375+
goto err_db;
367376
}
368377

369378
uar = &hr_dev->priv_uar;
@@ -436,6 +445,10 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
436445
hns_roce_ib_free_cq_buf(hr_dev, &hr_cq->hr_buf,
437446
hr_cq->ib_cq.cqe);
438447

448+
err_db:
449+
if (!context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB))
450+
hns_roce_free_db(hr_dev, &hr_cq->db);
451+
439452
err_cq:
440453
kfree(hr_cq);
441454
return ERR_PTR(ret);
@@ -465,6 +478,8 @@ int hns_roce_ib_destroy_cq(struct ib_cq *ib_cq)
465478
/* Free the buff of stored cq */
466479
hns_roce_ib_free_cq_buf(hr_dev, &hr_cq->hr_buf,
467480
ib_cq->cqe);
481+
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)
482+
hns_roce_free_db(hr_dev, &hr_cq->db);
468483
}
469484

470485
kfree(hr_cq);

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ struct hns_roce_cq {
395395
struct hns_roce_uar *uar;
396396
u32 cq_depth;
397397
u32 cons_index;
398+
u32 *set_ci_db;
398399
void __iomem *cq_db_l;
399400
u16 *tptr_addr;
400401
int arm_sn;

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,24 +1497,7 @@ static struct hns_roce_v2_cqe *next_cqe_sw_v2(struct hns_roce_cq *hr_cq)
14971497

14981498
static void hns_roce_v2_cq_set_ci(struct hns_roce_cq *hr_cq, u32 cons_index)
14991499
{
1500-
struct hns_roce_v2_cq_db cq_db;
1501-
1502-
cq_db.byte_4 = 0;
1503-
cq_db.parameter = 0;
1504-
1505-
roce_set_field(cq_db.byte_4, V2_CQ_DB_BYTE_4_TAG_M,
1506-
V2_CQ_DB_BYTE_4_TAG_S, hr_cq->cqn);
1507-
roce_set_field(cq_db.byte_4, V2_CQ_DB_BYTE_4_CMD_M,
1508-
V2_CQ_DB_BYTE_4_CMD_S, HNS_ROCE_V2_CQ_DB_PTR);
1509-
1510-
roce_set_field(cq_db.parameter, V2_CQ_DB_PARAMETER_CONS_IDX_M,
1511-
V2_CQ_DB_PARAMETER_CONS_IDX_S,
1512-
cons_index & ((hr_cq->cq_depth << 1) - 1));
1513-
roce_set_field(cq_db.parameter, V2_CQ_DB_PARAMETER_CMD_SN_M,
1514-
V2_CQ_DB_PARAMETER_CMD_SN_S, 1);
1515-
1516-
hns_roce_write64_k((__be32 *)&cq_db, hr_cq->cq_db_l);
1517-
1500+
*hr_cq->set_ci_db = cons_index & 0xffffff;
15181501
}
15191502

15201503
static void __hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn,

0 commit comments

Comments
 (0)