1f0706e82SJiri Benc /* 2f0706e82SJiri Benc * Copyright 2002-2005, Instant802 Networks, Inc. 3f0706e82SJiri Benc * Copyright 2005, Devicescape Software, Inc. 4f0706e82SJiri Benc * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5f0706e82SJiri Benc * 6f0706e82SJiri Benc * This program is free software; you can redistribute it and/or modify 7f0706e82SJiri Benc * it under the terms of the GNU General Public License version 2 as 8f0706e82SJiri Benc * published by the Free Software Foundation. 9f0706e82SJiri Benc */ 10f0706e82SJiri Benc 11f0706e82SJiri Benc #ifndef IEEE80211_I_H 12f0706e82SJiri Benc #define IEEE80211_I_H 13f0706e82SJiri Benc 14f0706e82SJiri Benc #include <linux/kernel.h> 15f0706e82SJiri Benc #include <linux/device.h> 16f0706e82SJiri Benc #include <linux/if_ether.h> 17f0706e82SJiri Benc #include <linux/interrupt.h> 18f0706e82SJiri Benc #include <linux/list.h> 19f0706e82SJiri Benc #include <linux/netdevice.h> 20f0706e82SJiri Benc #include <linux/skbuff.h> 21f0706e82SJiri Benc #include <linux/workqueue.h> 22f0706e82SJiri Benc #include <linux/types.h> 23f0706e82SJiri Benc #include <linux/spinlock.h> 24571ecf67SJohannes Berg #include <linux/etherdevice.h> 25f0706e82SJiri Benc #include <net/wireless.h> 26f0706e82SJiri Benc #include "ieee80211_key.h" 27f0706e82SJiri Benc #include "sta_info.h" 28f0706e82SJiri Benc 29f0706e82SJiri Benc /* ieee80211.o internal definitions, etc. These are not included into 30f0706e82SJiri Benc * low-level drivers. */ 31f0706e82SJiri Benc 32f0706e82SJiri Benc #ifndef ETH_P_PAE 33f0706e82SJiri Benc #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 34f0706e82SJiri Benc #endif /* ETH_P_PAE */ 35f0706e82SJiri Benc 36f0706e82SJiri Benc #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08) 37f0706e82SJiri Benc 389cfb0009SJohannes Berg #define IEEE80211_FC(type, subtype) cpu_to_le16(type | subtype) 39f0706e82SJiri Benc 409cfb0009SJohannes Berg struct ieee80211_local; 41f0706e82SJiri Benc 42f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the 43f0706e82SJiri Benc * associated stations are using power saving. */ 44f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128 45f0706e82SJiri Benc 46f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames. 47f0706e82SJiri Benc * Note: increasing this limit increases the potential memory requirement. Each 48f0706e82SJiri Benc * frame can be up to about 2 kB long. */ 49f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512 50f0706e82SJiri Benc 51f0706e82SJiri Benc /* Required encryption head and tailroom */ 52f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8 53f0706e82SJiri Benc #define IEEE80211_ENCRYPT_TAILROOM 12 54f0706e82SJiri Benc 55f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent 56f0706e82SJiri Benc * reception of at least three fragmented frames. This limit can be increased 57f0706e82SJiri Benc * by changing this define, at the cost of slower frame reassembly and 58f0706e82SJiri Benc * increased memory use (about 2 kB of RAM per entry). */ 59f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4 60f0706e82SJiri Benc 61f0706e82SJiri Benc struct ieee80211_fragment_entry { 62f0706e82SJiri Benc unsigned long first_frag_time; 63f0706e82SJiri Benc unsigned int seq; 64f0706e82SJiri Benc unsigned int rx_queue; 65f0706e82SJiri Benc unsigned int last_frag; 66f0706e82SJiri Benc unsigned int extra_len; 67f0706e82SJiri Benc struct sk_buff_head skb_list; 68f0706e82SJiri Benc int ccmp; /* Whether fragments were encrypted with CCMP */ 69f0706e82SJiri Benc u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ 70f0706e82SJiri Benc }; 71f0706e82SJiri Benc 72f0706e82SJiri Benc 73f0706e82SJiri Benc struct ieee80211_sta_bss { 74f0706e82SJiri Benc struct list_head list; 75f0706e82SJiri Benc struct ieee80211_sta_bss *hnext; 76056cdd59SJohannes Berg size_t ssid_len; 77056cdd59SJohannes Berg 78f0706e82SJiri Benc atomic_t users; 79f0706e82SJiri Benc 80f0706e82SJiri Benc u8 bssid[ETH_ALEN]; 81f0706e82SJiri Benc u8 ssid[IEEE80211_MAX_SSID_LEN]; 82f0706e82SJiri Benc u16 capability; /* host byte order */ 838318d78aSJohannes Berg enum ieee80211_band band; 84f0706e82SJiri Benc int freq; 85f0706e82SJiri Benc int rssi, signal, noise; 86f0706e82SJiri Benc u8 *wpa_ie; 87f0706e82SJiri Benc size_t wpa_ie_len; 88f0706e82SJiri Benc u8 *rsn_ie; 89f0706e82SJiri Benc size_t rsn_ie_len; 90f0706e82SJiri Benc u8 *wmm_ie; 91f0706e82SJiri Benc size_t wmm_ie_len; 92c7153508SRon Rindjunsky u8 *ht_ie; 93c7153508SRon Rindjunsky size_t ht_ie_len; 94ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 95ee385855SLuis Carlos Cobo u8 *mesh_id; 96ee385855SLuis Carlos Cobo size_t mesh_id_len; 9724736701SJohn W. Linville u8 *mesh_cfg; 98902acc78SJohannes Berg #endif 99f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32 100f0706e82SJiri Benc u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 101f0706e82SJiri Benc size_t supp_rates_len; 102f0706e82SJiri Benc u64 timestamp; 103056cdd59SJohannes Berg int beacon_int; 104f0706e82SJiri Benc 105f0706e82SJiri Benc int probe_resp; 106f0706e82SJiri Benc unsigned long last_update; 107f0706e82SJiri Benc 1085628221cSDaniel Drake /* during assocation, we save an ERP value from a probe response so 1095628221cSDaniel Drake * that we can feed ERP info to the driver when handling the 1105628221cSDaniel Drake * association completes. these fields probably won't be up-to-date 1115628221cSDaniel Drake * otherwise, you probably don't want to use them. */ 1125628221cSDaniel Drake int has_erp_value; 1135628221cSDaniel Drake u8 erp_value; 114f0706e82SJiri Benc }; 115f0706e82SJiri Benc 11624736701SJohn W. Linville static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss) 117902acc78SJohannes Berg { 118902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 119902acc78SJohannes Berg return bss->mesh_cfg; 120902acc78SJohannes Berg #endif 121902acc78SJohannes Berg return NULL; 122902acc78SJohannes Berg } 123902acc78SJohannes Berg 124902acc78SJohannes Berg static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss) 125902acc78SJohannes Berg { 126902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 127902acc78SJohannes Berg return bss->mesh_id; 128902acc78SJohannes Berg #endif 129902acc78SJohannes Berg return NULL; 130902acc78SJohannes Berg } 131902acc78SJohannes Berg 132902acc78SJohannes Berg static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss) 133902acc78SJohannes Berg { 134902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 135902acc78SJohannes Berg return bss->mesh_id_len; 136902acc78SJohannes Berg #endif 137902acc78SJohannes Berg return 0; 138902acc78SJohannes Berg } 139902acc78SJohannes Berg 140f0706e82SJiri Benc 1419ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result; 1429ae54c84SJohannes Berg #define TX_CONTINUE ((__force ieee80211_tx_result) 0u) 1439ae54c84SJohannes Berg #define TX_DROP ((__force ieee80211_tx_result) 1u) 1449ae54c84SJohannes Berg #define TX_QUEUED ((__force ieee80211_tx_result) 2u) 1459ae54c84SJohannes Berg 1465cf121c3SJohannes Berg #define IEEE80211_TX_FRAGMENTED BIT(0) 1475cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST BIT(1) 1485cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED BIT(2) 1495cf121c3SJohannes Berg #define IEEE80211_TX_PROBE_LAST_FRAG BIT(3) 1505cf121c3SJohannes Berg #define IEEE80211_TX_INJECTED BIT(4) 1519ae54c84SJohannes Berg 1525cf121c3SJohannes Berg struct ieee80211_tx_data { 153f0706e82SJiri Benc struct sk_buff *skb; 154f0706e82SJiri Benc struct net_device *dev; 155f0706e82SJiri Benc struct ieee80211_local *local; 156f0706e82SJiri Benc struct ieee80211_sub_if_data *sdata; 157f0706e82SJiri Benc struct sta_info *sta; 158f0706e82SJiri Benc struct ieee80211_key *key; 1595cf121c3SJohannes Berg 160f0706e82SJiri Benc struct ieee80211_tx_control *control; 1618318d78aSJohannes Berg struct ieee80211_channel *channel; 162f0706e82SJiri Benc struct ieee80211_rate *rate; 163f0706e82SJiri Benc /* use this rate (if set) for last fragment; rate can 164f0706e82SJiri Benc * be set to lower rate for the first fragments, e.g., 165f0706e82SJiri Benc * when using CTS protection with IEEE 802.11g. */ 166f0706e82SJiri Benc struct ieee80211_rate *last_frag_rate; 167f0706e82SJiri Benc 168f0706e82SJiri Benc /* Extra fragments (in addition to the first fragment 169f0706e82SJiri Benc * in skb) */ 170f0706e82SJiri Benc struct sk_buff **extra_frag; 171056cdd59SJohannes Berg int num_extra_frag; 172056cdd59SJohannes Berg 173056cdd59SJohannes Berg u16 fc, ethertype; 174056cdd59SJohannes Berg unsigned int flags; 1755cf121c3SJohannes Berg }; 1765cf121c3SJohannes Berg 1775cf121c3SJohannes Berg 1785cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result; 1795cf121c3SJohannes Berg #define RX_CONTINUE ((__force ieee80211_rx_result) 0u) 1805cf121c3SJohannes Berg #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u) 1815cf121c3SJohannes Berg #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u) 1825cf121c3SJohannes Berg #define RX_QUEUED ((__force ieee80211_rx_result) 3u) 1835cf121c3SJohannes Berg 1845cf121c3SJohannes Berg #define IEEE80211_RX_IN_SCAN BIT(0) 1855cf121c3SJohannes Berg /* frame is destined to interface currently processed (incl. multicast frames) */ 1865cf121c3SJohannes Berg #define IEEE80211_RX_RA_MATCH BIT(1) 1875cf121c3SJohannes Berg #define IEEE80211_RX_AMSDU BIT(2) 1885cf121c3SJohannes Berg #define IEEE80211_RX_CMNTR_REPORTED BIT(3) 1895cf121c3SJohannes Berg #define IEEE80211_RX_FRAGMENTED BIT(4) 1905cf121c3SJohannes Berg 1915cf121c3SJohannes Berg struct ieee80211_rx_data { 1925cf121c3SJohannes Berg struct sk_buff *skb; 1935cf121c3SJohannes Berg struct net_device *dev; 1945cf121c3SJohannes Berg struct ieee80211_local *local; 1955cf121c3SJohannes Berg struct ieee80211_sub_if_data *sdata; 1965cf121c3SJohannes Berg struct sta_info *sta; 1975cf121c3SJohannes Berg struct ieee80211_key *key; 198f0706e82SJiri Benc struct ieee80211_rx_status *status; 1998318d78aSJohannes Berg struct ieee80211_rate *rate; 200056cdd59SJohannes Berg 201056cdd59SJohannes Berg u16 fc, ethertype; 202056cdd59SJohannes Berg unsigned int flags; 203f0706e82SJiri Benc int sent_ps_buffered; 204f0706e82SJiri Benc int queue; 205f0706e82SJiri Benc int load; 20650741ae0SJohannes Berg u32 tkip_iv32; 20750741ae0SJohannes Berg u16 tkip_iv16; 208f0706e82SJiri Benc }; 209f0706e82SJiri Benc 210e8bf9649SJiri Slaby /* flags used in struct ieee80211_tx_packet_data.flags */ 211e8bf9649SJiri Slaby #define IEEE80211_TXPD_REQ_TX_STATUS BIT(0) 212e8bf9649SJiri Slaby #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1) 213e8bf9649SJiri Slaby #define IEEE80211_TXPD_REQUEUE BIT(2) 214678f5f71SJohannes Berg #define IEEE80211_TXPD_EAPOL_FRAME BIT(3) 2159e723492SRon Rindjunsky #define IEEE80211_TXPD_AMPDU BIT(4) 216f0706e82SJiri Benc /* Stored in sk_buff->cb */ 217f0706e82SJiri Benc struct ieee80211_tx_packet_data { 218f0706e82SJiri Benc int ifindex; 219f0706e82SJiri Benc unsigned long jiffies; 220e8bf9649SJiri Slaby unsigned int flags; 221e8bf9649SJiri Slaby u8 queue; 222f0706e82SJiri Benc }; 223f0706e82SJiri Benc 224f0706e82SJiri Benc struct ieee80211_tx_stored_packet { 225f0706e82SJiri Benc struct ieee80211_tx_control control; 226f0706e82SJiri Benc struct sk_buff *skb; 227f0706e82SJiri Benc struct sk_buff **extra_frag; 228f0706e82SJiri Benc struct ieee80211_rate *last_frag_rate; 229056cdd59SJohannes Berg int num_extra_frag; 230badffb72SJiri Slaby unsigned int last_frag_rate_ctrl_probe; 231f0706e82SJiri Benc }; 232f0706e82SJiri Benc 2335dfdaf58SJohannes Berg struct beacon_data { 2345dfdaf58SJohannes Berg u8 *head, *tail; 2355dfdaf58SJohannes Berg int head_len, tail_len; 2365dfdaf58SJohannes Berg int dtim_period; 2375dfdaf58SJohannes Berg }; 2385dfdaf58SJohannes Berg 239f0706e82SJiri Benc struct ieee80211_if_ap { 2405dfdaf58SJohannes Berg struct beacon_data *beacon; 241f0706e82SJiri Benc 2420ec3ca44SJohannes Berg struct list_head vlans; 2430ec3ca44SJohannes Berg 244f0706e82SJiri Benc u8 ssid[IEEE80211_MAX_SSID_LEN]; 245f0706e82SJiri Benc size_t ssid_len; 246f0706e82SJiri Benc 247f0706e82SJiri Benc /* yes, this looks ugly, but guarantees that we can later use 248f0706e82SJiri Benc * bitmap_empty :) 249004c872eSJohannes Berg * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ 250f0706e82SJiri Benc u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; 251f0706e82SJiri Benc struct sk_buff_head ps_bc_buf; 252056cdd59SJohannes Berg atomic_t num_sta_ps; /* number of stations in PS mode */ 2535dfdaf58SJohannes Berg int dtim_count; 254f0706e82SJiri Benc int force_unicast_rateidx; /* forced TX rateidx for unicast frames */ 255f0706e82SJiri Benc int max_ratectrl_rateidx; /* max TX rateidx for rate control */ 256f0706e82SJiri Benc int num_beacons; /* number of TXed beacon frames for this BSS */ 257f0706e82SJiri Benc }; 258f0706e82SJiri Benc 259f0706e82SJiri Benc struct ieee80211_if_wds { 260f0706e82SJiri Benc struct sta_info *sta; 261056cdd59SJohannes Berg u8 remote_addr[ETH_ALEN]; 262f0706e82SJiri Benc }; 263f0706e82SJiri Benc 264f0706e82SJiri Benc struct ieee80211_if_vlan { 2650ec3ca44SJohannes Berg struct ieee80211_sub_if_data *ap; 2660ec3ca44SJohannes Berg struct list_head list; 267f0706e82SJiri Benc }; 268f0706e82SJiri Benc 269ee385855SLuis Carlos Cobo struct mesh_stats { 270ee385855SLuis Carlos Cobo __u32 fwded_frames; /* Mesh forwarded frames */ 271ee385855SLuis Carlos Cobo __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ 272ee385855SLuis Carlos Cobo __u32 dropped_frames_no_route; /* Not transmitted, no route found */ 273ee385855SLuis Carlos Cobo atomic_t estab_plinks; 274ee385855SLuis Carlos Cobo }; 275ee385855SLuis Carlos Cobo 276ee385855SLuis Carlos Cobo #define PREQ_Q_F_START 0x1 277ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH 0x2 278ee385855SLuis Carlos Cobo struct mesh_preq_queue { 279ee385855SLuis Carlos Cobo struct list_head list; 280ee385855SLuis Carlos Cobo u8 dst[ETH_ALEN]; 281ee385855SLuis Carlos Cobo u8 flags; 282ee385855SLuis Carlos Cobo }; 283ee385855SLuis Carlos Cobo 284ee385855SLuis Carlos Cobo struct mesh_config { 285ee385855SLuis Carlos Cobo /* Timeouts in ms */ 286ee385855SLuis Carlos Cobo /* Mesh plink management parameters */ 287ee385855SLuis Carlos Cobo u16 dot11MeshRetryTimeout; 288ee385855SLuis Carlos Cobo u16 dot11MeshConfirmTimeout; 289ee385855SLuis Carlos Cobo u16 dot11MeshHoldingTimeout; 290ee385855SLuis Carlos Cobo u16 dot11MeshMaxPeerLinks; 291ee385855SLuis Carlos Cobo u8 dot11MeshMaxRetries; 292ee385855SLuis Carlos Cobo u8 dot11MeshTTL; 293ee385855SLuis Carlos Cobo bool auto_open_plinks; 294ee385855SLuis Carlos Cobo /* HWMP parameters */ 295ee385855SLuis Carlos Cobo u8 dot11MeshHWMPmaxPREQretries; 296ee385855SLuis Carlos Cobo u32 path_refresh_time; 297ee385855SLuis Carlos Cobo u16 min_discovery_timeout; 298056cdd59SJohannes Berg u32 dot11MeshHWMPactivePathTimeout; 299056cdd59SJohannes Berg u16 dot11MeshHWMPpreqMinInterval; 300056cdd59SJohannes Berg u16 dot11MeshHWMPnetDiameterTraversalTime; 301ee385855SLuis Carlos Cobo }; 302902acc78SJohannes Berg 303ee385855SLuis Carlos Cobo 304d6f2da5bSJiri Slaby /* flags used in struct ieee80211_if_sta.flags */ 305d6f2da5bSJiri Slaby #define IEEE80211_STA_SSID_SET BIT(0) 306d6f2da5bSJiri Slaby #define IEEE80211_STA_BSSID_SET BIT(1) 307d6f2da5bSJiri Slaby #define IEEE80211_STA_PREV_BSSID_SET BIT(2) 308d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTHENTICATED BIT(3) 309d6f2da5bSJiri Slaby #define IEEE80211_STA_ASSOCIATED BIT(4) 310d6f2da5bSJiri Slaby #define IEEE80211_STA_PROBEREQ_POLL BIT(5) 311d6f2da5bSJiri Slaby #define IEEE80211_STA_CREATE_IBSS BIT(6) 312d6f2da5bSJiri Slaby #define IEEE80211_STA_MIXED_CELL BIT(7) 313d6f2da5bSJiri Slaby #define IEEE80211_STA_WMM_ENABLED BIT(8) 314d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_SSID_SEL BIT(10) 315d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11) 316d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12) 3175b98b1f7SJohannes Berg #define IEEE80211_STA_PRIVACY_INVOKED BIT(13) 318f0706e82SJiri Benc struct ieee80211_if_sta { 319056cdd59SJohannes Berg struct timer_list timer; 320056cdd59SJohannes Berg struct work_struct work; 321056cdd59SJohannes Berg u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 322056cdd59SJohannes Berg u8 ssid[IEEE80211_MAX_SSID_LEN]; 323f0706e82SJiri Benc enum { 324f0706e82SJiri Benc IEEE80211_DISABLED, IEEE80211_AUTHENTICATE, 325f0706e82SJiri Benc IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED, 326ee385855SLuis Carlos Cobo IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED, 327ee385855SLuis Carlos Cobo IEEE80211_MESH_UP 328f0706e82SJiri Benc } state; 329f0706e82SJiri Benc size_t ssid_len; 330a0af5f14SHelmut Schaa u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 331a0af5f14SHelmut Schaa size_t scan_ssid_len; 332ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 333ee385855SLuis Carlos Cobo struct timer_list mesh_path_timer; 334ee385855SLuis Carlos Cobo u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; 335ee385855SLuis Carlos Cobo size_t mesh_id_len; 336ee385855SLuis Carlos Cobo /* Active Path Selection Protocol Identifier */ 337ee385855SLuis Carlos Cobo u8 mesh_pp_id[4]; 338ee385855SLuis Carlos Cobo /* Active Path Selection Metric Identifier */ 339ee385855SLuis Carlos Cobo u8 mesh_pm_id[4]; 340ee385855SLuis Carlos Cobo /* Congestion Control Mode Identifier */ 341ee385855SLuis Carlos Cobo u8 mesh_cc_id[4]; 342ee385855SLuis Carlos Cobo /* Local mesh Destination Sequence Number */ 343ee385855SLuis Carlos Cobo u32 dsn; 344ee385855SLuis Carlos Cobo /* Last used PREQ ID */ 345ee385855SLuis Carlos Cobo u32 preq_id; 346ee385855SLuis Carlos Cobo atomic_t mpaths; 347ee385855SLuis Carlos Cobo /* Timestamp of last DSN update */ 348ee385855SLuis Carlos Cobo unsigned long last_dsn_update; 349ee385855SLuis Carlos Cobo /* Timestamp of last DSN sent */ 350ee385855SLuis Carlos Cobo unsigned long last_preq; 351ee385855SLuis Carlos Cobo struct mesh_rmc *rmc; 352ee385855SLuis Carlos Cobo spinlock_t mesh_preq_queue_lock; 353ee385855SLuis Carlos Cobo struct mesh_preq_queue preq_queue; 354ee385855SLuis Carlos Cobo int preq_queue_len; 355ee385855SLuis Carlos Cobo struct mesh_stats mshstats; 356ee385855SLuis Carlos Cobo struct mesh_config mshcfg; 357ee385855SLuis Carlos Cobo u8 mesh_seqnum[3]; 358056cdd59SJohannes Berg bool accepting_plinks; 359ee385855SLuis Carlos Cobo #endif 360f0706e82SJiri Benc u16 aid; 361f0706e82SJiri Benc u16 ap_capab, capab; 362f0706e82SJiri Benc u8 *extra_ie; /* to be added to the end of AssocReq */ 363f0706e82SJiri Benc size_t extra_ie_len; 364f0706e82SJiri Benc 365f0706e82SJiri Benc /* The last AssocReq/Resp IEs */ 366f0706e82SJiri Benc u8 *assocreq_ies, *assocresp_ies; 367f0706e82SJiri Benc size_t assocreq_ies_len, assocresp_ies_len; 368f0706e82SJiri Benc 369056cdd59SJohannes Berg struct sk_buff_head skb_queue; 370056cdd59SJohannes Berg 371f0706e82SJiri Benc int auth_tries, assoc_tries; 372f0706e82SJiri Benc 373056cdd59SJohannes Berg unsigned long request; 374056cdd59SJohannes Berg 375056cdd59SJohannes Berg unsigned long last_probe; 376056cdd59SJohannes Berg 377d6f2da5bSJiri Slaby unsigned int flags; 378f0706e82SJiri Benc #define IEEE80211_STA_REQ_SCAN 0 379f0706e82SJiri Benc #define IEEE80211_STA_REQ_AUTH 1 380f0706e82SJiri Benc #define IEEE80211_STA_REQ_RUN 2 381f0706e82SJiri Benc 382f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_OPEN BIT(0) 383f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) 384f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_LEAP BIT(2) 385f0706e82SJiri Benc unsigned int auth_algs; /* bitfield of allowed auth algs */ 386f0706e82SJiri Benc int auth_alg; /* currently used IEEE 802.11 authentication algorithm */ 387f0706e82SJiri Benc int auth_transaction; 388f0706e82SJiri Benc 389f0706e82SJiri Benc unsigned long ibss_join_req; 390f0706e82SJiri Benc struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 3918318d78aSJohannes Berg u32 supp_rates_bits[IEEE80211_NUM_BANDS]; 392f0706e82SJiri Benc 393f0706e82SJiri Benc int wmm_last_param_set; 394ee385855SLuis Carlos Cobo int num_beacons; /* number of TXed beacon frames by this STA */ 395f0706e82SJiri Benc }; 396f0706e82SJiri Benc 397902acc78SJohannes Berg static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta, 398902acc78SJohannes Berg u8 mesh_id_len, u8 *mesh_id) 399902acc78SJohannes Berg { 400902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 401902acc78SJohannes Berg ifsta->mesh_id_len = mesh_id_len; 402902acc78SJohannes Berg memcpy(ifsta->mesh_id, mesh_id, mesh_id_len); 403902acc78SJohannes Berg #endif 404902acc78SJohannes Berg } 405902acc78SJohannes Berg 406902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 407902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \ 408902acc78SJohannes Berg do { (sta)->mshstats.name++; } while (0) 409902acc78SJohannes Berg #else 410902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \ 411902acc78SJohannes Berg do { } while (0) 412902acc78SJohannes Berg #endif 413f0706e82SJiri Benc 41413262ffdSJiri Slaby /* flags used in struct ieee80211_sub_if_data.flags */ 41513262ffdSJiri Slaby #define IEEE80211_SDATA_ALLMULTI BIT(0) 41613262ffdSJiri Slaby #define IEEE80211_SDATA_PROMISC BIT(1) 417471b3efdSJohannes Berg #define IEEE80211_SDATA_USERSPACE_MLME BIT(2) 4188318d78aSJohannes Berg #define IEEE80211_SDATA_OPERATING_GMODE BIT(3) 419f0706e82SJiri Benc struct ieee80211_sub_if_data { 420f0706e82SJiri Benc struct list_head list; 421f0706e82SJiri Benc 422f0706e82SJiri Benc struct wireless_dev wdev; 423f0706e82SJiri Benc 42411a843b7SJohannes Berg /* keys */ 42511a843b7SJohannes Berg struct list_head key_list; 42611a843b7SJohannes Berg 427f0706e82SJiri Benc struct net_device *dev; 428f0706e82SJiri Benc struct ieee80211_local *local; 429f0706e82SJiri Benc 43013262ffdSJiri Slaby unsigned int flags; 4317e9ed188SDaniel Drake 432f0706e82SJiri Benc int drop_unencrypted; 433f0706e82SJiri Benc 4348318d78aSJohannes Berg /* 4358318d78aSJohannes Berg * basic rates of this AP or the AP we're associated to 4368318d78aSJohannes Berg */ 4378318d78aSJohannes Berg u64 basic_rates; 4388318d78aSJohannes Berg 439f0706e82SJiri Benc u16 sequence; 440f0706e82SJiri Benc 441f0706e82SJiri Benc /* Fragment table for host-based reassembly */ 442f0706e82SJiri Benc struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX]; 443f0706e82SJiri Benc unsigned int fragment_next; 444f0706e82SJiri Benc 445f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4 446f0706e82SJiri Benc struct ieee80211_key *keys[NUM_DEFAULT_KEYS]; 447f0706e82SJiri Benc struct ieee80211_key *default_key; 448f0706e82SJiri Benc 449471b3efdSJohannes Berg /* 450471b3efdSJohannes Berg * BSS configuration for this interface. 451471b3efdSJohannes Berg * 452471b3efdSJohannes Berg * FIXME: I feel bad putting this here when we already have a 453471b3efdSJohannes Berg * bss pointer, but the bss pointer is just wrong when 454471b3efdSJohannes Berg * you have multiple virtual STA mode interfaces... 455471b3efdSJohannes Berg * This needs to be fixed. 456471b3efdSJohannes Berg */ 457471b3efdSJohannes Berg struct ieee80211_bss_conf bss_conf; 458f0706e82SJiri Benc struct ieee80211_if_ap *bss; /* BSS that this device belongs to */ 459f0706e82SJiri Benc 460f0706e82SJiri Benc union { 461f0706e82SJiri Benc struct ieee80211_if_ap ap; 462f0706e82SJiri Benc struct ieee80211_if_wds wds; 463f0706e82SJiri Benc struct ieee80211_if_vlan vlan; 464f0706e82SJiri Benc struct ieee80211_if_sta sta; 4658cc9a739SMichael Wu u32 mntr_flags; 466f0706e82SJiri Benc } u; 467f0706e82SJiri Benc int channel_use; 468f0706e82SJiri Benc int channel_use_raw; 469e9f207f0SJiri Benc 470e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 471e9f207f0SJiri Benc struct dentry *debugfsdir; 472e9f207f0SJiri Benc union { 473e9f207f0SJiri Benc struct { 474e9f207f0SJiri Benc struct dentry *channel_use; 475e9f207f0SJiri Benc struct dentry *drop_unencrypted; 476e9f207f0SJiri Benc struct dentry *state; 477e9f207f0SJiri Benc struct dentry *bssid; 478e9f207f0SJiri Benc struct dentry *prev_bssid; 479e9f207f0SJiri Benc struct dentry *ssid_len; 480e9f207f0SJiri Benc struct dentry *aid; 481e9f207f0SJiri Benc struct dentry *ap_capab; 482e9f207f0SJiri Benc struct dentry *capab; 483e9f207f0SJiri Benc struct dentry *extra_ie_len; 484e9f207f0SJiri Benc struct dentry *auth_tries; 485e9f207f0SJiri Benc struct dentry *assoc_tries; 486e9f207f0SJiri Benc struct dentry *auth_algs; 487e9f207f0SJiri Benc struct dentry *auth_alg; 488e9f207f0SJiri Benc struct dentry *auth_transaction; 489e9f207f0SJiri Benc struct dentry *flags; 490ee385855SLuis Carlos Cobo struct dentry *num_beacons_sta; 491e9f207f0SJiri Benc } sta; 492e9f207f0SJiri Benc struct { 493e9f207f0SJiri Benc struct dentry *channel_use; 494e9f207f0SJiri Benc struct dentry *drop_unencrypted; 495e9f207f0SJiri Benc struct dentry *num_sta_ps; 496e9f207f0SJiri Benc struct dentry *dtim_count; 497e9f207f0SJiri Benc struct dentry *num_beacons; 498e9f207f0SJiri Benc struct dentry *force_unicast_rateidx; 499e9f207f0SJiri Benc struct dentry *max_ratectrl_rateidx; 500e9f207f0SJiri Benc struct dentry *num_buffered_multicast; 501e9f207f0SJiri Benc } ap; 502e9f207f0SJiri Benc struct { 503e9f207f0SJiri Benc struct dentry *channel_use; 504e9f207f0SJiri Benc struct dentry *drop_unencrypted; 505e9f207f0SJiri Benc struct dentry *peer; 506e9f207f0SJiri Benc } wds; 507e9f207f0SJiri Benc struct { 508e9f207f0SJiri Benc struct dentry *channel_use; 509e9f207f0SJiri Benc struct dentry *drop_unencrypted; 510e9f207f0SJiri Benc } vlan; 511e9f207f0SJiri Benc struct { 512e9f207f0SJiri Benc struct dentry *mode; 513e9f207f0SJiri Benc } monitor; 514e9f207f0SJiri Benc struct dentry *default_key; 515e9f207f0SJiri Benc } debugfs; 516ee385855SLuis Carlos Cobo 517ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 518ee385855SLuis Carlos Cobo struct dentry *mesh_stats_dir; 519ee385855SLuis Carlos Cobo struct { 520ee385855SLuis Carlos Cobo struct dentry *fwded_frames; 521ee385855SLuis Carlos Cobo struct dentry *dropped_frames_ttl; 522ee385855SLuis Carlos Cobo struct dentry *dropped_frames_no_route; 523ee385855SLuis Carlos Cobo struct dentry *estab_plinks; 524ee385855SLuis Carlos Cobo struct timer_list mesh_path_timer; 525ee385855SLuis Carlos Cobo } mesh_stats; 526ee385855SLuis Carlos Cobo 527ee385855SLuis Carlos Cobo struct dentry *mesh_config_dir; 528ee385855SLuis Carlos Cobo struct { 529ee385855SLuis Carlos Cobo struct dentry *dot11MeshRetryTimeout; 530ee385855SLuis Carlos Cobo struct dentry *dot11MeshConfirmTimeout; 531ee385855SLuis Carlos Cobo struct dentry *dot11MeshHoldingTimeout; 532ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxRetries; 533ee385855SLuis Carlos Cobo struct dentry *dot11MeshTTL; 534ee385855SLuis Carlos Cobo struct dentry *auto_open_plinks; 535ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxPeerLinks; 536ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPactivePathTimeout; 537ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPpreqMinInterval; 538ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPnetDiameterTraversalTime; 539ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPmaxPREQretries; 540ee385855SLuis Carlos Cobo struct dentry *path_refresh_time; 541ee385855SLuis Carlos Cobo struct dentry *min_discovery_timeout; 542ee385855SLuis Carlos Cobo } mesh_config; 543ee385855SLuis Carlos Cobo #endif 544ee385855SLuis Carlos Cobo 545e9f207f0SJiri Benc #endif 54632bfd35dSJohannes Berg /* must be last, dynamically sized area in this! */ 54732bfd35dSJohannes Berg struct ieee80211_vif vif; 548f0706e82SJiri Benc }; 549f0706e82SJiri Benc 55032bfd35dSJohannes Berg static inline 55132bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) 55232bfd35dSJohannes Berg { 55332bfd35dSJohannes Berg return container_of(p, struct ieee80211_sub_if_data, vif); 55432bfd35dSJohannes Berg } 55532bfd35dSJohannes Berg 556f0706e82SJiri Benc #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev) 557f0706e82SJiri Benc 558f0706e82SJiri Benc enum { 559f0706e82SJiri Benc IEEE80211_RX_MSG = 1, 560f0706e82SJiri Benc IEEE80211_TX_STATUS_MSG = 2, 561eadc8d9eSRon Rindjunsky IEEE80211_DELBA_MSG = 3, 562eadc8d9eSRon Rindjunsky IEEE80211_ADDBA_MSG = 4, 563f0706e82SJiri Benc }; 564f0706e82SJiri Benc 565f0706e82SJiri Benc struct ieee80211_local { 566f0706e82SJiri Benc /* embed the driver visible part. 567f0706e82SJiri Benc * don't cast (use the static inlines below), but we keep 568f0706e82SJiri Benc * it first anyway so they become a no-op */ 569f0706e82SJiri Benc struct ieee80211_hw hw; 570f0706e82SJiri Benc 571f0706e82SJiri Benc const struct ieee80211_ops *ops; 572f0706e82SJiri Benc 573f0706e82SJiri Benc struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 574f0706e82SJiri Benc int open_count; 5753d30d949SMichael Wu int monitors, cooked_mntrs; 5768cc9a739SMichael Wu /* number of interfaces with corresponding FIF_ flags */ 5778cc9a739SMichael Wu int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; 5784150c572SJohannes Berg unsigned int filter_flags; /* FIF_* */ 579f0706e82SJiri Benc struct iw_statistics wstats; 580f0706e82SJiri Benc u8 wstats_flags; 581d0709a65SJohannes Berg bool tim_in_locked_section; /* see ieee80211_beacon_get() */ 582b306f453SJohannes Berg int tx_headroom; /* required headroom for hardware/radiotap */ 583f0706e82SJiri Benc 584f0706e82SJiri Benc enum { 585f0706e82SJiri Benc IEEE80211_DEV_UNINITIALIZED = 0, 586f0706e82SJiri Benc IEEE80211_DEV_REGISTERED, 587f0706e82SJiri Benc IEEE80211_DEV_UNREGISTERED, 588f0706e82SJiri Benc } reg_state; 589f0706e82SJiri Benc 590f0706e82SJiri Benc /* Tasklet and skb queue to process calls from IRQ mode. All frames 591f0706e82SJiri Benc * added to skb_queue will be processed, but frames in 592f0706e82SJiri Benc * skb_queue_unreliable may be dropped if the total length of these 593f0706e82SJiri Benc * queues increases over the limit. */ 594f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128 595f0706e82SJiri Benc struct tasklet_struct tasklet; 596f0706e82SJiri Benc struct sk_buff_head skb_queue; 597f0706e82SJiri Benc struct sk_buff_head skb_queue_unreliable; 598f0706e82SJiri Benc 599d0709a65SJohannes Berg /* Station data */ 600d0709a65SJohannes Berg /* 601d0709a65SJohannes Berg * The lock only protects the list, hash, timer and counter 602d0709a65SJohannes Berg * against manipulation, reads are done in RCU. Additionally, 603d0709a65SJohannes Berg * the lock protects each BSS's TIM bitmap and a few items 604d0709a65SJohannes Berg * in a STA info structure. 605d0709a65SJohannes Berg */ 606d0709a65SJohannes Berg spinlock_t sta_lock; 607d0709a65SJohannes Berg unsigned long num_sta; 608f0706e82SJiri Benc struct list_head sta_list; 609dc6676b7SJohannes Berg struct list_head sta_flush_list; 610dc6676b7SJohannes Berg struct work_struct sta_flush_work; 611f0706e82SJiri Benc struct sta_info *sta_hash[STA_HASH_SIZE]; 612f0706e82SJiri Benc struct timer_list sta_cleanup; 613f0706e82SJiri Benc 6149e723492SRon Rindjunsky unsigned long state[NUM_TX_DATA_QUEUES_AMPDU]; 6159e723492SRon Rindjunsky struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU]; 616f0706e82SJiri Benc struct tasklet_struct tx_pending_tasklet; 617f0706e82SJiri Benc 618f0706e82SJiri Benc /* number of interfaces with corresponding IFF_ flags */ 61953918994SJohannes Berg atomic_t iff_allmultis, iff_promiscs; 620f0706e82SJiri Benc 621f0706e82SJiri Benc struct rate_control_ref *rate_ctrl; 622f0706e82SJiri Benc 623f0706e82SJiri Benc int rts_threshold; 624f0706e82SJiri Benc int fragmentation_threshold; 625f0706e82SJiri Benc int short_retry_limit; /* dot11ShortRetryLimit */ 626f0706e82SJiri Benc int long_retry_limit; /* dot11LongRetryLimit */ 627f0706e82SJiri Benc 628f0706e82SJiri Benc struct crypto_blkcipher *wep_tx_tfm; 629f0706e82SJiri Benc struct crypto_blkcipher *wep_rx_tfm; 630f0706e82SJiri Benc u32 wep_iv; 631f0706e82SJiri Benc 632f0706e82SJiri Benc int bridge_packets; /* bridge packets between associated stations and 633f0706e82SJiri Benc * deliver multicast frames both back to wireless 634f0706e82SJiri Benc * media and to the local net stack */ 635f0706e82SJiri Benc 63679010420SJohannes Berg struct list_head interfaces; 63779010420SJohannes Berg 638ece8edddSZhu Yi bool sta_sw_scanning; 639ece8edddSZhu Yi bool sta_hw_scanning; 640f0706e82SJiri Benc int scan_channel_idx; 6418318d78aSJohannes Berg enum ieee80211_band scan_band; 6428318d78aSJohannes Berg 643f0706e82SJiri Benc enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; 644f0706e82SJiri Benc unsigned long last_scan_completed; 645f0706e82SJiri Benc struct delayed_work scan_work; 646f0706e82SJiri Benc struct net_device *scan_dev; 647f0706e82SJiri Benc struct ieee80211_channel *oper_channel, *scan_channel; 648f0706e82SJiri Benc u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 649f0706e82SJiri Benc size_t scan_ssid_len; 650f0706e82SJiri Benc struct list_head sta_bss_list; 651f0706e82SJiri Benc struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE]; 652f0706e82SJiri Benc spinlock_t sta_bss_lock; 653f0706e82SJiri Benc 654f0706e82SJiri Benc /* SNMP counters */ 655f0706e82SJiri Benc /* dot11CountersTable */ 656f0706e82SJiri Benc u32 dot11TransmittedFragmentCount; 657f0706e82SJiri Benc u32 dot11MulticastTransmittedFrameCount; 658f0706e82SJiri Benc u32 dot11FailedCount; 659f0706e82SJiri Benc u32 dot11RetryCount; 660f0706e82SJiri Benc u32 dot11MultipleRetryCount; 661f0706e82SJiri Benc u32 dot11FrameDuplicateCount; 662f0706e82SJiri Benc u32 dot11ReceivedFragmentCount; 663f0706e82SJiri Benc u32 dot11MulticastReceivedFrameCount; 664f0706e82SJiri Benc u32 dot11TransmittedFrameCount; 665f0706e82SJiri Benc u32 dot11WEPUndecryptableCount; 666f0706e82SJiri Benc 667f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS 668f0706e82SJiri Benc int tx_led_counter, rx_led_counter; 669cdcb006fSIvo van Doorn struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; 670cdcb006fSIvo van Doorn char tx_led_name[32], rx_led_name[32], 671cdcb006fSIvo van Doorn assoc_led_name[32], radio_led_name[32]; 672f0706e82SJiri Benc #endif 673f0706e82SJiri Benc 674f0706e82SJiri Benc u32 channel_use; 675f0706e82SJiri Benc u32 channel_use_raw; 676f0706e82SJiri Benc 677e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 678e9f207f0SJiri Benc struct work_struct sta_debugfs_add; 679e9f207f0SJiri Benc #endif 680e9f207f0SJiri Benc 681f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 682f0706e82SJiri Benc /* TX/RX handler statistics */ 683f0706e82SJiri Benc unsigned int tx_handlers_drop; 684f0706e82SJiri Benc unsigned int tx_handlers_queued; 685f0706e82SJiri Benc unsigned int tx_handlers_drop_unencrypted; 686f0706e82SJiri Benc unsigned int tx_handlers_drop_fragment; 687f0706e82SJiri Benc unsigned int tx_handlers_drop_wep; 688f0706e82SJiri Benc unsigned int tx_handlers_drop_not_assoc; 689f0706e82SJiri Benc unsigned int tx_handlers_drop_unauth_port; 690f0706e82SJiri Benc unsigned int rx_handlers_drop; 691f0706e82SJiri Benc unsigned int rx_handlers_queued; 692f0706e82SJiri Benc unsigned int rx_handlers_drop_nullfunc; 693f0706e82SJiri Benc unsigned int rx_handlers_drop_defrag; 694f0706e82SJiri Benc unsigned int rx_handlers_drop_short; 695f0706e82SJiri Benc unsigned int rx_handlers_drop_passive_scan; 696f0706e82SJiri Benc unsigned int tx_expand_skb_head; 697f0706e82SJiri Benc unsigned int tx_expand_skb_head_cloned; 698f0706e82SJiri Benc unsigned int rx_expand_skb_head; 699f0706e82SJiri Benc unsigned int rx_expand_skb_head2; 700f0706e82SJiri Benc unsigned int rx_handlers_fragments; 701f0706e82SJiri Benc unsigned int tx_status_drop; 702f0706e82SJiri Benc unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES]; 703f0706e82SJiri Benc unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES]; 704f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++ 705f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */ 706f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0) 707f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ 708f0706e82SJiri Benc 709f0706e82SJiri Benc 710f0706e82SJiri Benc int total_ps_buffered; /* total number of all buffered unicast and 711f0706e82SJiri Benc * multicast packets for power saving stations 712f0706e82SJiri Benc */ 713f0706e82SJiri Benc int wifi_wme_noack_test; 714f0706e82SJiri Benc unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 715f0706e82SJiri Benc 716e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 717e9f207f0SJiri Benc struct local_debugfsdentries { 718e9f207f0SJiri Benc struct dentry *frequency; 719e9f207f0SJiri Benc struct dentry *antenna_sel_tx; 720e9f207f0SJiri Benc struct dentry *antenna_sel_rx; 721e9f207f0SJiri Benc struct dentry *bridge_packets; 722e9f207f0SJiri Benc struct dentry *rts_threshold; 723e9f207f0SJiri Benc struct dentry *fragmentation_threshold; 724e9f207f0SJiri Benc struct dentry *short_retry_limit; 725e9f207f0SJiri Benc struct dentry *long_retry_limit; 726e9f207f0SJiri Benc struct dentry *total_ps_buffered; 727e9f207f0SJiri Benc struct dentry *wep_iv; 728e9f207f0SJiri Benc struct dentry *statistics; 729e9f207f0SJiri Benc struct local_debugfsdentries_statsdentries { 730e9f207f0SJiri Benc struct dentry *transmitted_fragment_count; 731e9f207f0SJiri Benc struct dentry *multicast_transmitted_frame_count; 732e9f207f0SJiri Benc struct dentry *failed_count; 733e9f207f0SJiri Benc struct dentry *retry_count; 734e9f207f0SJiri Benc struct dentry *multiple_retry_count; 735e9f207f0SJiri Benc struct dentry *frame_duplicate_count; 736e9f207f0SJiri Benc struct dentry *received_fragment_count; 737e9f207f0SJiri Benc struct dentry *multicast_received_frame_count; 738e9f207f0SJiri Benc struct dentry *transmitted_frame_count; 739e9f207f0SJiri Benc struct dentry *wep_undecryptable_count; 740e9f207f0SJiri Benc struct dentry *num_scans; 741e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 742e9f207f0SJiri Benc struct dentry *tx_handlers_drop; 743e9f207f0SJiri Benc struct dentry *tx_handlers_queued; 744e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unencrypted; 745e9f207f0SJiri Benc struct dentry *tx_handlers_drop_fragment; 746e9f207f0SJiri Benc struct dentry *tx_handlers_drop_wep; 747e9f207f0SJiri Benc struct dentry *tx_handlers_drop_not_assoc; 748e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unauth_port; 749e9f207f0SJiri Benc struct dentry *rx_handlers_drop; 750e9f207f0SJiri Benc struct dentry *rx_handlers_queued; 751e9f207f0SJiri Benc struct dentry *rx_handlers_drop_nullfunc; 752e9f207f0SJiri Benc struct dentry *rx_handlers_drop_defrag; 753e9f207f0SJiri Benc struct dentry *rx_handlers_drop_short; 754e9f207f0SJiri Benc struct dentry *rx_handlers_drop_passive_scan; 755e9f207f0SJiri Benc struct dentry *tx_expand_skb_head; 756e9f207f0SJiri Benc struct dentry *tx_expand_skb_head_cloned; 757e9f207f0SJiri Benc struct dentry *rx_expand_skb_head; 758e9f207f0SJiri Benc struct dentry *rx_expand_skb_head2; 759e9f207f0SJiri Benc struct dentry *rx_handlers_fragments; 760e9f207f0SJiri Benc struct dentry *tx_status_drop; 761e9f207f0SJiri Benc struct dentry *wme_tx_queue; 762e9f207f0SJiri Benc struct dentry *wme_rx_queue; 763e9f207f0SJiri Benc #endif 764e9f207f0SJiri Benc struct dentry *dot11ACKFailureCount; 765e9f207f0SJiri Benc struct dentry *dot11RTSFailureCount; 766e9f207f0SJiri Benc struct dentry *dot11FCSErrorCount; 767e9f207f0SJiri Benc struct dentry *dot11RTSSuccessCount; 768e9f207f0SJiri Benc } stats; 769e9f207f0SJiri Benc struct dentry *stations; 770e9f207f0SJiri Benc struct dentry *keys; 771e9f207f0SJiri Benc } debugfs; 772e9f207f0SJiri Benc #endif 773f0706e82SJiri Benc }; 774f0706e82SJiri Benc 775eadc8d9eSRon Rindjunsky /* this struct represents 802.11n's RA/TID combination */ 776eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid { 777eadc8d9eSRon Rindjunsky u8 ra[ETH_ALEN]; 778eadc8d9eSRon Rindjunsky u16 tid; 779eadc8d9eSRon Rindjunsky }; 780eadc8d9eSRon Rindjunsky 781ee385855SLuis Carlos Cobo /* Parsed Information Elements */ 782ee385855SLuis Carlos Cobo struct ieee802_11_elems { 783ee385855SLuis Carlos Cobo /* pointers to IEs */ 784ee385855SLuis Carlos Cobo u8 *ssid; 785ee385855SLuis Carlos Cobo u8 *supp_rates; 786ee385855SLuis Carlos Cobo u8 *fh_params; 787ee385855SLuis Carlos Cobo u8 *ds_params; 788ee385855SLuis Carlos Cobo u8 *cf_params; 789ee385855SLuis Carlos Cobo u8 *tim; 790ee385855SLuis Carlos Cobo u8 *ibss_params; 791ee385855SLuis Carlos Cobo u8 *challenge; 792ee385855SLuis Carlos Cobo u8 *wpa; 793ee385855SLuis Carlos Cobo u8 *rsn; 794ee385855SLuis Carlos Cobo u8 *erp_info; 795ee385855SLuis Carlos Cobo u8 *ext_supp_rates; 796ee385855SLuis Carlos Cobo u8 *wmm_info; 797ee385855SLuis Carlos Cobo u8 *wmm_param; 798ee385855SLuis Carlos Cobo u8 *ht_cap_elem; 799ee385855SLuis Carlos Cobo u8 *ht_info_elem; 800ee385855SLuis Carlos Cobo u8 *mesh_config; 801ee385855SLuis Carlos Cobo u8 *mesh_id; 802ee385855SLuis Carlos Cobo u8 *peer_link; 803ee385855SLuis Carlos Cobo u8 *preq; 804ee385855SLuis Carlos Cobo u8 *prep; 805ee385855SLuis Carlos Cobo u8 *perr; 806ee385855SLuis Carlos Cobo 807ee385855SLuis Carlos Cobo /* length of them, respectively */ 808ee385855SLuis Carlos Cobo u8 ssid_len; 809ee385855SLuis Carlos Cobo u8 supp_rates_len; 810ee385855SLuis Carlos Cobo u8 fh_params_len; 811ee385855SLuis Carlos Cobo u8 ds_params_len; 812ee385855SLuis Carlos Cobo u8 cf_params_len; 813ee385855SLuis Carlos Cobo u8 tim_len; 814ee385855SLuis Carlos Cobo u8 ibss_params_len; 815ee385855SLuis Carlos Cobo u8 challenge_len; 816ee385855SLuis Carlos Cobo u8 wpa_len; 817ee385855SLuis Carlos Cobo u8 rsn_len; 818ee385855SLuis Carlos Cobo u8 erp_info_len; 819ee385855SLuis Carlos Cobo u8 ext_supp_rates_len; 820ee385855SLuis Carlos Cobo u8 wmm_info_len; 821ee385855SLuis Carlos Cobo u8 wmm_param_len; 822ee385855SLuis Carlos Cobo u8 ht_cap_elem_len; 823ee385855SLuis Carlos Cobo u8 ht_info_elem_len; 824ee385855SLuis Carlos Cobo u8 mesh_config_len; 825ee385855SLuis Carlos Cobo u8 mesh_id_len; 826ee385855SLuis Carlos Cobo u8 peer_link_len; 827ee385855SLuis Carlos Cobo u8 preq_len; 828ee385855SLuis Carlos Cobo u8 prep_len; 829ee385855SLuis Carlos Cobo u8 perr_len; 830ee385855SLuis Carlos Cobo }; 831ee385855SLuis Carlos Cobo 832f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local( 833f0706e82SJiri Benc struct ieee80211_hw *hw) 834f0706e82SJiri Benc { 835f0706e82SJiri Benc return container_of(hw, struct ieee80211_local, hw); 836f0706e82SJiri Benc } 837f0706e82SJiri Benc 838f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw( 839f0706e82SJiri Benc struct ieee80211_local *local) 840f0706e82SJiri Benc { 841f0706e82SJiri Benc return &local->hw; 842f0706e82SJiri Benc } 843f0706e82SJiri Benc 844f0706e82SJiri Benc enum ieee80211_link_state_t { 845f0706e82SJiri Benc IEEE80211_LINK_STATE_XOFF = 0, 846f0706e82SJiri Benc IEEE80211_LINK_STATE_PENDING, 847f0706e82SJiri Benc }; 848f0706e82SJiri Benc 849f0706e82SJiri Benc struct sta_attribute { 850f0706e82SJiri Benc struct attribute attr; 851f0706e82SJiri Benc ssize_t (*show)(const struct sta_info *, char *buf); 852f0706e82SJiri Benc ssize_t (*store)(struct sta_info *, const char *buf, size_t count); 853f0706e82SJiri Benc }; 854f0706e82SJiri Benc 855571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) 856571ecf67SJohannes Berg { 857571ecf67SJohannes Berg return compare_ether_addr(raddr, addr) == 0 || 858571ecf67SJohannes Berg is_broadcast_ether_addr(raddr); 859571ecf67SJohannes Berg } 860571ecf67SJohannes Berg 861571ecf67SJohannes Berg 862f0706e82SJiri Benc /* ieee80211.c */ 863f0706e82SJiri Benc int ieee80211_hw_config(struct ieee80211_local *local); 864f0706e82SJiri Benc int ieee80211_if_config(struct net_device *dev); 865f0706e82SJiri Benc int ieee80211_if_config_beacon(struct net_device *dev); 8665cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx); 867f0706e82SJiri Benc void ieee80211_if_setup(struct net_device *dev); 86838668c05STomas Winkler u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht, 869d3c990fbSRon Rindjunsky struct ieee80211_ht_info *req_ht_cap, 870d3c990fbSRon Rindjunsky struct ieee80211_ht_bss_info *req_bss_cap); 871f0706e82SJiri Benc 872f0706e82SJiri Benc /* ieee80211_ioctl.c */ 873f0706e82SJiri Benc extern const struct iw_handler_def ieee80211_iw_handler_def; 874f0706e82SJiri Benc 875f0706e82SJiri Benc 876f0706e82SJiri Benc /* Least common multiple of the used rates (in 100 kbps). This is used to 877f0706e82SJiri Benc * calculate rate_inv values for each rate so that only integers are needed. */ 878f0706e82SJiri Benc #define CHAN_UTIL_RATE_LCM 95040 879f0706e82SJiri Benc /* 1 usec is 1/8 * (95040/10) = 1188 */ 880f0706e82SJiri Benc #define CHAN_UTIL_PER_USEC 1188 881f0706e82SJiri Benc /* Amount of bits to shift the result right to scale the total utilization 882f0706e82SJiri Benc * to values that will not wrap around 32-bit integers. */ 883f0706e82SJiri Benc #define CHAN_UTIL_SHIFT 9 884f0706e82SJiri Benc /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1): 885f0706e82SJiri Benc * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the 886f0706e82SJiri Benc * raw value with about 23 should give utilization in 10th of a percentage 887f0706e82SJiri Benc * (1/1000). However, utilization is only estimated and not all intervals 888f0706e82SJiri Benc * between frames etc. are calculated. 18 seems to give numbers that are closer 889f0706e82SJiri Benc * to the real maximum. */ 890f0706e82SJiri Benc #define CHAN_UTIL_PER_10MS 18 891f0706e82SJiri Benc #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC) 892f0706e82SJiri Benc #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC) 893f0706e82SJiri Benc 894f0706e82SJiri Benc 895f0706e82SJiri Benc /* ieee80211_ioctl.c */ 8968318d78aSJohannes Berg int ieee80211_set_freq(struct ieee80211_local *local, int freq); 897f0706e82SJiri Benc /* ieee80211_sta.c */ 898f0706e82SJiri Benc void ieee80211_sta_timer(unsigned long data); 899f0706e82SJiri Benc void ieee80211_sta_work(struct work_struct *work); 900f0706e82SJiri Benc void ieee80211_sta_scan_work(struct work_struct *work); 901f0706e82SJiri Benc void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb, 902f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 903f0706e82SJiri Benc int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len); 904f0706e82SJiri Benc int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len); 905f0706e82SJiri Benc int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid); 906f0706e82SJiri Benc int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len); 907f0706e82SJiri Benc void ieee80211_sta_req_auth(struct net_device *dev, 908f0706e82SJiri Benc struct ieee80211_if_sta *ifsta); 909f0706e82SJiri Benc int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len); 9109ae54c84SJohannes Berg ieee80211_rx_result ieee80211_sta_rx_scan( 9119ae54c84SJohannes Berg struct net_device *dev, struct sk_buff *skb, 912f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 913f0706e82SJiri Benc void ieee80211_rx_bss_list_init(struct net_device *dev); 914f0706e82SJiri Benc void ieee80211_rx_bss_list_deinit(struct net_device *dev); 915f0706e82SJiri Benc int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len); 916f0706e82SJiri Benc struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, 917f0706e82SJiri Benc struct sk_buff *skb, u8 *bssid, 918f0706e82SJiri Benc u8 *addr); 919f0706e82SJiri Benc int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason); 920f0706e82SJiri Benc int ieee80211_sta_disassociate(struct net_device *dev, u16 reason); 921471b3efdSJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 922471b3efdSJohannes Berg u32 changed); 923d9430a32SDaniel Drake void ieee80211_reset_erp_info(struct net_device *dev); 924c7153508SRon Rindjunsky int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, 925c7153508SRon Rindjunsky struct ieee80211_ht_info *ht_info); 926c7153508SRon Rindjunsky int ieee80211_ht_addt_info_ie_to_ht_bss_info( 927c7153508SRon Rindjunsky struct ieee80211_ht_addt_info *ht_add_info_ie, 928c7153508SRon Rindjunsky struct ieee80211_ht_bss_info *bss_info); 929eadc8d9eSRon Rindjunsky void ieee80211_send_addba_request(struct net_device *dev, const u8 *da, 930eadc8d9eSRon Rindjunsky u16 tid, u8 dialog_token, u16 start_seq_num, 931eadc8d9eSRon Rindjunsky u16 agg_size, u16 timeout); 932eadc8d9eSRon Rindjunsky void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, 933eadc8d9eSRon Rindjunsky u16 initiator, u16 reason_code); 93485249e5fSRon Rindjunsky 93507db2183SRon Rindjunsky void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da, 93607db2183SRon Rindjunsky u16 tid, u16 initiator, u16 reason); 93707db2183SRon Rindjunsky void sta_rx_agg_session_timer_expired(unsigned long data); 938eadc8d9eSRon Rindjunsky void sta_addba_resp_timer_expired(unsigned long data); 93985249e5fSRon Rindjunsky void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr); 940ee385855SLuis Carlos Cobo u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 941ee385855SLuis Carlos Cobo struct ieee802_11_elems *elems, 942ee385855SLuis Carlos Cobo enum ieee80211_band band); 943ee385855SLuis Carlos Cobo void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, 944ee385855SLuis Carlos Cobo int encrypt); 945ee385855SLuis Carlos Cobo void ieee802_11_parse_elems(u8 *start, size_t len, 946ee385855SLuis Carlos Cobo struct ieee802_11_elems *elems); 947ee385855SLuis Carlos Cobo 948902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 949902acc78SJohannes Berg void ieee80211_start_mesh(struct net_device *dev); 950902acc78SJohannes Berg #else 951902acc78SJohannes Berg static inline void ieee80211_start_mesh(struct net_device *dev) 952902acc78SJohannes Berg {} 953902acc78SJohannes Berg #endif 954ee385855SLuis Carlos Cobo 955f0706e82SJiri Benc /* ieee80211_iface.c */ 956f0706e82SJiri Benc int ieee80211_if_add(struct net_device *dev, const char *name, 957ee385855SLuis Carlos Cobo struct net_device **new_dev, int type, 958ee385855SLuis Carlos Cobo struct vif_params *params); 959f0706e82SJiri Benc void ieee80211_if_set_type(struct net_device *dev, int type); 960f0706e82SJiri Benc void ieee80211_if_reinit(struct net_device *dev); 961f0706e82SJiri Benc void __ieee80211_if_del(struct ieee80211_local *local, 962f0706e82SJiri Benc struct ieee80211_sub_if_data *sdata); 963f0706e82SJiri Benc int ieee80211_if_remove(struct net_device *dev, const char *name, int id); 964f0706e82SJiri Benc void ieee80211_if_free(struct net_device *dev); 965f0706e82SJiri Benc void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); 966f0706e82SJiri Benc 967e2ebc74dSJohannes Berg /* tx handling */ 968e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local); 969e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data); 970e2ebc74dSJohannes Berg int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); 971e2ebc74dSJohannes Berg int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); 972e2ebc74dSJohannes Berg int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); 973e2ebc74dSJohannes Berg 974c2d1560aSJohannes Berg /* utility functions/constants */ 975c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */ 976c2d1560aSJohannes Berg extern const unsigned char rfc1042_header[6]; 977c2d1560aSJohannes Berg extern const unsigned char bridge_tunnel_header[6]; 97871364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 97971364716SRon Rindjunsky enum ieee80211_if_types type); 980c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, 981c2d1560aSJohannes Berg int rate, int erp, int short_preamble); 982eb063c17SJohannes Berg void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx, 983eb063c17SJohannes Berg struct ieee80211_hdr *hdr); 984f0706e82SJiri Benc 985f0706e82SJiri Benc #endif /* IEEE80211_I_H */ 986