dpaa2-fd.h 18 KB

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