1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _RTL819XU_HTTYPE_H_
3 #define _RTL819XU_HTTYPE_H_
4 
5 //------------------------------------------------------------
6 // The HT Capability element is present in beacons, association request,
7 //	reassociation request and probe response frames
8 //------------------------------------------------------------
9 
10 //
11 // MIMO Power Save Settings
12 //
13 #define MIMO_PS_STATIC				0
14 
15 //
16 //	There should be 128 bits to cover all of the MCS rates. However, since
17 //	8190 does not support too much rates, one integer is quite enough.
18 //
19 
20 #define sHTCLng	4
21 
22 
23 #define HT_SUPPORTED_MCS_1SS_BITMAP					0x000000ff
24 #define HT_SUPPORTED_MCS_2SS_BITMAP					0x0000ff00
25 #define HT_SUPPORTED_MCS_1SS_2SS_BITMAP			HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
26 
27 //
28 // Represent Channel Width in HT Capabilities
29 //
30 enum ht_channel_width {
31 	HT_CHANNEL_WIDTH_20 = 0,
32 	HT_CHANNEL_WIDTH_20_40 = 1,
33 };
34 
35 //
36 // Represent Extension Channel Offset in HT Capabilities
37 // This is available only in 40Mhz mode.
38 //
39 enum ht_extension_chan_offset {
40 	HT_EXTCHNL_OFFSET_NO_EXT = 0,
41 	HT_EXTCHNL_OFFSET_UPPER = 1,
42 	HT_EXTCHNL_OFFSET_NO_DEF = 2,
43 	HT_EXTCHNL_OFFSET_LOWER = 3,
44 };
45 
46 typedef enum _CHNLOP {
47 	CHNLOP_NONE = 0, // No Action now
48 	CHNLOP_SCAN = 1, // Scan in progress
49 	CHNLOP_SWBW = 2, // Bandwidth switching in progress
50 	CHNLOP_SWCHNL = 3, // Software Channel switching in progress
51 } CHNLOP, *PCHNLOP;
52 
53 // Determine if the Channel Operation is in progress
54 #define CHHLOP_IN_PROGRESS(_pHTInfo)	\
55 		((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
56 
57 /*
58 typedef	union _HT_CAPABILITY{
59 	u16	ShortData;
60 	u8	CharData[2];
61 	struct
62 	{
63 		u16	AdvCoding:1;
64 		u16	ChlWidth:1;
65 		u16	MimoPwrSave:2;
66 		u16	GreenField:1;
67 		u16	ShortGI20Mhz:1;
68 		u16	ShortGI40Mhz:1;
69 		u16	STBC:1;
70 		u16	BeamForm:1;
71 		u16	DelayBA:1;
72 		u16	MaxAMSDUSize:1;
73 		u16	DssCCk:1;
74 		u16	PSMP:1;
75 		u16	Rsvd:3;
76 	}Field;
77 }HT_CAPABILITY, *PHT_CAPABILITY;
78 
79 typedef	union _HT_CAPABILITY_MACPARA{
80 	u8	ShortData;
81 	u8	CharData[1];
82 	struct
83 	{
84 		u8	MaxRxAMPDU:2;
85 		u8	MPDUDensity:2;
86 		u8	Rsvd:4;
87 	}Field;
88 }HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
89 */
90 
91 typedef	struct _HT_CAPABILITY_ELE {
92 
93 	//HT capability info
94 	u8	AdvCoding:1;
95 	u8	ChlWidth:1;
96 	u8	MimoPwrSave:2;
97 	u8	GreenField:1;
98 	u8	ShortGI20Mhz:1;
99 	u8	ShortGI40Mhz:1;
100 	u8	TxSTBC:1;
101 	u8	RxSTBC:2;
102 	u8	DelayBA:1;
103 	u8	MaxAMSDUSize:1;
104 	u8	DssCCk:1;
105 	u8	PSMP:1;
106 	u8	Rsvd1:1;
107 	u8	LSigTxopProtect:1;
108 
109 	//MAC HT parameters info
110 	u8	MaxRxAMPDUFactor:2;
111 	u8	MPDUDensity:3;
112 	u8	Rsvd2:3;
113 
114 	//Supported MCS set
115 	u8	MCS[16];
116 
117 
118 	//Extended HT Capability Info
119 	u16	ExtHTCapInfo;
120 
121 	//TXBF Capabilities
122 	u8	TxBFCap[4];
123 
124 	//Antenna Selection Capabilities
125 	u8	ASCap;
126 
127 } __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
128 
129 //------------------------------------------------------------
130 // The HT Information element is present in beacons
131 // Only AP is required to include this element
132 //------------------------------------------------------------
133 
134 typedef struct _HT_INFORMATION_ELE {
135 	u8	ControlChl;
136 
137 	u8	ExtChlOffset:2;
138 	u8	RecommemdedTxWidth:1;
139 	u8	RIFS:1;
140 	u8	PSMPAccessOnly:1;
141 	u8	SrvIntGranularity:3;
142 
143 	u8	OptMode:2;
144 	u8	NonGFDevPresent:1;
145 	u8	Revd1:5;
146 	u8	Revd2:8;
147 
148 	u8	Rsvd3:6;
149 	u8	DualBeacon:1;
150 	u8	DualCTSProtect:1;
151 
152 	u8	SecondaryBeacon:1;
153 	u8	LSigTxopProtectFull:1;
154 	u8	PcoActive:1;
155 	u8	PcoPhase:1;
156 	u8	Rsvd4:4;
157 
158 	u8	BasicMSC[16];
159 } __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
160 
161 typedef enum _HT_SPEC_VER {
162 	HT_SPEC_VER_IEEE = 0,
163 	HT_SPEC_VER_EWC = 1,
164 }HT_SPEC_VER, *PHT_SPEC_VER;
165 
166 typedef enum _HT_AGGRE_MODE_E {
167 	HT_AGG_AUTO = 0,
168 	HT_AGG_FORCE_ENABLE = 1,
169 	HT_AGG_FORCE_DISABLE = 2,
170 }HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
171 
172 //------------------------------------------------------------
173 //  The Data structure is used to keep HT related variables when card is
174 //  configured as non-AP STA mode.  **Note**  Current_xxx should be set
175 //	to default value in HTInitializeHTInfo()
176 //------------------------------------------------------------
177 
178 typedef struct _RT_HIGH_THROUGHPUT {
179 	u8				bEnableHT;
180 	u8				bCurrentHTSupport;
181 
182 	u8				bRegBW40MHz;				// Tx 40MHz channel capability
183 	u8				bCurBW40MHz;				// Tx 40MHz channel capability
184 
185 	u8				bRegShortGI40MHz;			// Tx Short GI for 40Mhz
186 	u8				bCurShortGI40MHz;			// Tx Short GI for 40MHz
187 
188 	u8				bRegShortGI20MHz;			// Tx Short GI for 20MHz
189 	u8				bCurShortGI20MHz;			// Tx Short GI for 20MHz
190 
191 	u8				bRegSuppCCK;				// Tx CCK rate capability
192 	u8				bCurSuppCCK;				// Tx CCK rate capability
193 
194 	// 802.11n spec version for "peer"
195 	HT_SPEC_VER			ePeerHTSpecVer;
196 
197 
198 	// HT related information for "Self"
199 	HT_CAPABILITY_ELE	SelfHTCap;		// This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
200 	HT_INFORMATION_ELE	SelfHTInfo;		// This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
201 
202 	// HT related information for "Peer"
203 	u8				PeerHTCapBuf[32];
204 	u8				PeerHTInfoBuf[32];
205 
206 
207 	// A-MSDU related
208 	u8				bAMSDU_Support;			// This indicates Tx A-MSDU capability
209 	u16				nAMSDU_MaxSize;			// This indicates Tx A-MSDU capability
210 	u8				bCurrent_AMSDU_Support;	// This indicates Tx A-MSDU capability
211 	u16				nCurrent_AMSDU_MaxSize;	// This indicates Tx A-MSDU capability
212 
213 
214 	// AMPDU  related <2006.08.10 Emily>
215 	u8				bAMPDUEnable;				// This indicate Tx A-MPDU capability
216 	u8				bCurrentAMPDUEnable;		// This indicate Tx A-MPDU capability
217 	u8				AMPDU_Factor;				// This indicate Tx A-MPDU capability
218 	u8				CurrentAMPDUFactor;		// This indicate Tx A-MPDU capability
219 	u8				MPDU_Density;				// This indicate Tx A-MPDU capability
220 	u8				CurrentMPDUDensity;			// This indicate Tx A-MPDU capability
221 
222 	// Forced A-MPDU enable
223 	HT_AGGRE_MODE_E	ForcedAMPDUMode;
224 	u8				ForcedAMPDUFactor;
225 	u8				ForcedMPDUDensity;
226 
227 	// Forced A-MSDU enable
228 	HT_AGGRE_MODE_E	ForcedAMSDUMode;
229 	u16				ForcedAMSDUMaxSize;
230 
231 	u8				bForcedShortGI;
232 
233 	u8				CurrentOpMode;
234 
235 	// MIMO PS related
236 	u8				SelfMimoPs;
237 	u8				PeerMimoPs;
238 
239 	// 40MHz Channel Offset settings.
240 	enum ht_extension_chan_offset	CurSTAExtChnlOffset;
241 	u8				bCurTxBW40MHz;	// If we use 40 MHz to Tx
242 	u8				PeerBandwidth;
243 
244 	// For Bandwidth Switching
245 	u8				bSwBwInProgress;
246 	CHNLOP				ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
247 	u8				SwBwStep;
248 	//struct timer_list		SwBwTimer;  //moved to ieee80211_device. as timer_list need include some header file here.
249 
250 	// For Realtek proprietary A-MPDU factor for aggregation
251 	u8				bRegRT2RTAggregation;
252 	u8				bCurrentRT2RTAggregation;
253 	u8				bCurrentRT2RTLongSlotTime;
254 	u8				szRT2RTAggBuffer[10];
255 
256 	// Rx Reorder control
257 	u8				bRegRxReorderEnable;
258 	u8				bCurRxReorderEnable;
259 	u8				RxReorderWinSize;
260 	u8				RxReorderPendingTime;
261 	u16				RxReorderDropCounter;
262 
263 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
264 	u8				UsbTxAggrNum;
265 #endif
266 #ifdef USB_RX_AGGREGATION_SUPPORT
267 	u8				UsbRxFwAggrEn;
268 	u8				UsbRxFwAggrPageNum;
269 	u8				UsbRxFwAggrPacketNum;
270 	u8				UsbRxFwAggrTimeout;
271 #endif
272 
273 	// Add for Broadcom(Linksys) IOT. Joseph
274 	u8				bIsPeerBcm;
275 
276 	// For IOT issue.
277 	u8				IOTPeer;
278 	u32				IOTAction;
279 } __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
280 
281 //------------------------------------------------------------
282 // The Data structure is used to keep HT related variable for "each AP"
283 // when card is configured as "STA mode"
284 //------------------------------------------------------------
285 
286 typedef struct _BSS_HT {
287 
288 	u8				bdSupportHT;
289 
290 	// HT related elements
291 	u8					bdHTCapBuf[32];
292 	u16					bdHTCapLen;
293 	u8					bdHTInfoBuf[32];
294 	u16					bdHTInfoLen;
295 
296 	HT_SPEC_VER				bdHTSpecVer;
297 	//HT_CAPABILITY_ELE			bdHTCapEle;
298 	//HT_INFORMATION_ELE		bdHTInfoEle;
299 
300 	u8					bdRT2RTAggregation;
301 	u8					bdRT2RTLongSlotTime;
302 } __attribute__ ((packed)) BSS_HT, *PBSS_HT;
303 
304 extern u8 MCS_FILTER_ALL[16];
305 extern u8 MCS_FILTER_1SS[16];
306 
307 /* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set
308    STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We have
309    to add a macro to judge wireless mode. */
310 #define PICK_RATE(_nLegacyRate, _nMcsRate)	\
311 		(_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate)
312 /* 2007/07/12 MH We only define legacy and HT wireless mode now. */
313 #define	LEGACY_WIRELESS_MODE	IEEE_MODE_MASK
314 
315 #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate)	\
316 					((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\
317 						(LegacyRate):\
318 						(PICK_RATE(LegacyRate, HTRate))
319 
320 
321 
322 // MCS Bw 40 {1~7, 12~15,32}
323 #define	RATE_ADPT_1SS_MASK		0xFF
324 #define	RATE_ADPT_2SS_MASK		0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily
325 #define	RATE_ADPT_MCS32_MASK		0x01
326 
327 #define		IS_11N_MCS_RATE(rate)		(rate&0x80)
328 
329 typedef enum _HT_AGGRE_SIZE {
330 	HT_AGG_SIZE_8K = 0,
331 	HT_AGG_SIZE_16K = 1,
332 	HT_AGG_SIZE_32K = 2,
333 	HT_AGG_SIZE_64K = 3,
334 }HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E;
335 
336 /* Indicate different AP vendor for IOT issue */
337 typedef enum _HT_IOT_PEER
338 {
339 	HT_IOT_PEER_UNKNOWN = 0,
340 	HT_IOT_PEER_REALTEK = 1,
341 	HT_IOT_PEER_BROADCOM = 2,
342 	HT_IOT_PEER_RALINK = 3,
343 	HT_IOT_PEER_ATHEROS = 4,
344 	HT_IOT_PEER_CISCO= 5,
345 	HT_IOT_PEER_MAX = 6
346 }HT_IOT_PEER_E, *PHTIOT_PEER_E;
347 
348 //
349 // IOT Action for different AP
350 //
351 typedef enum _HT_IOT_ACTION {
352 	HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
353 	HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
354 	HT_IOT_ACT_DISABLE_MCS14 = 0x00000004,
355 	HT_IOT_ACT_DISABLE_MCS15 = 0x00000008,
356 	HT_IOT_ACT_DISABLE_ALL_2SS = 0x00000010,
357 	HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000020,
358 	HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000040,
359 	HT_IOT_ACT_CDD_FSYNC = 0x00000080,
360 	HT_IOT_ACT_PURE_N_MODE = 0x00000100,
361 	HT_IOT_ACT_FORCED_CTS2SELF = 0x00000200,
362 }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
363 
364 #endif //_RTL819XU_HTTYPE_H_
365