net: wireless: rockchip_wlan: add rtl8188eu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188eu / hal / phydm / phydm_beamforming.h
1 #ifndef __INC_BEAMFORMING_H
2 #define __INC_BEAMFORMING_H
3
4 #ifndef BEAMFORMING_SUPPORT
5 #define BEAMFORMING_SUPPORT             0
6 #endif
7
8 /*Beamforming Related*/
9 #include "txbf/halcomtxbf.h"
10 #include "txbf/haltxbfjaguar.h"
11 #include "txbf/haltxbf8192e.h"
12 #include "txbf/haltxbf8814a.h"
13 #include "txbf/haltxbf8821b.h"
14 #include "txbf/haltxbf8822b.h"
15 #include "txbf/haltxbfinterface.h"
16
17 #if (BEAMFORMING_SUPPORT == 1)
18
19 #define MAX_BEAMFORMEE_SU       2
20 #define MAX_BEAMFORMER_SU       2
21 #if (RTL8822B_SUPPORT == 1)
22 #define MAX_BEAMFORMEE_MU       6
23 #define MAX_BEAMFORMER_MU       1
24 #else
25 #define MAX_BEAMFORMEE_MU       0
26 #define MAX_BEAMFORMER_MU       0
27 #endif
28
29 #define BEAMFORMEE_ENTRY_NUM            (MAX_BEAMFORMEE_SU + MAX_BEAMFORMEE_MU)
30 #define BEAMFORMER_ENTRY_NUM            (MAX_BEAMFORMER_SU + MAX_BEAMFORMER_MU)
31
32 #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
33 /*for different naming between WIN and CE*/
34 #define BEACON_QUEUE    BCN_QUEUE_INX
35 #define NORMAL_QUEUE    MGT_QUEUE_INX
36 #define RT_DISABLE_FUNC RTW_DISABLE_FUNC
37 #define RT_ENABLE_FUNC RTW_ENABLE_FUNC
38 #endif
39
40 typedef enum _BEAMFORMING_ENTRY_STATE {
41         BEAMFORMING_ENTRY_STATE_UNINITIALIZE, 
42         BEAMFORMING_ENTRY_STATE_INITIALIZEING, 
43         BEAMFORMING_ENTRY_STATE_INITIALIZED, 
44         BEAMFORMING_ENTRY_STATE_PROGRESSING, 
45         BEAMFORMING_ENTRY_STATE_PROGRESSED 
46 } BEAMFORMING_ENTRY_STATE, *PBEAMFORMING_ENTRY_STATE;
47
48
49 typedef enum _BEAMFORMING_NOTIFY_STATE {
50         BEAMFORMING_NOTIFY_NONE,
51         BEAMFORMING_NOTIFY_ADD,
52         BEAMFORMING_NOTIFY_DELETE,
53         BEAMFORMEE_NOTIFY_ADD_SU,
54         BEAMFORMEE_NOTIFY_DELETE_SU,
55         BEAMFORMEE_NOTIFY_ADD_MU,
56         BEAMFORMEE_NOTIFY_DELETE_MU,
57         BEAMFORMING_NOTIFY_RESET
58 } BEAMFORMING_NOTIFY_STATE, *PBEAMFORMING_NOTIFY_STATE;
59
60 typedef enum _BEAMFORMING_CAP {
61         BEAMFORMING_CAP_NONE = 0x0,
62         BEAMFORMER_CAP_HT_EXPLICIT = BIT1, 
63         BEAMFORMEE_CAP_HT_EXPLICIT = BIT2, 
64         BEAMFORMER_CAP_VHT_SU = BIT5,                   /* Self has er Cap, because Reg er  & peer ee */
65         BEAMFORMEE_CAP_VHT_SU = BIT6,                   /* Self has ee Cap, because Reg ee & peer er */
66         BEAMFORMER_CAP_VHT_MU = BIT7,                   /* Self has er Cap, because Reg er  & peer ee */
67         BEAMFORMEE_CAP_VHT_MU = BIT8,                   /* Self has ee Cap, because Reg ee & peer er */
68         BEAMFORMER_CAP = BIT9,
69         BEAMFORMEE_CAP = BIT10,
70 }BEAMFORMING_CAP, *PBEAMFORMING_CAP;
71
72
73 typedef enum _SOUNDING_MODE {
74         SOUNDING_SW_VHT_TIMER = 0x0,
75         SOUNDING_SW_HT_TIMER = 0x1, 
76         SOUNDING_STOP_All_TIMER = 0x2, 
77         SOUNDING_HW_VHT_TIMER = 0x3,                    
78         SOUNDING_HW_HT_TIMER = 0x4,
79         SOUNDING_STOP_OID_TIMER = 0x5, 
80         SOUNDING_AUTO_VHT_TIMER = 0x6,
81         SOUNDING_AUTO_HT_TIMER = 0x7,
82         SOUNDING_FW_VHT_TIMER = 0x8,
83         SOUNDING_FW_HT_TIMER = 0x9,
84 }SOUNDING_MODE, *PSOUNDING_MODE;
85
86 typedef struct _RT_BEAMFORM_STAINFO {
87         pu1Byte                                         RA; 
88         u2Byte                                          AID; 
89         u2Byte                                          MacID;
90         u1Byte                                          MyMacAddr[6];
91         WIRELESS_MODE                           WirelessMode;
92         CHANNEL_WIDTH                           BW;
93         BEAMFORMING_CAP                 BeamformCap;
94         u1Byte                                          HtBeamformCap;
95         u2Byte                                          VhtBeamformCap;
96         u1Byte                                          CurBeamform; 
97         u2Byte                                          CurBeamformVHT;
98 } RT_BEAMFORM_STAINFO, *PRT_BEAMFORM_STAINFO;
99
100
101 typedef struct _RT_BEAMFORMEE_ENTRY {
102         BOOLEAN bUsed;
103         BOOLEAN bTxBF;
104         BOOLEAN bSound;
105         u2Byte  AID;                            /*Used to construct AID field of NDPA packet.*/
106         u2Byte  MacId;                          /*Used to Set Reg42C in IBSS mode. */
107         u2Byte  P_AID;                          /*Used to fill Reg42C & Reg714 to compare with P_AID of Tx DESC. */
108         u2Byte  G_ID;                           /*Used to fill Tx DESC*/
109         u1Byte  MyMacAddr[6];
110         u1Byte  MacAddr[6];                     /*Used to fill Reg6E4 to fill Mac address of CSI report frame.*/
111         CHANNEL_WIDTH                   SoundBW;                /*Sounding BandWidth*/
112         u2Byte                                  SoundPeriod;
113         BEAMFORMING_CAP                 BeamformEntryCap;
114         BEAMFORMING_ENTRY_STATE BeamformEntryState;     
115         BOOLEAN                                         bBeamformingInProgress;
116         /*u1Byte        LogSeq;                                                                 // Move to _RT_BEAMFORMER_ENTRY*/
117         /*u2Byte        LogRetryCnt:3;          // 0~4                          // Move to _RT_BEAMFORMER_ENTRY*/
118         /*u2Byte        LogSuccessCnt:2;                // 0~2                          // Move to _RT_BEAMFORMER_ENTRY*/
119         u2Byte  LogStatusFailCnt:5;     // 0~21
120         u2Byte  DefaultCSICnt:5;                // 0~21
121         u1Byte  CSIMatrix[327];
122         u2Byte  CSIMatrixLen;
123         u1Byte  NumofSoundingDim;
124         u1Byte  CompSteeringNumofBFer;
125         u1Byte  su_reg_index;
126         /*For MU-MIMO*/
127         BOOLEAN is_mu_sta;
128         u1Byte  mu_reg_index;
129         u1Byte  gid_valid[8];
130         u1Byte  user_position[16];
131 } RT_BEAMFORMEE_ENTRY, *PRT_BEAMFORMEE_ENTRY;
132
133 typedef struct _RT_BEAMFORMER_ENTRY {
134         BOOLEAN                         bUsed;
135         /*P_AID of BFer entry is probably not used*/
136         u2Byte                          P_AID;                                  /*Used to fill Reg42C & Reg714 to compare with P_AID of Tx DESC. */
137         u2Byte                          G_ID;
138         u1Byte                          MyMacAddr[6];
139         u1Byte                          MacAddr[6];
140         BEAMFORMING_CAP BeamformEntryCap;
141         u1Byte                          NumofSoundingDim;
142         u1Byte                          ClockResetTimes;                /*Modified by Jeffery @2015-04-10*/
143         u1Byte                          PreLogSeq;                              /*Modified by Jeffery @2015-03-30*/
144         u1Byte                          LogSeq;                                 /*Modified by Jeffery @2014-10-29*/
145         u2Byte                          LogRetryCnt:3;                  /*Modified by Jeffery @2014-10-29*/
146         u2Byte                          LogSuccess:2;                   /*Modified by Jeffery @2014-10-29*/
147         u1Byte                          su_reg_index;
148          /*For MU-MIMO*/
149         BOOLEAN                         is_mu_ap;
150         u1Byte                          gid_valid[8];
151         u1Byte                          user_position[16];
152         u2Byte                          AID;
153 } RT_BEAMFORMER_ENTRY, *PRT_BEAMFORMER_ENTRY;
154
155 typedef struct _RT_SOUNDING_INFO {
156         u1Byte                  SoundIdx;
157         CHANNEL_WIDTH   SoundBW;
158         SOUNDING_MODE   SoundMode; 
159         u2Byte                  SoundPeriod;
160 } RT_SOUNDING_INFO, *PRT_SOUNDING_INFO;
161
162
163
164 typedef struct _RT_BEAMFORMING_OID_INFO {
165         u1Byte                  SoundOidIdx;
166         CHANNEL_WIDTH   SoundOidBW;     
167         SOUNDING_MODE   SoundOidMode;
168         u2Byte                  SoundOidPeriod;
169 } RT_BEAMFORMING_OID_INFO, *PRT_BEAMFORMING_OID_INFO;
170
171
172 typedef struct _RT_BEAMFORMING_INFO {
173         BEAMFORMING_CAP                 BeamformCap;
174         RT_BEAMFORMEE_ENTRY             BeamformeeEntry[BEAMFORMEE_ENTRY_NUM];
175         RT_BEAMFORMER_ENTRY             BeamformerEntry[BEAMFORMER_ENTRY_NUM];
176         RT_BEAMFORM_STAINFO             BeamformSTAinfo;
177         u1Byte                                  BeamformeeCurIdx;
178         RT_TIMER                                        BeamformingTimer;
179         RT_TIMER                                        mu_timer;
180         RT_SOUNDING_INFO                        SoundingInfo;
181         RT_BEAMFORMING_OID_INFO BeamformingOidInfo;
182         HAL_TXBF_INFO                   TxbfInfo;
183         u1Byte                                  SoundingSequence;
184         u1Byte                                  beamformee_su_cnt;
185         u1Byte                                  beamformer_su_cnt;
186         u4Byte                                  beamformee_su_reg_maping;
187         u4Byte                                  beamformer_su_reg_maping;
188         /*For MU-MINO*/
189         u1Byte                                  beamformee_mu_cnt;
190         u1Byte                                  beamformer_mu_cnt;
191         u4Byte                                  beamformee_mu_reg_maping;
192         u1Byte                                  mu_ap_index;
193         BOOLEAN                                 is_mu_sounding;
194         u1Byte                                  FirstMUBFeeIndex;
195 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
196         PADAPTER                                SourceAdapter;
197 #endif
198         /* Control register */
199         u4Byte                                  RegMUTxCtrl;            /* For USB/SDIO interfaces aync I/O  */
200 } RT_BEAMFORMING_INFO, *PRT_BEAMFORMING_INFO;
201
202
203 typedef struct _RT_NDPA_STA_INFO {
204         u2Byte  AID:12; 
205         u2Byte  FeedbackType:1;
206         u2Byte  NcIndex:3;      
207 } RT_NDPA_STA_INFO, *PRT_NDPA_STA_INFO;
208
209
210 BEAMFORMING_CAP
211 phydm_Beamforming_GetEntryBeamCapByMacId(
212         IN      PVOID   pDM_VOID,
213         IN      u1Byte  MacId
214  );
215
216 PRT_BEAMFORMEE_ENTRY
217 phydm_Beamforming_GetBFeeEntryByAddr(
218         IN      PVOID           pDM_VOID,
219         IN      pu1Byte         RA,
220         OUT     pu1Byte         Idx
221         );
222
223 PRT_BEAMFORMER_ENTRY
224 phydm_Beamforming_GetBFerEntryByAddr(
225         IN      PVOID   pDM_VOID,
226         IN      pu1Byte TA,
227         OUT     pu1Byte Idx
228         );
229
230 u1Byte
231 Beamforming_GetHTNDPTxRate(
232         IN      PVOID   pDM_VOID,
233         u1Byte  CompSteeringNumofBFer
234 );
235
236 u1Byte
237 Beamforming_GetVHTNDPTxRate(
238         IN      PVOID   pDM_VOID,
239         u1Byte  CompSteeringNumofBFer
240 );
241
242 VOID
243 phydm_Beamforming_Notify(
244         IN      PVOID   pDM_VOID
245         );
246
247
248 VOID
249 Beamforming_Enter(
250         IN PVOID                pDM_VOID,
251         IN u2Byte       staIdx
252         );
253
254 VOID
255 Beamforming_Leave(
256         IN PVOID                pDM_VOID,
257         pu1Byte                 RA
258         );
259
260 BOOLEAN
261 BeamformingStart_FW(
262         IN PVOID                        pDM_VOID,
263         u1Byte                  Idx
264         );
265
266 VOID
267 Beamforming_CheckSoundingSuccess(
268         IN PVOID                        pDM_VOID,
269         BOOLEAN                 Status  
270 );
271
272 VOID
273 phydm_Beamforming_End_SW(
274         IN PVOID                pDM_VOID,
275         BOOLEAN                 Status  
276         );
277
278 VOID
279 Beamforming_TimerCallback(
280         IN PVOID                        pDM_VOID
281         );
282
283 VOID
284 phydm_Beamforming_Init(
285         IN      PVOID           pDM_VOID
286         );
287
288
289
290 BEAMFORMING_CAP
291 phydm_Beamforming_GetBeamCap(
292         IN PVOID                        pDM_VOID,
293         IN PRT_BEAMFORMING_INFO         pBeamInfo
294         );
295
296
297 BOOLEAN
298 BeamformingControl_V1(
299         IN PVOID                        pDM_VOID,
300         pu1Byte                 RA,
301         u1Byte                  AID,
302         u1Byte                  Mode,
303         CHANNEL_WIDTH   BW,
304         u1Byte                  Rate
305         );
306
307
308 BOOLEAN
309 phydm_BeamformingControl_V2(
310         IN      PVOID           pDM_VOID,
311         u1Byte                  Idx,
312         u1Byte                  Mode, 
313         CHANNEL_WIDTH   BW,
314         u2Byte                  Period
315         );
316
317 VOID
318 phydm_Beamforming_Watchdog(
319         IN      PVOID           pDM_VOID
320         );
321
322 VOID
323 Beamforming_SWTimerCallback(
324 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
325         PRT_TIMER               pTimer
326 #elif(DM_ODM_SUPPORT_TYPE == ODM_CE)
327         void *FunctionContext
328 #endif
329         );
330
331 BOOLEAN
332 Beamforming_SendHTNDPAPacket(
333         IN      PVOID                   pDM_VOID,
334         IN      pu1Byte                 RA,
335         IN      CHANNEL_WIDTH   BW, 
336         IN      u1Byte                  QIdx
337         );
338
339
340 BOOLEAN
341 Beamforming_SendVHTNDPAPacket(
342         IN      PVOID                   pDM_VOID,
343         IN      pu1Byte                 RA,
344         IN      u2Byte                  AID,
345         IN      CHANNEL_WIDTH   BW,
346         IN      u1Byte                  QIdx
347         );
348
349 #else
350 #define Beamforming_GidPAid(Adapter, pTcb)
351 #define Beamforming_Enter(pDM_Odm, staIdx)
352 #define Beamforming_Leave(pDM_Odm, RA)
353 #define Beamforming_End_FW(pDMOdm)
354 #define BeamformingControl_V1(pDM_Odm, RA, AID, Mode, BW, Rate)         TRUE
355 #define BeamformingControl_V2(pDM_Odm, Idx, Mode, BW, Period)           TRUE
356 #define phydm_Beamforming_End_SW(pDM_Odm, _Status)
357 #define Beamforming_TimerCallback(pDM_Odm)
358 #define phydm_Beamforming_Init(pDM_Odm)
359 #define phydm_BeamformingControl_V2(pDM_Odm, _Idx, _Mode, _BW, _Period) FALSE
360 #define Beamforming_Watchdog(pDM_Odm)
361 #define phydm_Beamforming_Watchdog(pDM_Odm)
362
363
364 #endif
365 #endif