hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/hw/hns/hns_roce_device.h
....@@ -37,16 +37,16 @@
3737
3838 #define DRV_NAME "hns_roce"
3939
40
+#define PCI_REVISION_ID_HIP08 0x21
41
+#define PCI_REVISION_ID_HIP09 0x30
42
+
4043 #define HNS_ROCE_HW_VER1 ('h' << 24 | 'i' << 16 | '0' << 8 | '6')
4144
42
-#define MAC_ADDR_OCTET_NUM 6
4345 #define HNS_ROCE_MAX_MSG_LEN 0x80000000
44
-
45
-#define HNS_ROCE_ALOGN_UP(a, b) ((((a) + (b) - 1) / (b)) * (b))
4646
4747 #define HNS_ROCE_IB_MIN_SQ_STRIDE 6
4848
49
-#define HNS_ROCE_BA_SIZE (32 * 4096)
49
+#define BA_BYTE_LEN 8
5050
5151 /* Hardware specification only for v1 engine */
5252 #define HNS_ROCE_MIN_CQE_NUM 0x40
....@@ -64,23 +64,29 @@
6464
6565 #define HNS_ROCE_MAX_IRQ_NUM 128
6666
67
+#define HNS_ROCE_SGE_IN_WQE 2
68
+#define HNS_ROCE_SGE_SHIFT 4
69
+
6770 #define EQ_ENABLE 1
6871 #define EQ_DISABLE 0
6972
7073 #define HNS_ROCE_CEQ 0
7174 #define HNS_ROCE_AEQ 1
7275
73
-#define HNS_ROCE_CEQ_ENTRY_SIZE 0x4
74
-#define HNS_ROCE_AEQ_ENTRY_SIZE 0x10
76
+#define HNS_ROCE_CEQE_SIZE 0x4
77
+#define HNS_ROCE_AEQE_SIZE 0x10
7578
76
-/* 4G/4K = 1M */
77
-#define HNS_ROCE_SL_SHIFT 28
78
-#define HNS_ROCE_TCLASS_SHIFT 20
79
-#define HNS_ROCE_FLOW_LABEL_MASK 0xfffff
79
+#define HNS_ROCE_V3_EQE_SIZE 0x40
80
+
81
+#define HNS_ROCE_V2_CQE_SIZE 32
82
+#define HNS_ROCE_V3_CQE_SIZE 64
83
+
84
+#define HNS_ROCE_V2_QPC_SZ 256
85
+#define HNS_ROCE_V3_QPC_SZ 512
8086
8187 #define HNS_ROCE_MAX_PORTS 6
82
-#define HNS_ROCE_MAX_GID_NUM 16
8388 #define HNS_ROCE_GID_SIZE 16
89
+#define HNS_ROCE_SGE_SIZE 16
8490
8591 #define HNS_ROCE_HOP_NUM_0 0xff
8692
....@@ -88,17 +94,15 @@
8894 #define BITMAP_RR 1
8995
9096 #define MR_TYPE_MR 0x00
97
+#define MR_TYPE_FRMR 0x01
9198 #define MR_TYPE_DMA 0x03
99
+
100
+#define HNS_ROCE_FRMR_MAX_PA 512
92101
93102 #define PKEY_ID 0xffff
94103 #define GUID_LEN 8
95104 #define NODE_DESC_SIZE 64
96105 #define DB_REG_OFFSET 0x1000
97
-
98
-#define SERV_TYPE_RC 0
99
-#define SERV_TYPE_RD 1
100
-#define SERV_TYPE_UC 2
101
-#define SERV_TYPE_UD 3
102106
103107 /* Configure to HW for PAGE_SIZE larger than 4KB */
104108 #define PG_SHIFT_OFFSET (PAGE_SHIFT - 12)
....@@ -108,13 +112,28 @@
108112 #define PAGES_SHIFT_24 24
109113 #define PAGES_SHIFT_32 32
110114
115
+#define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
116
+#define SRQ_DB_REG 0x230
117
+
118
+/* The chip implementation of the consumer index is calculated
119
+ * according to twice the actual EQ depth
120
+ */
121
+#define EQ_DEPTH_COEFF 2
122
+
111123 enum {
112
- HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
113
- HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
124
+ SERV_TYPE_RC,
125
+ SERV_TYPE_UC,
126
+ SERV_TYPE_RD,
127
+ SERV_TYPE_UD,
114128 };
115129
116130 enum {
117
- HNS_ROCE_SUPPORT_CQ_RECORD_DB = 1 << 0,
131
+ HNS_ROCE_QP_CAP_RQ_RECORD_DB = BIT(0),
132
+ HNS_ROCE_QP_CAP_SQ_RECORD_DB = BIT(1),
133
+};
134
+
135
+enum hns_roce_cq_flags {
136
+ HNS_ROCE_CQ_FLAG_RECORD_DB = BIT(0),
118137 };
119138
120139 enum hns_roce_qp_state {
....@@ -187,21 +206,52 @@
187206 HNS_ROCE_OPCODE_RDMA_WITH_IMM_RECEIVE = 0x07,
188207 };
189208
209
+#define HNS_ROCE_CAP_FLAGS_EX_SHIFT 12
210
+
190211 enum {
191212 HNS_ROCE_CAP_FLAG_REREG_MR = BIT(0),
192213 HNS_ROCE_CAP_FLAG_ROCE_V1_V2 = BIT(1),
193214 HNS_ROCE_CAP_FLAG_RQ_INLINE = BIT(2),
194215 HNS_ROCE_CAP_FLAG_RECORD_DB = BIT(3),
195216 HNS_ROCE_CAP_FLAG_SQ_RECORD_DB = BIT(4),
217
+ HNS_ROCE_CAP_FLAG_SRQ = BIT(5),
218
+ HNS_ROCE_CAP_FLAG_MW = BIT(7),
219
+ HNS_ROCE_CAP_FLAG_FRMR = BIT(8),
220
+ HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL = BIT(9),
221
+ HNS_ROCE_CAP_FLAG_ATOMIC = BIT(10),
196222 };
197223
198
-enum hns_roce_mtt_type {
199
- MTT_TYPE_WQE,
200
- MTT_TYPE_CQE,
201
-};
224
+#define HNS_ROCE_DB_TYPE_COUNT 2
225
+#define HNS_ROCE_DB_UNIT_SIZE 4
202226
203227 enum {
204228 HNS_ROCE_DB_PER_PAGE = PAGE_SIZE / 4
229
+};
230
+
231
+enum hns_roce_reset_stage {
232
+ HNS_ROCE_STATE_NON_RST,
233
+ HNS_ROCE_STATE_RST_BEF_DOWN,
234
+ HNS_ROCE_STATE_RST_DOWN,
235
+ HNS_ROCE_STATE_RST_UNINIT,
236
+ HNS_ROCE_STATE_RST_INIT,
237
+ HNS_ROCE_STATE_RST_INITED,
238
+};
239
+
240
+enum hns_roce_instance_state {
241
+ HNS_ROCE_STATE_NON_INIT,
242
+ HNS_ROCE_STATE_INIT,
243
+ HNS_ROCE_STATE_INITED,
244
+ HNS_ROCE_STATE_UNINIT,
245
+};
246
+
247
+enum {
248
+ HNS_ROCE_RST_DIRECT_RETURN = 0,
249
+};
250
+
251
+enum {
252
+ CMD_RST_PRC_OTHERS,
253
+ CMD_RST_PRC_SUCCESS,
254
+ CMD_RST_PRC_EBUSY,
205255 };
206256
207257 #define HNS_ROCE_CMD_SUCCESS 1
....@@ -209,9 +259,12 @@
209259 #define HNS_ROCE_PORT_DOWN 0
210260 #define HNS_ROCE_PORT_UP 1
211261
212
-#define HNS_ROCE_MTT_ENTRY_PER_SEG 8
262
+/* The minimum page size is 4K for hardware */
263
+#define HNS_HW_PAGE_SHIFT 12
264
+#define HNS_HW_PAGE_SIZE (1 << HNS_HW_PAGE_SHIFT)
213265
214
-#define PAGE_ADDR_SHIFT 12
266
+/* The minimum page count for hardware access page directly. */
267
+#define HNS_HW_DIRECT_PAGE_COUNT 2
215268
216269 struct hns_roce_uar {
217270 u64 pfn;
....@@ -219,19 +272,11 @@
219272 unsigned long logic_idx;
220273 };
221274
222
-struct hns_roce_vma_data {
223
- struct list_head list;
224
- struct vm_area_struct *vma;
225
- struct mutex *vma_list_mutex;
226
-};
227
-
228275 struct hns_roce_ucontext {
229276 struct ib_ucontext ibucontext;
230277 struct hns_roce_uar uar;
231278 struct list_head page_list;
232279 struct mutex page_mutex;
233
- struct list_head vma_list;
234
- struct mutex vma_list_mutex;
235280 };
236281
237282 struct hns_roce_pd {
....@@ -250,22 +295,6 @@
250295 unsigned long *table;
251296 };
252297
253
-/* Order bitmap length -- bit num compute formula: 1 << (max_order - order) */
254
-/* Order = 0: bitmap is biggest, order = max bitmap is least (only a bit) */
255
-/* Every bit repesent to a partner free/used status in bitmap */
256
-/*
257
- * Initial, bits of other bitmap are all 0 except that a bit of max_order is 1
258
- * Bit = 1 represent to idle and available; bit = 0: not available
259
- */
260
-struct hns_roce_buddy {
261
- /* Members point to every order level bitmap */
262
- unsigned long **bits;
263
- /* Represent to avail bits of the order level bitmap */
264
- u32 *num_free;
265
- int max_order;
266
- spinlock_t lock;
267
-};
268
-
269298 /* For Hardware Entry Memory */
270299 struct hns_roce_hem_table {
271300 /* HEM type: 0 = qpc, 1 = mtt, 2 = cqc, 3 = srq, 4 = other */
....@@ -274,7 +303,7 @@
274303 unsigned long num_hem;
275304 /* HEM entry record obj total num */
276305 unsigned long num_obj;
277
- /*Single obj size */
306
+ /* Single obj size */
278307 unsigned long obj_size;
279308 unsigned long table_chunk_size;
280309 int lowmem;
....@@ -286,11 +315,60 @@
286315 dma_addr_t *bt_l0_dma_addr;
287316 };
288317
289
-struct hns_roce_mtt {
290
- unsigned long first_seg;
291
- int order;
292
- int page_shift;
293
- enum hns_roce_mtt_type mtt_type;
318
+struct hns_roce_buf_region {
319
+ int offset; /* page offset */
320
+ u32 count; /* page count */
321
+ int hopnum; /* addressing hop num */
322
+};
323
+
324
+#define HNS_ROCE_MAX_BT_REGION 3
325
+#define HNS_ROCE_MAX_BT_LEVEL 3
326
+struct hns_roce_hem_list {
327
+ struct list_head root_bt;
328
+ /* link all bt dma mem by hop config */
329
+ struct list_head mid_bt[HNS_ROCE_MAX_BT_REGION][HNS_ROCE_MAX_BT_LEVEL];
330
+ struct list_head btm_bt; /* link all bottom bt in @mid_bt */
331
+ dma_addr_t root_ba; /* pointer to the root ba table */
332
+};
333
+
334
+struct hns_roce_buf_attr {
335
+ struct {
336
+ size_t size; /* region size */
337
+ int hopnum; /* multi-hop addressing hop num */
338
+ } region[HNS_ROCE_MAX_BT_REGION];
339
+ int region_count; /* valid region count */
340
+ unsigned int page_shift; /* buffer page shift */
341
+ bool fixed_page; /* decide page shift is fixed-size or maximum size */
342
+ int user_access; /* umem access flag */
343
+ bool mtt_only; /* only alloc buffer-required MTT memory */
344
+};
345
+
346
+struct hns_roce_hem_cfg {
347
+ dma_addr_t root_ba; /* root BA table's address */
348
+ bool is_direct; /* addressing without BA table */
349
+ unsigned int ba_pg_shift; /* BA table page shift */
350
+ unsigned int buf_pg_shift; /* buffer page shift */
351
+ unsigned int buf_pg_count; /* buffer page count */
352
+ struct hns_roce_buf_region region[HNS_ROCE_MAX_BT_REGION];
353
+ int region_count;
354
+};
355
+
356
+/* memory translate region */
357
+struct hns_roce_mtr {
358
+ struct hns_roce_hem_list hem_list; /* multi-hop addressing resource */
359
+ struct ib_umem *umem; /* user space buffer */
360
+ struct hns_roce_buf *kmem; /* kernel space buffer */
361
+ struct hns_roce_hem_cfg hem_cfg; /* config for hardware addressing */
362
+};
363
+
364
+struct hns_roce_mw {
365
+ struct ib_mw ibmw;
366
+ u32 pdn;
367
+ u32 rkey;
368
+ int enabled; /* MW's active status */
369
+ u32 pbl_hop_num;
370
+ u32 pbl_ba_pg_sz;
371
+ u32 pbl_buf_pg_sz;
294372 };
295373
296374 /* Only support 4K page size for mr register */
....@@ -298,57 +376,40 @@
298376
299377 struct hns_roce_mr {
300378 struct ib_mr ibmr;
301
- struct ib_umem *umem;
302379 u64 iova; /* MR's virtual orignal addr */
303380 u64 size; /* Address range of MR */
304381 u32 key; /* Key of MR */
305382 u32 pd; /* PD num of MR */
306
- u32 access;/* Access permission of MR */
383
+ u32 access; /* Access permission of MR */
307384 int enabled; /* MR's active status */
308385 int type; /* MR's register type */
309
- u64 *pbl_buf;/* MR's PBL space */
310
- dma_addr_t pbl_dma_addr; /* MR's PBL space PA */
311
- u32 pbl_size;/* PA number in the PBL */
312
- u64 pbl_ba;/* page table address */
313
- u32 l0_chunk_last_num;/* L0 last number */
314
- u32 l1_chunk_last_num;/* L1 last number */
315
- u64 **pbl_bt_l2;/* PBL BT L2 */
316
- u64 **pbl_bt_l1;/* PBL BT L1 */
317
- u64 *pbl_bt_l0;/* PBL BT L0 */
318
- dma_addr_t *pbl_l2_dma_addr;/* PBL BT L2 dma addr */
319
- dma_addr_t *pbl_l1_dma_addr;/* PBL BT L1 dma addr */
320
- dma_addr_t pbl_l0_dma_addr;/* PBL BT L0 dma addr */
321
- u32 pbl_ba_pg_sz;/* BT chunk page size */
322
- u32 pbl_buf_pg_sz;/* buf chunk page size */
323
- u32 pbl_hop_num;/* multi-hop number */
386
+ u32 pbl_hop_num; /* multi-hop number */
387
+ struct hns_roce_mtr pbl_mtr;
388
+ u32 npages;
389
+ dma_addr_t *page_list;
324390 };
325391
326392 struct hns_roce_mr_table {
327393 struct hns_roce_bitmap mtpt_bitmap;
328
- struct hns_roce_buddy mtt_buddy;
329
- struct hns_roce_hem_table mtt_table;
330394 struct hns_roce_hem_table mtpt_table;
331
- struct hns_roce_buddy mtt_cqe_buddy;
332
- struct hns_roce_hem_table mtt_cqe_table;
333395 };
334396
335397 struct hns_roce_wq {
336398 u64 *wrid; /* Work request ID */
337399 spinlock_t lock;
338
- int wqe_cnt; /* WQE num */
339
- u32 max_post;
400
+ u32 wqe_cnt; /* WQE num */
340401 int max_gs;
341402 int offset;
342
- int wqe_shift;/* WQE size */
403
+ int wqe_shift; /* WQE size */
343404 u32 head;
344405 u32 tail;
345406 void __iomem *db_reg_l;
346407 };
347408
348409 struct hns_roce_sge {
349
- int sge_cnt; /* SGE num */
410
+ unsigned int sge_cnt; /* SGE num */
350411 int offset;
351
- int sge_shift;/* SGE size */
412
+ int sge_shift; /* SGE size */
352413 };
353414
354415 struct hns_roce_buf_list {
....@@ -359,16 +420,16 @@
359420 struct hns_roce_buf {
360421 struct hns_roce_buf_list direct;
361422 struct hns_roce_buf_list *page_list;
362
- int nbufs;
363423 u32 npages;
364
- int page_shift;
424
+ u32 size;
425
+ unsigned int page_shift;
365426 };
366427
367428 struct hns_roce_db_pgdir {
368429 struct list_head list;
369430 DECLARE_BITMAP(order0, HNS_ROCE_DB_PER_PAGE);
370
- DECLARE_BITMAP(order1, HNS_ROCE_DB_PER_PAGE / 2);
371
- unsigned long *bits[2];
431
+ DECLARE_BITMAP(order1, HNS_ROCE_DB_PER_PAGE / HNS_ROCE_DB_TYPE_COUNT);
432
+ unsigned long *bits[HNS_ROCE_DB_TYPE_COUNT];
372433 u32 *page;
373434 dma_addr_t db_dma;
374435 };
....@@ -392,37 +453,55 @@
392453 int order;
393454 };
394455
395
-struct hns_roce_cq_buf {
396
- struct hns_roce_buf hr_buf;
397
- struct hns_roce_mtt hr_mtt;
398
-};
399
-
400456 struct hns_roce_cq {
401457 struct ib_cq ib_cq;
402
- struct hns_roce_cq_buf hr_buf;
458
+ struct hns_roce_mtr mtr;
403459 struct hns_roce_db db;
404
- u8 db_en;
460
+ u32 flags;
405461 spinlock_t lock;
406
- struct ib_umem *umem;
407
- void (*comp)(struct hns_roce_cq *cq);
408
- void (*event)(struct hns_roce_cq *cq, enum hns_roce_event event_type);
409
-
410
- struct hns_roce_uar *uar;
411462 u32 cq_depth;
412463 u32 cons_index;
413464 u32 *set_ci_db;
414465 void __iomem *cq_db_l;
415466 u16 *tptr_addr;
416467 int arm_sn;
468
+ int cqe_size;
417469 unsigned long cqn;
418470 u32 vector;
419471 atomic_t refcount;
420472 struct completion free;
473
+ struct list_head sq_list; /* all qps on this send cq */
474
+ struct list_head rq_list; /* all qps on this recv cq */
475
+ int is_armed; /* cq is armed */
476
+ struct list_head node; /* all armed cqs are on a list */
477
+};
478
+
479
+struct hns_roce_idx_que {
480
+ struct hns_roce_mtr mtr;
481
+ int entry_shift;
482
+ unsigned long *bitmap;
421483 };
422484
423485 struct hns_roce_srq {
424486 struct ib_srq ibsrq;
425
- int srqn;
487
+ unsigned long srqn;
488
+ u32 wqe_cnt;
489
+ int max_gs;
490
+ int wqe_shift;
491
+ void __iomem *db_reg_l;
492
+
493
+ atomic_t refcount;
494
+ struct completion free;
495
+
496
+ struct hns_roce_mtr buf_mtr;
497
+
498
+ u64 *wrid;
499
+ struct hns_roce_idx_que idx_que;
500
+ spinlock_t lock;
501
+ int head;
502
+ int tail;
503
+ struct mutex mutex;
504
+ void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
426505 };
427506
428507 struct hns_roce_uar_table {
....@@ -431,16 +510,22 @@
431510
432511 struct hns_roce_qp_table {
433512 struct hns_roce_bitmap bitmap;
434
- spinlock_t lock;
435513 struct hns_roce_hem_table qp_table;
436514 struct hns_roce_hem_table irrl_table;
437515 struct hns_roce_hem_table trrl_table;
516
+ struct hns_roce_hem_table sccc_table;
517
+ struct mutex scc_mutex;
438518 };
439519
440520 struct hns_roce_cq_table {
441521 struct hns_roce_bitmap bitmap;
442
- spinlock_t lock;
443
- struct radix_tree_root tree;
522
+ struct xarray array;
523
+ struct hns_roce_hem_table table;
524
+};
525
+
526
+struct hns_roce_srq_table {
527
+ struct hns_roce_bitmap bitmap;
528
+ struct xarray xa;
444529 struct hns_roce_hem_table table;
445530 };
446531
....@@ -449,14 +534,18 @@
449534 };
450535
451536 struct hns_roce_av {
452
- __le32 port_pd;
453
- u8 gid_index;
454
- u8 stat_rate;
455
- u8 hop_limit;
456
- __le32 sl_tclass_flowlabel;
457
- u8 dgid[HNS_ROCE_GID_SIZE];
458
- u8 mac[6];
459
- __le16 vlan;
537
+ u8 port;
538
+ u8 gid_index;
539
+ u8 stat_rate;
540
+ u8 hop_limit;
541
+ u32 flowlabel;
542
+ u16 udp_sport;
543
+ u8 sl;
544
+ u8 tclass;
545
+ u8 dgid[HNS_ROCE_GID_SIZE];
546
+ u8 mac[ETH_ALEN];
547
+ u16 vlan_id;
548
+ u8 vlan_en;
460549 };
461550
462551 struct hns_roce_ah {
....@@ -497,7 +586,6 @@
497586 * close device, switch into poll mode(non event mode)
498587 */
499588 u8 use_events;
500
- u8 toggle;
501589 };
502590
503591 struct hns_roce_cmd_mailbox {
....@@ -522,23 +610,31 @@
522610 u32 wqe_cnt;
523611 };
524612
613
+enum {
614
+ HNS_ROCE_FLUSH_FLAG = 0,
615
+};
616
+
617
+struct hns_roce_work {
618
+ struct hns_roce_dev *hr_dev;
619
+ struct work_struct work;
620
+ u32 qpn;
621
+ u32 cqn;
622
+ int event_type;
623
+ int sub_type;
624
+};
625
+
525626 struct hns_roce_qp {
526627 struct ib_qp ibqp;
527
- struct hns_roce_buf hr_buf;
528628 struct hns_roce_wq rq;
529629 struct hns_roce_db rdb;
530630 struct hns_roce_db sdb;
531
- u8 rdb_en;
532
- u8 sdb_en;
631
+ unsigned long en_flags;
533632 u32 doorbell_qpn;
534
- __le32 sq_signal_bits;
535
- u32 sq_next_wqe;
536
- int sq_max_wqes_per_wr;
537
- int sq_spare_wqes;
633
+ enum ib_sig_type sq_signal_bits;
538634 struct hns_roce_wq sq;
539635
540
- struct ib_umem *umem;
541
- struct hns_roce_mtt mtt;
636
+ struct hns_roce_mtr mtr;
637
+
542638 u32 buff_size;
543639 struct mutex mutex;
544640 u8 port;
....@@ -559,12 +655,16 @@
559655
560656 struct hns_roce_sge sge;
561657 u32 next_sge;
658
+ enum ib_mtu path_mtu;
659
+ u32 max_inline_data;
562660
661
+ /* 0: flush needed, 1: unneeded */
662
+ unsigned long flush_flag;
663
+ struct hns_roce_work flush_work;
563664 struct hns_roce_rinl_buf rq_inl_buf;
564
-};
565
-
566
-struct hns_roce_sqp {
567
- struct hns_roce_qp hr_qp;
665
+ struct list_head node; /* all qps are on a list */
666
+ struct list_head rq_node; /* all recv qps are on a list */
667
+ struct list_head sq_node; /* all send qps are on a list */
568668 };
569669
570670 struct hns_roce_ib_iboe {
....@@ -580,7 +680,8 @@
580680 };
581681
582682 struct hns_roce_ceqe {
583
- u32 comp;
683
+ __le32 comp;
684
+ __le32 rsv[15];
584685 };
585686
586687 struct hns_roce_aeqe {
....@@ -591,6 +692,12 @@
591692 u32 rsv0;
592693 u32 rsv1;
593694 } qp_event;
695
+
696
+ struct {
697
+ __le32 srq;
698
+ u32 rsv0;
699
+ u32 rsv1;
700
+ } srq_event;
594701
595702 struct {
596703 __le32 cq;
....@@ -611,13 +718,14 @@
611718 u8 rsv0;
612719 } __packed cmd;
613720 } event;
721
+ __le32 rsv[12];
614722 };
615723
616724 struct hns_roce_eq {
617725 struct hns_roce_dev *hr_dev;
618726 void __iomem *doorbell;
619727
620
- int type_flag;/* Aeq:1 ceq:0 */
728
+ int type_flag; /* Aeq:1 ceq:0 */
621729 int eqn;
622730 u32 entries;
623731 int log_entries;
....@@ -629,23 +737,11 @@
629737 int over_ignore;
630738 int coalesce;
631739 int arm_st;
632
- u64 eqe_ba;
633
- int eqe_ba_pg_sz;
634
- int eqe_buf_pg_sz;
635740 int hop_num;
636
- u64 *bt_l0; /* Base address table for L0 */
637
- u64 **bt_l1; /* Base address table for L1 */
638
- u64 **buf;
639
- dma_addr_t l0_dma;
640
- dma_addr_t *l1_dma;
641
- dma_addr_t *buf_dma;
642
- u32 l0_last_num; /* L0 last chunk num */
643
- u32 l1_last_num; /* L1 last chunk num */
644
- int eq_max_cnt;
741
+ struct hns_roce_mtr mtr;
742
+ u16 eq_max_cnt;
645743 int eq_period;
646744 int shift;
647
- dma_addr_t cur_eqe_ba;
648
- dma_addr_t nxt_eqe_ba;
649745 int event_type;
650746 int sub_type;
651747 };
....@@ -656,58 +752,77 @@
656752 };
657753
658754 struct hns_roce_caps {
755
+ u64 fw_ver;
659756 u8 num_ports;
660757 int gid_table_len[HNS_ROCE_MAX_PORTS];
661758 int pkey_table_len[HNS_ROCE_MAX_PORTS];
662759 int local_ca_ack_delay;
663760 int num_uars;
664761 u32 phy_num_uars;
665
- u32 max_sq_sg; /* 2 */
666
- u32 max_sq_inline; /* 32 */
667
- u32 max_rq_sg; /* 2 */
762
+ u32 max_sq_sg;
763
+ u32 max_sq_inline;
764
+ u32 max_rq_sg;
668765 u32 max_extend_sg;
669
- int num_qps; /* 256k */
766
+ int num_qps;
670767 int reserved_qps;
671
- u32 max_wqes; /* 16k */
672
- u32 max_sq_desc_sz; /* 64 */
673
- u32 max_rq_desc_sz; /* 64 */
768
+ int num_qpc_timer;
769
+ int num_cqc_timer;
770
+ int num_srqs;
771
+ u32 max_wqes;
772
+ u32 max_srq_wrs;
773
+ u32 max_srq_sges;
774
+ u32 max_sq_desc_sz;
775
+ u32 max_rq_desc_sz;
674776 u32 max_srq_desc_sz;
675777 int max_qp_init_rdma;
676778 int max_qp_dest_rdma;
677779 int num_cqs;
678
- int max_cqes;
679
- int min_cqes;
780
+ u32 max_cqes;
781
+ u32 min_cqes;
680782 u32 min_wqes;
681783 int reserved_cqs;
682
- int num_aeq_vectors; /* 1 */
784
+ int reserved_srqs;
785
+ int num_aeq_vectors;
683786 int num_comp_vectors;
684787 int num_other_vectors;
685788 int num_mtpts;
686789 u32 num_mtt_segs;
687790 u32 num_cqe_segs;
791
+ u32 num_srqwqe_segs;
792
+ u32 num_idx_segs;
688793 int reserved_mrws;
689794 int reserved_uars;
690795 int num_pds;
691796 int reserved_pds;
692797 u32 mtt_entry_sz;
693
- u32 cq_entry_sz;
798
+ u32 cqe_sz;
694799 u32 page_size_cap;
695800 u32 reserved_lkey;
696801 int mtpt_entry_sz;
697
- int qpc_entry_sz;
802
+ int qpc_sz;
698803 int irrl_entry_sz;
699804 int trrl_entry_sz;
700805 int cqc_entry_sz;
806
+ int sccc_sz;
807
+ int qpc_timer_entry_sz;
808
+ int cqc_timer_entry_sz;
809
+ int srqc_entry_sz;
810
+ int idx_entry_sz;
701811 u32 pbl_ba_pg_sz;
702812 u32 pbl_buf_pg_sz;
703813 u32 pbl_hop_num;
704814 int aeqe_depth;
705815 int ceqe_depth;
816
+ u32 aeqe_size;
817
+ u32 ceqe_size;
706818 enum ib_mtu max_mtu;
707819 u32 qpc_bt_num;
820
+ u32 qpc_timer_bt_num;
708821 u32 srqc_bt_num;
709822 u32 cqc_bt_num;
823
+ u32 cqc_timer_bt_num;
710824 u32 mpt_bt_num;
825
+ u32 sccc_bt_num;
711826 u32 qpc_ba_pg_sz;
712827 u32 qpc_buf_pg_sz;
713828 u32 qpc_hop_num;
....@@ -723,25 +838,52 @@
723838 u32 mtt_ba_pg_sz;
724839 u32 mtt_buf_pg_sz;
725840 u32 mtt_hop_num;
726
- u32 cqe_ba_pg_sz;
841
+ u32 wqe_sq_hop_num;
842
+ u32 wqe_sge_hop_num;
843
+ u32 wqe_rq_hop_num;
844
+ u32 sccc_ba_pg_sz;
845
+ u32 sccc_buf_pg_sz;
846
+ u32 sccc_hop_num;
847
+ u32 qpc_timer_ba_pg_sz;
848
+ u32 qpc_timer_buf_pg_sz;
849
+ u32 qpc_timer_hop_num;
850
+ u32 cqc_timer_ba_pg_sz;
851
+ u32 cqc_timer_buf_pg_sz;
852
+ u32 cqc_timer_hop_num;
853
+ u32 cqe_ba_pg_sz; /* page_size = 4K*(2^cqe_ba_pg_sz) */
727854 u32 cqe_buf_pg_sz;
728855 u32 cqe_hop_num;
856
+ u32 srqwqe_ba_pg_sz;
857
+ u32 srqwqe_buf_pg_sz;
858
+ u32 srqwqe_hop_num;
859
+ u32 idx_ba_pg_sz;
860
+ u32 idx_buf_pg_sz;
861
+ u32 idx_hop_num;
729862 u32 eqe_ba_pg_sz;
730863 u32 eqe_buf_pg_sz;
731864 u32 eqe_hop_num;
732865 u32 sl_num;
733866 u32 tsq_buf_pg_sz;
734867 u32 tpq_buf_pg_sz;
735
- u32 chunk_sz; /* chunk size in non multihop mode*/
868
+ u32 chunk_sz; /* chunk size in non multihop mode */
736869 u64 flags;
870
+ u16 default_ceq_max_cnt;
871
+ u16 default_ceq_period;
872
+ u16 default_aeq_max_cnt;
873
+ u16 default_aeq_period;
874
+ u16 default_aeq_arm_st;
875
+ u16 default_ceq_arm_st;
737876 };
738877
739
-struct hns_roce_work {
740
- struct hns_roce_dev *hr_dev;
741
- struct work_struct work;
742
- u32 qpn;
743
- int event_type;
744
- int sub_type;
878
+struct hns_roce_dfx_hw {
879
+ int (*query_cqc_info)(struct hns_roce_dev *hr_dev, u32 cqn,
880
+ int *buffer);
881
+};
882
+
883
+enum hns_roce_device_state {
884
+ HNS_ROCE_DEVICE_STATE_INITED,
885
+ HNS_ROCE_DEVICE_STATE_RST_DOWN,
886
+ HNS_ROCE_DEVICE_STATE_UNINIT,
745887 };
746888
747889 struct hns_roce_hw {
....@@ -755,20 +897,24 @@
755897 u64 out_param, u32 in_modifier, u8 op_modifier, u16 op,
756898 u16 token, int event);
757899 int (*chk_mbox)(struct hns_roce_dev *hr_dev, unsigned long timeout);
900
+ int (*rst_prc_mbox)(struct hns_roce_dev *hr_dev);
758901 int (*set_gid)(struct hns_roce_dev *hr_dev, u8 port, int gid_index,
759902 const union ib_gid *gid, const struct ib_gid_attr *attr);
760903 int (*set_mac)(struct hns_roce_dev *hr_dev, u8 phy_port, u8 *addr);
761904 void (*set_mtu)(struct hns_roce_dev *hr_dev, u8 phy_port,
762905 enum ib_mtu mtu);
763
- int (*write_mtpt)(void *mb_buf, struct hns_roce_mr *mr,
764
- unsigned long mtpt_idx);
906
+ int (*write_mtpt)(struct hns_roce_dev *hr_dev, void *mb_buf,
907
+ struct hns_roce_mr *mr, unsigned long mtpt_idx);
765908 int (*rereg_write_mtpt)(struct hns_roce_dev *hr_dev,
766909 struct hns_roce_mr *mr, int flags, u32 pdn,
767910 int mr_access_flags, u64 iova, u64 size,
768911 void *mb_buf);
912
+ int (*frmr_write_mtpt)(struct hns_roce_dev *hr_dev, void *mb_buf,
913
+ struct hns_roce_mr *mr);
914
+ int (*mw_write_mtpt)(void *mb_buf, struct hns_roce_mw *mw);
769915 void (*write_cqc)(struct hns_roce_dev *hr_dev,
770916 struct hns_roce_cq *hr_cq, void *mb_buf, u64 *mtts,
771
- dma_addr_t dma_handle, int nent, u32 vector);
917
+ dma_addr_t dma_handle);
772918 int (*set_hem)(struct hns_roce_dev *hr_dev,
773919 struct hns_roce_hem_table *table, int obj, int step_idx);
774920 int (*clear_hem)(struct hns_roce_dev *hr_dev,
....@@ -779,18 +925,34 @@
779925 int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
780926 int attr_mask, enum ib_qp_state cur_state,
781927 enum ib_qp_state new_state);
782
- int (*destroy_qp)(struct ib_qp *ibqp);
928
+ int (*destroy_qp)(struct ib_qp *ibqp, struct ib_udata *udata);
929
+ int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev,
930
+ struct hns_roce_qp *hr_qp);
783931 int (*post_send)(struct ib_qp *ibqp, const struct ib_send_wr *wr,
784932 const struct ib_send_wr **bad_wr);
785933 int (*post_recv)(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
786934 const struct ib_recv_wr **bad_recv_wr);
787935 int (*req_notify_cq)(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
788936 int (*poll_cq)(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
789
- int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr);
790
- int (*destroy_cq)(struct ib_cq *ibcq);
937
+ int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr,
938
+ struct ib_udata *udata);
939
+ int (*destroy_cq)(struct ib_cq *ibcq, struct ib_udata *udata);
791940 int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period);
792941 int (*init_eq)(struct hns_roce_dev *hr_dev);
793942 void (*cleanup_eq)(struct hns_roce_dev *hr_dev);
943
+ void (*write_srqc)(struct hns_roce_dev *hr_dev,
944
+ struct hns_roce_srq *srq, u32 pdn, u16 xrcd, u32 cqn,
945
+ void *mb_buf, u64 *mtts_wqe, u64 *mtts_idx,
946
+ dma_addr_t dma_handle_wqe,
947
+ dma_addr_t dma_handle_idx);
948
+ int (*modify_srq)(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
949
+ enum ib_srq_attr_mask srq_attr_mask,
950
+ struct ib_udata *udata);
951
+ int (*query_srq)(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
952
+ int (*post_srq_recv)(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
953
+ const struct ib_recv_wr **bad_wr);
954
+ const struct ib_device_ops *hns_roce_dev_ops;
955
+ const struct ib_device_ops *hns_roce_dev_srq_ops;
794956 };
795957
796958 struct hns_roce_dev {
....@@ -804,16 +966,21 @@
804966 spinlock_t bt_cmd_lock;
805967 bool active;
806968 bool is_reset;
969
+ bool dis_db;
970
+ unsigned long reset_cnt;
807971 struct hns_roce_ib_iboe iboe;
972
+ enum hns_roce_device_state state;
973
+ struct list_head qp_list; /* list of all qps on this dev */
974
+ spinlock_t qp_list_lock; /* protect qp_list */
808975
809976 struct list_head pgdir_list;
810977 struct mutex pgdir_mutex;
811978 int irq[HNS_ROCE_MAX_IRQ_NUM];
812979 u8 __iomem *reg_base;
813980 struct hns_roce_caps caps;
814
- struct radix_tree_root qp_table_tree;
981
+ struct xarray qp_table_xa;
815982
816
- unsigned char dev_addr[HNS_ROCE_MAX_PORTS][MAC_ADDR_OCTET_NUM];
983
+ unsigned char dev_addr[HNS_ROCE_MAX_PORTS][ETH_ALEN];
817984 u64 sys_image_guid;
818985 u32 vendor_id;
819986 u32 vendor_part_id;
....@@ -825,18 +992,22 @@
825992 struct hns_roce_uar_table uar_table;
826993 struct hns_roce_mr_table mr_table;
827994 struct hns_roce_cq_table cq_table;
995
+ struct hns_roce_srq_table srq_table;
828996 struct hns_roce_qp_table qp_table;
829997 struct hns_roce_eq_table eq_table;
998
+ struct hns_roce_hem_table qpc_timer_table;
999
+ struct hns_roce_hem_table cqc_timer_table;
8301000
8311001 int cmd_mod;
8321002 int loop_idc;
8331003 u32 sdb_offset;
8341004 u32 odb_offset;
835
- dma_addr_t tptr_dma_addr; /*only for hw v1*/
836
- u32 tptr_size; /*only for hw v1*/
1005
+ dma_addr_t tptr_dma_addr; /* only for hw v1 */
1006
+ u32 tptr_size; /* only for hw v1 */
8371007 const struct hns_roce_hw *hw;
8381008 void *priv;
8391009 struct workqueue_struct *irq_workq;
1010
+ const struct hns_roce_dfx_hw *dfx;
8401011 };
8411012
8421013 static inline struct hns_roce_dev *to_hr_dev(struct ib_device *ib_dev)
....@@ -865,6 +1036,11 @@
8651036 return container_of(ibmr, struct hns_roce_mr, ibmr);
8661037 }
8671038
1039
+static inline struct hns_roce_mw *to_hr_mw(struct ib_mw *ibmw)
1040
+{
1041
+ return container_of(ibmw, struct hns_roce_mw, ibmw);
1042
+}
1043
+
8681044 static inline struct hns_roce_qp *to_hr_qp(struct ib_qp *ibqp)
8691045 {
8701046 return container_of(ibqp, struct hns_roce_qp, ibqp);
....@@ -880,11 +1056,6 @@
8801056 return container_of(ibsrq, struct hns_roce_srq, ibsrq);
8811057 }
8821058
883
-static inline struct hns_roce_sqp *hr_to_hr_sqp(struct hns_roce_qp *hr_qp)
884
-{
885
- return container_of(hr_qp, struct hns_roce_sqp, hr_qp);
886
-}
887
-
8881059 static inline void hns_roce_write64_k(__le32 val[2], void __iomem *dest)
8891060 {
8901061 __raw_writeq(*(u64 *) val, dest);
....@@ -893,19 +1064,78 @@
8931064 static inline struct hns_roce_qp
8941065 *__hns_roce_qp_lookup(struct hns_roce_dev *hr_dev, u32 qpn)
8951066 {
896
- return radix_tree_lookup(&hr_dev->qp_table_tree,
897
- qpn & (hr_dev->caps.num_qps - 1));
1067
+ return xa_load(&hr_dev->qp_table_xa, qpn & (hr_dev->caps.num_qps - 1));
1068
+}
1069
+
1070
+static inline bool hns_roce_buf_is_direct(struct hns_roce_buf *buf)
1071
+{
1072
+ if (buf->page_list)
1073
+ return false;
1074
+
1075
+ return true;
8981076 }
8991077
9001078 static inline void *hns_roce_buf_offset(struct hns_roce_buf *buf, int offset)
9011079 {
902
- u32 page_size = 1 << buf->page_shift;
1080
+ if (hns_roce_buf_is_direct(buf))
1081
+ return (char *)(buf->direct.buf) + (offset & (buf->size - 1));
9031082
904
- if (buf->nbufs == 1)
905
- return (char *)(buf->direct.buf) + offset;
1083
+ return (char *)(buf->page_list[offset >> buf->page_shift].buf) +
1084
+ (offset & ((1 << buf->page_shift) - 1));
1085
+}
1086
+
1087
+static inline dma_addr_t hns_roce_buf_page(struct hns_roce_buf *buf, int idx)
1088
+{
1089
+ if (hns_roce_buf_is_direct(buf))
1090
+ return buf->direct.map + ((dma_addr_t)idx << buf->page_shift);
9061091 else
907
- return (char *)(buf->page_list[offset >> buf->page_shift].buf) +
908
- (offset & (page_size - 1));
1092
+ return buf->page_list[idx].map;
1093
+}
1094
+
1095
+#define hr_hw_page_align(x) ALIGN(x, 1 << HNS_HW_PAGE_SHIFT)
1096
+
1097
+static inline u64 to_hr_hw_page_addr(u64 addr)
1098
+{
1099
+ return addr >> HNS_HW_PAGE_SHIFT;
1100
+}
1101
+
1102
+static inline u32 to_hr_hw_page_shift(u32 page_shift)
1103
+{
1104
+ return page_shift - HNS_HW_PAGE_SHIFT;
1105
+}
1106
+
1107
+static inline u32 to_hr_hem_hopnum(u32 hopnum, u32 count)
1108
+{
1109
+ if (count > 0)
1110
+ return hopnum == HNS_ROCE_HOP_NUM_0 ? 0 : hopnum;
1111
+
1112
+ return 0;
1113
+}
1114
+
1115
+static inline u32 to_hr_hem_entries_size(u32 count, u32 buf_shift)
1116
+{
1117
+ return hr_hw_page_align(count << buf_shift);
1118
+}
1119
+
1120
+static inline u32 to_hr_hem_entries_count(u32 count, u32 buf_shift)
1121
+{
1122
+ return hr_hw_page_align(count << buf_shift) >> buf_shift;
1123
+}
1124
+
1125
+static inline u32 to_hr_hem_entries_shift(u32 count, u32 buf_shift)
1126
+{
1127
+ if (!count)
1128
+ return 0;
1129
+
1130
+ return ilog2(to_hr_hem_entries_count(count, buf_shift));
1131
+}
1132
+
1133
+#define DSCP_SHIFT 2
1134
+
1135
+static inline u8 get_tclass(const struct ib_global_route *grh)
1136
+{
1137
+ return grh->sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP ?
1138
+ grh->traffic_class >> DSCP_SHIFT : grh->traffic_class;
9091139 }
9101140
9111141 int hns_roce_init_uar_table(struct hns_roce_dev *dev);
....@@ -920,24 +1150,31 @@
9201150 int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev);
9211151 void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev);
9221152
923
-int hns_roce_mtt_init(struct hns_roce_dev *hr_dev, int npages, int page_shift,
924
- struct hns_roce_mtt *mtt);
925
-void hns_roce_mtt_cleanup(struct hns_roce_dev *hr_dev,
926
- struct hns_roce_mtt *mtt);
927
-int hns_roce_buf_write_mtt(struct hns_roce_dev *hr_dev,
928
- struct hns_roce_mtt *mtt, struct hns_roce_buf *buf);
1153
+/* hns roce hw need current block and next block addr from mtt */
1154
+#define MTT_MIN_COUNT 2
1155
+int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
1156
+ int offset, u64 *mtt_buf, int mtt_max, u64 *base_addr);
1157
+int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
1158
+ struct hns_roce_buf_attr *buf_attr,
1159
+ unsigned int page_shift, struct ib_udata *udata,
1160
+ unsigned long user_addr);
1161
+void hns_roce_mtr_destroy(struct hns_roce_dev *hr_dev,
1162
+ struct hns_roce_mtr *mtr);
1163
+int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
1164
+ dma_addr_t *pages, int page_cnt);
9291165
9301166 int hns_roce_init_pd_table(struct hns_roce_dev *hr_dev);
9311167 int hns_roce_init_mr_table(struct hns_roce_dev *hr_dev);
932
-int hns_roce_init_eq_table(struct hns_roce_dev *hr_dev);
9331168 int hns_roce_init_cq_table(struct hns_roce_dev *hr_dev);
9341169 int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev);
1170
+int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev);
9351171
9361172 void hns_roce_cleanup_pd_table(struct hns_roce_dev *hr_dev);
9371173 void hns_roce_cleanup_mr_table(struct hns_roce_dev *hr_dev);
9381174 void hns_roce_cleanup_eq_table(struct hns_roce_dev *hr_dev);
9391175 void hns_roce_cleanup_cq_table(struct hns_roce_dev *hr_dev);
9401176 void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev);
1177
+void hns_roce_cleanup_srq_table(struct hns_roce_dev *hr_dev);
9411178
9421179 int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj);
9431180 void hns_roce_bitmap_free(struct hns_roce_bitmap *bitmap, unsigned long obj,
....@@ -952,16 +1189,16 @@
9521189 unsigned long obj, int cnt,
9531190 int rr);
9541191
955
-struct ib_ah *hns_roce_create_ah(struct ib_pd *pd,
956
- struct rdma_ah_attr *ah_attr,
957
- struct ib_udata *udata);
1192
+int hns_roce_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr,
1193
+ struct ib_udata *udata);
9581194 int hns_roce_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
959
-int hns_roce_destroy_ah(struct ib_ah *ah);
1195
+static inline int hns_roce_destroy_ah(struct ib_ah *ah, u32 flags)
1196
+{
1197
+ return 0;
1198
+}
9601199
961
-struct ib_pd *hns_roce_alloc_pd(struct ib_device *ib_dev,
962
- struct ib_ucontext *context,
963
- struct ib_udata *udata);
964
-int hns_roce_dealloc_pd(struct ib_pd *pd);
1200
+int hns_roce_alloc_pd(struct ib_pd *pd, struct ib_udata *udata);
1201
+int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
9651202
9661203 struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc);
9671204 struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
....@@ -970,28 +1207,46 @@
9701207 int hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length,
9711208 u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
9721209 struct ib_udata *udata);
973
-int hns_roce_dereg_mr(struct ib_mr *ibmr);
974
-int hns_roce_hw2sw_mpt(struct hns_roce_dev *hr_dev,
975
- struct hns_roce_cmd_mailbox *mailbox,
976
- unsigned long mpt_index);
1210
+struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
1211
+ u32 max_num_sg);
1212
+int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
1213
+ unsigned int *sg_offset);
1214
+int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
1215
+int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev,
1216
+ struct hns_roce_cmd_mailbox *mailbox,
1217
+ unsigned long mpt_index);
9771218 unsigned long key_to_hw_index(u32 key);
9781219
979
-void hns_roce_buf_free(struct hns_roce_dev *hr_dev, u32 size,
980
- struct hns_roce_buf *buf);
1220
+int hns_roce_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
1221
+int hns_roce_dealloc_mw(struct ib_mw *ibmw);
1222
+
1223
+void hns_roce_buf_free(struct hns_roce_dev *hr_dev, struct hns_roce_buf *buf);
9811224 int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
9821225 struct hns_roce_buf *buf, u32 page_shift);
9831226
984
-int hns_roce_ib_umem_write_mtt(struct hns_roce_dev *hr_dev,
985
- struct hns_roce_mtt *mtt, struct ib_umem *umem);
1227
+int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
1228
+ int buf_cnt, int start, struct hns_roce_buf *buf);
1229
+int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
1230
+ int buf_cnt, int start, struct ib_umem *umem,
1231
+ unsigned int page_shift);
1232
+
1233
+int hns_roce_create_srq(struct ib_srq *srq,
1234
+ struct ib_srq_init_attr *srq_init_attr,
1235
+ struct ib_udata *udata);
1236
+int hns_roce_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
1237
+ enum ib_srq_attr_mask srq_attr_mask,
1238
+ struct ib_udata *udata);
1239
+int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
9861240
9871241 struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
9881242 struct ib_qp_init_attr *init_attr,
9891243 struct ib_udata *udata);
9901244 int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
9911245 int attr_mask, struct ib_udata *udata);
992
-void *get_recv_wqe(struct hns_roce_qp *hr_qp, int n);
993
-void *get_send_wqe(struct hns_roce_qp *hr_qp, int n);
994
-void *get_send_extend_sge(struct hns_roce_qp *hr_qp, int n);
1246
+void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
1247
+void *hns_roce_get_recv_wqe(struct hns_roce_qp *hr_qp, int n);
1248
+void *hns_roce_get_send_wqe(struct hns_roce_qp *hr_qp, int n);
1249
+void *hns_roce_get_extend_sge(struct hns_roce_qp *hr_qp, int n);
9951250 bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
9961251 struct ib_cq *ib_cq);
9971252 enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state);
....@@ -1000,21 +1255,17 @@
10001255 void hns_roce_unlock_cqs(struct hns_roce_cq *send_cq,
10011256 struct hns_roce_cq *recv_cq);
10021257 void hns_roce_qp_remove(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
1003
-void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
1004
-void hns_roce_release_range_qp(struct hns_roce_dev *hr_dev, int base_qpn,
1005
- int cnt);
1258
+void hns_roce_qp_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
1259
+ struct ib_udata *udata);
10061260 __be32 send_ieth(const struct ib_send_wr *wr);
10071261 int to_hr_qp_type(int qp_type);
10081262
1009
-struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
1010
- const struct ib_cq_init_attr *attr,
1011
- struct ib_ucontext *context,
1012
- struct ib_udata *udata);
1263
+int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
1264
+ struct ib_udata *udata);
10131265
1014
-int hns_roce_ib_destroy_cq(struct ib_cq *ib_cq);
1015
-void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq);
1016
-
1017
-int hns_roce_db_map_user(struct hns_roce_ucontext *context, unsigned long virt,
1266
+int hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
1267
+int hns_roce_db_map_user(struct hns_roce_ucontext *context,
1268
+ struct ib_udata *udata, unsigned long virt,
10181269 struct hns_roce_db *db);
10191270 void hns_roce_db_unmap_user(struct hns_roce_ucontext *context,
10201271 struct hns_roce_db *db);
....@@ -1025,8 +1276,12 @@
10251276 void hns_roce_cq_completion(struct hns_roce_dev *hr_dev, u32 cqn);
10261277 void hns_roce_cq_event(struct hns_roce_dev *hr_dev, u32 cqn, int event_type);
10271278 void hns_roce_qp_event(struct hns_roce_dev *hr_dev, u32 qpn, int event_type);
1279
+void hns_roce_srq_event(struct hns_roce_dev *hr_dev, u32 srqn, int event_type);
10281280 int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index);
1281
+void hns_roce_handle_device_err(struct hns_roce_dev *hr_dev);
10291282 int hns_roce_init(struct hns_roce_dev *hr_dev);
10301283 void hns_roce_exit(struct hns_roce_dev *hr_dev);
10311284
1285
+int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
1286
+ struct ib_cq *ib_cq);
10321287 #endif /* _HNS_ROCE_DEVICE_H */