hif_rx.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/hif_rx.h#1
  3. */
  4. /*! \file "hif_rx.h"
  5. \brief Provide HIF RX Header Information between F/W and Driver
  6. N/A
  7. */
  8. /*
  9. ** Log: hif_rx.h
  10. *
  11. * 09 01 2010 kevin.huang
  12. * NULL
  13. * Use LINK LIST operation to process SCAN result
  14. *
  15. * 07 16 2010 yarco.yang
  16. *
  17. * 1. Support BSS Absence/Presence Event
  18. * 2. Support STA change PS mode Event
  19. * 3. Support BMC forwarding for AP mode.
  20. *
  21. * 07 08 2010 cp.wu
  22. *
  23. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  24. *
  25. * 06 14 2010 cp.wu
  26. * [WPD00003833][MT6620 and MT5931] Driver migration
  27. * follow-ups for HIF_RX_HEADER_T update:
  28. * 1) add TCL
  29. * 2) add RCPI
  30. * 3) add ChannelNumber
  31. *
  32. * 06 11 2010 cp.wu
  33. * [WPD00003833][MT6620 and MT5931] Driver migration
  34. * 1) migrate assoc.c.
  35. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  36. * 3) add configuration options for CNM_MEM and RSN modules
  37. * 4) add data path for management frames
  38. * 5) eliminate rPacketInfo of MSDU_INFO_T
  39. *
  40. * 06 09 2010 cp.wu
  41. * [WPD00003833][MT6620 and MT5931] Driver migration
  42. * add necessary changes to driver data paths.
  43. *
  44. * 06 06 2010 kevin.huang
  45. * [WPD00003832][MT6620 5931] Create driver base
  46. * [MT6620 5931] Create driver base
  47. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-12-10 16:44:00 GMT mtk02752
  48. ** code clean
  49. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-12-09 13:59:20 GMT MTK02468
  50. ** Added HIF_RX_HDR parsing macros
  51. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-11-24 19:54:54 GMT mtk02752
  52. ** adopt HIF_RX_HEADER_T in new data path
  53. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-10-29 19:51:19 GMT mtk01084
  54. ** modify FW/ driver interface
  55. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-28 10:33:58 GMT mtk01461
  56. ** Add define of HW_APPENED_LEN
  57. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-04-01 10:51:02 GMT mtk01461
  58. ** Rename ENUM_HIF_RX_PKT_TYPE_T
  59. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-19 12:05:03 GMT mtk01426
  60. ** Remove __KAL_ATTRIB_PACKED__ and add hifDataTypeCheck()
  61. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-17 20:18:52 GMT mtk01426
  62. ** Add comment to HIF_RX_HEADER_T
  63. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:16:23 GMT mtk01426
  64. ** Init for develop
  65. **
  66. */
  67. #ifndef _HIF_RX_H
  68. #define _HIF_RX_H
  69. /*******************************************************************************
  70. * C O M P I L E R F L A G S
  71. ********************************************************************************
  72. */
  73. /*******************************************************************************
  74. * E X T E R N A L R E F E R E N C E S
  75. ********************************************************************************
  76. */
  77. /*******************************************************************************
  78. * C O N S T A N T S
  79. ********************************************************************************
  80. */
  81. /*! HIF_RX_HEADER_T */
  82. /* DW 0, Byte 1 */
  83. #define HIF_RX_HDR_PACKET_TYPE_MASK BITS(0, 1)
  84. #define HIF_RX_HDR_SEC_MODE_MASK BITS(2, 5)
  85. #define HIF_RX_HDR_SEC_MODE_OFFSET 2
  86. /* DW 1, Byte 0 */
  87. #define HIF_RX_HDR_HEADER_LEN BITS(2, 7)
  88. #define HIF_RX_HDR_HEADER_LEN_OFFSET 2
  89. #define HIF_RX_HDR_HEADER_OFFSET_MASK BITS(0, 1)
  90. /* DW 1, Byte 1 */
  91. #define HIF_RX_HDR_80211_HEADER_FORMAT BIT(0)
  92. #define HIF_RX_HDR_DO_REORDER BIT(1)
  93. #define HIF_RX_HDR_PAL BIT(2)
  94. #define HIF_RX_HDR_TCL BIT(3)
  95. #define HIF_RX_HDR_NETWORK_IDX_MASK BITS(4, 7)
  96. #define HIF_RX_HDR_NETWORK_IDX_OFFSET 4
  97. /* DW 1, Byte 2, 3 */
  98. #define HIF_RX_HDR_SEQ_NO_MASK BITS(0, 11)
  99. #define HIF_RX_HDR_TID_MASK BITS(12, 14)
  100. #define HIF_RX_HDR_TID_OFFSET 12
  101. #define HIF_RX_HDR_BAR_FRAME BIT(15)
  102. #define HIF_RX_HDR_FLAG_AMP_WDS BIT(0)
  103. #define HIF_RX_HDR_FLAG_802_11_FORMAT BIT(1)
  104. #define HIF_RX_HDR_FLAG_BAR_FRAME BIT(2)
  105. #define HIF_RX_HDR_FLAG_DO_REORDERING BIT(3)
  106. #define HIF_RX_HDR_FLAG_CTRL_WARPPER_FRAME BIT(4)
  107. #define HIF_RX_HW_APPENDED_LEN 4
  108. /* For DW 2, Byte 3 - ucHwChannelNum */
  109. #define HW_CHNL_NUM_MAX_2G4 14
  110. #define HW_CHNL_NUM_MAX_4G_5G (255 - HW_CHNL_NUM_MAX_2G4)
  111. /*******************************************************************************
  112. * D A T A T Y P E S
  113. ********************************************************************************
  114. */
  115. typedef struct _HIF_RX_HEADER_T {
  116. UINT_16 u2PacketLen;
  117. UINT_16 u2PacketType;
  118. UINT_8 ucHerderLenOffset;
  119. UINT_8 uc80211_Reorder_PAL_TCL;
  120. UINT_16 u2SeqNoTid;
  121. UINT_8 ucStaRecIdx;
  122. UINT_8 ucRcpi;
  123. UINT_8 ucHwChannelNum;
  124. UINT_8 ucReserved;
  125. } HIF_RX_HEADER_T, *P_HIF_RX_HEADER_T;
  126. typedef enum _ENUM_HIF_RX_PKT_TYPE_T {
  127. HIF_RX_PKT_TYPE_DATA = 0,
  128. HIF_RX_PKT_TYPE_EVENT,
  129. HIF_RX_PKT_TYPE_TX_LOOPBACK,
  130. HIF_RX_PKT_TYPE_MANAGEMENT,
  131. HIF_RX_PKT_TYPE_NUM
  132. } ENUM_HIF_RX_PKT_TYPE_T, *P_ENUM_HIF_RX_PKT_TYPE_T;
  133. /*******************************************************************************
  134. * P U B L I C D A T A
  135. ********************************************************************************
  136. */
  137. /*******************************************************************************
  138. * P R I V A T E D A T A
  139. ********************************************************************************
  140. */
  141. /*******************************************************************************
  142. * M A C R O S
  143. ********************************************************************************
  144. */
  145. #define HIF_RX_HDR_SIZE sizeof(HIF_RX_HEADER_T)
  146. #define HIF_RX_HDR_GET_80211_FLAG(_prHifRxHdr) \
  147. (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_80211_HEADER_FORMAT) ? TRUE : FALSE))
  148. #define HIF_RX_HDR_GET_REORDER_FLAG(_prHifRxHdr) \
  149. (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_DO_REORDER) ? TRUE : FALSE))
  150. #define HIF_RX_HDR_GET_PAL_FLAG(_prHifRxHdr) \
  151. (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_PAL) ? TRUE : FALSE))
  152. #define HIF_RX_HDR_GET_TCL_FLAG(_prHifRxHdr) \
  153. (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_TCL) ? TRUE : FALSE))
  154. #define HIF_RX_HDR_GET_NETWORK_IDX(_prHifRxHdr) \
  155. ((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_NETWORK_IDX_MASK)\
  156. >> HIF_RX_HDR_NETWORK_IDX_OFFSET)
  157. #define HIF_RX_HDR_GET_SEC_MODE(_prHifRxHdr) \
  158. ((((_prHifRxHdr)->u2PacketType) & HIF_RX_HDR_SEC_MODE_MASK) >> HIF_RX_HDR_SEC_MODE_OFFSET)
  159. #define HIF_RX_HDR_GET_TID(_prHifRxHdr) \
  160. ((((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_TID_MASK)\
  161. >> HIF_RX_HDR_TID_OFFSET)
  162. #define HIF_RX_HDR_GET_SN(_prHifRxHdr) \
  163. (((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_SEQ_NO_MASK)
  164. #define HIF_RX_HDR_GET_BAR_FLAG(_prHifRxHdr) \
  165. (((((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_BAR_FRAME) ? TRUE : FALSE))
  166. #define HIF_RX_HDR_GET_CHNL_NUM(_prHifRxHdr) \
  167. ((((_prHifRxHdr)->ucHwChannelNum) > HW_CHNL_NUM_MAX_4G_5G) ? \
  168. (((_prHifRxHdr)->ucHwChannelNum) - HW_CHNL_NUM_MAX_4G_5G) : \
  169. ((_prHifRxHdr)->ucHwChannelNum))
  170. /* To do: support more bands other than 2.4G and 5G */
  171. #define HIF_RX_HDR_GET_RF_BAND(_prHifRxHdr) \
  172. ((((_prHifRxHdr)->ucHwChannelNum) <= HW_CHNL_NUM_MAX_2G4) ? \
  173. BAND_2G4 : BAND_5G)
  174. /*******************************************************************************
  175. * F U N C T I O N D E C L A R A T I O N S
  176. ********************************************************************************
  177. */
  178. static inline VOID hifDataTypeCheck(VOID);
  179. /*******************************************************************************
  180. * F U N C T I O N S
  181. ********************************************************************************
  182. */
  183. /* Kevin: we don't have to call following function to inspect the data structure.
  184. * It will check automatically while at compile time.
  185. * We'll need this for porting driver to different RTOS.
  186. */
  187. static inline VOID hifDataTypeCheck(VOID)
  188. {
  189. DATA_STRUCT_INSPECTING_ASSERT(sizeof(HIF_RX_HEADER_T) == 12);
  190. }
  191. #endif