Skip to content

Commit 2929c40

Browse files
wangxi11jgunthorpe
authored andcommitted
RDMA/hns: Remove unused MTT functions
The MTT (Memory Translate Table) interface is no longer used to configure the buffer address to BT (Base Address Table) that requires driver mapping. Because the MTT is not compatible with multi-hop addressing of the hip08, it is replaced by MTR (Memory Translate Region) interface, and all the MTT functions should be removed. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Xi Wang <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 9b2cf76 commit 2929c40

File tree

6 files changed

+2
-807
lines changed

6 files changed

+2
-807
lines changed

drivers/infiniband/hw/hns/hns_roce_alloc.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -283,49 +283,6 @@ int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
283283
return total;
284284
}
285285

286-
void hns_roce_init_buf_region(struct hns_roce_buf_region *region, int hopnum,
287-
int offset, int buf_cnt)
288-
{
289-
if (hopnum == HNS_ROCE_HOP_NUM_0)
290-
region->hopnum = 0;
291-
else
292-
region->hopnum = hopnum;
293-
294-
region->offset = offset;
295-
region->count = buf_cnt;
296-
}
297-
298-
void hns_roce_free_buf_list(dma_addr_t **bufs, int region_cnt)
299-
{
300-
int i;
301-
302-
for (i = 0; i < region_cnt; i++) {
303-
kfree(bufs[i]);
304-
bufs[i] = NULL;
305-
}
306-
}
307-
308-
int hns_roce_alloc_buf_list(struct hns_roce_buf_region *regions,
309-
dma_addr_t **bufs, int region_cnt)
310-
{
311-
struct hns_roce_buf_region *r;
312-
int i;
313-
314-
for (i = 0; i < region_cnt; i++) {
315-
r = &regions[i];
316-
bufs[i] = kcalloc(r->count, sizeof(dma_addr_t), GFP_KERNEL);
317-
if (!bufs[i])
318-
goto err_alloc;
319-
}
320-
321-
return 0;
322-
323-
err_alloc:
324-
hns_roce_free_buf_list(bufs, i);
325-
326-
return -ENOMEM;
327-
}
328-
329286
void hns_roce_cleanup_bitmap(struct hns_roce_dev *hr_dev)
330287
{
331288
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ)

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,6 @@ enum {
222222
HNS_ROCE_CAP_FLAG_ATOMIC = BIT(10),
223223
};
224224

225-
enum hns_roce_mtt_type {
226-
MTT_TYPE_WQE,
227-
MTT_TYPE_CQE,
228-
MTT_TYPE_SRQWQE,
229-
MTT_TYPE_IDX
230-
};
231-
232225
#define HNS_ROCE_DB_TYPE_COUNT 2
233226
#define HNS_ROCE_DB_UNIT_SIZE 4
234227

@@ -267,8 +260,6 @@ enum {
267260
#define HNS_ROCE_PORT_DOWN 0
268261
#define HNS_ROCE_PORT_UP 1
269262

270-
#define HNS_ROCE_MTT_ENTRY_PER_SEG 8
271-
272263
#define PAGE_ADDR_SHIFT 12
273264

274265
/* The minimum page count for hardware access page directly. */
@@ -303,22 +294,6 @@ struct hns_roce_bitmap {
303294
unsigned long *table;
304295
};
305296

306-
/* Order bitmap length -- bit num compute formula: 1 << (max_order - order) */
307-
/* Order = 0: bitmap is biggest, order = max bitmap is least (only a bit) */
308-
/* Every bit repesent to a partner free/used status in bitmap */
309-
/*
310-
* Initial, bits of other bitmap are all 0 except that a bit of max_order is 1
311-
* Bit = 1 represent to idle and available; bit = 0: not available
312-
*/
313-
struct hns_roce_buddy {
314-
/* Members point to every order level bitmap */
315-
unsigned long **bits;
316-
/* Represent to avail bits of the order level bitmap */
317-
u32 *num_free;
318-
int max_order;
319-
spinlock_t lock;
320-
};
321-
322297
/* For Hardware Entry Memory */
323298
struct hns_roce_hem_table {
324299
/* HEM type: 0 = qpc, 1 = mtt, 2 = cqc, 3 = srq, 4 = other */
@@ -339,13 +314,6 @@ struct hns_roce_hem_table {
339314
dma_addr_t *bt_l0_dma_addr;
340315
};
341316

342-
struct hns_roce_mtt {
343-
unsigned long first_seg;
344-
int order;
345-
int page_shift;
346-
enum hns_roce_mtt_type mtt_type;
347-
};
348-
349317
struct hns_roce_buf_region {
350318
int offset; /* page offset */
351319
u32 count; /* page count */
@@ -418,15 +386,7 @@ struct hns_roce_mr {
418386

419387
struct hns_roce_mr_table {
420388
struct hns_roce_bitmap mtpt_bitmap;
421-
struct hns_roce_buddy mtt_buddy;
422-
struct hns_roce_hem_table mtt_table;
423389
struct hns_roce_hem_table mtpt_table;
424-
struct hns_roce_buddy mtt_cqe_buddy;
425-
struct hns_roce_hem_table mtt_cqe_table;
426-
struct hns_roce_buddy mtt_srqwqe_buddy;
427-
struct hns_roce_hem_table mtt_srqwqe_table;
428-
struct hns_roce_buddy mtt_idx_buddy;
429-
struct hns_roce_hem_table mtt_idx_table;
430390
};
431391

432392
struct hns_roce_wq {
@@ -1141,21 +1101,6 @@ void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status,
11411101
int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev);
11421102
void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev);
11431103

1144-
int hns_roce_mtt_init(struct hns_roce_dev *hr_dev, int npages, int page_shift,
1145-
struct hns_roce_mtt *mtt);
1146-
void hns_roce_mtt_cleanup(struct hns_roce_dev *hr_dev,
1147-
struct hns_roce_mtt *mtt);
1148-
int hns_roce_buf_write_mtt(struct hns_roce_dev *hr_dev,
1149-
struct hns_roce_mtt *mtt, struct hns_roce_buf *buf);
1150-
1151-
void hns_roce_mtr_init(struct hns_roce_mtr *mtr, int bt_pg_shift,
1152-
int buf_pg_shift);
1153-
int hns_roce_mtr_attach(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
1154-
dma_addr_t **bufs, struct hns_roce_buf_region *regions,
1155-
int region_cnt);
1156-
void hns_roce_mtr_cleanup(struct hns_roce_dev *hr_dev,
1157-
struct hns_roce_mtr *mtr);
1158-
11591104
/* hns roce hw need current block and next block addr from mtt */
11601105
#define MTT_MIN_COUNT 2
11611106
int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
@@ -1228,15 +1173,6 @@ void hns_roce_buf_free(struct hns_roce_dev *hr_dev, struct hns_roce_buf *buf);
12281173
int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
12291174
struct hns_roce_buf *buf, u32 page_shift);
12301175

1231-
int hns_roce_ib_umem_write_mtt(struct hns_roce_dev *hr_dev,
1232-
struct hns_roce_mtt *mtt, struct ib_umem *umem);
1233-
1234-
void hns_roce_init_buf_region(struct hns_roce_buf_region *region, int hopnum,
1235-
int offset, int buf_cnt);
1236-
int hns_roce_alloc_buf_list(struct hns_roce_buf_region *regions,
1237-
dma_addr_t **bufs, int count);
1238-
void hns_roce_free_buf_list(dma_addr_t **bufs, int count);
1239-
12401176
int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
12411177
int buf_cnt, int start, struct hns_roce_buf *buf);
12421178
int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ bool hns_roce_check_whether_mhop(struct hns_roce_dev *hr_dev, u32 type)
7575
case HEM_TYPE_CQC_TIMER:
7676
hop_num = hr_dev->caps.cqc_timer_hop_num;
7777
break;
78-
case HEM_TYPE_CQE:
79-
hop_num = hr_dev->caps.cqe_hop_num;
80-
break;
81-
case HEM_TYPE_MTT:
82-
hop_num = hr_dev->caps.mtt_hop_num;
83-
break;
84-
case HEM_TYPE_SRQWQE:
85-
hop_num = hr_dev->caps.srqwqe_hop_num;
86-
break;
87-
case HEM_TYPE_IDX:
88-
hop_num = hr_dev->caps.idx_hop_num;
89-
break;
9078
default:
9179
return false;
9280
}
@@ -195,38 +183,6 @@ static int get_hem_table_config(struct hns_roce_dev *hr_dev,
195183
mhop->ba_l0_num = hr_dev->caps.srqc_bt_num;
196184
mhop->hop_num = hr_dev->caps.srqc_hop_num;
197185
break;
198-
case HEM_TYPE_MTT:
199-
mhop->buf_chunk_size = 1 << (hr_dev->caps.mtt_buf_pg_sz
200-
+ PAGE_SHIFT);
201-
mhop->bt_chunk_size = 1 << (hr_dev->caps.mtt_ba_pg_sz
202-
+ PAGE_SHIFT);
203-
mhop->ba_l0_num = mhop->bt_chunk_size / BA_BYTE_LEN;
204-
mhop->hop_num = hr_dev->caps.mtt_hop_num;
205-
break;
206-
case HEM_TYPE_CQE:
207-
mhop->buf_chunk_size = 1 << (hr_dev->caps.cqe_buf_pg_sz
208-
+ PAGE_SHIFT);
209-
mhop->bt_chunk_size = 1 << (hr_dev->caps.cqe_ba_pg_sz
210-
+ PAGE_SHIFT);
211-
mhop->ba_l0_num = mhop->bt_chunk_size / BA_BYTE_LEN;
212-
mhop->hop_num = hr_dev->caps.cqe_hop_num;
213-
break;
214-
case HEM_TYPE_SRQWQE:
215-
mhop->buf_chunk_size = 1 << (hr_dev->caps.srqwqe_buf_pg_sz
216-
+ PAGE_SHIFT);
217-
mhop->bt_chunk_size = 1 << (hr_dev->caps.srqwqe_ba_pg_sz
218-
+ PAGE_SHIFT);
219-
mhop->ba_l0_num = mhop->bt_chunk_size / BA_BYTE_LEN;
220-
mhop->hop_num = hr_dev->caps.srqwqe_hop_num;
221-
break;
222-
case HEM_TYPE_IDX:
223-
mhop->buf_chunk_size = 1 << (hr_dev->caps.idx_buf_pg_sz
224-
+ PAGE_SHIFT);
225-
mhop->bt_chunk_size = 1 << (hr_dev->caps.idx_ba_pg_sz
226-
+ PAGE_SHIFT);
227-
mhop->ba_l0_num = mhop->bt_chunk_size / BA_BYTE_LEN;
228-
mhop->hop_num = hr_dev->caps.idx_hop_num;
229-
break;
230186
default:
231187
dev_err(dev, "Table %d not support multi-hop addressing!\n",
232188
type);
@@ -899,57 +855,6 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
899855
return addr;
900856
}
901857

902-
int hns_roce_table_get_range(struct hns_roce_dev *hr_dev,
903-
struct hns_roce_hem_table *table,
904-
unsigned long start, unsigned long end)
905-
{
906-
struct hns_roce_hem_mhop mhop;
907-
unsigned long inc = table->table_chunk_size / table->obj_size;
908-
unsigned long i = 0;
909-
int ret;
910-
911-
if (hns_roce_check_whether_mhop(hr_dev, table->type)) {
912-
ret = hns_roce_calc_hem_mhop(hr_dev, table, NULL, &mhop);
913-
if (ret)
914-
goto fail;
915-
inc = mhop.bt_chunk_size / table->obj_size;
916-
}
917-
918-
/* Allocate MTT entry memory according to chunk(128K) */
919-
for (i = start; i <= end; i += inc) {
920-
ret = hns_roce_table_get(hr_dev, table, i);
921-
if (ret)
922-
goto fail;
923-
}
924-
925-
return 0;
926-
927-
fail:
928-
while (i > start) {
929-
i -= inc;
930-
hns_roce_table_put(hr_dev, table, i);
931-
}
932-
return ret;
933-
}
934-
935-
void hns_roce_table_put_range(struct hns_roce_dev *hr_dev,
936-
struct hns_roce_hem_table *table,
937-
unsigned long start, unsigned long end)
938-
{
939-
struct hns_roce_hem_mhop mhop;
940-
unsigned long inc = table->table_chunk_size / table->obj_size;
941-
unsigned long i;
942-
943-
if (hns_roce_check_whether_mhop(hr_dev, table->type)) {
944-
if (hns_roce_calc_hem_mhop(hr_dev, table, NULL, &mhop))
945-
return;
946-
inc = mhop.bt_chunk_size / table->obj_size;
947-
}
948-
949-
for (i = start; i <= end; i += inc)
950-
hns_roce_table_put(hr_dev, table, i);
951-
}
952-
953858
int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
954859
struct hns_roce_hem_table *table, u32 type,
955860
unsigned long obj_size, unsigned long nobj,
@@ -1112,12 +1017,6 @@ void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,
11121017

11131018
void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev)
11141019
{
1115-
if ((hr_dev->caps.num_idx_segs))
1116-
hns_roce_cleanup_hem_table(hr_dev,
1117-
&hr_dev->mr_table.mtt_idx_table);
1118-
if (hr_dev->caps.num_srqwqe_segs)
1119-
hns_roce_cleanup_hem_table(hr_dev,
1120-
&hr_dev->mr_table.mtt_srqwqe_table);
11211020
if (hr_dev->caps.srqc_entry_sz)
11221021
hns_roce_cleanup_hem_table(hr_dev,
11231022
&hr_dev->srq_table.table);
@@ -1137,10 +1036,6 @@ void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev)
11371036
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.irrl_table);
11381037
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->qp_table.qp_table);
11391038
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table);
1140-
if (hns_roce_check_whether_mhop(hr_dev, HEM_TYPE_CQE))
1141-
hns_roce_cleanup_hem_table(hr_dev,
1142-
&hr_dev->mr_table.mtt_cqe_table);
1143-
hns_roce_cleanup_hem_table(hr_dev, &hr_dev->mr_table.mtt_table);
11441039
}
11451040

11461041
struct roce_hem_item {

drivers/infiniband/hw/hns/hns_roce_hem.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ void hns_roce_table_put(struct hns_roce_dev *hr_dev,
115115
void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
116116
struct hns_roce_hem_table *table, unsigned long obj,
117117
dma_addr_t *dma_handle);
118-
int hns_roce_table_get_range(struct hns_roce_dev *hr_dev,
119-
struct hns_roce_hem_table *table,
120-
unsigned long start, unsigned long end);
121-
void hns_roce_table_put_range(struct hns_roce_dev *hr_dev,
122-
struct hns_roce_hem_table *table,
123-
unsigned long start, unsigned long end);
124118
int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
125119
struct hns_roce_hem_table *table, u32 type,
126120
unsigned long obj_size, unsigned long nobj,

0 commit comments

Comments
 (0)