[PATCH] mac80211: revamp interface and filter configuration
[safe/jmp/linux-2.6] / net / mac80211 / ieee80211_i.h
index ae94d64..74deecd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/workqueue.h>
 #include <linux/types.h>
 #include <linux/spinlock.h>
+#include <linux/etherdevice.h>
 #include <net/wireless.h>
 #include "ieee80211_key.h"
 #include "sta_info.h"
@@ -99,6 +100,12 @@ struct ieee80211_sta_bss {
        int probe_resp;
        unsigned long last_update;
 
+       /* during assocation, we save an ERP value from a probe response so
+        * that we can feed ERP info to the driver when handling the
+        * association completes. these fields probably won't be up-to-date
+        * otherwise, you probably don't want to use them. */
+       int has_erp_value;
+       u8 erp_value;
 };
 
 
@@ -106,6 +113,15 @@ typedef enum {
        TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
 } ieee80211_txrx_result;
 
+/* 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)
+/* frame is destined to interface currently processed (incl. multicast frames) */
+#define IEEE80211_TXRXD_RXRA_MATCH             BIT(5)
 struct ieee80211_txrx_data {
        struct sk_buff *skb;
        struct net_device *dev;
@@ -114,14 +130,10 @@ struct ieee80211_txrx_data {
        struct sta_info *sta;
        u16 fc, ethertype;
        struct ieee80211_key *key;
-       unsigned int fragmented:1; /* whether the MSDU was fragmented */
+       unsigned int flags;
        union {
                struct {
                        struct ieee80211_tx_control *control;
-                       unsigned int unicast:1;
-                       unsigned int ps_buffered:1;
-                       unsigned int short_preamble:1;
-                       unsigned int probe_last_frag:1;
                        struct ieee80211_hw_mode *mode;
                        struct ieee80211_rate *rate;
                        /* use this rate (if set) for last fragment; rate can
@@ -141,23 +153,21 @@ struct ieee80211_txrx_data {
                        int sent_ps_buffered;
                        int queue;
                        int load;
-                       unsigned int in_scan:1;
-                       /* frame is destined to interface currently processed
-                        * (including multicast frames) */
-                       unsigned int ra_match:1;
                } rx;
        } u;
 };
 
+/* flags used in struct ieee80211_tx_packet_data.flags */
+#define IEEE80211_TXPD_REQ_TX_STATUS   BIT(0)
+#define IEEE80211_TXPD_DO_NOT_ENCRYPT  BIT(1)
+#define IEEE80211_TXPD_REQUEUE         BIT(2)
+#define IEEE80211_TXPD_MGMT_IFACE      BIT(3)
 /* Stored in sk_buff->cb */
 struct ieee80211_tx_packet_data {
        int ifindex;
        unsigned long jiffies;
-       unsigned int req_tx_status:1;
-       unsigned int do_not_encrypt:1;
-       unsigned int requeue:1;
-       unsigned int mgmt_iface:1;
-       unsigned int queue:4;
+       unsigned int flags;
+       u8 queue;
 };
 
 struct ieee80211_tx_stored_packet {
@@ -168,7 +178,7 @@ struct ieee80211_tx_stored_packet {
        int last_frag_rateidx;
        int last_frag_hwrate;
        struct ieee80211_rate *last_frag_rate;
-       unsigned int last_frag_rate_ctrl_probe:1;
+       unsigned int last_frag_rate_ctrl_probe;
 };
 
 typedef ieee80211_txrx_result (*ieee80211_tx_handler)
@@ -207,6 +217,19 @@ struct ieee80211_if_vlan {
        u8 id;
 };
 
+/* flags used in struct ieee80211_if_sta.flags */
+#define IEEE80211_STA_SSID_SET         BIT(0)
+#define IEEE80211_STA_BSSID_SET                BIT(1)
+#define IEEE80211_STA_PREV_BSSID_SET   BIT(2)
+#define IEEE80211_STA_AUTHENTICATED    BIT(3)
+#define IEEE80211_STA_ASSOCIATED       BIT(4)
+#define IEEE80211_STA_PROBEREQ_POLL    BIT(5)
+#define IEEE80211_STA_CREATE_IBSS      BIT(6)
+#define IEEE80211_STA_MIXED_CELL       BIT(7)
+#define IEEE80211_STA_WMM_ENABLED      BIT(8)
+#define IEEE80211_STA_AUTO_SSID_SEL    BIT(10)
+#define IEEE80211_STA_AUTO_BSSID_SEL   BIT(11)
+#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
 struct ieee80211_if_sta {
        enum {
                IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
@@ -229,26 +252,14 @@ struct ieee80211_if_sta {
 
        int auth_tries, assoc_tries;
 
-       unsigned int ssid_set:1;
-       unsigned int bssid_set:1;
-       unsigned int prev_bssid_set:1;
-       unsigned int authenticated:1;
-       unsigned int associated:1;
-       unsigned int probereq_poll:1;
-       unsigned int use_protection:1;
-       unsigned int create_ibss:1;
-       unsigned int mixed_cell:1;
-       unsigned int wmm_enabled:1;
-       unsigned int auto_ssid_sel:1;
-       unsigned int auto_bssid_sel:1;
-       unsigned int auto_channel_sel:1;
+       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;
 
-       int key_mgmt;
+       int key_management_enabled;
        unsigned long last_probe;
 
 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
@@ -266,20 +277,28 @@ struct ieee80211_if_sta {
 };
 
 
+/* flags used in struct ieee80211_sub_if_data.flags */
+#define IEEE80211_SDATA_ALLMULTI       BIT(0)
+#define IEEE80211_SDATA_PROMISC                BIT(1)
+#define IEEE80211_SDATA_USE_PROTECTION BIT(2) /* CTS protect ERP frames */
+/* use short preamble with IEEE 802.11b: this flag is set when the AP or beacon
+ * generator reports that there are no present stations that cannot support short
+ * preambles */
+#define IEEE80211_SDATA_SHORT_PREAMBLE BIT(3)
 struct ieee80211_sub_if_data {
        struct list_head list;
        unsigned int type;
 
        struct wireless_dev wdev;
 
+       /* keys */
+       struct list_head key_list;
+
        struct net_device *dev;
        struct ieee80211_local *local;
 
-       int mc_count;
-       unsigned int allmulti:1;
-       unsigned int promisc:1;
+       unsigned int flags;
 
-       struct net_device_stats stats;
        int drop_unencrypted;
        int eapol; /* 0 = process EAPOL frames as normal data frames,
                    * 1 = send EAPOL frames through wlan#ap to hostapd
@@ -307,6 +326,65 @@ struct ieee80211_sub_if_data {
        } u;
        int channel_use;
        int channel_use_raw;
+
+#ifdef CONFIG_MAC80211_DEBUGFS
+       struct dentry *debugfsdir;
+       union {
+               struct {
+                       struct dentry *channel_use;
+                       struct dentry *drop_unencrypted;
+                       struct dentry *eapol;
+                       struct dentry *ieee8021_x;
+                       struct dentry *state;
+                       struct dentry *bssid;
+                       struct dentry *prev_bssid;
+                       struct dentry *ssid_len;
+                       struct dentry *aid;
+                       struct dentry *ap_capab;
+                       struct dentry *capab;
+                       struct dentry *extra_ie_len;
+                       struct dentry *auth_tries;
+                       struct dentry *assoc_tries;
+                       struct dentry *auth_algs;
+                       struct dentry *auth_alg;
+                       struct dentry *auth_transaction;
+                       struct dentry *flags;
+               } sta;
+               struct {
+                       struct dentry *channel_use;
+                       struct dentry *drop_unencrypted;
+                       struct dentry *eapol;
+                       struct dentry *ieee8021_x;
+                       struct dentry *num_sta_ps;
+                       struct dentry *dtim_period;
+                       struct dentry *dtim_count;
+                       struct dentry *num_beacons;
+                       struct dentry *force_unicast_rateidx;
+                       struct dentry *max_ratectrl_rateidx;
+                       struct dentry *num_buffered_multicast;
+                       struct dentry *beacon_head_len;
+                       struct dentry *beacon_tail_len;
+               } ap;
+               struct {
+                       struct dentry *channel_use;
+                       struct dentry *drop_unencrypted;
+                       struct dentry *eapol;
+                       struct dentry *ieee8021_x;
+                       struct dentry *peer;
+               } wds;
+               struct {
+                       struct dentry *channel_use;
+                       struct dentry *drop_unencrypted;
+                       struct dentry *eapol;
+                       struct dentry *ieee8021_x;
+                       struct dentry *vlan_id;
+               } vlan;
+               struct {
+                       struct dentry *mode;
+               } monitor;
+               struct dentry *default_key;
+       } debugfs;
+#endif
 };
 
 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
@@ -331,8 +409,10 @@ struct ieee80211_local {
        struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
        int open_count;
        int monitors;
+       unsigned int filter_flags; /* FIF_* */
        struct iw_statistics wstats;
        u8 wstats_flags;
+       int tx_headroom; /* required headroom for hardware/radiotap */
 
        enum {
                IEEE80211_DEV_UNINITIALIZED = 0,
@@ -350,10 +430,9 @@ struct ieee80211_local {
        struct sk_buff_head skb_queue_unreliable;
 
        /* Station data structures */
-       spinlock_t sta_lock; /* mutex for STA data structures */
+       rwlock_t sta_lock; /* protects STA data structures */
        int num_sta; /* number of stations in sta_list */
        struct list_head sta_list;
-       struct list_head deleted_sta_list;
        struct sta_info *sta_hash[STA_HASH_SIZE];
        struct timer_list sta_cleanup;
 
@@ -378,18 +457,13 @@ struct ieee80211_local {
        int *basic_rates[NUM_IEEE80211_MODES];
 
        int rts_threshold;
-       int cts_protect_erp_frames;
        int fragmentation_threshold;
        int short_retry_limit; /* dot11ShortRetryLimit */
        int long_retry_limit; /* dot11LongRetryLimit */
-       int short_preamble; /* use short preamble with IEEE 802.11b */
 
        struct crypto_blkcipher *wep_tx_tfm;
        struct crypto_blkcipher *wep_rx_tfm;
        u32 wep_iv;
-       int key_tx_rx_threshold; /* number of times any key can be used in TX
-                                 * or RX before generating a rekey
-                                 * notification; 0 = notification disabled. */
 
        int bridge_packets; /* bridge packets between associated stations and
                             * deliver multicast frames both back to wireless
@@ -441,16 +515,10 @@ struct ieee80211_local {
 
        u32 channel_use;
        u32 channel_use_raw;
-       u32 stat_time;
-       struct timer_list stat_timer;
-
-       enum {
-               STA_ANTENNA_SEL_AUTO = 0,
-               STA_ANTENNA_SEL_SW_CTRL = 1,
-               STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
-       } sta_antenna_sel;
 
-       int rate_ctrl_num_up, rate_ctrl_num_down;
+#ifdef CONFIG_MAC80211_DEBUGFS
+       struct work_struct sta_debugfs_add;
+#endif
 
 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
        /* TX/RX handler statistics */
@@ -481,16 +549,9 @@ struct ieee80211_local {
 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
 
 
-       int default_wep_only; /* only default WEP keys are used with this
-                              * interface; this is used to decide when hwaccel
-                              * can be used with default keys */
        int total_ps_buffered; /* total number of all buffered unicast and
                                * multicast packets for power saving stations
                                */
-       int allow_broadcast_always; /* whether to allow TX of broadcast frames
-                                    * even when there are no associated STAs
-                                    */
-
        int wifi_wme_noack_test;
        unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
 
@@ -500,6 +561,67 @@ struct ieee80211_local {
                                * (1 << MODE_*) */
 
        int user_space_mlme;
+
+#ifdef CONFIG_MAC80211_DEBUGFS
+       struct local_debugfsdentries {
+               struct dentry *channel;
+               struct dentry *frequency;
+               struct dentry *antenna_sel_tx;
+               struct dentry *antenna_sel_rx;
+               struct dentry *bridge_packets;
+               struct dentry *rts_threshold;
+               struct dentry *fragmentation_threshold;
+               struct dentry *short_retry_limit;
+               struct dentry *long_retry_limit;
+               struct dentry *total_ps_buffered;
+               struct dentry *mode;
+               struct dentry *wep_iv;
+               struct dentry *modes;
+               struct dentry *statistics;
+               struct local_debugfsdentries_statsdentries {
+                       struct dentry *transmitted_fragment_count;
+                       struct dentry *multicast_transmitted_frame_count;
+                       struct dentry *failed_count;
+                       struct dentry *retry_count;
+                       struct dentry *multiple_retry_count;
+                       struct dentry *frame_duplicate_count;
+                       struct dentry *received_fragment_count;
+                       struct dentry *multicast_received_frame_count;
+                       struct dentry *transmitted_frame_count;
+                       struct dentry *wep_undecryptable_count;
+                       struct dentry *num_scans;
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+                       struct dentry *tx_handlers_drop;
+                       struct dentry *tx_handlers_queued;
+                       struct dentry *tx_handlers_drop_unencrypted;
+                       struct dentry *tx_handlers_drop_fragment;
+                       struct dentry *tx_handlers_drop_wep;
+                       struct dentry *tx_handlers_drop_not_assoc;
+                       struct dentry *tx_handlers_drop_unauth_port;
+                       struct dentry *rx_handlers_drop;
+                       struct dentry *rx_handlers_queued;
+                       struct dentry *rx_handlers_drop_nullfunc;
+                       struct dentry *rx_handlers_drop_defrag;
+                       struct dentry *rx_handlers_drop_short;
+                       struct dentry *rx_handlers_drop_passive_scan;
+                       struct dentry *tx_expand_skb_head;
+                       struct dentry *tx_expand_skb_head_cloned;
+                       struct dentry *rx_expand_skb_head;
+                       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;
+                       struct dentry *dot11FCSErrorCount;
+                       struct dentry *dot11RTSSuccessCount;
+               } stats;
+               struct dentry *stations;
+               struct dentry *keys;
+       } debugfs;
+#endif
 };
 
 static inline struct ieee80211_local *hw_to_local(
@@ -537,9 +659,9 @@ static inline void __bss_tim_set(struct ieee80211_if_ap *bss, int aid)
 static inline void bss_tim_set(struct ieee80211_local *local,
                               struct ieee80211_if_ap *bss, int aid)
 {
-       spin_lock_bh(&local->sta_lock);
+       read_lock_bh(&local->sta_lock);
        __bss_tim_set(bss, aid);
-       spin_unlock_bh(&local->sta_lock);
+       read_unlock_bh(&local->sta_lock);
 }
 
 static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
@@ -554,9 +676,9 @@ static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
 static inline void bss_tim_clear(struct ieee80211_local *local,
                                 struct ieee80211_if_ap *bss, int aid)
 {
-       spin_lock_bh(&local->sta_lock);
+       read_lock_bh(&local->sta_lock);
        __bss_tim_clear(bss, aid);
-       spin_unlock_bh(&local->sta_lock);
+       read_unlock_bh(&local->sta_lock);
 }
 
 /**
@@ -576,16 +698,17 @@ static inline int ieee80211_is_erp_rate(int phymode, int rate)
        return 0;
 }
 
+static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
+{
+       return compare_ether_addr(raddr, addr) == 0 ||
+              is_broadcast_ether_addr(raddr);
+}
+
+
 /* ieee80211.c */
 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);
-struct ieee80211_key_conf *
-ieee80211_key_data2conf(struct ieee80211_local *local,
-                       const struct ieee80211_key *data);
-struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
-                                         int idx, size_t key_len, gfp_t flags);
-void ieee80211_key_free(struct ieee80211_key *key);
 void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
                       struct ieee80211_rx_status *status, u32 msg_type);
 void ieee80211_prepare_rates(struct ieee80211_local *local,
@@ -594,15 +717,12 @@ void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
 void ieee80211_if_setup(struct net_device *dev);
 void ieee80211_if_mgmt_setup(struct net_device *dev);
-int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
-                                const char *name);
-struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
+struct ieee80211_rate *ieee80211_get_rate(struct ieee80211_local *local,
+                                         int phymode, int hwrate);
 
 /* ieee80211_ioctl.c */
 extern const struct iw_handler_def ieee80211_iw_handler_def;
 
-void ieee80211_update_default_wep_only(struct ieee80211_local *local);
-
 
 /* Least common multiple of the used rates (in 100 kbps). This is used to
  * calculate rate_inv values for each rate so that only integers are needed. */
@@ -626,7 +746,6 @@ void ieee80211_update_default_wep_only(struct ieee80211_local *local);
 /* ieee80211_ioctl.c */
 int ieee80211_set_compression(struct ieee80211_local *local,
                              struct net_device *dev, struct sta_info *sta);
-int ieee80211_init_client(struct net_device *dev);
 int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
 /* ieee80211_sta.c */
 void ieee80211_sta_timer(unsigned long data);
@@ -651,6 +770,8 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
                                         u8 *addr);
 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
+void ieee80211_erp_info_change_notify(struct net_device *dev, u8 changes);
+void ieee80211_reset_erp_info(struct net_device *dev);
 
 /* ieee80211_iface.c */
 int ieee80211_if_add(struct net_device *dev, const char *name,
@@ -665,7 +786,32 @@ void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
 int ieee80211_if_add_mgmt(struct ieee80211_local *local);
 void ieee80211_if_del_mgmt(struct ieee80211_local *local);
 
-/* for wiphy privid */
-extern void *mac80211_wiphy_privid;
+/* regdomain.c */
+void ieee80211_regdomain_init(void);
+void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode);
+
+/* rx handling */
+extern ieee80211_rx_handler ieee80211_rx_pre_handlers[];
+extern ieee80211_rx_handler ieee80211_rx_handlers[];
+
+/* tx handling */
+extern ieee80211_tx_handler ieee80211_tx_handlers[];
+void ieee80211_clear_tx_pending(struct ieee80211_local *local);
+void ieee80211_tx_pending(unsigned long data);
+int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
+int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
+int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
+int ieee80211_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev);
+
+/* utility functions/constants */
+extern void *mac80211_wiphy_privid; /* for wiphy privid */
+extern const unsigned char rfc1042_header[6];
+extern const unsigned char bridge_tunnel_header[6];
+u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
+int ieee80211_is_eapol(const struct sk_buff *skb);
+int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
+                            int rate, int erp, int short_preamble);
+void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
+                                    struct ieee80211_hdr *hdr);
 
 #endif /* IEEE80211_I_H */