Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
[pandora-kernel.git] / drivers / staging / ath6kl / wlan / include / ieee80211_node.h
1 //------------------------------------------------------------------------------
2 // <copyright file="ieee80211_node.h" company="Atheros">
3 //    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
4 // 
5 //
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
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.
17 //
18 //
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // Author(s): ="Atheros"
22 //==============================================================================
23 #ifndef _IEEE80211_NODE_H_
24 #define _IEEE80211_NODE_H_
25
26 /*
27  * Node locking definitions.
28  */
29 #define IEEE80211_NODE_LOCK_INIT(_nt)   A_MUTEX_INIT(&(_nt)->nt_nodelock)
30 #define IEEE80211_NODE_LOCK_DESTROY(_nt) if (A_IS_MUTEX_VALID(&(_nt)->nt_nodelock)) { \
31                                                A_MUTEX_DELETE(&(_nt)->nt_nodelock); }
32        
33 #define IEEE80211_NODE_LOCK(_nt)        A_MUTEX_LOCK(&(_nt)->nt_nodelock)
34 #define IEEE80211_NODE_UNLOCK(_nt)      A_MUTEX_UNLOCK(&(_nt)->nt_nodelock)
35 #define IEEE80211_NODE_LOCK_BH(_nt)     A_MUTEX_LOCK(&(_nt)->nt_nodelock)
36 #define IEEE80211_NODE_UNLOCK_BH(_nt)   A_MUTEX_UNLOCK(&(_nt)->nt_nodelock)
37 #define IEEE80211_NODE_LOCK_ASSERT(_nt)
38
39 /*
40  * Node reference counting definitions.
41  *
42  * ieee80211_node_initref   initialize the reference count to 1
43  * ieee80211_node_incref    add a reference
44  * ieee80211_node_decref    remove a reference
45  * ieee80211_node_dectestref    remove a reference and return 1 if this
46  *              is the last reference, otherwise 0
47  * ieee80211_node_refcnt    reference count for printing (only)
48  */
49 #define ieee80211_node_initref(_ni)     ((_ni)->ni_refcnt = 1)
50 #define ieee80211_node_incref(_ni)      ((_ni)->ni_refcnt++)
51 #define ieee80211_node_decref(_ni)      ((_ni)->ni_refcnt--)
52 #define ieee80211_node_dectestref(_ni)  (((_ni)->ni_refcnt--) == 1)
53 #define ieee80211_node_refcnt(_ni)      ((_ni)->ni_refcnt)
54
55 #define IEEE80211_NODE_HASHSIZE 32
56 /* simple hash is enough for variation of macaddr */
57 #define IEEE80211_NODE_HASH(addr)   \
58     (((const A_UINT8 *)(addr))[IEEE80211_ADDR_LEN - 1] % \
59         IEEE80211_NODE_HASHSIZE)
60
61 /*
62  * Table of ieee80211_node instances.  Each ieee80211com
63  * has at least one for holding the scan candidates.
64  * When operating as an access point or in ibss mode there
65  * is a second table for associated stations or neighbors.
66  */
67 struct ieee80211_node_table {
68     void                   *nt_wmip;       /* back reference */
69     A_MUTEX_T               nt_nodelock;    /* on node table */
70     struct bss              *nt_node_first; /* information of all nodes */
71     struct bss              *nt_node_last;  /* information of all nodes */
72     struct bss              *nt_hash[IEEE80211_NODE_HASHSIZE];
73     const char              *nt_name;   /* for debugging */
74     A_UINT32                nt_scangen; /* gen# for timeout scan */
75 #ifdef THREAD_X
76     A_TIMER                 nt_inact_timer;
77     A_UINT8                 isTimerArmed;   /* is the node timer armed */
78 #endif
79     A_UINT32                nt_nodeAge; /* node aging time */
80 #ifdef OS_ROAM_MANAGEMENT
81     A_UINT32                nt_si_gen; /* gen# for scan indication*/
82 #endif
83 };
84
85 #ifdef THREAD_X
86 #define WLAN_NODE_INACT_TIMEOUT_MSEC            20000
87 #else
88 #define WLAN_NODE_INACT_TIMEOUT_MSEC            120000
89 #endif
90    
91 #define WLAN_NODE_INACT_CNT            4
92
93 #endif /* _IEEE80211_NODE_H_ */