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