mac80211: kill hw.conf.antenna_sel_{rx,tx}
[safe/jmp/linux-2.6] / drivers / net / wireless / rt2x00 / rt2x00.h
index 15ec797..1359a37 100644 (file)
@@ -44,7 +44,7 @@
 /*
  * Module information.
  */
-#define DRV_VERSION    "2.1.6"
+#define DRV_VERSION    "2.2.1"
 #define DRV_PROJECT    "http://rt2x00.serialmonkey.com"
 
 /*
  */
 #define DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, __args...)    \
        printk(__kernlvl "%s -> %s: %s - " __msg,                       \
-              wiphy_name((__dev)->hw->wiphy), __FUNCTION__, __lvl, ##__args)
+              wiphy_name((__dev)->hw->wiphy), __func__, __lvl, ##__args)
 
 #define DEBUG_PRINTK_PROBE(__kernlvl, __lvl, __msg, __args...) \
        printk(__kernlvl "%s -> %s: %s - " __msg,               \
-              KBUILD_MODNAME, __FUNCTION__, __lvl, ##__args)
+              KBUILD_MODNAME, __func__, __lvl, ##__args)
 
 #ifdef CONFIG_RT2X00_DEBUG
 #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...)        \
 #define SHORT_PIFS             ( SIFS + SHORT_SLOT_TIME )
 #define DIFS                   ( PIFS + SLOT_TIME )
 #define SHORT_DIFS             ( SHORT_PIFS + SHORT_SLOT_TIME )
-#define EIFS                   ( SIFS + (8 * (IEEE80211_HEADER + ACK_SIZE)) )
-
-/*
- * IEEE802.11 header defines
- */
-static inline int is_rts_frame(u16 fc)
-{
-       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
-               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS));
-}
-
-static inline int is_cts_frame(u16 fc)
-{
-       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
-               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS));
-}
-
-static inline int is_probe_resp(u16 fc)
-{
-       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
-               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
-}
-
-static inline int is_beacon(u16 fc)
-{
-       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
-               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON));
-}
+#define EIFS                   ( SIFS + DIFS + \
+                                 (8 * (IEEE80211_HEADER + ACK_SIZE)) )
+#define SHORT_EIFS             ( SIFS + SHORT_DIFS + \
+                                 (8 * (IEEE80211_HEADER + ACK_SIZE)) )
 
 /*
  * Chipset identification
@@ -168,6 +144,17 @@ struct rf_channel {
 };
 
 /*
+ * Channel information structure
+ */
+struct channel_info {
+       unsigned int flags;
+#define GEOGRAPHY_ALLOWED      0x00000001
+
+       short tx_power1;
+       short tx_power2;
+};
+
+/*
  * Antenna setup values.
  */
 struct antenna_setup {
@@ -391,6 +378,14 @@ struct rt2x00_intf {
 #define DELAYED_UPDATE_BEACON          0x00000001
 #define DELAYED_CONFIG_ERP             0x00000002
 #define DELAYED_LED_ASSOC              0x00000004
+
+       /*
+        * Software sequence counter, this is only required
+        * for hardware which doesn't support hardware
+        * sequence counting.
+        */
+       spinlock_t seqlock;
+       u16 seqno;
 };
 
 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
@@ -410,10 +405,7 @@ static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
  * @num_channels: Number of supported channels. This is used as array size
  *     for @tx_power_a, @tx_power_bg and @channels.
  * @channels: Device/chipset specific channel values (See &struct rf_channel).
- * @tx_power_a: TX power values for all 5.2GHz channels (may be NULL).
- * @tx_power_bg: TX power values for all 2.4GHz channels (may be NULL).
- * @tx_power_default: Default TX power value to use when either
- *     @tx_power_a or @tx_power_bg is missing.
+ * @channels_info: Additional information for channels (See &struct channel_info).
  */
 struct hw_mode_spec {
        unsigned int supported_bands;
@@ -426,10 +418,7 @@ struct hw_mode_spec {
 
        unsigned int num_channels;
        const struct rf_channel *channels;
-
-       const u8 *tx_power_a;
-       const u8 *tx_power_bg;
-       u8 tx_power_default;
+       const struct channel_info *channels_info;
 };
 
 /*
@@ -441,7 +430,9 @@ struct hw_mode_spec {
  */
 struct rt2x00lib_conf {
        struct ieee80211_conf *conf;
+
        struct rf_channel rf;
+       struct channel_info channel;
 
        struct antenna_setup ant;
 
@@ -461,12 +452,30 @@ struct rt2x00lib_conf {
  */
 struct rt2x00lib_erp {
        int short_preamble;
+       int cts_protection;
 
        int ack_timeout;
        int ack_consume_time;
 };
 
 /*
+ * Configuration structure for hardware encryption.
+ */
+struct rt2x00lib_crypto {
+       enum cipher cipher;
+
+       enum set_key_cmd cmd;
+       const u8 *address;
+
+       u32 bssidx;
+       u32 aid;
+
+       u8 key[16];
+       u8 tx_mic[8];
+       u8 rx_mic[8];
+};
+
+/*
  * Configuration structure wrapper around the
  * rt2x00 interface configuration handler.
  */
@@ -474,7 +483,7 @@ struct rt2x00intf_conf {
        /*
         * Interface type
         */
-       enum ieee80211_if_types type;
+       enum nl80211_iftype type;
 
        /*
         * TSF sync value, this is dependant on the operation type.
@@ -511,8 +520,8 @@ struct rt2x00lib_ops {
         */
        int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
        char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
-       u16 (*get_firmware_crc) (void *data, const size_t len);
-       int (*load_firmware) (struct rt2x00_dev *rt2x00dev, void *data,
+       u16 (*get_firmware_crc) (const void *data, const size_t len);
+       int (*load_firmware) (struct rt2x00_dev *rt2x00dev, const void *data,
                              const size_t len);
 
        /*
@@ -546,8 +555,8 @@ struct rt2x00lib_ops {
        void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev,
                               struct sk_buff *skb,
                               struct txentry_desc *txdesc);
-       int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
-                             struct data_queue *queue, struct sk_buff *skb);
+       int (*write_tx_data) (struct queue_entry *entry);
+       void (*write_beacon) (struct queue_entry *entry);
        int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
                                struct sk_buff *skb);
        void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
@@ -562,6 +571,12 @@ struct rt2x00lib_ops {
        /*
         * Configuration handlers.
         */
+       int (*config_shared_key) (struct rt2x00_dev *rt2x00dev,
+                                 struct rt2x00lib_crypto *crypto,
+                                 struct ieee80211_key_conf *key);
+       int (*config_pairwise_key) (struct rt2x00_dev *rt2x00dev,
+                                   struct rt2x00lib_crypto *crypto,
+                                   struct ieee80211_key_conf *key);
        void (*config_filter) (struct rt2x00_dev *rt2x00dev,
                               const unsigned int filter_flags);
        void (*config_intf) (struct rt2x00_dev *rt2x00dev,
@@ -614,26 +629,32 @@ enum rt2x00_flags {
        /*
         * Device state flags
         */
-       DEVICE_PRESENT,
-       DEVICE_REGISTERED_HW,
-       DEVICE_INITIALIZED,
-       DEVICE_STARTED,
-       DEVICE_STARTED_SUSPEND,
-       DEVICE_ENABLED_RADIO,
-       DEVICE_DISABLED_RADIO_HW,
+       DEVICE_STATE_PRESENT,
+       DEVICE_STATE_REGISTERED_HW,
+       DEVICE_STATE_INITIALIZED,
+       DEVICE_STATE_STARTED,
+       DEVICE_STATE_STARTED_SUSPEND,
+       DEVICE_STATE_ENABLED_RADIO,
+       DEVICE_STATE_DISABLED_RADIO_HW,
 
        /*
-        * Driver features
+        * Driver requirements
         */
        DRIVER_REQUIRE_FIRMWARE,
        DRIVER_REQUIRE_BEACON_GUARD,
        DRIVER_REQUIRE_ATIM_QUEUE,
        DRIVER_REQUIRE_SCHEDULED,
+       DRIVER_REQUIRE_DMA,
 
        /*
-        * Driver configuration
+        * Driver features
         */
        CONFIG_SUPPORT_HW_BUTTON,
+       CONFIG_SUPPORT_HW_CRYPTO,
+
+       /*
+        * Driver configuration
+        */
        CONFIG_FRAME_TYPE,
        CONFIG_RF_SEQUENCE,
        CONFIG_EXTERNAL_LNA_A,
@@ -653,11 +674,7 @@ struct rt2x00_dev {
         * When accessing this variable, the rt2x00dev_{pci,usb}
         * macro's should be used for correct typecasting.
         */
-       void *dev;
-#define rt2x00dev_pci(__dev)   ( (struct pci_dev *)(__dev)->dev )
-#define rt2x00dev_usb(__dev)   ( (struct usb_interface *)(__dev)->dev )
-#define rt2x00dev_usb_dev(__dev)\
-       ( (struct usb_device *)interface_to_usbdev(rt2x00dev_usb(__dev)) )
+       struct device *dev;
 
        /*
         * Callback functions.
@@ -680,7 +697,7 @@ struct rt2x00_dev {
 #define RFKILL_STATE_ALLOCATED         1
 #define RFKILL_STATE_REGISTERED                2
        struct rfkill *rfkill;
-       struct input_polled_dev *poll_dev;
+       struct delayed_work rfkill_work;
 #endif /* CONFIG_RT2X00_LIB_RFKILL */
 
        /*
@@ -786,6 +803,11 @@ struct rt2x00_dev {
        u32 *rf;
 
        /*
+        * LNA gain
+        */
+       short lna_gain;
+
+       /*
         * USB Max frame size (for rt2500usb & rt73usb).
         */
        u16 usb_maxpacket;
@@ -818,6 +840,9 @@ struct rt2x00_dev {
 
        /*
         * Scheduled work.
+        * NOTE: intf_work will use ieee80211_iterate_active_interfaces()
+        * which means it cannot be placed on the hw->workqueue
+        * due to RTNL locking requirements.
         */
        struct work_struct intf_work;
        struct work_struct filter_work;
@@ -827,7 +852,7 @@ struct rt2x00_dev {
         * The Beacon array also contains the Atim queue
         * if that is supported by the device.
         */
-       int data_queues;
+       unsigned int data_queues;
        struct data_queue *rx;
        struct data_queue *tx;
        struct data_queue *bcn;
@@ -931,37 +956,11 @@ static inline u16 get_duration_res(const unsigned int size, const u8 rate)
 }
 
 /**
- * rt2x00queue_create_tx_descriptor - Create TX descriptor from mac80211 input
- * @entry: The entry which will be used to transfer the TX frame.
- * @txdesc: rt2x00 TX descriptor which will be initialized by this function.
- *
- * This function will initialize the &struct txentry_desc based on information
- * from mac80211. This descriptor can then be used by rt2x00lib and the drivers
- * to correctly initialize the hardware descriptor.
- * Note that before calling this function the skb->cb array must be untouched
- * by rt2x00lib. Only after this function completes will it be save to
- * overwrite the skb->cb information.
- * The reason for this is that mac80211 writes its own tx information into
- * the skb->cb array, and this function will use that information to initialize
- * the &struct txentry_desc structure.
- */
-void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
-                                     struct txentry_desc *txdesc);
-
-/**
- * rt2x00queue_write_tx_descriptor - Write TX descriptor to hardware
- * @entry: The entry which will be used to transfer the TX frame.
- * @txdesc: TX descriptor which will be used to write hardware descriptor
- *
- * This function will write a TX descriptor initialized by
- * &rt2x00queue_create_tx_descriptor to the hardware. After this call
- * has completed the frame is now owned by the hardware, the hardware
- * queue will have automatically be kicked unless this frame was generated
- * by rt2x00lib, in which case the frame is "special" and must be kicked
- * by the caller.
+ * rt2x00queue_map_txskb - Map a skb into DMA for TX purposes.
+ * @rt2x00dev: Pointer to &struct rt2x00_dev.
+ * @skb: The skb to map.
  */
-void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
-                                    struct txentry_desc *txdesc);
+void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
 
 /**
  * rt2x00queue_get_queue - Convert queue index to queue pointer
@@ -979,26 +978,14 @@ struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
 struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
                                          enum queue_index index);
 
-/**
- * rt2x00queue_index_inc - Index incrementation function
- * @queue: Queue (&struct data_queue) to perform the action on.
- * @index: Index type (&enum queue_index) to perform the action on.
- *
- * This function will increase the requested index on the queue,
- * it will grab the appropriate locks and handle queue overflow events by
- * resetting the index to the start of the queue.
- */
-void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index);
-
-
 /*
  * Interrupt context handlers.
  */
 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
 void rt2x00lib_txdone(struct queue_entry *entry,
                      struct txdone_entry_desc *txdesc);
-void rt2x00lib_rxdone(struct queue_entry *entry,
-                     struct rxdone_entry_desc *rxdesc);
+void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
+                     struct queue_entry *entry);
 
 /*
  * mac80211 handlers.
@@ -1018,6 +1005,13 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
                                unsigned int changed_flags,
                                unsigned int *total_flags,
                                int mc_count, struct dev_addr_list *mc_list);
+#ifdef CONFIG_RT2X00_LIB_CRYPTO
+int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
+                     const u8 *local_address, const u8 *address,
+                     struct ieee80211_key_conf *key);
+#else
+#define rt2x00mac_set_key      NULL
+#endif /* CONFIG_RT2X00_LIB_CRYPTO */
 int rt2x00mac_get_stats(struct ieee80211_hw *hw,
                        struct ieee80211_low_level_stats *stats);
 int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw,