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