aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/rc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath9k/rc.c')
-rw-r--r--drivers/net/wireless/ath9k/rc.c98
1 files changed, 42 insertions, 56 deletions
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 1cc9daf44550..cca2fc5b0765 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "core.h" 22#include "core.h"
23/* FIXME: remove this include! */
23#include "../net/mac80211/rate.h" 24#include "../net/mac80211/rate.h"
24 25
25static u32 tx_triglevel_max; 26static u32 tx_triglevel_max;
@@ -1812,20 +1813,18 @@ static void ath_rc_sib_init(struct ath_rate_node *ath_rc_priv)
1812} 1813}
1813 1814
1814 1815
1815static void ath_setup_rates(struct ieee80211_local *local, struct sta_info *sta) 1816static void ath_setup_rates(struct ath_softc *sc,
1817 struct ieee80211_supported_band *sband,
1818 struct ieee80211_sta *sta,
1819 struct ath_rate_node *rc_priv)
1816 1820
1817{ 1821{
1818 struct ieee80211_supported_band *sband;
1819 struct ieee80211_hw *hw = local_to_hw(local);
1820 struct ath_softc *sc = hw->priv;
1821 struct ath_rate_node *rc_priv = sta->rate_ctrl_priv;
1822 int i, j = 0; 1822 int i, j = 0;
1823 1823
1824 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 1824 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
1825 1825
1826 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1827 for (i = 0; i < sband->n_bitrates; i++) { 1826 for (i = 0; i < sband->n_bitrates; i++) {
1828 if (sta->sta.supp_rates[local->hw.conf.channel->band] & BIT(i)) { 1827 if (sta->supp_rates[sband->band] & BIT(i)) {
1829 rc_priv->neg_rates.rs_rates[j] 1828 rc_priv->neg_rates.rs_rates[j]
1830 = (sband->bitrates[i].bitrate * 2) / 10; 1829 = (sband->bitrates[i].bitrate * 2) / 10;
1831 j++; 1830 j++;
@@ -1852,19 +1851,17 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv)
1852} 1851}
1853 1852
1854/* Rate Control callbacks */ 1853/* Rate Control callbacks */
1855static void ath_tx_status(void *priv, struct net_device *dev, 1854static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1855 struct ieee80211_sta *sta, void *priv_sta,
1856 struct sk_buff *skb) 1856 struct sk_buff *skb)
1857{ 1857{
1858 struct ath_softc *sc = priv; 1858 struct ath_softc *sc = priv;
1859 struct ath_tx_info_priv *tx_info_priv; 1859 struct ath_tx_info_priv *tx_info_priv;
1860 struct ath_node *an; 1860 struct ath_node *an;
1861 struct sta_info *sta;
1862 struct ieee80211_local *local;
1863 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1861 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1864 struct ieee80211_hdr *hdr; 1862 struct ieee80211_hdr *hdr;
1865 __le16 fc; 1863 __le16 fc;
1866 1864
1867 local = hw_to_local(sc->hw);
1868 hdr = (struct ieee80211_hdr *)skb->data; 1865 hdr = (struct ieee80211_hdr *)skb->data;
1869 fc = hdr->frame_control; 1866 fc = hdr->frame_control;
1870 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1867 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
@@ -1873,8 +1870,7 @@ static void ath_tx_status(void *priv, struct net_device *dev,
1873 an = ath_node_find(sc, hdr->addr1); 1870 an = ath_node_find(sc, hdr->addr1);
1874 spin_unlock_bh(&sc->node_lock); 1871 spin_unlock_bh(&sc->node_lock);
1875 1872
1876 sta = sta_info_get(local, hdr->addr1); 1873 if (!an || !priv_sta || !ieee80211_is_data(fc)) {
1877 if (!an || !sta || !ieee80211_is_data(fc)) {
1878 if (tx_info->driver_data[0] != NULL) { 1874 if (tx_info->driver_data[0] != NULL) {
1879 kfree(tx_info->driver_data[0]); 1875 kfree(tx_info->driver_data[0]);
1880 tx_info->driver_data[0] = NULL; 1876 tx_info->driver_data[0] = NULL;
@@ -1882,24 +1878,22 @@ static void ath_tx_status(void *priv, struct net_device *dev,
1882 return; 1878 return;
1883 } 1879 }
1884 if (tx_info->driver_data[0] != NULL) { 1880 if (tx_info->driver_data[0] != NULL) {
1885 ath_rate_tx_complete(sc, an, sta->rate_ctrl_priv, tx_info_priv); 1881 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1886 kfree(tx_info->driver_data[0]); 1882 kfree(tx_info->driver_data[0]);
1887 tx_info->driver_data[0] = NULL; 1883 tx_info->driver_data[0] = NULL;
1888 } 1884 }
1889} 1885}
1890 1886
1891static void ath_tx_aggr_resp(struct ath_softc *sc, 1887static void ath_tx_aggr_resp(struct ath_softc *sc,
1892 struct sta_info *sta, 1888 struct ieee80211_supported_band *sband,
1889 struct ieee80211_sta *sta,
1893 struct ath_node *an, 1890 struct ath_node *an,
1894 u8 tidno) 1891 u8 tidno)
1895{ 1892{
1896 struct ieee80211_hw *hw = sc->hw;
1897 struct ieee80211_local *local;
1898 struct ath_atx_tid *txtid; 1893 struct ath_atx_tid *txtid;
1899 struct ieee80211_supported_band *sband;
1900 u16 buffersize = 0; 1894 u16 buffersize = 0;
1901 int state; 1895 int state;
1902 DECLARE_MAC_BUF(mac); 1896 struct sta_info *si;
1903 1897
1904 if (!(sc->sc_flags & SC_OP_TXAGGR)) 1898 if (!(sc->sc_flags & SC_OP_TXAGGR))
1905 return; 1899 return;
@@ -1908,11 +1902,16 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
1908 if (!txtid->paused) 1902 if (!txtid->paused)
1909 return; 1903 return;
1910 1904
1911 local = hw_to_local(sc->hw); 1905 /*
1912 sband = hw->wiphy->bands[hw->conf.channel->band]; 1906 * XXX: This is entirely busted, we aren't supposed to
1907 * access the sta from here because it's internal
1908 * to mac80211, and looking at the state without
1909 * locking is wrong too.
1910 */
1911 si = container_of(sta, struct sta_info, sta);
1913 buffersize = IEEE80211_MIN_AMPDU_BUF << 1912 buffersize = IEEE80211_MIN_AMPDU_BUF <<
1914 sband->ht_info.ampdu_factor; /* FIXME */ 1913 sband->ht_info.ampdu_factor; /* FIXME */
1915 state = sta->ampdu_mlme.tid_state_tx[tidno]; 1914 state = si->ampdu_mlme.tid_state_tx[tidno];
1916 1915
1917 if (state & HT_ADDBA_RECEIVED_MSK) { 1916 if (state & HT_ADDBA_RECEIVED_MSK) {
1918 txtid->addba_exchangecomplete = 1; 1917 txtid->addba_exchangecomplete = 1;
@@ -1928,18 +1927,15 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
1928 } 1927 }
1929} 1928}
1930 1929
1931static void ath_get_rate(void *priv, struct net_device *dev, 1930static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1932 struct ieee80211_supported_band *sband, 1931 struct ieee80211_sta *sta, void *priv_sta,
1933 struct sk_buff *skb, 1932 struct sk_buff *skb, struct rate_selection *sel)
1934 struct rate_selection *sel)
1935{ 1933{
1936 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1934 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1937 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1935 struct ath_softc *sc = priv;
1938 struct sta_info *sta;
1939 struct ath_softc *sc = (struct ath_softc *)priv;
1940 struct ieee80211_hw *hw = sc->hw; 1936 struct ieee80211_hw *hw = sc->hw;
1941 struct ath_tx_info_priv *tx_info_priv; 1937 struct ath_tx_info_priv *tx_info_priv;
1942 struct ath_rate_node *ath_rc_priv; 1938 struct ath_rate_node *ath_rc_priv = priv_sta;
1943 struct ath_node *an; 1939 struct ath_node *an;
1944 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1940 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1945 int is_probe = FALSE, chk, ret; 1941 int is_probe = FALSE, chk, ret;
@@ -1955,8 +1951,7 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1955 ASSERT(tx_info->driver_data[0] != NULL); 1951 ASSERT(tx_info->driver_data[0] != NULL);
1956 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1952 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1957 1953
1958 sta = sta_info_get(local, hdr->addr1); 1954 lowest_idx = rate_lowest_index(sband, sta);
1959 lowest_idx = rate_lowest_index(local, sband, sta);
1960 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10; 1955 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
1961 /* lowest rate for management and multicast/broadcast frames */ 1956 /* lowest rate for management and multicast/broadcast frames */
1962 if (!ieee80211_is_data(fc) || 1957 if (!ieee80211_is_data(fc) ||
@@ -1965,8 +1960,6 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1965 return; 1960 return;
1966 } 1961 }
1967 1962
1968 ath_rc_priv = sta->rate_ctrl_priv;
1969
1970 /* Find tx rate for unicast frames */ 1963 /* Find tx rate for unicast frames */
1971 ath_rate_findrate(sc, ath_rc_priv, 1964 ath_rate_findrate(sc, ath_rc_priv,
1972 ATH_11N_TXMAXTRY, 4, 1965 ATH_11N_TXMAXTRY, 4,
@@ -1975,8 +1968,7 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1975 &is_probe, 1968 &is_probe,
1976 false); 1969 false);
1977 if (is_probe) 1970 if (is_probe)
1978 sel->probe_idx = ((struct ath_tx_ratectrl *) 1971 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1979 sta->rate_ctrl_priv)->probe_rate;
1980 1972
1981 /* Ratecontrol sometimes returns invalid rate index */ 1973 /* Ratecontrol sometimes returns invalid rate index */
1982 if (tx_info_priv->rcs[0].rix != 0xff) 1974 if (tx_info_priv->rcs[0].rix != 0xff)
@@ -2020,37 +2012,31 @@ static void ath_get_rate(void *priv, struct net_device *dev,
2020 __func__, 2012 __func__,
2021 print_mac(mac, hdr->addr1)); 2013 print_mac(mac, hdr->addr1));
2022 } else if (chk == AGGR_EXCHANGE_PROGRESS) 2014 } else if (chk == AGGR_EXCHANGE_PROGRESS)
2023 ath_tx_aggr_resp(sc, sta, an, tid); 2015 ath_tx_aggr_resp(sc, sband, sta, an, tid);
2024 } 2016 }
2025 } 2017 }
2026} 2018}
2027 2019
2028static void ath_rate_init(void *priv, void *priv_sta, 2020static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
2029 struct ieee80211_local *local, 2021 struct ieee80211_sta *sta, void *priv_sta)
2030 struct sta_info *sta)
2031{ 2022{
2032 struct ieee80211_supported_band *sband; 2023 struct ath_softc *sc = priv;
2033 struct ieee80211_hw *hw = local_to_hw(local);
2034 struct ieee80211_conf *conf = &local->hw.conf;
2035 struct ath_softc *sc = hw->priv;
2036 struct ath_rate_node *ath_rc_priv = priv_sta; 2024 struct ath_rate_node *ath_rc_priv = priv_sta;
2037 int i, j = 0; 2025 int i, j = 0;
2038 2026
2039 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 2027 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2040 2028
2041 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2029 ath_setup_rates(sc, sband, sta, ath_rc_priv);
2042 2030 if (sc->hw->conf.flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
2043 ath_setup_rates(local, sta);
2044 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
2045 for (i = 0; i < MCS_SET_SIZE; i++) { 2031 for (i = 0; i < MCS_SET_SIZE; i++) {
2046 if (conf->ht_conf.supp_mcs_set[i/8] & (1<<(i%8))) 2032 if (sc->hw->conf.ht_conf.supp_mcs_set[i/8] & (1<<(i%8)))
2047 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i; 2033 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
2048 if (j == ATH_RATE_MAX) 2034 if (j == ATH_RATE_MAX)
2049 break; 2035 break;
2050 } 2036 }
2051 ath_rc_priv->neg_ht_rates.rs_nrates = j; 2037 ath_rc_priv->neg_ht_rates.rs_nrates = j;
2052 } 2038 }
2053 ath_rc_node_update(hw, priv_sta); 2039 ath_rc_node_update(sc->hw, priv_sta);
2054} 2040}
2055 2041
2056static void ath_rate_clear(void *priv) 2042static void ath_rate_clear(void *priv)
@@ -2058,13 +2044,12 @@ static void ath_rate_clear(void *priv)
2058 return; 2044 return;
2059} 2045}
2060 2046
2061static void *ath_rate_alloc(struct ieee80211_local *local) 2047static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
2062{ 2048{
2063 struct ieee80211_hw *hw = local_to_hw(local);
2064 struct ath_softc *sc = hw->priv; 2049 struct ath_softc *sc = hw->priv;
2065 2050
2066 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 2051 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2067 return local->hw.priv; 2052 return hw->priv;
2068} 2053}
2069 2054
2070static void ath_rate_free(void *priv) 2055static void ath_rate_free(void *priv)
@@ -2072,7 +2057,7 @@ static void ath_rate_free(void *priv)
2072 return; 2057 return;
2073} 2058}
2074 2059
2075static void *ath_rate_alloc_sta(void *priv, gfp_t gfp) 2060static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
2076{ 2061{
2077 struct ath_softc *sc = priv; 2062 struct ath_softc *sc = priv;
2078 struct ath_vap *avp = sc->sc_vaps[0]; 2063 struct ath_vap *avp = sc->sc_vaps[0];
@@ -2092,7 +2077,8 @@ static void *ath_rate_alloc_sta(void *priv, gfp_t gfp)
2092 return rate_priv; 2077 return rate_priv;
2093} 2078}
2094 2079
2095static void ath_rate_free_sta(void *priv, void *priv_sta) 2080static void ath_rate_free_sta(void *priv, struct ieee80211_sta *sta,
2081 void *priv_sta)
2096{ 2082{
2097 struct ath_rate_node *rate_priv = priv_sta; 2083 struct ath_rate_node *rate_priv = priv_sta;
2098 struct ath_softc *sc = priv; 2084 struct ath_softc *sc = priv;
@@ -2111,7 +2097,7 @@ static struct rate_control_ops ath_rate_ops = {
2111 .alloc = ath_rate_alloc, 2097 .alloc = ath_rate_alloc,
2112 .free = ath_rate_free, 2098 .free = ath_rate_free,
2113 .alloc_sta = ath_rate_alloc_sta, 2099 .alloc_sta = ath_rate_alloc_sta,
2114 .free_sta = ath_rate_free_sta 2100 .free_sta = ath_rate_free_sta,
2115}; 2101};
2116 2102
2117int ath_rate_control_register(void) 2103int ath_rate_control_register(void)