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> 5e039fa4aSJohannes Berg * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net> 6f0706e82SJiri Benc * 7f0706e82SJiri Benc * This program is free software; you can redistribute it and/or modify 8f0706e82SJiri Benc * it under the terms of the GNU General Public License version 2 as 9f0706e82SJiri Benc * published by the Free Software Foundation. 10f0706e82SJiri Benc */ 11f0706e82SJiri Benc 12f0706e82SJiri Benc #ifndef IEEE80211_I_H 13f0706e82SJiri Benc #define IEEE80211_I_H 14f0706e82SJiri Benc 15f0706e82SJiri Benc #include <linux/kernel.h> 16f0706e82SJiri Benc #include <linux/device.h> 17f0706e82SJiri Benc #include <linux/if_ether.h> 18f0706e82SJiri Benc #include <linux/interrupt.h> 19f0706e82SJiri Benc #include <linux/list.h> 20f0706e82SJiri Benc #include <linux/netdevice.h> 21f0706e82SJiri Benc #include <linux/skbuff.h> 22f0706e82SJiri Benc #include <linux/workqueue.h> 23f0706e82SJiri Benc #include <linux/types.h> 24f0706e82SJiri Benc #include <linux/spinlock.h> 25571ecf67SJohannes Berg #include <linux/etherdevice.h> 26f0706e82SJiri Benc #include <net/wireless.h> 27ccc58057SDavid S. Miller #include <net/iw_handler.h> 2851cb6db0SDavid S. Miller #include <net/mac80211.h> 292c8dccc7SJohannes Berg #include "key.h" 30f0706e82SJiri Benc #include "sta_info.h" 31f0706e82SJiri Benc 329cfb0009SJohannes Berg struct ieee80211_local; 33f0706e82SJiri Benc 34f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the 35f0706e82SJiri Benc * associated stations are using power saving. */ 36f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128 37f0706e82SJiri Benc 38f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames. 39f0706e82SJiri Benc * Note: increasing this limit increases the potential memory requirement. Each 40f0706e82SJiri Benc * frame can be up to about 2 kB long. */ 41f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512 42f0706e82SJiri Benc 43f0706e82SJiri Benc /* Required encryption head and tailroom */ 44f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8 45f0706e82SJiri Benc #define IEEE80211_ENCRYPT_TAILROOM 12 46f0706e82SJiri Benc 47f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent 48f0706e82SJiri Benc * reception of at least three fragmented frames. This limit can be increased 49f0706e82SJiri Benc * by changing this define, at the cost of slower frame reassembly and 50f0706e82SJiri Benc * increased memory use (about 2 kB of RAM per entry). */ 51f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4 52f0706e82SJiri Benc 530a51b27eSJohannes Berg /* 540a51b27eSJohannes Berg * Time after which we ignore scan results and no longer report/use 550a51b27eSJohannes Berg * them in any way. 560a51b27eSJohannes Berg */ 570a51b27eSJohannes Berg #define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ) 580a51b27eSJohannes Berg 59f0706e82SJiri Benc struct ieee80211_fragment_entry { 60f0706e82SJiri Benc unsigned long first_frag_time; 61f0706e82SJiri Benc unsigned int seq; 62f0706e82SJiri Benc unsigned int rx_queue; 63f0706e82SJiri Benc unsigned int last_frag; 64f0706e82SJiri Benc unsigned int extra_len; 65f0706e82SJiri Benc struct sk_buff_head skb_list; 66f0706e82SJiri Benc int ccmp; /* Whether fragments were encrypted with CCMP */ 67f0706e82SJiri Benc u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ 68f0706e82SJiri Benc }; 69f0706e82SJiri Benc 70f0706e82SJiri Benc 71c2b13452SJohannes Berg struct ieee80211_bss { 72f0706e82SJiri Benc struct list_head list; 73c2b13452SJohannes Berg struct ieee80211_bss *hnext; 74056cdd59SJohannes Berg size_t ssid_len; 75056cdd59SJohannes Berg 76f0706e82SJiri Benc atomic_t users; 77f0706e82SJiri Benc 78f0706e82SJiri Benc u8 bssid[ETH_ALEN]; 79f0706e82SJiri Benc u8 ssid[IEEE80211_MAX_SSID_LEN]; 8098f7dfd8SEmmanuel Grumbach u8 dtim_period; 81f0706e82SJiri Benc u16 capability; /* host byte order */ 828318d78aSJohannes Berg enum ieee80211_band band; 83f0706e82SJiri Benc int freq; 84566bfe5aSBruno Randolf int signal, noise, qual; 8543ac2ca3SJouni Malinen u8 *ies; /* all information elements from the last Beacon or Probe 8643ac2ca3SJouni Malinen * Response frames; note Beacon frame is not allowed to 8743ac2ca3SJouni Malinen * override values from Probe Response */ 8843ac2ca3SJouni Malinen size_t ies_len; 8943ac2ca3SJouni Malinen bool wmm_used; 90ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 91ee385855SLuis Carlos Cobo u8 *mesh_id; 92ee385855SLuis Carlos Cobo size_t mesh_id_len; 9324736701SJohn W. Linville u8 *mesh_cfg; 94902acc78SJohannes Berg #endif 95f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32 96f0706e82SJiri Benc u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 97f0706e82SJiri Benc size_t supp_rates_len; 98f0706e82SJiri Benc u64 timestamp; 99056cdd59SJohannes Berg int beacon_int; 100f0706e82SJiri Benc 1019859b81eSRon Rindjunsky unsigned long last_probe_resp; 102f0706e82SJiri Benc unsigned long last_update; 103f0706e82SJiri Benc 1045628221cSDaniel Drake /* during assocation, we save an ERP value from a probe response so 1055628221cSDaniel Drake * that we can feed ERP info to the driver when handling the 1065628221cSDaniel Drake * association completes. these fields probably won't be up-to-date 1075628221cSDaniel Drake * otherwise, you probably don't want to use them. */ 1085628221cSDaniel Drake int has_erp_value; 1095628221cSDaniel Drake u8 erp_value; 110f0706e82SJiri Benc }; 111f0706e82SJiri Benc 112c2b13452SJohannes Berg static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss) 113902acc78SJohannes Berg { 114902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 115902acc78SJohannes Berg return bss->mesh_cfg; 116902acc78SJohannes Berg #endif 117902acc78SJohannes Berg return NULL; 118902acc78SJohannes Berg } 119902acc78SJohannes Berg 120c2b13452SJohannes Berg static inline u8 *bss_mesh_id(struct ieee80211_bss *bss) 121902acc78SJohannes Berg { 122902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 123902acc78SJohannes Berg return bss->mesh_id; 124902acc78SJohannes Berg #endif 125902acc78SJohannes Berg return NULL; 126902acc78SJohannes Berg } 127902acc78SJohannes Berg 128c2b13452SJohannes Berg static inline u8 bss_mesh_id_len(struct ieee80211_bss *bss) 129902acc78SJohannes Berg { 130902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 131902acc78SJohannes Berg return bss->mesh_id_len; 132902acc78SJohannes Berg #endif 133902acc78SJohannes Berg return 0; 134902acc78SJohannes Berg } 135902acc78SJohannes Berg 136f0706e82SJiri Benc 1379ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result; 1389ae54c84SJohannes Berg #define TX_CONTINUE ((__force ieee80211_tx_result) 0u) 1399ae54c84SJohannes Berg #define TX_DROP ((__force ieee80211_tx_result) 1u) 1409ae54c84SJohannes Berg #define TX_QUEUED ((__force ieee80211_tx_result) 2u) 1419ae54c84SJohannes Berg 1425cf121c3SJohannes Berg #define IEEE80211_TX_FRAGMENTED BIT(0) 1435cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST BIT(1) 1445cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED BIT(2) 1455cf121c3SJohannes Berg #define IEEE80211_TX_PROBE_LAST_FRAG BIT(3) 1469ae54c84SJohannes Berg 1475cf121c3SJohannes Berg struct ieee80211_tx_data { 148f0706e82SJiri Benc struct sk_buff *skb; 149f0706e82SJiri Benc struct net_device *dev; 150f0706e82SJiri Benc struct ieee80211_local *local; 151f0706e82SJiri Benc struct ieee80211_sub_if_data *sdata; 152f0706e82SJiri Benc struct sta_info *sta; 153f0706e82SJiri Benc struct ieee80211_key *key; 1545cf121c3SJohannes Berg 1558318d78aSJohannes Berg struct ieee80211_channel *channel; 1562e92e6f2SJohannes Berg s8 rate_idx; 157f0706e82SJiri Benc /* use this rate (if set) for last fragment; rate can 158f0706e82SJiri Benc * be set to lower rate for the first fragments, e.g., 159f0706e82SJiri Benc * when using CTS protection with IEEE 802.11g. */ 1602e92e6f2SJohannes Berg s8 last_frag_rate_idx; 161f0706e82SJiri Benc 162f0706e82SJiri Benc /* Extra fragments (in addition to the first fragment 163f0706e82SJiri Benc * in skb) */ 164f0706e82SJiri Benc struct sk_buff **extra_frag; 165056cdd59SJohannes Berg int num_extra_frag; 166056cdd59SJohannes Berg 167a4b7d7bdSHarvey Harrison u16 ethertype; 168056cdd59SJohannes Berg unsigned int flags; 1695cf121c3SJohannes Berg }; 1705cf121c3SJohannes Berg 1715cf121c3SJohannes Berg 1725cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result; 1735cf121c3SJohannes Berg #define RX_CONTINUE ((__force ieee80211_rx_result) 0u) 1745cf121c3SJohannes Berg #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u) 1755cf121c3SJohannes Berg #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u) 1765cf121c3SJohannes Berg #define RX_QUEUED ((__force ieee80211_rx_result) 3u) 1775cf121c3SJohannes Berg 1785cf121c3SJohannes Berg #define IEEE80211_RX_IN_SCAN BIT(0) 1795cf121c3SJohannes Berg /* frame is destined to interface currently processed (incl. multicast frames) */ 1805cf121c3SJohannes Berg #define IEEE80211_RX_RA_MATCH BIT(1) 1815cf121c3SJohannes Berg #define IEEE80211_RX_AMSDU BIT(2) 1825cf121c3SJohannes Berg #define IEEE80211_RX_CMNTR_REPORTED BIT(3) 1835cf121c3SJohannes Berg #define IEEE80211_RX_FRAGMENTED BIT(4) 1845cf121c3SJohannes Berg 1855cf121c3SJohannes Berg struct ieee80211_rx_data { 1865cf121c3SJohannes Berg struct sk_buff *skb; 1875cf121c3SJohannes Berg struct net_device *dev; 1885cf121c3SJohannes Berg struct ieee80211_local *local; 1895cf121c3SJohannes Berg struct ieee80211_sub_if_data *sdata; 1905cf121c3SJohannes Berg struct sta_info *sta; 1915cf121c3SJohannes Berg struct ieee80211_key *key; 192f0706e82SJiri Benc struct ieee80211_rx_status *status; 1938318d78aSJohannes Berg struct ieee80211_rate *rate; 194056cdd59SJohannes Berg 195a4b7d7bdSHarvey Harrison u16 ethertype; 196056cdd59SJohannes Berg unsigned int flags; 197f0706e82SJiri Benc int sent_ps_buffered; 198f0706e82SJiri Benc int queue; 19950741ae0SJohannes Berg u32 tkip_iv32; 20050741ae0SJohannes Berg u16 tkip_iv16; 201f0706e82SJiri Benc }; 202f0706e82SJiri Benc 203f0706e82SJiri Benc struct ieee80211_tx_stored_packet { 204f0706e82SJiri Benc struct sk_buff *skb; 205f0706e82SJiri Benc struct sk_buff **extra_frag; 2062e92e6f2SJohannes Berg s8 last_frag_rate_idx; 207056cdd59SJohannes Berg int num_extra_frag; 2082e92e6f2SJohannes Berg bool last_frag_rate_ctrl_probe; 209f0706e82SJiri Benc }; 210f0706e82SJiri Benc 2115dfdaf58SJohannes Berg struct beacon_data { 2125dfdaf58SJohannes Berg u8 *head, *tail; 2135dfdaf58SJohannes Berg int head_len, tail_len; 2145dfdaf58SJohannes Berg int dtim_period; 2155dfdaf58SJohannes Berg }; 2165dfdaf58SJohannes Berg 217f0706e82SJiri Benc struct ieee80211_if_ap { 2185dfdaf58SJohannes Berg struct beacon_data *beacon; 219f0706e82SJiri Benc 2200ec3ca44SJohannes Berg struct list_head vlans; 2210ec3ca44SJohannes Berg 222f0706e82SJiri Benc u8 ssid[IEEE80211_MAX_SSID_LEN]; 223f0706e82SJiri Benc size_t ssid_len; 224f0706e82SJiri Benc 225f0706e82SJiri Benc /* yes, this looks ugly, but guarantees that we can later use 226f0706e82SJiri Benc * bitmap_empty :) 227004c872eSJohannes Berg * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ 228f0706e82SJiri Benc u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; 229f0706e82SJiri Benc struct sk_buff_head ps_bc_buf; 230056cdd59SJohannes Berg atomic_t num_sta_ps; /* number of stations in PS mode */ 2315dfdaf58SJohannes Berg int dtim_count; 232f0706e82SJiri Benc }; 233f0706e82SJiri Benc 234f0706e82SJiri Benc struct ieee80211_if_wds { 235f0706e82SJiri Benc struct sta_info *sta; 236056cdd59SJohannes Berg u8 remote_addr[ETH_ALEN]; 237f0706e82SJiri Benc }; 238f0706e82SJiri Benc 239f0706e82SJiri Benc struct ieee80211_if_vlan { 2400ec3ca44SJohannes Berg struct list_head list; 241f0706e82SJiri Benc }; 242f0706e82SJiri Benc 243ee385855SLuis Carlos Cobo struct mesh_stats { 244ee385855SLuis Carlos Cobo __u32 fwded_frames; /* Mesh forwarded frames */ 245ee385855SLuis Carlos Cobo __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ 246ee385855SLuis Carlos Cobo __u32 dropped_frames_no_route; /* Not transmitted, no route found */ 247ee385855SLuis Carlos Cobo atomic_t estab_plinks; 248ee385855SLuis Carlos Cobo }; 249ee385855SLuis Carlos Cobo 250ee385855SLuis Carlos Cobo #define PREQ_Q_F_START 0x1 251ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH 0x2 252ee385855SLuis Carlos Cobo struct mesh_preq_queue { 253ee385855SLuis Carlos Cobo struct list_head list; 254ee385855SLuis Carlos Cobo u8 dst[ETH_ALEN]; 255ee385855SLuis Carlos Cobo u8 flags; 256ee385855SLuis Carlos Cobo }; 257ee385855SLuis Carlos Cobo 258ee385855SLuis Carlos Cobo struct mesh_config { 259ee385855SLuis Carlos Cobo /* Timeouts in ms */ 260ee385855SLuis Carlos Cobo /* Mesh plink management parameters */ 261ee385855SLuis Carlos Cobo u16 dot11MeshRetryTimeout; 262ee385855SLuis Carlos Cobo u16 dot11MeshConfirmTimeout; 263ee385855SLuis Carlos Cobo u16 dot11MeshHoldingTimeout; 264ee385855SLuis Carlos Cobo u16 dot11MeshMaxPeerLinks; 265ee385855SLuis Carlos Cobo u8 dot11MeshMaxRetries; 266ee385855SLuis Carlos Cobo u8 dot11MeshTTL; 267ee385855SLuis Carlos Cobo bool auto_open_plinks; 268ee385855SLuis Carlos Cobo /* HWMP parameters */ 269ee385855SLuis Carlos Cobo u8 dot11MeshHWMPmaxPREQretries; 270ee385855SLuis Carlos Cobo u32 path_refresh_time; 271ee385855SLuis Carlos Cobo u16 min_discovery_timeout; 272056cdd59SJohannes Berg u32 dot11MeshHWMPactivePathTimeout; 273056cdd59SJohannes Berg u16 dot11MeshHWMPpreqMinInterval; 274056cdd59SJohannes Berg u16 dot11MeshHWMPnetDiameterTraversalTime; 275ee385855SLuis Carlos Cobo }; 276902acc78SJohannes Berg 277ee385855SLuis Carlos Cobo 278d6f2da5bSJiri Slaby /* flags used in struct ieee80211_if_sta.flags */ 279d6f2da5bSJiri Slaby #define IEEE80211_STA_SSID_SET BIT(0) 280d6f2da5bSJiri Slaby #define IEEE80211_STA_BSSID_SET BIT(1) 281d6f2da5bSJiri Slaby #define IEEE80211_STA_PREV_BSSID_SET BIT(2) 282d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTHENTICATED BIT(3) 283d6f2da5bSJiri Slaby #define IEEE80211_STA_ASSOCIATED BIT(4) 284d6f2da5bSJiri Slaby #define IEEE80211_STA_PROBEREQ_POLL BIT(5) 285d6f2da5bSJiri Slaby #define IEEE80211_STA_CREATE_IBSS BIT(6) 286d6f2da5bSJiri Slaby #define IEEE80211_STA_MIXED_CELL BIT(7) 287d6f2da5bSJiri Slaby #define IEEE80211_STA_WMM_ENABLED BIT(8) 288d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_SSID_SEL BIT(10) 289d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11) 290d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12) 2915b98b1f7SJohannes Berg #define IEEE80211_STA_PRIVACY_INVOKED BIT(13) 29248c2fc59STomas Winkler /* flags for MLME request */ 29348c2fc59STomas Winkler #define IEEE80211_STA_REQ_SCAN 0 2949859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_DIRECT_PROBE 1 2959859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_AUTH 2 2969859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_RUN 3 29748c2fc59STomas Winkler 298ccd7b362SJohannes Berg /* STA/IBSS MLME states */ 29948c2fc59STomas Winkler enum ieee80211_sta_mlme_state { 30048c2fc59STomas Winkler IEEE80211_STA_MLME_DISABLED, 3019859b81eSRon Rindjunsky IEEE80211_STA_MLME_DIRECT_PROBE, 30248c2fc59STomas Winkler IEEE80211_STA_MLME_AUTHENTICATE, 30348c2fc59STomas Winkler IEEE80211_STA_MLME_ASSOCIATE, 30448c2fc59STomas Winkler IEEE80211_STA_MLME_ASSOCIATED, 30548c2fc59STomas Winkler IEEE80211_STA_MLME_IBSS_SEARCH, 30648c2fc59STomas Winkler IEEE80211_STA_MLME_IBSS_JOINED, 30748c2fc59STomas Winkler }; 30848c2fc59STomas Winkler 30948c2fc59STomas Winkler /* bitfield of allowed auth algs */ 31048c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_OPEN BIT(0) 31148c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) 31248c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_LEAP BIT(2) 31348c2fc59STomas Winkler 314f0706e82SJiri Benc struct ieee80211_if_sta { 315056cdd59SJohannes Berg struct timer_list timer; 316056cdd59SJohannes Berg struct work_struct work; 317056cdd59SJohannes Berg u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 318056cdd59SJohannes Berg u8 ssid[IEEE80211_MAX_SSID_LEN]; 31948c2fc59STomas Winkler enum ieee80211_sta_mlme_state state; 320f0706e82SJiri Benc size_t ssid_len; 321a0af5f14SHelmut Schaa u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 322a0af5f14SHelmut Schaa size_t scan_ssid_len; 323f0706e82SJiri Benc u16 aid; 324f0706e82SJiri Benc u16 ap_capab, capab; 325f0706e82SJiri Benc u8 *extra_ie; /* to be added to the end of AssocReq */ 326f0706e82SJiri Benc size_t extra_ie_len; 327f0706e82SJiri Benc 328f0706e82SJiri Benc /* The last AssocReq/Resp IEs */ 329f0706e82SJiri Benc u8 *assocreq_ies, *assocresp_ies; 330f0706e82SJiri Benc size_t assocreq_ies_len, assocresp_ies_len; 331f0706e82SJiri Benc 332056cdd59SJohannes Berg struct sk_buff_head skb_queue; 333056cdd59SJohannes Berg 3346042a3e3SRon Rindjunsky int assoc_scan_tries; /* number of scans done pre-association */ 3359859b81eSRon Rindjunsky int direct_probe_tries; /* retries for direct probes */ 3366042a3e3SRon Rindjunsky int auth_tries; /* retries for auth req */ 3376042a3e3SRon Rindjunsky int assoc_tries; /* retries for assoc req */ 338f0706e82SJiri Benc 339056cdd59SJohannes Berg unsigned long request; 340056cdd59SJohannes Berg 341056cdd59SJohannes Berg unsigned long last_probe; 342056cdd59SJohannes Berg 343d6f2da5bSJiri Slaby unsigned int flags; 344f0706e82SJiri Benc 345f0706e82SJiri Benc unsigned int auth_algs; /* bitfield of allowed auth algs */ 346f0706e82SJiri Benc int auth_alg; /* currently used IEEE 802.11 authentication algorithm */ 347f0706e82SJiri Benc int auth_transaction; 348f0706e82SJiri Benc 349f0706e82SJiri Benc unsigned long ibss_join_req; 350f0706e82SJiri Benc struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 3518318d78aSJohannes Berg u32 supp_rates_bits[IEEE80211_NUM_BANDS]; 352f0706e82SJiri Benc 353f0706e82SJiri Benc int wmm_last_param_set; 354f0706e82SJiri Benc }; 355f0706e82SJiri Benc 356472dbc45SJohannes Berg struct ieee80211_if_mesh { 357472dbc45SJohannes Berg struct work_struct work; 358472dbc45SJohannes Berg struct timer_list housekeeping_timer; 359472dbc45SJohannes Berg struct timer_list mesh_path_timer; 360472dbc45SJohannes Berg struct sk_buff_head skb_queue; 361472dbc45SJohannes Berg 362472dbc45SJohannes Berg bool housekeeping; 363472dbc45SJohannes Berg 364472dbc45SJohannes Berg u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; 365472dbc45SJohannes Berg size_t mesh_id_len; 366472dbc45SJohannes Berg /* Active Path Selection Protocol Identifier */ 367472dbc45SJohannes Berg u8 mesh_pp_id[4]; 368472dbc45SJohannes Berg /* Active Path Selection Metric Identifier */ 369472dbc45SJohannes Berg u8 mesh_pm_id[4]; 370472dbc45SJohannes Berg /* Congestion Control Mode Identifier */ 371472dbc45SJohannes Berg u8 mesh_cc_id[4]; 372472dbc45SJohannes Berg /* Local mesh Destination Sequence Number */ 373472dbc45SJohannes Berg u32 dsn; 374472dbc45SJohannes Berg /* Last used PREQ ID */ 375472dbc45SJohannes Berg u32 preq_id; 376472dbc45SJohannes Berg atomic_t mpaths; 377472dbc45SJohannes Berg /* Timestamp of last DSN update */ 378472dbc45SJohannes Berg unsigned long last_dsn_update; 379472dbc45SJohannes Berg /* Timestamp of last DSN sent */ 380472dbc45SJohannes Berg unsigned long last_preq; 381472dbc45SJohannes Berg struct mesh_rmc *rmc; 382472dbc45SJohannes Berg spinlock_t mesh_preq_queue_lock; 383472dbc45SJohannes Berg struct mesh_preq_queue preq_queue; 384472dbc45SJohannes Berg int preq_queue_len; 385472dbc45SJohannes Berg struct mesh_stats mshstats; 386472dbc45SJohannes Berg struct mesh_config mshcfg; 387472dbc45SJohannes Berg u32 mesh_seqnum; 388472dbc45SJohannes Berg bool accepting_plinks; 389472dbc45SJohannes Berg }; 390902acc78SJohannes Berg 391902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 392472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 393472dbc45SJohannes Berg do { (msh)->mshstats.name++; } while (0) 394902acc78SJohannes Berg #else 395472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 396902acc78SJohannes Berg do { } while (0) 397902acc78SJohannes Berg #endif 398f0706e82SJiri Benc 399213cd118SJohannes Berg /** 400213cd118SJohannes Berg * enum ieee80211_sub_if_data_flags - virtual interface flags 401213cd118SJohannes Berg * 402213cd118SJohannes Berg * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets 403213cd118SJohannes Berg * @IEEE80211_SDATA_PROMISC: interface is promisc 404213cd118SJohannes Berg * @IEEE80211_SDATA_USERSPACE_MLME: userspace MLME is active 405213cd118SJohannes Berg * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode 406213cd118SJohannes Berg * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between 407213cd118SJohannes Berg * associated stations and deliver multicast frames both 408213cd118SJohannes Berg * back to wireless media and to the local net stack. 409213cd118SJohannes Berg */ 410213cd118SJohannes Berg enum ieee80211_sub_if_data_flags { 411213cd118SJohannes Berg IEEE80211_SDATA_ALLMULTI = BIT(0), 412213cd118SJohannes Berg IEEE80211_SDATA_PROMISC = BIT(1), 413213cd118SJohannes Berg IEEE80211_SDATA_USERSPACE_MLME = BIT(2), 414213cd118SJohannes Berg IEEE80211_SDATA_OPERATING_GMODE = BIT(3), 415213cd118SJohannes Berg IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(4), 416213cd118SJohannes Berg }; 417213cd118SJohannes Berg 418f0706e82SJiri Benc struct ieee80211_sub_if_data { 419f0706e82SJiri Benc struct list_head list; 420f0706e82SJiri Benc 421f0706e82SJiri Benc struct wireless_dev wdev; 422f0706e82SJiri Benc 42311a843b7SJohannes Berg /* keys */ 42411a843b7SJohannes Berg struct list_head key_list; 42511a843b7SJohannes Berg 426f0706e82SJiri Benc struct net_device *dev; 427f0706e82SJiri Benc struct ieee80211_local *local; 428f0706e82SJiri Benc 42913262ffdSJiri Slaby unsigned int flags; 4307e9ed188SDaniel Drake 431f0706e82SJiri Benc int drop_unencrypted; 432f0706e82SJiri Benc 433f0706e82SJiri Benc /* Fragment table for host-based reassembly */ 434f0706e82SJiri Benc struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX]; 435f0706e82SJiri Benc unsigned int fragment_next; 436f0706e82SJiri Benc 437f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4 438f0706e82SJiri Benc struct ieee80211_key *keys[NUM_DEFAULT_KEYS]; 439f0706e82SJiri Benc struct ieee80211_key *default_key; 440f0706e82SJiri Benc 44194778280SJohannes Berg u16 sequence_number; 44294778280SJohannes Berg 4433e122be0SJohannes Berg /* BSS configuration for this interface. */ 444471b3efdSJohannes Berg struct ieee80211_bss_conf bss_conf; 4453e122be0SJohannes Berg 4463e122be0SJohannes Berg /* 4473e122be0SJohannes Berg * AP this belongs to: self in AP mode and 4483e122be0SJohannes Berg * corresponding AP in VLAN mode, NULL for 4493e122be0SJohannes Berg * all others (might be needed later in IBSS) 4503e122be0SJohannes Berg */ 4513e122be0SJohannes Berg struct ieee80211_if_ap *bss; 4523e122be0SJohannes Berg 4533e122be0SJohannes Berg int force_unicast_rateidx; /* forced TX rateidx for unicast frames */ 4543e122be0SJohannes Berg int max_ratectrl_rateidx; /* max TX rateidx for rate control */ 455f0706e82SJiri Benc 456f0706e82SJiri Benc union { 457f0706e82SJiri Benc struct ieee80211_if_ap ap; 458f0706e82SJiri Benc struct ieee80211_if_wds wds; 459f0706e82SJiri Benc struct ieee80211_if_vlan vlan; 460f0706e82SJiri Benc struct ieee80211_if_sta sta; 461472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH 462472dbc45SJohannes Berg struct ieee80211_if_mesh mesh; 463472dbc45SJohannes Berg #endif 4648cc9a739SMichael Wu u32 mntr_flags; 465f0706e82SJiri Benc } u; 466e9f207f0SJiri Benc 467e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 468e9f207f0SJiri Benc struct dentry *debugfsdir; 469e9f207f0SJiri Benc union { 470e9f207f0SJiri Benc struct { 471e9f207f0SJiri Benc struct dentry *drop_unencrypted; 472e9f207f0SJiri Benc struct dentry *state; 473e9f207f0SJiri Benc struct dentry *bssid; 474e9f207f0SJiri Benc struct dentry *prev_bssid; 475e9f207f0SJiri Benc struct dentry *ssid_len; 476e9f207f0SJiri Benc struct dentry *aid; 477e9f207f0SJiri Benc struct dentry *ap_capab; 478e9f207f0SJiri Benc struct dentry *capab; 479e9f207f0SJiri Benc struct dentry *extra_ie_len; 480e9f207f0SJiri Benc struct dentry *auth_tries; 481e9f207f0SJiri Benc struct dentry *assoc_tries; 482e9f207f0SJiri Benc struct dentry *auth_algs; 483e9f207f0SJiri Benc struct dentry *auth_alg; 484e9f207f0SJiri Benc struct dentry *auth_transaction; 485e9f207f0SJiri Benc struct dentry *flags; 48693015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 48793015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 488e9f207f0SJiri Benc } sta; 489e9f207f0SJiri Benc struct { 490e9f207f0SJiri Benc struct dentry *drop_unencrypted; 491e9f207f0SJiri Benc struct dentry *num_sta_ps; 492e9f207f0SJiri Benc struct dentry *dtim_count; 493e9f207f0SJiri Benc struct dentry *force_unicast_rateidx; 494e9f207f0SJiri Benc struct dentry *max_ratectrl_rateidx; 495e9f207f0SJiri Benc struct dentry *num_buffered_multicast; 496e9f207f0SJiri Benc } ap; 497e9f207f0SJiri Benc struct { 498e9f207f0SJiri Benc struct dentry *drop_unencrypted; 499e9f207f0SJiri Benc struct dentry *peer; 50093015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 50193015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 502e9f207f0SJiri Benc } wds; 503e9f207f0SJiri Benc struct { 504e9f207f0SJiri Benc struct dentry *drop_unencrypted; 50593015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 50693015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 507e9f207f0SJiri Benc } vlan; 508e9f207f0SJiri Benc struct { 509e9f207f0SJiri Benc struct dentry *mode; 510e9f207f0SJiri Benc } monitor; 511e9f207f0SJiri Benc } debugfs; 5122b58b209SJouni Malinen struct { 5132b58b209SJouni Malinen struct dentry *default_key; 5142b58b209SJouni Malinen } common_debugfs; 515ee385855SLuis Carlos Cobo 516ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 517ee385855SLuis Carlos Cobo struct dentry *mesh_stats_dir; 518ee385855SLuis Carlos Cobo struct { 519ee385855SLuis Carlos Cobo struct dentry *fwded_frames; 520ee385855SLuis Carlos Cobo struct dentry *dropped_frames_ttl; 521ee385855SLuis Carlos Cobo struct dentry *dropped_frames_no_route; 522ee385855SLuis Carlos Cobo struct dentry *estab_plinks; 523ee385855SLuis Carlos Cobo struct timer_list mesh_path_timer; 524ee385855SLuis Carlos Cobo } mesh_stats; 525ee385855SLuis Carlos Cobo 526ee385855SLuis Carlos Cobo struct dentry *mesh_config_dir; 527ee385855SLuis Carlos Cobo struct { 528ee385855SLuis Carlos Cobo struct dentry *dot11MeshRetryTimeout; 529ee385855SLuis Carlos Cobo struct dentry *dot11MeshConfirmTimeout; 530ee385855SLuis Carlos Cobo struct dentry *dot11MeshHoldingTimeout; 531ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxRetries; 532ee385855SLuis Carlos Cobo struct dentry *dot11MeshTTL; 533ee385855SLuis Carlos Cobo struct dentry *auto_open_plinks; 534ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxPeerLinks; 535ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPactivePathTimeout; 536ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPpreqMinInterval; 537ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPnetDiameterTraversalTime; 538ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPmaxPREQretries; 539ee385855SLuis Carlos Cobo struct dentry *path_refresh_time; 540ee385855SLuis Carlos Cobo struct dentry *min_discovery_timeout; 541ee385855SLuis Carlos Cobo } mesh_config; 542ee385855SLuis Carlos Cobo #endif 543ee385855SLuis Carlos Cobo 544e9f207f0SJiri Benc #endif 54532bfd35dSJohannes Berg /* must be last, dynamically sized area in this! */ 54632bfd35dSJohannes Berg struct ieee80211_vif vif; 547f0706e82SJiri Benc }; 548f0706e82SJiri Benc 54932bfd35dSJohannes Berg static inline 55032bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) 55132bfd35dSJohannes Berg { 55232bfd35dSJohannes Berg return container_of(p, struct ieee80211_sub_if_data, vif); 55332bfd35dSJohannes Berg } 55432bfd35dSJohannes Berg 555472dbc45SJohannes Berg static inline void 556472dbc45SJohannes Berg ieee80211_sdata_set_mesh_id(struct ieee80211_sub_if_data *sdata, 557472dbc45SJohannes Berg u8 mesh_id_len, u8 *mesh_id) 558472dbc45SJohannes Berg { 559472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH 560472dbc45SJohannes Berg struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 561472dbc45SJohannes Berg ifmsh->mesh_id_len = mesh_id_len; 562472dbc45SJohannes Berg memcpy(ifmsh->mesh_id, mesh_id, mesh_id_len); 563472dbc45SJohannes Berg #else 564472dbc45SJohannes Berg WARN_ON(1); 565472dbc45SJohannes Berg #endif 566472dbc45SJohannes Berg } 567472dbc45SJohannes Berg 568f0706e82SJiri Benc enum { 569f0706e82SJiri Benc IEEE80211_RX_MSG = 1, 570f0706e82SJiri Benc IEEE80211_TX_STATUS_MSG = 2, 571eadc8d9eSRon Rindjunsky IEEE80211_DELBA_MSG = 3, 572eadc8d9eSRon Rindjunsky IEEE80211_ADDBA_MSG = 4, 573f0706e82SJiri Benc }; 574f0706e82SJiri Benc 57551cb6db0SDavid S. Miller /* maximum number of hardware queues we support. */ 57651cb6db0SDavid S. Miller #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES) 57751cb6db0SDavid S. Miller 578133b8226SJohannes Berg struct ieee80211_master_priv { 579133b8226SJohannes Berg struct ieee80211_local *local; 580133b8226SJohannes Berg }; 581133b8226SJohannes Berg 582f0706e82SJiri Benc struct ieee80211_local { 583f0706e82SJiri Benc /* embed the driver visible part. 584f0706e82SJiri Benc * don't cast (use the static inlines below), but we keep 585f0706e82SJiri Benc * it first anyway so they become a no-op */ 586f0706e82SJiri Benc struct ieee80211_hw hw; 587f0706e82SJiri Benc 588f0706e82SJiri Benc const struct ieee80211_ops *ops; 589f0706e82SJiri Benc 59051cb6db0SDavid S. Miller unsigned long queue_pool[BITS_TO_LONGS(QD_MAX_QUEUES)]; 59151cb6db0SDavid S. Miller 592f0706e82SJiri Benc struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 593f0706e82SJiri Benc int open_count; 5943d30d949SMichael Wu int monitors, cooked_mntrs; 5958cc9a739SMichael Wu /* number of interfaces with corresponding FIF_ flags */ 5968cc9a739SMichael Wu int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; 5974150c572SJohannes Berg unsigned int filter_flags; /* FIF_* */ 598f0706e82SJiri Benc struct iw_statistics wstats; 599f0706e82SJiri Benc u8 wstats_flags; 600d0709a65SJohannes Berg bool tim_in_locked_section; /* see ieee80211_beacon_get() */ 601b306f453SJohannes Berg int tx_headroom; /* required headroom for hardware/radiotap */ 602f0706e82SJiri Benc 603f0706e82SJiri Benc /* Tasklet and skb queue to process calls from IRQ mode. All frames 604f0706e82SJiri Benc * added to skb_queue will be processed, but frames in 605f0706e82SJiri Benc * skb_queue_unreliable may be dropped if the total length of these 606f0706e82SJiri Benc * queues increases over the limit. */ 607f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128 608f0706e82SJiri Benc struct tasklet_struct tasklet; 609f0706e82SJiri Benc struct sk_buff_head skb_queue; 610f0706e82SJiri Benc struct sk_buff_head skb_queue_unreliable; 611f0706e82SJiri Benc 612d0709a65SJohannes Berg /* Station data */ 613d0709a65SJohannes Berg /* 614d0709a65SJohannes Berg * The lock only protects the list, hash, timer and counter 615d0709a65SJohannes Berg * against manipulation, reads are done in RCU. Additionally, 616b16bd15cSJohannes Berg * the lock protects each BSS's TIM bitmap. 617d0709a65SJohannes Berg */ 618d0709a65SJohannes Berg spinlock_t sta_lock; 619d0709a65SJohannes Berg unsigned long num_sta; 620f0706e82SJiri Benc struct list_head sta_list; 621dc6676b7SJohannes Berg struct list_head sta_flush_list; 622dc6676b7SJohannes Berg struct work_struct sta_flush_work; 623f0706e82SJiri Benc struct sta_info *sta_hash[STA_HASH_SIZE]; 624f0706e82SJiri Benc struct timer_list sta_cleanup; 625f0706e82SJiri Benc 626e2530083SJohannes Berg unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; 627f8e79dddSTomas Winkler unsigned long queues_pending_run[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; 628eefce91aSJohannes Berg struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES]; 629f0706e82SJiri Benc struct tasklet_struct tx_pending_tasklet; 630f0706e82SJiri Benc 631f0706e82SJiri Benc /* number of interfaces with corresponding IFF_ flags */ 63253918994SJohannes Berg atomic_t iff_allmultis, iff_promiscs; 633f0706e82SJiri Benc 634f0706e82SJiri Benc struct rate_control_ref *rate_ctrl; 635f0706e82SJiri Benc 636f0706e82SJiri Benc int rts_threshold; 637f0706e82SJiri Benc int fragmentation_threshold; 638f0706e82SJiri Benc int short_retry_limit; /* dot11ShortRetryLimit */ 639f0706e82SJiri Benc int long_retry_limit; /* dot11LongRetryLimit */ 640f0706e82SJiri Benc 641f0706e82SJiri Benc struct crypto_blkcipher *wep_tx_tfm; 642f0706e82SJiri Benc struct crypto_blkcipher *wep_rx_tfm; 643f0706e82SJiri Benc u32 wep_iv; 644f0706e82SJiri Benc 64579010420SJohannes Berg struct list_head interfaces; 64679010420SJohannes Berg 647b16bd15cSJohannes Berg /* 648b16bd15cSJohannes Berg * Key lock, protects sdata's key_list and sta_info's 649b16bd15cSJohannes Berg * key pointers (write access, they're RCU.) 650b16bd15cSJohannes Berg */ 651b16bd15cSJohannes Berg spinlock_t key_lock; 652b16bd15cSJohannes Berg 653b16bd15cSJohannes Berg 654c2b13452SJohannes Berg /* Scanning and BSS list */ 655c2b13452SJohannes Berg bool sw_scanning, hw_scanning; 656f0706e82SJiri Benc int scan_channel_idx; 6578318d78aSJohannes Berg enum ieee80211_band scan_band; 6588318d78aSJohannes Berg 659f0706e82SJiri Benc enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; 660f0706e82SJiri Benc unsigned long last_scan_completed; 661f0706e82SJiri Benc struct delayed_work scan_work; 662491775a5SJohannes Berg struct ieee80211_sub_if_data *scan_sdata; 663f0706e82SJiri Benc struct ieee80211_channel *oper_channel, *scan_channel; 664f0706e82SJiri Benc u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 665f0706e82SJiri Benc size_t scan_ssid_len; 666c2b13452SJohannes Berg struct list_head bss_list; 667c2b13452SJohannes Berg struct ieee80211_bss *bss_hash[STA_HASH_SIZE]; 668c2b13452SJohannes Berg spinlock_t bss_lock; 669f0706e82SJiri Benc 670f0706e82SJiri Benc /* SNMP counters */ 671f0706e82SJiri Benc /* dot11CountersTable */ 672f0706e82SJiri Benc u32 dot11TransmittedFragmentCount; 673f0706e82SJiri Benc u32 dot11MulticastTransmittedFrameCount; 674f0706e82SJiri Benc u32 dot11FailedCount; 675f0706e82SJiri Benc u32 dot11RetryCount; 676f0706e82SJiri Benc u32 dot11MultipleRetryCount; 677f0706e82SJiri Benc u32 dot11FrameDuplicateCount; 678f0706e82SJiri Benc u32 dot11ReceivedFragmentCount; 679f0706e82SJiri Benc u32 dot11MulticastReceivedFrameCount; 680f0706e82SJiri Benc u32 dot11TransmittedFrameCount; 681f0706e82SJiri Benc u32 dot11WEPUndecryptableCount; 682f0706e82SJiri Benc 683f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS 684f0706e82SJiri Benc int tx_led_counter, rx_led_counter; 685cdcb006fSIvo van Doorn struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; 686cdcb006fSIvo van Doorn char tx_led_name[32], rx_led_name[32], 687cdcb006fSIvo van Doorn assoc_led_name[32], radio_led_name[32]; 688f0706e82SJiri Benc #endif 689f0706e82SJiri Benc 690e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 691e9f207f0SJiri Benc struct work_struct sta_debugfs_add; 692e9f207f0SJiri Benc #endif 693e9f207f0SJiri Benc 694f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 695f0706e82SJiri Benc /* TX/RX handler statistics */ 696f0706e82SJiri Benc unsigned int tx_handlers_drop; 697f0706e82SJiri Benc unsigned int tx_handlers_queued; 698f0706e82SJiri Benc unsigned int tx_handlers_drop_unencrypted; 699f0706e82SJiri Benc unsigned int tx_handlers_drop_fragment; 700f0706e82SJiri Benc unsigned int tx_handlers_drop_wep; 701f0706e82SJiri Benc unsigned int tx_handlers_drop_not_assoc; 702f0706e82SJiri Benc unsigned int tx_handlers_drop_unauth_port; 703f0706e82SJiri Benc unsigned int rx_handlers_drop; 704f0706e82SJiri Benc unsigned int rx_handlers_queued; 705f0706e82SJiri Benc unsigned int rx_handlers_drop_nullfunc; 706f0706e82SJiri Benc unsigned int rx_handlers_drop_defrag; 707f0706e82SJiri Benc unsigned int rx_handlers_drop_short; 708f0706e82SJiri Benc unsigned int rx_handlers_drop_passive_scan; 709f0706e82SJiri Benc unsigned int tx_expand_skb_head; 710f0706e82SJiri Benc unsigned int tx_expand_skb_head_cloned; 711f0706e82SJiri Benc unsigned int rx_expand_skb_head; 712f0706e82SJiri Benc unsigned int rx_expand_skb_head2; 713f0706e82SJiri Benc unsigned int rx_handlers_fragments; 714f0706e82SJiri Benc unsigned int tx_status_drop; 715f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++ 716f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */ 717f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0) 718f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ 719f0706e82SJiri Benc 720f0706e82SJiri Benc 721f0706e82SJiri Benc int total_ps_buffered; /* total number of all buffered unicast and 722f0706e82SJiri Benc * multicast packets for power saving stations 723f0706e82SJiri Benc */ 724f0706e82SJiri Benc int wifi_wme_noack_test; 725f0706e82SJiri Benc unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 726f0706e82SJiri Benc 727e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 728e9f207f0SJiri Benc struct local_debugfsdentries { 7294b7679a5SJohannes Berg struct dentry *rcdir; 7304b7679a5SJohannes Berg struct dentry *rcname; 731e9f207f0SJiri Benc struct dentry *frequency; 732e9f207f0SJiri Benc struct dentry *rts_threshold; 733e9f207f0SJiri Benc struct dentry *fragmentation_threshold; 734e9f207f0SJiri Benc struct dentry *short_retry_limit; 735e9f207f0SJiri Benc struct dentry *long_retry_limit; 736e9f207f0SJiri Benc struct dentry *total_ps_buffered; 737e9f207f0SJiri Benc struct dentry *wep_iv; 738e9f207f0SJiri Benc struct dentry *statistics; 739e9f207f0SJiri Benc struct local_debugfsdentries_statsdentries { 740e9f207f0SJiri Benc struct dentry *transmitted_fragment_count; 741e9f207f0SJiri Benc struct dentry *multicast_transmitted_frame_count; 742e9f207f0SJiri Benc struct dentry *failed_count; 743e9f207f0SJiri Benc struct dentry *retry_count; 744e9f207f0SJiri Benc struct dentry *multiple_retry_count; 745e9f207f0SJiri Benc struct dentry *frame_duplicate_count; 746e9f207f0SJiri Benc struct dentry *received_fragment_count; 747e9f207f0SJiri Benc struct dentry *multicast_received_frame_count; 748e9f207f0SJiri Benc struct dentry *transmitted_frame_count; 749e9f207f0SJiri Benc struct dentry *wep_undecryptable_count; 750e9f207f0SJiri Benc struct dentry *num_scans; 751e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 752e9f207f0SJiri Benc struct dentry *tx_handlers_drop; 753e9f207f0SJiri Benc struct dentry *tx_handlers_queued; 754e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unencrypted; 755e9f207f0SJiri Benc struct dentry *tx_handlers_drop_fragment; 756e9f207f0SJiri Benc struct dentry *tx_handlers_drop_wep; 757e9f207f0SJiri Benc struct dentry *tx_handlers_drop_not_assoc; 758e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unauth_port; 759e9f207f0SJiri Benc struct dentry *rx_handlers_drop; 760e9f207f0SJiri Benc struct dentry *rx_handlers_queued; 761e9f207f0SJiri Benc struct dentry *rx_handlers_drop_nullfunc; 762e9f207f0SJiri Benc struct dentry *rx_handlers_drop_defrag; 763e9f207f0SJiri Benc struct dentry *rx_handlers_drop_short; 764e9f207f0SJiri Benc struct dentry *rx_handlers_drop_passive_scan; 765e9f207f0SJiri Benc struct dentry *tx_expand_skb_head; 766e9f207f0SJiri Benc struct dentry *tx_expand_skb_head_cloned; 767e9f207f0SJiri Benc struct dentry *rx_expand_skb_head; 768e9f207f0SJiri Benc struct dentry *rx_expand_skb_head2; 769e9f207f0SJiri Benc struct dentry *rx_handlers_fragments; 770e9f207f0SJiri Benc struct dentry *tx_status_drop; 771e9f207f0SJiri Benc #endif 772e9f207f0SJiri Benc struct dentry *dot11ACKFailureCount; 773e9f207f0SJiri Benc struct dentry *dot11RTSFailureCount; 774e9f207f0SJiri Benc struct dentry *dot11FCSErrorCount; 775e9f207f0SJiri Benc struct dentry *dot11RTSSuccessCount; 776e9f207f0SJiri Benc } stats; 777e9f207f0SJiri Benc struct dentry *stations; 778e9f207f0SJiri Benc struct dentry *keys; 779e9f207f0SJiri Benc } debugfs; 780e9f207f0SJiri Benc #endif 781f0706e82SJiri Benc }; 782f0706e82SJiri Benc 7833e122be0SJohannes Berg static inline struct ieee80211_sub_if_data * 7843e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) 7853e122be0SJohannes Berg { 7863e122be0SJohannes Berg struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 7873e122be0SJohannes Berg 7883e122be0SJohannes Berg BUG_ON(!local || local->mdev == dev); 7893e122be0SJohannes Berg 7903e122be0SJohannes Berg return netdev_priv(dev); 7913e122be0SJohannes Berg } 7923e122be0SJohannes Berg 793eadc8d9eSRon Rindjunsky /* this struct represents 802.11n's RA/TID combination */ 794eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid { 795eadc8d9eSRon Rindjunsky u8 ra[ETH_ALEN]; 796eadc8d9eSRon Rindjunsky u16 tid; 797eadc8d9eSRon Rindjunsky }; 798eadc8d9eSRon Rindjunsky 799ee385855SLuis Carlos Cobo /* Parsed Information Elements */ 800ee385855SLuis Carlos Cobo struct ieee802_11_elems { 80143ac2ca3SJouni Malinen u8 *ie_start; 80243ac2ca3SJouni Malinen size_t total_len; 80343ac2ca3SJouni Malinen 804ee385855SLuis Carlos Cobo /* pointers to IEs */ 805ee385855SLuis Carlos Cobo u8 *ssid; 806ee385855SLuis Carlos Cobo u8 *supp_rates; 807ee385855SLuis Carlos Cobo u8 *fh_params; 808ee385855SLuis Carlos Cobo u8 *ds_params; 809ee385855SLuis Carlos Cobo u8 *cf_params; 810ee385855SLuis Carlos Cobo u8 *tim; 811ee385855SLuis Carlos Cobo u8 *ibss_params; 812ee385855SLuis Carlos Cobo u8 *challenge; 813ee385855SLuis Carlos Cobo u8 *wpa; 814ee385855SLuis Carlos Cobo u8 *rsn; 815ee385855SLuis Carlos Cobo u8 *erp_info; 816ee385855SLuis Carlos Cobo u8 *ext_supp_rates; 817ee385855SLuis Carlos Cobo u8 *wmm_info; 818ee385855SLuis Carlos Cobo u8 *wmm_param; 81909914813SJohannes Berg struct ieee80211_ht_cap *ht_cap_elem; 820d9fe60deSJohannes Berg struct ieee80211_ht_info *ht_info_elem; 821ee385855SLuis Carlos Cobo u8 *mesh_config; 822ee385855SLuis Carlos Cobo u8 *mesh_id; 823ee385855SLuis Carlos Cobo u8 *peer_link; 824ee385855SLuis Carlos Cobo u8 *preq; 825ee385855SLuis Carlos Cobo u8 *prep; 826ee385855SLuis Carlos Cobo u8 *perr; 827f2df3859SAssaf Krauss u8 *ch_switch_elem; 828f2df3859SAssaf Krauss u8 *country_elem; 829f2df3859SAssaf Krauss u8 *pwr_constr_elem; 830f2df3859SAssaf Krauss u8 *quiet_elem; /* first quite element */ 831ee385855SLuis Carlos Cobo 832ee385855SLuis Carlos Cobo /* length of them, respectively */ 833ee385855SLuis Carlos Cobo u8 ssid_len; 834ee385855SLuis Carlos Cobo u8 supp_rates_len; 835ee385855SLuis Carlos Cobo u8 fh_params_len; 836ee385855SLuis Carlos Cobo u8 ds_params_len; 837ee385855SLuis Carlos Cobo u8 cf_params_len; 838ee385855SLuis Carlos Cobo u8 tim_len; 839ee385855SLuis Carlos Cobo u8 ibss_params_len; 840ee385855SLuis Carlos Cobo u8 challenge_len; 841ee385855SLuis Carlos Cobo u8 wpa_len; 842ee385855SLuis Carlos Cobo u8 rsn_len; 843ee385855SLuis Carlos Cobo u8 erp_info_len; 844ee385855SLuis Carlos Cobo u8 ext_supp_rates_len; 845ee385855SLuis Carlos Cobo u8 wmm_info_len; 846ee385855SLuis Carlos Cobo u8 wmm_param_len; 847ee385855SLuis Carlos Cobo u8 mesh_config_len; 848ee385855SLuis Carlos Cobo u8 mesh_id_len; 849ee385855SLuis Carlos Cobo u8 peer_link_len; 850ee385855SLuis Carlos Cobo u8 preq_len; 851ee385855SLuis Carlos Cobo u8 prep_len; 852ee385855SLuis Carlos Cobo u8 perr_len; 853f2df3859SAssaf Krauss u8 ch_switch_elem_len; 854f2df3859SAssaf Krauss u8 country_elem_len; 855f2df3859SAssaf Krauss u8 pwr_constr_elem_len; 856f2df3859SAssaf Krauss u8 quiet_elem_len; 857f2df3859SAssaf Krauss u8 num_of_quiet_elem; /* can be more the one */ 858ee385855SLuis Carlos Cobo }; 859ee385855SLuis Carlos Cobo 860f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local( 861f0706e82SJiri Benc struct ieee80211_hw *hw) 862f0706e82SJiri Benc { 863f0706e82SJiri Benc return container_of(hw, struct ieee80211_local, hw); 864f0706e82SJiri Benc } 865f0706e82SJiri Benc 866f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw( 867f0706e82SJiri Benc struct ieee80211_local *local) 868f0706e82SJiri Benc { 869f0706e82SJiri Benc return &local->hw; 870f0706e82SJiri Benc } 871f0706e82SJiri Benc 872f0706e82SJiri Benc 873571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) 874571ecf67SJohannes Berg { 875571ecf67SJohannes Berg return compare_ether_addr(raddr, addr) == 0 || 876571ecf67SJohannes Berg is_broadcast_ether_addr(raddr); 877571ecf67SJohannes Berg } 878571ecf67SJohannes Berg 879571ecf67SJohannes Berg 880e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed); 8819d139c81SJohannes Berg int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed); 8825cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx); 8839c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 8849c6bd790SJohannes Berg u32 changed); 8850d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local); 886f0706e82SJiri Benc 8879c6bd790SJohannes Berg /* wireless extensions */ 888f0706e82SJiri Benc extern const struct iw_handler_def ieee80211_iw_handler_def; 88965b53e4cSDavid S. Miller 8909c6bd790SJohannes Berg /* STA/IBSS code */ 8919c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 892c2b13452SJohannes Berg void ieee80211_scan_work(struct work_struct *work); 893f698d856SJasper Bryant-Greene void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 894f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 895f698d856SJasper Bryant-Greene int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len); 896f698d856SJasper Bryant-Greene int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len); 897f698d856SJasper Bryant-Greene int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid); 898f698d856SJasper Bryant-Greene void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata, 899f0706e82SJiri Benc struct ieee80211_if_sta *ifsta); 9009c6bd790SJohannes Berg struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 9019c6bd790SJohannes Berg struct sk_buff *skb, u8 *bssid, 9029c6bd790SJohannes Berg u8 *addr, u64 supp_rates); 9039c6bd790SJohannes Berg int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason); 9049c6bd790SJohannes Berg int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); 9059c6bd790SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 9069c6bd790SJohannes Berg u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 9079c6bd790SJohannes Berg struct ieee802_11_elems *elems, 9089c6bd790SJohannes Berg enum ieee80211_band band); 9099c6bd790SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 9109c6bd790SJohannes Berg u8 *ssid, size_t ssid_len); 9119c6bd790SJohannes Berg 9129c6bd790SJohannes Berg /* scan/BSS handling */ 913c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, 914c2b13452SJohannes Berg u8 *ssid, size_t ssid_len); 915c2b13452SJohannes Berg int ieee80211_scan_results(struct ieee80211_local *local, 916ccc58057SDavid S. Miller struct iw_request_info *info, 917ccc58057SDavid S. Miller char *buf, size_t len); 918c2b13452SJohannes Berg ieee80211_rx_result 919c2b13452SJohannes Berg ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, 920c2b13452SJohannes Berg struct sk_buff *skb, 921f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 9223e122be0SJohannes Berg void ieee80211_rx_bss_list_init(struct ieee80211_local *local); 9233e122be0SJohannes Berg void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local); 924c2b13452SJohannes Berg int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, 925c2b13452SJohannes Berg char *ie, size_t len); 9269c6bd790SJohannes Berg 9270a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); 928c2b13452SJohannes Berg int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata, 9290a51b27eSJohannes Berg u8 *ssid, size_t ssid_len); 930c2b13452SJohannes Berg struct ieee80211_bss * 93198c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local, 93298c8fccfSJohannes Berg struct ieee80211_rx_status *rx_status, 93398c8fccfSJohannes Berg struct ieee80211_mgmt *mgmt, 93498c8fccfSJohannes Berg size_t len, 93598c8fccfSJohannes Berg struct ieee802_11_elems *elems, 93698c8fccfSJohannes Berg int freq, bool beacon); 937c2b13452SJohannes Berg struct ieee80211_bss * 9385484e237SJohannes Berg ieee80211_rx_bss_add(struct ieee80211_local *local, u8 *bssid, int freq, 9395484e237SJohannes Berg u8 *ssid, u8 ssid_len); 940c2b13452SJohannes Berg struct ieee80211_bss * 9415484e237SJohannes Berg ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, 9425484e237SJohannes Berg u8 *ssid, u8 ssid_len); 94398c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local, 944c2b13452SJohannes Berg struct ieee80211_bss *bss); 945ee385855SLuis Carlos Cobo 9463e122be0SJohannes Berg /* interface handling */ 9473e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name, 94805c914feSJohannes Berg struct net_device **new_dev, enum nl80211_iftype type, 949ee385855SLuis Carlos Cobo struct vif_params *params); 950f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, 95105c914feSJohannes Berg enum nl80211_iftype type); 952f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata); 95375636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local); 954f0706e82SJiri Benc 955e2ebc74dSJohannes Berg /* tx handling */ 956e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local); 957e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data); 958e2ebc74dSJohannes Berg int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); 959e2ebc74dSJohannes Berg int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); 960e2ebc74dSJohannes Berg int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); 961e2ebc74dSJohannes Berg 962de1ede7aSJohannes Berg /* HT */ 963d9fe60deSJohannes Berg void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_ht_cap *ht_cap_ie, 964d9fe60deSJohannes Berg struct ieee80211_sta_ht_cap *ht_cap); 965d9fe60deSJohannes Berg void ieee80211_ht_info_ie_to_ht_bss_info( 966d9fe60deSJohannes Berg struct ieee80211_ht_info *ht_add_info_ie, 967de1ede7aSJohannes Berg struct ieee80211_ht_bss_info *bss_info); 968d9fe60deSJohannes Berg u32 ieee80211_handle_ht(struct ieee80211_local *local, 969d9fe60deSJohannes Berg struct ieee80211_sta_ht_cap *req_ht_cap, 970d9fe60deSJohannes Berg struct ieee80211_ht_bss_info *req_bss_cap); 971de1ede7aSJohannes Berg void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn); 972de1ede7aSJohannes Berg 973de1ede7aSJohannes Berg void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, 974de1ede7aSJohannes Berg u16 tid, u16 initiator, u16 reason); 975de1ede7aSJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr); 976de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, 977de1ede7aSJohannes Berg struct sta_info *sta, 978de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, size_t len); 979de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local, 980de1ede7aSJohannes Berg struct sta_info *sta, 981de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, 982de1ede7aSJohannes Berg size_t len); 983de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local, 984de1ede7aSJohannes Berg struct sta_info *sta, 985de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, 986de1ede7aSJohannes Berg size_t len); 987de1ede7aSJohannes Berg 98839192c0bSJohannes Berg /* Spectrum management */ 98939192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, 99039192c0bSJohannes Berg struct ieee80211_mgmt *mgmt, 99139192c0bSJohannes Berg size_t len); 99239192c0bSJohannes Berg 993c2d1560aSJohannes Berg /* utility functions/constants */ 994c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */ 995c2d1560aSJohannes Berg extern const unsigned char rfc1042_header[6]; 996c2d1560aSJohannes Berg extern const unsigned char bridge_tunnel_header[6]; 99771364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 99805c914feSJohannes Berg enum nl80211_iftype type); 999c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, 1000c2d1560aSJohannes Berg int rate, int erp, int short_preamble); 1001f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, 1002eb063c17SJohannes Berg struct ieee80211_hdr *hdr); 10035825fe10SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); 1004e50db65cSJohannes Berg void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 1005e50db65cSJohannes Berg int encrypt); 10069c6bd790SJohannes Berg void ieee802_11_parse_elems(u8 *start, size_t len, 10079c6bd790SJohannes Berg struct ieee802_11_elems *elems); 1008e16751c3SJohannes Berg int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq); 100996dd22acSJohannes Berg u64 ieee80211_mandatory_rates(struct ieee80211_local *local, 101096dd22acSJohannes Berg enum ieee80211_band band); 1011f0706e82SJiri Benc 1012f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE 1013d9e8a70fSJohannes Berg #define debug_noinline noinline 1014d9e8a70fSJohannes Berg #else 1015d9e8a70fSJohannes Berg #define debug_noinline 1016d9e8a70fSJohannes Berg #endif 1017d9e8a70fSJohannes Berg 1018f0706e82SJiri Benc #endif /* IEEE80211_I_H */ 1019