This source file includes following definitions.
- dpaa2_fd_get_addr
- dpaa2_fd_set_addr
- dpaa2_fd_get_frc
- dpaa2_fd_set_frc
- dpaa2_fd_get_ctrl
- dpaa2_fd_set_ctrl
- dpaa2_fd_get_flc
- dpaa2_fd_set_flc
- dpaa2_fd_short_len
- dpaa2_fd_get_len
- dpaa2_fd_set_len
- dpaa2_fd_get_offset
- dpaa2_fd_set_offset
- dpaa2_fd_get_format
- dpaa2_fd_set_format
- dpaa2_fd_get_bpid
- dpaa2_fd_set_bpid
- dpaa2_sg_get_addr
- dpaa2_sg_set_addr
- dpaa2_sg_short_len
- dpaa2_sg_get_len
- dpaa2_sg_set_len
- dpaa2_sg_get_offset
- dpaa2_sg_set_offset
- dpaa2_sg_get_format
- dpaa2_sg_set_format
- dpaa2_sg_get_bpid
- dpaa2_sg_set_bpid
- dpaa2_sg_is_final
- dpaa2_sg_set_final
- dpaa2_fl_get_addr
- dpaa2_fl_set_addr
- dpaa2_fl_get_frc
- dpaa2_fl_set_frc
- dpaa2_fl_get_ctrl
- dpaa2_fl_set_ctrl
- dpaa2_fl_get_flc
- dpaa2_fl_set_flc
- dpaa2_fl_short_len
- dpaa2_fl_get_len
- dpaa2_fl_set_len
- dpaa2_fl_get_offset
- dpaa2_fl_set_offset
- dpaa2_fl_get_format
- dpaa2_fl_set_format
- dpaa2_fl_get_bpid
- dpaa2_fl_set_bpid
- dpaa2_fl_is_final
- dpaa2_fl_set_final
1
2
3
4
5
6
7 #ifndef __FSL_DPAA2_FD_H
8 #define __FSL_DPAA2_FD_H
9
10 #include <linux/kernel.h>
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 struct dpaa2_fd {
39 union {
40 u32 words[8];
41 struct dpaa2_fd_simple {
42 __le64 addr;
43 __le32 len;
44 __le16 bpid;
45 __le16 format_offset;
46 __le32 frc;
47 __le32 ctrl;
48 __le64 flc;
49 } simple;
50 };
51 };
52
53 #define FD_SHORT_LEN_FLAG_MASK 0x1
54 #define FD_SHORT_LEN_FLAG_SHIFT 14
55 #define FD_SHORT_LEN_MASK 0x3FFFF
56 #define FD_OFFSET_MASK 0x0FFF
57 #define FD_FORMAT_MASK 0x3
58 #define FD_FORMAT_SHIFT 12
59 #define FD_BPID_MASK 0x3FFF
60 #define SG_SHORT_LEN_FLAG_MASK 0x1
61 #define SG_SHORT_LEN_FLAG_SHIFT 14
62 #define SG_SHORT_LEN_MASK 0x1FFFF
63 #define SG_OFFSET_MASK 0x0FFF
64 #define SG_FORMAT_MASK 0x3
65 #define SG_FORMAT_SHIFT 12
66 #define SG_BPID_MASK 0x3FFF
67 #define SG_FINAL_FLAG_MASK 0x1
68 #define SG_FINAL_FLAG_SHIFT 15
69 #define FL_SHORT_LEN_FLAG_MASK 0x1
70 #define FL_SHORT_LEN_FLAG_SHIFT 14
71 #define FL_SHORT_LEN_MASK 0x3FFFF
72 #define FL_OFFSET_MASK 0x0FFF
73 #define FL_FORMAT_MASK 0x3
74 #define FL_FORMAT_SHIFT 12
75 #define FL_BPID_MASK 0x3FFF
76 #define FL_FINAL_FLAG_MASK 0x1
77 #define FL_FINAL_FLAG_SHIFT 15
78
79
80 #define FD_CTRL_ERR_MASK 0x000000FF
81 #define FD_CTRL_UFD 0x00000004
82 #define FD_CTRL_SBE 0x00000008
83 #define FD_CTRL_FLC 0x00000010
84 #define FD_CTRL_FSE 0x00000020
85 #define FD_CTRL_FAERR 0x00000040
86
87
88 #define FD_CTRL_PTA 0x00800000
89 #define FD_CTRL_PTV1 0x00400000
90
91 enum dpaa2_fd_format {
92 dpaa2_fd_single = 0,
93 dpaa2_fd_list,
94 dpaa2_fd_sg
95 };
96
97
98
99
100
101
102
103 static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
104 {
105 return (dma_addr_t)le64_to_cpu(fd->simple.addr);
106 }
107
108
109
110
111
112
113 static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
114 {
115 fd->simple.addr = cpu_to_le64(addr);
116 }
117
118
119
120
121
122
123
124 static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
125 {
126 return le32_to_cpu(fd->simple.frc);
127 }
128
129
130
131
132
133
134 static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
135 {
136 fd->simple.frc = cpu_to_le32(frc);
137 }
138
139
140
141
142
143
144
145 static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
146 {
147 return le32_to_cpu(fd->simple.ctrl);
148 }
149
150
151
152
153
154
155 static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
156 {
157 fd->simple.ctrl = cpu_to_le32(ctrl);
158 }
159
160
161
162
163
164
165
166 static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
167 {
168 return (dma_addr_t)le64_to_cpu(fd->simple.flc);
169 }
170
171
172
173
174
175
176 static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd, dma_addr_t flc_addr)
177 {
178 fd->simple.flc = cpu_to_le64(flc_addr);
179 }
180
181 static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
182 {
183 return !!((le16_to_cpu(fd->simple.format_offset) >>
184 FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
185 }
186
187
188
189
190
191
192
193 static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
194 {
195 if (dpaa2_fd_short_len(fd))
196 return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
197
198 return le32_to_cpu(fd->simple.len);
199 }
200
201
202
203
204
205
206 static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
207 {
208 fd->simple.len = cpu_to_le32(len);
209 }
210
211
212
213
214
215
216
217 static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
218 {
219 return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
220 }
221
222
223
224
225
226
227 static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
228 {
229 fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
230 fd->simple.format_offset |= cpu_to_le16(offset);
231 }
232
233
234
235
236
237
238
239 static inline enum dpaa2_fd_format dpaa2_fd_get_format(
240 const struct dpaa2_fd *fd)
241 {
242 return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
243 >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
244 }
245
246
247
248
249
250
251 static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
252 enum dpaa2_fd_format format)
253 {
254 fd->simple.format_offset &=
255 cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
256 fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
257 }
258
259
260
261
262
263
264
265 static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
266 {
267 return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
268 }
269
270
271
272
273
274
275 static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
276 {
277 fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
278 fd->simple.bpid |= cpu_to_le16(bpid);
279 }
280
281
282
283
284
285
286
287
288 struct dpaa2_sg_entry {
289 __le64 addr;
290 __le32 len;
291 __le16 bpid;
292 __le16 format_offset;
293 };
294
295 enum dpaa2_sg_format {
296 dpaa2_sg_single = 0,
297 dpaa2_sg_frame_data,
298 dpaa2_sg_sgt_ext
299 };
300
301
302
303
304
305
306
307
308
309 static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
310 {
311 return (dma_addr_t)le64_to_cpu(sg->addr);
312 }
313
314
315
316
317
318
319 static inline void dpaa2_sg_set_addr(struct dpaa2_sg_entry *sg, dma_addr_t addr)
320 {
321 sg->addr = cpu_to_le64(addr);
322 }
323
324 static inline bool dpaa2_sg_short_len(const struct dpaa2_sg_entry *sg)
325 {
326 return !!((le16_to_cpu(sg->format_offset) >> SG_SHORT_LEN_FLAG_SHIFT)
327 & SG_SHORT_LEN_FLAG_MASK);
328 }
329
330
331
332
333
334
335
336 static inline u32 dpaa2_sg_get_len(const struct dpaa2_sg_entry *sg)
337 {
338 if (dpaa2_sg_short_len(sg))
339 return le32_to_cpu(sg->len) & SG_SHORT_LEN_MASK;
340
341 return le32_to_cpu(sg->len);
342 }
343
344
345
346
347
348
349 static inline void dpaa2_sg_set_len(struct dpaa2_sg_entry *sg, u32 len)
350 {
351 sg->len = cpu_to_le32(len);
352 }
353
354
355
356
357
358
359
360 static inline u16 dpaa2_sg_get_offset(const struct dpaa2_sg_entry *sg)
361 {
362 return le16_to_cpu(sg->format_offset) & SG_OFFSET_MASK;
363 }
364
365
366
367
368
369
370 static inline void dpaa2_sg_set_offset(struct dpaa2_sg_entry *sg,
371 u16 offset)
372 {
373 sg->format_offset &= cpu_to_le16(~SG_OFFSET_MASK);
374 sg->format_offset |= cpu_to_le16(offset);
375 }
376
377
378
379
380
381
382
383 static inline enum dpaa2_sg_format
384 dpaa2_sg_get_format(const struct dpaa2_sg_entry *sg)
385 {
386 return (enum dpaa2_sg_format)((le16_to_cpu(sg->format_offset)
387 >> SG_FORMAT_SHIFT) & SG_FORMAT_MASK);
388 }
389
390
391
392
393
394
395 static inline void dpaa2_sg_set_format(struct dpaa2_sg_entry *sg,
396 enum dpaa2_sg_format format)
397 {
398 sg->format_offset &= cpu_to_le16(~(SG_FORMAT_MASK << SG_FORMAT_SHIFT));
399 sg->format_offset |= cpu_to_le16(format << SG_FORMAT_SHIFT);
400 }
401
402
403
404
405
406
407
408 static inline u16 dpaa2_sg_get_bpid(const struct dpaa2_sg_entry *sg)
409 {
410 return le16_to_cpu(sg->bpid) & SG_BPID_MASK;
411 }
412
413
414
415
416
417
418 static inline void dpaa2_sg_set_bpid(struct dpaa2_sg_entry *sg, u16 bpid)
419 {
420 sg->bpid &= cpu_to_le16(~(SG_BPID_MASK));
421 sg->bpid |= cpu_to_le16(bpid);
422 }
423
424
425
426
427
428
429
430 static inline bool dpaa2_sg_is_final(const struct dpaa2_sg_entry *sg)
431 {
432 return !!(le16_to_cpu(sg->format_offset) >> SG_FINAL_FLAG_SHIFT);
433 }
434
435
436
437
438
439
440 static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
441 {
442 sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
443 << SG_FINAL_FLAG_SHIFT)) & 0xFFFF);
444 sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
445 }
446
447
448
449
450
451
452
453
454
455
456
457 struct dpaa2_fl_entry {
458 __le64 addr;
459 __le32 len;
460 __le16 bpid;
461 __le16 format_offset;
462 __le32 frc;
463 __le32 ctrl;
464 __le64 flc;
465 };
466
467 enum dpaa2_fl_format {
468 dpaa2_fl_single = 0,
469 dpaa2_fl_res,
470 dpaa2_fl_sg
471 };
472
473
474
475
476
477
478
479 static inline dma_addr_t dpaa2_fl_get_addr(const struct dpaa2_fl_entry *fle)
480 {
481 return (dma_addr_t)le64_to_cpu(fle->addr);
482 }
483
484
485
486
487
488
489 static inline void dpaa2_fl_set_addr(struct dpaa2_fl_entry *fle,
490 dma_addr_t addr)
491 {
492 fle->addr = cpu_to_le64(addr);
493 }
494
495
496
497
498
499
500
501 static inline u32 dpaa2_fl_get_frc(const struct dpaa2_fl_entry *fle)
502 {
503 return le32_to_cpu(fle->frc);
504 }
505
506
507
508
509
510
511 static inline void dpaa2_fl_set_frc(struct dpaa2_fl_entry *fle, u32 frc)
512 {
513 fle->frc = cpu_to_le32(frc);
514 }
515
516
517
518
519
520
521
522 static inline u32 dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry *fle)
523 {
524 return le32_to_cpu(fle->ctrl);
525 }
526
527
528
529
530
531
532 static inline void dpaa2_fl_set_ctrl(struct dpaa2_fl_entry *fle, u32 ctrl)
533 {
534 fle->ctrl = cpu_to_le32(ctrl);
535 }
536
537
538
539
540
541
542
543 static inline dma_addr_t dpaa2_fl_get_flc(const struct dpaa2_fl_entry *fle)
544 {
545 return (dma_addr_t)le64_to_cpu(fle->flc);
546 }
547
548
549
550
551
552
553 static inline void dpaa2_fl_set_flc(struct dpaa2_fl_entry *fle,
554 dma_addr_t flc_addr)
555 {
556 fle->flc = cpu_to_le64(flc_addr);
557 }
558
559 static inline bool dpaa2_fl_short_len(const struct dpaa2_fl_entry *fle)
560 {
561 return !!((le16_to_cpu(fle->format_offset) >>
562 FL_SHORT_LEN_FLAG_SHIFT) & FL_SHORT_LEN_FLAG_MASK);
563 }
564
565
566
567
568
569
570
571 static inline u32 dpaa2_fl_get_len(const struct dpaa2_fl_entry *fle)
572 {
573 if (dpaa2_fl_short_len(fle))
574 return le32_to_cpu(fle->len) & FL_SHORT_LEN_MASK;
575
576 return le32_to_cpu(fle->len);
577 }
578
579
580
581
582
583
584 static inline void dpaa2_fl_set_len(struct dpaa2_fl_entry *fle, u32 len)
585 {
586 fle->len = cpu_to_le32(len);
587 }
588
589
590
591
592
593
594
595 static inline u16 dpaa2_fl_get_offset(const struct dpaa2_fl_entry *fle)
596 {
597 return le16_to_cpu(fle->format_offset) & FL_OFFSET_MASK;
598 }
599
600
601
602
603
604
605 static inline void dpaa2_fl_set_offset(struct dpaa2_fl_entry *fle, u16 offset)
606 {
607 fle->format_offset &= cpu_to_le16(~FL_OFFSET_MASK);
608 fle->format_offset |= cpu_to_le16(offset);
609 }
610
611
612
613
614
615
616
617 static inline enum dpaa2_fl_format dpaa2_fl_get_format(const struct dpaa2_fl_entry *fle)
618 {
619 return (enum dpaa2_fl_format)((le16_to_cpu(fle->format_offset) >>
620 FL_FORMAT_SHIFT) & FL_FORMAT_MASK);
621 }
622
623
624
625
626
627
628 static inline void dpaa2_fl_set_format(struct dpaa2_fl_entry *fle,
629 enum dpaa2_fl_format format)
630 {
631 fle->format_offset &= cpu_to_le16(~(FL_FORMAT_MASK << FL_FORMAT_SHIFT));
632 fle->format_offset |= cpu_to_le16(format << FL_FORMAT_SHIFT);
633 }
634
635
636
637
638
639
640
641 static inline u16 dpaa2_fl_get_bpid(const struct dpaa2_fl_entry *fle)
642 {
643 return le16_to_cpu(fle->bpid) & FL_BPID_MASK;
644 }
645
646
647
648
649
650
651 static inline void dpaa2_fl_set_bpid(struct dpaa2_fl_entry *fle, u16 bpid)
652 {
653 fle->bpid &= cpu_to_le16(~(FL_BPID_MASK));
654 fle->bpid |= cpu_to_le16(bpid);
655 }
656
657
658
659
660
661
662
663 static inline bool dpaa2_fl_is_final(const struct dpaa2_fl_entry *fle)
664 {
665 return !!(le16_to_cpu(fle->format_offset) >> FL_FINAL_FLAG_SHIFT);
666 }
667
668
669
670
671
672
673 static inline void dpaa2_fl_set_final(struct dpaa2_fl_entry *fle, bool final)
674 {
675 fle->format_offset &= cpu_to_le16((~(FL_FINAL_FLAG_MASK <<
676 FL_FINAL_FLAG_SHIFT)) & 0xFFFF);
677 fle->format_offset |= cpu_to_le16(final << FL_FINAL_FLAG_SHIFT);
678 }
679
680 #endif