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 int num_beacons; /* number of TXed beacon frames for this BSS */ 233f0706e82SJiri Benc }; 234f0706e82SJiri Benc 235f0706e82SJiri Benc struct ieee80211_if_wds { 236f0706e82SJiri Benc struct sta_info *sta; 237056cdd59SJohannes Berg u8 remote_addr[ETH_ALEN]; 238f0706e82SJiri Benc }; 239f0706e82SJiri Benc 240f0706e82SJiri Benc struct ieee80211_if_vlan { 2410ec3ca44SJohannes Berg struct list_head list; 242f0706e82SJiri Benc }; 243f0706e82SJiri Benc 244ee385855SLuis Carlos Cobo struct mesh_stats { 245ee385855SLuis Carlos Cobo __u32 fwded_frames; /* Mesh forwarded frames */ 246ee385855SLuis Carlos Cobo __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ 247ee385855SLuis Carlos Cobo __u32 dropped_frames_no_route; /* Not transmitted, no route found */ 248ee385855SLuis Carlos Cobo atomic_t estab_plinks; 249ee385855SLuis Carlos Cobo }; 250ee385855SLuis Carlos Cobo 251ee385855SLuis Carlos Cobo #define PREQ_Q_F_START 0x1 252ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH 0x2 253ee385855SLuis Carlos Cobo struct mesh_preq_queue { 254ee385855SLuis Carlos Cobo struct list_head list; 255ee385855SLuis Carlos Cobo u8 dst[ETH_ALEN]; 256ee385855SLuis Carlos Cobo u8 flags; 257ee385855SLuis Carlos Cobo }; 258ee385855SLuis Carlos Cobo 259ee385855SLuis Carlos Cobo struct mesh_config { 260ee385855SLuis Carlos Cobo /* Timeouts in ms */ 261ee385855SLuis Carlos Cobo /* Mesh plink management parameters */ 262ee385855SLuis Carlos Cobo u16 dot11MeshRetryTimeout; 263ee385855SLuis Carlos Cobo u16 dot11MeshConfirmTimeout; 264ee385855SLuis Carlos Cobo u16 dot11MeshHoldingTimeout; 265ee385855SLuis Carlos Cobo u16 dot11MeshMaxPeerLinks; 266ee385855SLuis Carlos Cobo u8 dot11MeshMaxRetries; 267ee385855SLuis Carlos Cobo u8 dot11MeshTTL; 268ee385855SLuis Carlos Cobo bool auto_open_plinks; 269ee385855SLuis Carlos Cobo /* HWMP parameters */ 270ee385855SLuis Carlos Cobo u8 dot11MeshHWMPmaxPREQretries; 271ee385855SLuis Carlos Cobo u32 path_refresh_time; 272ee385855SLuis Carlos Cobo u16 min_discovery_timeout; 273056cdd59SJohannes Berg u32 dot11MeshHWMPactivePathTimeout; 274056cdd59SJohannes Berg u16 dot11MeshHWMPpreqMinInterval; 275056cdd59SJohannes Berg u16 dot11MeshHWMPnetDiameterTraversalTime; 276ee385855SLuis Carlos Cobo }; 277902acc78SJohannes Berg 278ee385855SLuis Carlos Cobo 279d6f2da5bSJiri Slaby /* flags used in struct ieee80211_if_sta.flags */ 280d6f2da5bSJiri Slaby #define IEEE80211_STA_SSID_SET BIT(0) 281d6f2da5bSJiri Slaby #define IEEE80211_STA_BSSID_SET BIT(1) 282d6f2da5bSJiri Slaby #define IEEE80211_STA_PREV_BSSID_SET BIT(2) 283d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTHENTICATED BIT(3) 284d6f2da5bSJiri Slaby #define IEEE80211_STA_ASSOCIATED BIT(4) 285d6f2da5bSJiri Slaby #define IEEE80211_STA_PROBEREQ_POLL BIT(5) 286d6f2da5bSJiri Slaby #define IEEE80211_STA_CREATE_IBSS BIT(6) 287d6f2da5bSJiri Slaby #define IEEE80211_STA_MIXED_CELL BIT(7) 288d6f2da5bSJiri Slaby #define IEEE80211_STA_WMM_ENABLED BIT(8) 289d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_SSID_SEL BIT(10) 290d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11) 291d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12) 2925b98b1f7SJohannes Berg #define IEEE80211_STA_PRIVACY_INVOKED BIT(13) 29348c2fc59STomas Winkler /* flags for MLME request */ 29448c2fc59STomas Winkler #define IEEE80211_STA_REQ_SCAN 0 2959859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_DIRECT_PROBE 1 2969859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_AUTH 2 2979859b81eSRon Rindjunsky #define IEEE80211_STA_REQ_RUN 3 29848c2fc59STomas Winkler 299ccd7b362SJohannes Berg /* STA/IBSS MLME states */ 30048c2fc59STomas Winkler enum ieee80211_sta_mlme_state { 30148c2fc59STomas Winkler IEEE80211_STA_MLME_DISABLED, 3029859b81eSRon Rindjunsky IEEE80211_STA_MLME_DIRECT_PROBE, 30348c2fc59STomas Winkler IEEE80211_STA_MLME_AUTHENTICATE, 30448c2fc59STomas Winkler IEEE80211_STA_MLME_ASSOCIATE, 30548c2fc59STomas Winkler IEEE80211_STA_MLME_ASSOCIATED, 30648c2fc59STomas Winkler IEEE80211_STA_MLME_IBSS_SEARCH, 30748c2fc59STomas Winkler IEEE80211_STA_MLME_IBSS_JOINED, 30848c2fc59STomas Winkler }; 30948c2fc59STomas Winkler 31048c2fc59STomas Winkler /* bitfield of allowed auth algs */ 31148c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_OPEN BIT(0) 31248c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) 31348c2fc59STomas Winkler #define IEEE80211_AUTH_ALG_LEAP BIT(2) 31448c2fc59STomas Winkler 315f0706e82SJiri Benc struct ieee80211_if_sta { 316056cdd59SJohannes Berg struct timer_list timer; 317056cdd59SJohannes Berg struct work_struct work; 318056cdd59SJohannes Berg u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 319056cdd59SJohannes Berg u8 ssid[IEEE80211_MAX_SSID_LEN]; 32048c2fc59STomas Winkler enum ieee80211_sta_mlme_state state; 321f0706e82SJiri Benc size_t ssid_len; 322a0af5f14SHelmut Schaa u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 323a0af5f14SHelmut Schaa size_t scan_ssid_len; 324f0706e82SJiri Benc u16 aid; 325f0706e82SJiri Benc u16 ap_capab, capab; 326f0706e82SJiri Benc u8 *extra_ie; /* to be added to the end of AssocReq */ 327f0706e82SJiri Benc size_t extra_ie_len; 328f0706e82SJiri Benc 329f0706e82SJiri Benc /* The last AssocReq/Resp IEs */ 330f0706e82SJiri Benc u8 *assocreq_ies, *assocresp_ies; 331f0706e82SJiri Benc size_t assocreq_ies_len, assocresp_ies_len; 332f0706e82SJiri Benc 333056cdd59SJohannes Berg struct sk_buff_head skb_queue; 334056cdd59SJohannes Berg 3356042a3e3SRon Rindjunsky int assoc_scan_tries; /* number of scans done pre-association */ 3369859b81eSRon Rindjunsky int direct_probe_tries; /* retries for direct probes */ 3376042a3e3SRon Rindjunsky int auth_tries; /* retries for auth req */ 3386042a3e3SRon Rindjunsky int assoc_tries; /* retries for assoc req */ 339f0706e82SJiri Benc 340056cdd59SJohannes Berg unsigned long request; 341056cdd59SJohannes Berg 342056cdd59SJohannes Berg unsigned long last_probe; 343056cdd59SJohannes Berg 344d6f2da5bSJiri Slaby unsigned int flags; 345f0706e82SJiri Benc 346f0706e82SJiri Benc unsigned int auth_algs; /* bitfield of allowed auth algs */ 347f0706e82SJiri Benc int auth_alg; /* currently used IEEE 802.11 authentication algorithm */ 348f0706e82SJiri Benc int auth_transaction; 349f0706e82SJiri Benc 350f0706e82SJiri Benc unsigned long ibss_join_req; 351f0706e82SJiri Benc struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 3528318d78aSJohannes Berg u32 supp_rates_bits[IEEE80211_NUM_BANDS]; 353f0706e82SJiri Benc 354f0706e82SJiri Benc int wmm_last_param_set; 355ee385855SLuis Carlos Cobo int num_beacons; /* number of TXed beacon frames by this STA */ 356f0706e82SJiri Benc }; 357f0706e82SJiri Benc 358472dbc45SJohannes Berg struct ieee80211_if_mesh { 359472dbc45SJohannes Berg struct work_struct work; 360472dbc45SJohannes Berg struct timer_list housekeeping_timer; 361472dbc45SJohannes Berg struct timer_list mesh_path_timer; 362472dbc45SJohannes Berg struct sk_buff_head skb_queue; 363472dbc45SJohannes Berg 364472dbc45SJohannes Berg bool housekeeping; 365472dbc45SJohannes Berg 366472dbc45SJohannes Berg u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; 367472dbc45SJohannes Berg size_t mesh_id_len; 368472dbc45SJohannes Berg /* Active Path Selection Protocol Identifier */ 369472dbc45SJohannes Berg u8 mesh_pp_id[4]; 370472dbc45SJohannes Berg /* Active Path Selection Metric Identifier */ 371472dbc45SJohannes Berg u8 mesh_pm_id[4]; 372472dbc45SJohannes Berg /* Congestion Control Mode Identifier */ 373472dbc45SJohannes Berg u8 mesh_cc_id[4]; 374472dbc45SJohannes Berg /* Local mesh Destination Sequence Number */ 375472dbc45SJohannes Berg u32 dsn; 376472dbc45SJohannes Berg /* Last used PREQ ID */ 377472dbc45SJohannes Berg u32 preq_id; 378472dbc45SJohannes Berg atomic_t mpaths; 379472dbc45SJohannes Berg /* Timestamp of last DSN update */ 380472dbc45SJohannes Berg unsigned long last_dsn_update; 381472dbc45SJohannes Berg /* Timestamp of last DSN sent */ 382472dbc45SJohannes Berg unsigned long last_preq; 383472dbc45SJohannes Berg struct mesh_rmc *rmc; 384472dbc45SJohannes Berg spinlock_t mesh_preq_queue_lock; 385472dbc45SJohannes Berg struct mesh_preq_queue preq_queue; 386472dbc45SJohannes Berg int preq_queue_len; 387472dbc45SJohannes Berg struct mesh_stats mshstats; 388472dbc45SJohannes Berg struct mesh_config mshcfg; 389472dbc45SJohannes Berg u32 mesh_seqnum; 390472dbc45SJohannes Berg bool accepting_plinks; 391472dbc45SJohannes Berg int num_beacons; 392472dbc45SJohannes Berg }; 393902acc78SJohannes Berg 394902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 395472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 396472dbc45SJohannes Berg do { (msh)->mshstats.name++; } while (0) 397902acc78SJohannes Berg #else 398472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 399902acc78SJohannes Berg do { } while (0) 400902acc78SJohannes Berg #endif 401f0706e82SJiri Benc 402213cd118SJohannes Berg /** 403213cd118SJohannes Berg * enum ieee80211_sub_if_data_flags - virtual interface flags 404213cd118SJohannes Berg * 405213cd118SJohannes Berg * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets 406213cd118SJohannes Berg * @IEEE80211_SDATA_PROMISC: interface is promisc 407213cd118SJohannes Berg * @IEEE80211_SDATA_USERSPACE_MLME: userspace MLME is active 408213cd118SJohannes Berg * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode 409213cd118SJohannes Berg * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between 410213cd118SJohannes Berg * associated stations and deliver multicast frames both 411213cd118SJohannes Berg * back to wireless media and to the local net stack. 412213cd118SJohannes Berg */ 413213cd118SJohannes Berg enum ieee80211_sub_if_data_flags { 414213cd118SJohannes Berg IEEE80211_SDATA_ALLMULTI = BIT(0), 415213cd118SJohannes Berg IEEE80211_SDATA_PROMISC = BIT(1), 416213cd118SJohannes Berg IEEE80211_SDATA_USERSPACE_MLME = BIT(2), 417213cd118SJohannes Berg IEEE80211_SDATA_OPERATING_GMODE = BIT(3), 418213cd118SJohannes Berg IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(4), 419213cd118SJohannes Berg }; 420213cd118SJohannes Berg 421f0706e82SJiri Benc struct ieee80211_sub_if_data { 422f0706e82SJiri Benc struct list_head list; 423f0706e82SJiri Benc 424f0706e82SJiri Benc struct wireless_dev wdev; 425f0706e82SJiri Benc 42611a843b7SJohannes Berg /* keys */ 42711a843b7SJohannes Berg struct list_head key_list; 42811a843b7SJohannes Berg 429f0706e82SJiri Benc struct net_device *dev; 430f0706e82SJiri Benc struct ieee80211_local *local; 431f0706e82SJiri Benc 43213262ffdSJiri Slaby unsigned int flags; 4337e9ed188SDaniel Drake 434f0706e82SJiri Benc int drop_unencrypted; 435f0706e82SJiri Benc 436f0706e82SJiri Benc /* Fragment table for host-based reassembly */ 437f0706e82SJiri Benc struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX]; 438f0706e82SJiri Benc unsigned int fragment_next; 439f0706e82SJiri Benc 440f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4 441f0706e82SJiri Benc struct ieee80211_key *keys[NUM_DEFAULT_KEYS]; 442f0706e82SJiri Benc struct ieee80211_key *default_key; 443f0706e82SJiri Benc 4443e122be0SJohannes Berg /* BSS configuration for this interface. */ 445471b3efdSJohannes Berg struct ieee80211_bss_conf bss_conf; 4463e122be0SJohannes Berg 4473e122be0SJohannes Berg /* 4483e122be0SJohannes Berg * AP this belongs to: self in AP mode and 4493e122be0SJohannes Berg * corresponding AP in VLAN mode, NULL for 4503e122be0SJohannes Berg * all others (might be needed later in IBSS) 4513e122be0SJohannes Berg */ 4523e122be0SJohannes Berg struct ieee80211_if_ap *bss; 4533e122be0SJohannes Berg 4543e122be0SJohannes Berg int force_unicast_rateidx; /* forced TX rateidx for unicast frames */ 4553e122be0SJohannes Berg int max_ratectrl_rateidx; /* max TX rateidx for rate control */ 456f0706e82SJiri Benc 457f0706e82SJiri Benc union { 458f0706e82SJiri Benc struct ieee80211_if_ap ap; 459f0706e82SJiri Benc struct ieee80211_if_wds wds; 460f0706e82SJiri Benc struct ieee80211_if_vlan vlan; 461f0706e82SJiri Benc struct ieee80211_if_sta sta; 462472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH 463472dbc45SJohannes Berg struct ieee80211_if_mesh mesh; 464472dbc45SJohannes Berg #endif 4658cc9a739SMichael Wu u32 mntr_flags; 466f0706e82SJiri Benc } u; 467e9f207f0SJiri Benc 468e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 469e9f207f0SJiri Benc struct dentry *debugfsdir; 470e9f207f0SJiri Benc union { 471e9f207f0SJiri Benc struct { 472e9f207f0SJiri Benc struct dentry *drop_unencrypted; 473e9f207f0SJiri Benc struct dentry *state; 474e9f207f0SJiri Benc struct dentry *bssid; 475e9f207f0SJiri Benc struct dentry *prev_bssid; 476e9f207f0SJiri Benc struct dentry *ssid_len; 477e9f207f0SJiri Benc struct dentry *aid; 478e9f207f0SJiri Benc struct dentry *ap_capab; 479e9f207f0SJiri Benc struct dentry *capab; 480e9f207f0SJiri Benc struct dentry *extra_ie_len; 481e9f207f0SJiri Benc struct dentry *auth_tries; 482e9f207f0SJiri Benc struct dentry *assoc_tries; 483e9f207f0SJiri Benc struct dentry *auth_algs; 484e9f207f0SJiri Benc struct dentry *auth_alg; 485e9f207f0SJiri Benc struct dentry *auth_transaction; 486e9f207f0SJiri Benc struct dentry *flags; 487ee385855SLuis Carlos Cobo struct dentry *num_beacons_sta; 48893015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 48993015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 490e9f207f0SJiri Benc } sta; 491e9f207f0SJiri Benc struct { 492e9f207f0SJiri Benc struct dentry *drop_unencrypted; 493e9f207f0SJiri Benc struct dentry *num_sta_ps; 494e9f207f0SJiri Benc struct dentry *dtim_count; 495e9f207f0SJiri Benc struct dentry *num_beacons; 496e9f207f0SJiri Benc struct dentry *force_unicast_rateidx; 497e9f207f0SJiri Benc struct dentry *max_ratectrl_rateidx; 498e9f207f0SJiri Benc struct dentry *num_buffered_multicast; 499e9f207f0SJiri Benc } ap; 500e9f207f0SJiri Benc struct { 501e9f207f0SJiri Benc struct dentry *drop_unencrypted; 502e9f207f0SJiri Benc struct dentry *peer; 50393015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 50493015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 505e9f207f0SJiri Benc } wds; 506e9f207f0SJiri Benc struct { 507e9f207f0SJiri Benc struct dentry *drop_unencrypted; 50893015f0fSJouni Malinen struct dentry *force_unicast_rateidx; 50993015f0fSJouni Malinen struct dentry *max_ratectrl_rateidx; 510e9f207f0SJiri Benc } vlan; 511e9f207f0SJiri Benc struct { 512e9f207f0SJiri Benc struct dentry *mode; 513e9f207f0SJiri Benc } monitor; 514e9f207f0SJiri Benc } debugfs; 5152b58b209SJouni Malinen struct { 5162b58b209SJouni Malinen struct dentry *default_key; 5172b58b209SJouni Malinen } common_debugfs; 518ee385855SLuis Carlos Cobo 519ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH 520ee385855SLuis Carlos Cobo struct dentry *mesh_stats_dir; 521ee385855SLuis Carlos Cobo struct { 522ee385855SLuis Carlos Cobo struct dentry *fwded_frames; 523ee385855SLuis Carlos Cobo struct dentry *dropped_frames_ttl; 524ee385855SLuis Carlos Cobo struct dentry *dropped_frames_no_route; 525ee385855SLuis Carlos Cobo struct dentry *estab_plinks; 526ee385855SLuis Carlos Cobo struct timer_list mesh_path_timer; 527ee385855SLuis Carlos Cobo } mesh_stats; 528ee385855SLuis Carlos Cobo 529ee385855SLuis Carlos Cobo struct dentry *mesh_config_dir; 530ee385855SLuis Carlos Cobo struct { 531ee385855SLuis Carlos Cobo struct dentry *dot11MeshRetryTimeout; 532ee385855SLuis Carlos Cobo struct dentry *dot11MeshConfirmTimeout; 533ee385855SLuis Carlos Cobo struct dentry *dot11MeshHoldingTimeout; 534ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxRetries; 535ee385855SLuis Carlos Cobo struct dentry *dot11MeshTTL; 536ee385855SLuis Carlos Cobo struct dentry *auto_open_plinks; 537ee385855SLuis Carlos Cobo struct dentry *dot11MeshMaxPeerLinks; 538ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPactivePathTimeout; 539ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPpreqMinInterval; 540ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPnetDiameterTraversalTime; 541ee385855SLuis Carlos Cobo struct dentry *dot11MeshHWMPmaxPREQretries; 542ee385855SLuis Carlos Cobo struct dentry *path_refresh_time; 543ee385855SLuis Carlos Cobo struct dentry *min_discovery_timeout; 544ee385855SLuis Carlos Cobo } mesh_config; 545ee385855SLuis Carlos Cobo #endif 546ee385855SLuis Carlos Cobo 547e9f207f0SJiri Benc #endif 54832bfd35dSJohannes Berg /* must be last, dynamically sized area in this! */ 54932bfd35dSJohannes Berg struct ieee80211_vif vif; 550f0706e82SJiri Benc }; 551f0706e82SJiri Benc 55232bfd35dSJohannes Berg static inline 55332bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) 55432bfd35dSJohannes Berg { 55532bfd35dSJohannes Berg return container_of(p, struct ieee80211_sub_if_data, vif); 55632bfd35dSJohannes Berg } 55732bfd35dSJohannes Berg 558472dbc45SJohannes Berg static inline void 559472dbc45SJohannes Berg ieee80211_sdata_set_mesh_id(struct ieee80211_sub_if_data *sdata, 560472dbc45SJohannes Berg u8 mesh_id_len, u8 *mesh_id) 561472dbc45SJohannes Berg { 562472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH 563472dbc45SJohannes Berg struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 564472dbc45SJohannes Berg ifmsh->mesh_id_len = mesh_id_len; 565472dbc45SJohannes Berg memcpy(ifmsh->mesh_id, mesh_id, mesh_id_len); 566472dbc45SJohannes Berg #else 567472dbc45SJohannes Berg WARN_ON(1); 568472dbc45SJohannes Berg #endif 569472dbc45SJohannes Berg } 570472dbc45SJohannes Berg 571f0706e82SJiri Benc enum { 572f0706e82SJiri Benc IEEE80211_RX_MSG = 1, 573f0706e82SJiri Benc IEEE80211_TX_STATUS_MSG = 2, 574eadc8d9eSRon Rindjunsky IEEE80211_DELBA_MSG = 3, 575eadc8d9eSRon Rindjunsky IEEE80211_ADDBA_MSG = 4, 576f0706e82SJiri Benc }; 577f0706e82SJiri Benc 57851cb6db0SDavid S. Miller /* maximum number of hardware queues we support. */ 57951cb6db0SDavid S. Miller #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES) 58051cb6db0SDavid S. Miller 581f0706e82SJiri Benc struct ieee80211_local { 582f0706e82SJiri Benc /* embed the driver visible part. 583f0706e82SJiri Benc * don't cast (use the static inlines below), but we keep 584f0706e82SJiri Benc * it first anyway so they become a no-op */ 585f0706e82SJiri Benc struct ieee80211_hw hw; 586f0706e82SJiri Benc 587f0706e82SJiri Benc const struct ieee80211_ops *ops; 588f0706e82SJiri Benc 58951cb6db0SDavid S. Miller unsigned long queue_pool[BITS_TO_LONGS(QD_MAX_QUEUES)]; 59051cb6db0SDavid S. Miller 591f0706e82SJiri Benc struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 592f0706e82SJiri Benc int open_count; 5933d30d949SMichael Wu int monitors, cooked_mntrs; 5948cc9a739SMichael Wu /* number of interfaces with corresponding FIF_ flags */ 5958cc9a739SMichael Wu int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; 5964150c572SJohannes Berg unsigned int filter_flags; /* FIF_* */ 597f0706e82SJiri Benc struct iw_statistics wstats; 598f0706e82SJiri Benc u8 wstats_flags; 599d0709a65SJohannes Berg bool tim_in_locked_section; /* see ieee80211_beacon_get() */ 600b306f453SJohannes Berg int tx_headroom; /* required headroom for hardware/radiotap */ 601f0706e82SJiri Benc 602f0706e82SJiri Benc /* Tasklet and skb queue to process calls from IRQ mode. All frames 603f0706e82SJiri Benc * added to skb_queue will be processed, but frames in 604f0706e82SJiri Benc * skb_queue_unreliable may be dropped if the total length of these 605f0706e82SJiri Benc * queues increases over the limit. */ 606f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128 607f0706e82SJiri Benc struct tasklet_struct tasklet; 608f0706e82SJiri Benc struct sk_buff_head skb_queue; 609f0706e82SJiri Benc struct sk_buff_head skb_queue_unreliable; 610f0706e82SJiri Benc 611d0709a65SJohannes Berg /* Station data */ 612d0709a65SJohannes Berg /* 613d0709a65SJohannes Berg * The lock only protects the list, hash, timer and counter 614d0709a65SJohannes Berg * against manipulation, reads are done in RCU. Additionally, 615b16bd15cSJohannes Berg * the lock protects each BSS's TIM bitmap. 616d0709a65SJohannes Berg */ 617d0709a65SJohannes Berg spinlock_t sta_lock; 618d0709a65SJohannes Berg unsigned long num_sta; 619f0706e82SJiri Benc struct list_head sta_list; 620dc6676b7SJohannes Berg struct list_head sta_flush_list; 621dc6676b7SJohannes Berg struct work_struct sta_flush_work; 622f0706e82SJiri Benc struct sta_info *sta_hash[STA_HASH_SIZE]; 623f0706e82SJiri Benc struct timer_list sta_cleanup; 624f0706e82SJiri Benc 625e2530083SJohannes Berg unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; 626f8e79dddSTomas Winkler unsigned long queues_pending_run[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; 627eefce91aSJohannes Berg struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES]; 628f0706e82SJiri Benc struct tasklet_struct tx_pending_tasklet; 629f0706e82SJiri Benc 630f0706e82SJiri Benc /* number of interfaces with corresponding IFF_ flags */ 63153918994SJohannes Berg atomic_t iff_allmultis, iff_promiscs; 632f0706e82SJiri Benc 633f0706e82SJiri Benc struct rate_control_ref *rate_ctrl; 634f0706e82SJiri Benc 635f0706e82SJiri Benc int rts_threshold; 636f0706e82SJiri Benc int fragmentation_threshold; 637f0706e82SJiri Benc int short_retry_limit; /* dot11ShortRetryLimit */ 638f0706e82SJiri Benc int long_retry_limit; /* dot11LongRetryLimit */ 639f0706e82SJiri Benc 640f0706e82SJiri Benc struct crypto_blkcipher *wep_tx_tfm; 641f0706e82SJiri Benc struct crypto_blkcipher *wep_rx_tfm; 642f0706e82SJiri Benc u32 wep_iv; 643f0706e82SJiri Benc 64479010420SJohannes Berg struct list_head interfaces; 64579010420SJohannes Berg 646b16bd15cSJohannes Berg /* 647b16bd15cSJohannes Berg * Key lock, protects sdata's key_list and sta_info's 648b16bd15cSJohannes Berg * key pointers (write access, they're RCU.) 649b16bd15cSJohannes Berg */ 650b16bd15cSJohannes Berg spinlock_t key_lock; 651b16bd15cSJohannes Berg 652b16bd15cSJohannes Berg 653c2b13452SJohannes Berg /* Scanning and BSS list */ 654c2b13452SJohannes Berg bool sw_scanning, hw_scanning; 655f0706e82SJiri Benc int scan_channel_idx; 6568318d78aSJohannes Berg enum ieee80211_band scan_band; 6578318d78aSJohannes Berg 658f0706e82SJiri Benc enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; 659f0706e82SJiri Benc unsigned long last_scan_completed; 660f0706e82SJiri Benc struct delayed_work scan_work; 661491775a5SJohannes Berg struct ieee80211_sub_if_data *scan_sdata; 662f0706e82SJiri Benc struct ieee80211_channel *oper_channel, *scan_channel; 663f0706e82SJiri Benc u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; 664f0706e82SJiri Benc size_t scan_ssid_len; 665c2b13452SJohannes Berg struct list_head bss_list; 666c2b13452SJohannes Berg struct ieee80211_bss *bss_hash[STA_HASH_SIZE]; 667c2b13452SJohannes Berg spinlock_t bss_lock; 668f0706e82SJiri Benc 669f0706e82SJiri Benc /* SNMP counters */ 670f0706e82SJiri Benc /* dot11CountersTable */ 671f0706e82SJiri Benc u32 dot11TransmittedFragmentCount; 672f0706e82SJiri Benc u32 dot11MulticastTransmittedFrameCount; 673f0706e82SJiri Benc u32 dot11FailedCount; 674f0706e82SJiri Benc u32 dot11RetryCount; 675f0706e82SJiri Benc u32 dot11MultipleRetryCount; 676f0706e82SJiri Benc u32 dot11FrameDuplicateCount; 677f0706e82SJiri Benc u32 dot11ReceivedFragmentCount; 678f0706e82SJiri Benc u32 dot11MulticastReceivedFrameCount; 679f0706e82SJiri Benc u32 dot11TransmittedFrameCount; 680f0706e82SJiri Benc u32 dot11WEPUndecryptableCount; 681f0706e82SJiri Benc 682f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS 683f0706e82SJiri Benc int tx_led_counter, rx_led_counter; 684cdcb006fSIvo van Doorn struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; 685cdcb006fSIvo van Doorn char tx_led_name[32], rx_led_name[32], 686cdcb006fSIvo van Doorn assoc_led_name[32], radio_led_name[32]; 687f0706e82SJiri Benc #endif 688f0706e82SJiri Benc 689e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 690e9f207f0SJiri Benc struct work_struct sta_debugfs_add; 691e9f207f0SJiri Benc #endif 692e9f207f0SJiri Benc 693f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 694f0706e82SJiri Benc /* TX/RX handler statistics */ 695f0706e82SJiri Benc unsigned int tx_handlers_drop; 696f0706e82SJiri Benc unsigned int tx_handlers_queued; 697f0706e82SJiri Benc unsigned int tx_handlers_drop_unencrypted; 698f0706e82SJiri Benc unsigned int tx_handlers_drop_fragment; 699f0706e82SJiri Benc unsigned int tx_handlers_drop_wep; 700f0706e82SJiri Benc unsigned int tx_handlers_drop_not_assoc; 701f0706e82SJiri Benc unsigned int tx_handlers_drop_unauth_port; 702f0706e82SJiri Benc unsigned int rx_handlers_drop; 703f0706e82SJiri Benc unsigned int rx_handlers_queued; 704f0706e82SJiri Benc unsigned int rx_handlers_drop_nullfunc; 705f0706e82SJiri Benc unsigned int rx_handlers_drop_defrag; 706f0706e82SJiri Benc unsigned int rx_handlers_drop_short; 707f0706e82SJiri Benc unsigned int rx_handlers_drop_passive_scan; 708f0706e82SJiri Benc unsigned int tx_expand_skb_head; 709f0706e82SJiri Benc unsigned int tx_expand_skb_head_cloned; 710f0706e82SJiri Benc unsigned int rx_expand_skb_head; 711f0706e82SJiri Benc unsigned int rx_expand_skb_head2; 712f0706e82SJiri Benc unsigned int rx_handlers_fragments; 713f0706e82SJiri Benc unsigned int tx_status_drop; 714f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++ 715f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */ 716f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0) 717f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ 718f0706e82SJiri Benc 719f0706e82SJiri Benc 720f0706e82SJiri Benc int total_ps_buffered; /* total number of all buffered unicast and 721f0706e82SJiri Benc * multicast packets for power saving stations 722f0706e82SJiri Benc */ 723f0706e82SJiri Benc int wifi_wme_noack_test; 724f0706e82SJiri Benc unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 725f0706e82SJiri Benc 726e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS 727e9f207f0SJiri Benc struct local_debugfsdentries { 728e9f207f0SJiri Benc struct dentry *frequency; 729e9f207f0SJiri Benc struct dentry *antenna_sel_tx; 730e9f207f0SJiri Benc struct dentry *antenna_sel_rx; 731e9f207f0SJiri Benc struct dentry *rts_threshold; 732e9f207f0SJiri Benc struct dentry *fragmentation_threshold; 733e9f207f0SJiri Benc struct dentry *short_retry_limit; 734e9f207f0SJiri Benc struct dentry *long_retry_limit; 735e9f207f0SJiri Benc struct dentry *total_ps_buffered; 736e9f207f0SJiri Benc struct dentry *wep_iv; 737e9f207f0SJiri Benc struct dentry *statistics; 738e9f207f0SJiri Benc struct local_debugfsdentries_statsdentries { 739e9f207f0SJiri Benc struct dentry *transmitted_fragment_count; 740e9f207f0SJiri Benc struct dentry *multicast_transmitted_frame_count; 741e9f207f0SJiri Benc struct dentry *failed_count; 742e9f207f0SJiri Benc struct dentry *retry_count; 743e9f207f0SJiri Benc struct dentry *multiple_retry_count; 744e9f207f0SJiri Benc struct dentry *frame_duplicate_count; 745e9f207f0SJiri Benc struct dentry *received_fragment_count; 746e9f207f0SJiri Benc struct dentry *multicast_received_frame_count; 747e9f207f0SJiri Benc struct dentry *transmitted_frame_count; 748e9f207f0SJiri Benc struct dentry *wep_undecryptable_count; 749e9f207f0SJiri Benc struct dentry *num_scans; 750e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 751e9f207f0SJiri Benc struct dentry *tx_handlers_drop; 752e9f207f0SJiri Benc struct dentry *tx_handlers_queued; 753e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unencrypted; 754e9f207f0SJiri Benc struct dentry *tx_handlers_drop_fragment; 755e9f207f0SJiri Benc struct dentry *tx_handlers_drop_wep; 756e9f207f0SJiri Benc struct dentry *tx_handlers_drop_not_assoc; 757e9f207f0SJiri Benc struct dentry *tx_handlers_drop_unauth_port; 758e9f207f0SJiri Benc struct dentry *rx_handlers_drop; 759e9f207f0SJiri Benc struct dentry *rx_handlers_queued; 760e9f207f0SJiri Benc struct dentry *rx_handlers_drop_nullfunc; 761e9f207f0SJiri Benc struct dentry *rx_handlers_drop_defrag; 762e9f207f0SJiri Benc struct dentry *rx_handlers_drop_short; 763e9f207f0SJiri Benc struct dentry *rx_handlers_drop_passive_scan; 764e9f207f0SJiri Benc struct dentry *tx_expand_skb_head; 765e9f207f0SJiri Benc struct dentry *tx_expand_skb_head_cloned; 766e9f207f0SJiri Benc struct dentry *rx_expand_skb_head; 767e9f207f0SJiri Benc struct dentry *rx_expand_skb_head2; 768e9f207f0SJiri Benc struct dentry *rx_handlers_fragments; 769e9f207f0SJiri Benc struct dentry *tx_status_drop; 770e9f207f0SJiri Benc #endif 771e9f207f0SJiri Benc struct dentry *dot11ACKFailureCount; 772e9f207f0SJiri Benc struct dentry *dot11RTSFailureCount; 773e9f207f0SJiri Benc struct dentry *dot11FCSErrorCount; 774e9f207f0SJiri Benc struct dentry *dot11RTSSuccessCount; 775e9f207f0SJiri Benc } stats; 776e9f207f0SJiri Benc struct dentry *stations; 777e9f207f0SJiri Benc struct dentry *keys; 778e9f207f0SJiri Benc } debugfs; 779e9f207f0SJiri Benc #endif 780f0706e82SJiri Benc }; 781f0706e82SJiri Benc 7823e122be0SJohannes Berg static inline struct ieee80211_sub_if_data * 7833e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) 7843e122be0SJohannes Berg { 7853e122be0SJohannes Berg struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 7863e122be0SJohannes Berg 7873e122be0SJohannes Berg BUG_ON(!local || local->mdev == dev); 7883e122be0SJohannes Berg 7893e122be0SJohannes Berg return netdev_priv(dev); 7903e122be0SJohannes Berg } 7913e122be0SJohannes Berg 792eadc8d9eSRon Rindjunsky /* this struct represents 802.11n's RA/TID combination */ 793eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid { 794eadc8d9eSRon Rindjunsky u8 ra[ETH_ALEN]; 795eadc8d9eSRon Rindjunsky u16 tid; 796eadc8d9eSRon Rindjunsky }; 797eadc8d9eSRon Rindjunsky 798ee385855SLuis Carlos Cobo /* Parsed Information Elements */ 799ee385855SLuis Carlos Cobo struct ieee802_11_elems { 80043ac2ca3SJouni Malinen u8 *ie_start; 80143ac2ca3SJouni Malinen size_t total_len; 80243ac2ca3SJouni Malinen 803ee385855SLuis Carlos Cobo /* pointers to IEs */ 804ee385855SLuis Carlos Cobo u8 *ssid; 805ee385855SLuis Carlos Cobo u8 *supp_rates; 806ee385855SLuis Carlos Cobo u8 *fh_params; 807ee385855SLuis Carlos Cobo u8 *ds_params; 808ee385855SLuis Carlos Cobo u8 *cf_params; 809ee385855SLuis Carlos Cobo u8 *tim; 810ee385855SLuis Carlos Cobo u8 *ibss_params; 811ee385855SLuis Carlos Cobo u8 *challenge; 812ee385855SLuis Carlos Cobo u8 *wpa; 813ee385855SLuis Carlos Cobo u8 *rsn; 814ee385855SLuis Carlos Cobo u8 *erp_info; 815ee385855SLuis Carlos Cobo u8 *ext_supp_rates; 816ee385855SLuis Carlos Cobo u8 *wmm_info; 817ee385855SLuis Carlos Cobo u8 *wmm_param; 818ee385855SLuis Carlos Cobo u8 *ht_cap_elem; 819ee385855SLuis Carlos Cobo u8 *ht_info_elem; 820ee385855SLuis Carlos Cobo u8 *mesh_config; 821ee385855SLuis Carlos Cobo u8 *mesh_id; 822ee385855SLuis Carlos Cobo u8 *peer_link; 823ee385855SLuis Carlos Cobo u8 *preq; 824ee385855SLuis Carlos Cobo u8 *prep; 825ee385855SLuis Carlos Cobo u8 *perr; 826f2df3859SAssaf Krauss u8 *ch_switch_elem; 827f2df3859SAssaf Krauss u8 *country_elem; 828f2df3859SAssaf Krauss u8 *pwr_constr_elem; 829f2df3859SAssaf Krauss u8 *quiet_elem; /* first quite element */ 830ee385855SLuis Carlos Cobo 831ee385855SLuis Carlos Cobo /* length of them, respectively */ 832ee385855SLuis Carlos Cobo u8 ssid_len; 833ee385855SLuis Carlos Cobo u8 supp_rates_len; 834ee385855SLuis Carlos Cobo u8 fh_params_len; 835ee385855SLuis Carlos Cobo u8 ds_params_len; 836ee385855SLuis Carlos Cobo u8 cf_params_len; 837ee385855SLuis Carlos Cobo u8 tim_len; 838ee385855SLuis Carlos Cobo u8 ibss_params_len; 839ee385855SLuis Carlos Cobo u8 challenge_len; 840ee385855SLuis Carlos Cobo u8 wpa_len; 841ee385855SLuis Carlos Cobo u8 rsn_len; 842ee385855SLuis Carlos Cobo u8 erp_info_len; 843ee385855SLuis Carlos Cobo u8 ext_supp_rates_len; 844ee385855SLuis Carlos Cobo u8 wmm_info_len; 845ee385855SLuis Carlos Cobo u8 wmm_param_len; 846ee385855SLuis Carlos Cobo u8 ht_cap_elem_len; 847ee385855SLuis Carlos Cobo u8 ht_info_elem_len; 848ee385855SLuis Carlos Cobo u8 mesh_config_len; 849ee385855SLuis Carlos Cobo u8 mesh_id_len; 850ee385855SLuis Carlos Cobo u8 peer_link_len; 851ee385855SLuis Carlos Cobo u8 preq_len; 852ee385855SLuis Carlos Cobo u8 prep_len; 853ee385855SLuis Carlos Cobo u8 perr_len; 854f2df3859SAssaf Krauss u8 ch_switch_elem_len; 855f2df3859SAssaf Krauss u8 country_elem_len; 856f2df3859SAssaf Krauss u8 pwr_constr_elem_len; 857f2df3859SAssaf Krauss u8 quiet_elem_len; 858f2df3859SAssaf Krauss u8 num_of_quiet_elem; /* can be more the one */ 859ee385855SLuis Carlos Cobo }; 860ee385855SLuis Carlos Cobo 861f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local( 862f0706e82SJiri Benc struct ieee80211_hw *hw) 863f0706e82SJiri Benc { 864f0706e82SJiri Benc return container_of(hw, struct ieee80211_local, hw); 865f0706e82SJiri Benc } 866f0706e82SJiri Benc 867f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw( 868f0706e82SJiri Benc struct ieee80211_local *local) 869f0706e82SJiri Benc { 870f0706e82SJiri Benc return &local->hw; 871f0706e82SJiri Benc } 872f0706e82SJiri Benc 873f0706e82SJiri Benc struct sta_attribute { 874f0706e82SJiri Benc struct attribute attr; 875f0706e82SJiri Benc ssize_t (*show)(const struct sta_info *, char *buf); 876f0706e82SJiri Benc ssize_t (*store)(struct sta_info *, const char *buf, size_t count); 877f0706e82SJiri Benc }; 878f0706e82SJiri Benc 879571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) 880571ecf67SJohannes Berg { 881571ecf67SJohannes Berg return compare_ether_addr(raddr, addr) == 0 || 882571ecf67SJohannes Berg is_broadcast_ether_addr(raddr); 883571ecf67SJohannes Berg } 884571ecf67SJohannes Berg 885571ecf67SJohannes Berg 886f0706e82SJiri Benc int ieee80211_hw_config(struct ieee80211_local *local); 8879d139c81SJohannes Berg int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed); 8885cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx); 88938668c05STomas Winkler u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht, 890d3c990fbSRon Rindjunsky struct ieee80211_ht_info *req_ht_cap, 891d3c990fbSRon Rindjunsky struct ieee80211_ht_bss_info *req_bss_cap); 8929c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 8939c6bd790SJohannes Berg u32 changed); 894f0706e82SJiri Benc 8959c6bd790SJohannes Berg /* wireless extensions */ 896f0706e82SJiri Benc extern const struct iw_handler_def ieee80211_iw_handler_def; 89765b53e4cSDavid S. Miller 8989c6bd790SJohannes Berg /* STA/IBSS code */ 8999c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 900c2b13452SJohannes Berg void ieee80211_scan_work(struct work_struct *work); 901f698d856SJasper Bryant-Greene void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 902f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 903f698d856SJasper Bryant-Greene int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len); 904f698d856SJasper Bryant-Greene int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len); 905f698d856SJasper Bryant-Greene int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid); 906f698d856SJasper Bryant-Greene void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata, 907f0706e82SJiri Benc struct ieee80211_if_sta *ifsta); 9089c6bd790SJohannes Berg struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 9099c6bd790SJohannes Berg struct sk_buff *skb, u8 *bssid, 9109c6bd790SJohannes Berg u8 *addr, u64 supp_rates); 9119c6bd790SJohannes Berg int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason); 9129c6bd790SJohannes Berg int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); 9139c6bd790SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 9149c6bd790SJohannes Berg u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 9159c6bd790SJohannes Berg struct ieee802_11_elems *elems, 9169c6bd790SJohannes Berg enum ieee80211_band band); 9179c6bd790SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 9189c6bd790SJohannes Berg u8 *ssid, size_t ssid_len); 9199c6bd790SJohannes Berg 9209c6bd790SJohannes Berg /* scan/BSS handling */ 921c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, 922c2b13452SJohannes Berg u8 *ssid, size_t ssid_len); 923c2b13452SJohannes Berg int ieee80211_scan_results(struct ieee80211_local *local, 924ccc58057SDavid S. Miller struct iw_request_info *info, 925ccc58057SDavid S. Miller char *buf, size_t len); 926c2b13452SJohannes Berg ieee80211_rx_result 927c2b13452SJohannes Berg ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, 928c2b13452SJohannes Berg struct sk_buff *skb, 929f0706e82SJiri Benc struct ieee80211_rx_status *rx_status); 9303e122be0SJohannes Berg void ieee80211_rx_bss_list_init(struct ieee80211_local *local); 9313e122be0SJohannes Berg void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local); 932c2b13452SJohannes Berg int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, 933c2b13452SJohannes Berg char *ie, size_t len); 9349c6bd790SJohannes Berg 9350a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); 936c2b13452SJohannes Berg int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata, 9370a51b27eSJohannes Berg u8 *ssid, size_t ssid_len); 938c2b13452SJohannes Berg struct ieee80211_bss * 93998c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local, 94098c8fccfSJohannes Berg struct ieee80211_rx_status *rx_status, 94198c8fccfSJohannes Berg struct ieee80211_mgmt *mgmt, 94298c8fccfSJohannes Berg size_t len, 94398c8fccfSJohannes Berg struct ieee802_11_elems *elems, 94498c8fccfSJohannes Berg int freq, bool beacon); 945c2b13452SJohannes Berg struct ieee80211_bss * 9465484e237SJohannes Berg ieee80211_rx_bss_add(struct ieee80211_local *local, u8 *bssid, int freq, 9475484e237SJohannes Berg u8 *ssid, u8 ssid_len); 948c2b13452SJohannes Berg struct ieee80211_bss * 9495484e237SJohannes Berg ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, 9505484e237SJohannes Berg u8 *ssid, u8 ssid_len); 95198c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local, 952c2b13452SJohannes Berg struct ieee80211_bss *bss); 953ee385855SLuis Carlos Cobo 9543e122be0SJohannes Berg /* interface handling */ 95575636525SJohannes Berg void ieee80211_if_setup(struct net_device *dev); 9563e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name, 95775636525SJohannes Berg struct net_device **new_dev, enum ieee80211_if_types type, 958ee385855SLuis Carlos Cobo struct vif_params *params); 959f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, 96075636525SJohannes Berg enum ieee80211_if_types type); 961f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata); 96275636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local); 963f0706e82SJiri Benc 964e2ebc74dSJohannes Berg /* tx handling */ 965e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local); 966e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data); 967e2ebc74dSJohannes Berg int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); 968e2ebc74dSJohannes Berg int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); 969e2ebc74dSJohannes Berg int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); 970e2ebc74dSJohannes Berg 971de1ede7aSJohannes Berg /* HT */ 972de1ede7aSJohannes Berg int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, 973de1ede7aSJohannes Berg struct ieee80211_ht_info *ht_info); 974de1ede7aSJohannes Berg int ieee80211_ht_addt_info_ie_to_ht_bss_info( 975de1ede7aSJohannes Berg struct ieee80211_ht_addt_info *ht_add_info_ie, 976de1ede7aSJohannes Berg struct ieee80211_ht_bss_info *bss_info); 977de1ede7aSJohannes Berg void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn); 978de1ede7aSJohannes Berg 979de1ede7aSJohannes Berg void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, 980de1ede7aSJohannes Berg u16 tid, u16 initiator, u16 reason); 981de1ede7aSJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr); 982de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, 983de1ede7aSJohannes Berg struct sta_info *sta, 984de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, size_t len); 985de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local, 986de1ede7aSJohannes Berg struct sta_info *sta, 987de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, 988de1ede7aSJohannes Berg size_t len); 989de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local, 990de1ede7aSJohannes Berg struct sta_info *sta, 991de1ede7aSJohannes Berg struct ieee80211_mgmt *mgmt, 992de1ede7aSJohannes Berg size_t len); 993de1ede7aSJohannes Berg 99439192c0bSJohannes Berg /* Spectrum management */ 99539192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, 99639192c0bSJohannes Berg struct ieee80211_mgmt *mgmt, 99739192c0bSJohannes Berg size_t len); 99839192c0bSJohannes Berg 999c2d1560aSJohannes Berg /* utility functions/constants */ 1000c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */ 1001c2d1560aSJohannes Berg extern const unsigned char rfc1042_header[6]; 1002c2d1560aSJohannes Berg extern const unsigned char bridge_tunnel_header[6]; 100371364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 100471364716SRon Rindjunsky enum ieee80211_if_types type); 1005c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, 1006c2d1560aSJohannes Berg int rate, int erp, int short_preamble); 1007f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, 1008eb063c17SJohannes Berg struct ieee80211_hdr *hdr); 10095825fe10SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); 1010e50db65cSJohannes Berg void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 1011e50db65cSJohannes Berg int encrypt); 10129c6bd790SJohannes Berg void ieee802_11_parse_elems(u8 *start, size_t len, 10139c6bd790SJohannes Berg struct ieee802_11_elems *elems); 1014e16751c3SJohannes Berg int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq); 101596dd22acSJohannes Berg u64 ieee80211_mandatory_rates(struct ieee80211_local *local, 101696dd22acSJohannes Berg enum ieee80211_band band); 1017f0706e82SJiri Benc 1018f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE 1019d9e8a70fSJohannes Berg #define debug_noinline noinline 1020d9e8a70fSJohannes Berg #else 1021d9e8a70fSJohannes Berg #define debug_noinline 1022d9e8a70fSJohannes Berg #endif 1023d9e8a70fSJohannes Berg 1024f0706e82SJiri Benc #endif /* IEEE80211_I_H */ 1025