lldesc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _ROM_LLDESC_H_
  7. #define _ROM_LLDESC_H_
  8. #include <stdint.h>
  9. #include "sys/queue.h"
  10. #include "esp_rom_lldesc.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #define LLDESC_TX_MBLK_SIZE 268 /* */
  15. #define LLDESC_RX_SMBLK_SIZE 64 /* small block size, for small mgmt frame */
  16. #define LLDESC_RX_MBLK_SIZE 524 /* rx is large sinec we want to contain mgmt frame in one block*/
  17. #define LLDESC_RX_AMPDU_ENTRY_MBLK_SIZE 64 /* it is a small buffer which is a cycle link*/
  18. #define LLDESC_RX_AMPDU_LEN_MBLK_SIZE 256 /*for ampdu entry*/
  19. #ifdef ESP_MAC_5
  20. #define LLDESC_TX_MBLK_NUM 116 /* 64K / 256 */
  21. #define LLDESC_RX_MBLK_NUM 82 /* 64K / 512 MAX 172*/
  22. #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4
  23. #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 12
  24. #else
  25. #ifdef SBUF_RXTX
  26. #define LLDESC_TX_MBLK_NUM_MAX (2 * 48) /* 23K / 260 - 8 */
  27. #define LLDESC_RX_MBLK_NUM_MAX (2 * 48) /* 23K / 524 */
  28. #define LLDESC_TX_MBLK_NUM_MIN (2 * 16) /* 23K / 260 - 8 */
  29. #define LLDESC_RX_MBLK_NUM_MIN (2 * 16) /* 23K / 524 */
  30. #endif
  31. #define LLDESC_TX_MBLK_NUM 10 //(2 * 32) /* 23K / 260 - 8 */
  32. #ifdef IEEE80211_RX_AMPDU
  33. #define LLDESC_RX_MBLK_NUM 30
  34. #else
  35. #define LLDESC_RX_MBLK_NUM 10
  36. #endif /*IEEE80211_RX_AMPDU*/
  37. #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4
  38. #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8
  39. #endif /* !ESP_MAC_5 */
  40. typedef struct tx_ampdu_entry_s{
  41. uint32_t sub_len :12,
  42. dili_num : 7,
  43. : 1,
  44. null_byte: 2,
  45. data : 1,
  46. enc : 1,
  47. seq : 8;
  48. } tx_ampdu_entry_t;
  49. typedef struct lldesc_chain_s {
  50. lldesc_t *head;
  51. lldesc_t *tail;
  52. } lldesc_chain_t;
  53. #ifdef SBUF_RXTX
  54. enum sbuf_mask_s {
  55. SBUF_MOVE_NO = 0,
  56. SBUF_MOVE_TX2RX,
  57. SBUF_MOVE_RX2TX,
  58. } ;
  59. #define SBUF_MOVE_STEP 8
  60. #endif
  61. #define LLDESC_SIZE sizeof(struct lldesc_s)
  62. /* SLC Descriptor */
  63. #define LLDESC_OWNER_MASK 0x80000000
  64. #define LLDESC_OWNER_SHIFT 31
  65. #define LLDESC_SW_OWNED 0
  66. #define LLDESC_HW_OWNED 1
  67. #define LLDESC_EOF_MASK 0x40000000
  68. #define LLDESC_EOF_SHIFT 30
  69. #define LLDESC_SOSF_MASK 0x20000000
  70. #define LLDESC_SOSF_SHIFT 29
  71. #define LLDESC_LENGTH_MASK 0x00fff000
  72. #define LLDESC_LENGTH_SHIFT 12
  73. #define LLDESC_SIZE_MASK 0x00000fff
  74. #define LLDESC_SIZE_SHIFT 0
  75. #define LLDESC_ADDR_MASK 0x000fffff
  76. void lldesc_build_chain(uint8_t *descptr, uint32_t desclen, uint8_t * mblkptr, uint32_t buflen, uint32_t blksz, uint8_t owner,
  77. lldesc_t **head,
  78. #ifdef TO_HOST_RESTART
  79. lldesc_t ** one_before_tail,
  80. #endif
  81. lldesc_t **tail);
  82. lldesc_t *lldesc_num2link(lldesc_t * head, uint16_t nblks);
  83. lldesc_t *lldesc_set_owner(lldesc_t * head, uint16_t nblks, uint8_t owner);
  84. static inline uint32_t lldesc_get_chain_length(lldesc_t *head)
  85. {
  86. lldesc_t *ds = head;
  87. uint32_t len = 0;
  88. while (ds) {
  89. len += ds->length;
  90. ds = STAILQ_NEXT(ds, qe);
  91. }
  92. return len;
  93. }
  94. static inline void lldesc_config(lldesc_t *ds, uint8_t owner, uint8_t eof, uint8_t sosf, uint16_t len)
  95. {
  96. ds->owner = owner;
  97. ds->eof = eof;
  98. ds->sosf = sosf;
  99. ds->length = len;
  100. }
  101. #define LLDESC_CONFIG(_desc, _owner, _eof, _sosf, _len) do { \
  102. (_desc)->owner = (_owner); \
  103. (_desc)->eof = (_eof); \
  104. (_desc)->sosf = (_sosf); \
  105. (_desc)->length = (_len); \
  106. } while(0)
  107. #define LLDESC_FROM_HOST_CLEANUP(ds) LLDESC_CONFIG((ds), LLDESC_HW_OWNED, 0, 0, 0)
  108. #define LLDESC_MAC_RX_CLEANUP(ds) LLDESC_CONFIG((ds), LLDESC_HW_OWNED, 0, 0, (ds)->size)
  109. #define LLDESC_TO_HOST_CLEANUP(ds) LLDESC_CONFIG((ds), LLDESC_HW_OWNED, 0, 0, 0)
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* _ROM_LLDESC_H_ */