Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / wlan / ieee80211_var.h
1 #ifndef _NET80211_IEEE80211_VAR_H_
2 #define _NET80211_IEEE80211_VAR_H_
3
4 #include"ieee80211_linux.h"
5 #include <asf_bitmap.h>
6 #include"_ieee80211.h"
7 #include"ieee80211.h"
8 #include"ieee80211_node.h"
9 #include <wlan_hdr.h>
10
11 #define ieee80211_tgt_free_nbuf( _nbuf)          adf_nbuf_free( _nbuf)
12 /*
13  * Built-in implementation for local skb free. Only interesting for platforms
14  * that pass skbs between OS instances.
15  */ 
16 #define ieee80211_tgt_free_local_nbuf( _nbuf)    ieee80211_tgt_free_nbuf( _nbuf)
17
18
19 #define IEEE80211_ADDR_EQ(a1,a2)    (adf_os_mem_cmp(a1,a2,IEEE80211_ADDR_LEN) == 0)
20 #define IEEE80211_ADDR_COPY(dst,src)    adf_os_mem_copy(dst, src, IEEE80211_ADDR_LEN)
21
22 /* ic_flags */
23 #define IEEE80211_F_FF          0x00000001  /* CONF: ATH FF enabled */
24 #define IEEE80211_F_TURBOP      0x00000002  /* CONF: ATH Turbo enabled*/
25 #define IEEE80211_F_PROMISC     0x00000004  /* STATUS: promiscuous mode */
26 #define IEEE80211_F_ALLMULTI    0x00000008  /* STATUS: all multicast mode */
27 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
28 #define IEEE80211_F_PRIVACY     0x00000010  /* CONF: privacy enabled */
29 #define IEEE80211_F_PUREG       0x00000020  /* CONF: 11g w/o 11b sta's */
30 #define IEEE80211_F_XRUPDATE    0x00000040  /* CONF: update beacon XR element*/
31 #define IEEE80211_F_SCAN        0x00000080  /* STATUS: scanning */
32 #define IEEE80211_F_XR          0x00000100  /* CONF: operate in XR mode */
33 #define IEEE80211_F_SIBSS       0x00000200  /* STATUS: start IBSS */
34 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
35 #define IEEE80211_F_SHSLOT      0x00000400  /* STATUS: use short slot time*/
36 #define IEEE80211_F_PMGTON      0x00000800  /* CONF: Power mgmt enable */
37 #define IEEE80211_F_DESBSSID    0x00001000  /* CONF: des_bssid is set */
38 #define IEEE80211_F_WME         0x00002000  /* CONF: enable WME use */
39 #define IEEE80211_F_BGSCAN      0x00004000  /* CONF: bg scan enabled */
40 #define IEEE80211_F_SWRETRY     0x00008000  /* CONF: sw tx retry enabled */
41 #define IEEE80211_F_TXPOW_FIXED 0x00010000  /* TX Power: fixed rate */
42 #define IEEE80211_F_IBSSON      0x00020000  /* CONF: IBSS creation enable */
43 #define IEEE80211_F_SHPREAMBLE  0x00040000  /* STATUS: use short preamble */
44 #define IEEE80211_F_DATAPAD     0x00080000  /* CONF: do alignment pad */
45 #define IEEE80211_F_USEPROT     0x00100000  /* STATUS: protection enabled */
46 #define IEEE80211_F_USEBARKER   0x00200000  /* STATUS: use barker preamble*/
47 #define IEEE80211_F_TIMUPDATE   0x00400000  /* STATUS: update beacon tim */
48 #define IEEE80211_F_WPA1        0x00800000  /* CONF: WPA enabled */
49 #define IEEE80211_F_WPA2        0x01000000  /* CONF: WPA2 enabled */
50 #define IEEE80211_F_WPA         0x01800000  /* CONF: WPA/WPA2 enabled */
51 #define IEEE80211_F_DROPUNENC   0x02000000  /* CONF: drop unencrypted */
52 #define IEEE80211_F_COUNTERM    0x04000000  /* CONF: TKIP countermeasures */
53 #define IEEE80211_F_HIDESSID    0x08000000  /* CONF: hide SSID in beacon */
54 #define IEEE80211_F_NOBRIDGE    0x10000000  /* CONF: disable internal bridge */
55 #define IEEE80211_F_WMEUPDATE   0x20000000  /* STATUS: update beacon wme */
56 #define IEEE80211_F_DOTH        0x40000000  /* enable 11.h */
57 #define IEEE80211_F_CHANSWITCH  0x80000000  /* force chanswitch */
58
59 /* ic_flags_ext */
60 #define IEEE80211_FEXT_WDS          0x00000001  /* CONF: 4 addr allowed */
61 #define IEEE80211_FEXT_COUNTRYIE    0x00000002 /* CONF: enable country IE */
62 #define IEEE80211_FEXT_SCAN_PENDING 0x00000004 /* STATE: scan pending */
63 #define IEEE80211_FEXT_BGSCAN       0x00000008  /* STATE: enable full bgscan completion */
64 #define IEEE80211_FEXT_UAPSD        0x00000010  /* CONF: enable U-APSD */
65 #define IEEE80211_FEXT_SLEEP        0x00000020  /* STATUS: sleeping */
66 #define IEEE80211_FEXT_EOSPDROP     0x00000040  /* drop uapsd EOSP frames for test */
67 #define IEEE80211_FEXT_MARKDFS      0x00000080  /* Enable marking of dfs interfernce */
68 #define IEEE80211_FEXT_REGCLASS     0x00000100  /* CONF: send regclassids in country ie */
69 #define IEEE80211_FEXT_MARKDFS      0x00000080  /* Enable marking of dfs interfernce */
70 #define IEEE80211_FEXT_ERPUPDATE    0x00000200  /* STATUS: update ERP element */
71 #define IEEE80211_FEXT_SWBMISS      0x00000400  /* CONF: use software beacon timer */
72 #define IEEE80211_FEXT_BLKDFSCHAN   0x00000800  /* CONF: block the use of DFS channels */
73 #define IEEE80211_FEXT_APPIE_UPDATE 0x00001000 /* STATE: beacon APP IE updated */
74 #define IEEE80211_FAST_CC           0x00002000  /* CONF: Fast channel change */
75 #define IEEE80211_C_AMPDU           0x00004000  /* CONF: A-MPDU supported */
76 #define IEEE80211_C_AMSDU           0x00008000  /* CONF: A-MSDU supported */
77 #define IEEE80211_C_HTPROT          0x00010000  /* CONF: HT traffic protected */
78 #define IEEE80211_C_RESET           0x00020000  /* CONF: Reset once */
79 #define IEEE80211_F_NONHT_AP        0x00040000  /* STATUS: HT traffic protected */
80 #define IEEE80211_FEXT_HTUPDATE     0x00080000      /* STATUS: update HT element */
81 #define IEEE80211_C_WDS_AUTODETECT  0x00100000 /* CONF: WDS auto Detect/DELBA */
82 #define IEEE80211_C_RB              0x00200000  /* CONF: RB control */
83 #define IEEE80211_C_RB_DETECT       0x00400000  /* CONF: RB auto detection */
84 #define IEEE80211_C_NO_HTIE         0x00800000 /* CONF: No HT IE sending/parsing */
85
86 /* ic_caps */
87 #define IEEE80211_C_WEP     0x00000001  /* CAPABILITY: WEP available */
88 #define IEEE80211_C_TKIP    0x00000002  /* CAPABILITY: TKIP available */
89 #define IEEE80211_C_AES     0x00000004  /* CAPABILITY: AES OCB avail */
90 #define IEEE80211_C_AES_CCM 0x00000008  /* CAPABILITY: AES CCM avail */
91 #define IEEE80211_C_CKIP    0x00000020  /* CAPABILITY: CKIP available */
92 #define IEEE80211_C_FF      0x00000040  /* CAPABILITY: ATH FF avail */
93 #define IEEE80211_C_TURBOP  0x00000080  /* CAPABILITY: ATH Turbo avail*/
94 #define IEEE80211_C_IBSS    0x00000100  /* CAPABILITY: IBSS available */
95 #define IEEE80211_C_PMGT    0x00000200  /* CAPABILITY: Power mgmt */
96 #define IEEE80211_C_HOSTAP  0x00000400  /* CAPABILITY: HOSTAP avail */
97 #define IEEE80211_C_AHDEMO  0x00000800  /* CAPABILITY: Old Adhoc Demo */
98 #define IEEE80211_C_SWRETRY 0x00001000  /* CAPABILITY: sw tx retry */
99 #define IEEE80211_C_TXPMGT  0x00002000  /* CAPABILITY: tx power mgmt */
100 #define IEEE80211_C_SHSLOT  0x00004000  /* CAPABILITY: short slottime */
101 #define IEEE80211_C_SHPREAMBLE  0x00008000  /* CAPABILITY: short preamble */
102 #define IEEE80211_C_MONITOR 0x00010000  /* CAPABILITY: monitor mode */
103 #define IEEE80211_C_TKIPMIC 0x00020000  /* CAPABILITY: TKIP MIC avail */
104 #define IEEE80211_C_WPA1    0x00800000  /* CAPABILITY: WPA1 avail */
105 #define IEEE80211_C_WPA2    0x01000000  /* CAPABILITY: WPA2 avail */
106 #define IEEE80211_C_WPA     0x01800000  /* CAPABILITY: WPA1+WPA2 avail*/
107 #define IEEE80211_C_BURST   0x02000000  /* CAPABILITY: frame bursting */
108 #define IEEE80211_C_WME     0x04000000  /* CAPABILITY: WME avail */
109 #define IEEE80211_C_WDS     0x08000000  /* CAPABILITY: 4-addr support */
110 #define IEEE80211_C_WME_TKIPMIC 0x10000000  /* CAPABILITY: TKIP MIC for QoS frame */
111 #define IEEE80211_C_BGSCAN  0x20000000  /* CAPABILITY: bg scanning */
112 #define IEEE80211_C_UAPSD       0x40000000      /* CAPABILITY: UAPSD */
113 #define IEEE80211_C_FASTCC      0x80000000      /* CAPABILITY: fast channel change */
114
115 /* XXX protection/barker? */
116
117 #define IEEE80211_C_CRYPTO  0x0000002f  /* CAPABILITY: crypto alg's */
118
119 /* Atheros ABOLT definitions */
120 #define IEEE80211_ABOLT_TURBO_G     0x01    /* Legacy Turbo G */
121 #define IEEE80211_ABOLT_TURBO_PRIME 0x02    /* Turbo Prime */
122 #define IEEE80211_ABOLT_COMPRESSION 0x04    /* Compression */
123 #define IEEE80211_ABOLT_FAST_FRAME  0x08    /* Fast Frames */
124 #define IEEE80211_ABOLT_BURST       0x10    /* Bursting */
125 #define IEEE80211_ABOLT_WME_ELE     0x20    /* WME based cwmin/max/burst tuning */
126 #define IEEE80211_ABOLT_XR          0x40    /* XR */
127 #define IEEE80211_ABOLT_AR          0x80    /* AR switches out based on adjaced non-turbo traffic */
128
129 /* Atheros Advanced Capabilities ABOLT definition */
130 #define IEEE80211_ABOLT_ADVCAP  (IEEE80211_ABOLT_TURBO_PRIME |  \
131                                  IEEE80211_ABOLT_COMPRESSION |  \
132                                  IEEE80211_ABOLT_FAST_FRAME |   \
133                                  IEEE80211_ABOLT_XR |           \
134                                  IEEE80211_ABOLT_AR |           \
135                                  IEEE80211_ABOLT_BURST |        \
136                                  IEEE80211_ABOLT_WME_ELE)
137
138 /* check if a capability was negotiated for use */
139 #define IEEE80211_ATH_CAP(vap, ni, bit) \
140     ((ni)->ni_ath_flags & (vap)->iv_ath_cap & (bit))
141
142 /* flags to VAP create function */
143 #define IEEE80211_VAP_XR        0x10000 /* create a XR VAP without registering net device with OS*/
144
145 /* HT flags */
146 #define IEEE80211_HTF_SHORTGI          0x0001
147
148
149 /***************  Utility Routines ***/
150 /*
151  * Return the size of the 802.11 header for a management or data frame.
152  */
153 static __inline a_int32_t
154 ieee80211_hdrsize(const void *data)
155 {
156         const struct ieee80211_frame *wh = data;
157         a_int32_t size = sizeof(struct ieee80211_frame);
158
159         /* NB: we don't handle control frames */
160         adf_os_assert((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL);
161         if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
162                 size += IEEE80211_ADDR_LEN;
163         if (IEEE80211_QOS_HAS_SEQ(wh))
164                 size += sizeof(a_uint16_t);
165         return size;
166 }
167
168 /*
169  * Return the size of the 802.11 header for a management or data frame.
170  */
171 static __inline a_int32_t
172 ieee80211_hdrsize_padding(const void *data)
173 {
174         const struct ieee80211_frame *wh = data;
175         a_int32_t size = sizeof(struct ieee80211_frame);
176         a_int32_t is4addr = (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS;
177         a_int32_t is_qos = IEEE80211_QOS_HAS_SEQ(wh);
178
179         /* NB: we don't handle control frames */
180         adf_os_assert((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL);
181         if (is4addr)
182                 size += IEEE80211_ADDR_LEN;
183         if (is_qos)
184                 size += sizeof(a_uint16_t);
185         if (is4addr && is_qos)
186                 size += sizeof(a_uint16_t);
187         return size;
188 }
189
190 /*
191  * Like ieee80211_hdrsize, but handles any type of frame.
192  */
193 static __inline a_int32_t
194 ieee80211_anyhdrsize(const void *data)
195 {
196         const struct ieee80211_frame *wh = data;
197
198         if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
199                 switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) {
200                 case IEEE80211_FC0_SUBTYPE_CTS:
201                 case IEEE80211_FC0_SUBTYPE_ACK:
202                         return sizeof(struct ieee80211_frame_ack);
203                 }
204                 return sizeof(struct ieee80211_frame_min);
205         } else
206                 return ieee80211_hdrsize(data);
207 }
208
209 #endif