forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/soc/fsl/dpaa2-fd.h
....@@ -66,6 +66,15 @@
6666 #define SG_BPID_MASK 0x3FFF
6767 #define SG_FINAL_FLAG_MASK 0x1
6868 #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
6978
7079 /* Error bits in FD CTRL */
7180 #define FD_CTRL_ERR_MASK 0x000000FF
....@@ -435,4 +444,237 @@
435444 sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
436445 }
437446
447
+/**
448
+ * struct dpaa2_fl_entry - structure for frame list entry.
449
+ * @addr: address in the FLE
450
+ * @len: length in the FLE
451
+ * @bpid: buffer pool ID
452
+ * @format_offset: format, offset, and short-length fields
453
+ * @frc: frame context
454
+ * @ctrl: control bits...including pta, pvt1, pvt2, err, etc
455
+ * @flc: flow context address
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
+ * dpaa2_fl_get_addr() - get the addr field of FLE
475
+ * @fle: the given frame list entry
476
+ *
477
+ * Return the address in the frame list entry.
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
+ * dpaa2_fl_set_addr() - Set the addr field of FLE
486
+ * @fle: the given frame list entry
487
+ * @addr: the address needs to be set in frame list entry
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
+ * dpaa2_fl_get_frc() - Get the frame context in the FLE
497
+ * @fle: the given frame list entry
498
+ *
499
+ * Return the frame context field in the frame lsit entry.
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
+ * dpaa2_fl_set_frc() - Set the frame context in the FLE
508
+ * @fle: the given frame list entry
509
+ * @frc: the frame context needs to be set in frame list entry
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
+ * dpaa2_fl_get_ctrl() - Get the control bits in the FLE
518
+ * @fle: the given frame list entry
519
+ *
520
+ * Return the control bits field in the frame list entry.
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
+ * dpaa2_fl_set_ctrl() - Set the control bits in the FLE
529
+ * @fle: the given frame list entry
530
+ * @ctrl: the control bits to be set in the frame list entry
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
+ * dpaa2_fl_get_flc() - Get the flow context in the FLE
539
+ * @fle: the given frame list entry
540
+ *
541
+ * Return the flow context in the frame list entry.
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
+ * dpaa2_fl_set_flc() - Set the flow context field of FLE
550
+ * @fle: the given frame list entry
551
+ * @flc_addr: the flow context needs to be set in frame list entry
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
+ * dpaa2_fl_get_len() - Get the length in the FLE
567
+ * @fle: the given frame list entry
568
+ *
569
+ * Return the length field in the frame list entry.
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
+ * dpaa2_fl_set_len() - Set the length field of FLE
581
+ * @fle: the given frame list entry
582
+ * @len: the length needs to be set in frame list entry
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
+ * dpaa2_fl_get_offset() - Get the offset field in the frame list entry
591
+ * @fle: the given frame list entry
592
+ *
593
+ * Return the offset.
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
+ * dpaa2_fl_set_offset() - Set the offset field of FLE
602
+ * @fle: the given frame list entry
603
+ * @offset: the offset needs to be set in frame list entry
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
+ * dpaa2_fl_get_format() - Get the format field in the FLE
613
+ * @fle: the given frame list entry
614
+ *
615
+ * Return the format.
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
+ * dpaa2_fl_set_format() - Set the format field of FLE
625
+ * @fle: the given frame list entry
626
+ * @format: the format needs to be set in frame list entry
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
+ * dpaa2_fl_get_bpid() - Get the bpid field in the FLE
637
+ * @fle: the given frame list entry
638
+ *
639
+ * Return the buffer pool id.
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
+ * dpaa2_fl_set_bpid() - Set the bpid field of FLE
648
+ * @fle: the given frame list entry
649
+ * @bpid: buffer pool id to be set
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
+ * dpaa2_fl_is_final() - Check final bit in FLE
659
+ * @fle: the given frame list entry
660
+ *
661
+ * Return bool.
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
+ * dpaa2_fl_set_final() - Set the final bit in FLE
670
+ * @fle: the given frame list entry
671
+ * @final: the final boolean to be set
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
+
438680 #endif /* __FSL_DPAA2_FD_H */