• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** \file softGemini.c
2  *  \brief BlueTooth-Wlan coexistence module interface
3  *
4  *  \see softGemini.h
5  */
6 /****************************************************************************
7 **+-----------------------------------------------------------------------+**
8 **|                                                                       |**
9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
10 **| All rights reserved.                                                  |**
11 **|                                                                       |**
12 **| Redistribution and use in source and binary forms, with or without    |**
13 **| modification, are permitted provided that the following conditions    |**
14 **| are met:                                                              |**
15 **|                                                                       |**
16 **|  * Redistributions of source code must retain the above copyright     |**
17 **|    notice, this list of conditions and the following disclaimer.      |**
18 **|  * Redistributions in binary form must reproduce the above copyright  |**
19 **|    notice, this list of conditions and the following disclaimer in    |**
20 **|    the documentation and/or other materials provided with the         |**
21 **|    distribution.                                                      |**
22 **|  * Neither the name Texas Instruments nor the names of its            |**
23 **|    contributors may be used to endorse or promote products derived    |**
24 **|    from this software without specific prior written permission.      |**
25 **|                                                                       |**
26 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
27 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
28 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
29 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
30 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
31 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
32 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
33 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
34 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
35 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
36 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
37 **|                                                                       |**
38 **+-----------------------------------------------------------------------+**
39 ****************************************************************************/
40 
41 /****************************************************************************************************
42 *																									*
43 *		MODULE:		softGemini.c																	*
44 *		PURPOSE:	BlueTooth-Wlan coexistence module interface.							*
45 *					This module handles all data base (and Fw setting accordingly)					*
46 *					for Bluetooth-Wlan coexistence implementation.									*
47 *																						 			*
48 ****************************************************************************************************/
49 
50 #include "report.h"
51 #include "osApi.h"
52 #include "SoftGemini.h"
53 #include "whalCtrl_api.h"
54 #include "DataCtrl_Api.h"
55 #include "scrApi.h"
56 #include "PowerMgr_API.h"
57 #include "srcApi.h"
58 #include "ScanCncnApi.h"
59 #include "currBss.h"
60 #include "bssTypes.h"
61 #include "EvHandler.h"
62 
63 
64 #define SENSE_MODE_ENABLE		0x01
65 #define SENSE_MODE_DISABLE		0x00
66 #define PROTECTIVE_MODE_ON		0x01
67 #define PROTECTIVE_MODE_OFF		0x00
68 
69 /********************************************************************************/
70 /*						Internal functions prototypes.							*/
71 /********************************************************************************/
72 
73 static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, SoftGeminiEnableModes_e SoftGeminiEnable, BOOL recovery);
74 static TI_STATUS SoftGemini_setRateParam(TI_HANDLE hSoftGemini, UINT8 *pRates);
75 static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, SoftGeminiParam_t *SoftGeminiParam);
76 static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, UINT32 *param);
77 static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini);
78 static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini);
79 static void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini);
80 static void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini);
81 static void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini);
82 static void SoftGemini_reconnect(TI_HANDLE hSoftGemini);
83 static TI_STATUS SoftGemini_SetPS(SoftGemini_t	*pSoftGemini);
84 static TI_STATUS SoftGemini_unSetPS(SoftGemini_t	*pSoftGemini);
85 
86 #ifdef REPORT_LOG
87 static char* SoftGemini_ConvertModeToString(SoftGeminiEnableModes_e SoftGeminiEnable);
88 #endif
89 
90 /********************************************************************************/
91 /*						Interface functions Implementation.						*/
92 /********************************************************************************/
93 
94 /************************************************************************
95  *                        SoftGemini_SetPSmode									*
96  ************************************************************************
97 DESCRIPTION: SoftGemini module, called by the conn_Infra on connection
98 				performs the following:
99 				-	Enables SG if needed
100                                 -       Enables the SG power mode
101 INPUT:      hSoftGemini -		Handle to SoftGemini
102 
103 OUTPUT:
104 
105 RETURN:
106 
107 ************************************************************************/
SoftGemini_SetPSmode(TI_HANDLE hSoftGemini)108 void SoftGemini_SetPSmode(TI_HANDLE hSoftGemini)
109 {
110 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
111 
112 	if (pSoftGemini)
113 	{
114 		if (pSoftGemini->bDriverEnabled)
115 		{
116 			SoftGemini_SetPS(pSoftGemini);
117 		}
118 		if (pSoftGemini->bProtectiveMode)
119 		{
120 			SoftGemini_EnableProtectiveMode(hSoftGemini);
121 		}
122 	}
123 	else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_SetPSmode() - Error hSoftGemini= NULL \n"));
124 }
125 
126 /************************************************************************
127  *                        SoftGemini_unSetPSmode									*
128  ************************************************************************
129 DESCRIPTION: SoftGemini module, called by the conn_Infra after disconnecting
130 				performs the following:
131 				-	Disables the SG
132                                 -       Disables the SG power mode
133 INPUT:      hSoftGemini -		Handle to SoftGemini
134 
135 OUTPUT:
136 
137 RETURN:
138 
139 ************************************************************************/
SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini)140 void SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini)
141 {
142 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
143 
144     if (pSoftGemini)
145 	{
146 		if (pSoftGemini->bDriverEnabled)
147 		{
148 			SoftGemini_unSetPS(pSoftGemini);
149 		}
150 	}
151 	else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  (" SoftGemini_unSetPSmode() - Error hSoftGemini= NULL \n"));
152 }
153 
154 /************************************************************************
155  *                        SoftGemini_create									*
156  ************************************************************************
157 DESCRIPTION: SoftGemini module creation function, called by the config mgr in creation phase
158 				performs the following:
159 				-	Allocate the SoftGemini handle
160 
161 INPUT:      hOs -			Handle to OS
162 
163 
164 OUTPUT:
165 
166 RETURN:     Handle to the SoftGemini module on success, NULL otherwise
167 
168 ************************************************************************/
SoftGemini_create(TI_HANDLE hOs)169 TI_HANDLE SoftGemini_create(TI_HANDLE hOs)
170 {
171 	SoftGemini_t			*pSoftGemini = NULL;
172 
173 	/* allocating the SoftGemini object */
174 	pSoftGemini = os_memoryAlloc(hOs,sizeof(SoftGemini_t));
175 
176 	if (pSoftGemini == NULL)
177 		return NULL;
178 
179 	pSoftGemini->hOs = hOs;
180 
181 	return pSoftGemini;
182 }
183 
184 /************************************************************************
185  *                        SoftGemini_config						*
186  ************************************************************************
187 DESCRIPTION: SoftGemini module configuration function, called by the config mgr in configuration phase
188 				performs the following:
189 				-	Reset & initializes local variables
190 				-	Init the handles to be used by the module
191 
192 INPUT:      hSoftGemini	-	SoftGemini handle
193 			List of handles to be used by the module
194 			pSoftGeminiInitParams	-	Init table of the module.
195 
196 
197 OUTPUT:
198 
199 RETURN:     OK on success, NOK otherwise
200 
201 ************************************************************************/
202 
SoftGemini_config(TI_HANDLE hSoftGemini,TI_HANDLE hCtrlData,TI_HANDLE hHalCtrl,TI_HANDLE hReport,TI_HANDLE hSCR,TI_HANDLE hPowerMgr,TI_HANDLE hConfigMgr,TI_HANDLE hScanCncn,TI_HANDLE hCurrBss,TI_HANDLE hEvHandler,SoftGeminiInitParams_t * pSoftGeminiInitParams)203 TI_STATUS SoftGemini_config(	TI_HANDLE		hSoftGemini,
204 								TI_HANDLE		hCtrlData,
205 					  			TI_HANDLE		hHalCtrl,
206 								TI_HANDLE		hReport,
207 								TI_HANDLE		hSCR,
208 								TI_HANDLE		hPowerMgr,
209 								TI_HANDLE		hConfigMgr,
210 								TI_HANDLE		hScanCncn,
211 								TI_HANDLE		hCurrBss,
212 								TI_HANDLE		hEvHandler,
213 								SoftGeminiInitParams_t *pSoftGeminiInitParams)
214 {
215 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
216 	TI_STATUS status;
217 
218 	/*******************/
219 	/* init Handles */
220 	/*****************/
221 
222 	pSoftGemini->hCtrlData  = hCtrlData;
223 	pSoftGemini->hHalCtrl	= hHalCtrl;
224 	pSoftGemini->hReport	= hReport;
225 	pSoftGemini->hSCR       = hSCR;
226 	pSoftGemini->hPowerMgr  = hPowerMgr;
227 	pSoftGemini->hConfigMgr = hConfigMgr;
228 	pSoftGemini->hScanCncn  = hScanCncn;
229 	pSoftGemini->hCurrBss	= hCurrBss;
230 	pSoftGemini->hEvHandler= hEvHandler;
231 
232 	/*************************************/
233 	/* Getting SoftGemini init Params */
234 	/***********************************/
235 
236 	SoftGemini_setRateParam(hSoftGemini,pSoftGeminiInitParams->SoftGeminiRate);
237 
238 	/* read parameters for scan but no need to use them yet, only used when we enable/disable driver */
239 	pSoftGemini->scanNumOfProbeRequest   = pSoftGeminiInitParams->scanNumOfProbeRequest;
240 	pSoftGemini->scanCompensationPercent = pSoftGeminiInitParams->scanCompensationPercent;
241 	pSoftGemini->scanCompensationMaxTime = pSoftGeminiInitParams->scanCompensationMaxTime;
242 	pSoftGemini->BSSLossCompensationPercent = pSoftGeminiInitParams->BSSLossCompensationPercent;
243 
244 	os_memoryCopy(hSoftGemini,&pSoftGemini->SoftGeminiParam,&pSoftGeminiInitParams->SoftGeminiParam,sizeof(SoftGeminiParam_t));
245 	/* Send the configuration to the FW */
246 	status = SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
247 
248 	/*******************************/
249     /* register Indication interrupts  */
250 	/*****************************/
251 
252     whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl,
253                                          HAL_EVENT_SOFT_GEMINI_SENSE,
254                                          (void *)SoftGemini_SenseIndicationCB,
255                                          hSoftGemini );
256 	whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl,
257                                          HAL_EVENT_SOFT_GEMINI_PREDICTION,
258                                          (void *)SoftGemini_ProtectiveIndicationCB,
259                                          hSoftGemini );
260 
261 	whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl,
262                                          HAL_EVENT_SOFT_GEMINI_AVALANCHE,
263                                          (void *)SoftGemini_AvalancheIndicationCB,
264                                          hSoftGemini );
265 
266     whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_SENSE );
267 
268 	whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_PREDICTION );
269 
270 	whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_AVALANCHE );
271 
272 	/* On system initialization SG is disabled but later calls to SoftGemini_setEnableParam() */
273 	pSoftGemini->bProtectiveMode = FALSE;
274 	pSoftGemini->SoftGeminiEnable = SG_DISABLE;
275 	pSoftGemini->bDriverEnabled = FALSE;
276     pSoftGemini->bPsPollFailureActive = FALSE;
277 
278 	if ((OK == status) && (pSoftGeminiInitParams->SoftGeminiEnable != SG_DISABLE))
279 	{	/* called only if different than SG_DISABLE */
280 		status = SoftGemini_setEnableParam(hSoftGemini, pSoftGeminiInitParams->SoftGeminiEnable, FALSE);
281 	}
282 
283 	if (status == OK)
284 	{
285 		WLAN_REPORT_INIT(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_config() - configured successfully\n"));
286 	}
287 	else
288 	{
289 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_config() - Error configuring module \n"));
290 	}
291 
292 	return status;
293 }
294 
295 /************************************************************************
296  *                        SoftGemini_destroy							*
297  ************************************************************************
298 DESCRIPTION: SoftGemini module destroy function, called by the config mgr in the destroy phase
299 				performs the following:
300 				-	Free all memory aloocated by the module
301 
302 INPUT:      hSoftGemini	-	SoftGemini handle.
303 
304 
305 OUTPUT:
306 
307 RETURN:     OK on success, NOK otherwise
308 
309 ************************************************************************/
SoftGemini_destroy(TI_HANDLE hSoftGemini)310 TI_STATUS SoftGemini_destroy(TI_HANDLE hSoftGemini)
311 {
312 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
313 
314 	if (pSoftGemini != NULL)
315 	{
316 		os_memoryFree( pSoftGemini->hOs, (TI_HANDLE)pSoftGemini , sizeof(SoftGemini_t));
317 	}
318 
319 	return OK;
320 }
321 
322 
323 /***********************************************************************
324  *                        SoftGemini_setParam
325  ***********************************************************************
326 DESCRIPTION: SoftGemini set param function, called by the following:
327 			-	config mgr in order to set a parameter receiving from the OS abstraction layer.
328 			-	From inside the driver
329 
330 INPUT:      hSoftGemini	-	SoftGemini handle.
331 			pParam	-	Pointer to the parameter
332 
333 OUTPUT:
334 
335 RETURN:     OK on success, NOK otherwise
336 
337 ************************************************************************/
SoftGemini_setParam(TI_HANDLE hSoftGemini,paramInfo_t * pParam)338 TI_STATUS SoftGemini_setParam(TI_HANDLE	hSoftGemini,
339 											paramInfo_t	*pParam)
340 {
341 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
342 	TI_STATUS return_value = OK;
343 
344 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  SoftGemini_setParam() (0x%x)\n", pParam->paramType));
345 
346 	switch(pParam->paramType)
347 	{
348 
349 	case SOFT_GEMINI_SET_ENABLE:
350 
351 		return_value = SoftGemini_setEnableParam(hSoftGemini,pParam->content.SoftGeminiEnable, FALSE);
352 		break;
353 
354 	case SOFT_GEMINI_SET_RATE:
355 
356 		return_value = SoftGemini_setRateParam(hSoftGemini, pParam->content.SoftGeminiRate);
357 		break;
358 
359 	case SOFT_GEMINI_SET_CONFIG:
360 
361 		/* copy new params to SoftGemini module */
362 		SoftGemini_setConfigParam(hSoftGemini,pParam->content.SoftGeminiParamArray);
363 
364 		/* set new params to FW */
365 		return_value = SoftGemini_setParamsToFW(hSoftGemini, &(pSoftGemini->SoftGeminiParam));
366 		break;
367 
368 	default:
369 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  SoftGemini_setParam(), Params is not supported, %d\n\n", pParam->paramType));
370 		return PARAM_NOT_SUPPORTED;
371 	}
372 
373 	return return_value;
374 }
375 
376 /***********************************************************************
377  *			      SoftGemini_getParam
378  ***********************************************************************
379 DESCRIPTION: SoftGemini get param function, called by the following:
380 			-	config mgr in order to get a parameter from the OS abstraction layer.
381 			-	From inside the dirver
382 
383 INPUT:      hSoftGemini	-	SoftGemini handle.
384 
385 
386 OUTPUT:		pParam	-	Pointer to the parameter
387 
388 RETURN:     OK on success, NOK otherwise
389 
390 ************************************************************************/
SoftGemini_getParam(TI_HANDLE hSoftGemini,paramInfo_t * pParam)391 TI_STATUS SoftGemini_getParam(TI_HANDLE		hSoftGemini,
392 											paramInfo_t	*pParam)
393 {
394 	SoftGemini_printParams(hSoftGemini);
395 
396 	return OK;
397 }
398 
399 
400 
401 /***************************************************************************
402 *					SoftGemini_setEnableParam					    	       *
403 ****************************************************************************
404 * DESCRIPTION:	The function sets the  appropriate Enable value,
405 *				configures SCR , POWER MGR , DATA CTRL , FW.
406 *
407 * INPUTS:		pSoftGemini - the object
408 ***************************************************************************/
SoftGemini_setEnableParam(TI_HANDLE hSoftGemini,SoftGeminiEnableModes_e SoftGeminiEnable,BOOL recovery)409 static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, SoftGeminiEnableModes_e SoftGeminiEnable, BOOL recovery)
410 {
411 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
412 	whalParamInfo_t	param;
413 	TI_STATUS return_value = OK;
414 
415 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  setSoftGeminiEnableParam() - Old value = %s, New value = %s\n",
416 		SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable),SoftGemini_ConvertModeToString(SoftGeminiEnable)));
417 
418 
419     /*
420      * PsPoll work around is active. Just save the value and configure it later
421      */
422     if ( pSoftGemini->bPsPollFailureActive )
423     {
424         WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
425             ("  setSoftGeminiEnableParam() - while PsPollFailure is active\n"));
426 
427         pSoftGemini->PsPollFailureLastEnableValue = SoftGeminiEnable;
428         return OK;
429     }
430 
431 	/**********************************/
432 	/* Sanity check on enable values */
433 	/********************************/
434 
435 	/*				Old Value						New Value		    */
436 	/*					|							    |			    */
437 	/*			  	   \|/							   \|/			    */
438 
439 	if ((pSoftGemini->SoftGeminiEnable == SoftGeminiEnable) && !recovery)
440 	{
441 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  %s - setting same value \n",__FUNCTION__));
442 		return NOK;
443 	}
444 
445 
446 	/*******************************/
447 	/* Make the necessary actions */
448 	/*****************************/
449 
450 	switch (SoftGeminiEnable)
451 	{
452 	case SG_ENABLE:
453 
454 		if (!pSoftGemini->bDriverEnabled)
455 		{
456 			SoftGemini_EnableDriver(hSoftGemini);
457 		}
458 		/* set FW with SG_ENABLE */
459 		param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
460 		param.content.SoftGeminiEnable = SG_ENABLE;
461 		return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
462 
463 		/* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
464 		pSoftGemini->btCoexStatus.state = TRUE;
465 
466 		break;
467 
468 	case SG_DISABLE:
469 
470 		/* set FW with SG_DISABLE */
471 		param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
472 		param.content.SoftGeminiEnable = SG_DISABLE;
473 		return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
474 
475 		if (pSoftGemini->bDriverEnabled)
476 		{
477 			SoftGemini_DisableDriver(hSoftGemini);
478 		}
479 
480 		/* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
481 		pSoftGemini->btCoexStatus.state = FALSE;
482 
483 		break;
484 
485 	case SG_SENSE_NO_ACTIVITY:
486 
487 		/* set FW with SG_SENSE_NO_ACTIVITY */
488 		param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
489 		param.content.SoftGeminiEnable = SG_SENSE_NO_ACTIVITY;
490 		return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
491 
492 		if (pSoftGemini->bDriverEnabled)
493 		{
494 			SoftGemini_DisableDriver(hSoftGemini);
495 		}
496 
497 		/* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
498 		pSoftGemini->btCoexStatus.state = FALSE;
499 
500 		break;
501 
502 	case SG_SENSE_ACTIVE:
503 
504 		if (!pSoftGemini->bDriverEnabled)
505 		{
506 			SoftGemini_EnableDriver(hSoftGemini);
507 		}
508 		/* set FW with SG_SENSE_ACTIVE */
509 		param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
510 		param.content.SoftGeminiEnable = SG_SENSE_ACTIVE;
511 		return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
512 
513 		/* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
514 		pSoftGemini->btCoexStatus.state = TRUE;
515 
516 		break;
517 
518 	default:
519 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s defualt :%d\n",__FUNCTION__,SoftGeminiEnable));
520 		return NOK;
521 /*		break; - unreachable*/
522 	}
523 
524 	/* Pass to the new enable state */
525 	pSoftGemini->SoftGeminiEnable = SoftGeminiEnable;
526 
527 	if (OK != return_value)
528 	{
529 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
530 			("%s can't configure enable param to FW :%s\n",__FUNCTION__,SoftGemini_ConvertModeToString(SoftGeminiEnable)));
531 	}
532 	else
533 	{
534 		EvHandlerSendEvent(pSoftGemini->hEvHandler, IPC_EVENT_BT_COEX_MODE, (UINT8*)&pSoftGemini->btCoexStatus, sizeof(btCoexStatus_t));
535 	}
536 
537 	return return_value;
538 }
539 
540 /***************************************************************************
541 *					SoftGemini_setConfigParam				    	       *
542 ****************************************************************************
543 * DESCRIPTION:	The function sets params
544 *
545 * INPUTS:		pSoftGemini - the object
546 *				param       - params to be configured
547 ***************************************************************************/
SoftGemini_setConfigParam(TI_HANDLE hSoftGemini,UINT32 * param)548 static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, UINT32 *param)
549 {
550 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
551 	UINT32 i = 0;
552 
553 	pSoftGemini->SoftGeminiParam.wlanRxMinRateToRespectBtHp		= (UINT32)param[i++];
554 	pSoftGemini->SoftGeminiParam.btHpMaxTime					= (UINT16)param[i++];
555 	pSoftGemini->SoftGeminiParam.wlanHpMaxTime					= (UINT16)param[i++];
556 	pSoftGemini->SoftGeminiParam.senseDisableTimer				= (UINT16)param[i++];
557 	pSoftGemini->SoftGeminiParam.protectiveRxTimeBeforeBtHp		= (UINT16)param[i++];
558 	pSoftGemini->SoftGeminiParam.protectiveTxTimeBeforeBtHp		= (UINT16)param[i++];
559 	pSoftGemini->SoftGeminiParam.protectiveRxTimeBeforeBtHpFastAp = (UINT16)param[i++];
560 	pSoftGemini->SoftGeminiParam.protectiveTxTimeBeforeBtHpFastAp = (UINT16)param[i++];
561 	pSoftGemini->SoftGeminiParam.protectiveWlanCycleTimeForFastAp = (UINT16)param[i++];
562     pSoftGemini->SoftGeminiParam.btAntiStarvationPeriod			  = (UINT16)param[i++];
563     pSoftGemini->SoftGeminiParam.timeoutNextBtLpPacket            = (UINT16)param[i++];
564 	pSoftGemini->SoftGeminiParam.wakeUpTimeBeforeBeacon           = (UINT16)param[i++];
565 	pSoftGemini->SoftGeminiParam.hpdmMaxGuardTime				 = (UINT16)param[i++];
566 	pSoftGemini->SoftGeminiParam.timeoutNextWlanPacket           = (UINT16)param[i++];
567 	pSoftGemini->SoftGeminiParam.sgAntennaType					= (UINT8)param[i++];
568 	pSoftGemini->SoftGeminiParam.signalingType					= (UINT8)param[i++];
569 	pSoftGemini->SoftGeminiParam.afhLeverageOn					= (UINT8)param[i++];
570 	pSoftGemini->SoftGeminiParam.numberQuietCycle				= (UINT8)param[i++];
571 	pSoftGemini->SoftGeminiParam.maxNumCts						= (UINT8)param[i++];
572 	pSoftGemini->SoftGeminiParam.numberOfWlanPackets			= (UINT8)param[i++];
573 	pSoftGemini->SoftGeminiParam.numberOfBtPackets				= (UINT8)param[i++];
574 	pSoftGemini->SoftGeminiParam.numberOfMissedRxForAvalancheTrigger = (UINT8)param[i++];
575 	pSoftGemini->SoftGeminiParam.wlanElpHpSupport				= (UINT8)param[i++];
576 	pSoftGemini->SoftGeminiParam.btAntiStarvationNumberOfCyclesWithinThePeriod  = (UINT8)param[i++];
577     pSoftGemini->SoftGeminiParam.ackModeDuringBtLpInDualAnt     = (UINT8)param[i++];
578     pSoftGemini->SoftGeminiParam.allowPaSdToggleDuringBtActivityEnable = (UINT8)param[i++];
579 	/*
580 	 * Check if SG is Active and sgAutoModeNoCts was changed on the fly.
581 	 *  If so - update powerMgr.
582 	 */
583 	pSoftGemini->SoftGeminiParam.sgAutoModeNoCts = (UINT8)param[i++];
584 
585     if ( pSoftGemini->SoftGeminiEnable == SG_SENSE_ACTIVE || pSoftGemini->SoftGeminiEnable == SG_ENABLE )
586 	{
587         if (pSoftGemini->SoftGeminiParam.sgAutoModeNoCts)
588 		{
589 			/* Exit "Always PS" mode */
590 			SoftGemini_unSetPS(pSoftGemini);
591 		}
592 		else /* Normal behavior - enter PS */
593 		{
594 			SoftGemini_SetPS(pSoftGemini);
595 		}
596 	}
597 
598 	pSoftGemini->SoftGeminiParam.numOfBtHpRespectedReq = (UINT8)param[i++];
599 
600 }
601 
602 /***************************************************************************
603 *					setSoftGeminiRateParam				    	    	       *
604 ****************************************************************************
605 * DESCRIPTION:	The function sets the Ctrl Data with the appropriate Rate value
606 *
607 * INPUTS:		pSoftGemini - the object
608 ***************************************************************************/
SoftGemini_setRateParam(TI_HANDLE hSoftGemini,UINT8 * pRates)609 static TI_STATUS SoftGemini_setRateParam(TI_HANDLE hSoftGemini, UINT8 *pRates)
610 {
611 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
612 	int i;
613 	UINT32 supportedRates = 0;
614 	paramInfo_t param;
615 	rateMask_e supportedRatesArray[NUM_OF_RATES_IN_SG] =
616 	{DRV_RATE_MASK_1_BARKER,DRV_RATE_MASK_2_BARKER,DRV_RATE_MASK_5_5_CCK,DRV_RATE_MASK_6_OFDM,
617 	DRV_RATE_MASK_9_OFDM,DRV_RATE_MASK_11_CCK,DRV_RATE_MASK_12_OFDM,DRV_RATE_MASK_18_OFDM,
618 	DRV_RATE_MASK_22_PBCC,DRV_RATE_MASK_24_OFDM,DRV_RATE_MASK_36_OFDM,DRV_RATE_MASK_48_OFDM,DRV_RATE_MASK_54_OFDM};
619 
620 	/* loop on all rates and mark the corresponding bit if the rate is enabled */
621 	for (i = 0 ; i < NUM_OF_RATES_IN_SG ; i++)
622 	{
623 		WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
624 			(" %s rate %u = %u \n", __FUNCTION__, i,pRates[i]));
625 		pSoftGemini->SoftGeminiRate[i] = pRates[i];
626 
627 		if (pRates[i] > 0)
628 		{
629 			/* Store the minTxRate */
630 			if (!supportedRates)
631 			{
632 				pSoftGemini->btCoexStatus.minTxRate = (UINT8)supportedRatesArray[i];
633 			}
634 
635 			supportedRates |= supportedRatesArray[i];
636 		}
637 	}
638 
639 	if ((supportedRates & DRV_RATE_MASK_1_BARKER) || (supportedRates & DRV_RATE_MASK_2_BARKER))
640 	{
641 		WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
642 			(" %s Using rates 1 or 2 in Soft Gemini is not recommended !!!\n", __FUNCTION__));
643 	}
644 
645 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
646 		(" %s rateMask = 0x%x \n", __FUNCTION__,supportedRates));
647 
648 	param.paramType = CTRL_DATA_NEXT_RATE_MASK_FOR_CLIENT;
649 	param.content.ctrlDataRateClassMask.clientID = SG_RATE_CLASS;
650 	param.content.ctrlDataRateClassMask.clientRateMask = supportedRates;
651 	ctrlData_setParam(pSoftGemini->hCtrlData,&param);
652 
653 	return OK;
654 }
655 
656 /***************************************************************************
657 *					SoftGemini_printParams					    	       *
658 ****************************************************************************
659 * DESCRIPTION:	Print SG Parameters.
660 *
661 * INPUTS:		pSoftGemini - the object
662 ***************************************************************************/
SoftGemini_printParams(TI_HANDLE hSoftGemini)663 void SoftGemini_printParams(TI_HANDLE hSoftGemini)
664 {
665 #ifdef REPORT_LOG
666 
667 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
668 	SoftGeminiParam_t *SoftGeminiParam = &pSoftGemini->SoftGeminiParam;
669 	int i;
670 
671 	WLAN_OS_REPORT(("Rates starting from 1 to 54: \n"));
672 
673 	for (i = 0 ; i < NUM_OF_RATES_IN_SG ; i++)
674 	{
675 		WLAN_OS_REPORT((" rate[%u] = %u \n", i,pSoftGemini->SoftGeminiRate[i]));
676 	}
677 
678 	WLAN_OS_REPORT(("  wlanRxMinRateToRespectBtHp = %d\n", SoftGeminiParam->wlanRxMinRateToRespectBtHp));
679 	WLAN_OS_REPORT(("  btHpMaxTime = %d\n", SoftGeminiParam->btHpMaxTime));
680 	WLAN_OS_REPORT(("  wlanHpMaxTime = %d\n", SoftGeminiParam->wlanHpMaxTime));
681 	WLAN_OS_REPORT(("  senseDisableTimer = %d\n", SoftGeminiParam->senseDisableTimer));
682 	WLAN_OS_REPORT(("  protectiveRxTimeBeforeBtHp = %d\n", SoftGeminiParam->protectiveRxTimeBeforeBtHp));
683 	WLAN_OS_REPORT(("  protectiveTxTimeBeforeBtHp = %d\n", SoftGeminiParam->protectiveTxTimeBeforeBtHp));
684 	WLAN_OS_REPORT(("  protectiveRxTimeBeforeBtHpFastAp = %d\n", SoftGeminiParam->protectiveRxTimeBeforeBtHpFastAp));
685 	WLAN_OS_REPORT(("  protectiveTxTimeBeforeBtHpFastAp = %d\n", SoftGeminiParam->protectiveTxTimeBeforeBtHpFastAp));
686 	WLAN_OS_REPORT(("  protectiveWlanCycleTimeForFastAp = %d\n", SoftGeminiParam->protectiveWlanCycleTimeForFastAp));
687     WLAN_OS_REPORT(("  btAntiStarvationPeriod  = %d\n", SoftGeminiParam->btAntiStarvationPeriod));
688 	WLAN_OS_REPORT(("  timeoutNextBtLpPacket = %d\n", SoftGeminiParam->timeoutNextBtLpPacket));
689     WLAN_OS_REPORT(("  wakeUpTimeBeforeBeacon = %d\n", SoftGeminiParam->wakeUpTimeBeforeBeacon));
690 	WLAN_OS_REPORT(("  hpdmMaxGuardTime = %d\n", SoftGeminiParam->hpdmMaxGuardTime));
691 	WLAN_OS_REPORT(("  timeoutNextWlanPacket = %d\n", SoftGeminiParam->timeoutNextWlanPacket));
692     WLAN_OS_REPORT(("  sgAntennaType = %d\n", SoftGeminiParam->sgAntennaType));
693     WLAN_OS_REPORT(("  signalingType = %d\n", SoftGeminiParam->signalingType));
694 	WLAN_OS_REPORT(("  afhLeverageOn = %d\n", SoftGeminiParam->afhLeverageOn));
695     WLAN_OS_REPORT(("  numberQuietCycle = %d\n", SoftGeminiParam->numberQuietCycle));
696 	WLAN_OS_REPORT(("  maxNumCts = %d\n", SoftGeminiParam->maxNumCts));
697 	WLAN_OS_REPORT(("  numberOfWlanPackets = %d\n", SoftGeminiParam->numberOfWlanPackets));
698 	WLAN_OS_REPORT(("  numberOfBtPackets = %d\n", SoftGeminiParam->numberOfBtPackets));
699 	WLAN_OS_REPORT(("  numberOfMissedRxForAvalancheTrigger = %d\n", SoftGeminiParam->numberOfMissedRxForAvalancheTrigger));
700 	WLAN_OS_REPORT(("  wlanElpHpSupport = %d\n", SoftGeminiParam->wlanElpHpSupport));
701 	WLAN_OS_REPORT(("  btAntiStarvationNumberOfCyclesWithinThePeriod = %d\n", SoftGeminiParam->btAntiStarvationNumberOfCyclesWithinThePeriod));
702     WLAN_OS_REPORT(("  ackModeDuringBtLpInDualAnt = %d\n", SoftGeminiParam->ackModeDuringBtLpInDualAnt));
703     WLAN_OS_REPORT(("  allowPaSdToggleDuringBtActivityEnable = %d\n", SoftGeminiParam->allowPaSdToggleDuringBtActivityEnable));
704 	WLAN_OS_REPORT(("  sgAutoModeNoCts = %d\n", SoftGeminiParam->sgAutoModeNoCts));
705 	WLAN_OS_REPORT(("  numOfBtHpRespectedReq = %d\n\n", SoftGeminiParam->numOfBtHpRespectedReq));
706 
707 	WLAN_OS_REPORT(("  Enable mode : %s\n", SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable)));
708 	WLAN_OS_REPORT(("  Driver Enabled : %s\n",(pSoftGemini->bDriverEnabled ? "YES" : "NO")));
709 	WLAN_OS_REPORT(("  Protective mode : %s\n", (pSoftGemini->bProtectiveMode ? "ON" : "OFF")));
710     WLAN_OS_REPORT(("  PsPoll failure active : %s\n", (pSoftGemini->bPsPollFailureActive ? "YES" : "NO")));
711 
712 #endif
713 }
714 
715 /***********************************************************************
716  *                        SoftGemini_reconnect
717  ***********************************************************************
718 DESCRIPTION: causes driver to disconnect and reconnect to current AP
719 
720 INPUT:      hSoftGemini	-	SoftGemini handle.
721 
722 ************************************************************************/
723 
SoftGemini_reconnect(TI_HANDLE hSoftGemini)724 void SoftGemini_reconnect(TI_HANDLE hSoftGemini)
725 {
726 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
727 	paramInfo_t	ssidParam;
728 	paramInfo_t	param;
729 	TI_STATUS	status;
730 
731 	/* Get current SSID; if we are not connected, there is nothing to do, return */
732 	ssidParam.paramType = SITE_MGR_CURRENT_SSID_PARAM;
733 	status =  configMgr_getParam(pSoftGemini->hConfigMgr, &ssidParam);
734 	if (status != OK)
735 	{
736 		return;
737 	}
738 
739 	/* Take care of scan enabled SME parameter: if is set to TRUE, set it to SKIP_ONCE */
740 	param.paramType = SME_SCAN_ENABLED_PARAM;
741 	configMgr_getParam(pSoftGemini->hConfigMgr, &param);
742 
743 	if (param.content.smeSMScanEnabled == SCAN_ENABLED)
744 	{
745 		param.content.smeSMScanEnabled = SKIP_NEXT_SCAN;
746 		configMgr_setParam(pSoftGemini->hConfigMgr, &param);
747 	}
748 
749 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s - reconnecting !!!\n",__FUNCTION__));
750 
751 	/* Re-set desired SSID */
752 	ssidParam.paramType = SITE_MGR_DESIRED_SSID_PARAM;
753 	configMgr_setParam(pSoftGemini->hConfigMgr, &ssidParam);
754 }
755 
756 /***************************************************************************
757 *					SoftGemini_setParamsToFW					    	       *
758 ****************************************************************************
759 * DESCRIPTION:	The function sets the FW with the appropriate parameters set.
760 *
761 * INPUTS:		pSoftGemini - the object
762 *
763 *
764 * OUTPUT:
765 *
766 * RETURNS:
767 ***************************************************************************/
SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini,SoftGeminiParam_t * SoftGeminiParam)768 static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, SoftGeminiParam_t *SoftGeminiParam)
769 {
770 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
771 	whalParamInfo_t	whalParam;
772 
773 	os_memoryCopy(pSoftGemini->hOs,&whalParam.content.SoftGeminiParam, SoftGeminiParam, sizeof(SoftGeminiParam_t));
774 	whalParam.paramType = HAL_CTRL_SG_CONFIG_PARAM;
775 	return whalCtrl_SetParam(pSoftGemini->hHalCtrl,&whalParam);
776 }
777 
778 
779 /***************************************************************************
780 *					SoftGemini_EnableDriver  		    	       *
781 ****************************************************************************
782 * DESCRIPTION:	Activated when SG is enabled (after CLI or FW command)
783 *
784 * INPUTS:		pSoftGemini - the object
785 *
786 ***************************************************************************/
SoftGemini_EnableDriver(TI_HANDLE hSoftGemini)787 static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini)
788 {
789 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
790 	TI_STATUS return_value = OK;
791 	paramInfo_t param;
792 
793 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
794 
795 	pSoftGemini->bDriverEnabled = TRUE;
796 
797 	/* Set Always PS only if sgAutoModeNoCts is FALSE, i.e. normal operation */
798 	if ( !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts )
799 	{
800 		SoftGemini_SetPS(pSoftGemini);
801 	}
802 
803 	/* set ctrlData to use SG rates */
804 	param.paramType = CTRL_DATA_CURRENT_RATE_CLASS_CLIENT;
805 	param.content.ctrlDataRateClassID = SG_RATE_CLASS;
806 	ctrlData_setParam(pSoftGemini->hCtrlData,&param);
807 
808 	scr_setMode(pSoftGemini->hSCR, SCR_MID_SG);
809 
810 	return return_value;
811 }
812 
813 /***************************************************************************
814 *					SoftGemini_DisableDriver  		    	       *
815 ****************************************************************************
816 * DESCRIPTION:	Activated when SG is disabled (after CLI or FW command)
817 *
818 * INPUTS:		pSoftGemini - the object
819 *
820 ***************************************************************************/
SoftGemini_DisableDriver(TI_HANDLE hSoftGemini)821 static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini)
822 {
823 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
824 	TI_STATUS return_value = OK;
825 	paramInfo_t param;
826 
827 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
828 
829 	pSoftGemini->bDriverEnabled = FALSE;
830 
831 	/* set ctrlData to use default rates */
832 	param.paramType = CTRL_DATA_CURRENT_RATE_CLASS_CLIENT;
833 	param.content.ctrlDataRateClassID = USER_RATE_CLASS;
834 	ctrlData_setParam(pSoftGemini->hCtrlData,&param);
835 
836 	scr_setMode(pSoftGemini->hSCR, SCR_MID_NORMAL);
837 
838 	/* unSet Always PS only if sgAutoModeNoCts is FALSE, i.e. normal operation */
839 	if ( !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts )
840 	{
841 		SoftGemini_unSetPS(pSoftGemini);
842 	}
843 
844 	/* Undo the changes that were made when Protective mode was on */
845 	if (pSoftGemini->bProtectiveMode)
846 	{
847 		SoftGemini_DisableProtectiveMode(hSoftGemini);
848 	}
849 
850 	return return_value;
851 
852 }
853 
854 /***************************************************************************
855 *					SoftGemini_SetPS  		    						   *
856 ****************************************************************************
857 * DESCRIPTION:	Set Always PS to PowerMgr
858 *
859 * INPUTS:		pSoftGemini - the object
860 *
861 ***************************************************************************/
SoftGemini_SetPS(SoftGemini_t * pSoftGemini)862 static TI_STATUS SoftGemini_SetPS(SoftGemini_t	*pSoftGemini)
863 {
864 	paramInfo_t param;
865 	bssEntry_t *pBssInfo=NULL;
866 
867     if (pSoftGemini->hCurrBss)
868 	{
869 		pBssInfo = currBSS_getBssInfo(pSoftGemini->hCurrBss);
870 	}
871 	else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("SoftGemini_SetPS: hCurrBss = NULL!!!\n"));
872 
873 
874 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
875 
876 	if (pBssInfo)
877 	{
878 		if ((pBssInfo->band == RADIO_BAND_2_4_GHZ) && (!pSoftGemini->SoftGeminiParam.sgAutoModeNoCts))
879 		{
880 			WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SG-setPS: band == RADIO_BAND_2_4_GHZ"));
881 
882 			/* Set Params to Power Mgr for SG priority */
883 			param.paramType = POWER_MGR_POWER_MODE;
884 			param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
885 			param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
886 			powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
887 
888 			/* enable SG priority for Power Mgr */
889 			param.paramType = POWER_MGR_ENABLE_PRIORITY;
890 			param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
891 			return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
892 		}
893 		else WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SG-setPS: band == RADIO_BAND_5_GHZ"));
894 	}
895 	return OK;
896 }
897 
898 /***************************************************************************
899 *					SoftGemini_unSetPS  		    						   *
900 ****************************************************************************
901 * DESCRIPTION:	unSet Always PS to PowerMgr
902 *
903 * INPUTS:		pSoftGemini - the object
904 *
905 ***************************************************************************/
SoftGemini_unSetPS(SoftGemini_t * pSoftGemini)906 static TI_STATUS SoftGemini_unSetPS(SoftGemini_t	*pSoftGemini)
907 {
908 	paramInfo_t param;
909 
910 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s, SG-unSetPS \n",__FUNCTION__));
911 
912      /* disable SG priority for Power Mgr*/
913 	param.paramType = POWER_MGR_DISABLE_PRIORITY;
914 	param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
915 	return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
916 
917 }
918 
919 /***************************************************************************
920 *					SoftGemini_EnableProtectiveMode  		    	       *
921 ****************************************************************************
922 * DESCRIPTION:	Activated when FW inform us that protective mode is ON
923 *
924 *
925 * INPUTS:		pSoftGemini - the object
926 *
927 ***************************************************************************/
SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini)928 void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini)
929 {
930 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
931 	paramInfo_t 	param;
932 
933 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
934 
935 	pSoftGemini->bProtectiveMode = TRUE;
936 
937 	/* set new configurations of SG roaming parameters */
938 	currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,pSoftGemini->BSSLossCompensationPercent,TRUE);
939 
940 	/* set new configurations of scan to scancncn */
941 	scanConcentrator_SGconfigureScanParams(pSoftGemini->hScanCncn,TRUE,pSoftGemini->scanNumOfProbeRequest,
942 		pSoftGemini->scanCompensationMaxTime,pSoftGemini->scanCompensationPercent);
943 
944     /* Call the power manager to enter short doze */
945 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SoftGemini_EnableProtectiveMode set SD"));
946 
947 	/* Set Params to Power Mgr for SG priority */
948 	param.paramType = POWER_MGR_POWER_MODE;
949 	param.content.powerMngPowerMode.PowerMode = POWER_MODE_SHORT_DOZE;
950 	param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
951 	powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
952 }
953 
954 /***************************************************************************
955 *					SoftGemini_DisableProtectiveMode  		    	       *
956 ****************************************************************************
957 * DESCRIPTION:	Activated when FW inform us that protective mode is OFF or SG is disabled
958 *
959 * INPUTS:		pSoftGemini - the object
960 *
961 ***************************************************************************/
SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini)962 void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini)
963 {
964 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
965 
966 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
967 
968 	pSoftGemini->bProtectiveMode = FALSE;
969 
970 	SoftGemini_RemoveProtectiveModeParameters(hSoftGemini);
971 }
972 
973 /***************************************************************************
974 *					SoftGemini_DisableProtectiveMode  		    	       *
975 ****************************************************************************
976 * DESCRIPTION:	Called from SoftGemini_DisableProtectiveMode() when FW inform
977 *				us that protective mode is OFF or SG is disabled, or from
978 *				SoftGemini_unSetPSmode() when driver disconnects from AP.
979 *
980 * INPUTS:		pSoftGemini - the object
981 *
982 ***************************************************************************/
983 
SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini)984 void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini)
985 {
986 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
987 	paramInfo_t  	param;
988 
989 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__));
990 
991 	/* don't use the SG roaming parameters */
992 	currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,0,FALSE);
993 
994 	/* don't use the SG scan parameters */
995 	scanConcentrator_SGconfigureScanParams(pSoftGemini->hScanCncn,FALSE,0,0,0);
996 
997     /* Call the power manager to exit short doze */
998 	/* Set Params to Power Mgr for SG priority */
999 	param.paramType = POWER_MGR_POWER_MODE;
1000 	param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
1001 	param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
1002 	powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
1003 }
1004 
1005 /***************************************************************************
1006 *					SoftGemini_SenseIndicationCB  		    	       *
1007 ****************************************************************************
1008 * DESCRIPTION:	This is the the function which is called for sense mode indication from FW
1009 *				(i.e. we are in SENSE mode and FW detects BT activity )
1010 *				SENSE_MODE_ENABLE - Indicates that FW detected BT activity
1011 *				SENSE_MODE_DISABLE - Indicates that FW doesn't detect BT activity for a period of time
1012 *
1013 * INPUTS:		pSoftGemini - the object
1014 * NOTE			This function is located in the API for debug purposes
1015 ***************************************************************************/
1016 
SoftGemini_SenseIndicationCB(TI_HANDLE hSoftGemini,char * str,UINT32 strLen)1017 void SoftGemini_SenseIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
1018 {
1019 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1020 
1021 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s with 0x%x\n",__FUNCTION__,*str));
1022 
1023 	if ((SG_SENSE_NO_ACTIVITY == pSoftGemini->SoftGeminiEnable) && (SENSE_MODE_ENABLE == *str))
1024 	{
1025 		SoftGemini_setEnableParam(hSoftGemini, SG_SENSE_ACTIVE, FALSE);
1026 	}
1027 	else if ((SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable) && (SENSE_MODE_DISABLE == *str))
1028 	{
1029 		SoftGemini_setEnableParam(hSoftGemini, SG_SENSE_NO_ACTIVITY, FALSE);
1030 	}
1031 	else
1032 	{
1033 			WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : %s called when SG mode is %s ? \n",
1034 				__FUNCTION__,SoftGemini_ConvertModeToString(((SENSE_MODE_ENABLE == *str) ? SG_SENSE_ACTIVE : SG_SENSE_NO_ACTIVITY))
1035 				,SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable)));
1036 	}
1037 }
1038 
1039 /***************************************************************************
1040 *					SoftGemini_ProtectiveIndicationCB  		    	       *
1041 ****************************************************************************
1042 * DESCRIPTION:	This is the the function which is called when FW starts Protective mode (i.e BT voice)
1043 *
1044 *				PROTECTIVE_MODE_ON - FW is activated on protective mode (BT voice is running)
1045 *				PROTECTIVE_MODE_OFF - FW is not activated on protective mode
1046 *
1047 * INPUTS:		pSoftGemini - the object
1048 * NOTE			This function is located in the API for debug purposes
1049 ***************************************************************************/
1050 
SoftGemini_ProtectiveIndicationCB(TI_HANDLE hSoftGemini,char * str,UINT32 strLen)1051 void SoftGemini_ProtectiveIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
1052 {
1053 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1054 
1055 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s with 0x%x\n",__FUNCTION__,*str));
1056 
1057 	if ((SG_ENABLE == pSoftGemini->SoftGeminiEnable) ||
1058 		(SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable))
1059 	{
1060 		if ((!pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_ON == *str))
1061 		{
1062 			SoftGemini_EnableProtectiveMode(hSoftGemini);
1063 		}
1064 		else if ((pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_OFF == *str))
1065 		{
1066 			SoftGemini_DisableProtectiveMode(hSoftGemini);
1067 		}
1068 		else
1069 		{
1070 			WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : Protective mode %s called when Protective mode is %s \n",
1071 			__FUNCTION__,((PROTECTIVE_MODE_ON == *str) ? "ON" : "OFF"),((pSoftGemini->bProtectiveMode) ? "ON" : "OFF")));
1072 		}
1073 	}
1074 	else
1075 	{
1076 		WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : Protective mode %s called when SG mode is %s ? \n",
1077 			__FUNCTION__,((PROTECTIVE_MODE_ON == *str) ? "ON" : "OFF"),SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable)));
1078 	}
1079 }
1080 
1081 /***************************************************************************
1082 *					SoftGemini_AvalancheIndicationCB  		    	       *
1083 ****************************************************************************
1084 * DESCRIPTION:	This is the the function which is called when
1085 *				FW detect that our current connection quality is reducing
1086 *				(AP decrease his rates with his rate adaptation mechanism because
1087 *				of BT activity) the solution is reconnect to the same AP
1088 *
1089 * INPUTS:		pSoftGemini - the object
1090 * NOTE			This function is located in the API for debug purposes
1091 ***************************************************************************/
1092 
SoftGemini_AvalancheIndicationCB(TI_HANDLE hSoftGemini,char * str,UINT32 strLen)1093 void SoftGemini_AvalancheIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
1094 {
1095 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1096 
1097 	WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s \n",__FUNCTION__));
1098 
1099 	if ((SG_ENABLE == pSoftGemini->SoftGeminiEnable) ||
1100 		(SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable))
1101 	{
1102 		SoftGemini_reconnect(hSoftGemini);
1103 	}
1104 	else
1105 	{
1106 		WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
1107 			("%s : Avalanche Avoidance called when SG mode is %s \n",
1108 			__FUNCTION__,SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable)));
1109 	}
1110 
1111 }
1112 
1113 /***************************************************************************
1114 *					SoftGemini_ConvertModeToString  		    	       *
1115 ****************************************************************************/
1116 #ifdef REPORT_LOG
1117 
SoftGemini_ConvertModeToString(SoftGeminiEnableModes_e SoftGeminiEnable)1118 char* SoftGemini_ConvertModeToString(SoftGeminiEnableModes_e SoftGeminiEnable)
1119 {
1120 	switch(SoftGeminiEnable)
1121 	{
1122 	case SG_ENABLE:				return "SG_ENABLE";
1123 	case SG_DISABLE:			return "SG_DISABLE";
1124 	case SG_SENSE_NO_ACTIVITY:  return "SG_SENSE_NO_ACTIVITY";
1125 	case SG_SENSE_ACTIVE:		return "SG_SENSE_ACTIVE";
1126 	default:
1127 		return "ERROR";
1128 	}
1129 }
1130 
1131 #endif
1132 
1133 /***************************************************************************
1134 *					SoftGemini_getSGMode						  		    	       *
1135 ****************************************************************************/
SoftGemini_getSGMode(TI_HANDLE hSoftGemini)1136 SoftGeminiEnableModes_e SoftGemini_getSGMode(TI_HANDLE hSoftGemini)
1137 {
1138 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1139 	return pSoftGemini->SoftGeminiEnable;
1140 }
1141 
1142 /***************************************************************************
1143 *					SoftGemini_handleRecovery					    	       *
1144 ****************************************************************************
1145 * DESCRIPTION:	The function reconfigures WHAL with the SG parameters.
1146 *
1147 * INPUTS:		pSoftGemini - the object
1148 ***************************************************************************/
SoftGemini_handleRecovery(TI_HANDLE hSoftGemini)1149 TI_STATUS SoftGemini_handleRecovery(TI_HANDLE hSoftGemini)
1150 {
1151 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1152 	SoftGeminiEnableModes_e       realSoftGeminiEnableMode;
1153 
1154 	realSoftGeminiEnableMode = pSoftGemini->SoftGeminiEnable;
1155     /* Disable the SG */
1156     SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, TRUE);
1157     WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("Disable SG \n"));
1158 
1159 	pSoftGemini->SoftGeminiEnable = realSoftGeminiEnableMode;
1160 	/* Set enable param */
1161 	if (pSoftGemini->SoftGeminiEnable == SG_SENSE_ACTIVE)
1162 	{
1163 		pSoftGemini->SoftGeminiEnable = SG_SENSE_NO_ACTIVITY;
1164 	}
1165     SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->SoftGeminiEnable, TRUE);
1166     WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("Set SG to-%d\n", pSoftGemini->SoftGeminiEnable));
1167 
1168 	/* Config the params to FW */
1169 	SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
1170 	/*SoftGemini_printParams(hSoftGemini);*/
1171 	return OK;
1172 }
1173 /***************************************************************************
1174 *					SoftGemini_startPsPollFailure					       *
1175 ****************************************************************************
1176 * DESCRIPTION:	After Ps-Poll failure we disable the SG
1177 *
1178 * INPUTS:		pSoftGemini - the object
1179 ***************************************************************************/
SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini)1180 void SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini)
1181 {
1182     SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1183 
1184     WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("%s\n",__FUNCTION__));
1185 
1186     if ( !pSoftGemini->bPsPollFailureActive && !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts)
1187     {
1188         pSoftGemini->PsPollFailureLastEnableValue = pSoftGemini->SoftGeminiEnable;
1189 
1190         /* Disable SG if needed */
1191         if ( pSoftGemini->SoftGeminiEnable != SG_DISABLE )
1192         {
1193             SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, FALSE);
1194         }
1195 
1196         pSoftGemini->bPsPollFailureActive = TRUE;
1197     }
1198     else /* Calling SoftGemini_startPsPollFailure twice ? */
1199     {
1200         WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
1201             ("Calling  SoftGemini_startPsPollFailure while bPsPollFailureActive is TRUE\n"));
1202     }
1203 }
1204 
1205 /***************************************************************************
1206 *					SoftGemini_endPsPollFailure					    	   *
1207 ****************************************************************************
1208 * DESCRIPTION:	Return to normal behavior after the PsPoll failure
1209 *
1210 * INPUTS:		pSoftGemini - the object
1211 ***************************************************************************/
SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini)1212 void SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini)
1213 {
1214     SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
1215 
1216     WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("%s\n",__FUNCTION__));
1217 
1218     if ( pSoftGemini->bPsPollFailureActive )
1219     {
1220         pSoftGemini->bPsPollFailureActive = FALSE;
1221 
1222         /* return to previous value */
1223         if ( pSoftGemini->PsPollFailureLastEnableValue != SG_DISABLE )
1224         {
1225             if ( pSoftGemini->PsPollFailureLastEnableValue == SG_SENSE_ACTIVE)
1226             {
1227                 /* In this case Fw must get SG_SENSE_NO_ACTIVITY to start sensing again */
1228                 pSoftGemini->PsPollFailureLastEnableValue = SG_SENSE_NO_ACTIVITY;
1229             }
1230 
1231             SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->PsPollFailureLastEnableValue, FALSE);
1232         }
1233     }
1234     else /* Calling SoftGemini_endPsPollFailure twice ? */
1235     {
1236         WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,
1237             ("Calling  SoftGemini_endPsPollFailure while bPsPollFailureActive is FALSE\n"));
1238     }
1239 }
1240 
1241 
1242