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