]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/rt2x00/rt2x00.h
rt2x00: rework RT chipset and revision determination for PCI an SOC devices.
[~andy/linux] / drivers / net / wireless / rt2x00 / rt2x00.h
index 27bc6b7fbfdeffb6d610f4c4a3a5a2de294f0c99..d9daa9c406fadf2d914dab71f89313ba5636e51a 100644 (file)
@@ -1,5 +1,6 @@
 /*
-       Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
+       Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
+       Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
        <http://rt2x00.serialmonkey.com>
 
        This program is free software; you can redistribute it and/or modify
 #define GET_DURATION(__size, __rate)   (((__size) * 8 * 10) / (__rate))
 #define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate))
 
+/*
+ * Determine the number of L2 padding bytes required between the header and
+ * the payload.
+ */
+#define L2PAD_SIZE(__hdrlen)   (-(__hdrlen) & 3)
+
 /*
  * Determine the alignment requirement,
  * to make sure the 802.11 payload is padded to a 4-byte boundrary
 #define ALIGN_SIZE(__skb, __header) \
        (  ((unsigned long)((__skb)->data + (__header))) & 3 )
 
+/*
+ * Constants for extra TX headroom for alignment purposes.
+ */
+#define RT2X00_ALIGN_SIZE      4 /* Only whole frame needs alignment */
+#define RT2X00_L2PAD_SIZE      8 /* Both header & payload need alignment */
+
 /*
  * Standard timing and size defines.
  * These values should follow the ieee80211 specifications.
@@ -144,6 +157,12 @@ struct avg_val {
        int avg_weight;
 };
 
+enum rt2x00_chip_intf {
+       RT2X00_CHIP_INTF_PCI,
+       RT2X00_CHIP_INTF_USB,
+       RT2X00_CHIP_INTF_SOC,
+};
+
 /*
  * Chipset identification
  * The chipset on the device is composed of a RT and RF chip.
@@ -151,17 +170,28 @@ struct avg_val {
  */
 struct rt2x00_chip {
        u16 rt;
-#define RT2460         0x0101
-#define RT2560         0x0201
-#define RT2570         0x1201
-#define RT2561s                0x0301  /* Turbo */
-#define RT2561         0x0302
-#define RT2661         0x0401
-#define RT2571         0x1300
-#define RT2870         0x1600
+#define RT2460         0x2460
+#define RT2560         0x2560
+#define RT2570         0x2570
+#define RT2661         0x2661
+#define RT2573         0x2573
+#define RT2860         0x2860  /* 2.4GHz PCI/CB */
+#define RT2870         0x2870
+#define RT2872         0x2872
+#define RT2880         0x2880  /* WSOC */
+#define RT2883         0x2883  /* WSOC */
+#define RT2890         0x2890  /* 2.4GHz PCIe */
+#define RT3052         0x3052  /* WSOC */
+#define RT3070         0x3070
+#define RT3071         0x3071
+#define RT3090         0x3090  /* 2.4GHz PCIe */
+#define RT3390         0x3390
+#define RT3572         0x3572
 
        u16 rf;
-       u32 rev;
+       u16 rev;
+
+       enum rt2x00_chip_intf intf;
 };
 
 /*
@@ -298,13 +328,6 @@ struct link {
         */
        struct avg_val avg_rssi;
 
-       /*
-        * Currently precalculated percentages of successful
-        * TX and RX frames.
-        */
-       int rx_percentage;
-       int tx_percentage;
-
        /*
         * Work structure for scheduling periodic link tuning.
         */
@@ -579,6 +602,7 @@ struct rt2x00_ops {
        const unsigned int eeprom_size;
        const unsigned int rf_size;
        const unsigned int tx_queues;
+       const unsigned int extra_tx_headroom;
        const struct data_queue_desc *rx;
        const struct data_queue_desc *tx;
        const struct data_queue_desc *bcn;
@@ -835,8 +859,22 @@ struct rt2x00_dev {
         * Firmware image.
         */
        const struct firmware *fw;
+
+       /*
+        * Driver specific data.
+        */
+       void *priv;
 };
 
+/*
+ * Register defines.
+ * Some registers require multiple attempts before success,
+ * in those cases REGISTER_BUSY_COUNT attempts should be
+ * taken with a REGISTER_BUSY_DELAY interval.
+ */
+#define REGISTER_BUSY_COUNT    5
+#define REGISTER_BUSY_DELAY    100
+
 /*
  * Generic RF access.
  * The RF is being accessed by word index.
@@ -881,48 +919,57 @@ static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev,
  * Chipset handlers
  */
 static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
-                                  const u16 rt, const u16 rf, const u32 rev)
+                                  const u16 rt, const u16 rf, const u16 rev)
 {
-       INFO(rt2x00dev,
-            "Chipset detected - rt: %04x, rf: %04x, rev: %08x.\n",
-            rt, rf, rev);
-
        rt2x00dev->chip.rt = rt;
        rt2x00dev->chip.rf = rf;
        rt2x00dev->chip.rev = rev;
+
+       INFO(rt2x00dev,
+            "Chipset detected - rt: %04x, rf: %04x, rev: %04x.\n",
+            rt2x00dev->chip.rt, rt2x00dev->chip.rf, rt2x00dev->chip.rev);
 }
 
-static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
-                                     const u16 rt)
+static inline char rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
 {
-       rt2x00dev->chip.rt = rt;
+       return (rt2x00dev->chip.rt == rt);
+}
+
+static inline char rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
+{
+       return (rt2x00dev->chip.rf == rf);
+}
+
+static inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev)
+{
+       return rt2x00dev->chip.rev;
 }
 
-static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
-                                     const u16 rf, const u32 rev)
+static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev,
+                                       enum rt2x00_chip_intf intf)
 {
-       rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
+       rt2x00dev->chip.intf = intf;
 }
 
-static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
+static inline bool rt2x00_intf(struct rt2x00_dev *rt2x00dev,
+                              enum rt2x00_chip_intf intf)
 {
-       return (chipset->rt == chip);
+       return (rt2x00dev->chip.intf == intf);
 }
 
-static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip)
+static inline bool rt2x00_is_pci(struct rt2x00_dev *rt2x00dev)
 {
-       return (chipset->rf == chip);
+       return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI);
 }
 
-static inline u32 rt2x00_rev(const struct rt2x00_chip *chipset)
+static inline bool rt2x00_is_usb(struct rt2x00_dev *rt2x00dev)
 {
-       return chipset->rev;
+       return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_USB);
 }
 
-static inline bool rt2x00_check_rev(const struct rt2x00_chip *chipset,
-                                   const u32 mask, const u32 rev)
+static inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev)
 {
-       return ((chipset->rev & mask) == rev);
+       return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
 }
 
 /**
@@ -964,9 +1011,9 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
 int rt2x00mac_start(struct ieee80211_hw *hw);
 void rt2x00mac_stop(struct ieee80211_hw *hw);
 int rt2x00mac_add_interface(struct ieee80211_hw *hw,
-                           struct ieee80211_if_init_conf *conf);
+                           struct ieee80211_vif *vif);
 void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
-                               struct ieee80211_if_init_conf *conf);
+                               struct ieee80211_vif *vif);
 int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
 void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
                                unsigned int changed_flags,
@@ -983,8 +1030,6 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 #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,
-                          struct ieee80211_tx_queue_stats *stats);
 void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
                                struct ieee80211_vif *vif,
                                struct ieee80211_bss_conf *bss_conf,