Linux 5.6.13
[linux/fpc-iii.git] / include / soc / fsl / dpaa2-global.h
blob2bfc379d3dc97171ae73efe9ca997ed95d7aa521
1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /*
3 * Copyright 2014-2016 Freescale Semiconductor Inc.
4 * Copyright 2016 NXP
6 */
7 #ifndef __FSL_DPAA2_GLOBAL_H
8 #define __FSL_DPAA2_GLOBAL_H
10 #include <linux/types.h>
11 #include <linux/cpumask.h>
12 #include "dpaa2-fd.h"
14 struct dpaa2_dq {
15 union {
16 struct common {
17 u8 verb;
18 u8 reserved[63];
19 } common;
20 struct dq {
21 u8 verb;
22 u8 stat;
23 __le16 seqnum;
24 __le16 oprid;
25 u8 reserved;
26 u8 tok;
27 __le32 fqid;
28 u32 reserved2;
29 __le32 fq_byte_cnt;
30 __le32 fq_frm_cnt;
31 __le64 fqd_ctx;
32 u8 fd[32];
33 } dq;
34 struct scn {
35 u8 verb;
36 u8 stat;
37 u8 state;
38 u8 reserved;
39 __le32 rid_tok;
40 __le64 ctx;
41 } scn;
45 /* Parsing frame dequeue results */
46 /* FQ empty */
47 #define DPAA2_DQ_STAT_FQEMPTY 0x80
48 /* FQ held active */
49 #define DPAA2_DQ_STAT_HELDACTIVE 0x40
50 /* FQ force eligible */
51 #define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
52 /* valid frame */
53 #define DPAA2_DQ_STAT_VALIDFRAME 0x10
54 /* FQ ODP enable */
55 #define DPAA2_DQ_STAT_ODPVALID 0x04
56 /* volatile dequeue */
57 #define DPAA2_DQ_STAT_VOLATILE 0x02
58 /* volatile dequeue command is expired */
59 #define DPAA2_DQ_STAT_EXPIRED 0x01
61 #define DQ_FQID_MASK 0x00FFFFFF
62 #define DQ_FRAME_COUNT_MASK 0x00FFFFFF
64 /**
65 * dpaa2_dq_flags() - Get the stat field of dequeue response
66 * @dq: the dequeue result.
68 static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
70 return dq->dq.stat;
73 /**
74 * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
75 * command.
76 * @dq: the dequeue result
78 * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
80 static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
82 return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
85 /**
86 * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
87 * @dq: the dequeue result
89 * Return boolean.
91 static inline bool dpaa2_dq_is_pull_complete(const struct dpaa2_dq *dq)
93 return !!(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_EXPIRED);
96 /**
97 * dpaa2_dq_seqnum() - Get the seqnum field in dequeue response
98 * @dq: the dequeue result
100 * seqnum is valid only if VALIDFRAME flag is TRUE
102 * Return seqnum.
104 static inline u16 dpaa2_dq_seqnum(const struct dpaa2_dq *dq)
106 return le16_to_cpu(dq->dq.seqnum);
110 * dpaa2_dq_odpid() - Get the odpid field in dequeue response
111 * @dq: the dequeue result
113 * odpid is valid only if ODPVALID flag is TRUE.
115 * Return odpid.
117 static inline u16 dpaa2_dq_odpid(const struct dpaa2_dq *dq)
119 return le16_to_cpu(dq->dq.oprid);
123 * dpaa2_dq_fqid() - Get the fqid in dequeue response
124 * @dq: the dequeue result
126 * Return fqid.
128 static inline u32 dpaa2_dq_fqid(const struct dpaa2_dq *dq)
130 return le32_to_cpu(dq->dq.fqid) & DQ_FQID_MASK;
134 * dpaa2_dq_byte_count() - Get the byte count in dequeue response
135 * @dq: the dequeue result
137 * Return the byte count remaining in the FQ.
139 static inline u32 dpaa2_dq_byte_count(const struct dpaa2_dq *dq)
141 return le32_to_cpu(dq->dq.fq_byte_cnt);
145 * dpaa2_dq_frame_count() - Get the frame count in dequeue response
146 * @dq: the dequeue result
148 * Return the frame count remaining in the FQ.
150 static inline u32 dpaa2_dq_frame_count(const struct dpaa2_dq *dq)
152 return le32_to_cpu(dq->dq.fq_frm_cnt) & DQ_FRAME_COUNT_MASK;
156 * dpaa2_dq_fd_ctx() - Get the frame queue context in dequeue response
157 * @dq: the dequeue result
159 * Return the frame queue context.
161 static inline u64 dpaa2_dq_fqd_ctx(const struct dpaa2_dq *dq)
163 return le64_to_cpu(dq->dq.fqd_ctx);
167 * dpaa2_dq_fd() - Get the frame descriptor in dequeue response
168 * @dq: the dequeue result
170 * Return the frame descriptor.
172 static inline const struct dpaa2_fd *dpaa2_dq_fd(const struct dpaa2_dq *dq)
174 return (const struct dpaa2_fd *)&dq->dq.fd[0];
177 #define DPAA2_CSCN_SIZE sizeof(struct dpaa2_dq)
178 #define DPAA2_CSCN_ALIGN 16
179 #define DPAA2_CSCN_STATE_CG BIT(0)
182 * dpaa2_cscn_state_congested() - Check congestion state
183 * @cscn: congestion SCN (delivered to WQ or memory)
185 i * Return true is congested.
187 static inline bool dpaa2_cscn_state_congested(struct dpaa2_dq *cscn)
189 return !!(cscn->scn.state & DPAA2_CSCN_STATE_CG);
192 #endif /* __FSL_DPAA2_GLOBAL_H */