Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
/*
 * Copyright (c) 2018-2019 Cavium, Inc.
 * All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 *
 */

#ifndef __QLNXR_ROCE_H__
#define __QLNXR_ROCE_H__ 


/*
 * roce completion notification queue element
 */
struct roce_cnqe {
	struct regpair cq_handle;
};


struct roce_cqe_responder {
	struct regpair srq_wr_id;
	struct regpair qp_handle;
	__le32 imm_data_or_inv_r_Key;
	__le32 length;
	__le32 reserved0;
	__le16 rq_cons;
	u8 flags;
#define ROCE_CQE_RESPONDER_TOGGLE_BIT_MASK  0x1
#define ROCE_CQE_RESPONDER_TOGGLE_BIT_SHIFT 0
#define ROCE_CQE_RESPONDER_TYPE_MASK        0x3
#define ROCE_CQE_RESPONDER_TYPE_SHIFT       1
#define ROCE_CQE_RESPONDER_INV_FLG_MASK     0x1
#define ROCE_CQE_RESPONDER_INV_FLG_SHIFT    3
#define ROCE_CQE_RESPONDER_IMM_FLG_MASK     0x1
#define ROCE_CQE_RESPONDER_IMM_FLG_SHIFT    4
#define ROCE_CQE_RESPONDER_RDMA_FLG_MASK    0x1
#define ROCE_CQE_RESPONDER_RDMA_FLG_SHIFT   5
#define ROCE_CQE_RESPONDER_RESERVED2_MASK   0x3
#define ROCE_CQE_RESPONDER_RESERVED2_SHIFT  6
	u8 status;
};

struct roce_cqe_requester {
	__le16 sq_cons;
	__le16 reserved0;
	__le32 reserved1;
	struct regpair qp_handle;
	struct regpair reserved2;
	__le32 reserved3;
	__le16 reserved4;
	u8 flags;
#define ROCE_CQE_REQUESTER_TOGGLE_BIT_MASK  0x1
#define ROCE_CQE_REQUESTER_TOGGLE_BIT_SHIFT 0
#define ROCE_CQE_REQUESTER_TYPE_MASK        0x3
#define ROCE_CQE_REQUESTER_TYPE_SHIFT       1
#define ROCE_CQE_REQUESTER_RESERVED5_MASK   0x1F
#define ROCE_CQE_REQUESTER_RESERVED5_SHIFT  3
	u8 status;
};

struct roce_cqe_common {
	struct regpair reserved0;
	struct regpair qp_handle;
	__le16 reserved1[7];
	u8 flags;
#define ROCE_CQE_COMMON_TOGGLE_BIT_MASK  0x1
#define ROCE_CQE_COMMON_TOGGLE_BIT_SHIFT 0
#define ROCE_CQE_COMMON_TYPE_MASK        0x3
#define ROCE_CQE_COMMON_TYPE_SHIFT       1
#define ROCE_CQE_COMMON_RESERVED2_MASK   0x1F
#define ROCE_CQE_COMMON_RESERVED2_SHIFT  3
	u8 status;
};

/*
 * roce completion queue element
 */
union roce_cqe {
	struct roce_cqe_responder resp;
	struct roce_cqe_requester req;
	struct roce_cqe_common cmn;
};




/*
 * CQE requester status enumeration
 */
enum roce_cqe_requester_status_enum {
	ROCE_CQE_REQ_STS_OK,
	ROCE_CQE_REQ_STS_BAD_RESPONSE_ERR,
	ROCE_CQE_REQ_STS_LOCAL_LENGTH_ERR,
	ROCE_CQE_REQ_STS_LOCAL_QP_OPERATION_ERR,
	ROCE_CQE_REQ_STS_LOCAL_PROTECTION_ERR,
	ROCE_CQE_REQ_STS_MEMORY_MGT_OPERATION_ERR,
	ROCE_CQE_REQ_STS_REMOTE_INVALID_REQUEST_ERR,
	ROCE_CQE_REQ_STS_REMOTE_ACCESS_ERR,
	ROCE_CQE_REQ_STS_REMOTE_OPERATION_ERR,
	ROCE_CQE_REQ_STS_RNR_NAK_RETRY_CNT_ERR,
	ROCE_CQE_REQ_STS_TRANSPORT_RETRY_CNT_ERR,
	ROCE_CQE_REQ_STS_WORK_REQUEST_FLUSHED_ERR,
	MAX_ROCE_CQE_REQUESTER_STATUS_ENUM
};



/*
 * CQE responder status enumeration
 */
enum roce_cqe_responder_status_enum {
	ROCE_CQE_RESP_STS_OK,
	ROCE_CQE_RESP_STS_LOCAL_ACCESS_ERR,
	ROCE_CQE_RESP_STS_LOCAL_LENGTH_ERR,
	ROCE_CQE_RESP_STS_LOCAL_QP_OPERATION_ERR,
	ROCE_CQE_RESP_STS_LOCAL_PROTECTION_ERR,
	ROCE_CQE_RESP_STS_MEMORY_MGT_OPERATION_ERR,
	ROCE_CQE_RESP_STS_REMOTE_INVALID_REQUEST_ERR,
	ROCE_CQE_RESP_STS_WORK_REQUEST_FLUSHED_ERR,
	MAX_ROCE_CQE_RESPONDER_STATUS_ENUM
};


/*
 * CQE type enumeration
 */
enum roce_cqe_type {
	ROCE_CQE_TYPE_REQUESTER,
	ROCE_CQE_TYPE_RESPONDER_RQ,
	ROCE_CQE_TYPE_RESPONDER_SRQ,
	ROCE_CQE_TYPE_INVALID,
	MAX_ROCE_CQE_TYPE
};


/*
 * memory window type enumeration
 */
enum roce_mw_type {
	ROCE_MW_TYPE_1,
	ROCE_MW_TYPE_2A,
	MAX_ROCE_MW_TYPE
};


struct roce_rq_sge {
	struct regpair addr;
	__le32 length;
	__le32 flags;
#define ROCE_RQ_SGE_L_KEY_MASK      0x3FFFFFF
#define ROCE_RQ_SGE_L_KEY_SHIFT     0
#define ROCE_RQ_SGE_NUM_SGES_MASK   0x7
#define ROCE_RQ_SGE_NUM_SGES_SHIFT  26
#define ROCE_RQ_SGE_RESERVED0_MASK  0x7
#define ROCE_RQ_SGE_RESERVED0_SHIFT 29
};


struct roce_sq_atomic_wqe {
	struct regpair remote_va;
	__le32 xrc_srq;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_ATOMIC_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_ATOMIC_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_ATOMIC_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_ATOMIC_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_ATOMIC_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_ATOMIC_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_ATOMIC_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_ATOMIC_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_ATOMIC_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_ATOMIC_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_ATOMIC_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_ATOMIC_WQE_RESERVED0_SHIFT     5
	u8 reserved1;
	u8 prev_wqe_size;
	struct regpair swap_data;
	__le32 r_key;
	__le32 reserved2;
	struct regpair cmp_data;
	struct regpair reserved3;
};


/*
 * First element (16 bytes) of atomic wqe
 */
struct roce_sq_atomic_wqe_1st {
	struct regpair remote_va;
	__le32 xrc_srq;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_ATOMIC_WQE_1ST_COMP_FLG_MASK       0x1
#define ROCE_SQ_ATOMIC_WQE_1ST_COMP_FLG_SHIFT      0
#define ROCE_SQ_ATOMIC_WQE_1ST_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_ATOMIC_WQE_1ST_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_ATOMIC_WQE_1ST_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_ATOMIC_WQE_1ST_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_ATOMIC_WQE_1ST_SE_FLG_MASK         0x1
#define ROCE_SQ_ATOMIC_WQE_1ST_SE_FLG_SHIFT        3
#define ROCE_SQ_ATOMIC_WQE_1ST_INLINE_FLG_MASK     0x1
#define ROCE_SQ_ATOMIC_WQE_1ST_INLINE_FLG_SHIFT    4
#define ROCE_SQ_ATOMIC_WQE_1ST_RESERVED0_MASK      0x7
#define ROCE_SQ_ATOMIC_WQE_1ST_RESERVED0_SHIFT     5
	u8 reserved1;
	u8 prev_wqe_size;
};


/*
 * Second element (16 bytes) of atomic wqe
 */
struct roce_sq_atomic_wqe_2nd {
	struct regpair swap_data;
	__le32 r_key;
	__le32 reserved2;
};


/*
 * Third element (16 bytes) of atomic wqe
 */
struct roce_sq_atomic_wqe_3rd {
	struct regpair cmp_data;
	struct regpair reserved3;
};


struct roce_sq_bind_wqe {
	struct regpair addr;
	__le32 l_key;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_BIND_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_BIND_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_BIND_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_BIND_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_BIND_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_BIND_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_BIND_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_BIND_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_BIND_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_BIND_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_BIND_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_BIND_WQE_RESERVED0_SHIFT     5
	u8 access_ctrl;
#define ROCE_SQ_BIND_WQE_REMOTE_READ_MASK    0x1
#define ROCE_SQ_BIND_WQE_REMOTE_READ_SHIFT   0
#define ROCE_SQ_BIND_WQE_REMOTE_WRITE_MASK   0x1
#define ROCE_SQ_BIND_WQE_REMOTE_WRITE_SHIFT  1
#define ROCE_SQ_BIND_WQE_ENABLE_ATOMIC_MASK  0x1
#define ROCE_SQ_BIND_WQE_ENABLE_ATOMIC_SHIFT 2
#define ROCE_SQ_BIND_WQE_LOCAL_READ_MASK     0x1
#define ROCE_SQ_BIND_WQE_LOCAL_READ_SHIFT    3
#define ROCE_SQ_BIND_WQE_LOCAL_WRITE_MASK    0x1
#define ROCE_SQ_BIND_WQE_LOCAL_WRITE_SHIFT   4
#define ROCE_SQ_BIND_WQE_RESERVED1_MASK      0x7
#define ROCE_SQ_BIND_WQE_RESERVED1_SHIFT     5
	u8 prev_wqe_size;
	u8 bind_ctrl;
#define ROCE_SQ_BIND_WQE_ZERO_BASED_MASK     0x1
#define ROCE_SQ_BIND_WQE_ZERO_BASED_SHIFT    0
#define ROCE_SQ_BIND_WQE_MW_TYPE_MASK        0x1
#define ROCE_SQ_BIND_WQE_MW_TYPE_SHIFT       1
#define ROCE_SQ_BIND_WQE_RESERVED2_MASK      0x3F
#define ROCE_SQ_BIND_WQE_RESERVED2_SHIFT     2
	u8 reserved3[2];
	u8 length_hi;
	__le32 length_lo;
	__le32 parent_l_key;
	__le32 reserved6;
};


/*
 * First element (16 bytes) of bind wqe
 */
struct roce_sq_bind_wqe_1st {
	struct regpair addr;
	__le32 l_key;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_BIND_WQE_1ST_COMP_FLG_MASK       0x1
#define ROCE_SQ_BIND_WQE_1ST_COMP_FLG_SHIFT      0
#define ROCE_SQ_BIND_WQE_1ST_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_BIND_WQE_1ST_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_BIND_WQE_1ST_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_BIND_WQE_1ST_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_BIND_WQE_1ST_SE_FLG_MASK         0x1
#define ROCE_SQ_BIND_WQE_1ST_SE_FLG_SHIFT        3
#define ROCE_SQ_BIND_WQE_1ST_INLINE_FLG_MASK     0x1
#define ROCE_SQ_BIND_WQE_1ST_INLINE_FLG_SHIFT    4
#define ROCE_SQ_BIND_WQE_1ST_RESERVED0_MASK      0x7
#define ROCE_SQ_BIND_WQE_1ST_RESERVED0_SHIFT     5
	u8 access_ctrl;
#define ROCE_SQ_BIND_WQE_1ST_REMOTE_READ_MASK    0x1
#define ROCE_SQ_BIND_WQE_1ST_REMOTE_READ_SHIFT   0
#define ROCE_SQ_BIND_WQE_1ST_REMOTE_WRITE_MASK   0x1
#define ROCE_SQ_BIND_WQE_1ST_REMOTE_WRITE_SHIFT  1
#define ROCE_SQ_BIND_WQE_1ST_ENABLE_ATOMIC_MASK  0x1
#define ROCE_SQ_BIND_WQE_1ST_ENABLE_ATOMIC_SHIFT 2
#define ROCE_SQ_BIND_WQE_1ST_LOCAL_READ_MASK     0x1
#define ROCE_SQ_BIND_WQE_1ST_LOCAL_READ_SHIFT    3
#define ROCE_SQ_BIND_WQE_1ST_LOCAL_WRITE_MASK    0x1
#define ROCE_SQ_BIND_WQE_1ST_LOCAL_WRITE_SHIFT   4
#define ROCE_SQ_BIND_WQE_1ST_RESERVED1_MASK      0x7
#define ROCE_SQ_BIND_WQE_1ST_RESERVED1_SHIFT     5
	u8 prev_wqe_size;
};


/*
 * Second element (16 bytes) of bind wqe
 */
struct roce_sq_bind_wqe_2nd {
	u8 bind_ctrl;
#define ROCE_SQ_BIND_WQE_2ND_ZERO_BASED_MASK  0x1
#define ROCE_SQ_BIND_WQE_2ND_ZERO_BASED_SHIFT 0
#define ROCE_SQ_BIND_WQE_2ND_MW_TYPE_MASK     0x1
#define ROCE_SQ_BIND_WQE_2ND_MW_TYPE_SHIFT    1
#define ROCE_SQ_BIND_WQE_2ND_RESERVED2_MASK   0x3F
#define ROCE_SQ_BIND_WQE_2ND_RESERVED2_SHIFT  2
	u8 reserved3[2];
	u8 length_hi;
	__le32 length_lo;
	__le32 parent_l_key;
	__le32 reserved6;
};


/*
 * Structure with only the SQ WQE common fields. Size is of one SQ element (16B)
 */
struct roce_sq_common_wqe {
	__le32 reserved1[3];
	u8 req_type;
	u8 flags;
#define ROCE_SQ_COMMON_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_COMMON_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_COMMON_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_COMMON_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_COMMON_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_COMMON_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_COMMON_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_COMMON_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_COMMON_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_COMMON_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_COMMON_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_COMMON_WQE_RESERVED0_SHIFT     5
	u8 reserved2;
	u8 prev_wqe_size;
};


struct roce_sq_fmr_wqe {
	struct regpair addr;
	__le32 l_key;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_FMR_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_FMR_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_FMR_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_FMR_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_FMR_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_FMR_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_FMR_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_FMR_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_FMR_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_FMR_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_FMR_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_FMR_WQE_RESERVED0_SHIFT     5
	u8 access_ctrl;
#define ROCE_SQ_FMR_WQE_REMOTE_READ_MASK    0x1
#define ROCE_SQ_FMR_WQE_REMOTE_READ_SHIFT   0
#define ROCE_SQ_FMR_WQE_REMOTE_WRITE_MASK   0x1
#define ROCE_SQ_FMR_WQE_REMOTE_WRITE_SHIFT  1
#define ROCE_SQ_FMR_WQE_ENABLE_ATOMIC_MASK  0x1
#define ROCE_SQ_FMR_WQE_ENABLE_ATOMIC_SHIFT 2
#define ROCE_SQ_FMR_WQE_LOCAL_READ_MASK     0x1
#define ROCE_SQ_FMR_WQE_LOCAL_READ_SHIFT    3
#define ROCE_SQ_FMR_WQE_LOCAL_WRITE_MASK    0x1
#define ROCE_SQ_FMR_WQE_LOCAL_WRITE_SHIFT   4
#define ROCE_SQ_FMR_WQE_RESERVED1_MASK      0x7
#define ROCE_SQ_FMR_WQE_RESERVED1_SHIFT     5
	u8 prev_wqe_size;
	u8 fmr_ctrl;
#define ROCE_SQ_FMR_WQE_PAGE_SIZE_LOG_MASK  0x1F
#define ROCE_SQ_FMR_WQE_PAGE_SIZE_LOG_SHIFT 0
#define ROCE_SQ_FMR_WQE_ZERO_BASED_MASK     0x1
#define ROCE_SQ_FMR_WQE_ZERO_BASED_SHIFT    5
#define ROCE_SQ_FMR_WQE_BIND_EN_MASK        0x1
#define ROCE_SQ_FMR_WQE_BIND_EN_SHIFT       6
#define ROCE_SQ_FMR_WQE_RESERVED2_MASK      0x1
#define ROCE_SQ_FMR_WQE_RESERVED2_SHIFT     7
	u8 reserved3[2];
	u8 length_hi;
	__le32 length_lo;
	struct regpair pbl_addr;
};


/*
 * First element (16 bytes) of fmr wqe
 */
struct roce_sq_fmr_wqe_1st {
	struct regpair addr;
	__le32 l_key;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_FMR_WQE_1ST_COMP_FLG_MASK       0x1
#define ROCE_SQ_FMR_WQE_1ST_COMP_FLG_SHIFT      0
#define ROCE_SQ_FMR_WQE_1ST_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_FMR_WQE_1ST_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_FMR_WQE_1ST_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_FMR_WQE_1ST_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_FMR_WQE_1ST_SE_FLG_MASK         0x1
#define ROCE_SQ_FMR_WQE_1ST_SE_FLG_SHIFT        3
#define ROCE_SQ_FMR_WQE_1ST_INLINE_FLG_MASK     0x1
#define ROCE_SQ_FMR_WQE_1ST_INLINE_FLG_SHIFT    4
#define ROCE_SQ_FMR_WQE_1ST_RESERVED0_MASK      0x7
#define ROCE_SQ_FMR_WQE_1ST_RESERVED0_SHIFT     5
	u8 access_ctrl;
#define ROCE_SQ_FMR_WQE_1ST_REMOTE_READ_MASK    0x1
#define ROCE_SQ_FMR_WQE_1ST_REMOTE_READ_SHIFT   0
#define ROCE_SQ_FMR_WQE_1ST_REMOTE_WRITE_MASK   0x1
#define ROCE_SQ_FMR_WQE_1ST_REMOTE_WRITE_SHIFT  1
#define ROCE_SQ_FMR_WQE_1ST_ENABLE_ATOMIC_MASK  0x1
#define ROCE_SQ_FMR_WQE_1ST_ENABLE_ATOMIC_SHIFT 2
#define ROCE_SQ_FMR_WQE_1ST_LOCAL_READ_MASK     0x1
#define ROCE_SQ_FMR_WQE_1ST_LOCAL_READ_SHIFT    3
#define ROCE_SQ_FMR_WQE_1ST_LOCAL_WRITE_MASK    0x1
#define ROCE_SQ_FMR_WQE_1ST_LOCAL_WRITE_SHIFT   4
#define ROCE_SQ_FMR_WQE_1ST_RESERVED1_MASK      0x7
#define ROCE_SQ_FMR_WQE_1ST_RESERVED1_SHIFT     5
	u8 prev_wqe_size;
};


/*
 * Second element (16 bytes) of fmr wqe
 */
struct roce_sq_fmr_wqe_2nd {
	u8 fmr_ctrl;
#define ROCE_SQ_FMR_WQE_2ND_PAGE_SIZE_LOG_MASK  0x1F
#define ROCE_SQ_FMR_WQE_2ND_PAGE_SIZE_LOG_SHIFT 0
#define ROCE_SQ_FMR_WQE_2ND_ZERO_BASED_MASK     0x1
#define ROCE_SQ_FMR_WQE_2ND_ZERO_BASED_SHIFT    5
#define ROCE_SQ_FMR_WQE_2ND_BIND_EN_MASK        0x1
#define ROCE_SQ_FMR_WQE_2ND_BIND_EN_SHIFT       6
#define ROCE_SQ_FMR_WQE_2ND_RESERVED2_MASK      0x1
#define ROCE_SQ_FMR_WQE_2ND_RESERVED2_SHIFT     7
	u8 reserved3[2];
	u8 length_hi;
	__le32 length_lo;
	struct regpair pbl_addr;
};


struct roce_sq_local_inv_wqe {
	struct regpair reserved;
	__le32 inv_l_key;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_LOCAL_INV_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_LOCAL_INV_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_LOCAL_INV_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_LOCAL_INV_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_LOCAL_INV_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_LOCAL_INV_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_LOCAL_INV_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_LOCAL_INV_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_LOCAL_INV_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_LOCAL_INV_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_LOCAL_INV_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_LOCAL_INV_WQE_RESERVED0_SHIFT     5
	u8 reserved1;
	u8 prev_wqe_size;
};


struct roce_sq_rdma_wqe {
	__le32 imm_data;
	__le32 length;
	__le32 xrc_srq;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_RDMA_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_RDMA_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_RDMA_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_RDMA_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_RDMA_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_RDMA_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_RDMA_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_RDMA_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_RDMA_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_RDMA_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_RDMA_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_RDMA_WQE_RESERVED0_SHIFT     5
	u8 wqe_size;
	u8 prev_wqe_size;
	struct regpair remote_va;
	__le32 r_key;
	__le32 reserved1;
};


/*
 * First element (16 bytes) of rdma wqe
 */
struct roce_sq_rdma_wqe_1st {
	__le32 imm_data;
	__le32 length;
	__le32 xrc_srq;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_RDMA_WQE_1ST_COMP_FLG_MASK       0x1
#define ROCE_SQ_RDMA_WQE_1ST_COMP_FLG_SHIFT      0
#define ROCE_SQ_RDMA_WQE_1ST_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_RDMA_WQE_1ST_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_RDMA_WQE_1ST_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_RDMA_WQE_1ST_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_RDMA_WQE_1ST_SE_FLG_MASK         0x1
#define ROCE_SQ_RDMA_WQE_1ST_SE_FLG_SHIFT        3
#define ROCE_SQ_RDMA_WQE_1ST_INLINE_FLG_MASK     0x1
#define ROCE_SQ_RDMA_WQE_1ST_INLINE_FLG_SHIFT    4
#define ROCE_SQ_RDMA_WQE_1ST_RESERVED0_MASK      0x7
#define ROCE_SQ_RDMA_WQE_1ST_RESERVED0_SHIFT     5
	u8 wqe_size;
	u8 prev_wqe_size;
};


/*
 * Second element (16 bytes) of rdma wqe
 */
struct roce_sq_rdma_wqe_2nd {
	struct regpair remote_va;
	__le32 r_key;
	__le32 reserved1;
};


/*
 * SQ WQE req type enumeration
 */
enum roce_sq_req_type {
	ROCE_SQ_REQ_TYPE_SEND,
	ROCE_SQ_REQ_TYPE_SEND_WITH_IMM,
	ROCE_SQ_REQ_TYPE_SEND_WITH_INVALIDATE,
	ROCE_SQ_REQ_TYPE_RDMA_WR,
	ROCE_SQ_REQ_TYPE_RDMA_WR_WITH_IMM,
	ROCE_SQ_REQ_TYPE_RDMA_RD,
	ROCE_SQ_REQ_TYPE_ATOMIC_CMP_AND_SWAP,
	ROCE_SQ_REQ_TYPE_ATOMIC_ADD,
	ROCE_SQ_REQ_TYPE_LOCAL_INVALIDATE,
	ROCE_SQ_REQ_TYPE_FAST_MR,
	ROCE_SQ_REQ_TYPE_BIND,
	ROCE_SQ_REQ_TYPE_INVALID,
	MAX_ROCE_SQ_REQ_TYPE
};


struct roce_sq_send_wqe {
	__le32 inv_key_or_imm_data;
	__le32 length;
	__le32 xrc_srq;
	u8 req_type;
	u8 flags;
#define ROCE_SQ_SEND_WQE_COMP_FLG_MASK       0x1
#define ROCE_SQ_SEND_WQE_COMP_FLG_SHIFT      0
#define ROCE_SQ_SEND_WQE_RD_FENCE_FLG_MASK   0x1
#define ROCE_SQ_SEND_WQE_RD_FENCE_FLG_SHIFT  1
#define ROCE_SQ_SEND_WQE_INV_FENCE_FLG_MASK  0x1
#define ROCE_SQ_SEND_WQE_INV_FENCE_FLG_SHIFT 2
#define ROCE_SQ_SEND_WQE_SE_FLG_MASK         0x1
#define ROCE_SQ_SEND_WQE_SE_FLG_SHIFT        3
#define ROCE_SQ_SEND_WQE_INLINE_FLG_MASK     0x1
#define ROCE_SQ_SEND_WQE_INLINE_FLG_SHIFT    4
#define ROCE_SQ_SEND_WQE_RESERVED0_MASK      0x7
#define ROCE_SQ_SEND_WQE_RESERVED0_SHIFT     5
	u8 wqe_size;
	u8 prev_wqe_size;
};


struct roce_sq_sge {
	__le32 length;
	struct regpair addr;
	__le32 l_key;
};


struct roce_srq_prod {
	__le16 prod;
};


struct roce_srq_sge {
	struct regpair addr;
	__le32 length;
	__le32 l_key;
	struct regpair wr_id;
	u8 flags;
#define ROCE_SRQ_SGE_NUM_SGES_MASK   0x3
#define ROCE_SRQ_SGE_NUM_SGES_SHIFT  0
#define ROCE_SRQ_SGE_RESERVED0_MASK  0x3F
#define ROCE_SRQ_SGE_RESERVED0_SHIFT 2
	u8 reserved1;
	__le16 reserved2;
	__le32 reserved3;
};


/*
 * RoCE doorbell data for SQ and RQ
 */
struct roce_pwm_val16_data {
	__le16 icid;
	__le16 prod_val;
};


union roce_pwm_val16_data_union {
	struct roce_pwm_val16_data as_struct;
	__le32 as_dword;
};


/*
 * RoCE doorbell data for CQ
 */
struct roce_pwm_val32_data {
	__le16 icid;
	u8 agg_flags;
	u8 params;
#define ROCE_PWM_VAL32_DATA_AGG_CMD_MASK    0x3
#define ROCE_PWM_VAL32_DATA_AGG_CMD_SHIFT   0
#define ROCE_PWM_VAL32_DATA_BYPASS_EN_MASK  0x1
#define ROCE_PWM_VAL32_DATA_BYPASS_EN_SHIFT 2
#define ROCE_PWM_VAL32_DATA_RESERVED_MASK   0x1F
#define ROCE_PWM_VAL32_DATA_RESERVED_SHIFT  3
	__le32 cq_cons_val;
};


union roce_pwm_val32_data_union {
	struct roce_pwm_val32_data as_struct;
	struct regpair as_repair;
};

#endif /* __QLNXR_ROCE_H__ */