Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: chromeos/drivers/ath6kl/wlan/src/wlan_node.c

Issue 3579004: ath6kl: Bringing in the upstream version (Closed) Base URL: http://git.chromium.org/git/kernel.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 //------------------------------------------------------------------------------ 1 //------------------------------------------------------------------------------
2 // <copyright file="wlan_node.c" company="Atheros"> 2 // <copyright file="wlan_node.c" company="Atheros">
3 // Copyright (c) 2004-2008 Atheros Corporation. All rights reserved. 3 // Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
4 // 4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 // 5 //
9 // Software distributed under the License is distributed on an "AS 6 // Permission to use, copy, modify, and/or distribute this software for any
10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 7 // purpose with or without fee is hereby granted, provided that the above
11 // implied. See the License for the specific language governing 8 // copyright notice and this permission notice appear in all copies.
12 // rights and limitations under the License. 9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13 // 17 //
14 // 18 //
15 //------------------------------------------------------------------------------ 19 //------------------------------------------------------------------------------
16 //============================================================================== 20 //==============================================================================
17 // IEEE 802.11 node handling support. 21 // IEEE 802.11 node handling support.
18 // 22 //
19 // Author(s): ="Atheros" 23 // Author(s): ="Atheros"
20 //============================================================================== 24 //==============================================================================
21 #include <a_config.h> 25 #include <a_config.h>
22 #include <athdefs.h> 26 #include <athdefs.h>
23 #include <a_types.h> 27 #include <a_types.h>
24 #include <a_osapi.h> 28 #include <a_osapi.h>
25 #define ATH_MODULE_NAME wlan 29 #define ATH_MODULE_NAME wlan
26 #include <a_debug.h> 30 #include <a_debug.h>
27 #include "htc.h" 31 #include "htc.h"
28 #include "htc_api.h" 32 #include "htc_api.h"
29 #include <wmi.h> 33 #include <wmi.h>
30 #include <ieee80211.h> 34 #include <ieee80211.h>
31 #include <wlan_api.h> 35 #include <wlan_api.h>
32 #include <wmi_api.h> 36 #include <wmi_api.h>
33 #include <ieee80211_node.h> 37 #include <ieee80211_node.h>
34 38
35 #define ATH_DEBUG_WLAN ATH_DEBUG_MAKE_MODULE_MASK(0) 39 #define ATH_DEBUG_WLAN ATH_DEBUG_MAKE_MODULE_MASK(0)
36 40
37 #ifdef DEBUG 41 #ifdef ATH_DEBUG_MODULE
38 42
39 static ATH_DEBUG_MASK_DESCRIPTION wlan_debug_desc[] = { 43 static ATH_DEBUG_MASK_DESCRIPTION wlan_debug_desc[] = {
40 { ATH_DEBUG_WLAN , "General WLAN Node Tracing"}, 44 { ATH_DEBUG_WLAN , "General WLAN Node Tracing"},
41 }; 45 };
42 46
43 ATH_DEBUG_INSTANTIATE_MODULE_VAR(wlan, 47 ATH_DEBUG_INSTANTIATE_MODULE_VAR(wlan,
44 "wlan", 48 "wlan",
45 "WLAN Node Management", 49 "WLAN Node Management",
46 ATH_DEBUG_MASK_DEFAULTS, 50 ATH_DEBUG_MASK_DEFAULTS,
47 ATH_DEBUG_DESCRIPTION_COUNT(wlan_debug_desc), 51 ATH_DEBUG_DESCRIPTION_COUNT(wlan_debug_desc),
48 wlan_debug_desc); 52 wlan_debug_desc);
49 53
50 #endif 54 #endif
51 55
56 #ifdef THREAD_X
52 static void wlan_node_timeout(A_ATH_TIMER arg); 57 static void wlan_node_timeout(A_ATH_TIMER arg);
58 #endif
53 59
54 static bss_t * _ieee80211_find_node (struct ieee80211_node_table *nt, 60 static bss_t * _ieee80211_find_node (struct ieee80211_node_table *nt,
55 const A_UINT8 *macaddr); 61 const A_UINT8 *macaddr);
56 62
57 bss_t * 63 bss_t *
58 wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size) 64 wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size)
59 { 65 {
60 bss_t *ni; 66 bss_t *ni;
61 67
62 ni = A_MALLOC_NOWAIT(sizeof(bss_t)); 68 ni = A_MALLOC_NOWAIT(sizeof(bss_t));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int hash; 116 int hash;
111 A_UINT32 timeoutValue = 0; 117 A_UINT32 timeoutValue = 0;
112 118
113 A_MEMCPY(ni->ni_macaddr, macaddr, IEEE80211_ADDR_LEN); 119 A_MEMCPY(ni->ni_macaddr, macaddr, IEEE80211_ADDR_LEN);
114 hash = IEEE80211_NODE_HASH (macaddr); 120 hash = IEEE80211_NODE_HASH (macaddr);
115 ieee80211_node_initref (ni); /* mark referenced */ 121 ieee80211_node_initref (ni); /* mark referenced */
116 122
117 timeoutValue = nt->nt_nodeAge; 123 timeoutValue = nt->nt_nodeAge;
118 124
119 ni->ni_tstamp = A_GET_MS (timeoutValue); 125 ni->ni_tstamp = A_GET_MS (timeoutValue);
126 ni->ni_actcnt = WLAN_NODE_INACT_CNT;
120 127
121 IEEE80211_NODE_LOCK_BH(nt); 128 IEEE80211_NODE_LOCK_BH(nt);
122 129
123 /* Insert at the end of the node list */ 130 /* Insert at the end of the node list */
124 ni->ni_list_next = NULL; 131 ni->ni_list_next = NULL;
125 ni->ni_list_prev = nt->nt_node_last; 132 ni->ni_list_prev = nt->nt_node_last;
126 if(nt->nt_node_last != NULL) 133 if(nt->nt_node_last != NULL)
127 { 134 {
128 nt->nt_node_last->ni_list_next = ni; 135 nt->nt_node_last->ni_list_next = ni;
129 } 136 }
130 nt->nt_node_last = ni; 137 nt->nt_node_last = ni;
131 if(nt->nt_node_first == NULL) 138 if(nt->nt_node_first == NULL)
132 { 139 {
133 nt->nt_node_first = ni; 140 nt->nt_node_first = ni;
134 } 141 }
135 142
136 /* Insert into the hash list i.e. the bucket */ 143 /* Insert into the hash list i.e. the bucket */
137 if((ni->ni_hash_next = nt->nt_hash[hash]) != NULL) 144 if((ni->ni_hash_next = nt->nt_hash[hash]) != NULL)
138 { 145 {
139 nt->nt_hash[hash]->ni_hash_prev = ni; 146 nt->nt_hash[hash]->ni_hash_prev = ni;
140 } 147 }
141 ni->ni_hash_prev = NULL; 148 ni->ni_hash_prev = NULL;
142 nt->nt_hash[hash] = ni; 149 nt->nt_hash[hash] = ni;
143 150
151 #ifdef THREAD_X
144 if (!nt->isTimerArmed) { 152 if (!nt->isTimerArmed) {
145 A_TIMEOUT_MS(&nt->nt_inact_timer, timeoutValue, 0); 153 A_TIMEOUT_MS(&nt->nt_inact_timer, timeoutValue, 0);
146 nt->isTimerArmed = TRUE; 154 nt->isTimerArmed = TRUE;
147 } 155 }
156 #endif
148 157
149 IEEE80211_NODE_UNLOCK_BH(nt); 158 IEEE80211_NODE_UNLOCK_BH(nt);
150 } 159 }
151 160
152 static bss_t * 161 static bss_t *
153 _ieee80211_find_node(struct ieee80211_node_table *nt, 162 _ieee80211_find_node(struct ieee80211_node_table *nt,
154 const A_UINT8 *macaddr) 163 const A_UINT8 *macaddr)
155 { 164 {
156 bss_t *ni; 165 bss_t *ni;
157 int hash; 166 int hash;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 279 }
271 280
272 /* 281 /*
273 * Node table support. 282 * Node table support.
274 */ 283 */
275 void 284 void
276 wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt) 285 wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt)
277 { 286 {
278 int i; 287 int i;
279 288
280 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN, ("node table = 0x%x\n", (A_UINT32)nt)); 289 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN, ("node table = 0x%lx\n", (unsigned long)nt)) ;
281 IEEE80211_NODE_LOCK_INIT(nt); 290 IEEE80211_NODE_LOCK_INIT(nt);
282 291
283 A_REGISTER_MODULE_DEBUG_INFO(wlan); 292 A_REGISTER_MODULE_DEBUG_INFO(wlan);
284 293
285 nt->nt_node_first = nt->nt_node_last = NULL; 294 nt->nt_node_first = nt->nt_node_last = NULL;
286 for(i = 0; i < IEEE80211_NODE_HASHSIZE; i++) 295 for(i = 0; i < IEEE80211_NODE_HASHSIZE; i++)
287 { 296 {
288 nt->nt_hash[i] = NULL; 297 nt->nt_hash[i] = NULL;
289 } 298 }
290 299
300 #ifdef THREAD_X
291 A_INIT_TIMER(&nt->nt_inact_timer, wlan_node_timeout, nt); 301 A_INIT_TIMER(&nt->nt_inact_timer, wlan_node_timeout, nt);
292 nt->isTimerArmed = FALSE; 302 nt->isTimerArmed = FALSE;
303 #endif
293 nt->nt_wmip = wmip; 304 nt->nt_wmip = wmip;
294 nt->nt_nodeAge = WLAN_NODE_INACT_TIMEOUT_MSEC; 305 nt->nt_nodeAge = WLAN_NODE_INACT_TIMEOUT_MSEC;
295 306
296 // 307 //
297 // nt_scangen never initialized before and during suspend/resume of winmobil e, 308 // nt_scangen never initialized before and during suspend/resume of winmobil e,
298 // that some junk has been stored in this, due to this scan list didn't prop erly updated 309 // that some junk has been stored in this, due to this scan list didn't prop erly updated
299 // 310 //
300 nt->nt_scangen = 0; 311 nt->nt_scangen = 0;
301 312
302 #ifdef OS_ROAM_MANAGEMENT 313 #ifdef OS_ROAM_MANAGEMENT
303 nt->nt_si_gen = 0; 314 nt->nt_si_gen = 0;
304 #endif 315 #endif
305 } 316 }
306 317
307 void 318 void
308 wlan_set_nodeage(struct ieee80211_node_table *nt, A_UINT32 nodeAge) 319 wlan_set_nodeage(struct ieee80211_node_table *nt, A_UINT32 nodeAge)
309 { 320 {
310 nt->nt_nodeAge = nodeAge; 321 nt->nt_nodeAge = nodeAge;
311 return; 322 return;
312 } 323 }
324 void
325 wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt)
326 {
327 #ifdef THREAD_X
328 bss_t *bss, *nextBss;
329 A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE;
330
331 wmi_get_current_bssid(nt->nt_wmip, myBssid);
332
333 bss = nt->nt_node_first;
334 while (bss != NULL)
335 {
336 nextBss = bss->ni_list_next;
337 if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0)
338 {
339 /*
340 * free up all but the current bss - if set
341 */
342 wlan_node_reclaim(nt, bss);
343
344 }
345 bss = nextBss;
346 }
347 #else
348 bss_t *bss, *nextBss;
349 A_UINT8 myBssid[IEEE80211_ADDR_LEN];
350 A_UINT32 timeoutValue = 0;
351 A_UINT32 now = A_GET_MS(0);
352 timeoutValue = nt->nt_nodeAge;
353
354 wmi_get_current_bssid(nt->nt_wmip, myBssid);
355
356 bss = nt->nt_node_first;
357 while (bss != NULL)
358 {
359 nextBss = bss->ni_list_next;
360 if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0)
361 {
362
363 if (bss->ni_tstamp <= now || --bss->ni_actcnt == 0)
364 {
365 /*
366 * free up all but the current bss - if set
367 */
368 wlan_node_reclaim(nt, bss);
369 }
370 }
371 bss = nextBss;
372 }
373 #endif
374 }
375
376 #ifdef THREAD_X
313 static void 377 static void
314 wlan_node_timeout (A_ATH_TIMER arg) 378 wlan_node_timeout (A_ATH_TIMER arg)
315 { 379 {
316 struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg; 380 struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg;
317 bss_t *bss, *nextBss; 381 bss_t *bss, *nextBss;
318 A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE; 382 A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE;
319 A_UINT32 timeoutValue = 0; 383 A_UINT32 timeoutValue = 0;
320 384
321 timeoutValue = nt->nt_nodeAge; 385 timeoutValue = nt->nt_nodeAge;
322 386
(...skipping 23 matching lines...) Expand all
346 } 410 }
347 } 411 }
348 bss = nextBss; 412 bss = nextBss;
349 } 413 }
350 414
351 if (reArmTimer) 415 if (reArmTimer)
352 A_TIMEOUT_MS (&nt->nt_inact_timer, timeoutValue, 0); 416 A_TIMEOUT_MS (&nt->nt_inact_timer, timeoutValue, 0);
353 417
354 nt->isTimerArmed = reArmTimer; 418 nt->isTimerArmed = reArmTimer;
355 } 419 }
420 #endif
356 421
357 void 422 void
358 wlan_node_table_cleanup(struct ieee80211_node_table *nt) 423 wlan_node_table_cleanup(struct ieee80211_node_table *nt)
359 { 424 {
425 #ifdef THREAD_X
360 A_UNTIMEOUT(&nt->nt_inact_timer); 426 A_UNTIMEOUT(&nt->nt_inact_timer);
361 A_DELETE_TIMER(&nt->nt_inact_timer); 427 A_DELETE_TIMER(&nt->nt_inact_timer);
428 #endif
362 wlan_free_allnodes(nt); 429 wlan_free_allnodes(nt);
363 IEEE80211_NODE_LOCK_DESTROY(nt); 430 IEEE80211_NODE_LOCK_DESTROY(nt);
364 } 431 }
365 432
366 bss_t * 433 bss_t *
367 wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid, 434 wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid,
368 A_UINT32 ssidLength, A_BOOL bIsWPA2, A_BOOL bMatchSSID) 435 A_UINT32 ssidLength, A_BOOL bIsWPA2, A_BOOL bMatchSSID)
369 { 436 {
370 bss_t *ni = NULL; 437 bss_t *ni = NULL;
371 A_UCHAR *pIESsid = NULL; 438 A_UCHAR *pIESsid = NULL;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 627 }
561 } 628 }
562 } 629 }
563 } 630 }
564 631
565 IEEE80211_NODE_UNLOCK (nt); 632 IEEE80211_NODE_UNLOCK (nt);
566 633
567 return best_ni; 634 return best_ni;
568 } 635 }
569 636
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/wlan/src/makefile ('k') | chromeos/drivers/ath6kl/wlan/src/wlan_recv_beacon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698