Skip to content

Commit 707783a

Browse files
Yixian Liujgunthorpe
authored andcommitted
RDMA/hns: Rename the functions used inside creating cq
Current names of functions are not proper, such as hns_roce_free_cq, actually it means free cqc, thus we rename them. Furthermore, functions used inside one file can be named without the prefix hns_roce_ which will make the functions for verbs symbols more eye-catching. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Yixian Liu <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 18a96d2 commit 707783a

File tree

5 files changed

+35
-56
lines changed

5 files changed

+35
-56
lines changed

drivers/infiniband/hw/hns/hns_roce_cmd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ enum {
119119
HNS_ROCE_CMD_DESTROY_MPT = 0xf,
120120

121121
/* CQ commands */
122-
HNS_ROCE_CMD_CREATE_CQ = 0x16,
123-
HNS_ROCE_CMD_DESTROY_CQ = 0x17,
122+
HNS_ROCE_CMD_CREATE_CQC = 0x16,
123+
HNS_ROCE_CMD_DESTROY_CQC = 0x17,
124124

125125
/* QP/EE commands */
126126
HNS_ROCE_CMD_RST2INIT_QP = 0x19,

drivers/infiniband/hw/hns/hns_roce_cq.c

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,8 @@ static void hns_roce_ib_cq_event(struct hns_roce_cq *hr_cq,
7373
}
7474
}
7575

76-
static int hns_roce_hw_create_cq(struct hns_roce_dev *dev,
77-
struct hns_roce_cmd_mailbox *mailbox,
78-
unsigned long cq_num)
79-
{
80-
return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cq_num, 0,
81-
HNS_ROCE_CMD_CREATE_CQ,
82-
HNS_ROCE_CMD_TIMEOUT_MSECS);
83-
}
84-
85-
static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev,
86-
struct hns_roce_cq *hr_cq)
76+
static int hns_roce_alloc_cqc(struct hns_roce_dev *hr_dev,
77+
struct hns_roce_cq *hr_cq)
8778
{
8879
struct hns_roce_cmd_mailbox *mailbox;
8980
struct hns_roce_hem_table *mtt_table;
@@ -140,7 +131,8 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev,
140131
hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle);
141132

142133
/* Send mailbox to hw */
143-
ret = hns_roce_hw_create_cq(hr_dev, mailbox, hr_cq->cqn);
134+
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, 0,
135+
HNS_ROCE_CMD_CREATE_CQC, HNS_ROCE_CMD_TIMEOUT_MSECS);
144136
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
145137
if (ret) {
146138
dev_err(dev,
@@ -168,22 +160,15 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev,
168160
return ret;
169161
}
170162

171-
static int hns_roce_hw_destroy_cq(struct hns_roce_dev *dev,
172-
struct hns_roce_cmd_mailbox *mailbox,
173-
unsigned long cq_num)
174-
{
175-
return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, cq_num,
176-
mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_CQ,
177-
HNS_ROCE_CMD_TIMEOUT_MSECS);
178-
}
179-
180-
void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
163+
void hns_roce_free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
181164
{
182165
struct hns_roce_cq_table *cq_table = &hr_dev->cq_table;
183166
struct device *dev = hr_dev->dev;
184167
int ret;
185168

186-
ret = hns_roce_hw_destroy_cq(hr_dev, NULL, hr_cq->cqn);
169+
ret = hns_roce_cmd_mbox(hr_dev, 0, 0, hr_cq->cqn, 1,
170+
HNS_ROCE_CMD_DESTROY_CQC,
171+
HNS_ROCE_CMD_TIMEOUT_MSECS);
187172
if (ret)
188173
dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret,
189174
hr_cq->cqn);
@@ -202,10 +187,9 @@ void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
202187
hns_roce_bitmap_free(&cq_table->bitmap, hr_cq->cqn, BITMAP_NO_RR);
203188
}
204189

205-
static int hns_roce_ib_get_cq_umem(struct hns_roce_dev *hr_dev,
206-
struct hns_roce_cq *hr_cq,
207-
struct hns_roce_ib_create_cq ucmd,
208-
struct ib_udata *udata)
190+
static int get_cq_umem(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq,
191+
struct hns_roce_ib_create_cq ucmd,
192+
struct ib_udata *udata)
209193
{
210194
struct hns_roce_buf *buf = &hr_cq->buf;
211195
struct hns_roce_mtt *mtt = &hr_cq->mtt;
@@ -243,8 +227,7 @@ static int hns_roce_ib_get_cq_umem(struct hns_roce_dev *hr_dev,
243227
return ret;
244228
}
245229

246-
static int hns_roce_ib_alloc_cq_buf(struct hns_roce_dev *hr_dev,
247-
struct hns_roce_cq *hr_cq)
230+
static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
248231
{
249232
struct hns_roce_buf *buf = &hr_cq->buf;
250233
struct hns_roce_mtt *mtt = &hr_cq->mtt;
@@ -280,8 +263,7 @@ static int hns_roce_ib_alloc_cq_buf(struct hns_roce_dev *hr_dev,
280263
return ret;
281264
}
282265

283-
static void hns_roce_ib_free_cq_buf(struct hns_roce_dev *hr_dev,
284-
struct hns_roce_cq *hr_cq)
266+
static void free_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
285267
{
286268
hns_roce_buf_free(hr_dev, hr_cq->buf.size, &hr_cq->buf);
287269
}
@@ -303,7 +285,7 @@ static int create_user_cq(struct hns_roce_dev *hr_dev,
303285
}
304286

305287
/* Get user space address, write it into mtt table */
306-
ret = hns_roce_ib_get_cq_umem(hr_dev, hr_cq, ucmd, udata);
288+
ret = get_cq_umem(hr_dev, hr_cq, ucmd, udata);
307289
if (ret) {
308290
dev_err(dev, "Failed to get_cq_umem.\n");
309291
return ret;
@@ -347,7 +329,7 @@ static int create_kernel_cq(struct hns_roce_dev *hr_dev,
347329
}
348330

349331
/* Init mtt table and write buff address to mtt table */
350-
ret = hns_roce_ib_alloc_cq_buf(hr_dev, hr_cq);
332+
ret = alloc_cq_buf(hr_dev, hr_cq);
351333
if (ret) {
352334
dev_err(dev, "Failed to alloc_cq_buf.\n");
353335
goto err_db;
@@ -385,15 +367,14 @@ static void destroy_kernel_cq(struct hns_roce_dev *hr_dev,
385367
struct hns_roce_cq *hr_cq)
386368
{
387369
hns_roce_mtt_cleanup(hr_dev, &hr_cq->mtt);
388-
hns_roce_ib_free_cq_buf(hr_dev, hr_cq);
370+
free_cq_buf(hr_dev, hr_cq);
389371

390372
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)
391373
hns_roce_free_db(hr_dev, &hr_cq->db);
392374
}
393375

394-
int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
395-
const struct ib_cq_init_attr *attr,
396-
struct ib_udata *udata)
376+
int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
377+
struct ib_udata *udata)
397378
{
398379
struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device);
399380
struct hns_roce_ib_create_cq_resp resp = {};
@@ -438,8 +419,7 @@ int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
438419
}
439420
}
440421

441-
/* Allocate cq index, fill cq_context */
442-
ret = hns_roce_cq_alloc(hr_dev, hr_cq);
422+
ret = hns_roce_alloc_cqc(hr_dev, hr_cq);
443423
if (ret) {
444424
dev_err(dev, "Alloc CQ failed(%d).\n", ret);
445425
goto err_dbmap;
@@ -468,7 +448,7 @@ int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
468448
return 0;
469449

470450
err_cqc:
471-
hns_roce_free_cq(hr_dev, hr_cq);
451+
hns_roce_free_cqc(hr_dev, hr_cq);
472452

473453
err_dbmap:
474454
if (udata)
@@ -480,7 +460,7 @@ int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
480460
return ret;
481461
}
482462

483-
void hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
463+
void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
484464
{
485465
struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device);
486466
struct hns_roce_cq *hr_cq = to_hr_cq(ib_cq);
@@ -490,7 +470,7 @@ void hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
490470
return;
491471
}
492472

493-
hns_roce_free_cq(hr_dev, hr_cq);
473+
hns_roce_free_cqc(hr_dev, hr_cq);
494474
hns_roce_mtt_cleanup(hr_dev, &hr_cq->mtt);
495475

496476
ib_umem_release(hr_cq->umem);
@@ -503,7 +483,7 @@ void hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
503483
&hr_cq->db);
504484
} else {
505485
/* Free the buff of stored cq */
506-
hns_roce_ib_free_cq_buf(hr_dev, hr_cq);
486+
free_cq_buf(hr_dev, hr_cq);
507487
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)
508488
hns_roce_free_db(hr_dev, &hr_cq->db);
509489
}

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,12 +1240,11 @@ void hns_roce_release_range_qp(struct hns_roce_dev *hr_dev, int base_qpn,
12401240
__be32 send_ieth(const struct ib_send_wr *wr);
12411241
int to_hr_qp_type(int qp_type);
12421242

1243-
int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
1244-
const struct ib_cq_init_attr *attr,
1245-
struct ib_udata *udata);
1243+
int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
1244+
struct ib_udata *udata);
12461245

1247-
void hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
1248-
void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq);
1246+
void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
1247+
void hns_roce_free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq);
12491248

12501249
int hns_roce_db_map_user(struct hns_roce_ucontext *context,
12511250
struct ib_udata *udata, unsigned long virt,

drivers/infiniband/hw/hns/hns_roce_hw_v1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
732732
if (!cq)
733733
return -ENOMEM;
734734

735-
ret = hns_roce_ib_create_cq(cq, &cq_init_attr, NULL);
735+
ret = hns_roce_create_cq(cq, &cq_init_attr, NULL);
736736
if (ret) {
737737
dev_err(dev, "Create cq for reserved loop qp failed!");
738738
goto alloc_cq_failed;
@@ -868,7 +868,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
868868
kfree(pd);
869869

870870
alloc_mem_failed:
871-
hns_roce_ib_destroy_cq(cq, NULL);
871+
hns_roce_destroy_cq(cq, NULL);
872872
alloc_cq_failed:
873873
kfree(cq);
874874
return ret;
@@ -897,7 +897,7 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev)
897897
i, ret);
898898
}
899899

900-
hns_roce_ib_destroy_cq(&free_mr->mr_free_cq->ib_cq, NULL);
900+
hns_roce_destroy_cq(&free_mr->mr_free_cq->ib_cq, NULL);
901901
kfree(&free_mr->mr_free_cq->ib_cq);
902902
hns_roce_dealloc_pd(&free_mr->mr_free_pd->ibpd, NULL);
903903
kfree(&free_mr->mr_free_pd->ibpd);
@@ -3656,7 +3656,7 @@ static void hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
36563656
u32 cqe_cnt_cur;
36573657
int wait_time = 0;
36583658

3659-
hns_roce_free_cq(hr_dev, hr_cq);
3659+
hns_roce_free_cqc(hr_dev, hr_cq);
36603660

36613661
/*
36623662
* Before freeing cq buffer, we need to ensure that the outstanding CQE

drivers/infiniband/hw/hns/hns_roce_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,14 @@ static const struct ib_device_ops hns_roce_dev_ops = {
419419
.alloc_pd = hns_roce_alloc_pd,
420420
.alloc_ucontext = hns_roce_alloc_ucontext,
421421
.create_ah = hns_roce_create_ah,
422-
.create_cq = hns_roce_ib_create_cq,
422+
.create_cq = hns_roce_create_cq,
423423
.create_qp = hns_roce_create_qp,
424424
.dealloc_pd = hns_roce_dealloc_pd,
425425
.dealloc_ucontext = hns_roce_dealloc_ucontext,
426426
.del_gid = hns_roce_del_gid,
427427
.dereg_mr = hns_roce_dereg_mr,
428428
.destroy_ah = hns_roce_destroy_ah,
429-
.destroy_cq = hns_roce_ib_destroy_cq,
429+
.destroy_cq = hns_roce_destroy_cq,
430430
.disassociate_ucontext = hns_roce_disassociate_ucontext,
431431
.fill_res_entry = hns_roce_fill_res_entry,
432432
.get_dma_mr = hns_roce_get_dma_mr,

0 commit comments

Comments
 (0)