support different wifi bt chip auto compatible
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / combo_mt66xx / mt6620 / 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
93 // DW 1, Byte 0
94 #define HIF_RX_HDR_HEADER_LEN            BITS(2,7)
95 #define HIF_RX_HDR_HEADER_LEN_OFFSET     2
96 #define HIF_RX_HDR_HEADER_OFFSET_MASK    BITS(0,1)
97
98 // DW 1, Byte 1
99 #define HIF_RX_HDR_80211_HEADER_FORMAT   BIT(0)
100 #define HIF_RX_HDR_DO_REORDER            BIT(1)
101 #define HIF_RX_HDR_PAL                   BIT(2)
102 #define HIF_RX_HDR_TCL                   BIT(3)
103 #define HIF_RX_HDR_NETWORK_IDX_MASK      BITS(4,7)
104 #define HIF_RX_HDR_NETWORK_IDX_OFFSET    4
105
106 // DW 1, Byte 2, 3
107 #define HIF_RX_HDR_SEQ_NO_MASK           BITS(0,11)
108 #define HIF_RX_HDR_TID_MASK              BITS(12,14)
109 #define HIF_RX_HDR_TID_OFFSET            12
110 #define HIF_RX_HDR_BAR_FRAME             BIT(15)
111
112
113
114 #define HIF_RX_HDR_FLAG_AMP_WDS             BIT(0)
115 #define HIF_RX_HDR_FLAG_802_11_FORMAT       BIT(1)
116 #define HIF_RX_HDR_FLAG_BAR_FRAME           BIT(2)
117 #define HIF_RX_HDR_FLAG_DO_REORDERING       BIT(3)
118 #define HIF_RX_HDR_FLAG_CTRL_WARPPER_FRAME  BIT(4)
119
120 #define HIF_RX_HW_APPENDED_LEN              4
121
122 // For DW 2, Byte 3 - ucHwChannelNum
123 #define HW_CHNL_NUM_MAX_2G4                 14
124 #define HW_CHNL_NUM_MAX_4G_5G               (255 - HW_CHNL_NUM_MAX_2G4)
125
126 /*******************************************************************************
127 *                         D A T A   T Y P E S
128 ********************************************************************************
129 */
130
131 typedef struct _HIF_RX_HEADER_T {
132     UINT_16    u2PacketLen;
133     UINT_16    u2PacketType;
134     UINT_8     ucHerderLenOffset;
135     UINT_8     uc80211_Reorder_PAL_TCL;
136     UINT_16    u2SeqNoTid;
137     UINT_8     ucStaRecIdx;
138     UINT_8     ucRcpi;
139     UINT_8     ucHwChannelNum;
140     UINT_8     ucReserved;
141 }  HIF_RX_HEADER_T, *P_HIF_RX_HEADER_T;
142
143 typedef enum _ENUM_HIF_RX_PKT_TYPE_T {
144     HIF_RX_PKT_TYPE_DATA = 0,
145     HIF_RX_PKT_TYPE_EVENT,
146     HIF_RX_PKT_TYPE_TX_LOOPBACK,
147     HIF_RX_PKT_TYPE_MANAGEMENT,
148     HIF_RX_PKT_TYPE_NUM
149 } ENUM_HIF_RX_PKT_TYPE_T, *P_ENUM_HIF_RX_PKT_TYPE_T;
150
151 /*******************************************************************************
152 *                            P U B L I C   D A T A
153 ********************************************************************************
154 */
155
156 /*******************************************************************************
157 *                           P R I V A T E   D A T A
158 ********************************************************************************
159 */
160
161 /*******************************************************************************
162 *                                 M A C R O S
163 ********************************************************************************
164 */
165 #define HIF_RX_HDR_SIZE        sizeof(HIF_RX_HEADER_T)
166
167 #define HIF_RX_HDR_GET_80211_FLAG(_prHifRxHdr) \
168     (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_80211_HEADER_FORMAT) ? TRUE : FALSE))
169 #define HIF_RX_HDR_GET_REORDER_FLAG(_prHifRxHdr) \
170     (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_DO_REORDER) ? TRUE : FALSE))
171 #define HIF_RX_HDR_GET_PAL_FLAG(_prHifRxHdr) \
172     (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_PAL) ? TRUE : FALSE))
173 #define HIF_RX_HDR_GET_TCL_FLAG(_prHifRxHdr) \
174     (((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_TCL) ? TRUE : FALSE))
175 #define HIF_RX_HDR_GET_NETWORK_IDX(_prHifRxHdr) \
176     ((((_prHifRxHdr)->uc80211_Reorder_PAL_TCL) & HIF_RX_HDR_NETWORK_IDX_MASK)\
177     >> HIF_RX_HDR_NETWORK_IDX_OFFSET)
178
179
180 #define HIF_RX_HDR_GET_TID(_prHifRxHdr) \
181     ((((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_TID_MASK)\
182     >> HIF_RX_HDR_TID_OFFSET)
183 #define HIF_RX_HDR_GET_SN(_prHifRxHdr) \
184     (((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_SEQ_NO_MASK)
185 #define HIF_RX_HDR_GET_BAR_FLAG(_prHifRxHdr) \
186     (((((_prHifRxHdr)->u2SeqNoTid) & HIF_RX_HDR_BAR_FRAME)? TRUE: FALSE))
187
188
189 #define HIF_RX_HDR_GET_CHNL_NUM(_prHifRxHdr) \
190     ( ( ((_prHifRxHdr)->ucHwChannelNum) > HW_CHNL_NUM_MAX_4G_5G ) ? \
191       ( ((_prHifRxHdr)->ucHwChannelNum) - HW_CHNL_NUM_MAX_4G_5G ) : \
192       ((_prHifRxHdr)->ucHwChannelNum) )
193
194 /* To do: support more bands other than 2.4G and 5G */
195 #define HIF_RX_HDR_GET_RF_BAND(_prHifRxHdr) \
196     ( ( ((_prHifRxHdr)->ucHwChannelNum) <= HW_CHNL_NUM_MAX_2G4 ) ? \
197       BAND_2G4 : BAND_5G)
198
199 /*******************************************************************************
200 *                  F U N C T I O N   D E C L A R A T I O N S
201 ********************************************************************************
202 */
203 __KAL_INLINE__ VOID
204 hifDataTypeCheck (
205     VOID
206     );
207
208 /*******************************************************************************
209 *                              F U N C T I O N S
210 ********************************************************************************
211 */
212
213 /* Kevin: we don't have to call following function to inspect the data structure.
214  * It will check automatically while at compile time.
215  * We'll need this for porting driver to different RTOS.
216  */
217 __KAL_INLINE__ VOID
218 hifDataTypeCheck (
219     VOID
220     )
221 {
222     DATA_STRUC_INSPECTING_ASSERT(sizeof(HIF_RX_HEADER_T) == 12);
223
224     return;
225 }
226
227 #endif