0001
0002
0003
0004
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
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
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
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
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
0100
0101
0102
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
0111
0112
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
0121
0122
0123
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
0132
0133
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
0142
0143
0144
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
0153
0154
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
0163
0164
0165
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
0174
0175
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
0190
0191
0192
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
0204
0205
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
0214
0215
0216
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
0225
0226
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
0236
0237
0238
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
0249
0250
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
0262
0263
0264
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
0273
0274
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
0284
0285
0286
0287
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
0303
0304
0305
0306
0307
0308
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
0317
0318
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
0333
0334
0335
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
0347
0348
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
0357
0358
0359
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
0368
0369
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
0380
0381
0382
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
0393
0394
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
0405
0406
0407
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
0416
0417
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
0427
0428
0429
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
0438
0439
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
0450
0451
0452
0453
0454
0455
0456
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
0476
0477
0478
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
0487
0488
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
0498
0499
0500
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
0509
0510
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
0519
0520
0521
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
0530
0531
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
0540
0541
0542
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
0551
0552
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
0568
0569
0570
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
0582
0583
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
0592
0593
0594
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
0603
0604
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
0614
0615
0616
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
0626
0627
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
0638
0639
0640
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
0649
0650
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
0660
0661
0662
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
0671
0672
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