blob: 0218fee94beed8301d1fb432688f955ab6db7a7f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*===========================================================================
7
8 b a p A p i L i n k C n t l . C
9
10 OVERVIEW:
11
12 This software unit holds the implementation of the WLAN BAP modules
13 Link Control functions.
14
15 The functions externalized by this module are to be called ONLY by other
16 WLAN modules (HDD) that properly register with the BAP Layer initially.
17
18 DEPENDENCIES:
19
20 Are listed for each API below.
21
22
23 Copyright (c) 2008 QUALCOMM Incorporated.
24 All Rights Reserved.
25 Qualcomm Confidential and Proprietary
26===========================================================================*/
27
28/*===========================================================================
29
30 EDIT HISTORY FOR FILE
31
32
33 This section contains comments describing changes made to the module.
34 Notice that changes are listed in reverse chronological order.
35
36
37 $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 $
38
39
40 when who what, where, why
41---------- --- --------------------------------------------------------
422008-09-15 jez Created module
43
44===========================================================================*/
45
46/*----------------------------------------------------------------------------
47 * Include Files
48 * -------------------------------------------------------------------------*/
49//#include "wlan_qct_tl.h"
50#include "vos_trace.h"
51// Pick up the CSR callback definition
52#include "csrApi.h"
53
54/* BT-AMP PAL API header file */
55#include "bapApi.h"
56#include "bapInternal.h"
57#include "btampFsm.h"
58
59//#define BAP_DEBUG
60/*----------------------------------------------------------------------------
61 * Preprocessor Definitions and Constants
62 * -------------------------------------------------------------------------*/
63
64
65/*----------------------------------------------------------------------------
66 * Type Declarations
67 * -------------------------------------------------------------------------*/
68
69/*----------------------------------------------------------------------------
70 * Global Data Definitions
71 * -------------------------------------------------------------------------*/
72
73/*----------------------------------------------------------------------------
74 * Static Variable Definitions
75 * -------------------------------------------------------------------------*/
76
77/*----------------------------------------------------------------------------
78 * Static Function Declarations and Definitions
79 * -------------------------------------------------------------------------*/
80
81/*----------------------------------------------------------------------------
82 * Externalized Function Definitions
83* -------------------------------------------------------------------------*/
84
85/*----------------------------------------------------------------------------
86 * Function Declarations and Documentation
87 * -------------------------------------------------------------------------*/
88
89/*----------------------------------------------------------------------------
90
91 FUNCTION WLANBAP_RoamCallback()
92
93 DESCRIPTION
94 Callback for Roam (connection status) Events
95
96 DEPENDENCIES
97 NA.
98
99 PARAMETERS
100
101 IN
102 pContext: is the pContext passed in with the roam request
103 pCsrRoamInfo: is a pointer to a tCsrRoamInfo, see definition of eRoamCmdStatus and
104 eRoamCmdResult: for detail valid members. It may be NULL
105 roamId: is to identify the callback related roam request. 0 means unsolicited
106 roamStatus: is a flag indicating the status of the callback
107 roamResult: is the result
108
109 RETURN VALUE
110 The eHalStatus code associated with performing the operation
111
112 eHAL_STATUS_SUCCESS: Success
113
114 SIDE EFFECTS
115
116----------------------------------------------------------------------------*/
117#if 0
118eCSR_ROAM_RESULT_WDS_STARTED
119#define eWLAN_BAP_MAC_START_BSS_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
120
121eCSR_ROAM_RESULT_FAILURE
122eCSR_ROAM_RESULT_NOT_ASSOCIATED
123#define eWLAN_BAP_MAC_START_FAILS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
124
125eCSR_ROAM_RESULT_WDS_ASSOCIATED
126#define eWLAN_BAP_MAC_CONNECT_COMPLETED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATED */
127
128
129eCSR_ROAM_RESULT_FAILURE
130eCSR_ROAM_RESULT_NOT_ASSOCIATED
131#define eWLAN_BAP_MAC_CONNECT_FAILED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
132
133
134eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND
135#define eWLAN_BAP_MAC_CONNECT_INDICATION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND */
136
137
138eCSR_ROAM_RESULT_KEY_SET
139#define eWLAN_BAP_MAC_KEY_SET_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_KEY_SET */
140
141
142eCSR_ROAM_RESULT_WDS_DISASSOC_IND
143#define eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_DISASSOC_IND */
144
145
146eCSR_ROAM_RESULT_WDS_STOPPED
147#define eWLAN_BAP_MAC_READY_FOR_CONNECTIONS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STOPPED */
148
149#endif //0
150
151
152eHalStatus
153WLANBAP_RoamCallback
154(
155 void *pContext,
156 tCsrRoamInfo *pCsrRoamInfo,
157 tANI_U32 roamId,
158 eRoamCmdStatus roamStatus,
159 eCsrRoamResult roamResult
160)
161{
162 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
163 /* btampContext value */
164 ptBtampContext btampContext = (ptBtampContext) pContext;
165 tWLAN_BAPEvent bapEvent; /* State machine event */
166 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
167 v_U8_t status; /* return the BT-AMP status here */
168 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
169
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700170 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 -0700171
172 switch (roamStatus) {
173 //JEZ081110: For testing purposes, with Infra STA as BT STA, this
174 //actually takes care of the "eCSR_ROAM_RESULT_WDS_STARTED" case,
175 //below, better than "eCSR_ROAM_RESULT_IBSS_STARTED".
176 //case eCSR_ROAM_ROAMING_START:
177 case eCSR_ROAM_ASSOCIATION_START:
178 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700179 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 -0700180 // This only gets called when CSR decides to roam on its own - due to lostlink.
181#if 0
182 if ((pCsrRoamInfo) && (pCsrRoamInfo->pConnectedProfile) && (pCsrRoamInfo->pConnectedProfile->pBssDesc))
183 {
184 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pConnectedProfile->pBssDesc->bssId,
185 sizeof(tSirMacAddr));
186 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700187 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 }
189#endif //0
190 /* Fill in the event structure */
191 bapEvent.event = eWLAN_BAP_MAC_START_BSS_SUCCESS;
192 bapEvent.params = pCsrRoamInfo;
193 bapEvent.u1 = roamStatus;
194 bapEvent.u2 = roamResult;
195
196 /* Handle event */
197 vosStatus = btampFsm(btampContext, &bapEvent, &status);
198
199 break;
200
201 case eCSR_ROAM_SET_KEY_COMPLETE:
202 /* bapRoamCompleteCallback with eCSR_ROAM_SET_KEY_COMPLETE */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700203 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 -0700204
205 /* Fill in the event structure */
206 bapEvent.event = eWLAN_BAP_MAC_KEY_SET_SUCCESS;
207 bapEvent.params = pCsrRoamInfo;
208 bapEvent.u1 = roamStatus;
209 bapEvent.u2 = roamResult;
210
211 /* Handle event */
212 vosStatus = btampFsm(btampContext, &bapEvent, &status);
213
214 break;
215
216 case eCSR_ROAM_DISASSOCIATED:
217 /* bapRoamCompleteCallback with eCSR_ROAM_DISASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700218 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 -0700219 case eCSR_ROAM_LOSTLINK:
220 /* bapRoamCompleteCallback with eCSR_ROAM_LOSTLINK */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700221 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 -0700222
223 if (roamResult != eCSR_ROAM_RESULT_NONE) {
224 /* Fill in the event structure */
225 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
226 bapEvent.params = pCsrRoamInfo;
227 bapEvent.u1 = roamStatus;
228 bapEvent.u2 = roamResult;
229
230 /* Handle event */
231 vosStatus = btampFsm(btampContext, &bapEvent, &status);
232 }
233
234 break;
235
236 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700237 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 -0700238
239 break;
240 }
241
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700242 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 -0700243
244 switch (roamResult) {
245 //JEZ081110: Commented out for testing. Test relies upon IBSS.
246 case eCSR_ROAM_RESULT_IBSS_STARTED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700247 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 -0700248 case eCSR_ROAM_RESULT_WDS_STARTED:
249 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700250 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 -0700251
252 /* Fill in the event structure */
253 bapEvent.event = eWLAN_BAP_MAC_START_BSS_SUCCESS;
254 bapEvent.params = pCsrRoamInfo;
255 bapEvent.u1 = roamStatus;
256 bapEvent.u2 = roamResult;
257
258 /* Handle event */
259 vosStatus = btampFsm(btampContext, &bapEvent, &status);
260
261 break;
262
263 //JEZ081110: Commented out for testing. Test relies upon IBSS.
264 //JEZ081110: But I cannot rely upon IBSS for the initial testing.
265 case eCSR_ROAM_RESULT_FAILURE:
266 //case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
267 //case eCSR_ROAM_RESULT_IBSS_START_FAILED:
268 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700269 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 -0700270#ifdef FEATURE_WLAN_BTAMP_UT_RF
271 break;
272#endif
273 case eCSR_ROAM_RESULT_WDS_START_FAILED:
274 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_START_FAILED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700275 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 -0700276
277 /* Fill in the event structure */
278 /* I don't think I should signal a eCSR_ROAM_RESULT_FAILURE
279 * as a eWLAN_BAP_MAC_START_FAILS
280 */
281 bapEvent.event = eWLAN_BAP_MAC_START_FAILS;
282 bapEvent.params = pCsrRoamInfo;
283 bapEvent.u1 = roamStatus;
284 bapEvent.u2 = roamResult;
285
286 /* Handle event */
287 vosStatus = btampFsm(btampContext, &bapEvent, &status);
288
289 break;
290
291 //JEZ081110: Commented out for testing. This handles both Infra STA and IBSS STA.
292 case eCSR_ROAM_RESULT_IBSS_CONNECT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700293 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 -0700294 case eCSR_ROAM_RESULT_ASSOCIATED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700295 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 -0700296 case eCSR_ROAM_RESULT_WDS_ASSOCIATED:
297 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700298 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 -0700299
300 /* Fill in the event structure */
301 bapEvent.event = eWLAN_BAP_MAC_CONNECT_COMPLETED;
302 bapEvent.params = pCsrRoamInfo;
303 bapEvent.u1 = roamStatus;
304 bapEvent.u2 = roamResult;
305
306 /* Handle event */
307 vosStatus = btampFsm(btampContext, &bapEvent, &status);
308
309 break;
310
311 //JEZ081110: Commented out for testing. Test relies upon IBSS.
312 //JEZ081110: But I cannot rely upon IBSS for the initial testing.
313 //case eCSR_ROAM_RESULT_FAILURE:
314 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700315 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 -0700316 case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
317 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700318 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 -0700319#ifdef FEATURE_WLAN_BTAMP_UT_RF
320 break;
321#endif
322 case eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED:
323 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700324 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 -0700325
326 /* Fill in the event structure */
327 bapEvent.event = eWLAN_BAP_MAC_CONNECT_FAILED;
328 bapEvent.params = pCsrRoamInfo;
329 bapEvent.u1 = roamStatus;
330 bapEvent.u2 = roamResult;
331
332 /* Handle event */
333 vosStatus = btampFsm(btampContext, &bapEvent, &status);
334
335 break;
336
337 //JEZ081110: I think I have to check for the bssType to
338 //differentiate between IBSS Start and IBSS Join success.
339 //case eCSR_ROAM_RESULT_IBSS_CONNECT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700340 //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 -0700341
342 //JEZ081110: Commented out for testing. Test relies upon IBSS.
343 // No longer commented out.
344 case eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND:
345 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700346 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 -0700347
348 /* Fill in the event structure */
349 bapEvent.event = eWLAN_BAP_MAC_CONNECT_INDICATION;
350 bapEvent.params = pCsrRoamInfo;
351 bapEvent.u1 = roamStatus;
352 bapEvent.u2 = roamResult;
353
354 /* Handle event */
355 vosStatus = btampFsm(btampContext, &bapEvent, &status);
356
357 /* If BAP doesn't like the incoming association, signal SME/CSR */
358 if ( status != WLANBAP_STATUS_SUCCESS)
359 halStatus = eHAL_STATUS_FAILURE;
360
361 break;
362
363 //JEZ081110: Not supported in SME and CSR, yet.
364#if 0
365 case eCSR_ROAM_RESULT_KEY_SET:
366 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_KEY_SET */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700367 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 -0700368
369 /* Fill in the event structure */
370 bapEvent.event = eWLAN_BAP_MAC_KEY_SET_SUCCESS;
371 bapEvent.params = pCsrRoamInfo;
372 bapEvent.u1 = roamStatus;
373 bapEvent.u2 = roamResult;
374
375 /* Handle event */
376 vosStatus = btampFsm(btampContext, &bapEvent, &status);
377
378 break;
379#endif //0
380
381 case eCSR_ROAM_RESULT_DISASSOC_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_DISASSOC_IND", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 case eCSR_ROAM_RESULT_WDS_DISASSOCIATED:
384 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_DISASSOCIATED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700385 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 -0700386
387 /* Fill in the event structure */
388 bapEvent.event = eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION;
389 bapEvent.params = pCsrRoamInfo;
390 bapEvent.u1 = roamStatus;
391 bapEvent.u2 = roamResult;
392
393 /* Handle event */
394 vosStatus = btampFsm(btampContext, &bapEvent, &status);
395
396 /* Fill in the event structure */
397 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
398 bapEvent.params = pCsrRoamInfo;
399 bapEvent.u1 = roamStatus;
400 bapEvent.u2 = roamResult;
401
402 /* Handle event */
403 vosStatus = btampFsm(btampContext, &bapEvent, &status);
404
405 break;
406
407 //JEZ081110: Commented out for testing. Test relies upon IBSS.
408 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700409 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 -0700410 case eCSR_ROAM_RESULT_WDS_STOPPED:
411 /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STOPPED */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700412 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 -0700413
414 /* Fill in the event structure */
415 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
416 bapEvent.params = pCsrRoamInfo;
417 bapEvent.u1 = roamStatus;
418 bapEvent.u2 = roamResult;
419
420 /* Handle event */
421 vosStatus = btampFsm(btampContext, &bapEvent, &status);
422
423 break;
424
425 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700426 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 -0700427
428 break;
429 }
430
431#if 0
432 switch (roamResult) {
433 case eCSR_ROAM_RESULT_IBSS_CONNECT:
434 // we have an IBSS connection...
435
436 // update our state
437 btampContext->mAssociatedStatus = WLANBAP_STATUS_SUCCESS;
438 btampContext->mAssociated = VOS_TRUE;
439 // update "assocBssid" with the BSSID of the IBSS
440 if (pCsrRoamInfo)
441 memcpy(btampContext->assocBssid, pCsrRoamInfo->peerMacOrBssidForIBSS, 6);
442
443 // We must update the system role to match that of the
444 // lower layers in case the upper layers decided to try
445 // joining the network in infrastructure mode if the
446 // initial join in IBSS mode fails. Andreas Wolf
447 // (awolf@apple.com) explains the behavior as follows:
448 // "If the client attempts to join an open network and it fails
449 // on the first attempt, it reverts back to b-only mode. This
450 // workaround was specifically put in place to allow the client
451 // to associate to some third party b-only infrastructure APs.
452 // It did not take IBSS into account, it seems that the fallback
453 // always forces infrastructure."
454
455 btampContext->systemRole = eSYSTEM_STA_IN_IBSS_ROLE;
456
457 if (mLinkStatus == 0)
458 {
459 // enable the flow of data
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700460 DBGLOG("%s: marking link as up in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 mLinkStatus = 1;
462 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkUp);
463 outputQueue->setCapacity(TRANSMIT_QUEUE_SIZE);
464 outputQueue->start();
465 // Let them know we are ready
466 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_ASSOC_DONE);
467 }
468 else
469 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700470 DBGLOG("%s: link is already up in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_CONNECT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 }
472 break;
473
474 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
475 // we have no more IBSS peers, so disable the flow of data
476 if (mLinkStatus != 0)
477 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700478 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_INACTIVE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 mLinkStatus = (tANI_U8) 0;
480 // JEZ070627: Revisit ?
481 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
482 outputQueue->stop();
483 outputQueue->setCapacity(0);
484
485 // update our state
486 btampContext->mAssociated = false;
487 }
488 else
489 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700490 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_IBSS_INACTIVE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 }
492
493 break;
494
495 case eCSR_ROAM_RESULT_ASSOCIATED:
496 btampContext->mAssociatedStatus = APPLE80211_STATUS_SUCCESS;
497 btampContext->mAssociated = true;
498
499 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc)) {
500 ccpCsrToAppleScanResult(mPMacObject, pCsrRoamInfo->pBssDesc, &scanResult);
501
502 /* Save away the IEs used by the AP */
503 ccpCsrToAssocApiedata( mPMacObject, pCsrRoamInfo->pBssDesc, &(btampContext->apiedata));
504
505 if (BssidChanged((tCsrBssid*) btampContext->assocBssid, (ether_addr*) scanResult.asr_bssid)) {
506 memcpy(btampContext->assocBssid, scanResult.asr_bssid, 6);
507 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_BSSID_CHANGED );
508 }
509 }
510
511 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_ASSOC_DONE);
512
513 if (mLinkStatus == 0)
514 {
515 mLinkStatus = (tANI_U8) 1;
516 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkUp);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700517 DBGLOG("%s: marking link as up in %s\n", __func__, "eCSR_ROAM_RESULT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 outputQueue->setCapacity(TRANSMIT_QUEUE_SIZE);
519 outputQueue->start();
520 }
521 else
522 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700523 DBGLOG("%s: link is already up in %s\n", __func__, "eCSR_ROAM_RESULT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 }
525 break;
526 case eCSR_ROAM_RESULT_NOT_ASSOCIATED:
527 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNAVAILABLE;
528 btampContext->mAssociated = false;
529
530 if (mLinkStatus != 0)
531 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700532 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_NOT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 mLinkStatus = (tANI_U8) 0;
534 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
535 }
536 else
537 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700538 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_NOT_ASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 }
540 break;
541
542 case eCSR_ROAM_RESULT_FAILURE:
543 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNSPECIFIED_FAILURE;
544 btampContext->mAssociated = false;
545
546 if (mLinkStatus != 0)
547 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700548 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_FAILURE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 mLinkStatus = (tANI_U8) 0;
550 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
551 }
552 else
553 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700554 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_FAILURE");
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 }
556 break;
557
558 case eCSR_ROAM_RESULT_DISASSOC_IND:
559 {
560 btampContext->mAssociated = false;
561
562 if (mLinkStatus != 0)
563 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700564 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_DISASSOC_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 mLinkStatus = (tANI_U8) 0;
566 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
567 }
568 else
569 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700570 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_DISASSOC_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 }
572
573 //if (pCsrRoamInfo) // For now, leave this commented out. Until CSR changes integrated.
574 {
575 // Now set the reason and status codes.
576 // Actually, the "result code" field in the tSirSmeDisassocInd should be named reasonCode and NOT statusCode.
577 // "Reason Codes" are found in DisAssoc or DeAuth Ind. "Status Code" fields are found in Rsp Mgmt Frame.
578 // For now, we are going to have to (painfully) map the only "result code" type information we have
579 // available at ALL from LIM/CSR. And that is the statusCode field of type tSirResultCodes
580 // BTW, tSirResultCodes is the COMPLETELY WRONG TYPE for this "result code" field. It SHOULD be
581 // of type tSirMacReasonCodes.
582 // Right now, we don't even have that. So, I have to just make up some "reason code" that I will
583 // pretend I found in the incoming DisAssoc Indication.
584 //btampContext->statusCode = ((tpSirSmeDisassocInd) pCallbackInfo)->statusCode; // tSirResultCodes
585 //btampContext->reasonCode = ((tpSirSmeDisassocInd) pCallbackInfo)->statusCode; // tSirResultCodes
586 btampContext->reasonCode = (tANI_U16) eSIR_MAC_UNSPEC_FAILURE_REASON; //tANI_U16 // tSirMacReasonCodes
587 btampContext->deAuthReasonCode = 0; // tANI_U16 // eSIR_SME_DEAUTH_FROM_PEER
588 // Shouldn't the next line really use a tANI_U16? //0; // tANI_U16 // eSIR_SME_DISASSOC_FROM_PEER
589 btampContext->disassocReasonCode = btampContext->reasonCode; // tSirMacReasonCodes
590 // Let's remember the peer who just disassoc'd us
591 //memcpy(btampContext->peerMacAddr, pCsrRoamInfo->peerMacOrBssidForIBSS, 6);
592 }
593 }
594 break;
595
596 case eCSR_ROAM_RESULT_DEAUTH_IND:
597 {
598 btampContext->mAssociated = false;
599
600 if (mLinkStatus != 0)
601 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700602 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_RESULT_DEAUTH_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 mLinkStatus = (tANI_U8) 0;
604 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
605 }
606 else
607 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700608 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_RESULT_DEAUTH_IND");
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 }
610
611 //if (pCsrRoamInfo) // For now, leave this commented out. Until CSR changes integrated.
612 {
613 // Now set the reason and status codes.
614 // Actually, the "result code" field in the tSirSmeDeauthInd should be named reasonCode and NOT statusCode.
615 // "Reason Codes" are found in DisAssoc or DeAuth Ind. "Status Code" fields are found in Rsp Mgmt Frame.
616 // For now, we are going to have to (painfully) map the only "result code" type information we have
617 // available at ALL from LIM/CSR. And that is the statusCode field of type tSirResultCodes
618 // BTW, tSirResultCodes is the COMPLETELY WRONG TYPE for this "result code" field. It SHOULD be
619 // of type tSirMacReasonCodes.
620 // Right now, we don't even have that. So, I have to just make up some "reason code" that I will
621 // pretend I found in the incoming DeAuth Indication.
622 //btampContext->statusCode = ((tpSirSmeDeauthInd) pCallbackInfo)->statusCode; // tSirResultCodes
623 //btampContext->reasonCode = ((tpSirSmeDeauthInd) pCallbackInfo)->statusCode; // tSirResultCodes
624 btampContext->reasonCode = (tANI_U16) eSIR_MAC_UNSPEC_FAILURE_REASON; //tANI_U16 // tSirMacReasonCodes
625 btampContext->disassocReasonCode = 0; // tANI_U16 // eSIR_SME_DISASSOC_FROM_PEER
626 // Shouldn't the next line really use a tANI_U16? //0; // tANI_U16 // eSIR_SME_DEAUTH_FROM_PEER
627 btampContext->deAuthReasonCode = btampContext->reasonCode; // tSirMacReasonCodes
628 // Let's remember the peer who just de-auth'd us
629 //memcpy(btampContext->peerMacAddr, ((tpSirSmeDeauthInd) pCallbackInfo)->peerMacAddr, 6);
630 }
631 }
632 break;
633
634 case eCSR_ROAM_RESULT_MIC_ERROR_UNICAST:
635
636 //if (eCSR_ROAM_MIC_ERROR_IND == roamStatus) // Make sure
637 {
638 if (btampContext->mTKIPCounterMeasures)
639 {
640 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_MIC_ERROR_UCAST);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700641 DBGLOG("%s: TKIP Countermeasures in effect in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_UNICAST");
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 }
643 else
644 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700645 DBGLOG("%s: TKIP Countermeasures disabled in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_UNICAST");
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 }
647 }
648 break;
649
650 case eCSR_ROAM_RESULT_MIC_ERROR_GROUP:
651
652 //if (eCSR_ROAM_MIC_ERROR_IND == roamStatus) // Make sure
653 {
654 if (btampContext->mTKIPCounterMeasures)
655 {
656 ((IO80211Interface*) mNetworkIF)->postMessage(APPLE80211_M_MIC_ERROR_MCAST);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700657 DBGLOG("%s: TKIP Countermeasures in effect in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_GROUP");
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 }
659 else
660 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700661 DBGLOG("%s: TKIP Countermeasures disabled in %s\n", __func__, "eCSR_ROAM_RESULT_MIC_ERROR_GROUP");
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 }
663 }
664 break;
665
666 default:
667 break;
668 }
669 switch (roamStatus) {
670 case eCSR_ROAM_ROAMING_START:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700671 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ROAMING_START");
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 // This only gets called when CSR decides to roam on its own - due to lostlink.
673 // Apple still needs to be told.
674 if ((pCsrRoamInfo) && (pCsrRoamInfo->pConnectedProfile) && (pCsrRoamInfo->pConnectedProfile->pBssDesc))
675 {
676 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pConnectedProfile->pBssDesc->bssId,
677 sizeof(tSirMacAddr));
678 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700679 DBGLOG("%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 }
681 break;
682
683 case eCSR_ROAM_SHOULD_ROAM:
684 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc)) {
685 // pCallbackInfo points to the BSS desc. Convert to Apple Scan Result.
686 halStatus = ccpCsrToAppleScanResult(
687 mPMacObject,
688 pCsrRoamInfo->pBssDesc,
689 &scanResult);
690 if ( halStatus != 0 )
691 return eHAL_STATUS_FAILURE;
692 roamAccepted = apple80211Interface->shouldRoam(&scanResult); // Return result is crucial
693 if (roamAccepted == true) {
694 // If the roam is acceptable, return SUCCESS
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700695 DBGLOG("%s: shouldRoam returns \"acceptable\"\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696//#if 0
697 // Actually, before returning, immediately signal willRoam
698 // This is a workaround for a CSR bug. Eventually, when
699 // eCSR_ROAM_ASSOCIATION_START gets called WITH callback param p1
700 // pointing to a tBssDescription, this work-around can be removed.
701 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pBssDesc->bssId, sizeof(tSirMacAddr));
702 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700703 DBGLOG("%s: willRoam (called out of order) returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 DBGLOG(" with BSSID = " MAC_ADDR_STRING(bssid.ether_addr_octet));
705//#endif
706 return eHAL_STATUS_SUCCESS;
707 } else {
708 // If the roam is NOT acceptable, return FAILURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700709 DBGLOG("%s: shouldRoam returns \"NOT acceptable\"\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return eHAL_STATUS_FAILURE;
711 }
712 }
713 break;
714
715 case eCSR_ROAM_DISASSOCIATED:
716 //if (eCSR_ROAM_RESULT_FORCED == roamResult || eCSR_ROAM_RESULT_MIC_ERROR == roamResult)
717 {
718 btampContext->mAssociated = false;
719
720 if (mLinkStatus != 0)
721 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700722 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_DISASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 mLinkStatus = (tANI_U8) 0;
724 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
725 }
726 else
727 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700728 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_DISASSOCIATED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 }
730 }
731 break;
732
733 case eCSR_ROAM_LOSTLINK:
734 btampContext->mAssociatedStatus = APPLE80211_STATUS_UNSPECIFIED_FAILURE;
735 btampContext->mAssociated = false;
736
737 if (mLinkStatus != 0)
738 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700739 DBGLOG("%s: marking link as down in %s\n", __func__, "eCSR_ROAM_LOSTLINK");
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 mLinkStatus = (tANI_U8) 0;
741 ((IO80211Interface*) mNetworkIF)->setLinkState(kIO80211NetworkLinkDown);
742 }
743 else
744 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 DBGLOG("%s: link already down in %s\n", __func__, "eCSR_ROAM_LOSTLINK");
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 }
747 break;
748
749 case eCSR_ROAM_ASSOCIATION_START:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700750 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ASSOCIATION_START");
Jeff Johnson295189b2012-06-20 16:38:30 -0700751#if 0
752 // This is the right place to call willRoam - for an "initial" association.
753 // But, unfortunately, when eCSR_ROAM_ASSOCIATION_START gets called,
754 // it doesn't have a pointer to the tBssDescription in the roaming callback
755 // routines parameter p1 (pCallbackInfo in SetWextState). So, don't use this code, yet.
756 if ((pCsrRoamInfo) && (pCsrRoamInfo->pBssDesc) {
757 memcpy(bssid.ether_addr_octet, pCsrRoamInfo->pBssDesc->bssId, 6);
758 apple80211Interface->willRoam(&bssid); // Return result isn't significant
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700759 DBGLOG("%s: willRoam returns\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 DBGLOG(" with BSSID = " MAC_ADDR_STRING(bssid.ether_addr_octet));
761 }
762#endif //0
763 break;
764
765 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700766 DBGLOG("%s: In %s\n", __func__, "eCSR_ROAM_ASSOCIATION_COMPLETION");
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 break;
768
769 case eCSR_ROAM_MIC_ERROR_IND: // Handled in eCSR_ROAM_RESULT_MIC_ERROR_UNICAST and GROUP, above
770 case eCSR_ROAM_CANCELLED:
771 case eCSR_ROAM_ROAMING_COMPLETION:
772 case eCSR_ROAM_SCAN_FOUND_NEW_BSS:
773 default:
774 break;
775 }
776#endif //0
777
778 return halStatus;
779}
780
781/*----------------------------------------------------------------------------
782 Host Controller Interface Procedural API
783 ---------------------------------------------------------------------------*/
784
785/** BT v3.0 Link Control commands */
786
787/*----------------------------------------------------------------------------
788 Each of the next eight command result in asynchronous events (e.g.,
789 HCI_PHYSICAL_LINK_COMPLETE_EVENT, HCI_LOGICAL_LINK_COMPLETE_EVENT, etc...)
790 These are signalled thru the event callback. (I.E., (*tpWLAN_BAPEventCB).)
791 ---------------------------------------------------------------------------*/
792
793/*----------------------------------------------------------------------------
794
795 FUNCTION WLAN_BAPPhysicalLinkCreate()
796
797 DESCRIPTION
798 Implements the actual HCI Create Physical Link command
799
800 DEPENDENCIES
801 NA.
802
803 PARAMETERS
804
805 IN
806 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
807 WLANBAP_GetNewHndl has to be called before every call to
808 WLAN_BAPPhysicalLinkCreate. Since the context is per
809 physical link.
810 pBapHCIPhysLinkCreate: pointer to the "HCI Create Physical Link" Structure.
811 pHddHdl: The context passed in by the caller. (e.g., BSL specific context)
812
813 IN/OUT
814 pBapHCIEvent: Return event value for the command status event.
815 (The caller of this routine is responsible for sending
816 the Command Status event up the HCI interface.)
817
818 RETURN VALUE
819 The result code associated with performing the operation
820
821 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkCreate is NULL
822 VOS_STATUS_SUCCESS: Success
823
824 SIDE EFFECTS
825
826----------------------------------------------------------------------------*/
827VOS_STATUS
828WLAN_BAPPhysicalLinkCreate
829(
830 ptBtampHandle btampHandle,
831 tBtampTLVHCI_Create_Physical_Link_Cmd *pBapHCIPhysLinkCreate,
832 v_PVOID_t pHddHdl, /* BSL passes in its specific context */
833 /* And I get phy_link_handle from the Command */
834 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
835 /* Including Command Complete and Command Status*/
836)
837{
838 tWLAN_BAPEvent bapEvent; /* State machine event */
839 VOS_STATUS vosStatus;
840 /* I am using btampContext, instead of pBapPhysLinkMachine */
841 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
842 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
843 v_U8_t status; /* return the BT-AMP status here */
844 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
845
846 /* Validate params */
847 if ((pBapHCIPhysLinkCreate == NULL) || (NULL == btampContext))
848 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530849 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 -0700850 __func__, btampHandle, pBapHCIPhysLinkCreate);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 return VOS_STATUS_E_FAULT;
852 }
853
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530854 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855
856 if(DISCONNECTED != instanceVar->stateVar)
857 {
858 /* Create/Accept Phy link request in invalid state */
859 status = WLANBAP_ERROR_MAX_NUM_CNCTS;
860
861 }
862 else
863 {
864 /* Fill in the event structure */
865 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_CREATE;
866 bapEvent.params = pBapHCIPhysLinkCreate;
867 //bapEvent.callback = pBapHCIPhysLinkCreateCB;
868
869 /* Allocate a new state machine instance */
870 /* There will only ever be one of these (NB: Don't assume this.) */
871 /* So for now this returns a pointer to a static structure */
872 /* (With all state set to initial values) */
873 vosStatus = WLANBAP_CreateNewPhyLinkCtx (
874 btampHandle,
875 pBapHCIPhysLinkCreate->phy_link_handle, /* I get phy_link_handle from the Command */
876 pHddHdl, /* BSL passes in its specific context */
877 &btampContext, /* Handle to return per assoc btampContext value in */
878 BT_INITIATOR); /* BT_INITIATOR */
879
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530880 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881
882 /* Handle event */
883 vosStatus = btampFsm(btampContext, &bapEvent, &status);
884 }
885
886 /* Format the command status event to return... */
887 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
888 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
889 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
890 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
891 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
892 = BTAMP_TLV_HCI_CREATE_PHYSICAL_LINK_CMD;
893
894 /* ... */
895
896 return VOS_STATUS_SUCCESS;
897} /* WLAN_BAPPhysicalLinkCreate */
898
899/*----------------------------------------------------------------------------
900
901 FUNCTION WLAN_BAPPhysicalLinkAccept()
902
903 DESCRIPTION
904 Implements the actual HCI Accept Physical Link command
905
906 DEPENDENCIES
907 NA.
908
909 PARAMETERS
910
911 IN
912 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
913 pBapHCIPhysLinkAccept: pointer to the "HCI Accept Physical Link" Structure.
914 pHddHdl: The context passed in by the caller. (e.g., BSL specific context)
915
916 IN/OUT
917 pBapHCIEvent: Return event value for the command status event.
918 (The caller of this routine is responsible for sending
919 the Command Status event up the HCI interface.)
920
921 RETURN VALUE
922 The result code associated with performing the operation
923
924 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkAccept is NULL
925 VOS_STATUS_SUCCESS: Success
926
927 SIDE EFFECTS
928
929----------------------------------------------------------------------------*/
930VOS_STATUS
931WLAN_BAPPhysicalLinkAccept
932(
933 ptBtampHandle btampHandle,
934 tBtampTLVHCI_Accept_Physical_Link_Cmd *pBapHCIPhysLinkAccept,
935 v_PVOID_t pHddHdl, /* BSL passes in its specific context */
936 /* And I get phy_link_handle from the Command */
937 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
938 /* Including Command Complete and Command Status*/
939)
940{
941 tWLAN_BAPEvent bapEvent; /* State machine event */
942 VOS_STATUS vosStatus;
943 /* I am using btampContext, instead of pBapPhysLinkMachine */
944 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
945 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
946 v_U8_t status; /* return the BT-AMP status here */
947 BTAMPFSM_INSTANCEDATA_T *instanceVar;
948
949 /* Validate params */
950 if ((pBapHCIPhysLinkAccept == NULL) || (NULL == btampContext))
951 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530952 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 -0700953 __func__, btampHandle, pBapHCIPhysLinkAccept);
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 return VOS_STATUS_E_FAULT;
955 }
956
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530957 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
959 instanceVar = &(btampContext->bapPhysLinkMachine);
960 if(DISCONNECTED != instanceVar->stateVar)
961 {
962 /* Create/Accept Phy link request in invalid state */
963 status = WLANBAP_ERROR_MAX_NUM_CNCTS;
964
965 }
966 else
967 {
968 /* Fill in the event structure */
969 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_ACCEPT;
970 bapEvent.params = pBapHCIPhysLinkAccept;
971 //bapEvent.callback = pBapHCIPhysLinkAcceptCB;
972
973 /* Allocate a new state machine instance */
974 /* There will only ever be one of these (NB: Don't assume this.) */
975 /* So for now this returns a pointer to a static structure */
976 /* (With all state set to initial values) */
977 vosStatus = WLANBAP_CreateNewPhyLinkCtx (
978 btampHandle,
979 pBapHCIPhysLinkAccept->phy_link_handle, /* I get phy_link_handle from the Command */
980 pHddHdl, /* BSL passes in its specific context */
981 &btampContext, /* Handle to return per assoc btampContext value in */
982 BT_RESPONDER); /* BT_RESPONDER */
983
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530984 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 /* Handle event */
987 vosStatus = btampFsm(btampContext, &bapEvent, &status);
988
989 }
990 /* Format the command status event to return... */
991 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
992 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
993 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
994 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
995 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
996 = BTAMP_TLV_HCI_ACCEPT_PHYSICAL_LINK_CMD;
997
998 /* ... */
999
1000 return VOS_STATUS_SUCCESS;
1001} /* WLAN_BAPPhysicalLinkAccept */
1002
1003/*----------------------------------------------------------------------------
1004
1005 FUNCTION WLAN_BAPPhysicalLinkDisconnect()
1006
1007 DESCRIPTION
1008 Implements the actual HCI Disconnect Physical Link command
1009
1010 DEPENDENCIES
1011 NA.
1012
1013 PARAMETERS
1014
1015 IN
1016 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1017 pBapHCIPhysLinkDisconnect: pointer to the "HCI Disconnect Physical Link" Structure.
1018
1019 IN/OUT
1020 pBapHCIEvent: Return event value for the command status event.
1021 (The caller of this routine is responsible for sending
1022 the Command Status event up the HCI interface.)
1023
1024 RETURN VALUE
1025 The result code associated with performing the operation
1026
1027 VOS_STATUS_E_FAULT: pointer to pBapHCIPhysLinkDisconnect is NULL
1028 VOS_STATUS_SUCCESS: Success
1029
1030 SIDE EFFECTS
1031
1032----------------------------------------------------------------------------*/
1033VOS_STATUS
1034WLAN_BAPPhysicalLinkDisconnect
1035(
1036 ptBtampHandle btampHandle,
1037 tBtampTLVHCI_Disconnect_Physical_Link_Cmd *pBapHCIPhysLinkDisconnect,
1038 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1039 /* Including Command Complete and Command Status*/
1040)
1041{
1042 tWLAN_BAPEvent bapEvent; /* State machine event */
1043 VOS_STATUS vosStatus;
1044 /* I am using btampContext, instead of pBapPhysLinkMachine */
1045 //tWLAN_BAPbapPhysLinkMachine *pBapPhysLinkMachine;
1046 ptBtampContext btampContext = (ptBtampContext) btampHandle; /* btampContext value */
1047 v_U8_t status; /* return the BT-AMP status here */
1048
1049 /* Validate params */
1050 if (pBapHCIPhysLinkDisconnect == NULL) {
1051 return VOS_STATUS_E_FAULT;
1052 }
1053
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301054 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001055
1056 /* Validate the Physical link handle */
1057 if (pBapHCIPhysLinkDisconnect->phy_link_handle != btampContext->phy_link_handle)
1058 {
1059 /* Format the command status event to return... */
1060 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1061 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
1062 pBapHCIEvent->u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1063 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
1064 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
1065 = BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_CMD;
1066 return VOS_STATUS_SUCCESS;
1067 }
1068
1069 /* Fill in the event structure */
1070 bapEvent.event = eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT;
1071 bapEvent.params = pBapHCIPhysLinkDisconnect;
1072
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301073 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001074
1075 /* Handle event */
1076 vosStatus = btampFsm(btampContext, &bapEvent, &status);
1077
1078 /* Fill in the event structure */
1079 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
1080 bapEvent.params = pBapHCIPhysLinkDisconnect;
1081
1082 /* Handle event */
1083 vosStatus = btampFsm(btampContext, &bapEvent, &status);
1084
1085
1086 /* Format the command status event to return... */
1087 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1088 pBapHCIEvent->u.btampCommandStatusEvent.present = 1;
1089 pBapHCIEvent->u.btampCommandStatusEvent.status = status;
1090 pBapHCIEvent->u.btampCommandStatusEvent.num_hci_command_packets = 1;
1091 pBapHCIEvent->u.btampCommandStatusEvent.command_opcode
1092 = BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_CMD;
1093
1094 /* ... */
1095
1096 return VOS_STATUS_SUCCESS;
1097} /* WLAN_BAPPhysicalLinkDisconnect */
1098
1099/*----------------------------------------------------------------------------
1100
1101 FUNCTION WLAN_BAPLogicalLinkCreate()
1102
1103 DESCRIPTION
1104 Implements the actual HCI Create Logical Link command
1105
1106 DEPENDENCIES
1107 NA.
1108
1109 PARAMETERS
1110
1111 IN
1112 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1113 pBapHCILogLinkCreate: pointer to the "HCI Create Logical Link" Structure.
1114
1115 IN/OUT
1116 pBapHCIEvent: Return event value for the command status event.
1117 (The caller of this routine is responsible for sending
1118 the Command Status event up the HCI interface.)
1119
1120 RETURN VALUE
1121 The result code associated with performing the operation
1122
1123 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkCreate is NULL
1124 VOS_STATUS_SUCCESS: Success
1125
1126 SIDE EFFECTS
1127
1128----------------------------------------------------------------------------*/
1129VOS_STATUS
1130WLAN_BAPLogicalLinkCreate
1131(
1132 ptBtampHandle btampHandle,
1133 tBtampTLVHCI_Create_Logical_Link_Cmd *pBapHCILogLinkCreate,
1134 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1135 /* Including Command Complete and Command Status*/
1136)
1137{
1138 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1139 VOS_STATUS vosStatus;
1140 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1141 v_U16_t log_link_index = 0;
1142 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
1143 VOS_STATUS retval;
1144 v_U16_t index_for_logLinkCtx = 0;
1145 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1146
1147
1148 /* Validate params */
1149 if (btampHandle == NULL) {
1150 return VOS_STATUS_E_FAULT;
1151 }
1152
1153 /* Validate params */
1154 if (pBapHCILogLinkCreate == NULL) {
1155 return VOS_STATUS_E_FAULT;
1156 }
1157
1158
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301159 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
1161 /* Validate the BAP state to accept the logical link request
1162 Logical Link create/accept requests are allowed only in
1163 CONNECTED state */
1164 /* Form and immediately return the command status event... */
1165 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1166 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1167 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1168 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1169 = BTAMP_TLV_HCI_CREATE_LOGICAL_LINK_CMD;
1170
1171 retval = VOS_STATUS_E_FAILURE;
1172 if(DISCONNECTED == instanceVar->stateVar)
1173 {
1174 /* Create Logical link request in invalid state */
1175 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1176 WLANBAP_ERROR_CMND_DISALLOWED;
1177 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1178
1179 }
1180 else if (CONNECTED != instanceVar->stateVar)
1181 {
1182 /* Create Logical link request in invalid state */
1183 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1184 WLANBAP_ERROR_CMND_DISALLOWED;
1185 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_CMND_DISALLOWED;
1186 }
1187 else if (pBapHCILogLinkCreate->phy_link_handle != btampContext->phy_link_handle)
1188 {
1189 /* Invalid Physical link handle */
1190 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1191 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1192 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1193 }
1194 else
1195 {
1196 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkInProgress;
1197
1198 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1199 {
1200 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1201 WLANBAP_ERROR_NO_CNCT;
1202 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1203 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1204 btampContext->btamp_logical_link_cancel_pending = FALSE;
1205 }
1206 else
1207 {
1208 /* If btamp_async_logical_link_create is set, we will seralize the req
1209 on MC thread & handle it there after; If the above flag is not set
1210 respond to HCI the sync way as before */
1211 if(FALSE == btampContext->btamp_async_logical_link_create)
1212 {
1213 /* Allocate a logical link index for these flow specs */
1214 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1215 btampContext, /* per assoc btampContext value */
1216 pBapHCILogLinkCreate->phy_link_handle, /* I get phy_link_handle from the Command */
1217 pBapHCILogLinkCreate->tx_flow_spec, /* I get tx_flow_spec from the Command */
1218 pBapHCILogLinkCreate->rx_flow_spec, /* I get rx_flow_spec from the Command */
1219 &log_link_index /* Return the logical link index here */
1220 );
1221 if (VOS_STATUS_SUCCESS != vosStatus)
1222 {
1223 /* Invalid flow spec format */
1224 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1225 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1226 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1227 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1228 }
1229 else
1230 {
1231 retval = VOS_STATUS_SUCCESS;
1232 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1233
1234 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1235 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1236 }
1237 }
1238 else
1239 {
1240 btampContext->btamp_logical_link_req_info.phyLinkHandle =
1241 pBapHCILogLinkCreate->phy_link_handle;
1242 vos_mem_copy(btampContext->btamp_logical_link_req_info.txFlowSpec,
1243 pBapHCILogLinkCreate->tx_flow_spec, 18);
1244 vos_mem_copy(btampContext->btamp_logical_link_req_info.rxFlowSpec,
1245 pBapHCILogLinkCreate->rx_flow_spec, 18);
1246 btampContext->btamp_async_logical_link_create = FALSE;
1247 vosStatus = btampEstablishLogLink(btampContext);
1248 if(VOS_STATUS_SUCCESS == vosStatus)
1249 {
1250 retval = VOS_STATUS_E_BUSY;//this will make sure event complete is not sent to HCI
1251 }
1252 else
1253 {
1254 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1255 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1256 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1257 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1258 }
1259
1260 }
1261 }
1262 }
1263
1264 vosStatus = (*btampContext->pBapHCIEventCB)
1265 (
1266 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1267 &bapHCIEvent, /* This now encodes ALL event types */
1268 VOS_TRUE /* Flag to indicate assoc-specific event */
1269 );
1270
1271 index_for_logLinkCtx = log_link_index >> 8;
1272 /* Format the Logical Link Complete event to return... */
1273 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1274 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.present = 1;
1275
1276 /* Return the logical link index here */
1277 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.log_link_handle
1278 = log_link_index;
1279 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.phy_link_handle
1280 = pBapHCILogLinkCreate->phy_link_handle;
1281 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.flow_spec_id
1282 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1283
1284 /* ... */
1285
1286 return retval;
1287} /* WLAN_BAPLogicalLinkCreate */
1288
1289/*----------------------------------------------------------------------------
1290
1291 FUNCTION WLAN_BAPLogicalLinkAccept()
1292
1293 DESCRIPTION
1294 Implements the actual HCI Accept Logical Link command
1295
1296 DEPENDENCIES
1297 NA.
1298
1299 PARAMETERS
1300
1301 IN
1302 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1303 pBapHCILogLinkAccept: pointer to the "HCI Accept Logical Link" Structure.
1304
1305 IN/OUT
1306 pBapHCIEvent: Return event value for the command status event.
1307 (The caller of this routine is responsible for sending
1308 the Command Status event up the HCI interface.)
1309
1310 RETURN VALUE
1311 The result code associated with performing the operation
1312
1313 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkAccept is NULL
1314 VOS_STATUS_SUCCESS: Success
1315
1316 SIDE EFFECTS
1317
1318----------------------------------------------------------------------------*/
1319VOS_STATUS
1320WLAN_BAPLogicalLinkAccept
1321(
1322 ptBtampHandle btampHandle,
1323 tBtampTLVHCI_Accept_Logical_Link_Cmd *pBapHCILogLinkAccept,
1324 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1325 /* Including Command Complete and Command Status*/
1326)
1327{
1328 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1329 VOS_STATUS vosStatus;
1330 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1331 v_U16_t log_link_index = 0;
1332 BTAMPFSM_INSTANCEDATA_T *instanceVar = &(btampContext->bapPhysLinkMachine);
1333 VOS_STATUS retval;
1334 v_U16_t index_for_logLinkCtx;
1335 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1336
1337
1338 /* Validate params */
1339 if (btampHandle == NULL) {
1340 return VOS_STATUS_E_FAULT;
1341 }
1342
1343 /* Validate params */
1344 if (pBapHCILogLinkAccept == NULL) {
1345 return VOS_STATUS_E_FAULT;
1346 }
1347
1348
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301349 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampHandle value: %p", __func__, btampHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001350
1351 /* Validate the BAP state to accept the logical link request
1352 Logical Link create/accept requests are allowed only in
1353 CONNECTED state */
1354 /* Form and immediately return the command status event... */
1355 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1356 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1357 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1358 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1359 = BTAMP_TLV_HCI_ACCEPT_LOGICAL_LINK_CMD;
1360
1361 retval = VOS_STATUS_E_FAILURE;
1362 if(DISCONNECTED == instanceVar->stateVar)
1363 {
1364 /* Create Logical link request in invalid state */
1365 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1366 WLANBAP_ERROR_CMND_DISALLOWED;
1367 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1368
1369 }
1370 else if (CONNECTED != instanceVar->stateVar)
1371 {
1372 /* Create Logical link request in invalid state */
1373 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1374 WLANBAP_ERROR_CMND_DISALLOWED;
1375 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_CMND_DISALLOWED;
1376 }
1377 else if (pBapHCILogLinkAccept->phy_link_handle != btampContext->phy_link_handle)
1378 {
1379 /* Invalid Physical link handle */
1380 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1381 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1382 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1383 }
1384 else
1385 {
1386 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkInProgress;
1387 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1388 {
1389 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1390 WLANBAP_ERROR_NO_CNCT;
1391 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1392 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1393 btampContext->btamp_logical_link_cancel_pending = FALSE;
1394 }
1395 else
1396 {
1397 /* If btamp_async_logical_link_create is set, we will seralize the req
1398 on MC thread & handle it there after; If the above flag is not set
1399 respond to HCI the sync way as before */
1400 if(FALSE == btampContext->btamp_async_logical_link_create)
1401 {
1402 /* Allocate a logical link index for these flow specs */
1403 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1404 btampContext, /* per assoc btampContext value */
1405 pBapHCILogLinkAccept->phy_link_handle, /* I get phy_link_handle from the Command */
1406 pBapHCILogLinkAccept->tx_flow_spec, /* I get tx_flow_spec from the Command */
1407 pBapHCILogLinkAccept->rx_flow_spec, /* I get rx_flow_spec from the Command */
1408 &log_link_index /* Return the logical link index here */
1409 );
1410 if (VOS_STATUS_SUCCESS != vosStatus)
1411 {
1412 /* Invalid flow spec format */
1413 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1414 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1415 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1416 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1417 }
1418 else
1419 {
1420 retval = VOS_STATUS_SUCCESS;
1421 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1422
1423 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1424 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1425 }
1426 }
1427 else
1428 {
1429 btampContext->btamp_logical_link_req_info.phyLinkHandle =
1430 pBapHCILogLinkAccept->phy_link_handle;
1431 vos_mem_copy(btampContext->btamp_logical_link_req_info.txFlowSpec,
1432 pBapHCILogLinkAccept->tx_flow_spec, 18);
1433 vos_mem_copy(btampContext->btamp_logical_link_req_info.rxFlowSpec,
1434 pBapHCILogLinkAccept->rx_flow_spec, 18);
1435 btampContext->btamp_async_logical_link_create = FALSE;
1436 vosStatus = btampEstablishLogLink(btampContext);
1437 if(VOS_STATUS_SUCCESS == vosStatus)
1438 {
1439 retval = VOS_STATUS_E_BUSY;//this will make sure event complete is not sent to HCI
1440 }
1441 else
1442 {
1443 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.status =
1444 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1445 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1446 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1447 }
1448
1449 }
1450 }
1451 }
1452 vosStatus = (*btampContext->pBapHCIEventCB)
1453 (
1454 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1455 &bapHCIEvent, /* This now encodes ALL event types */
1456 VOS_TRUE /* Flag to indicate assoc-specific event */
1457 );
1458
1459 index_for_logLinkCtx = log_link_index >> 8;
1460
1461 /* Format the Logical Link Complete event to return... */
1462 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1463 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.present = 1;
1464 /* Return the logical link index here */
1465 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.log_link_handle
1466 = log_link_index;
1467 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.phy_link_handle
1468 = pBapHCILogLinkAccept->phy_link_handle;
1469 pBapHCIEvent->u.btampLogicalLinkCompleteEvent.flow_spec_id
1470 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1471
1472 /* ... */
1473
1474 return retval;
1475} /* WLAN_BAPLogicalLinkAccept */
1476
1477/*----------------------------------------------------------------------------
1478
1479 FUNCTION WLAN_BAPLogicalLinkDisconnect()
1480
1481 DESCRIPTION
1482 Implements the actual HCI Disconnect Logical Link command
1483
1484 DEPENDENCIES
1485 NA.
1486
1487 PARAMETERS
1488
1489 IN
1490 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1491 pBapHCILogLinkDisconnect: pointer to the "HCI Disconnect Logical Link" Structure.
1492
1493 IN/OUT
1494 pBapHCIEvent: Return event value for the command status event.
1495 (The caller of this routine is responsible for sending
1496 the Command Status event up the HCI interface.)
1497
1498 RETURN VALUE
1499 The result code associated with performing the operation
1500
1501 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkDisconnect is NULL
1502 VOS_STATUS_SUCCESS: Success
1503
1504 SIDE EFFECTS
1505
1506----------------------------------------------------------------------------*/
1507VOS_STATUS
1508WLAN_BAPLogicalLinkDisconnect
1509(
1510 ptBtampHandle btampHandle,
1511 tBtampTLVHCI_Disconnect_Logical_Link_Cmd *pBapHCILogLinkDisconnect,
1512 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1513 /* Including Command Complete and Command Status*/
1514)
1515{
1516 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1517 ptBtampContext btampContext = (ptBtampContext) btampHandle;
1518 tpBtampLogLinkCtx pLogLinkContext;
1519 VOS_STATUS retval = VOS_STATUS_SUCCESS;
1520 v_U8_t log_link_index;
1521
1522 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1523
1524 /*------------------------------------------------------------------------
1525 Sanity check
1526 ------------------------------------------------------------------------*/
1527 if (( NULL == pBapHCILogLinkDisconnect ) ||
1528 ( NULL == btampContext))
1529 {
1530 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1531 "Critical error: Invalid input parameter on %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001532 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 return VOS_STATUS_E_FAULT;
1534 }
1535
1536 /* Derive logical link index from handle */
1537 log_link_index = ((pBapHCILogLinkDisconnect->log_link_handle) >> 8);
1538
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001539 if( log_link_index >= WLANBAP_MAX_LOG_LINKS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 {
1541 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1542 "Critical error: Invalid input parameter on %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001543 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 /* Fill in the event code to propagate the event notification to BRM
1545 BRM generates the Command status Event based on this.*/
1546 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT;
1547 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.present = 1;
1548 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status =
1549 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1550 return VOS_STATUS_E_INVAL;
1551
1552 }
1553
1554#ifdef BAP_DEBUG
1555 /* Trace the tBtampCtx being passed in. */
1556 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301557 "WLAN BAP Context Monitor: btampContext value = %p in %s:%d", btampContext, __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001558#endif //BAP_DEBUG
1559
1560 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1561 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1562 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1563 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1564 = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_CMD;
1565
1566 /*------------------------------------------------------------------------
1567 FIXME: Validate the Logical Link handle, Generation and freeing...
1568 Here the Logical link is not validated and assumed that it is correct to.
1569 get the Logical link context. .
1570 ------------------------------------------------------------------------*/
1571 pLogLinkContext =
1572 &(btampContext->btampLogLinkCtx[log_link_index]);
1573
1574 // Validate whether the context is active.
1575 if ((VOS_FALSE == pLogLinkContext->present) ||
1576 (pBapHCILogLinkDisconnect->log_link_handle != pLogLinkContext->log_link_handle))
1577 {
1578 /* If status is failed, the platform specific layer generates the
1579 command status event with proper status */
1580 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status =
1581 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1582 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1583 retval = VOS_STATUS_E_FAILURE;
1584#ifdef BAP_DEBUG
1585 /* Log the error. */
1586 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001587 "%s:%d Invalid Logical Link handle(should be) = %d(%d)", __func__, __LINE__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 pBapHCILogLinkDisconnect->log_link_handle, pLogLinkContext->log_link_handle);
1589 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1590 " Logical Link index = %d", log_link_index);
1591#endif //BAP_DEBUG
1592 }
1593 else
1594 {
1595 /* Form and return the command status event... */
1596 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1597 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.status
1598 = WLANBAP_STATUS_SUCCESS;
1599
1600
1601 pLogLinkContext->present = VOS_FALSE;
1602 pLogLinkContext->uTxPktCompleted = 0;
1603 pLogLinkContext->log_link_handle = 0;
1604 /* Decrement the total logical link count */
1605 btampContext->total_log_link_index--;
1606 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1607 }
1608
1609 /* Notify the Command status Event */
1610 (*btampContext->pBapHCIEventCB)
1611 (
1612 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1613 &bapHCIEvent, /* This now encodes ALL event types */
1614 VOS_TRUE /* Flag to indicate assoc-specific event */
1615 );
1616
1617 /* Format the Logical Link Complete event to return... */
1618 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT;
1619 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.present = 1;
1620 /* Return the logical link index here */
1621 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.log_link_handle
1622 = pBapHCILogLinkDisconnect->log_link_handle;
1623 pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent.reason
1624 = WLANBAP_ERROR_TERM_BY_LOCAL_HOST;
1625
1626 return retval;
1627} /* WLAN_BAPLogicalLinkDisconnect */
1628
1629/*----------------------------------------------------------------------------
1630
1631 FUNCTION WLAN_BAPLogicalLinkCancel()
1632
1633 DESCRIPTION
1634 Implements the actual HCI Cancel Logical Link command
1635
1636 DEPENDENCIES
1637 NA.
1638
1639 PARAMETERS
1640
1641 IN
1642 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1643 pBapHCILogLinkCancel: pointer to the "HCI Cancel Logical Link" Structure.
1644
1645 IN/OUT
1646 pBapHCIEvent: Return event value for the command complete event.
1647 (The caller of this routine is responsible for sending
1648 the Command Complete event up the HCI interface.)
1649 (BTW, the required "HCI Logical Link Complete Event"
1650 will be generated by the BAP state machine and sent up
1651 via the (*tpWLAN_BAPEventCB).)
1652
1653 RETURN VALUE
1654 The result code associated with performing the operation
1655
1656 VOS_STATUS_E_FAULT: pointer to pBapHCILogLinkCancel is NULL
1657 VOS_STATUS_SUCCESS: Success
1658
1659 SIDE EFFECTS
1660
1661----------------------------------------------------------------------------*/
1662VOS_STATUS
1663WLAN_BAPLogicalLinkCancel
1664(
1665 ptBtampHandle btampHandle,
1666 tBtampTLVHCI_Logical_Link_Cancel_Cmd *pBapHCILogLinkCancel,
1667 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1668 /* Including Command Complete and Command Status*/
1669)
1670{
1671 ptBtampContext btampContext;
1672 BTAMPFSM_INSTANCEDATA_T *instanceVar;
1673 /* Validate params */
1674 if ((btampHandle == NULL) || (pBapHCILogLinkCancel == NULL) ||
1675 (pBapHCIEvent == NULL))
1676 {
1677 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001678 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 return VOS_STATUS_E_FAULT;
1680 }
1681
1682 btampContext = (ptBtampContext) btampHandle;
1683 instanceVar = &(btampContext->bapPhysLinkMachine);
1684
1685 /* Form and immediately return the command status event... */
1686 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_COMPLETE_EVENT;
1687 pBapHCIEvent->u.btampCommandCompleteEvent.present = 1;
1688 pBapHCIEvent->u.btampCommandCompleteEvent.command_opcode =
1689 BTAMP_TLV_HCI_LOGICAL_LINK_CANCEL_CMD;
1690 pBapHCIEvent->u.btampCommandCompleteEvent.num_hci_command_packets = 1;
1691
1692 if (pBapHCILogLinkCancel->phy_link_handle != btampContext->phy_link_handle)
1693 {
1694 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1695 WLANBAP_ERROR_NO_CNCT;
1696 }
1697 else
1698 {
1699 /* As the logical link create is returned immediately, the logical link is
1700 created and so cancel can not return success.
1701 And it returns WLANBAP_ERROR_NO_CNCT if not connected or
1702 WLANBAP_ERROR_MAX_NUM_ACL_CNCTS if connected */
1703 if(WLAN_BAPLogLinkClosed == btampContext->btamp_logical_link_state )
1704 {
1705 /* Cancel Logical link request in invalid state */
1706 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1707 WLANBAP_ERROR_NO_CNCT;
1708 }
1709 else if(WLAN_BAPLogLinkOpen == btampContext->btamp_logical_link_state )
1710 {
1711 /* Cancel Logical link request in conected state */
1712 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1713 WLANBAP_ERROR_MAX_NUM_ACL_CNCTS;
1714 }
1715 else if(WLAN_BAPLogLinkInProgress == btampContext->btamp_logical_link_state )
1716 {
1717 /* Cancel Logical link request in progress state, need to fail logical link
1718 creation as well */
1719 btampContext->btamp_logical_link_cancel_pending = TRUE;
1720 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1721 WLANBAP_STATUS_SUCCESS;
1722 }
1723 else
1724 {
1725 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.status =
1726 WLANBAP_ERROR_NO_CNCT;
1727 }
1728 }
1729 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.phy_link_handle =
1730 pBapHCILogLinkCancel->phy_link_handle;
1731 /* Since the status is not success, the Tx flow spec Id is not meaningful and
1732 filling with 0 */
1733 pBapHCIEvent->u.btampCommandCompleteEvent.cc_event.Logical_Link_Cancel.tx_flow_spec_id =
1734 pBapHCILogLinkCancel->tx_flow_spec_id;
1735
1736 return VOS_STATUS_SUCCESS;
1737} /* WLAN_BAPLogicalLinkCancel */
1738
1739/*----------------------------------------------------------------------------
1740
1741 FUNCTION WLAN_BAPFlowSpecModify()
1742
1743 DESCRIPTION
1744 Implements the actual HCI Modify Logical Link command
1745 Produces an asynchronous flow spec modify complete event. Through the
1746 event callback.
1747
1748 DEPENDENCIES
1749 NA.
1750
1751 PARAMETERS
1752
1753 IN
1754 btampHandle: pointer to the BAP handle. Returned from WLANBAP_GetNewHndl.
1755 pBapHCIFlowSpecModify: pointer to the "HCI Flow Spec Modify" Structure.
1756
1757 IN/OUT
1758 pBapHCIEvent: Return event value for the command status event.
1759 (The caller of this routine is responsible for sending
1760 the Command Status event up the HCI interface.)
1761
1762 RETURN VALUE
1763 The result code associated with performing the operation
1764
1765 VOS_STATUS_E_FAULT: pointer to pBapHCIFlowSpecModify is NULL
1766 VOS_STATUS_SUCCESS: Success
1767
1768 SIDE EFFECTS
1769
1770----------------------------------------------------------------------------*/
1771VOS_STATUS
1772WLAN_BAPFlowSpecModify
1773(
1774 ptBtampHandle btampHandle,
1775 tBtampTLVHCI_Flow_Spec_Modify_Cmd *pBapHCIFlowSpecModify,
1776 tpBtampHCI_Event pBapHCIEvent /* This now encodes ALL event types */
1777 /* Including Command Complete and Command Status*/
1778)
1779{
1780 v_U16_t index_for_logLinkHandle = 0;
1781 ptBtampContext btampContext;
1782 tpBtampLogLinkCtx pLogLinkContext;
1783 v_U32_t retval;
1784 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1785 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1786 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1787 /* Validate params */
1788 if ((btampHandle == NULL) || (pBapHCIFlowSpecModify == NULL) ||
1789 (pBapHCIEvent == NULL))
1790 {
1791 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001792 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 return VOS_STATUS_E_FAULT;
1794 }
1795
1796 btampContext = (ptBtampContext) btampHandle;
1797
1798 index_for_logLinkHandle = pBapHCIFlowSpecModify->log_link_handle >> 8; /* Return the logical link index here */
1799 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001800 " %s:index_for_logLinkHandle=%d", __func__,index_for_logLinkHandle);
Jeff Johnson295189b2012-06-20 16:38:30 -07001801
1802 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
1803 bapHCIEvent.u.btampCommandStatusEvent.present = 1;
1804 bapHCIEvent.u.btampCommandStatusEvent.num_hci_command_packets = 1;
1805 bapHCIEvent.u.btampCommandStatusEvent.command_opcode
1806 = BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_CMD;
1807
1808 /*------------------------------------------------------------------------
1809 Evaluate the Tx and Rx Flow specification for this logical link.
1810 ------------------------------------------------------------------------*/
1811 // Currently we only support flow specs with service types of BE (0x01)
1812
1813 /*------------------------------------------------------------------------
1814 Now configure the Logical Link context.
1815 ------------------------------------------------------------------------*/
1816 pLogLinkContext = &(btampContext->btampLogLinkCtx[index_for_logLinkHandle]);
1817
1818 /* Extract Tx flow spec into the context structure */
1819 retval = btampUnpackTlvFlow_Spec((void *)btampContext, pBapHCIFlowSpecModify->tx_flow_spec,
1820 WLAN_BAP_PAL_FLOW_SPEC_TLV_LEN,
1821 &pLogLinkContext->btampFlowSpec);
1822 if (retval != BTAMP_PARSE_SUCCESS)
1823 {
1824 /* Flow spec parsing failed, return failure */
1825 vosStatus = VOS_STATUS_E_FAILURE;
1826 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.status =
1827 WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1828 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1829 }
1830 else
1831 {
1832 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_STATUS_SUCCESS;
1833 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.status
1834 = WLANBAP_STATUS_SUCCESS;
1835
1836 }
1837 /* Notify the Command status Event */
1838 vosStatus =
1839 (*btampContext->pBapHCIEventCB)
1840 (
1841 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1842 &bapHCIEvent, /* This now encodes ALL event types */
1843 VOS_TRUE /* Flag to indicate assoc-specific event */
1844 );
1845
1846 /* Form and immediately return the command status event... */
1847 pBapHCIEvent->bapHCIEventCode = BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_COMPLETE_EVENT;
1848 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.present = 1;
1849 pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent.log_link_handle =
1850 pBapHCIFlowSpecModify->log_link_handle;
1851
1852 return vosStatus;
1853} /* WLAN_BAPFlowSpecModify */
1854
1855
1856void WLAN_BAPEstablishLogicalLink(ptBtampContext btampContext)
1857{
1858 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1859 v_U16_t log_link_index = 0;
1860 v_U16_t index_for_logLinkCtx = 0;
1861 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1862
1863 if (btampContext == NULL)
1864 {
1865 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001866 "%s: Null Parameters Not allowed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 return;
1868 }
1869
1870 if( TRUE == btampContext->btamp_logical_link_cancel_pending )
1871 {
1872 bapHCIEvent.u.btampCommandStatusEvent.status = WLANBAP_ERROR_NO_CNCT;
1873 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1874 btampContext->btamp_logical_link_cancel_pending = FALSE;
1875 }
1876 else
1877 {
1878 /* Allocate a logical link index for these flow specs */
1879 vosStatus = WLANBAP_CreateNewLogLinkCtx(
1880 btampContext, /* per assoc btampContext value */
1881 btampContext->btamp_logical_link_req_info.phyLinkHandle, /* I get phy_link_handle from the Command */
1882 btampContext->btamp_logical_link_req_info.txFlowSpec, /* I get tx_flow_spec from the Command */
1883 btampContext->btamp_logical_link_req_info.rxFlowSpec, /* I get rx_flow_spec from the Command */
1884 &log_link_index /* Return the logical link index here */
1885 );
1886 if (VOS_STATUS_SUCCESS != vosStatus)
1887 {
1888 /* Invalid flow spec format */
1889 bapHCIEvent.u.btampLogicalLinkCompleteEvent.status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
1890 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkClosed;
1891 }
1892 else
1893 {
1894 bapHCIEvent.u.btampLogicalLinkCompleteEvent.status = WLANBAP_STATUS_SUCCESS;
1895 btampContext->btamp_logical_link_state = WLAN_BAPLogLinkOpen;
1896 }
1897 }
1898
1899 index_for_logLinkCtx = log_link_index >> 8;
1900 /* Format the Logical Link Complete event to return... */
1901 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT;
1902 bapHCIEvent.u.btampLogicalLinkCompleteEvent.present = 1;
1903
1904 /* Return the logical link index here */
1905 bapHCIEvent.u.btampLogicalLinkCompleteEvent.log_link_handle
1906 = log_link_index;
1907 bapHCIEvent.u.btampLogicalLinkCompleteEvent.phy_link_handle
1908 = btampContext->btamp_logical_link_req_info.phyLinkHandle;
1909 bapHCIEvent.u.btampLogicalLinkCompleteEvent.flow_spec_id
1910 = btampContext->btampLogLinkCtx[index_for_logLinkCtx].btampFlowSpec.flow_spec_id;
1911
1912 vosStatus = (*btampContext->pBapHCIEventCB)
1913 (
1914 btampContext->pHddHdl, /* this refers to the BSL per connection context */
1915 &bapHCIEvent, /* This now encodes ALL event types */
1916 VOS_TRUE /* Flag to indicate assoc-specific event */
1917 );
1918 return;
1919}
1920
1921
1922