xref: /OK3568_Linux_fs/kernel/include/soc/fsl/dpaa2-fd.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright 2014-2016 Freescale Semiconductor Inc.
4*4882a593Smuzhiyun  * Copyright 2016 NXP
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun #ifndef __FSL_DPAA2_FD_H
8*4882a593Smuzhiyun #define __FSL_DPAA2_FD_H
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /**
13*4882a593Smuzhiyun  * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
16*4882a593Smuzhiyun  * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed
17*4882a593Smuzhiyun  * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * There are three types of frames: single, scatter gather, and frame lists.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * The set of APIs in this file must be used to create, manipulate and
22*4882a593Smuzhiyun  * query Frame Descriptors.
23*4882a593Smuzhiyun  */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /**
26*4882a593Smuzhiyun  * struct dpaa2_fd - Struct describing FDs
27*4882a593Smuzhiyun  * @words:         for easier/faster copying the whole FD structure
28*4882a593Smuzhiyun  * @addr:          address in the FD
29*4882a593Smuzhiyun  * @len:           length in the FD
30*4882a593Smuzhiyun  * @bpid:          buffer pool ID
31*4882a593Smuzhiyun  * @format_offset: format, offset, and short-length fields
32*4882a593Smuzhiyun  * @frc:           frame context
33*4882a593Smuzhiyun  * @ctrl:          control bits...including dd, sc, va, err, etc
34*4882a593Smuzhiyun  * @flc:           flow context address
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * This structure represents the basic Frame Descriptor used in the system.
37*4882a593Smuzhiyun  */
38*4882a593Smuzhiyun struct dpaa2_fd {
39*4882a593Smuzhiyun 	union {
40*4882a593Smuzhiyun 		u32 words[8];
41*4882a593Smuzhiyun 		struct dpaa2_fd_simple {
42*4882a593Smuzhiyun 			__le64 addr;
43*4882a593Smuzhiyun 			__le32 len;
44*4882a593Smuzhiyun 			__le16 bpid;
45*4882a593Smuzhiyun 			__le16 format_offset;
46*4882a593Smuzhiyun 			__le32 frc;
47*4882a593Smuzhiyun 			__le32 ctrl;
48*4882a593Smuzhiyun 			__le64 flc;
49*4882a593Smuzhiyun 		} simple;
50*4882a593Smuzhiyun 	};
51*4882a593Smuzhiyun };
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #define FD_SHORT_LEN_FLAG_MASK	0x1
54*4882a593Smuzhiyun #define FD_SHORT_LEN_FLAG_SHIFT	14
55*4882a593Smuzhiyun #define FD_SHORT_LEN_MASK	0x3FFFF
56*4882a593Smuzhiyun #define FD_OFFSET_MASK		0x0FFF
57*4882a593Smuzhiyun #define FD_FORMAT_MASK		0x3
58*4882a593Smuzhiyun #define FD_FORMAT_SHIFT		12
59*4882a593Smuzhiyun #define FD_BPID_MASK		0x3FFF
60*4882a593Smuzhiyun #define SG_SHORT_LEN_FLAG_MASK	0x1
61*4882a593Smuzhiyun #define SG_SHORT_LEN_FLAG_SHIFT	14
62*4882a593Smuzhiyun #define SG_SHORT_LEN_MASK	0x1FFFF
63*4882a593Smuzhiyun #define SG_OFFSET_MASK		0x0FFF
64*4882a593Smuzhiyun #define SG_FORMAT_MASK		0x3
65*4882a593Smuzhiyun #define SG_FORMAT_SHIFT		12
66*4882a593Smuzhiyun #define SG_BPID_MASK		0x3FFF
67*4882a593Smuzhiyun #define SG_FINAL_FLAG_MASK	0x1
68*4882a593Smuzhiyun #define SG_FINAL_FLAG_SHIFT	15
69*4882a593Smuzhiyun #define FL_SHORT_LEN_FLAG_MASK	0x1
70*4882a593Smuzhiyun #define FL_SHORT_LEN_FLAG_SHIFT	14
71*4882a593Smuzhiyun #define FL_SHORT_LEN_MASK	0x3FFFF
72*4882a593Smuzhiyun #define FL_OFFSET_MASK		0x0FFF
73*4882a593Smuzhiyun #define FL_FORMAT_MASK		0x3
74*4882a593Smuzhiyun #define FL_FORMAT_SHIFT		12
75*4882a593Smuzhiyun #define FL_BPID_MASK		0x3FFF
76*4882a593Smuzhiyun #define FL_FINAL_FLAG_MASK	0x1
77*4882a593Smuzhiyun #define FL_FINAL_FLAG_SHIFT	15
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun /* Error bits in FD CTRL */
80*4882a593Smuzhiyun #define FD_CTRL_ERR_MASK	0x000000FF
81*4882a593Smuzhiyun #define FD_CTRL_UFD		0x00000004
82*4882a593Smuzhiyun #define FD_CTRL_SBE		0x00000008
83*4882a593Smuzhiyun #define FD_CTRL_FLC		0x00000010
84*4882a593Smuzhiyun #define FD_CTRL_FSE		0x00000020
85*4882a593Smuzhiyun #define FD_CTRL_FAERR		0x00000040
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun /* Annotation bits in FD CTRL */
88*4882a593Smuzhiyun #define FD_CTRL_PTA		0x00800000
89*4882a593Smuzhiyun #define FD_CTRL_PTV1		0x00400000
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun enum dpaa2_fd_format {
92*4882a593Smuzhiyun 	dpaa2_fd_single = 0,
93*4882a593Smuzhiyun 	dpaa2_fd_list,
94*4882a593Smuzhiyun 	dpaa2_fd_sg
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun /**
98*4882a593Smuzhiyun  * dpaa2_fd_get_addr() - get the addr field of frame descriptor
99*4882a593Smuzhiyun  * @fd: the given frame descriptor
100*4882a593Smuzhiyun  *
101*4882a593Smuzhiyun  * Return the address in the frame descriptor.
102*4882a593Smuzhiyun  */
dpaa2_fd_get_addr(const struct dpaa2_fd * fd)103*4882a593Smuzhiyun static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
104*4882a593Smuzhiyun {
105*4882a593Smuzhiyun 	return (dma_addr_t)le64_to_cpu(fd->simple.addr);
106*4882a593Smuzhiyun }
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun /**
109*4882a593Smuzhiyun  * dpaa2_fd_set_addr() - Set the addr field of frame descriptor
110*4882a593Smuzhiyun  * @fd: the given frame descriptor
111*4882a593Smuzhiyun  * @addr: the address needs to be set in frame descriptor
112*4882a593Smuzhiyun  */
dpaa2_fd_set_addr(struct dpaa2_fd * fd,dma_addr_t addr)113*4882a593Smuzhiyun static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
114*4882a593Smuzhiyun {
115*4882a593Smuzhiyun 	fd->simple.addr = cpu_to_le64(addr);
116*4882a593Smuzhiyun }
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun /**
119*4882a593Smuzhiyun  * dpaa2_fd_get_frc() - Get the frame context in the frame descriptor
120*4882a593Smuzhiyun  * @fd: the given frame descriptor
121*4882a593Smuzhiyun  *
122*4882a593Smuzhiyun  * Return the frame context field in the frame descriptor.
123*4882a593Smuzhiyun  */
dpaa2_fd_get_frc(const struct dpaa2_fd * fd)124*4882a593Smuzhiyun static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
125*4882a593Smuzhiyun {
126*4882a593Smuzhiyun 	return le32_to_cpu(fd->simple.frc);
127*4882a593Smuzhiyun }
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun /**
130*4882a593Smuzhiyun  * dpaa2_fd_set_frc() - Set the frame context in the frame descriptor
131*4882a593Smuzhiyun  * @fd: the given frame descriptor
132*4882a593Smuzhiyun  * @frc: the frame context needs to be set in frame descriptor
133*4882a593Smuzhiyun  */
dpaa2_fd_set_frc(struct dpaa2_fd * fd,u32 frc)134*4882a593Smuzhiyun static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
135*4882a593Smuzhiyun {
136*4882a593Smuzhiyun 	fd->simple.frc = cpu_to_le32(frc);
137*4882a593Smuzhiyun }
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun /**
140*4882a593Smuzhiyun  * dpaa2_fd_get_ctrl() - Get the control bits in the frame descriptor
141*4882a593Smuzhiyun  * @fd: the given frame descriptor
142*4882a593Smuzhiyun  *
143*4882a593Smuzhiyun  * Return the control bits field in the frame descriptor.
144*4882a593Smuzhiyun  */
dpaa2_fd_get_ctrl(const struct dpaa2_fd * fd)145*4882a593Smuzhiyun static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
146*4882a593Smuzhiyun {
147*4882a593Smuzhiyun 	return le32_to_cpu(fd->simple.ctrl);
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun /**
151*4882a593Smuzhiyun  * dpaa2_fd_set_ctrl() - Set the control bits in the frame descriptor
152*4882a593Smuzhiyun  * @fd: the given frame descriptor
153*4882a593Smuzhiyun  * @ctrl: the control bits to be set in the frame descriptor
154*4882a593Smuzhiyun  */
dpaa2_fd_set_ctrl(struct dpaa2_fd * fd,u32 ctrl)155*4882a593Smuzhiyun static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
156*4882a593Smuzhiyun {
157*4882a593Smuzhiyun 	fd->simple.ctrl = cpu_to_le32(ctrl);
158*4882a593Smuzhiyun }
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun /**
161*4882a593Smuzhiyun  * dpaa2_fd_get_flc() - Get the flow context in the frame descriptor
162*4882a593Smuzhiyun  * @fd: the given frame descriptor
163*4882a593Smuzhiyun  *
164*4882a593Smuzhiyun  * Return the flow context in the frame descriptor.
165*4882a593Smuzhiyun  */
dpaa2_fd_get_flc(const struct dpaa2_fd * fd)166*4882a593Smuzhiyun static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
167*4882a593Smuzhiyun {
168*4882a593Smuzhiyun 	return (dma_addr_t)le64_to_cpu(fd->simple.flc);
169*4882a593Smuzhiyun }
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun /**
172*4882a593Smuzhiyun  * dpaa2_fd_set_flc() - Set the flow context field of frame descriptor
173*4882a593Smuzhiyun  * @fd: the given frame descriptor
174*4882a593Smuzhiyun  * @flc_addr: the flow context needs to be set in frame descriptor
175*4882a593Smuzhiyun  */
dpaa2_fd_set_flc(struct dpaa2_fd * fd,dma_addr_t flc_addr)176*4882a593Smuzhiyun static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd,  dma_addr_t flc_addr)
177*4882a593Smuzhiyun {
178*4882a593Smuzhiyun 	fd->simple.flc = cpu_to_le64(flc_addr);
179*4882a593Smuzhiyun }
180*4882a593Smuzhiyun 
dpaa2_fd_short_len(const struct dpaa2_fd * fd)181*4882a593Smuzhiyun static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
182*4882a593Smuzhiyun {
183*4882a593Smuzhiyun 	return !!((le16_to_cpu(fd->simple.format_offset) >>
184*4882a593Smuzhiyun 		  FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun 
187*4882a593Smuzhiyun /**
188*4882a593Smuzhiyun  * dpaa2_fd_get_len() - Get the length in the frame descriptor
189*4882a593Smuzhiyun  * @fd: the given frame descriptor
190*4882a593Smuzhiyun  *
191*4882a593Smuzhiyun  * Return the length field in the frame descriptor.
192*4882a593Smuzhiyun  */
dpaa2_fd_get_len(const struct dpaa2_fd * fd)193*4882a593Smuzhiyun static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
194*4882a593Smuzhiyun {
195*4882a593Smuzhiyun 	if (dpaa2_fd_short_len(fd))
196*4882a593Smuzhiyun 		return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun 	return le32_to_cpu(fd->simple.len);
199*4882a593Smuzhiyun }
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun /**
202*4882a593Smuzhiyun  * dpaa2_fd_set_len() - Set the length field of frame descriptor
203*4882a593Smuzhiyun  * @fd: the given frame descriptor
204*4882a593Smuzhiyun  * @len: the length needs to be set in frame descriptor
205*4882a593Smuzhiyun  */
dpaa2_fd_set_len(struct dpaa2_fd * fd,u32 len)206*4882a593Smuzhiyun static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
207*4882a593Smuzhiyun {
208*4882a593Smuzhiyun 	fd->simple.len = cpu_to_le32(len);
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun /**
212*4882a593Smuzhiyun  * dpaa2_fd_get_offset() - Get the offset field in the frame descriptor
213*4882a593Smuzhiyun  * @fd: the given frame descriptor
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * Return the offset.
216*4882a593Smuzhiyun  */
dpaa2_fd_get_offset(const struct dpaa2_fd * fd)217*4882a593Smuzhiyun static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
218*4882a593Smuzhiyun {
219*4882a593Smuzhiyun 	return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
220*4882a593Smuzhiyun }
221*4882a593Smuzhiyun 
222*4882a593Smuzhiyun /**
223*4882a593Smuzhiyun  * dpaa2_fd_set_offset() - Set the offset field of frame descriptor
224*4882a593Smuzhiyun  * @fd: the given frame descriptor
225*4882a593Smuzhiyun  * @offset: the offset needs to be set in frame descriptor
226*4882a593Smuzhiyun  */
dpaa2_fd_set_offset(struct dpaa2_fd * fd,uint16_t offset)227*4882a593Smuzhiyun static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
228*4882a593Smuzhiyun {
229*4882a593Smuzhiyun 	fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
230*4882a593Smuzhiyun 	fd->simple.format_offset |= cpu_to_le16(offset);
231*4882a593Smuzhiyun }
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun /**
234*4882a593Smuzhiyun  * dpaa2_fd_get_format() - Get the format field in the frame descriptor
235*4882a593Smuzhiyun  * @fd: the given frame descriptor
236*4882a593Smuzhiyun  *
237*4882a593Smuzhiyun  * Return the format.
238*4882a593Smuzhiyun  */
dpaa2_fd_get_format(const struct dpaa2_fd * fd)239*4882a593Smuzhiyun static inline enum dpaa2_fd_format dpaa2_fd_get_format(
240*4882a593Smuzhiyun 						const struct dpaa2_fd *fd)
241*4882a593Smuzhiyun {
242*4882a593Smuzhiyun 	return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
243*4882a593Smuzhiyun 				      >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
244*4882a593Smuzhiyun }
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun /**
247*4882a593Smuzhiyun  * dpaa2_fd_set_format() - Set the format field of frame descriptor
248*4882a593Smuzhiyun  * @fd: the given frame descriptor
249*4882a593Smuzhiyun  * @format: the format needs to be set in frame descriptor
250*4882a593Smuzhiyun  */
dpaa2_fd_set_format(struct dpaa2_fd * fd,enum dpaa2_fd_format format)251*4882a593Smuzhiyun static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
252*4882a593Smuzhiyun 				       enum dpaa2_fd_format format)
253*4882a593Smuzhiyun {
254*4882a593Smuzhiyun 	fd->simple.format_offset &=
255*4882a593Smuzhiyun 		cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
256*4882a593Smuzhiyun 	fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
257*4882a593Smuzhiyun }
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun /**
260*4882a593Smuzhiyun  * dpaa2_fd_get_bpid() - Get the bpid field in the frame descriptor
261*4882a593Smuzhiyun  * @fd: the given frame descriptor
262*4882a593Smuzhiyun  *
263*4882a593Smuzhiyun  * Return the buffer pool id.
264*4882a593Smuzhiyun  */
dpaa2_fd_get_bpid(const struct dpaa2_fd * fd)265*4882a593Smuzhiyun static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
266*4882a593Smuzhiyun {
267*4882a593Smuzhiyun 	return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
268*4882a593Smuzhiyun }
269*4882a593Smuzhiyun 
270*4882a593Smuzhiyun /**
271*4882a593Smuzhiyun  * dpaa2_fd_set_bpid() - Set the bpid field of frame descriptor
272*4882a593Smuzhiyun  * @fd: the given frame descriptor
273*4882a593Smuzhiyun  * @bpid: buffer pool id to be set
274*4882a593Smuzhiyun  */
dpaa2_fd_set_bpid(struct dpaa2_fd * fd,uint16_t bpid)275*4882a593Smuzhiyun static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
276*4882a593Smuzhiyun {
277*4882a593Smuzhiyun 	fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
278*4882a593Smuzhiyun 	fd->simple.bpid |= cpu_to_le16(bpid);
279*4882a593Smuzhiyun }
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun /**
282*4882a593Smuzhiyun  * struct dpaa2_sg_entry - the scatter-gathering structure
283*4882a593Smuzhiyun  * @addr: address of the sg entry
284*4882a593Smuzhiyun  * @len: length in this sg entry
285*4882a593Smuzhiyun  * @bpid: buffer pool id
286*4882a593Smuzhiyun  * @format_offset: format and offset fields
287*4882a593Smuzhiyun  */
288*4882a593Smuzhiyun struct dpaa2_sg_entry {
289*4882a593Smuzhiyun 	__le64 addr;
290*4882a593Smuzhiyun 	__le32 len;
291*4882a593Smuzhiyun 	__le16 bpid;
292*4882a593Smuzhiyun 	__le16 format_offset;
293*4882a593Smuzhiyun };
294*4882a593Smuzhiyun 
295*4882a593Smuzhiyun enum dpaa2_sg_format {
296*4882a593Smuzhiyun 	dpaa2_sg_single = 0,
297*4882a593Smuzhiyun 	dpaa2_sg_frame_data,
298*4882a593Smuzhiyun 	dpaa2_sg_sgt_ext
299*4882a593Smuzhiyun };
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun /* Accessors for SG entry fields */
302*4882a593Smuzhiyun 
303*4882a593Smuzhiyun /**
304*4882a593Smuzhiyun  * dpaa2_sg_get_addr() - Get the address from SG entry
305*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
306*4882a593Smuzhiyun  *
307*4882a593Smuzhiyun  * Return the address.
308*4882a593Smuzhiyun  */
dpaa2_sg_get_addr(const struct dpaa2_sg_entry * sg)309*4882a593Smuzhiyun static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
310*4882a593Smuzhiyun {
311*4882a593Smuzhiyun 	return (dma_addr_t)le64_to_cpu(sg->addr);
312*4882a593Smuzhiyun }
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun /**
315*4882a593Smuzhiyun  * dpaa2_sg_set_addr() - Set the address in SG entry
316*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
317*4882a593Smuzhiyun  * @addr: the address to be set
318*4882a593Smuzhiyun  */
dpaa2_sg_set_addr(struct dpaa2_sg_entry * sg,dma_addr_t addr)319*4882a593Smuzhiyun static inline void dpaa2_sg_set_addr(struct dpaa2_sg_entry *sg, dma_addr_t addr)
320*4882a593Smuzhiyun {
321*4882a593Smuzhiyun 	sg->addr = cpu_to_le64(addr);
322*4882a593Smuzhiyun }
323*4882a593Smuzhiyun 
dpaa2_sg_short_len(const struct dpaa2_sg_entry * sg)324*4882a593Smuzhiyun static inline bool dpaa2_sg_short_len(const struct dpaa2_sg_entry *sg)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun 	return !!((le16_to_cpu(sg->format_offset) >> SG_SHORT_LEN_FLAG_SHIFT)
327*4882a593Smuzhiyun 		& SG_SHORT_LEN_FLAG_MASK);
328*4882a593Smuzhiyun }
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun /**
331*4882a593Smuzhiyun  * dpaa2_sg_get_len() - Get the length in SG entry
332*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
333*4882a593Smuzhiyun  *
334*4882a593Smuzhiyun  * Return the length.
335*4882a593Smuzhiyun  */
dpaa2_sg_get_len(const struct dpaa2_sg_entry * sg)336*4882a593Smuzhiyun static inline u32 dpaa2_sg_get_len(const struct dpaa2_sg_entry *sg)
337*4882a593Smuzhiyun {
338*4882a593Smuzhiyun 	if (dpaa2_sg_short_len(sg))
339*4882a593Smuzhiyun 		return le32_to_cpu(sg->len) & SG_SHORT_LEN_MASK;
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun 	return le32_to_cpu(sg->len);
342*4882a593Smuzhiyun }
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun /**
345*4882a593Smuzhiyun  * dpaa2_sg_set_len() - Set the length in SG entry
346*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
347*4882a593Smuzhiyun  * @len: the length to be set
348*4882a593Smuzhiyun  */
dpaa2_sg_set_len(struct dpaa2_sg_entry * sg,u32 len)349*4882a593Smuzhiyun static inline void dpaa2_sg_set_len(struct dpaa2_sg_entry *sg, u32 len)
350*4882a593Smuzhiyun {
351*4882a593Smuzhiyun 	sg->len = cpu_to_le32(len);
352*4882a593Smuzhiyun }
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun /**
355*4882a593Smuzhiyun  * dpaa2_sg_get_offset() - Get the offset in SG entry
356*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
357*4882a593Smuzhiyun  *
358*4882a593Smuzhiyun  * Return the offset.
359*4882a593Smuzhiyun  */
dpaa2_sg_get_offset(const struct dpaa2_sg_entry * sg)360*4882a593Smuzhiyun static inline u16 dpaa2_sg_get_offset(const struct dpaa2_sg_entry *sg)
361*4882a593Smuzhiyun {
362*4882a593Smuzhiyun 	return le16_to_cpu(sg->format_offset) & SG_OFFSET_MASK;
363*4882a593Smuzhiyun }
364*4882a593Smuzhiyun 
365*4882a593Smuzhiyun /**
366*4882a593Smuzhiyun  * dpaa2_sg_set_offset() - Set the offset in SG entry
367*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
368*4882a593Smuzhiyun  * @offset: the offset to be set
369*4882a593Smuzhiyun  */
dpaa2_sg_set_offset(struct dpaa2_sg_entry * sg,u16 offset)370*4882a593Smuzhiyun static inline void dpaa2_sg_set_offset(struct dpaa2_sg_entry *sg,
371*4882a593Smuzhiyun 				       u16 offset)
372*4882a593Smuzhiyun {
373*4882a593Smuzhiyun 	sg->format_offset &= cpu_to_le16(~SG_OFFSET_MASK);
374*4882a593Smuzhiyun 	sg->format_offset |= cpu_to_le16(offset);
375*4882a593Smuzhiyun }
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun /**
378*4882a593Smuzhiyun  * dpaa2_sg_get_format() - Get the SG format in SG entry
379*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
380*4882a593Smuzhiyun  *
381*4882a593Smuzhiyun  * Return the format.
382*4882a593Smuzhiyun  */
383*4882a593Smuzhiyun static inline enum dpaa2_sg_format
dpaa2_sg_get_format(const struct dpaa2_sg_entry * sg)384*4882a593Smuzhiyun 	dpaa2_sg_get_format(const struct dpaa2_sg_entry *sg)
385*4882a593Smuzhiyun {
386*4882a593Smuzhiyun 	return (enum dpaa2_sg_format)((le16_to_cpu(sg->format_offset)
387*4882a593Smuzhiyun 				       >> SG_FORMAT_SHIFT) & SG_FORMAT_MASK);
388*4882a593Smuzhiyun }
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun /**
391*4882a593Smuzhiyun  * dpaa2_sg_set_format() - Set the SG format in SG entry
392*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
393*4882a593Smuzhiyun  * @format: the format to be set
394*4882a593Smuzhiyun  */
dpaa2_sg_set_format(struct dpaa2_sg_entry * sg,enum dpaa2_sg_format format)395*4882a593Smuzhiyun static inline void dpaa2_sg_set_format(struct dpaa2_sg_entry *sg,
396*4882a593Smuzhiyun 				       enum dpaa2_sg_format format)
397*4882a593Smuzhiyun {
398*4882a593Smuzhiyun 	sg->format_offset &= cpu_to_le16(~(SG_FORMAT_MASK << SG_FORMAT_SHIFT));
399*4882a593Smuzhiyun 	sg->format_offset |= cpu_to_le16(format << SG_FORMAT_SHIFT);
400*4882a593Smuzhiyun }
401*4882a593Smuzhiyun 
402*4882a593Smuzhiyun /**
403*4882a593Smuzhiyun  * dpaa2_sg_get_bpid() - Get the buffer pool id in SG entry
404*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
405*4882a593Smuzhiyun  *
406*4882a593Smuzhiyun  * Return the bpid.
407*4882a593Smuzhiyun  */
dpaa2_sg_get_bpid(const struct dpaa2_sg_entry * sg)408*4882a593Smuzhiyun static inline u16 dpaa2_sg_get_bpid(const struct dpaa2_sg_entry *sg)
409*4882a593Smuzhiyun {
410*4882a593Smuzhiyun 	return le16_to_cpu(sg->bpid) & SG_BPID_MASK;
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun 
413*4882a593Smuzhiyun /**
414*4882a593Smuzhiyun  * dpaa2_sg_set_bpid() - Set the buffer pool id in SG entry
415*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
416*4882a593Smuzhiyun  * @bpid: the bpid to be set
417*4882a593Smuzhiyun  */
dpaa2_sg_set_bpid(struct dpaa2_sg_entry * sg,u16 bpid)418*4882a593Smuzhiyun static inline void dpaa2_sg_set_bpid(struct dpaa2_sg_entry *sg, u16 bpid)
419*4882a593Smuzhiyun {
420*4882a593Smuzhiyun 	sg->bpid &= cpu_to_le16(~(SG_BPID_MASK));
421*4882a593Smuzhiyun 	sg->bpid |= cpu_to_le16(bpid);
422*4882a593Smuzhiyun }
423*4882a593Smuzhiyun 
424*4882a593Smuzhiyun /**
425*4882a593Smuzhiyun  * dpaa2_sg_is_final() - Check final bit in SG entry
426*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
427*4882a593Smuzhiyun  *
428*4882a593Smuzhiyun  * Return bool.
429*4882a593Smuzhiyun  */
dpaa2_sg_is_final(const struct dpaa2_sg_entry * sg)430*4882a593Smuzhiyun static inline bool dpaa2_sg_is_final(const struct dpaa2_sg_entry *sg)
431*4882a593Smuzhiyun {
432*4882a593Smuzhiyun 	return !!(le16_to_cpu(sg->format_offset) >> SG_FINAL_FLAG_SHIFT);
433*4882a593Smuzhiyun }
434*4882a593Smuzhiyun 
435*4882a593Smuzhiyun /**
436*4882a593Smuzhiyun  * dpaa2_sg_set_final() - Set the final bit in SG entry
437*4882a593Smuzhiyun  * @sg: the given scatter-gathering object
438*4882a593Smuzhiyun  * @final: the final boolean to be set
439*4882a593Smuzhiyun  */
dpaa2_sg_set_final(struct dpaa2_sg_entry * sg,bool final)440*4882a593Smuzhiyun static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
441*4882a593Smuzhiyun {
442*4882a593Smuzhiyun 	sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
443*4882a593Smuzhiyun 					 << SG_FINAL_FLAG_SHIFT)) & 0xFFFF);
444*4882a593Smuzhiyun 	sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
445*4882a593Smuzhiyun }
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun /**
448*4882a593Smuzhiyun  * struct dpaa2_fl_entry - structure for frame list entry.
449*4882a593Smuzhiyun  * @addr:          address in the FLE
450*4882a593Smuzhiyun  * @len:           length in the FLE
451*4882a593Smuzhiyun  * @bpid:          buffer pool ID
452*4882a593Smuzhiyun  * @format_offset: format, offset, and short-length fields
453*4882a593Smuzhiyun  * @frc:           frame context
454*4882a593Smuzhiyun  * @ctrl:          control bits...including pta, pvt1, pvt2, err, etc
455*4882a593Smuzhiyun  * @flc:           flow context address
456*4882a593Smuzhiyun  */
457*4882a593Smuzhiyun struct dpaa2_fl_entry {
458*4882a593Smuzhiyun 	__le64 addr;
459*4882a593Smuzhiyun 	__le32 len;
460*4882a593Smuzhiyun 	__le16 bpid;
461*4882a593Smuzhiyun 	__le16 format_offset;
462*4882a593Smuzhiyun 	__le32 frc;
463*4882a593Smuzhiyun 	__le32 ctrl;
464*4882a593Smuzhiyun 	__le64 flc;
465*4882a593Smuzhiyun };
466*4882a593Smuzhiyun 
467*4882a593Smuzhiyun enum dpaa2_fl_format {
468*4882a593Smuzhiyun 	dpaa2_fl_single = 0,
469*4882a593Smuzhiyun 	dpaa2_fl_res,
470*4882a593Smuzhiyun 	dpaa2_fl_sg
471*4882a593Smuzhiyun };
472*4882a593Smuzhiyun 
473*4882a593Smuzhiyun /**
474*4882a593Smuzhiyun  * dpaa2_fl_get_addr() - get the addr field of FLE
475*4882a593Smuzhiyun  * @fle: the given frame list entry
476*4882a593Smuzhiyun  *
477*4882a593Smuzhiyun  * Return the address in the frame list entry.
478*4882a593Smuzhiyun  */
dpaa2_fl_get_addr(const struct dpaa2_fl_entry * fle)479*4882a593Smuzhiyun static inline dma_addr_t dpaa2_fl_get_addr(const struct dpaa2_fl_entry *fle)
480*4882a593Smuzhiyun {
481*4882a593Smuzhiyun 	return (dma_addr_t)le64_to_cpu(fle->addr);
482*4882a593Smuzhiyun }
483*4882a593Smuzhiyun 
484*4882a593Smuzhiyun /**
485*4882a593Smuzhiyun  * dpaa2_fl_set_addr() - Set the addr field of FLE
486*4882a593Smuzhiyun  * @fle: the given frame list entry
487*4882a593Smuzhiyun  * @addr: the address needs to be set in frame list entry
488*4882a593Smuzhiyun  */
dpaa2_fl_set_addr(struct dpaa2_fl_entry * fle,dma_addr_t addr)489*4882a593Smuzhiyun static inline void dpaa2_fl_set_addr(struct dpaa2_fl_entry *fle,
490*4882a593Smuzhiyun 				     dma_addr_t addr)
491*4882a593Smuzhiyun {
492*4882a593Smuzhiyun 	fle->addr = cpu_to_le64(addr);
493*4882a593Smuzhiyun }
494*4882a593Smuzhiyun 
495*4882a593Smuzhiyun /**
496*4882a593Smuzhiyun  * dpaa2_fl_get_frc() - Get the frame context in the FLE
497*4882a593Smuzhiyun  * @fle: the given frame list entry
498*4882a593Smuzhiyun  *
499*4882a593Smuzhiyun  * Return the frame context field in the frame lsit entry.
500*4882a593Smuzhiyun  */
dpaa2_fl_get_frc(const struct dpaa2_fl_entry * fle)501*4882a593Smuzhiyun static inline u32 dpaa2_fl_get_frc(const struct dpaa2_fl_entry *fle)
502*4882a593Smuzhiyun {
503*4882a593Smuzhiyun 	return le32_to_cpu(fle->frc);
504*4882a593Smuzhiyun }
505*4882a593Smuzhiyun 
506*4882a593Smuzhiyun /**
507*4882a593Smuzhiyun  * dpaa2_fl_set_frc() - Set the frame context in the FLE
508*4882a593Smuzhiyun  * @fle: the given frame list entry
509*4882a593Smuzhiyun  * @frc: the frame context needs to be set in frame list entry
510*4882a593Smuzhiyun  */
dpaa2_fl_set_frc(struct dpaa2_fl_entry * fle,u32 frc)511*4882a593Smuzhiyun static inline void dpaa2_fl_set_frc(struct dpaa2_fl_entry *fle, u32 frc)
512*4882a593Smuzhiyun {
513*4882a593Smuzhiyun 	fle->frc = cpu_to_le32(frc);
514*4882a593Smuzhiyun }
515*4882a593Smuzhiyun 
516*4882a593Smuzhiyun /**
517*4882a593Smuzhiyun  * dpaa2_fl_get_ctrl() - Get the control bits in the FLE
518*4882a593Smuzhiyun  * @fle: the given frame list entry
519*4882a593Smuzhiyun  *
520*4882a593Smuzhiyun  * Return the control bits field in the frame list entry.
521*4882a593Smuzhiyun  */
dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry * fle)522*4882a593Smuzhiyun static inline u32 dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry *fle)
523*4882a593Smuzhiyun {
524*4882a593Smuzhiyun 	return le32_to_cpu(fle->ctrl);
525*4882a593Smuzhiyun }
526*4882a593Smuzhiyun 
527*4882a593Smuzhiyun /**
528*4882a593Smuzhiyun  * dpaa2_fl_set_ctrl() - Set the control bits in the FLE
529*4882a593Smuzhiyun  * @fle: the given frame list entry
530*4882a593Smuzhiyun  * @ctrl: the control bits to be set in the frame list entry
531*4882a593Smuzhiyun  */
dpaa2_fl_set_ctrl(struct dpaa2_fl_entry * fle,u32 ctrl)532*4882a593Smuzhiyun static inline void dpaa2_fl_set_ctrl(struct dpaa2_fl_entry *fle, u32 ctrl)
533*4882a593Smuzhiyun {
534*4882a593Smuzhiyun 	fle->ctrl = cpu_to_le32(ctrl);
535*4882a593Smuzhiyun }
536*4882a593Smuzhiyun 
537*4882a593Smuzhiyun /**
538*4882a593Smuzhiyun  * dpaa2_fl_get_flc() - Get the flow context in the FLE
539*4882a593Smuzhiyun  * @fle: the given frame list entry
540*4882a593Smuzhiyun  *
541*4882a593Smuzhiyun  * Return the flow context in the frame list entry.
542*4882a593Smuzhiyun  */
dpaa2_fl_get_flc(const struct dpaa2_fl_entry * fle)543*4882a593Smuzhiyun static inline dma_addr_t dpaa2_fl_get_flc(const struct dpaa2_fl_entry *fle)
544*4882a593Smuzhiyun {
545*4882a593Smuzhiyun 	return (dma_addr_t)le64_to_cpu(fle->flc);
546*4882a593Smuzhiyun }
547*4882a593Smuzhiyun 
548*4882a593Smuzhiyun /**
549*4882a593Smuzhiyun  * dpaa2_fl_set_flc() - Set the flow context field of FLE
550*4882a593Smuzhiyun  * @fle: the given frame list entry
551*4882a593Smuzhiyun  * @flc_addr: the flow context needs to be set in frame list entry
552*4882a593Smuzhiyun  */
dpaa2_fl_set_flc(struct dpaa2_fl_entry * fle,dma_addr_t flc_addr)553*4882a593Smuzhiyun static inline void dpaa2_fl_set_flc(struct dpaa2_fl_entry *fle,
554*4882a593Smuzhiyun 				    dma_addr_t flc_addr)
555*4882a593Smuzhiyun {
556*4882a593Smuzhiyun 	fle->flc = cpu_to_le64(flc_addr);
557*4882a593Smuzhiyun }
558*4882a593Smuzhiyun 
dpaa2_fl_short_len(const struct dpaa2_fl_entry * fle)559*4882a593Smuzhiyun static inline bool dpaa2_fl_short_len(const struct dpaa2_fl_entry *fle)
560*4882a593Smuzhiyun {
561*4882a593Smuzhiyun 	return !!((le16_to_cpu(fle->format_offset) >>
562*4882a593Smuzhiyun 		  FL_SHORT_LEN_FLAG_SHIFT) & FL_SHORT_LEN_FLAG_MASK);
563*4882a593Smuzhiyun }
564*4882a593Smuzhiyun 
565*4882a593Smuzhiyun /**
566*4882a593Smuzhiyun  * dpaa2_fl_get_len() - Get the length in the FLE
567*4882a593Smuzhiyun  * @fle: the given frame list entry
568*4882a593Smuzhiyun  *
569*4882a593Smuzhiyun  * Return the length field in the frame list entry.
570*4882a593Smuzhiyun  */
dpaa2_fl_get_len(const struct dpaa2_fl_entry * fle)571*4882a593Smuzhiyun static inline u32 dpaa2_fl_get_len(const struct dpaa2_fl_entry *fle)
572*4882a593Smuzhiyun {
573*4882a593Smuzhiyun 	if (dpaa2_fl_short_len(fle))
574*4882a593Smuzhiyun 		return le32_to_cpu(fle->len) & FL_SHORT_LEN_MASK;
575*4882a593Smuzhiyun 
576*4882a593Smuzhiyun 	return le32_to_cpu(fle->len);
577*4882a593Smuzhiyun }
578*4882a593Smuzhiyun 
579*4882a593Smuzhiyun /**
580*4882a593Smuzhiyun  * dpaa2_fl_set_len() - Set the length field of FLE
581*4882a593Smuzhiyun  * @fle: the given frame list entry
582*4882a593Smuzhiyun  * @len: the length needs to be set in frame list entry
583*4882a593Smuzhiyun  */
dpaa2_fl_set_len(struct dpaa2_fl_entry * fle,u32 len)584*4882a593Smuzhiyun static inline void dpaa2_fl_set_len(struct dpaa2_fl_entry *fle, u32 len)
585*4882a593Smuzhiyun {
586*4882a593Smuzhiyun 	fle->len = cpu_to_le32(len);
587*4882a593Smuzhiyun }
588*4882a593Smuzhiyun 
589*4882a593Smuzhiyun /**
590*4882a593Smuzhiyun  * dpaa2_fl_get_offset() - Get the offset field in the frame list entry
591*4882a593Smuzhiyun  * @fle: the given frame list entry
592*4882a593Smuzhiyun  *
593*4882a593Smuzhiyun  * Return the offset.
594*4882a593Smuzhiyun  */
dpaa2_fl_get_offset(const struct dpaa2_fl_entry * fle)595*4882a593Smuzhiyun static inline u16 dpaa2_fl_get_offset(const struct dpaa2_fl_entry *fle)
596*4882a593Smuzhiyun {
597*4882a593Smuzhiyun 	return le16_to_cpu(fle->format_offset) & FL_OFFSET_MASK;
598*4882a593Smuzhiyun }
599*4882a593Smuzhiyun 
600*4882a593Smuzhiyun /**
601*4882a593Smuzhiyun  * dpaa2_fl_set_offset() - Set the offset field of FLE
602*4882a593Smuzhiyun  * @fle: the given frame list entry
603*4882a593Smuzhiyun  * @offset: the offset needs to be set in frame list entry
604*4882a593Smuzhiyun  */
dpaa2_fl_set_offset(struct dpaa2_fl_entry * fle,u16 offset)605*4882a593Smuzhiyun static inline void dpaa2_fl_set_offset(struct dpaa2_fl_entry *fle, u16 offset)
606*4882a593Smuzhiyun {
607*4882a593Smuzhiyun 	fle->format_offset &= cpu_to_le16(~FL_OFFSET_MASK);
608*4882a593Smuzhiyun 	fle->format_offset |= cpu_to_le16(offset);
609*4882a593Smuzhiyun }
610*4882a593Smuzhiyun 
611*4882a593Smuzhiyun /**
612*4882a593Smuzhiyun  * dpaa2_fl_get_format() - Get the format field in the FLE
613*4882a593Smuzhiyun  * @fle: the given frame list entry
614*4882a593Smuzhiyun  *
615*4882a593Smuzhiyun  * Return the format.
616*4882a593Smuzhiyun  */
dpaa2_fl_get_format(const struct dpaa2_fl_entry * fle)617*4882a593Smuzhiyun static inline enum dpaa2_fl_format dpaa2_fl_get_format(const struct dpaa2_fl_entry *fle)
618*4882a593Smuzhiyun {
619*4882a593Smuzhiyun 	return (enum dpaa2_fl_format)((le16_to_cpu(fle->format_offset) >>
620*4882a593Smuzhiyun 				       FL_FORMAT_SHIFT) & FL_FORMAT_MASK);
621*4882a593Smuzhiyun }
622*4882a593Smuzhiyun 
623*4882a593Smuzhiyun /**
624*4882a593Smuzhiyun  * dpaa2_fl_set_format() - Set the format field of FLE
625*4882a593Smuzhiyun  * @fle: the given frame list entry
626*4882a593Smuzhiyun  * @format: the format needs to be set in frame list entry
627*4882a593Smuzhiyun  */
dpaa2_fl_set_format(struct dpaa2_fl_entry * fle,enum dpaa2_fl_format format)628*4882a593Smuzhiyun static inline void dpaa2_fl_set_format(struct dpaa2_fl_entry *fle,
629*4882a593Smuzhiyun 				       enum dpaa2_fl_format format)
630*4882a593Smuzhiyun {
631*4882a593Smuzhiyun 	fle->format_offset &= cpu_to_le16(~(FL_FORMAT_MASK << FL_FORMAT_SHIFT));
632*4882a593Smuzhiyun 	fle->format_offset |= cpu_to_le16(format << FL_FORMAT_SHIFT);
633*4882a593Smuzhiyun }
634*4882a593Smuzhiyun 
635*4882a593Smuzhiyun /**
636*4882a593Smuzhiyun  * dpaa2_fl_get_bpid() - Get the bpid field in the FLE
637*4882a593Smuzhiyun  * @fle: the given frame list entry
638*4882a593Smuzhiyun  *
639*4882a593Smuzhiyun  * Return the buffer pool id.
640*4882a593Smuzhiyun  */
dpaa2_fl_get_bpid(const struct dpaa2_fl_entry * fle)641*4882a593Smuzhiyun static inline u16 dpaa2_fl_get_bpid(const struct dpaa2_fl_entry *fle)
642*4882a593Smuzhiyun {
643*4882a593Smuzhiyun 	return le16_to_cpu(fle->bpid) & FL_BPID_MASK;
644*4882a593Smuzhiyun }
645*4882a593Smuzhiyun 
646*4882a593Smuzhiyun /**
647*4882a593Smuzhiyun  * dpaa2_fl_set_bpid() - Set the bpid field of FLE
648*4882a593Smuzhiyun  * @fle: the given frame list entry
649*4882a593Smuzhiyun  * @bpid: buffer pool id to be set
650*4882a593Smuzhiyun  */
dpaa2_fl_set_bpid(struct dpaa2_fl_entry * fle,u16 bpid)651*4882a593Smuzhiyun static inline void dpaa2_fl_set_bpid(struct dpaa2_fl_entry *fle, u16 bpid)
652*4882a593Smuzhiyun {
653*4882a593Smuzhiyun 	fle->bpid &= cpu_to_le16(~(FL_BPID_MASK));
654*4882a593Smuzhiyun 	fle->bpid |= cpu_to_le16(bpid);
655*4882a593Smuzhiyun }
656*4882a593Smuzhiyun 
657*4882a593Smuzhiyun /**
658*4882a593Smuzhiyun  * dpaa2_fl_is_final() - Check final bit in FLE
659*4882a593Smuzhiyun  * @fle: the given frame list entry
660*4882a593Smuzhiyun  *
661*4882a593Smuzhiyun  * Return bool.
662*4882a593Smuzhiyun  */
dpaa2_fl_is_final(const struct dpaa2_fl_entry * fle)663*4882a593Smuzhiyun static inline bool dpaa2_fl_is_final(const struct dpaa2_fl_entry *fle)
664*4882a593Smuzhiyun {
665*4882a593Smuzhiyun 	return !!(le16_to_cpu(fle->format_offset) >> FL_FINAL_FLAG_SHIFT);
666*4882a593Smuzhiyun }
667*4882a593Smuzhiyun 
668*4882a593Smuzhiyun /**
669*4882a593Smuzhiyun  * dpaa2_fl_set_final() - Set the final bit in FLE
670*4882a593Smuzhiyun  * @fle: the given frame list entry
671*4882a593Smuzhiyun  * @final: the final boolean to be set
672*4882a593Smuzhiyun  */
dpaa2_fl_set_final(struct dpaa2_fl_entry * fle,bool final)673*4882a593Smuzhiyun static inline void dpaa2_fl_set_final(struct dpaa2_fl_entry *fle, bool final)
674*4882a593Smuzhiyun {
675*4882a593Smuzhiyun 	fle->format_offset &= cpu_to_le16((~(FL_FINAL_FLAG_MASK <<
676*4882a593Smuzhiyun 					     FL_FINAL_FLAG_SHIFT)) & 0xFFFF);
677*4882a593Smuzhiyun 	fle->format_offset |= cpu_to_le16(final << FL_FINAL_FLAG_SHIFT);
678*4882a593Smuzhiyun }
679*4882a593Smuzhiyun 
680*4882a593Smuzhiyun #endif /* __FSL_DPAA2_FD_H */
681