Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
0002 /*
0003  * Copyright 2014-2016 Freescale Semiconductor Inc.
0004  * Copyright 2016 NXP
0005  *
0006  */
0007 #ifndef __FSL_DPAA2_FD_H
0008 #define __FSL_DPAA2_FD_H
0009 
0010 #include <linux/byteorder/generic.h>
0011 #include <linux/types.h>
0012 
0013 /**
0014  * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
0015  *
0016  * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
0017  * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed
0018  * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
0019  *
0020  * There are three types of frames: single, scatter gather, and frame lists.
0021  *
0022  * The set of APIs in this file must be used to create, manipulate and
0023  * query Frame Descriptors.
0024  */
0025 
0026 /**
0027  * struct dpaa2_fd - Struct describing FDs
0028  * @words:         for easier/faster copying the whole FD structure
0029  * @addr:          address in the FD
0030  * @len:           length in the FD
0031  * @bpid:          buffer pool ID
0032  * @format_offset: format, offset, and short-length fields
0033  * @frc:           frame context
0034  * @ctrl:          control bits...including dd, sc, va, err, etc
0035  * @flc:           flow context address
0036  *
0037  * This structure represents the basic Frame Descriptor used in the system.
0038  */
0039 struct dpaa2_fd {
0040     union {
0041         u32 words[8];
0042         struct dpaa2_fd_simple {
0043             __le64 addr;
0044             __le32 len;
0045             __le16 bpid;
0046             __le16 format_offset;
0047             __le32 frc;
0048             __le32 ctrl;
0049             __le64 flc;
0050         } simple;
0051     };
0052 };
0053 
0054 #define FD_SHORT_LEN_FLAG_MASK  0x1
0055 #define FD_SHORT_LEN_FLAG_SHIFT 14
0056 #define FD_SHORT_LEN_MASK   0x3FFFF
0057 #define FD_OFFSET_MASK      0x0FFF
0058 #define FD_FORMAT_MASK      0x3
0059 #define FD_FORMAT_SHIFT     12
0060 #define FD_BPID_MASK        0x3FFF
0061 #define SG_SHORT_LEN_FLAG_MASK  0x1
0062 #define SG_SHORT_LEN_FLAG_SHIFT 14
0063 #define SG_SHORT_LEN_MASK   0x1FFFF
0064 #define SG_OFFSET_MASK      0x0FFF
0065 #define SG_FORMAT_MASK      0x3
0066 #define SG_FORMAT_SHIFT     12
0067 #define SG_BPID_MASK        0x3FFF
0068 #define SG_FINAL_FLAG_MASK  0x1
0069 #define SG_FINAL_FLAG_SHIFT 15
0070 #define FL_SHORT_LEN_FLAG_MASK  0x1
0071 #define FL_SHORT_LEN_FLAG_SHIFT 14
0072 #define FL_SHORT_LEN_MASK   0x3FFFF
0073 #define FL_OFFSET_MASK      0x0FFF
0074 #define FL_FORMAT_MASK      0x3
0075 #define FL_FORMAT_SHIFT     12
0076 #define FL_BPID_MASK        0x3FFF
0077 #define FL_FINAL_FLAG_MASK  0x1
0078 #define FL_FINAL_FLAG_SHIFT 15
0079 
0080 /* Error bits in FD CTRL */
0081 #define FD_CTRL_ERR_MASK    0x000000FF
0082 #define FD_CTRL_UFD     0x00000004
0083 #define FD_CTRL_SBE     0x00000008
0084 #define FD_CTRL_FLC     0x00000010
0085 #define FD_CTRL_FSE     0x00000020
0086 #define FD_CTRL_FAERR       0x00000040
0087 
0088 /* Annotation bits in FD CTRL */
0089 #define FD_CTRL_PTA     0x00800000
0090 #define FD_CTRL_PTV1        0x00400000
0091 
0092 enum dpaa2_fd_format {
0093     dpaa2_fd_single = 0,
0094     dpaa2_fd_list,
0095     dpaa2_fd_sg
0096 };
0097 
0098 /**
0099  * dpaa2_fd_get_addr() - get the addr field of frame descriptor
0100  * @fd: the given frame descriptor
0101  *
0102  * Return the address in the frame descriptor.
0103  */
0104 static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
0105 {
0106     return (dma_addr_t)le64_to_cpu(fd->simple.addr);
0107 }
0108 
0109 /**
0110  * dpaa2_fd_set_addr() - Set the addr field of frame descriptor
0111  * @fd: the given frame descriptor
0112  * @addr: the address needs to be set in frame descriptor
0113  */
0114 static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
0115 {
0116     fd->simple.addr = cpu_to_le64(addr);
0117 }
0118 
0119 /**
0120  * dpaa2_fd_get_frc() - Get the frame context in the frame descriptor
0121  * @fd: the given frame descriptor
0122  *
0123  * Return the frame context field in the frame descriptor.
0124  */
0125 static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
0126 {
0127     return le32_to_cpu(fd->simple.frc);
0128 }
0129 
0130 /**
0131  * dpaa2_fd_set_frc() - Set the frame context in the frame descriptor
0132  * @fd: the given frame descriptor
0133  * @frc: the frame context needs to be set in frame descriptor
0134  */
0135 static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
0136 {
0137     fd->simple.frc = cpu_to_le32(frc);
0138 }
0139 
0140 /**
0141  * dpaa2_fd_get_ctrl() - Get the control bits in the frame descriptor
0142  * @fd: the given frame descriptor
0143  *
0144  * Return the control bits field in the frame descriptor.
0145  */
0146 static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
0147 {
0148     return le32_to_cpu(fd->simple.ctrl);
0149 }
0150 
0151 /**
0152  * dpaa2_fd_set_ctrl() - Set the control bits in the frame descriptor
0153  * @fd: the given frame descriptor
0154  * @ctrl: the control bits to be set in the frame descriptor
0155  */
0156 static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
0157 {
0158     fd->simple.ctrl = cpu_to_le32(ctrl);
0159 }
0160 
0161 /**
0162  * dpaa2_fd_get_flc() - Get the flow context in the frame descriptor
0163  * @fd: the given frame descriptor
0164  *
0165  * Return the flow context in the frame descriptor.
0166  */
0167 static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
0168 {
0169     return (dma_addr_t)le64_to_cpu(fd->simple.flc);
0170 }
0171 
0172 /**
0173  * dpaa2_fd_set_flc() - Set the flow context field of frame descriptor
0174  * @fd: the given frame descriptor
0175  * @flc_addr: the flow context needs to be set in frame descriptor
0176  */
0177 static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd,  dma_addr_t flc_addr)
0178 {
0179     fd->simple.flc = cpu_to_le64(flc_addr);
0180 }
0181 
0182 static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
0183 {
0184     return !!((le16_to_cpu(fd->simple.format_offset) >>
0185           FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
0186 }
0187 
0188 /**
0189  * dpaa2_fd_get_len() - Get the length in the frame descriptor
0190  * @fd: the given frame descriptor
0191  *
0192  * Return the length field in the frame descriptor.
0193  */
0194 static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
0195 {
0196     if (dpaa2_fd_short_len(fd))
0197         return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
0198 
0199     return le32_to_cpu(fd->simple.len);
0200 }
0201 
0202 /**
0203  * dpaa2_fd_set_len() - Set the length field of frame descriptor
0204  * @fd: the given frame descriptor
0205  * @len: the length needs to be set in frame descriptor
0206  */
0207 static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
0208 {
0209     fd->simple.len = cpu_to_le32(len);
0210 }
0211 
0212 /**
0213  * dpaa2_fd_get_offset() - Get the offset field in the frame descriptor
0214  * @fd: the given frame descriptor
0215  *
0216  * Return the offset.
0217  */
0218 static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
0219 {
0220     return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
0221 }
0222 
0223 /**
0224  * dpaa2_fd_set_offset() - Set the offset field of frame descriptor
0225  * @fd: the given frame descriptor
0226  * @offset: the offset needs to be set in frame descriptor
0227  */
0228 static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
0229 {
0230     fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
0231     fd->simple.format_offset |= cpu_to_le16(offset);
0232 }
0233 
0234 /**
0235  * dpaa2_fd_get_format() - Get the format field in the frame descriptor
0236  * @fd: the given frame descriptor
0237  *
0238  * Return the format.
0239  */
0240 static inline enum dpaa2_fd_format dpaa2_fd_get_format(
0241                         const struct dpaa2_fd *fd)
0242 {
0243     return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
0244                       >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
0245 }
0246 
0247 /**
0248  * dpaa2_fd_set_format() - Set the format field of frame descriptor
0249  * @fd: the given frame descriptor
0250  * @format: the format needs to be set in frame descriptor
0251  */
0252 static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
0253                        enum dpaa2_fd_format format)
0254 {
0255     fd->simple.format_offset &=
0256         cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
0257     fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
0258 }
0259 
0260 /**
0261  * dpaa2_fd_get_bpid() - Get the bpid field in the frame descriptor
0262  * @fd: the given frame descriptor
0263  *
0264  * Return the buffer pool id.
0265  */
0266 static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
0267 {
0268     return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
0269 }
0270 
0271 /**
0272  * dpaa2_fd_set_bpid() - Set the bpid field of frame descriptor
0273  * @fd: the given frame descriptor
0274  * @bpid: buffer pool id to be set
0275  */
0276 static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
0277 {
0278     fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
0279     fd->simple.bpid |= cpu_to_le16(bpid);
0280 }
0281 
0282 /**
0283  * struct dpaa2_sg_entry - the scatter-gathering structure
0284  * @addr: address of the sg entry
0285  * @len: length in this sg entry
0286  * @bpid: buffer pool id
0287  * @format_offset: format and offset fields
0288  */
0289 struct dpaa2_sg_entry {
0290     __le64 addr;
0291     __le32 len;
0292     __le16 bpid;
0293     __le16 format_offset;
0294 };
0295 
0296 enum dpaa2_sg_format {
0297     dpaa2_sg_single = 0,
0298     dpaa2_sg_frame_data,
0299     dpaa2_sg_sgt_ext
0300 };
0301 
0302 /* Accessors for SG entry fields */
0303 
0304 /**
0305  * dpaa2_sg_get_addr() - Get the address from SG entry
0306  * @sg: the given scatter-gathering object
0307  *
0308  * Return the address.
0309  */
0310 static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
0311 {
0312     return (dma_addr_t)le64_to_cpu(sg->addr);
0313 }
0314 
0315 /**
0316  * dpaa2_sg_set_addr() - Set the address in SG entry
0317  * @sg: the given scatter-gathering object
0318  * @addr: the address to be set
0319  */
0320 static inline void dpaa2_sg_set_addr(struct dpaa2_sg_entry *sg, dma_addr_t addr)
0321 {
0322     sg->addr = cpu_to_le64(addr);
0323 }
0324 
0325 static inline bool dpaa2_sg_short_len(const struct dpaa2_sg_entry *sg)
0326 {
0327     return !!((le16_to_cpu(sg->format_offset) >> SG_SHORT_LEN_FLAG_SHIFT)
0328         & SG_SHORT_LEN_FLAG_MASK);
0329 }
0330 
0331 /**
0332  * dpaa2_sg_get_len() - Get the length in SG entry
0333  * @sg: the given scatter-gathering object
0334  *
0335  * Return the length.
0336  */
0337 static inline u32 dpaa2_sg_get_len(const struct dpaa2_sg_entry *sg)
0338 {
0339     if (dpaa2_sg_short_len(sg))
0340         return le32_to_cpu(sg->len) & SG_SHORT_LEN_MASK;
0341 
0342     return le32_to_cpu(sg->len);
0343 }
0344 
0345 /**
0346  * dpaa2_sg_set_len() - Set the length in SG entry
0347  * @sg: the given scatter-gathering object
0348  * @len: the length to be set
0349  */
0350 static inline void dpaa2_sg_set_len(struct dpaa2_sg_entry *sg, u32 len)
0351 {
0352     sg->len = cpu_to_le32(len);
0353 }
0354 
0355 /**
0356  * dpaa2_sg_get_offset() - Get the offset in SG entry
0357  * @sg: the given scatter-gathering object
0358  *
0359  * Return the offset.
0360  */
0361 static inline u16 dpaa2_sg_get_offset(const struct dpaa2_sg_entry *sg)
0362 {
0363     return le16_to_cpu(sg->format_offset) & SG_OFFSET_MASK;
0364 }
0365 
0366 /**
0367  * dpaa2_sg_set_offset() - Set the offset in SG entry
0368  * @sg: the given scatter-gathering object
0369  * @offset: the offset to be set
0370  */
0371 static inline void dpaa2_sg_set_offset(struct dpaa2_sg_entry *sg,
0372                        u16 offset)
0373 {
0374     sg->format_offset &= cpu_to_le16(~SG_OFFSET_MASK);
0375     sg->format_offset |= cpu_to_le16(offset);
0376 }
0377 
0378 /**
0379  * dpaa2_sg_get_format() - Get the SG format in SG entry
0380  * @sg: the given scatter-gathering object
0381  *
0382  * Return the format.
0383  */
0384 static inline enum dpaa2_sg_format
0385     dpaa2_sg_get_format(const struct dpaa2_sg_entry *sg)
0386 {
0387     return (enum dpaa2_sg_format)((le16_to_cpu(sg->format_offset)
0388                        >> SG_FORMAT_SHIFT) & SG_FORMAT_MASK);
0389 }
0390 
0391 /**
0392  * dpaa2_sg_set_format() - Set the SG format in SG entry
0393  * @sg: the given scatter-gathering object
0394  * @format: the format to be set
0395  */
0396 static inline void dpaa2_sg_set_format(struct dpaa2_sg_entry *sg,
0397                        enum dpaa2_sg_format format)
0398 {
0399     sg->format_offset &= cpu_to_le16(~(SG_FORMAT_MASK << SG_FORMAT_SHIFT));
0400     sg->format_offset |= cpu_to_le16(format << SG_FORMAT_SHIFT);
0401 }
0402 
0403 /**
0404  * dpaa2_sg_get_bpid() - Get the buffer pool id in SG entry
0405  * @sg: the given scatter-gathering object
0406  *
0407  * Return the bpid.
0408  */
0409 static inline u16 dpaa2_sg_get_bpid(const struct dpaa2_sg_entry *sg)
0410 {
0411     return le16_to_cpu(sg->bpid) & SG_BPID_MASK;
0412 }
0413 
0414 /**
0415  * dpaa2_sg_set_bpid() - Set the buffer pool id in SG entry
0416  * @sg: the given scatter-gathering object
0417  * @bpid: the bpid to be set
0418  */
0419 static inline void dpaa2_sg_set_bpid(struct dpaa2_sg_entry *sg, u16 bpid)
0420 {
0421     sg->bpid &= cpu_to_le16(~(SG_BPID_MASK));
0422     sg->bpid |= cpu_to_le16(bpid);
0423 }
0424 
0425 /**
0426  * dpaa2_sg_is_final() - Check final bit in SG entry
0427  * @sg: the given scatter-gathering object
0428  *
0429  * Return bool.
0430  */
0431 static inline bool dpaa2_sg_is_final(const struct dpaa2_sg_entry *sg)
0432 {
0433     return !!(le16_to_cpu(sg->format_offset) >> SG_FINAL_FLAG_SHIFT);
0434 }
0435 
0436 /**
0437  * dpaa2_sg_set_final() - Set the final bit in SG entry
0438  * @sg: the given scatter-gathering object
0439  * @final: the final boolean to be set
0440  */
0441 static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
0442 {
0443     sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
0444                      << SG_FINAL_FLAG_SHIFT)) & 0xFFFF);
0445     sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
0446 }
0447 
0448 /**
0449  * struct dpaa2_fl_entry - structure for frame list entry.
0450  * @addr:          address in the FLE
0451  * @len:           length in the FLE
0452  * @bpid:          buffer pool ID
0453  * @format_offset: format, offset, and short-length fields
0454  * @frc:           frame context
0455  * @ctrl:          control bits...including pta, pvt1, pvt2, err, etc
0456  * @flc:           flow context address
0457  */
0458 struct dpaa2_fl_entry {
0459     __le64 addr;
0460     __le32 len;
0461     __le16 bpid;
0462     __le16 format_offset;
0463     __le32 frc;
0464     __le32 ctrl;
0465     __le64 flc;
0466 };
0467 
0468 enum dpaa2_fl_format {
0469     dpaa2_fl_single = 0,
0470     dpaa2_fl_res,
0471     dpaa2_fl_sg
0472 };
0473 
0474 /**
0475  * dpaa2_fl_get_addr() - get the addr field of FLE
0476  * @fle: the given frame list entry
0477  *
0478  * Return the address in the frame list entry.
0479  */
0480 static inline dma_addr_t dpaa2_fl_get_addr(const struct dpaa2_fl_entry *fle)
0481 {
0482     return (dma_addr_t)le64_to_cpu(fle->addr);
0483 }
0484 
0485 /**
0486  * dpaa2_fl_set_addr() - Set the addr field of FLE
0487  * @fle: the given frame list entry
0488  * @addr: the address needs to be set in frame list entry
0489  */
0490 static inline void dpaa2_fl_set_addr(struct dpaa2_fl_entry *fle,
0491                      dma_addr_t addr)
0492 {
0493     fle->addr = cpu_to_le64(addr);
0494 }
0495 
0496 /**
0497  * dpaa2_fl_get_frc() - Get the frame context in the FLE
0498  * @fle: the given frame list entry
0499  *
0500  * Return the frame context field in the frame lsit entry.
0501  */
0502 static inline u32 dpaa2_fl_get_frc(const struct dpaa2_fl_entry *fle)
0503 {
0504     return le32_to_cpu(fle->frc);
0505 }
0506 
0507 /**
0508  * dpaa2_fl_set_frc() - Set the frame context in the FLE
0509  * @fle: the given frame list entry
0510  * @frc: the frame context needs to be set in frame list entry
0511  */
0512 static inline void dpaa2_fl_set_frc(struct dpaa2_fl_entry *fle, u32 frc)
0513 {
0514     fle->frc = cpu_to_le32(frc);
0515 }
0516 
0517 /**
0518  * dpaa2_fl_get_ctrl() - Get the control bits in the FLE
0519  * @fle: the given frame list entry
0520  *
0521  * Return the control bits field in the frame list entry.
0522  */
0523 static inline u32 dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry *fle)
0524 {
0525     return le32_to_cpu(fle->ctrl);
0526 }
0527 
0528 /**
0529  * dpaa2_fl_set_ctrl() - Set the control bits in the FLE
0530  * @fle: the given frame list entry
0531  * @ctrl: the control bits to be set in the frame list entry
0532  */
0533 static inline void dpaa2_fl_set_ctrl(struct dpaa2_fl_entry *fle, u32 ctrl)
0534 {
0535     fle->ctrl = cpu_to_le32(ctrl);
0536 }
0537 
0538 /**
0539  * dpaa2_fl_get_flc() - Get the flow context in the FLE
0540  * @fle: the given frame list entry
0541  *
0542  * Return the flow context in the frame list entry.
0543  */
0544 static inline dma_addr_t dpaa2_fl_get_flc(const struct dpaa2_fl_entry *fle)
0545 {
0546     return (dma_addr_t)le64_to_cpu(fle->flc);
0547 }
0548 
0549 /**
0550  * dpaa2_fl_set_flc() - Set the flow context field of FLE
0551  * @fle: the given frame list entry
0552  * @flc_addr: the flow context needs to be set in frame list entry
0553  */
0554 static inline void dpaa2_fl_set_flc(struct dpaa2_fl_entry *fle,
0555                     dma_addr_t flc_addr)
0556 {
0557     fle->flc = cpu_to_le64(flc_addr);
0558 }
0559 
0560 static inline bool dpaa2_fl_short_len(const struct dpaa2_fl_entry *fle)
0561 {
0562     return !!((le16_to_cpu(fle->format_offset) >>
0563           FL_SHORT_LEN_FLAG_SHIFT) & FL_SHORT_LEN_FLAG_MASK);
0564 }
0565 
0566 /**
0567  * dpaa2_fl_get_len() - Get the length in the FLE
0568  * @fle: the given frame list entry
0569  *
0570  * Return the length field in the frame list entry.
0571  */
0572 static inline u32 dpaa2_fl_get_len(const struct dpaa2_fl_entry *fle)
0573 {
0574     if (dpaa2_fl_short_len(fle))
0575         return le32_to_cpu(fle->len) & FL_SHORT_LEN_MASK;
0576 
0577     return le32_to_cpu(fle->len);
0578 }
0579 
0580 /**
0581  * dpaa2_fl_set_len() - Set the length field of FLE
0582  * @fle: the given frame list entry
0583  * @len: the length needs to be set in frame list entry
0584  */
0585 static inline void dpaa2_fl_set_len(struct dpaa2_fl_entry *fle, u32 len)
0586 {
0587     fle->len = cpu_to_le32(len);
0588 }
0589 
0590 /**
0591  * dpaa2_fl_get_offset() - Get the offset field in the frame list entry
0592  * @fle: the given frame list entry
0593  *
0594  * Return the offset.
0595  */
0596 static inline u16 dpaa2_fl_get_offset(const struct dpaa2_fl_entry *fle)
0597 {
0598     return le16_to_cpu(fle->format_offset) & FL_OFFSET_MASK;
0599 }
0600 
0601 /**
0602  * dpaa2_fl_set_offset() - Set the offset field of FLE
0603  * @fle: the given frame list entry
0604  * @offset: the offset needs to be set in frame list entry
0605  */
0606 static inline void dpaa2_fl_set_offset(struct dpaa2_fl_entry *fle, u16 offset)
0607 {
0608     fle->format_offset &= cpu_to_le16(~FL_OFFSET_MASK);
0609     fle->format_offset |= cpu_to_le16(offset);
0610 }
0611 
0612 /**
0613  * dpaa2_fl_get_format() - Get the format field in the FLE
0614  * @fle: the given frame list entry
0615  *
0616  * Return the format.
0617  */
0618 static inline enum dpaa2_fl_format dpaa2_fl_get_format(const struct dpaa2_fl_entry *fle)
0619 {
0620     return (enum dpaa2_fl_format)((le16_to_cpu(fle->format_offset) >>
0621                        FL_FORMAT_SHIFT) & FL_FORMAT_MASK);
0622 }
0623 
0624 /**
0625  * dpaa2_fl_set_format() - Set the format field of FLE
0626  * @fle: the given frame list entry
0627  * @format: the format needs to be set in frame list entry
0628  */
0629 static inline void dpaa2_fl_set_format(struct dpaa2_fl_entry *fle,
0630                        enum dpaa2_fl_format format)
0631 {
0632     fle->format_offset &= cpu_to_le16(~(FL_FORMAT_MASK << FL_FORMAT_SHIFT));
0633     fle->format_offset |= cpu_to_le16(format << FL_FORMAT_SHIFT);
0634 }
0635 
0636 /**
0637  * dpaa2_fl_get_bpid() - Get the bpid field in the FLE
0638  * @fle: the given frame list entry
0639  *
0640  * Return the buffer pool id.
0641  */
0642 static inline u16 dpaa2_fl_get_bpid(const struct dpaa2_fl_entry *fle)
0643 {
0644     return le16_to_cpu(fle->bpid) & FL_BPID_MASK;
0645 }
0646 
0647 /**
0648  * dpaa2_fl_set_bpid() - Set the bpid field of FLE
0649  * @fle: the given frame list entry
0650  * @bpid: buffer pool id to be set
0651  */
0652 static inline void dpaa2_fl_set_bpid(struct dpaa2_fl_entry *fle, u16 bpid)
0653 {
0654     fle->bpid &= cpu_to_le16(~(FL_BPID_MASK));
0655     fle->bpid |= cpu_to_le16(bpid);
0656 }
0657 
0658 /**
0659  * dpaa2_fl_is_final() - Check final bit in FLE
0660  * @fle: the given frame list entry
0661  *
0662  * Return bool.
0663  */
0664 static inline bool dpaa2_fl_is_final(const struct dpaa2_fl_entry *fle)
0665 {
0666     return !!(le16_to_cpu(fle->format_offset) >> FL_FINAL_FLAG_SHIFT);
0667 }
0668 
0669 /**
0670  * dpaa2_fl_set_final() - Set the final bit in FLE
0671  * @fle: the given frame list entry
0672  * @final: the final boolean to be set
0673  */
0674 static inline void dpaa2_fl_set_final(struct dpaa2_fl_entry *fle, bool final)
0675 {
0676     fle->format_offset &= cpu_to_le16((~(FL_FINAL_FLAG_MASK <<
0677                          FL_FINAL_FLAG_SHIFT)) & 0xFFFF);
0678     fle->format_offset |= cpu_to_le16(final << FL_FINAL_FLAG_SHIFT);
0679 }
0680 
0681 #endif /* __FSL_DPAA2_FD_H */