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