ath9k: Nuke struct ath9k_node_stats
[pandora-kernel.git] / drivers / net / wireless / ath / ath9k / ath9k.h
index 515880a..7705da1 100644 (file)
 #include <linux/device.h>
 #include <net/mac80211.h>
 #include <linux/leds.h>
-#include <linux/rfkill.h>
 
 #include "hw.h"
 #include "rc.h"
 #include "debug.h"
+#include "../ath.h"
 
 struct ath_node;
 
@@ -165,7 +165,6 @@ void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
 #define WME_NUM_TID             16
 #define ATH_TXBUF               512
 #define ATH_TXMAXTRY            13
-#define ATH_11N_TXMAXTRY        10
 #define ATH_MGT_TXMAXTRY        4
 #define WME_BA_BMP_SIZE         64
 #define WME_MAX_BA              WME_BA_BMP_SIZE
@@ -192,12 +191,9 @@ void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
 #define ATH_AGGR_MIN_QDEPTH        2
 #define ATH_AMPDU_SUBFRAME_DEFAULT 32
 #define ATH_AMPDU_LIMIT_MAX        (64 * 1024 - 1)
-#define ATH_AMPDU_LIMIT_DEFAULT    ATH_AMPDU_LIMIT_MAX
 
 #define IEEE80211_SEQ_SEQ_SHIFT    4
 #define IEEE80211_SEQ_MAX          4096
-#define IEEE80211_MIN_AMPDU_BUF    0x8
-#define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13
 #define IEEE80211_WEP_IVLEN        3
 #define IEEE80211_WEP_KIDLEN       1
 #define IEEE80211_WEP_CRCLEN       4
@@ -227,6 +223,8 @@ void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
 #define ATH_DS_TX_BA(_ds)          ((_ds)->ds_us.tx.ts_flags & ATH9K_TX_BA)
 #define ATH_AN_2_TID(_an, _tidno)  (&(_an)->tid[(_tidno)])
 
+#define ATH_TX_COMPLETE_POLL_INT       1000
+
 enum ATH_AGGR_STATUS {
        ATH_AGGR_DONE,
        ATH_AGGR_BAW_CLOSED,
@@ -240,8 +238,8 @@ struct ath_txq {
        spinlock_t axq_lock;
        u32 axq_depth;
        u8 axq_aggr_depth;
-       u32 axq_totalqueued;
        bool stopped;
+       bool axq_tx_inprogress;
        struct ath_buf *axq_linkbuf;
 
        /* first desc of the last descriptor that contains CTS */
@@ -273,7 +271,6 @@ struct ath_atx_tid {
        int sched;
        int paused;
        u8 state;
-       int addba_exchangeattempts;
 };
 
 struct ath_atx_ac {
@@ -293,12 +290,28 @@ struct ath_tx_control {
 #define ATH_TX_XRETRY       0x02
 #define ATH_TX_BAR          0x04
 
+#define ATH_RSSI_LPF_LEN               10
+#define RSSI_LPF_THRESHOLD             -20
+#define ATH9K_RSSI_BAD                 0x80
+#define ATH_RSSI_EP_MULTIPLIER     (1<<7)
+#define ATH_EP_MUL(x, mul)         ((x) * (mul))
+#define ATH_RSSI_IN(x)             (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
+#define ATH_LPF_RSSI(x, y, len) \
+    ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
+#define ATH_RSSI_LPF(x, y) do {                                        \
+    if ((y) >= RSSI_LPF_THRESHOLD)                                     \
+       x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN);      \
+} while (0)
+#define ATH_EP_RND(x, mul)                                             \
+       ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
+
 struct ath_node {
        struct ath_softc *an_sc;
        struct ath_atx_tid tid[WME_NUM_TID];
        struct ath_atx_ac ac[WME_NUM_AC];
        u16 maxampdu;
        u8 mpdudensity;
+       int last_rssi;
 };
 
 struct ath_tx {
@@ -349,9 +362,9 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
 void ath_tx_tasklet(struct ath_softc *sc);
 void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb);
 bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno);
-int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
-                     u16 tid, u16 *ssn);
-int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
+void ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
+                      u16 tid, u16 *ssn);
+void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
 void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
 
 /********/
@@ -441,7 +454,8 @@ struct ath_ani {
 /*   LED Control    */
 /********************/
 
-#define ATH_LED_PIN    1
+#define ATH_LED_PIN_DEF                1
+#define ATH_LED_PIN_9287               8
 #define ATH_LED_ON_DURATION_IDLE       350     /* in msecs */
 #define ATH_LED_OFF_DURATION_IDLE      250     /* in msecs */
 
@@ -460,12 +474,6 @@ struct ath_led {
        bool registered;
 };
 
-struct ath_rfkill {
-       struct rfkill *rfkill;
-       struct rfkill_ops ops;
-       char rfkill_name[32];
-};
-
 /********************/
 /* Main driver core */
 /********************/
@@ -505,7 +513,6 @@ struct ath_rfkill {
 #define SC_OP_PROTECT_ENABLE    BIT(6)
 #define SC_OP_RXFLUSH           BIT(7)
 #define SC_OP_LED_ASSOCIATED    BIT(8)
-#define SC_OP_RFKILL_REGISTERED BIT(9)
 #define SC_OP_WAIT_FOR_BEACON   BIT(12)
 #define SC_OP_LED_ON            BIT(13)
 #define SC_OP_SCANNING          BIT(14)
@@ -527,6 +534,8 @@ struct ath_softc {
        struct ieee80211_hw *hw;
        struct device *dev;
 
+       struct ath_common common;
+
        spinlock_t wiphy_lock; /* spinlock to protect ath_wiphy data */
        struct ath_wiphy *pri_wiphy;
        struct ath_wiphy **sec_wiphy; /* secondary wiphys (virtual radios); may
@@ -549,6 +558,8 @@ struct ath_softc {
        int irq;
        spinlock_t sc_resetlock;
        spinlock_t sc_serial_rw;
+       spinlock_t ani_lock;
+       spinlock_t sc_pm_lock;
        struct mutex mutex;
 
        u8 curbssid[ETH_ALEN];
@@ -557,7 +568,6 @@ struct ath_softc {
        u32 sc_flags; /* SC_OP_* */
        u16 curtxpow;
        u16 curaid;
-       u16 cachelsz;
        u8 nbcnvifs;
        u16 nvifs;
        u8 tx_chainmask;
@@ -565,7 +575,8 @@ struct ath_softc {
        u32 keymax;
        DECLARE_BITMAP(keymap, ATH_KEYMAX);
        u8 splitmic;
-       atomic_t ps_usecount;
+       bool ps_enabled;
+       unsigned long ps_usecount;
        enum ath9k_int imask;
        enum ath9k_ht_extprotspacing ht_extprotspacing;
        enum ath9k_ht_macmode tx_chan_width;
@@ -591,14 +602,13 @@ struct ath_softc {
 
        int beacon_interval;
 
-       struct ath_rfkill rf_kill;
        struct ath_ani ani;
-       struct ath9k_node_stats nodestats;
 #ifdef CONFIG_ATH9K_DEBUG
        struct ath9k_debug debug;
 #endif
        struct ath_bus_ops *bus_ops;
        struct ath_beacon_config cur_beacon_conf;
+       struct delayed_work tx_complete_work;
 };
 
 struct ath_wiphy {
@@ -620,6 +630,16 @@ int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
 int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
 int ath_cabq_update(struct ath_softc *);
 
+static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
+{
+       return &ah->ah_sc->common;
+}
+
+static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah)
+{
+       return &(ath9k_hw_common(ah)->regulatory);
+}
+
 static inline void ath_read_cachesize(struct ath_softc *sc, int *csz)
 {
        sc->bus_ops->read_cachesize(sc, csz);
@@ -634,7 +654,7 @@ extern struct ieee80211_ops ath9k_ops;
 
 irqreturn_t ath_isr(int irq, void *dev);
 void ath_cleanup(struct ath_softc *sc);
-int ath_attach(u16 devid, struct ath_softc *sc);
+int ath_init_device(u16 devid, struct ath_softc *sc);
 void ath_detach(struct ath_softc *sc);
 const char *ath_mac_bb_name(u32 mac_bb_version);
 const char *ath_rf_name(u16 rf_version);
@@ -663,26 +683,8 @@ static inline int ath_ahb_init(void) { return 0; };
 static inline void ath_ahb_exit(void) {};
 #endif
 
-static inline void ath9k_ps_wakeup(struct ath_softc *sc)
-{
-       if (atomic_inc_return(&sc->ps_usecount) == 1)
-               if (sc->sc_ah->power_mode !=  ATH9K_PM_AWAKE) {
-                       sc->sc_ah->restore_mode = sc->sc_ah->power_mode;
-                       ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
-               }
-}
-
-static inline void ath9k_ps_restore(struct ath_softc *sc)
-{
-       if (atomic_dec_and_test(&sc->ps_usecount))
-               if ((sc->hw->conf.flags & IEEE80211_CONF_PS) &&
-                   !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
-                                     SC_OP_WAIT_FOR_PSPOLL_DATA |
-                                     SC_OP_WAIT_FOR_TX_ACK)))
-                       ath9k_hw_setpower(sc->sc_ah,
-                                         sc->sc_ah->restore_mode);
-}
-
+void ath9k_ps_wakeup(struct ath_softc *sc);
+void ath9k_ps_restore(struct ath_softc *sc);
 
 void ath9k_set_bssid_mask(struct ieee80211_hw *hw);
 int ath9k_wiphy_add(struct ath_softc *sc);
@@ -698,6 +700,7 @@ void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
                                  struct ath_wiphy *selected);
 bool ath9k_wiphy_scanning(struct ath_softc *sc);
 void ath9k_wiphy_work(struct work_struct *work);
+bool ath9k_all_wiphys_idle(struct ath_softc *sc);
 
 void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val);
 unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset);