2 * Copyright 2014-2016 Freescale Semiconductor Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Freescale Semiconductor nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef __FSL_DPAA2_GLOBAL_H
33 #define __FSL_DPAA2_GLOBAL_H
35 #include <linux/types.h>
36 #include <linux/cpumask.h>
70 /* Parsing frame dequeue results */
72 #define DPAA2_DQ_STAT_FQEMPTY 0x80
74 #define DPAA2_DQ_STAT_HELDACTIVE 0x40
75 /* FQ force eligible */
76 #define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
78 #define DPAA2_DQ_STAT_VALIDFRAME 0x10
80 #define DPAA2_DQ_STAT_ODPVALID 0x04
81 /* volatile dequeue */
82 #define DPAA2_DQ_STAT_VOLATILE 0x02
83 /* volatile dequeue command is expired */
84 #define DPAA2_DQ_STAT_EXPIRED 0x01
86 #define DQ_FQID_MASK 0x00FFFFFF
87 #define DQ_FRAME_COUNT_MASK 0x00FFFFFF
90 * dpaa2_dq_flags() - Get the stat field of dequeue response
91 * @dq: the dequeue result.
93 static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
99 * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
101 * @dq: the dequeue result
103 * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
105 static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
107 return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
111 * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
112 * @dq: the dequeue result
116 static inline bool dpaa2_dq_is_pull_complete(const struct dpaa2_dq *dq)
118 return !!(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_EXPIRED);
122 * dpaa2_dq_seqnum() - Get the seqnum field in dequeue response
123 * @dq: the dequeue result
125 * seqnum is valid only if VALIDFRAME flag is TRUE
129 static inline u16 dpaa2_dq_seqnum(const struct dpaa2_dq *dq)
131 return le16_to_cpu(dq->dq.seqnum);
135 * dpaa2_dq_odpid() - Get the odpid field in dequeue response
136 * @dq: the dequeue result
138 * odpid is valid only if ODPVALID flag is TRUE.
142 static inline u16 dpaa2_dq_odpid(const struct dpaa2_dq *dq)
144 return le16_to_cpu(dq->dq.oprid);
148 * dpaa2_dq_fqid() - Get the fqid in dequeue response
149 * @dq: the dequeue result
153 static inline u32 dpaa2_dq_fqid(const struct dpaa2_dq *dq)
155 return le32_to_cpu(dq->dq.fqid) & DQ_FQID_MASK;
159 * dpaa2_dq_byte_count() - Get the byte count in dequeue response
160 * @dq: the dequeue result
162 * Return the byte count remaining in the FQ.
164 static inline u32 dpaa2_dq_byte_count(const struct dpaa2_dq *dq)
166 return le32_to_cpu(dq->dq.fq_byte_cnt);
170 * dpaa2_dq_frame_count() - Get the frame count in dequeue response
171 * @dq: the dequeue result
173 * Return the frame count remaining in the FQ.
175 static inline u32 dpaa2_dq_frame_count(const struct dpaa2_dq *dq)
177 return le32_to_cpu(dq->dq.fq_frm_cnt) & DQ_FRAME_COUNT_MASK;
181 * dpaa2_dq_fd_ctx() - Get the frame queue context in dequeue response
182 * @dq: the dequeue result
184 * Return the frame queue context.
186 static inline u64 dpaa2_dq_fqd_ctx(const struct dpaa2_dq *dq)
188 return le64_to_cpu(dq->dq.fqd_ctx);
192 * dpaa2_dq_fd() - Get the frame descriptor in dequeue response
193 * @dq: the dequeue result
195 * Return the frame descriptor.
197 static inline const struct dpaa2_fd *dpaa2_dq_fd(const struct dpaa2_dq *dq)
199 return (const struct dpaa2_fd *)&dq->dq.fd[0];
202 #endif /* __FSL_DPAA2_GLOBAL_H */