1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **| |**
4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
5 **| All rights reserved. |**
6 **| |**
7 **| Redistribution and use in source and binary forms, with or without |**
8 **| modification, are permitted provided that the following conditions |**
9 **| are met: |**
10 **| |**
11 **| * Redistributions of source code must retain the above copyright |**
12 **| notice, this list of conditions and the following disclaimer. |**
13 **| * Redistributions in binary form must reproduce the above copyright |**
14 **| notice, this list of conditions and the following disclaimer in |**
15 **| the documentation and/or other materials provided with the |**
16 **| distribution. |**
17 **| * Neither the name Texas Instruments nor the names of its |**
18 **| contributors may be used to endorse or promote products derived |**
19 **| from this software without specific prior written permission. |**
20 **| |**
21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
32 **| |**
33 **+-----------------------------------------------------------------------+**
34 ****************************************************************************/
35 /***************************************************************************/
36 /* */
37 /* MODULE: */
38 /* PURPOSE: */
39 /* */
40 /***************************************************************************/
41 #include "fourX.h"
42 #include "report.h"
43 #include "osApi.h"
44 #include "utils.h"
45
46
47 static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX);
48 static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX);
49
50 static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX,
51 dot11_4X_t* site4xParams,
52 fourX_Capabilities_t* pFourX_Capabilities);
53
54 static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities);
55 static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX,
56 dot11_4X_t* fourXInfoElemnt);
57
58 static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX,
59 dot11_4X_t* fourXInfoElemnt);
60
61
62
63
64 /* 4X manager */
fourXManager_evalSite(fourX_t * pFourX,dot11_4X_t * site4xParams,UINT32 * matchingLevel)65 TI_STATUS fourXManager_evalSite(fourX_t* pFourX,
66 dot11_4X_t* site4xParams,
67 UINT32 *matchingLevel)
68 {
69 /* TODO - define 4x matching level */
70 return OK;
71 }
72
fourXManager_setSite(fourX_t * pFourX,dot11_4X_t * site4xParams)73 TI_STATUS fourXManager_setSite(fourX_t* pFourX,
74 dot11_4X_t* site4xParams)
75 {
76 TI_STATUS status;
77 whalParamInfo_t param;
78
79
80 status = fourXManager_InfoElementParsing(pFourX,
81 site4xParams,
82 &pFourX->ApFourX_Capabilities);
83 if(status != OK)
84 {
85 /* set all 4x capabilities to 0 */
86 fourXManager_resetAll4xCapabilities(pFourX);
87 return NOK;
88 }
89
90 /*
91 * configure fourX module and driver 4x Parameters
92 */
93
94 /* configure concatenation parameters */
95 if( (pFourX->desiredConcatenationEnable == TRUE) &&
96 (pFourX->ApFourX_Capabilities.concatenationParams.enableDisable == TRUE) )
97 {
98 pFourX->concatenationEnable = TRUE;
99 }
100 else
101 {
102 pFourX->concatenationEnable = FALSE;
103 }
104 pFourX->currentMaxConcatSize = MIN(pFourX->desiredMaxConcatSize,pFourX->ApFourX_Capabilities.concatenationParams.concatenationSize);
105
106 /*
107 * set Hal Parameters
108 */
109 param.paramType = HAL_CTRL_RTS_THRESHOLD_PARAM;
110 param.content.halCtrlRtsThreshold = HAL_CTRL_RTS_THRESHOLD_MAX;
111
112 whalCtrl_SetParam(pFourX->hWhalCtrl, ¶m);
113
114
115 /* configure contentionWindow parameters */
116 if( (pFourX->desiredCWMinEnable == TRUE) &&
117 (pFourX->ApFourX_Capabilities.contentionWindowParams.enableDisable == TRUE) )
118 {
119 pFourX->CWMinEnable = TRUE;
120 }
121 else
122 {
123 pFourX->CWMinEnable = FALSE;
124
125 }
126 pFourX->currentCWMax = MIN(pFourX->desiredCWMax,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMax);
127 pFourX->currentCWMax = MAX(pFourX->desiredCWMin,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMin);
128
129 /* configure CWCombo parameters - DO NOT Supported */
130 if( (pFourX->desiredCWComboEnable == TRUE) &&
131 (pFourX->ApFourX_Capabilities.CWCombParams.enableDisable == TRUE) )
132 {
133 pFourX->CWComboEnable = TRUE;
134 }
135 else
136 {
137 pFourX->CWComboEnable = FALSE;
138
139 }
140
141 /* configure CWCombo parameters */
142 if( (pFourX->desiredAckEmulationEnable == TRUE) &&
143 (pFourX->ApFourX_Capabilities.ackEmulationParams.enableDisable == TRUE) )
144 {
145 #ifdef ACK_EMUL
146 pFourX->ackEmulationEnable = TRUE;
147 #else
148 pFourX->ackEmulationEnable = FALSE;
149 #endif
150 }
151 else
152 {
153 pFourX->ackEmulationEnable = FALSE;
154
155 }
156
157 /* configure CWCombo parameters - DO NOT Supported */
158 if( (pFourX->desiredERP_ProtectionEnable == TRUE) &&
159 (pFourX->ApFourX_Capabilities.ERP_ProtectionParams.enableDisable == TRUE) )
160 {
161 pFourX->ERP_ProtectionEnable = TRUE;
162 }
163 else
164 {
165 pFourX->ERP_ProtectionEnable = FALSE;
166
167 }
168
169 return OK;
170 }
171
172
fourXManager_InfoElementParsing(fourX_t * pFourX,dot11_4X_t * site4xParams,fourX_Capabilities_t * pFourX_Capabilities)173 static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX,
174 dot11_4X_t* site4xParams,
175 fourX_Capabilities_t* pFourX_Capabilities)
176 {
177 char *capPtr;
178 UINT32 len;
179 UINT16 capLen;
180 WlanTIcap_t cap_type;
181 UINT8 ti_oui[] = TI_OUI;
182
183 if(site4xParams == NULL)
184 {
185 fourXManager_resetAll_AP_4xCapabilities(pFourX);
186 return NOK;
187 }
188
189 /*
190 * IE parsing
191 */
192 if( (site4xParams->hdr.eleId != DOT11_4X_ELE_ID) ||
193 (site4xParams->hdr.eleLen > DOT11_4X_MAX_LEN) ||
194 (os_memoryCompare(pFourX->hOs ,ti_oui, (PUINT8)site4xParams->fourXCapabilities, DOT11_OUI_LEN) != 0) )
195 {
196 fourXManager_resetAll_AP_4xCapabilities(pFourX);
197 return NOK;
198 }
199
200 /*
201 * check protocol version
202 */
203 if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_0)
204 {
205 /*
206 * version 0
207 */
208 pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_0;
209 setDefault4xCapabilities(pFourX_Capabilities);
210 return OK;
211 }
212 else
213 if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_1)
214 {
215 /*
216 * version 1
217 */
218 pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_1;
219
220 capPtr = (char *)site4xParams;
221 capPtr += (sizeof(dot11_eleHdr_t) + DOT11_OUI_LEN + 1); /*IE header + TI_OUI + version field */;
222
223 len = DOT11_OUI_LEN+1; /* TI_OUI + version field */
224
225 while(len < (UINT32)(site4xParams->hdr.eleLen)) /* Dm: Security fix */
226 {
227 cap_type = (WlanTIcap_t)(*((UINT16*)(capPtr)));
228
229 switch(cap_type)
230 {
231 case TI_CAP_4X_CONCATENATION:
232 pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
233 capPtr += 2;
234 capLen = *((UINT16*)(capPtr));
235 capPtr += 2;
236 pFourX_Capabilities->concatenationParams.concatenationSize = *((UINT16*)(capPtr));
237 capPtr += 2;
238 len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val fields */;
239 break;
240
241 case TI_CAP_4X_CONT_WINDOW:
242 pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
243 capPtr += 2;
244 capLen = *((UINT16*)(capPtr));
245 capPtr += 2;
246 pFourX_Capabilities->contentionWindowParams.CWMin = *((UINT16*)(capPtr));
247 capPtr += 2;
248 pFourX_Capabilities->contentionWindowParams.CWMax = *((UINT16*)(capPtr));
249 capPtr += 2;
250 len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
251 break;
252
253 case TI_CAP_4X_CONT_WINDOW_COMBO:
254 pFourX_Capabilities->CWCombParams.enableDisable = TRUE;
255 capPtr += 2;
256 capLen = *((UINT16*)(capPtr));
257 capPtr += 2;
258 pFourX_Capabilities->CWCombParams.DIFS = *((UINT16*)(capPtr));
259 capPtr += 2;
260 pFourX_Capabilities->CWCombParams.SLOT = *((UINT16*)(capPtr));
261 capPtr += 2;
262 pFourX_Capabilities->CWCombParams.CWMin = *((UINT16*)(capPtr));
263 capPtr += 2;
264 len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
265 break;
266
267 case TI_CAP_4X_TCP_ACK_EMUL:
268 pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
269 capPtr += 2;
270 capLen = *((UINT16*)(capPtr));
271 capPtr += 2;
272 len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
273 break;
274
275 case TI_CAP_TRICK_PACKET_ERP:
276 pFourX_Capabilities->ERP_ProtectionParams.enableDisable = TRUE;
277 capPtr += 2;
278 capLen = *((UINT16*)(capPtr));
279 capPtr += 2;
280 len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
281 break;
282
283 default:
284 WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
285 ("unrecognized capability in TI IE: %d\n",cap_type));
286 return NOK;
287 }
288 }
289 }
290 else
291 {
292 /*
293 * unknown version
294 */
295 fourXManager_resetAll_AP_4xCapabilities(pFourX);
296 return NOK;
297 }
298
299 return OK;
300 }
301
fourXManager_get4xInfoElemnt(fourX_t * pFourX,dot11_4X_t * fourXInfoElemnt)302 TI_STATUS fourXManager_get4xInfoElemnt(fourX_t* pFourX,
303 dot11_4X_t* fourXInfoElemnt)
304 {
305 TI_STATUS Status;
306 if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_0)
307 {
308 Status = build4XInfoElementVersion0(pFourX, fourXInfoElemnt);
309 }
310 else
311 if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_1)
312 {
313 Status = build4XInfoElementVersion1(pFourX, fourXInfoElemnt);
314 }
315 else
316 {
317 WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
318 ("fourXManager_get4xInfoElemnt: Versionm unknown\n"));
319 return NOK;
320 }
321
322 return Status;
323 }
324
build4XInfoElementVersion0(fourX_t * pFourX,dot11_4X_t * fourXInfoElemnt)325 static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX,
326 dot11_4X_t* fourXInfoElemnt)
327 {
328 UINT8 ti_oui[] = TI_OUI;
329
330 WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
331 ("build4XInfoElementVersion0: build IE version 0\n"));
332
333 /* 4x Protocol version should support ALL version 0 features */
334 if( (pFourX->desiredConcatenationEnable == FALSE) ||
335 (pFourX->desiredCWMinEnable == FALSE) )
336 {
337 return NOK;
338 }
339
340 fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
341 fourXInfoElemnt->hdr.eleLen = FOUR_X_INFO_ELEMENT_VERSION_0_LEN;
342
343 os_memoryCopy(pFourX->hOs, (PUINT8)fourXInfoElemnt->fourXCapabilities, ti_oui, DOT11_OUI_LEN);
344 fourXInfoElemnt->fourXCapabilities[DOT11_OUI_LEN] = FOUR_X_PROTOCOL_VERSION_0;
345 return OK;
346 }
347
build4XInfoElementVersion1(fourX_t * pFourX,dot11_4X_t * fourXInfoElemnt)348 static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX,
349 dot11_4X_t* fourXInfoElemnt)
350 {
351 UINT8 len = 0;
352 UINT8 *capPtr;
353 UINT8 ti_oui[] = TI_OUI;
354
355 WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,
356 ("build4XInfoElementVersion0: build IE version 1\n"));
357
358 fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
359
360 capPtr = (UINT8 *)fourXInfoElemnt->fourXCapabilities;
361
362 os_memoryCopy(pFourX->hOs, capPtr, ti_oui, DOT11_OUI_LEN);
363 capPtr += DOT11_OUI_LEN ;
364 len += DOT11_OUI_LEN ;
365
366 *capPtr = FOUR_X_PROTOCOL_VERSION_1;
367 capPtr += 1;
368 len += 1;
369
370
371 if(pFourX->desiredConcatenationEnable == TRUE)
372 {
373 *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_ID;
374 capPtr += 2;
375 len += 2;
376 *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_LEN;
377 capPtr += 2;
378 len += 2;
379 *((UINT16*)capPtr) = 4095;
380 capPtr += 2;
381 len += 2;
382 }
383
384
385 fourXInfoElemnt->hdr.eleLen = len;
386 return OK;
387
388 }
389
fourXManager_resetAll4xCapabilities(fourX_t * pFourX)390 static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX)
391 {
392 pFourX->concatenationEnable = FALSE;
393 pFourX->CWMinEnable = FALSE;
394 pFourX->CWComboEnable = FALSE;
395 pFourX->ackEmulationEnable = FALSE;
396 pFourX->ERP_ProtectionEnable = FALSE;
397 }
398
fourXManager_resetAll_AP_4xCapabilities(fourX_t * pFourX)399 static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX)
400 {
401 os_memoryZero(pFourX->hOs, &pFourX->ApFourX_Capabilities, (sizeof(fourX_Capabilities_t)));
402 }
403
setDefault4xCapabilities(fourX_Capabilities_t * pFourX_Capabilities)404 static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities)
405 {
406 /* Concatenation */
407 pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
408 pFourX_Capabilities->concatenationParams.concatenationSize = MAX_CONCAT_SIZE_DEF;
409
410 /* CW min */
411 pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
412 pFourX_Capabilities->contentionWindowParams.CWMax = DEF_CW_MAX;
413 pFourX_Capabilities->contentionWindowParams.CWMin = DEF_CW_MIN;
414
415 /* CW combo */
416 pFourX_Capabilities->CWCombParams.enableDisable = FALSE;
417 pFourX_Capabilities->CWCombParams.CWMin = DEF_CW_COMBO_CW_MIN;
418 pFourX_Capabilities->CWCombParams.DIFS = DEF_CW_COMBO_DIFS;
419 pFourX_Capabilities->CWCombParams.SLOT = DEF_CW_COMBO_SLOT;
420
421 /* Ack Emulation */
422 pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
423
424 /* ERP protection */
425 pFourX_Capabilities->ERP_ProtectionParams.enableDisable = FALSE;
426
427
428 }
429
430
431