]>
Commit | Line | Data |
---|---|---|
a2a55e51 PK |
1 | /* |
2 | * Copyright (C) 2014 Freescale Semiconductor | |
3 | * | |
4 | * SPDX-License-Identifier: GPL-2.0+ | |
5 | */ | |
6 | #ifndef __FSL_DPAA_FD_H | |
7 | #define __FSL_DPAA_FD_H | |
8 | ||
9 | /* Place-holder for FDs, we represent it via the simplest form that we need for | |
10 | * now. Different overlays may be needed to support different options, etc. (It | |
11 | * is impractical to define One True Struct, because the resulting encoding | |
12 | * routines (lots of read-modify-writes) would be worst-case performance whether | |
13 | * or not circumstances required them.) */ | |
14 | struct dpaa_fd { | |
15 | union { | |
16 | u32 words[8]; | |
17 | struct dpaa_fd_simple { | |
18 | u32 addr_lo; | |
19 | u32 addr_hi; | |
20 | u32 len; | |
21 | /* offset in the MS 16 bits, BPID in the LS 16 bits */ | |
22 | u32 bpid_offset; | |
23 | u32 frc; /* frame context */ | |
24 | /* "err", "va", "cbmt", "asal", [...] */ | |
25 | u32 ctrl; | |
26 | /* flow context */ | |
27 | u32 flc_lo; | |
28 | u32 flc_hi; | |
29 | } simple; | |
30 | }; | |
31 | }; | |
32 | ||
33 | enum dpaa_fd_format { | |
34 | dpaa_fd_single = 0, | |
35 | dpaa_fd_list, | |
36 | dpaa_fd_sg | |
37 | }; | |
38 | ||
39 | static inline u64 ldpaa_fd_get_addr(const struct dpaa_fd *fd) | |
40 | { | |
41 | return (u64)((((uint64_t)fd->simple.addr_hi) << 32) | |
42 | + fd->simple.addr_lo); | |
43 | } | |
44 | ||
45 | static inline void ldpaa_fd_set_addr(struct dpaa_fd *fd, u64 addr) | |
46 | { | |
47 | fd->simple.addr_hi = upper_32_bits(addr); | |
48 | fd->simple.addr_lo = lower_32_bits(addr); | |
49 | } | |
50 | ||
51 | static inline u32 ldpaa_fd_get_len(const struct dpaa_fd *fd) | |
52 | { | |
53 | return fd->simple.len; | |
54 | } | |
55 | ||
56 | static inline void ldpaa_fd_set_len(struct dpaa_fd *fd, u32 len) | |
57 | { | |
58 | fd->simple.len = len; | |
59 | } | |
60 | ||
61 | static inline uint16_t ldpaa_fd_get_offset(const struct dpaa_fd *fd) | |
62 | { | |
63 | return (uint16_t)(fd->simple.bpid_offset >> 16) & 0x0FFF; | |
64 | } | |
65 | ||
66 | static inline void ldpaa_fd_set_offset(struct dpaa_fd *fd, uint16_t offset) | |
67 | { | |
68 | fd->simple.bpid_offset &= 0xF000FFFF; | |
69 | fd->simple.bpid_offset |= (u32)offset << 16; | |
70 | } | |
71 | ||
72 | static inline uint16_t ldpaa_fd_get_bpid(const struct dpaa_fd *fd) | |
73 | { | |
74 | return (uint16_t)(fd->simple.bpid_offset & 0xFFFF); | |
75 | } | |
76 | ||
77 | static inline void ldpaa_fd_set_bpid(struct dpaa_fd *fd, uint16_t bpid) | |
78 | { | |
79 | fd->simple.bpid_offset &= 0xFFFF0000; | |
80 | fd->simple.bpid_offset |= (u32)bpid; | |
81 | } | |
82 | ||
83 | /* When frames are dequeued, the FDs show up inside "dequeue" result structures | |
84 | * (if at all, not all dequeue results contain valid FDs). This structure type | |
85 | * is intentionally defined without internal detail, and the only reason it | |
86 | * isn't declared opaquely (without size) is to allow the user to provide | |
87 | * suitably-sized (and aligned) memory for these entries. */ | |
88 | struct ldpaa_dq { | |
89 | uint32_t dont_manipulate_directly[16]; | |
90 | }; | |
91 | ||
92 | /* Parsing frame dequeue results */ | |
93 | #define LDPAA_DQ_STAT_FQEMPTY 0x80 | |
94 | #define LDPAA_DQ_STAT_HELDACTIVE 0x40 | |
95 | #define LDPAA_DQ_STAT_FORCEELIGIBLE 0x20 | |
96 | #define LDPAA_DQ_STAT_VALIDFRAME 0x10 | |
97 | #define LDPAA_DQ_STAT_ODPVALID 0x04 | |
98 | #define LDPAA_DQ_STAT_VOLATILE 0x02 | |
99 | #define LDPAA_DQ_STAT_EXPIRED 0x01 | |
100 | uint32_t ldpaa_dq_flags(const struct ldpaa_dq *); | |
101 | static inline int ldpaa_dq_is_pull(const struct ldpaa_dq *dq) | |
102 | { | |
103 | return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_VOLATILE); | |
104 | } | |
105 | static inline int ldpaa_dq_is_pull_complete( | |
106 | const struct ldpaa_dq *dq) | |
107 | { | |
108 | return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_EXPIRED); | |
109 | } | |
110 | /* seqnum/odpid are valid only if VALIDFRAME and ODPVALID flags are TRUE */ | |
111 | uint16_t ldpaa_dq_seqnum(const struct ldpaa_dq *); | |
112 | uint16_t ldpaa_dq_odpid(const struct ldpaa_dq *); | |
113 | uint32_t ldpaa_dq_fqid(const struct ldpaa_dq *); | |
114 | uint32_t ldpaa_dq_byte_count(const struct ldpaa_dq *); | |
115 | uint32_t ldpaa_dq_frame_count(const struct ldpaa_dq *); | |
116 | uint32_t ldpaa_dq_fqd_ctx_hi(const struct ldpaa_dq *); | |
117 | uint32_t ldpaa_dq_fqd_ctx_lo(const struct ldpaa_dq *); | |
118 | /* get the Frame Descriptor */ | |
119 | const struct dpaa_fd *ldpaa_dq_fd(const struct ldpaa_dq *); | |
120 | ||
121 | #endif /* __FSL_DPAA_FD_H */ |