]> err.no Git - linux-2.6/blobdiff - net/mac80211/ieee80211_i.h
mac80211: QoS related cleanups
[linux-2.6] / net / mac80211 / ieee80211_i.h
index 49466b6996d18e468cc6ee43c87c1b115e259982..d82ed20a344c1c9f89c42301b3407fbfe1ebe93c 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/spinlock.h>
 #include <linux/etherdevice.h>
 #include <net/wireless.h>
-#include "ieee80211_key.h"
+#include "key.h"
 #include "sta_info.h"
 
 /* ieee80211.o internal definitions, etc. These are not included into
@@ -35,9 +35,9 @@
 
 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
 
-struct ieee80211_local;
+#define IEEE80211_FC(type, subtype) cpu_to_le16(type | subtype)
 
-#define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
+struct ieee80211_local;
 
 /* Maximum number of broadcast/multicast frames to buffer when some of the
  * associated stations are using power saving. */
@@ -73,11 +73,12 @@ struct ieee80211_fragment_entry {
 struct ieee80211_sta_bss {
        struct list_head list;
        struct ieee80211_sta_bss *hnext;
+       size_t ssid_len;
+
        atomic_t users;
 
        u8 bssid[ETH_ALEN];
        u8 ssid[IEEE80211_MAX_SSID_LEN];
-       size_t ssid_len;
        u16 capability; /* host byte order */
        enum ieee80211_band band;
        int freq;
@@ -93,16 +94,15 @@ struct ieee80211_sta_bss {
 #ifdef CONFIG_MAC80211_MESH
        u8 *mesh_id;
        size_t mesh_id_len;
-#endif
-       /* mesh_cfg left out the ifdef to reduce clutter on bss handling */
        u8 *mesh_cfg;
+#endif
 #define IEEE80211_MAX_SUPP_RATES 32
        u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
        size_t supp_rates_len;
-       int beacon_int;
        u64 timestamp;
+       int beacon_int;
 
-       int probe_resp;
+       bool probe_resp;
        unsigned long last_update;
 
        /* during assocation, we save an ERP value from a probe response so
@@ -113,65 +113,98 @@ struct ieee80211_sta_bss {
        u8 erp_value;
 };
 
+static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
+{
+#ifdef CONFIG_MAC80211_MESH
+       return bss->mesh_cfg;
+#endif
+       return NULL;
+}
+
+static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss)
+{
+#ifdef CONFIG_MAC80211_MESH
+       return bss->mesh_id;
+#endif
+       return NULL;
+}
+
+static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss)
+{
+#ifdef CONFIG_MAC80211_MESH
+       return bss->mesh_id_len;
+#endif
+       return 0;
+}
+
 
 typedef unsigned __bitwise__ ieee80211_tx_result;
 #define TX_CONTINUE    ((__force ieee80211_tx_result) 0u)
 #define TX_DROP                ((__force ieee80211_tx_result) 1u)
 #define TX_QUEUED      ((__force ieee80211_tx_result) 2u)
 
+#define IEEE80211_TX_FRAGMENTED                BIT(0)
+#define IEEE80211_TX_UNICAST           BIT(1)
+#define IEEE80211_TX_PS_BUFFERED       BIT(2)
+#define IEEE80211_TX_PROBE_LAST_FRAG   BIT(3)
+#define IEEE80211_TX_INJECTED          BIT(4)
+
+struct ieee80211_tx_data {
+       struct sk_buff *skb;
+       struct net_device *dev;
+       struct ieee80211_local *local;
+       struct ieee80211_sub_if_data *sdata;
+       struct sta_info *sta;
+       struct ieee80211_key *key;
+
+       struct ieee80211_tx_control *control;
+       struct ieee80211_channel *channel;
+       struct ieee80211_rate *rate;
+       /* use this rate (if set) for last fragment; rate can
+        * be set to lower rate for the first fragments, e.g.,
+        * when using CTS protection with IEEE 802.11g. */
+       struct ieee80211_rate *last_frag_rate;
+
+       /* Extra fragments (in addition to the first fragment
+        * in skb) */
+       struct sk_buff **extra_frag;
+       int num_extra_frag;
+
+       u16 fc, ethertype;
+       unsigned int flags;
+};
+
+
 typedef unsigned __bitwise__ ieee80211_rx_result;
 #define RX_CONTINUE            ((__force ieee80211_rx_result) 0u)
 #define RX_DROP_UNUSABLE       ((__force ieee80211_rx_result) 1u)
 #define RX_DROP_MONITOR                ((__force ieee80211_rx_result) 2u)
 #define RX_QUEUED              ((__force ieee80211_rx_result) 3u)
 
-
-/* flags used in struct ieee80211_txrx_data.flags */
-/* whether the MSDU was fragmented */
-#define IEEE80211_TXRXD_FRAGMENTED             BIT(0)
-#define IEEE80211_TXRXD_TXUNICAST              BIT(1)
-#define IEEE80211_TXRXD_TXPS_BUFFERED          BIT(2)
-#define IEEE80211_TXRXD_TXPROBE_LAST_FRAG      BIT(3)
-#define IEEE80211_TXRXD_RXIN_SCAN              BIT(4)
+#define IEEE80211_RX_IN_SCAN           BIT(0)
 /* frame is destined to interface currently processed (incl. multicast frames) */
-#define IEEE80211_TXRXD_RXRA_MATCH             BIT(5)
-#define IEEE80211_TXRXD_TX_INJECTED            BIT(6)
-#define IEEE80211_TXRXD_RX_AMSDU               BIT(7)
-#define IEEE80211_TXRXD_RX_CMNTR_REPORTED      BIT(8)
-struct ieee80211_txrx_data {
+#define IEEE80211_RX_RA_MATCH          BIT(1)
+#define IEEE80211_RX_AMSDU             BIT(2)
+#define IEEE80211_RX_CMNTR_REPORTED    BIT(3)
+#define IEEE80211_RX_FRAGMENTED                BIT(4)
+
+struct ieee80211_rx_data {
        struct sk_buff *skb;
        struct net_device *dev;
        struct ieee80211_local *local;
        struct ieee80211_sub_if_data *sdata;
        struct sta_info *sta;
-       u16 fc, ethertype;
        struct ieee80211_key *key;
+       struct ieee80211_rx_status *status;
+       struct ieee80211_rate *rate;
+
+       u16 fc, ethertype;
        unsigned int flags;
-       union {
-               struct {
-                       struct ieee80211_tx_control *control;
-                       struct ieee80211_channel *channel;
-                       struct ieee80211_rate *rate;
-                       /* use this rate (if set) for last fragment; rate can
-                        * be set to lower rate for the first fragments, e.g.,
-                        * when using CTS protection with IEEE 802.11g. */
-                       struct ieee80211_rate *last_frag_rate;
-
-                       /* Extra fragments (in addition to the first fragment
-                        * in skb) */
-                       int num_extra_frag;
-                       struct sk_buff **extra_frag;
-               } tx;
-               struct {
-                       struct ieee80211_rx_status *status;
-                       struct ieee80211_rate *rate;
-                       int sent_ps_buffered;
-                       int queue;
-                       int load;
-                       u32 tkip_iv32;
-                       u16 tkip_iv16;
-               } rx;
-       } u;
+       int sent_ps_buffered;
+       int queue;
+       int load;
+       u32 tkip_iv32;
+       u16 tkip_iv16;
 };
 
 /* flags used in struct ieee80211_tx_packet_data.flags */
@@ -191,9 +224,9 @@ struct ieee80211_tx_packet_data {
 struct ieee80211_tx_stored_packet {
        struct ieee80211_tx_control control;
        struct sk_buff *skb;
-       int num_extra_frag;
        struct sk_buff **extra_frag;
        struct ieee80211_rate *last_frag_rate;
+       int num_extra_frag;
        unsigned int last_frag_rate_ctrl_probe;
 };
 
@@ -215,8 +248,8 @@ struct ieee80211_if_ap {
         * bitmap_empty :)
         * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
        u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
-       atomic_t num_sta_ps; /* number of stations in PS mode */
        struct sk_buff_head ps_bc_buf;
+       atomic_t num_sta_ps; /* number of stations in PS mode */
        int dtim_count;
        int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
        int max_ratectrl_rateidx; /* max TX rateidx for rate control */
@@ -224,8 +257,8 @@ struct ieee80211_if_ap {
 };
 
 struct ieee80211_if_wds {
-       u8 remote_addr[ETH_ALEN];
        struct sta_info *sta;
+       u8 remote_addr[ETH_ALEN];
 };
 
 struct ieee80211_if_vlan {
@@ -233,7 +266,6 @@ struct ieee80211_if_vlan {
        struct list_head list;
 };
 
-#ifdef CONFIG_MAC80211_MESH
 struct mesh_stats {
        __u32 fwded_frames;             /* Mesh forwarded frames */
        __u32 dropped_frames_ttl;       /* Not transmitted since mesh_ttl == 0*/
@@ -249,7 +281,6 @@ struct mesh_preq_queue {
        u8 flags;
 };
 
-
 struct mesh_config {
        /* Timeouts in ms */
        /* Mesh plink management parameters */
@@ -261,14 +292,14 @@ struct mesh_config {
        u8  dot11MeshTTL;
        bool auto_open_plinks;
        /* HWMP parameters */
-       u32 dot11MeshHWMPactivePathTimeout;
-       u16 dot11MeshHWMPpreqMinInterval;
-       u16 dot11MeshHWMPnetDiameterTraversalTime;
        u8  dot11MeshHWMPmaxPREQretries;
        u32 path_refresh_time;
        u16 min_discovery_timeout;
+       u32 dot11MeshHWMPactivePathTimeout;
+       u16 dot11MeshHWMPpreqMinInterval;
+       u16 dot11MeshHWMPnetDiameterTraversalTime;
 };
-#endif
+
 
 /* flags used in struct ieee80211_if_sta.flags */
 #define IEEE80211_STA_SSID_SET         BIT(0)
@@ -285,23 +316,22 @@ struct mesh_config {
 #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
 #define IEEE80211_STA_PRIVACY_INVOKED  BIT(13)
 struct ieee80211_if_sta {
+       struct timer_list timer;
+       struct work_struct work;
+       u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
+       u8 ssid[IEEE80211_MAX_SSID_LEN];
        enum {
                IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
                IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
                IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED,
                IEEE80211_MESH_UP
        } state;
-       struct timer_list timer;
-       struct work_struct work;
-       u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
-       u8 ssid[IEEE80211_MAX_SSID_LEN];
        size_t ssid_len;
        u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
        size_t scan_ssid_len;
 #ifdef CONFIG_MAC80211_MESH
        struct timer_list mesh_path_timer;
        u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
-       bool accepting_plinks;
        size_t mesh_id_len;
        /* Active Path Selection Protocol Identifier */
        u8 mesh_pp_id[4];
@@ -324,7 +354,8 @@ struct ieee80211_if_sta {
        int preq_queue_len;
        struct mesh_stats mshstats;
        struct mesh_config mshcfg;
-       u8 mesh_seqnum[3];
+       u32 mesh_seqnum;
+       bool accepting_plinks;
 #endif
        u16 aid;
        u16 ap_capab, capab;
@@ -335,16 +366,18 @@ struct ieee80211_if_sta {
        u8 *assocreq_ies, *assocresp_ies;
        size_t assocreq_ies_len, assocresp_ies_len;
 
+       struct sk_buff_head skb_queue;
+
        int auth_tries, assoc_tries;
 
+       unsigned long request;
+
+       unsigned long last_probe;
+
        unsigned int flags;
 #define IEEE80211_STA_REQ_SCAN 0
 #define IEEE80211_STA_REQ_AUTH 1
 #define IEEE80211_STA_REQ_RUN  2
-       unsigned long request;
-       struct sk_buff_head skb_queue;
-
-       unsigned long last_probe;
 
 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
@@ -361,6 +394,22 @@ struct ieee80211_if_sta {
        int num_beacons; /* number of TXed beacon frames by this STA */
 };
 
+static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta,
+                                               u8 mesh_id_len, u8 *mesh_id)
+{
+#ifdef CONFIG_MAC80211_MESH
+       ifsta->mesh_id_len = mesh_id_len;
+       memcpy(ifsta->mesh_id, mesh_id, mesh_id_len);
+#endif
+}
+
+#ifdef CONFIG_MAC80211_MESH
+#define IEEE80211_IFSTA_MESH_CTR_INC(sta, name)        \
+       do { (sta)->mshstats.name++; } while (0)
+#else
+#define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
+       do { } while (0)
+#endif
 
 /* flags used in struct ieee80211_sub_if_data.flags */
 #define IEEE80211_SDATA_ALLMULTI       BIT(0)
@@ -472,7 +521,7 @@ struct ieee80211_sub_if_data {
                struct dentry *dropped_frames_ttl;
                struct dentry *dropped_frames_no_route;
                struct dentry *estab_plinks;
-       struct timer_list mesh_path_timer;
+               struct timer_list mesh_path_timer;
        } mesh_stats;
 
        struct dentry *mesh_config_dir;
@@ -529,6 +578,7 @@ struct ieee80211_local {
        unsigned int filter_flags; /* FIF_* */
        struct iw_statistics wstats;
        u8 wstats_flags;
+       bool tim_in_locked_section; /* see ieee80211_beacon_get() */
        int tx_headroom; /* required headroom for hardware/radiotap */
 
        enum {
@@ -546,15 +596,22 @@ struct ieee80211_local {
        struct sk_buff_head skb_queue;
        struct sk_buff_head skb_queue_unreliable;
 
-       /* Station data structures */
-       rwlock_t sta_lock; /* protects STA data structures */
-       int num_sta; /* number of stations in sta_list */
+       /* Station data */
+       /*
+        * The lock only protects the list, hash, timer and counter
+        * against manipulation, reads are done in RCU. Additionally,
+        * the lock protects each BSS's TIM bitmap.
+        */
+       spinlock_t sta_lock;
+       unsigned long num_sta;
        struct list_head sta_list;
+       struct list_head sta_flush_list;
+       struct work_struct sta_flush_work;
        struct sta_info *sta_hash[STA_HASH_SIZE];
        struct timer_list sta_cleanup;
 
-       unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
-       struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
+       unsigned long state[IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_AMPDU_QUEUES];
+       struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_AMPDU_QUEUES];
        struct tasklet_struct tx_pending_tasklet;
 
        /* number of interfaces with corresponding IFF_ flags */
@@ -577,6 +634,13 @@ struct ieee80211_local {
 
        struct list_head interfaces;
 
+       /*
+        * Key lock, protects sdata's key_list and sta_info's
+        * key pointers (write access, they're RCU.)
+        */
+       spinlock_t key_lock;
+
+
        bool sta_sw_scanning;
        bool sta_hw_scanning;
        int scan_channel_idx;
@@ -641,8 +705,6 @@ struct ieee80211_local {
        unsigned int rx_expand_skb_head2;
        unsigned int rx_handlers_fragments;
        unsigned int tx_status_drop;
-       unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
-       unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
 #define I802_DEBUG_INC(c) (c)++
 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
 #define I802_DEBUG_INC(c) do { } while (0)
@@ -700,8 +762,6 @@ struct ieee80211_local {
                        struct dentry *rx_expand_skb_head2;
                        struct dentry *rx_handlers_fragments;
                        struct dentry *tx_status_drop;
-                       struct dentry *wme_tx_queue;
-                       struct dentry *wme_rx_queue;
 #endif
                        struct dentry *dot11ACKFailureCount;
                        struct dentry *dot11RTSFailureCount;
@@ -805,12 +865,11 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
 int ieee80211_hw_config(struct ieee80211_local *local);
 int ieee80211_if_config(struct net_device *dev);
 int ieee80211_if_config_beacon(struct net_device *dev);
-void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
-int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
+void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
 void ieee80211_if_setup(struct net_device *dev);
-int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
-                          struct ieee80211_ht_info *req_ht_cap,
-                          struct ieee80211_ht_bss_info *req_bss_cap);
+u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht,
+                       struct ieee80211_ht_info *req_ht_cap,
+                       struct ieee80211_ht_bss_info *req_bss_cap);
 
 /* ieee80211_ioctl.c */
 extern const struct iw_handler_def ieee80211_iw_handler_def;
@@ -836,11 +895,8 @@ extern const struct iw_handler_def ieee80211_iw_handler_def;
 
 
 /* ieee80211_ioctl.c */
-int ieee80211_set_compression(struct ieee80211_local *local,
-                             struct net_device *dev, struct sta_info *sta);
 int ieee80211_set_freq(struct ieee80211_local *local, int freq);
 /* ieee80211_sta.c */
-#define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)
 void ieee80211_sta_timer(unsigned long data);
 void ieee80211_sta_work(struct work_struct *work);
 void ieee80211_sta_scan_work(struct work_struct *work);
@@ -859,9 +915,9 @@ ieee80211_rx_result ieee80211_sta_rx_scan(
 void ieee80211_rx_bss_list_init(struct net_device *dev);
 void ieee80211_rx_bss_list_deinit(struct net_device *dev);
 int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
-struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
-                                        struct sk_buff *skb, u8 *bssid,
-                                        u8 *addr);
+struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev,
+                                       struct sk_buff *skb, u8 *bssid,
+                                       u8 *addr);
 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
@@ -877,19 +933,25 @@ void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
                                  u16 agg_size, u16 timeout);
 void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
                                u16 initiator, u16 reason_code);
+
 void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
                                u16 tid, u16 initiator, u16 reason);
-void sta_rx_agg_session_timer_expired(unsigned long data);
 void sta_addba_resp_timer_expired(unsigned long data);
+void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr);
 u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
                            struct ieee802_11_elems *elems,
                            enum ieee80211_band band);
-void ieee80211_start_mesh(struct net_device *dev);
 void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
                int encrypt);
 void ieee802_11_parse_elems(u8 *start, size_t len,
                                   struct ieee802_11_elems *elems);
 
+#ifdef CONFIG_MAC80211_MESH
+void ieee80211_start_mesh(struct net_device *dev);
+#else
+static inline void ieee80211_start_mesh(struct net_device *dev)
+{}
+#endif
 
 /* ieee80211_iface.c */
 int ieee80211_if_add(struct net_device *dev, const char *name,