blob: b8ae3c5120f8927345f818759bdb6b7cfa086f79 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*===========================================================================
43
44 b a p A p i L i n k C n t l . C
45
46 OVERVIEW:
47
48 This software unit holds the implementation of the WLAN BAP modules
49 Link Control functions.
50
51 The functions externalized by this module are to be called ONLY by other
52 WLAN modules (HDD) that properly register with the BAP Layer initially.
53
54 DEPENDENCIES:
55
56 Are listed for each API below.
57
58
59 Copyright (c) 2008 QUALCOMM Incorporated.
60 All Rights Reserved.
61 Qualcomm Confidential and Proprietary
62===========================================================================*/
63
64/*===========================================================================
65
66 EDIT HISTORY FOR FILE
67
68
69 This section contains comments describing changes made to the module.
70 Notice that changes are listed in reverse chronological order.
71
72
73 $Header: /home/labuser/ampBlueZ_2/CORE/BAP/src/bapApiLinkCntl.c,v 1.1 2010/10/23 23:40:28 labuser Exp labuser $$DateTime$$Author: labuser $
74
75
76 when who what, where, why
77---------- --- --------------------------------------------------------
782008-09-15 jez Created module
79
80===========================================================================*/
81
82/*----------------------------------------------------------------------------
83 * Include Files
84 * -------------------------------------------------------------------------*/
85//#include "wlan_qct_tl.h"
86#include "vos_trace.h"
87// Pick up the CSR callback definition
88#include "csrApi.h"
89
90/* BT-AMP PAL API header file */
91#include "bapApi.h"
92#include "bapInternal.h"
93#include "btampFsm.h"
94
95//#define BAP_DEBUG
96/*----------------------------------------------------------------------------
97 * Preprocessor Definitions and Constants
98 * -------------------------------------------------------------------------*/
99
100
101/*----------------------------------------------------------------------------
102 * Type Declarations
103 * -------------------------------------------------------------------------*/
104
105/*----------------------------------------------------------------------------
106 * Global Data Definitions
107 * -------------------------------------------------------------------------*/
108
109/*----------------------------------------------------------------------------
110 * Static Variable Definitions
111 * -------------------------------------------------------------------------*/
112
113/*----------------------------------------------------------------------------
114 * Static Function Declarations and Definitions
115 * -------------------------------------------------------------------------*/
116
117/*----------------------------------------------------------------------------
118 * Externalized Function Definitions
119* -------------------------------------------------------------------------*/
120
121/*----------------------------------------------------------------------------
122 * Function Declarations and Documentation
123 * -------------------------------------------------------------------------*/
124
125/*----------------------------------------------------------------------------
126
127 FUNCTION WLANBAP_RoamCallback()
128
129 DESCRIPTION
130 Callback for Roam (connection status) Events
131
132 DEPENDENCIES
133 NA.
134
135 PARAMETERS
136
137 IN
138 pContext: is the pContext passed in with the roam request
139 pCsrRoamInfo: is a pointer to a tCsrRoamInfo, see definition of eRoamCmdStatus and
140 eRoamCmdResult: for detail valid members. It may be NULL
141 roamId: is to identify the callback related roam request. 0 means unsolicited
142 roamStatus: is a flag indicating the status of the callback
143 roamResult: is the result
144
145 RETURN VALUE
146 The eHalStatus code associated with performing the operation
147
148 eHAL_STATUS_SUCCESS: Success
149
150 SIDE EFFECTS
151
152----------------------------------------------------------------------------*/
153#if 0
154eCSR_ROAM_RESULT_WDS_STARTED
155#define eWLAN_BAP_MAC_START_BSS_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
156
157eCSR_ROAM_RESULT_FAILURE
158eCSR_ROAM_RESULT_NOT_ASSOCIATED
159#define eWLAN_BAP_MAC_START_FAILS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
160
161eCSR_ROAM_RESULT_WDS_ASSOCIATED
162#define eWLAN_BAP_MAC_CONNECT_COMPLETED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATED */
163
164
165eCSR_ROAM_RESULT_FAILURE
166eCSR_ROAM_RESULT_NOT_ASSOCIATED
167#define eWLAN_BAP_MAC_CONNECT_FAILED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
168
169
170eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND
171#define eWLAN_BAP_MAC_CONNECT_INDICATION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND */
172
173
174eCSR_ROAM_RESULT_KEY_SET
175#define eWLAN_BAP_MAC_KEY_SET_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_KEY_SET */
176
177
178eCSR_ROAM_RESULT_WDS_DISASSOC_IND
179#define eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_DISASSOC_IND */
180
181
182eCSR_ROAM_RESULT_WDS_STOPPED
183#define eWLAN_BAP_MAC_READY_FOR_CONNECTIONS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STOPPED */
184
185#endif //0
186
187
188eHalStatus
189WLANBAP_RoamCallback
190(
191 void *pContext,
192 tCsrRoamInfo *pCsrRoamInfo,
193 tANI_U32 roamId,
194 eRoamCmdStatus roamStatus,
195 eCsrRoamResult roamResult
196)
197{
198 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
199 /* btampContext value */
200 ptBtampContext btampContext = (ptBtampContext) pContext;
201 tWLAN_BAPEvent bapEvent; /* State machine event */
202 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
203 v_U8_t status; /* return the BT-AMP status here */
204 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
205
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700206 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, before switch on roamStatus = %d", __func__, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208 switch (roamStatus) {
209 //JEZ081110: For testing purposes, with Infra STA as BT STA, this
210 //actually takes care of the "eCSR_ROAM_RESULT_WDS_STARTED" case,
211 //below, better than "eCSR_ROAM_RESULT_IBSS_STARTED".
212 //case eCSR_ROAM_ROAMING_START:
213 case eCSR_ROAM_ASSOCIATION_START:
214 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700215 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_ROAMING_START", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 // This only gets called when CSR decides to roam on its own - due to lostlink.
217#if 0
218 if ((pCsrRoamInfo) && (pCsrRoamInfo->pConnectedProfile) && (pCsrRoamInfo->pConnectedProfile->pBssDesc))
219 {
220 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pConnectedProfile->pBssDesc->bssId,
221 sizeof(tSirMacAddr));
222 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700223 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 }
225#endif //0
226 /* Fill in the event structure */
227 bapEvent.event = eWLAN_BAP_MAC_START_BSS_SUCCESS;
228 bapEvent.params = pCsrRoamInfo;
229 bapEvent.u1 = roamStatus;
230 bapEvent.u2 = roamResult;
231
232 /* Handle event */
233 vosStatus = btampFsm(btampContext, &bapEvent, &status);
234
235 break;
236
237 case eCSR_ROAM_SET_KEY_COMPLETE:
238 /* bapRoamCompleteCallback with eCSR_ROAM_SET_KEY_COMPLETE */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700239 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)", __func__, "eCSR_ROAM_SET_KEY_COMPLETE", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
241 /* Fill in the event structure */
242 bapEvent.event = eWLAN_BAP_MAC_KEY_SET_SUCCESS;
243 bapEvent.params = pCsrRoamInfo;
244 bapEvent.u1 = roamStatus;
245 bapEvent.u2 = roamResult;
246
247 /* Handle event */
248 vosStatus = btampFsm(btampContext, &bapEvent, &status);
249
250 break;
251
252 case eCSR_ROAM_DISASSOCIATED:
253 /* bapRoamCompleteCallback with eCSR_ROAM_DISASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700254 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)", __func__, "eCSR_ROAM_DISASSOCIATED", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 case eCSR_ROAM_LOSTLINK:
256 /* bapRoamCompleteCallback with eCSR_ROAM_LOSTLINK */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700257 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)", __func__, "eCSR_ROAM_LOSTLINK", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700258
259 if (roamResult != eCSR_ROAM_RESULT_NONE) {
260 /* Fill in the event structure */
261 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
262 bapEvent.params = pCsrRoamInfo;
263 bapEvent.u1 = roamStatus;
264 bapEvent.u2 = roamResult;
265
266 /* Handle event */
267 vosStatus = btampFsm(btampContext, &bapEvent, &status);
268 }
269
270 break;
271
272 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700273 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, unsupported CSR roamStatus = %d", __func__, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275 break;
276 }
277
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700278 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, before switch on roamResult = %d", __func__, roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 switch (roamResult) {
281 //JEZ081110: Commented out for testing. Test relies upon IBSS.
282 case eCSR_ROAM_RESULT_IBSS_STARTED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700283 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_IBSS_STARTED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 case eCSR_ROAM_RESULT_WDS_STARTED:
285 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700286 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_STARTED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 /* Fill in the event structure */
289 bapEvent.event = eWLAN_BAP_MAC_START_BSS_SUCCESS;
290 bapEvent.params = pCsrRoamInfo;
291 bapEvent.u1 = roamStatus;
292 bapEvent.u2 = roamResult;
293
294 /* Handle event */
295 vosStatus = btampFsm(btampContext, &bapEvent, &status);
296
297 break;
298
299 //JEZ081110: Commented out for testing. Test relies upon IBSS.
300 //JEZ081110: But I cannot rely upon IBSS for the initial testing.
301 case eCSR_ROAM_RESULT_FAILURE:
302 //case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
303 //case eCSR_ROAM_RESULT_IBSS_START_FAILED:
304 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700305 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_FAILURE", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700306#ifdef FEATURE_WLAN_BTAMP_UT_RF
307 break;
308#endif
309 case eCSR_ROAM_RESULT_WDS_START_FAILED:
310 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_START_FAILED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700311 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_START_FAILED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700312
313 /* Fill in the event structure */
314 /* I don't think I should signal a eCSR_ROAM_RESULT_FAILURE
315 * as a eWLAN_BAP_MAC_START_FAILS
316 */
317 bapEvent.event = eWLAN_BAP_MAC_START_FAILS;
318 bapEvent.params = pCsrRoamInfo;
319 bapEvent.u1 = roamStatus;
320 bapEvent.u2 = roamResult;
321
322 /* Handle event */
323 vosStatus = btampFsm(btampContext, &bapEvent, &status);
324
325 break;
326
327 //JEZ081110: Commented out for testing. This handles both Infra STA and IBSS STA.
328 case eCSR_ROAM_RESULT_IBSS_CONNECT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700329 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 case eCSR_ROAM_RESULT_ASSOCIATED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700331 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_ASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 case eCSR_ROAM_RESULT_WDS_ASSOCIATED:
333 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700334 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_ASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700335
336 /* Fill in the event structure */
337 bapEvent.event = eWLAN_BAP_MAC_CONNECT_COMPLETED;
338 bapEvent.params = pCsrRoamInfo;
339 bapEvent.u1 = roamStatus;
340 bapEvent.u2 = roamResult;
341
342 /* Handle event */
343 vosStatus = btampFsm(btampContext, &bapEvent, &status);
344
345 break;
346
347 //JEZ081110: Commented out for testing. Test relies upon IBSS.
348 //JEZ081110: But I cannot rely upon IBSS for the initial testing.
349 //case eCSR_ROAM_RESULT_FAILURE:
350 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700351 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_IBSS_START_FAILED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
353 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700354 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_NOT_ASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355#ifdef FEATURE_WLAN_BTAMP_UT_RF
356 break;
357#endif
358 case eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED:
359 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700360 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362 /* Fill in the event structure */
363 bapEvent.event = eWLAN_BAP_MAC_CONNECT_FAILED;
364 bapEvent.params = pCsrRoamInfo;
365 bapEvent.u1 = roamStatus;
366 bapEvent.u2 = roamResult;
367
368 /* Handle event */
369 vosStatus = btampFsm(btampContext, &bapEvent, &status);
370
371 break;
372
373 //JEZ081110: I think I have to check for the bssType to
374 //differentiate between IBSS Start and IBSS Join success.
375 //case eCSR_ROAM_RESULT_IBSS_CONNECT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700376 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700377
378 //JEZ081110: Commented out for testing. Test relies upon IBSS.
379 // No longer commented out.
380 case eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND:
381 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700382 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383
384 /* Fill in the event structure */
385 bapEvent.event = eWLAN_BAP_MAC_CONNECT_INDICATION;
386 bapEvent.params = pCsrRoamInfo;
387 bapEvent.u1 = roamStatus;
388 bapEvent.u2 = roamResult;
389
390 /* Handle event */
391 vosStatus = btampFsm(btampContext, &bapEvent, &status);
392
393 /* If BAP doesn't like the incoming association, signal SME/CSR */
394 if ( status != WLANBAP_STATUS_SUCCESS)
395 halStatus = eHAL_STATUS_FAILURE;
396
397 break;
398
399 //JEZ081110: Not supported in SME and CSR, yet.
400#if 0
401 case eCSR_ROAM_RESULT_KEY_SET:
402 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_KEY_SET */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700403 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_KEY_SET", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404
405 /* Fill in the event structure */
406 bapEvent.event = eWLAN_BAP_MAC_KEY_SET_SUCCESS;
407 bapEvent.params = pCsrRoamInfo;
408 bapEvent.u1 = roamStatus;
409 bapEvent.u2 = roamResult;
410
411 /* Handle event */
412 vosStatus = btampFsm(btampContext, &bapEvent, &status);
413
414 break;
415#endif //0
416
417 case eCSR_ROAM_RESULT_DISASSOC_IND:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700418 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_DISASSOC_IND", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 case eCSR_ROAM_RESULT_WDS_DISASSOCIATED:
420 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_DISASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700421 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_DISASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
423 /* Fill in the event structure */
424 bapEvent.event = eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION;
425 bapEvent.params = pCsrRoamInfo;
426 bapEvent.u1 = roamStatus;
427 bapEvent.u2 = roamResult;
428
429 /* Handle event */
430 vosStatus = btampFsm(btampContext, &bapEvent, &status);
431
432 /* Fill in the event structure */
433 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
434 bapEvent.params = pCsrRoamInfo;
435 bapEvent.u1 = roamStatus;
436 bapEvent.u2 = roamResult;
437
438 /* Handle event */
439 vosStatus = btampFsm(btampContext, &bapEvent, &status);
440
441 break;
442
443 //JEZ081110: Commented out for testing. Test relies upon IBSS.
444 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700445 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_IBSS_INACTIVE", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 case eCSR_ROAM_RESULT_WDS_STOPPED:
447 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STOPPED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700448 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)", __func__, "eCSR_ROAM_RESULT_WDS_STOPPED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700449
450 /* Fill in the event structure */
451 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
452 bapEvent.params = pCsrRoamInfo;
453 bapEvent.u1 = roamStatus;
454 bapEvent.u2 = roamResult;
455
456 /* Handle event */
457 vosStatus = btampFsm(btampContext, &bapEvent, &status);
458
459 break;
460
461 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700462 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, unsupported CSR roamResult = %d", __func__, roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700463
464 break;
465 }
466
467#if 0
468 switch (roamResult) {
469 case eCSR_ROAM_RESULT_IBSS_CONNECT:
470 // we have an IBSS connection...
471
472 // update our state
473 btampContext->mAssociatedStatus = WLANBAP_STATUS_SUCCESS;
474 btampContext->mAssociated = VOS_TRUE;
475 // update "assocBssid" with the BSSID of the IBSS
476 if (pCsrRoamInfo)
477 memcpy(btampContext->assocBssid, pCsrRoamInfo->peerMacOrBssidForIBSS, 6);
478
479 // We must update the system role to match that of the
480 // lower layers in case the upper layers decided to try
481 // joining the network in infrastructure mode if the
482 // initial join in IBSS mode fails. Andreas Wolf
483 // (awolf@apple.com) explains the behavior as follows:
484 // "If the client attempts to join an open network and it fails
485 // on the first attempt, it reverts back to b-only mode. This
486 // workaround was specifically put in place to allow the client
487 // to associate to some third party b-only infrastructure APs.
488 // It did not take IBSS into account, it seems that the fallback
489 // always forces infrastructure."
490
491 btampContext->systemRole = eSYSTEM_STA_IN_IBSS_ROLE;
492
493 if (mLinkStatus == 0)
494 {
495 // enable the flow of data
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700496 DBGLOG("%s: marking link as up in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 mLinkStatus = 1;
498 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkUp);
499 outputQueue->setCapacity(TRANSMIT_QUEUE_SIZE);
500 outputQueue->start();
501 // Let them know we are ready
502 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_ASSOC_DONE);
503 }
504 else
505 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700506 DBGLOG("%s: link is already up in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 }
508 break;
509
510 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
511 // we have no more IBSS peers, so disable the flow of data
512 if (mLinkStatus != 0)
513 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700514 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_INACTIVE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 mLinkStatus = (tANI_U8) 0;
516 // JEZ070627: Revisit ?
517 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
518 outputQueue->stop();
519 outputQueue->setCapacity(0);
520
521 // update our state
522 btampContext->mAssociated = false;
523 }
524 else
525 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700526 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_INACTIVE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 }
528
529 break;
530
531 case eCSR_ROAM_RESULT_ASSOCIATED:
532 btampContext->mAssociatedStatus = APPLE80211_STATUS_SUCCESS;
533 btampContext->mAssociated = true;
534
535 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc)) {
536 ccpCsrToAppleScanResult(mPMacObject, pCsrRoamInfo->pBssDesc, &scanResult);
537
538 /* Save away the IEs used by the AP */
539 ccpCsrToAssocApiedata( mPMacObject, pCsrRoamInfo->pBssDesc, &(btampContext->apiedata));
540
541 if (BssidChanged((tCsrBssid*) btampContext->assocBssid, (ether_addr*) scanResult.asr_bssid)) {
542 memcpy(btampContext->assocBssid, scanResult.asr_bssid, 6);
543 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_BSSID_CHANGED );
544 }
545 }
546
547 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_ASSOC_DONE);
548
549 if (mLinkStatus == 0)
550 {
551 mLinkStatus = (tANI_U8) 1;
552 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkUp);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700553 DBGLOG("%s: marking link as up in %s\n", __func__, "eCSR_ROAM_RESULT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 outputQueue->setCapacity(TRANSMIT_QUEUE_SIZE);
555 outputQueue->start();
556 }
557 else
558 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700559 DBGLOG("%s: link is already up in %s\n", __func__, "eCSR_ROAM_RESULT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561 break;
562 case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
563 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNAVAILABLE;
564 btampContext->mAssociated = false;
565
566 if (mLinkStatus != 0)
567 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700568 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_NOT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 mLinkStatus = (tANI_U8) 0;
570 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
571 }
572 else
573 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700574 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_NOT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 }
576 break;
577
578 case eCSR_ROAM_RESULT_FAILURE:
579 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNSPECIFIED_FAILURE;
580 btampContext->mAssociated = false;
581
582 if (mLinkStatus != 0)
583 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700584 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_FAILURE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 mLinkStatus = (tANI_U8) 0;
586 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
587 }
588 else
589 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700590 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_FAILURE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 }
592 break;
593
594 case eCSR_ROAM_RESULT_DISASSOC_IND:
595 {
596 btampContext->mAssociated = false;
597
598 if (mLinkStatus != 0)
599 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700600 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_DISASSOC_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 mLinkStatus = (tANI_U8) 0;
602 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
603 }
604 else
605 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700606 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_DISASSOC_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 }
608
609 //if (pCsrRoamInfo) // For now, leave this commented out. Until CSR changes integrated.
610 {
611 // Now set the reason and status codes.
612 // Actually, the "result code" field in the tSirSmeDisassocInd should be named reasonCode and NOT statusCode.
613 // "Reason Codes" are found in DisAssoc or DeAuth Ind. "Status Code" fields are found in Rsp Mgmt Frame.
614 // For now, we are going to have to (painfully) map the only "result code" type information we have
615 // available at ALL from LIM/CSR. And that is the statusCode field of type tSirResultCodes
616 // BTW, tSirResultCodes is the COMPLETELY WRONG TYPE for this "result code" field. It SHOULD be
617 // of type tSirMacReasonCodes.
618 // Right now, we don't even have that. So, I have to just make up some "reason code" that I will
619 // pretend I found in the incoming DisAssoc Indication.
620 //btampContext->statusCode = ((tpSirSmeDisassocInd) pCallbackInfo)->statusCode; // tSirResultCodes
621 //btampContext->reasonCode = ((tpSirSmeDisassocInd) pCallbackInfo)->statusCode; // tSirResultCodes
622 btampContext->reasonCode = (tANI_U16) eSIR_MAC_UNSPEC_FAILURE_REASON; //tANI_U16 // tSirMacReasonCodes
623 btampContext->deAuthReasonCode = 0; // tANI_U16 // eSIR_SME_DEAUTH_FROM_PEER
624 // Shouldn't the next line really use a tANI_U16? //0; // tANI_U16 // eSIR_SME_DISASSOC_FROM_PEER
625 btampContext->disassocReasonCode = btampContext->reasonCode; // tSirMacReasonCodes
626 // Let's remember the peer who just disassoc'd us
627 //memcpy(btampContext->peerMacAddr, pCsrRoamInfo->peerMacOrBssidForIBSS, 6);
628 }
629 }
630 break;
631
632 case eCSR_ROAM_RESULT_DEAUTH_IND:
633 {
634 btampContext->mAssociated = false;
635
636 if (mLinkStatus != 0)
637 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700638 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_DEAUTH_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 mLinkStatus = (tANI_U8) 0;
640 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
641 }
642 else
643 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700644 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_DEAUTH_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 }
646
647 //if (pCsrRoamInfo) // For now, leave this commented out. Until CSR changes integrated.
648 {
649 // Now set the reason and status codes.
650 // Actually, the "result code" field in the tSirSmeDeauthInd should be named reasonCode and NOT statusCode.
651 // "Reason Codes" are found in DisAssoc or DeAuth Ind. "Status Code" fields are found in Rsp Mgmt Frame.
652 // For now, we are going to have to (painfully) map the only "result code" type information we have
653 // available at ALL from LIM/CSR. And that is the statusCode field of type tSirResultCodes
654 // BTW, tSirResultCodes is the COMPLETELY WRONG TYPE for this "result code" field. It SHOULD be
655 // of type tSirMacReasonCodes.
656 // Right now, we don't even have that. So, I have to just make up some "reason code" that I will
657 // pretend I found in the incoming DeAuth Indication.
658 //btampContext->statusCode = ((tpSirSmeDeauthInd) pCallbackInfo)->statusCode; // tSirResultCodes
659 //btampContext->reasonCode = ((tpSirSmeDeauthInd) pCallbackInfo)->statusCode; // tSirResultCodes
660 btampContext->reasonCode = (tANI_U16) eSIR_MAC_UNSPEC_FAILURE_REASON; //tANI_U16 // tSirMacReasonCodes
661 btampContext->disassocReasonCode = 0; // tANI_U16 // eSIR_SME_DISASSOC_FROM_PEER
662 // Shouldn't the next line really use a tANI_U16? //0; // tANI_U16 // eSIR_SME_DEAUTH_FROM_PEER
663 btampContext->deAuthReasonCode = btampContext->reasonCode; // tSirMacReasonCodes
664 // Let's remember the peer who just de-auth'd us
665 //memcpy(btampContext->peerMacAddr, ((tpSirSmeDeauthInd) pCallbackInfo)->peerMacAddr, 6);
666 }
667 }
668 break;
669
670 case eCSR_ROAM_RESULT_MIC_ERROR_UNICAST:
671
672 //if (eCSR_ROAM_MIC_ERROR_IND == roamStatus) // Make sure
673 {
674 if (btampContext->mTKIPCounterMeasures)
675 {
676 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_MIC_ERROR_UCAST);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700677 DBGLOG("%s: TKIP Countermeasures in effect in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_UNICAST");
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 }
679 else
680 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700681 DBGLOG("%s: TKIP Countermeasures disabled in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_UNICAST");
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 }
683 }
684 break;
685
686 case eCSR_ROAM_RESULT_MIC_ERROR_GROUP:
687
688 //if (eCSR_ROAM_MIC_ERROR_IND == roamStatus) // Make sure
689 {
690 if (btampContext->mTKIPCounterMeasures)
691 {
692 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_MIC_ERROR_MCAST);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700693 DBGLOG("%s: TKIP Countermeasures in effect in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_GROUP");
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 }
695 else
696 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700697 DBGLOG("%s: TKIP Countermeasures disabled in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_GROUP");
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 }
699 }
700 break;
701
702 default:
703 break;
704 }
705 switch (roamStatus) {
706 case eCSR_ROAM_ROAMING_START:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700707 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ROAMING_START");
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 // This only gets called when CSR decides to roam on its own - due to lostlink.
709 // Apple still needs to be told.
710 if ((pCsrRoamInfo) && (pCsrRoamInfo->pConnectedProfile) && (pCsrRoamInfo->pConnectedProfile->pBssDesc))
711 {
712 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pConnectedProfile->pBssDesc->bssId,
713 sizeof(tSirMacAddr));
714 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700715 DBGLOG("%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 }
717 break;
718
719 case eCSR_ROAM_SHOULD_ROAM:
720 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc)) {
721 // pCallbackInfo points to the BSS desc. Convert to Apple Scan Result.
722 halStatus = ccpCsrToAppleScanResult(
723 mPMacObject,
724 pCsrRoamInfo->pBssDesc,
725 &scanResult);
726 if ( halStatus != 0 )
727 return eHAL_STATUS_FAILURE;
728 roamAccepted = apple80211Interface->shouldRoam(&scanResult); // Return result is crucial
729 if (roamAccepted == true) {
730 // If the roam is acceptable, return SUCCESS
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700731 DBGLOG("%s: shouldRoam returns \"acceptable\"\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700732//#if 0
733 // Actually, before returning, immediately signal willRoam
734 // This is a workaround for a CSR bug. Eventually, when
735 // eCSR_ROAM_ASSOCIATION_START gets called WITH callback param p1
736 // pointing to a tBssDescription, this work-around can be removed.
737 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pBssDesc->bssId, sizeof(tSirMacAddr));
738 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700739 DBGLOG("%s: willRoam (called out of order) returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 DBGLOG(" with BSSID = " MAC_ADDR_STRING(bssid.ether_addr_octet));
741//#endif
742 return eHAL_STATUS_SUCCESS;
743 } else {
744 // If the roam is NOT acceptable, return FAILURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 DBGLOG("%s: shouldRoam returns \"NOT acceptable\"\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 return eHAL_STATUS_FAILURE;
747 }
748 }
749 break;
750
751 case eCSR_ROAM_DISASSOCIATED:
752 //if (eCSR_ROAM_RESULT_FORCED == roamResult || eCSR_ROAM_RESULT_MIC_ERROR == roamResult)
753 {
754 btampContext->mAssociated = false;
755
756 if (mLinkStatus != 0)
757 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700758 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_DISASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 mLinkStatus = (tANI_U8) 0;
760 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
761 }
762 else
763 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_DISASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766 }
767 break;
768
769 case eCSR_ROAM_LOSTLINK:
770 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNSPECIFIED_FAILURE;
771 btampContext->mAssociated = false;
772
773 if (mLinkStatus != 0)
774 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700775 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_LOSTLINK");
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 mLinkStatus = (tANI_U8) 0;
777 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
778 }
779 else
780 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700781 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_LOSTLINK");
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 }
783 break;
784
785 case eCSR_ROAM_ASSOCIATION_START:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700786 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ASSOCIATION_START");
Jeff Johnson295189b2012-06-20 16:38:30 -0700787#if 0
788 // This is the right place to call willRoam - for an "initial" association.
789 // But, unfortunately, when eCSR_ROAM_ASSOCIATION_START gets called,
790 // it doesn't have a pointer to the tBssDescription in the roaming callback
791 // routines parameter p1 (pCallbackInfo in SetWextState). So, don't use this code, yet.
792 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc) {
793 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pBssDesc->bssId, 6);
794 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700795 DBGLOG("%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 DBGLOG(" with BSSID = " MAC_ADDR_STRING(bssid.ether_addr_octet));
797 }
798#endif //0
799 break;
800
801 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700802 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ASSOCIATION_COMPLETION");
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 break;
804
805 case eCSR_ROAM_MIC_ERROR_IND: // Handled in eCSR_ROAM_RESULT_MIC_ERROR_UNICAST and GROUP, above
806 case eCSR_ROAM_CANCELLED:
807 case eCSR_ROAM_ROAMING_COMPLETION:
808 case eCSR_ROAM_SCAN_FOUND_NEW_BSS:
809 default:
810 break;
811 }
812#endif //0
813
814 return halStatus;
815}
816
817/*----------------------------------------------------------------------------
818 Host Controller Interface Procedural API
819 ---------------------------------------------------------------------------*/
820
821/** BT v3.0 Link Control commands */
822
823/*----------------------------------------------------------------------------
824 Each of the next eight command result in asynchronous events (e.g.,
825 HCI_PHYSICAL_LINK_COMPLETE_EVENT, HCI_LOGICAL_LINK_COMPLETE_EVENT, etc...)
826 These are signalled thru the event callback. (I.E., (*tpWLAN_BAPEventCB).)
827 ---------------------------------------------------------------------------*/
828
829/*----------------------------------------------------------------------------
830
831 FUNCTION WLAN_BAPPhysicalLinkCreate()
832
833 DESCRIPTION
834 Implements the actual HCI Create Physical Link command
835
836 DEPENDENCIES
837 NA.
838
839 PARAMETERS
840
841 IN
842 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
843 WLANBAP_GetNewHndl has to be called before every call to
844 WLAN_BAPPhysicalLinkCreate. Since the context is per
845 physical link.
846 pBapHCIPhysLinkCreate: pointer to the "HCI Create Physical Link" Structure.
847 pHddHdl: The context passed in by the caller. (e.g., BSL specific context)
848
849 IN/OUT
850 pBapHCIEvent: Return event value for the command status event.
851 (The caller of this routine is responsible for sending
852 the Command Status event up the HCI interface.)
853
854 RETURN VALUE
855 The result code associated with performing the operation
856
857 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkCreate is NULL
858 VOS_STATUS_SUCCESS: Success
859
860 SIDE EFFECTS
861
862----------------------------------------------------------------------------*/
863VOS_STATUS
864WLAN_BAPPhysicalLinkCreate
865(
866 ptBtampHandle btampHandle,
867 tBtampTLVHCI_Create_Physical_Link_Cmd *pBapHCIPhysLinkCreate,
868 v_PVOID_t pHddHdl, /* BSL passes in its specific context */
869 /* And I get phy_link_handle from the Command */
870 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
871 /* Including Command Complete and Command Status*/
872)
873{
874 tWLAN_BAPEvent bapEvent; /* State machine event */
875 VOS_STATUS vosStatus;
876 /* I am using btampContext, instead of pBapPhysLinkMachine */
877 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
878 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
879 v_U8_t status; /* return the BT-AMP status here */
880 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
881
882 /* Validate params */
883 if ((pBapHCIPhysLinkCreate == NULL) || (NULL == btampContext))
884 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530885 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: btampHandle value: %p, pBapHCIPhysLinkCreate is %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700886 __func__, btampHandle, pBapHCIPhysLinkCreate);
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 return VOS_STATUS_E_FAULT;
888 }
889
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530890 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -0700891
892 if(DISCONNECTED != instanceVar->stateVar)
893 {
894 /* Create/Accept Phy link request in invalid state */
895 status = WLANBAP_ERROR_MAX_NUM_CNCTS;
896
897 }
898 else
899 {
900 /* Fill in the event structure */
901 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_CREATE;
902 bapEvent.params = pBapHCIPhysLinkCreate;
903 //bapEvent.callback = pBapHCIPhysLinkCreateCB;
904
905 /* Allocate a new state machine instance */
906 /* There will only ever be one of these (NB: Don't assume this.) */
907 /* So for now this returns a pointer to a static structure */
908 /* (With all state set to initial values) */
909 vosStatus = WLANBAP_CreateNewPhyLinkCtx (
910 btampHandle,
911 pBapHCIPhysLinkCreate->phy_link_handle, /* I get phy_link_handle from the Command */
912 pHddHdl, /* BSL passes in its specific context */
913 &btampContext, /* Handle to return per assoc btampContext value in */
914 BT_INITIATOR); /* BT_INITIATOR */
915
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530916 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700917
918 /* Handle event */
919 vosStatus = btampFsm(btampContext, &bapEvent, &status);
920 }
921
922 /* Format the command status event to return... */
923 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
924 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
925 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
926 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
927 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
928 = BTAMP_TLV_HCI_CREATE_PHYSICAL_LINK_CMD;
929
930 /* ... */
931
932 return VOS_STATUS_SUCCESS;
933} /* WLAN_BAPPhysicalLinkCreate */
934
935/*----------------------------------------------------------------------------
936
937 FUNCTION WLAN_BAPPhysicalLinkAccept()
938
939 DESCRIPTION
940 Implements the actual HCI Accept Physical Link command
941
942 DEPENDENCIES
943 NA.
944
945 PARAMETERS
946
947 IN
948 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
949 pBapHCIPhysLinkAccept: pointer to the "HCI Accept Physical Link" Structure.
950 pHddHdl: The context passed in by the caller. (e.g., BSL specific context)
951
952 IN/OUT
953 pBapHCIEvent: Return event value for the command status event.
954 (The caller of this routine is responsible for sending
955 the Command Status event up the HCI interface.)
956
957 RETURN VALUE
958 The result code associated with performing the operation
959
960 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkAccept is NULL
961 VOS_STATUS_SUCCESS: Success
962
963 SIDE EFFECTS
964
965----------------------------------------------------------------------------*/
966VOS_STATUS
967WLAN_BAPPhysicalLinkAccept
968(
969 ptBtampHandle btampHandle,
970 tBtampTLVHCI_Accept_Physical_Link_Cmd *pBapHCIPhysLinkAccept,
971 v_PVOID_t pHddHdl, /* BSL passes in its specific context */
972 /* And I get phy_link_handle from the Command */
973 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
974 /* Including Command Complete and Command Status*/
975)
976{
977 tWLAN_BAPEvent bapEvent; /* State machine event */
978 VOS_STATUS vosStatus;
979 /* I am using btampContext, instead of pBapPhysLinkMachine */
980 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
981 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
982 v_U8_t status; /* return the BT-AMP status here */
983 BTAMPFSM_INSTANCEDATA_T *instanceVar;
984
985 /* Validate params */
986 if ((pBapHCIPhysLinkAccept == NULL) || (NULL == btampContext))
987 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530988 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: btampHandle value: %p, pBapHCIPhysLinkAccept is %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700989 __func__, btampHandle, pBapHCIPhysLinkAccept);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 return VOS_STATUS_E_FAULT;
991 }
992
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530993 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -0700994
995 instanceVar = &(btampContext->bapPhysLinkMachine);
996 if(DISCONNECTED != instanceVar->stateVar)
997 {
998 /* Create/Accept Phy link request in invalid state */
999 status = WLANBAP_ERROR_MAX_NUM_CNCTS;
1000
1001 }
1002 else
1003 {
1004 /* Fill in the event structure */
1005 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_ACCEPT;
1006 bapEvent.params = pBapHCIPhysLinkAccept;
1007 //bapEvent.callback = pBapHCIPhysLinkAcceptCB;
1008
1009 /* Allocate a new state machine instance */
1010 /* There will only ever be one of these (NB: Don't assume this.) */
1011 /* So for now this returns a pointer to a static structure */
1012 /* (With all state set to initial values) */
1013 vosStatus = WLANBAP_CreateNewPhyLinkCtx (
1014 btampHandle,
1015 pBapHCIPhysLinkAccept->phy_link_handle, /* I get phy_link_handle from the Command */
1016 pHddHdl, /* BSL passes in its specific context */
1017 &btampContext, /* Handle to return per assoc btampContext value in */
1018 BT_RESPONDER); /* BT_RESPONDER */
1019
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301020 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021
1022 /* Handle event */
1023 vosStatus = btampFsm(btampContext, &bapEvent, &status);
1024
1025 }
1026 /* Format the command status event to return... */
1027 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1028 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
1029 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
1030 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
1031 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
1032 = BTAMP_TLV_HCI_ACCEPT_PHYSICAL_LINK_CMD;
1033
1034 /* ... */
1035
1036 return VOS_STATUS_SUCCESS;
1037} /* WLAN_BAPPhysicalLinkAccept */
1038
1039/*----------------------------------------------------------------------------
1040
1041 FUNCTION WLAN_BAPPhysicalLinkDisconnect()
1042
1043 DESCRIPTION
1044 Implements the actual HCI Disconnect Physical Link command
1045
1046 DEPENDENCIES
1047 NA.
1048
1049 PARAMETERS
1050
1051 IN
1052 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1053 pBapHCIPhysLinkDisconnect: pointer to the "HCI Disconnect Physical Link" Structure.
1054
1055 IN/OUT
1056 pBapHCIEvent: Return event value for the command status event.
1057 (The caller of this routine is responsible for sending
1058 the Command Status event up the HCI interface.)
1059
1060 RETURN VALUE
1061 The result code associated with performing the operation
1062
1063 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkDisconnect is NULL
1064 VOS_STATUS_SUCCESS: Success
1065
1066 SIDE EFFECTS
1067
1068----------------------------------------------------------------------------*/
1069VOS_STATUS
1070WLAN_BAPPhysicalLinkDisconnect
1071(
1072 ptBtampHandle btampHandle,
1073 tBtampTLVHCI_Disconnect_Physical_Link_Cmd *pBapHCIPhysLinkDisconnect,
1074 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1075 /* Including Command Complete and Command Status*/
1076)
1077{
1078 tWLAN_BAPEvent bapEvent; /* State machine event */
1079 VOS_STATUS vosStatus;
1080 /* I am using btampContext, instead of pBapPhysLinkMachine */
1081 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
1082 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
1083 v_U8_t status; /* return the BT-AMP status here */
1084
1085 /* Validate params */
1086 if (pBapHCIPhysLinkDisconnect == NULL) {
1087 return VOS_STATUS_E_FAULT;
1088 }
1089
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301090 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091
1092 /* Validate the Physical link handle */
1093 if (pBapHCIPhysLinkDisconnect->phy_link_handle != btampContext->phy_link_handle)
1094 {
1095 /* Format the command status event to return... */
1096 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1097 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
1098 pBapHCIEvent->u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1099 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
1100 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
1101 = BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_CMD;
1102 return VOS_STATUS_SUCCESS;
1103 }
1104
1105 /* Fill in the event structure */
1106 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT;
1107 bapEvent.params = pBapHCIPhysLinkDisconnect;
1108
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301109 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
1111 /* Handle event */
1112 vosStatus = btampFsm(btampContext, &bapEvent, &status);
1113
1114 /* Fill in the event structure */
1115 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
1116 bapEvent.params = pBapHCIPhysLinkDisconnect;
1117
1118 /* Handle event */
1119 vosStatus = btampFsm(btampContext, &bapEvent, &status);
1120
1121
1122 /* Format the command status event to return... */
1123 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1124 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
1125 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
1126 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
1127 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
1128 = BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_CMD;
1129
1130 /* ... */
1131
1132 return VOS_STATUS_SUCCESS;
1133} /* WLAN_BAPPhysicalLinkDisconnect */
1134
1135/*----------------------------------------------------------------------------
1136
1137 FUNCTION WLAN_BAPLogicalLinkCreate()
1138
1139 DESCRIPTION
1140 Implements the actual HCI Create Logical Link command
1141
1142 DEPENDENCIES
1143 NA.
1144
1145 PARAMETERS
1146
1147 IN
1148 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1149 pBapHCILogLinkCreate: pointer to the "HCI Create Logical Link" Structure.
1150
1151 IN/OUT
1152 pBapHCIEvent: Return event value for the command status event.
1153 (The caller of this routine is responsible for sending
1154 the Command Status event up the HCI interface.)
1155
1156 RETURN VALUE
1157 The result code associated with performing the operation
1158
1159 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkCreate is NULL
1160 VOS_STATUS_SUCCESS: Success
1161
1162 SIDE EFFECTS
1163
1164----------------------------------------------------------------------------*/
1165VOS_STATUS
1166WLAN_BAPLogicalLinkCreate
1167(
1168 ptBtampHandle btampHandle,
1169 tBtampTLVHCI_Create_Logical_Link_Cmd *pBapHCILogLinkCreate,
1170 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1171 /* Including Command Complete and Command Status*/
1172)
1173{
1174 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1175 VOS_STATUS vosStatus;
1176 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1177 v_U16_t log_link_index = 0;
1178 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
1179 VOS_STATUS retval;
1180 v_U16_t index_for_logLinkCtx = 0;
1181 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1182
1183
1184 /* Validate params */
1185 if (btampHandle == NULL) {
1186 return VOS_STATUS_E_FAULT;
1187 }
1188
1189 /* Validate params */
1190 if (pBapHCILogLinkCreate == NULL) {
1191 return VOS_STATUS_E_FAULT;
1192 }
1193
1194
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301195 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001196
1197 /* Validate the BAP state to accept the logical link request
1198 Logical Link create/accept requests are allowed only in
1199 CONNECTED state */
1200 /* Form and immediately return the command status event... */
1201 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1202 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1203 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1204 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1205 = BTAMP_TLV_HCI_CREATE_LOGICAL_LINK_CMD;
1206
1207 retval = VOS_STATUS_E_FAILURE;
1208 if(DISCONNECTED == instanceVar->stateVar)
1209 {
1210 /* Create Logical link request in invalid state */
1211 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1212 WLANBAP_ERROR_CMND_DISALLOWED;
1213 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1214
1215 }
1216 else if (CONNECTED != instanceVar->stateVar)
1217 {
1218 /* Create Logical link request in invalid state */
1219 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1220 WLANBAP_ERROR_CMND_DISALLOWED;
1221 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_CMND_DISALLOWED;
1222 }
1223 else if (pBapHCILogLinkCreate->phy_link_handle != btampContext->phy_link_handle)
1224 {
1225 /* Invalid Physical link handle */
1226 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1227 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1228 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1229 }
1230 else
1231 {
1232 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkInProgress;
1233
1234 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1235 {
1236 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1237 WLANBAP_ERROR_NO_CNCT;
1238 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1239 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1240 btampContext->btamp_logical_link_cancel_pending = FALSE;
1241 }
1242 else
1243 {
1244 /* If btamp_async_logical_link_create is set, we will seralize the req
1245 on MC thread & handle it there after; If the above flag is not set
1246 respond to HCI the sync way as before */
1247 if(FALSE == btampContext->btamp_async_logical_link_create)
1248 {
1249 /* Allocate a logical link index for these flow specs */
1250 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1251 btampContext, /* per assoc btampContext value */
1252 pBapHCILogLinkCreate->phy_link_handle, /* I get phy_link_handle from the Command */
1253 pBapHCILogLinkCreate->tx_flow_spec, /* I get tx_flow_spec from the Command */
1254 pBapHCILogLinkCreate->rx_flow_spec, /* I get rx_flow_spec from the Command */
1255 &log_link_index /* Return the logical link index here */
1256 );
1257 if (VOS_STATUS_SUCCESS != vosStatus)
1258 {
1259 /* Invalid flow spec format */
1260 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1261 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1262 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1263 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1264 }
1265 else
1266 {
1267 retval = VOS_STATUS_SUCCESS;
1268 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1269
1270 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1271 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1272 }
1273 }
1274 else
1275 {
1276 btampContext->btamp_logical_link_req_info.phyLinkHandle =
1277 pBapHCILogLinkCreate->phy_link_handle;
1278 vos_mem_copy(btampContext->btamp_logical_link_req_info.txFlowSpec,
1279 pBapHCILogLinkCreate->tx_flow_spec, 18);
1280 vos_mem_copy(btampContext->btamp_logical_link_req_info.rxFlowSpec,
1281 pBapHCILogLinkCreate->rx_flow_spec, 18);
1282 btampContext->btamp_async_logical_link_create = FALSE;
1283 vosStatus = btampEstablishLogLink(btampContext);
1284 if(VOS_STATUS_SUCCESS == vosStatus)
1285 {
1286 retval = VOS_STATUS_E_BUSY;//this will make sure event complete is not sent to HCI
1287 }
1288 else
1289 {
1290 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1291 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1292 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1293 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1294 }
1295
1296 }
1297 }
1298 }
1299
1300 vosStatus = (*btampContext->pBapHCIEventCB)
1301 (
1302 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1303 &bapHCIEvent, /* This now encodes ALL event types */
1304 VOS_TRUE /* Flag to indicate assoc-specific event */
1305 );
1306
1307 index_for_logLinkCtx = log_link_index >> 8;
1308 /* Format the Logical Link Complete event to return... */
1309 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1310 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.present = 1;
1311
1312 /* Return the logical link index here */
1313 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.log_link_handle
1314 = log_link_index;
1315 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.phy_link_handle
1316 = pBapHCILogLinkCreate->phy_link_handle;
1317 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.flow_spec_id
1318 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1319
1320 /* ... */
1321
1322 return retval;
1323} /* WLAN_BAPLogicalLinkCreate */
1324
1325/*----------------------------------------------------------------------------
1326
1327 FUNCTION WLAN_BAPLogicalLinkAccept()
1328
1329 DESCRIPTION
1330 Implements the actual HCI Accept Logical Link command
1331
1332 DEPENDENCIES
1333 NA.
1334
1335 PARAMETERS
1336
1337 IN
1338 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1339 pBapHCILogLinkAccept: pointer to the "HCI Accept Logical Link" Structure.
1340
1341 IN/OUT
1342 pBapHCIEvent: Return event value for the command status event.
1343 (The caller of this routine is responsible for sending
1344 the Command Status event up the HCI interface.)
1345
1346 RETURN VALUE
1347 The result code associated with performing the operation
1348
1349 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkAccept is NULL
1350 VOS_STATUS_SUCCESS: Success
1351
1352 SIDE EFFECTS
1353
1354----------------------------------------------------------------------------*/
1355VOS_STATUS
1356WLAN_BAPLogicalLinkAccept
1357(
1358 ptBtampHandle btampHandle,
1359 tBtampTLVHCI_Accept_Logical_Link_Cmd *pBapHCILogLinkAccept,
1360 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1361 /* Including Command Complete and Command Status*/
1362)
1363{
1364 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1365 VOS_STATUS vosStatus;
1366 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1367 v_U16_t log_link_index = 0;
1368 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
1369 VOS_STATUS retval;
1370 v_U16_t index_for_logLinkCtx;
1371 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1372
1373
1374 /* Validate params */
1375 if (btampHandle == NULL) {
1376 return VOS_STATUS_E_FAULT;
1377 }
1378
1379 /* Validate params */
1380 if (pBapHCILogLinkAccept == NULL) {
1381 return VOS_STATUS_E_FAULT;
1382 }
1383
1384
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301385 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
1387 /* Validate the BAP state to accept the logical link request
1388 Logical Link create/accept requests are allowed only in
1389 CONNECTED state */
1390 /* Form and immediately return the command status event... */
1391 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1392 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1393 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1394 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1395 = BTAMP_TLV_HCI_ACCEPT_LOGICAL_LINK_CMD;
1396
1397 retval = VOS_STATUS_E_FAILURE;
1398 if(DISCONNECTED == instanceVar->stateVar)
1399 {
1400 /* Create Logical link request in invalid state */
1401 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1402 WLANBAP_ERROR_CMND_DISALLOWED;
1403 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1404
1405 }
1406 else if (CONNECTED != instanceVar->stateVar)
1407 {
1408 /* Create Logical link request in invalid state */
1409 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1410 WLANBAP_ERROR_CMND_DISALLOWED;
1411 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_CMND_DISALLOWED;
1412 }
1413 else if (pBapHCILogLinkAccept->phy_link_handle != btampContext->phy_link_handle)
1414 {
1415 /* Invalid Physical link handle */
1416 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1417 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1418 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1419 }
1420 else
1421 {
1422 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkInProgress;
1423 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1424 {
1425 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1426 WLANBAP_ERROR_NO_CNCT;
1427 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1428 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1429 btampContext->btamp_logical_link_cancel_pending = FALSE;
1430 }
1431 else
1432 {
1433 /* If btamp_async_logical_link_create is set, we will seralize the req
1434 on MC thread & handle it there after; If the above flag is not set
1435 respond to HCI the sync way as before */
1436 if(FALSE == btampContext->btamp_async_logical_link_create)
1437 {
1438 /* Allocate a logical link index for these flow specs */
1439 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1440 btampContext, /* per assoc btampContext value */
1441 pBapHCILogLinkAccept->phy_link_handle, /* I get phy_link_handle from the Command */
1442 pBapHCILogLinkAccept->tx_flow_spec, /* I get tx_flow_spec from the Command */
1443 pBapHCILogLinkAccept->rx_flow_spec, /* I get rx_flow_spec from the Command */
1444 &log_link_index /* Return the logical link index here */
1445 );
1446 if (VOS_STATUS_SUCCESS != vosStatus)
1447 {
1448 /* Invalid flow spec format */
1449 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1450 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1451 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1452 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1453 }
1454 else
1455 {
1456 retval = VOS_STATUS_SUCCESS;
1457 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1458
1459 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1460 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1461 }
1462 }
1463 else
1464 {
1465 btampContext->btamp_logical_link_req_info.phyLinkHandle =
1466 pBapHCILogLinkAccept->phy_link_handle;
1467 vos_mem_copy(btampContext->btamp_logical_link_req_info.txFlowSpec,
1468 pBapHCILogLinkAccept->tx_flow_spec, 18);
1469 vos_mem_copy(btampContext->btamp_logical_link_req_info.rxFlowSpec,
1470 pBapHCILogLinkAccept->rx_flow_spec, 18);
1471 btampContext->btamp_async_logical_link_create = FALSE;
1472 vosStatus = btampEstablishLogLink(btampContext);
1473 if(VOS_STATUS_SUCCESS == vosStatus)
1474 {
1475 retval = VOS_STATUS_E_BUSY;//this will make sure event complete is not sent to HCI
1476 }
1477 else
1478 {
1479 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1480 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1481 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1482 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1483 }
1484
1485 }
1486 }
1487 }
1488 vosStatus = (*btampContext->pBapHCIEventCB)
1489 (
1490 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1491 &bapHCIEvent, /* This now encodes ALL event types */
1492 VOS_TRUE /* Flag to indicate assoc-specific event */
1493 );
1494
1495 index_for_logLinkCtx = log_link_index >> 8;
1496
1497 /* Format the Logical Link Complete event to return... */
1498 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1499 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.present = 1;
1500 /* Return the logical link index here */
1501 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.log_link_handle
1502 = log_link_index;
1503 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.phy_link_handle
1504 = pBapHCILogLinkAccept->phy_link_handle;
1505 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.flow_spec_id
1506 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1507
1508 /* ... */
1509
1510 return retval;
1511} /* WLAN_BAPLogicalLinkAccept */
1512
1513/*----------------------------------------------------------------------------
1514
1515 FUNCTION WLAN_BAPLogicalLinkDisconnect()
1516
1517 DESCRIPTION
1518 Implements the actual HCI Disconnect Logical Link command
1519
1520 DEPENDENCIES
1521 NA.
1522
1523 PARAMETERS
1524
1525 IN
1526 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1527 pBapHCILogLinkDisconnect: pointer to the "HCI Disconnect Logical Link" Structure.
1528
1529 IN/OUT
1530 pBapHCIEvent: Return event value for the command status event.
1531 (The caller of this routine is responsible for sending
1532 the Command Status event up the HCI interface.)
1533
1534 RETURN VALUE
1535 The result code associated with performing the operation
1536
1537 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkDisconnect is NULL
1538 VOS_STATUS_SUCCESS: Success
1539
1540 SIDE EFFECTS
1541
1542----------------------------------------------------------------------------*/
1543VOS_STATUS
1544WLAN_BAPLogicalLinkDisconnect
1545(
1546 ptBtampHandle btampHandle,
1547 tBtampTLVHCI_Disconnect_Logical_Link_Cmd *pBapHCILogLinkDisconnect,
1548 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1549 /* Including Command Complete and Command Status*/
1550)
1551{
1552 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1553 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1554 tpBtampLogLinkCtx pLogLinkContext;
1555 VOS_STATUS retval = VOS_STATUS_SUCCESS;
1556 v_U8_t log_link_index;
1557
1558 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1559
1560 /*------------------------------------------------------------------------
1561 Sanity check
1562 ------------------------------------------------------------------------*/
1563 if (( NULL == pBapHCILogLinkDisconnect ) ||
1564 ( NULL == btampContext))
1565 {
1566 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1567 "Critical error: Invalid input parameter on %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001568 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 return VOS_STATUS_E_FAULT;
1570 }
1571
1572 /* Derive logical link index from handle */
1573 log_link_index = ((pBapHCILogLinkDisconnect->log_link_handle) >> 8);
1574
1575 if( log_link_index > WLANBAP_MAX_LOG_LINKS )
1576 {
1577 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1578 "Critical error: Invalid input parameter on %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001579 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 /* Fill in the event code to propagate the event notification to BRM
1581 BRM generates the Command status Event based on this.*/
1582 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT;
1583 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.present = 1;
1584 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status =
1585 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1586 return VOS_STATUS_E_INVAL;
1587
1588 }
1589
1590#ifdef BAP_DEBUG
1591 /* Trace the tBtampCtx being passed in. */
1592 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301593 "WLAN BAP Context Monitor: btampContext value = %p in %s:%d", btampContext, __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001594#endif //BAP_DEBUG
1595
1596 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1597 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1598 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1599 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1600 = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_CMD;
1601
1602 /*------------------------------------------------------------------------
1603 FIXME: Validate the Logical Link handle, Generation and freeing...
1604 Here the Logical link is not validated and assumed that it is correct to.
1605 get the Logical link context. .
1606 ------------------------------------------------------------------------*/
1607 pLogLinkContext =
1608 &(btampContext->btampLogLinkCtx[log_link_index]);
1609
1610 // Validate whether the context is active.
1611 if ((VOS_FALSE == pLogLinkContext->present) ||
1612 (pBapHCILogLinkDisconnect->log_link_handle != pLogLinkContext->log_link_handle))
1613 {
1614 /* If status is failed, the platform specific layer generates the
1615 command status event with proper status */
1616 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status =
1617 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1618 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1619 retval = VOS_STATUS_E_FAILURE;
1620#ifdef BAP_DEBUG
1621 /* Log the error. */
1622 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001623 "%s:%d Invalid Logical Link handle(should be) = %d(%d)", __func__, __LINE__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 pBapHCILogLinkDisconnect->log_link_handle, pLogLinkContext->log_link_handle);
1625 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1626 " Logical Link index = %d", log_link_index);
1627#endif //BAP_DEBUG
1628 }
1629 else
1630 {
1631 /* Form and return the command status event... */
1632 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1633 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status
1634 = WLANBAP_STATUS_SUCCESS;
1635
1636
1637 pLogLinkContext->present = VOS_FALSE;
1638 pLogLinkContext->uTxPktCompleted = 0;
1639 pLogLinkContext->log_link_handle = 0;
1640 /* Decrement the total logical link count */
1641 btampContext->total_log_link_index--;
1642 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1643 }
1644
1645 /* Notify the Command status Event */
1646 (*btampContext->pBapHCIEventCB)
1647 (
1648 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1649 &bapHCIEvent, /* This now encodes ALL event types */
1650 VOS_TRUE /* Flag to indicate assoc-specific event */
1651 );
1652
1653 /* Format the Logical Link Complete event to return... */
1654 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT;
1655 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.present = 1;
1656 /* Return the logical link index here */
1657 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.log_link_handle
1658 = pBapHCILogLinkDisconnect->log_link_handle;
1659 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.reason
1660 = WLANBAP_ERROR_TERM_BY_LOCAL_HOST;
1661
1662 return retval;
1663} /* WLAN_BAPLogicalLinkDisconnect */
1664
1665/*----------------------------------------------------------------------------
1666
1667 FUNCTION WLAN_BAPLogicalLinkCancel()
1668
1669 DESCRIPTION
1670 Implements the actual HCI Cancel Logical Link command
1671
1672 DEPENDENCIES
1673 NA.
1674
1675 PARAMETERS
1676
1677 IN
1678 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1679 pBapHCILogLinkCancel: pointer to the "HCI Cancel Logical Link" Structure.
1680
1681 IN/OUT
1682 pBapHCIEvent: Return event value for the command complete event.
1683 (The caller of this routine is responsible for sending
1684 the Command Complete event up the HCI interface.)
1685 (BTW, the required "HCI Logical Link Complete Event"
1686 will be generated by the BAP state machine and sent up
1687 via the (*tpWLAN_BAPEventCB).)
1688
1689 RETURN VALUE
1690 The result code associated with performing the operation
1691
1692 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkCancel is NULL
1693 VOS_STATUS_SUCCESS: Success
1694
1695 SIDE EFFECTS
1696
1697----------------------------------------------------------------------------*/
1698VOS_STATUS
1699WLAN_BAPLogicalLinkCancel
1700(
1701 ptBtampHandle btampHandle,
1702 tBtampTLVHCI_Logical_Link_Cancel_Cmd *pBapHCILogLinkCancel,
1703 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1704 /* Including Command Complete and Command Status*/
1705)
1706{
1707 ptBtampContext btampContext;
1708 BTAMPFSM_INSTANCEDATA_T *instanceVar;
1709 /* Validate params */
1710 if ((btampHandle == NULL) || (pBapHCILogLinkCancel == NULL) ||
1711 (pBapHCIEvent == NULL))
1712 {
1713 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001714 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 return VOS_STATUS_E_FAULT;
1716 }
1717
1718 btampContext = (ptBtampContext) btampHandle;
1719 instanceVar = &(btampContext->bapPhysLinkMachine);
1720
1721 /* Form and immediately return the command status event... */
1722 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_COMPLETE_EVENT;
1723 pBapHCIEvent->u.btampCommandCompleteEvent.present = 1;
1724 pBapHCIEvent->u.btampCommandCompleteEvent.command_opcode =
1725 BTAMP_TLV_HCI_LOGICAL_LINK_CANCEL_CMD;
1726 pBapHCIEvent->u.btampCommandCompleteEvent.num_hci_command_packets = 1;
1727
1728 if (pBapHCILogLinkCancel->phy_link_handle != btampContext->phy_link_handle)
1729 {
1730 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1731 WLANBAP_ERROR_NO_CNCT;
1732 }
1733 else
1734 {
1735 /* As the logical link create is returned immediately, the logical link is
1736 created and so cancel can not return success.
1737 And it returns WLANBAP_ERROR_NO_CNCT if not connected or
1738 WLANBAP_ERROR_MAX_NUM_ACL_CNCTS if connected */
1739 if(WLAN_BAPLogLinkClosed == btampContext->btamp_logical_link_state )
1740 {
1741 /* Cancel Logical link request in invalid state */
1742 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1743 WLANBAP_ERROR_NO_CNCT;
1744 }
1745 else if(WLAN_BAPLogLinkOpen == btampContext->btamp_logical_link_state )
1746 {
1747 /* Cancel Logical link request in conected state */
1748 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1749 WLANBAP_ERROR_MAX_NUM_ACL_CNCTS;
1750 }
1751 else if(WLAN_BAPLogLinkInProgress == btampContext->btamp_logical_link_state )
1752 {
1753 /* Cancel Logical link request in progress state, need to fail logical link
1754 creation as well */
1755 btampContext->btamp_logical_link_cancel_pending = TRUE;
1756 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1757 WLANBAP_STATUS_SUCCESS;
1758 }
1759 else
1760 {
1761 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1762 WLANBAP_ERROR_NO_CNCT;
1763 }
1764 }
1765 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.phy_link_handle =
1766 pBapHCILogLinkCancel->phy_link_handle;
1767 /* Since the status is not success, the Tx flow spec Id is not meaningful and
1768 filling with 0 */
1769 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.tx_flow_spec_id =
1770 pBapHCILogLinkCancel->tx_flow_spec_id;
1771
1772 return VOS_STATUS_SUCCESS;
1773} /* WLAN_BAPLogicalLinkCancel */
1774
1775/*----------------------------------------------------------------------------
1776
1777 FUNCTION WLAN_BAPFlowSpecModify()
1778
1779 DESCRIPTION
1780 Implements the actual HCI Modify Logical Link command
1781 Produces an asynchronous flow spec modify complete event. Through the
1782 event callback.
1783
1784 DEPENDENCIES
1785 NA.
1786
1787 PARAMETERS
1788
1789 IN
1790 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1791 pBapHCIFlowSpecModify: pointer to the "HCI Flow Spec Modify" Structure.
1792
1793 IN/OUT
1794 pBapHCIEvent: Return event value for the command status event.
1795 (The caller of this routine is responsible for sending
1796 the Command Status event up the HCI interface.)
1797
1798 RETURN VALUE
1799 The result code associated with performing the operation
1800
1801 VOS_STATUS_E_FAULT: pointer to pBapHCIFlowSpecModify is NULL
1802 VOS_STATUS_SUCCESS: Success
1803
1804 SIDE EFFECTS
1805
1806----------------------------------------------------------------------------*/
1807VOS_STATUS
1808WLAN_BAPFlowSpecModify
1809(
1810 ptBtampHandle btampHandle,
1811 tBtampTLVHCI_Flow_Spec_Modify_Cmd *pBapHCIFlowSpecModify,
1812 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1813 /* Including Command Complete and Command Status*/
1814)
1815{
1816 v_U16_t index_for_logLinkHandle = 0;
1817 ptBtampContext btampContext;
1818 tpBtampLogLinkCtx pLogLinkContext;
1819 v_U32_t retval;
1820 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1821 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1822 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1823 /* Validate params */
1824 if ((btampHandle == NULL) || (pBapHCIFlowSpecModify == NULL) ||
1825 (pBapHCIEvent == NULL))
1826 {
1827 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001828 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 return VOS_STATUS_E_FAULT;
1830 }
1831
1832 btampContext = (ptBtampContext) btampHandle;
1833
1834 index_for_logLinkHandle = pBapHCIFlowSpecModify->log_link_handle >> 8; /* Return the logical link index here */
1835 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001836 " %s:index_for_logLinkHandle=%d", __func__,index_for_logLinkHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001837
1838 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1839 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1840 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1841 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1842 = BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_CMD;
1843
1844 /*------------------------------------------------------------------------
1845 Evaluate the Tx and Rx Flow specification for this logical link.
1846 ------------------------------------------------------------------------*/
1847 // Currently we only support flow specs with service types of BE (0x01)
1848
1849 /*------------------------------------------------------------------------
1850 Now configure the Logical Link context.
1851 ------------------------------------------------------------------------*/
1852 pLogLinkContext = &(btampContext->btampLogLinkCtx[index_for_logLinkHandle]);
1853
1854 /* Extract Tx flow spec into the context structure */
1855 retval = btampUnpackTlvFlow_Spec((void *)btampContext, pBapHCIFlowSpecModify->tx_flow_spec,
1856 WLAN_BAP_PAL_FLOW_SPEC_TLV_LEN,
1857 &pLogLinkContext->btampFlowSpec);
1858 if (retval != BTAMP_PARSE_SUCCESS)
1859 {
1860 /* Flow spec parsing failed, return failure */
1861 vosStatus = VOS_STATUS_E_FAILURE;
1862 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.status =
1863 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1864 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1865 }
1866 else
1867 {
1868 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1869 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.status
1870 = WLANBAP_STATUS_SUCCESS;
1871
1872 }
1873 /* Notify the Command status Event */
1874 vosStatus =
1875 (*btampContext->pBapHCIEventCB)
1876 (
1877 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1878 &bapHCIEvent, /* This now encodes ALL event types */
1879 VOS_TRUE /* Flag to indicate assoc-specific event */
1880 );
1881
1882 /* Form and immediately return the command status event... */
1883 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_COMPLETE_EVENT;
1884 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.present = 1;
1885 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.log_link_handle =
1886 pBapHCIFlowSpecModify->log_link_handle;
1887
1888 return vosStatus;
1889} /* WLAN_BAPFlowSpecModify */
1890
1891
1892void WLAN_BAPEstablishLogicalLink(ptBtampContext btampContext)
1893{
1894 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1895 v_U16_t log_link_index = 0;
1896 v_U16_t index_for_logLinkCtx = 0;
1897 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1898
1899 if (btampContext == NULL)
1900 {
1901 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001902 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 return;
1904 }
1905
1906 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1907 {
1908 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1909 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1910 btampContext->btamp_logical_link_cancel_pending = FALSE;
1911 }
1912 else
1913 {
1914 /* Allocate a logical link index for these flow specs */
1915 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1916 btampContext, /* per assoc btampContext value */
1917 btampContext->btamp_logical_link_req_info.phyLinkHandle, /* I get phy_link_handle from the Command */
1918 btampContext->btamp_logical_link_req_info.txFlowSpec, /* I get tx_flow_spec from the Command */
1919 btampContext->btamp_logical_link_req_info.rxFlowSpec, /* I get rx_flow_spec from the Command */
1920 &log_link_index /* Return the logical link index here */
1921 );
1922 if (VOS_STATUS_SUCCESS != vosStatus)
1923 {
1924 /* Invalid flow spec format */
1925 bapHCIEvent.u.btampLogicalLinkCompleteEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1926 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1927 }
1928 else
1929 {
1930 bapHCIEvent.u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1931 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1932 }
1933 }
1934
1935 index_for_logLinkCtx = log_link_index >> 8;
1936 /* Format the Logical Link Complete event to return... */
1937 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1938 bapHCIEvent.u.btampLogicalLinkCompleteEvent.present = 1;
1939
1940 /* Return the logical link index here */
1941 bapHCIEvent.u.btampLogicalLinkCompleteEvent.log_link_handle
1942 = log_link_index;
1943 bapHCIEvent.u.btampLogicalLinkCompleteEvent.phy_link_handle
1944 = btampContext->btamp_logical_link_req_info.phyLinkHandle;
1945 bapHCIEvent.u.btampLogicalLinkCompleteEvent.flow_spec_id
1946 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1947
1948 vosStatus = (*btampContext->pBapHCIEventCB)
1949 (
1950 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1951 &bapHCIEvent, /* This now encodes ALL event types */
1952 VOS_TRUE /* Flag to indicate assoc-specific event */
1953 );
1954 return;
1955}
1956
1957
1958