Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: fsl: dpio: add frame list format support

Add support for dpaa2_fd_list format, i.e. dpaa2_fl_entry structure
and accessors.

Frame list entries (FLEs) are similar, but not identical to FDs:
+ "F" (final) bit
- FMT[b'01] is reserved
- DD, SC, DROPP bits (covered by "FD compatibility" field in FLE case)
- FLC[5:0] not used for stashing

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Acked-by: Li Yang <leoyang.li@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Horia Geantă and committed by
Herbert Xu
009447a0 48c43de0

+242
+242
include/soc/fsl/dpaa2-fd.h
··· 66 66 #define SG_BPID_MASK 0x3FFF 67 67 #define SG_FINAL_FLAG_MASK 0x1 68 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 69 78 70 79 /* Error bits in FD CTRL */ 71 80 #define FD_CTRL_ERR_MASK 0x000000FF ··· 442 433 sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK 443 434 << SG_FINAL_FLAG_SHIFT)) & 0xFFFF); 444 435 sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT); 436 + } 437 + 438 + /** 439 + * struct dpaa2_fl_entry - structure for frame list entry. 440 + * @addr: address in the FLE 441 + * @len: length in the FLE 442 + * @bpid: buffer pool ID 443 + * @format_offset: format, offset, and short-length fields 444 + * @frc: frame context 445 + * @ctrl: control bits...including pta, pvt1, pvt2, err, etc 446 + * @flc: flow context address 447 + */ 448 + struct dpaa2_fl_entry { 449 + __le64 addr; 450 + __le32 len; 451 + __le16 bpid; 452 + __le16 format_offset; 453 + __le32 frc; 454 + __le32 ctrl; 455 + __le64 flc; 456 + }; 457 + 458 + enum dpaa2_fl_format { 459 + dpaa2_fl_single = 0, 460 + dpaa2_fl_res, 461 + dpaa2_fl_sg 462 + }; 463 + 464 + /** 465 + * dpaa2_fl_get_addr() - get the addr field of FLE 466 + * @fle: the given frame list entry 467 + * 468 + * Return the address in the frame list entry. 469 + */ 470 + static inline dma_addr_t dpaa2_fl_get_addr(const struct dpaa2_fl_entry *fle) 471 + { 472 + return (dma_addr_t)le64_to_cpu(fle->addr); 473 + } 474 + 475 + /** 476 + * dpaa2_fl_set_addr() - Set the addr field of FLE 477 + * @fle: the given frame list entry 478 + * @addr: the address needs to be set in frame list entry 479 + */ 480 + static inline void dpaa2_fl_set_addr(struct dpaa2_fl_entry *fle, 481 + dma_addr_t addr) 482 + { 483 + fle->addr = cpu_to_le64(addr); 484 + } 485 + 486 + /** 487 + * dpaa2_fl_get_frc() - Get the frame context in the FLE 488 + * @fle: the given frame list entry 489 + * 490 + * Return the frame context field in the frame lsit entry. 491 + */ 492 + static inline u32 dpaa2_fl_get_frc(const struct dpaa2_fl_entry *fle) 493 + { 494 + return le32_to_cpu(fle->frc); 495 + } 496 + 497 + /** 498 + * dpaa2_fl_set_frc() - Set the frame context in the FLE 499 + * @fle: the given frame list entry 500 + * @frc: the frame context needs to be set in frame list entry 501 + */ 502 + static inline void dpaa2_fl_set_frc(struct dpaa2_fl_entry *fle, u32 frc) 503 + { 504 + fle->frc = cpu_to_le32(frc); 505 + } 506 + 507 + /** 508 + * dpaa2_fl_get_ctrl() - Get the control bits in the FLE 509 + * @fle: the given frame list entry 510 + * 511 + * Return the control bits field in the frame list entry. 512 + */ 513 + static inline u32 dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry *fle) 514 + { 515 + return le32_to_cpu(fle->ctrl); 516 + } 517 + 518 + /** 519 + * dpaa2_fl_set_ctrl() - Set the control bits in the FLE 520 + * @fle: the given frame list entry 521 + * @ctrl: the control bits to be set in the frame list entry 522 + */ 523 + static inline void dpaa2_fl_set_ctrl(struct dpaa2_fl_entry *fle, u32 ctrl) 524 + { 525 + fle->ctrl = cpu_to_le32(ctrl); 526 + } 527 + 528 + /** 529 + * dpaa2_fl_get_flc() - Get the flow context in the FLE 530 + * @fle: the given frame list entry 531 + * 532 + * Return the flow context in the frame list entry. 533 + */ 534 + static inline dma_addr_t dpaa2_fl_get_flc(const struct dpaa2_fl_entry *fle) 535 + { 536 + return (dma_addr_t)le64_to_cpu(fle->flc); 537 + } 538 + 539 + /** 540 + * dpaa2_fl_set_flc() - Set the flow context field of FLE 541 + * @fle: the given frame list entry 542 + * @flc_addr: the flow context needs to be set in frame list entry 543 + */ 544 + static inline void dpaa2_fl_set_flc(struct dpaa2_fl_entry *fle, 545 + dma_addr_t flc_addr) 546 + { 547 + fle->flc = cpu_to_le64(flc_addr); 548 + } 549 + 550 + static inline bool dpaa2_fl_short_len(const struct dpaa2_fl_entry *fle) 551 + { 552 + return !!((le16_to_cpu(fle->format_offset) >> 553 + FL_SHORT_LEN_FLAG_SHIFT) & FL_SHORT_LEN_FLAG_MASK); 554 + } 555 + 556 + /** 557 + * dpaa2_fl_get_len() - Get the length in the FLE 558 + * @fle: the given frame list entry 559 + * 560 + * Return the length field in the frame list entry. 561 + */ 562 + static inline u32 dpaa2_fl_get_len(const struct dpaa2_fl_entry *fle) 563 + { 564 + if (dpaa2_fl_short_len(fle)) 565 + return le32_to_cpu(fle->len) & FL_SHORT_LEN_MASK; 566 + 567 + return le32_to_cpu(fle->len); 568 + } 569 + 570 + /** 571 + * dpaa2_fl_set_len() - Set the length field of FLE 572 + * @fle: the given frame list entry 573 + * @len: the length needs to be set in frame list entry 574 + */ 575 + static inline void dpaa2_fl_set_len(struct dpaa2_fl_entry *fle, u32 len) 576 + { 577 + fle->len = cpu_to_le32(len); 578 + } 579 + 580 + /** 581 + * dpaa2_fl_get_offset() - Get the offset field in the frame list entry 582 + * @fle: the given frame list entry 583 + * 584 + * Return the offset. 585 + */ 586 + static inline u16 dpaa2_fl_get_offset(const struct dpaa2_fl_entry *fle) 587 + { 588 + return le16_to_cpu(fle->format_offset) & FL_OFFSET_MASK; 589 + } 590 + 591 + /** 592 + * dpaa2_fl_set_offset() - Set the offset field of FLE 593 + * @fle: the given frame list entry 594 + * @offset: the offset needs to be set in frame list entry 595 + */ 596 + static inline void dpaa2_fl_set_offset(struct dpaa2_fl_entry *fle, u16 offset) 597 + { 598 + fle->format_offset &= cpu_to_le16(~FL_OFFSET_MASK); 599 + fle->format_offset |= cpu_to_le16(offset); 600 + } 601 + 602 + /** 603 + * dpaa2_fl_get_format() - Get the format field in the FLE 604 + * @fle: the given frame list entry 605 + * 606 + * Return the format. 607 + */ 608 + static inline enum dpaa2_fl_format dpaa2_fl_get_format(const struct dpaa2_fl_entry *fle) 609 + { 610 + return (enum dpaa2_fl_format)((le16_to_cpu(fle->format_offset) >> 611 + FL_FORMAT_SHIFT) & FL_FORMAT_MASK); 612 + } 613 + 614 + /** 615 + * dpaa2_fl_set_format() - Set the format field of FLE 616 + * @fle: the given frame list entry 617 + * @format: the format needs to be set in frame list entry 618 + */ 619 + static inline void dpaa2_fl_set_format(struct dpaa2_fl_entry *fle, 620 + enum dpaa2_fl_format format) 621 + { 622 + fle->format_offset &= cpu_to_le16(~(FL_FORMAT_MASK << FL_FORMAT_SHIFT)); 623 + fle->format_offset |= cpu_to_le16(format << FL_FORMAT_SHIFT); 624 + } 625 + 626 + /** 627 + * dpaa2_fl_get_bpid() - Get the bpid field in the FLE 628 + * @fle: the given frame list entry 629 + * 630 + * Return the buffer pool id. 631 + */ 632 + static inline u16 dpaa2_fl_get_bpid(const struct dpaa2_fl_entry *fle) 633 + { 634 + return le16_to_cpu(fle->bpid) & FL_BPID_MASK; 635 + } 636 + 637 + /** 638 + * dpaa2_fl_set_bpid() - Set the bpid field of FLE 639 + * @fle: the given frame list entry 640 + * @bpid: buffer pool id to be set 641 + */ 642 + static inline void dpaa2_fl_set_bpid(struct dpaa2_fl_entry *fle, u16 bpid) 643 + { 644 + fle->bpid &= cpu_to_le16(~(FL_BPID_MASK)); 645 + fle->bpid |= cpu_to_le16(bpid); 646 + } 647 + 648 + /** 649 + * dpaa2_fl_is_final() - Check final bit in FLE 650 + * @fle: the given frame list entry 651 + * 652 + * Return bool. 653 + */ 654 + static inline bool dpaa2_fl_is_final(const struct dpaa2_fl_entry *fle) 655 + { 656 + return !!(le16_to_cpu(fle->format_offset) >> FL_FINAL_FLAG_SHIFT); 657 + } 658 + 659 + /** 660 + * dpaa2_fl_set_final() - Set the final bit in FLE 661 + * @fle: the given frame list entry 662 + * @final: the final boolean to be set 663 + */ 664 + static inline void dpaa2_fl_set_final(struct dpaa2_fl_entry *fle, bool final) 665 + { 666 + fle->format_offset &= cpu_to_le16((~(FL_FINAL_FLAG_MASK << 667 + FL_FINAL_FLAG_SHIFT)) & 0xFFFF); 668 + fle->format_offset |= cpu_to_le16(final << FL_FINAL_FLAG_SHIFT); 445 669 } 446 670 447 671 #endif /* __FSL_DPAA2_FD_H */