diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-18 12:14:18 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-24 16:18:03 -0400 |
commit | 4b7679a561e552eeda1e3567119bef2bca99b66e (patch) | |
tree | b5f2b45c9186eb954f9329322d07e277e669b422 | |
parent | 2ff6a6d4e92270283432690adf53a7e5ab186d19 (diff) |
mac80211: clean up rate control API
Long awaited, hard work. This patch totally cleans up the rate control
API to remove the requirement to include internal headers outside of
net/mac80211/.
There's one internal use in the PID algorithm left for mesh networking,
we'll have to figure out a way to clean that one up and decide how to
do the peer link evaluation, possibly independent of the rate control
algorithm or via new API.
Additionally, ath9k is left using the cross-inclusion hack for now, we
will add new API where necessary to make this work properly, but right
now I'm not expert enough to do it. It's still off better than before.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath9k/rc.c | 98 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 182 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 146 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 11 | ||||
-rw-r--r-- | include/net/mac80211.h | 68 | ||||
-rw-r--r-- | net/mac80211/cfg.c | 2 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 2 | ||||
-rw-r--r-- | net/mac80211/main.c | 4 | ||||
-rw-r--r-- | net/mac80211/mlme.c | 4 | ||||
-rw-r--r-- | net/mac80211/rate.c | 71 | ||||
-rw-r--r-- | net/mac80211/rate.h | 102 | ||||
-rw-r--r-- | net/mac80211/rc80211_pid.h | 2 | ||||
-rw-r--r-- | net/mac80211/rc80211_pid_algo.c | 158 | ||||
-rw-r--r-- | net/mac80211/sta_info.c | 17 | ||||
-rw-r--r-- | net/mac80211/sta_info.h | 2 | ||||
-rw-r--r-- | net/mac80211/tx.c | 5 |
18 files changed, 373 insertions, 514 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 | ||
25 | static u32 tx_triglevel_max; | 26 | static 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 | ||
1815 | static void ath_setup_rates(struct ieee80211_local *local, struct sta_info *sta) | 1816 | static 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 */ |
1855 | static void ath_tx_status(void *priv, struct net_device *dev, | 1854 | static 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 | ||
1891 | static void ath_tx_aggr_resp(struct ath_softc *sc, | 1887 | static 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 | ||
1931 | static void ath_get_rate(void *priv, struct net_device *dev, | 1930 | static 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 | ||
2028 | static void ath_rate_init(void *priv, void *priv_sta, | 2020 | static 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 | ||
2056 | static void ath_rate_clear(void *priv) | 2042 | static 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 | ||
2061 | static void *ath_rate_alloc(struct ieee80211_local *local) | 2047 | static 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 | ||
2070 | static void ath_rate_free(void *priv) | 2055 | static 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 | ||
2075 | static void *ath_rate_alloc_sta(void *priv, gfp_t gfp) | 2060 | static 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 | ||
2095 | static void ath_rate_free_sta(void *priv, void *priv_sta) | 2080 | static 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 | ||
2117 | int ath_rate_control_register(void) | 2103 | int ath_rate_control_register(void) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index a279bf1dc9b0..6fc5e7361f26 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -36,8 +36,6 @@ | |||
36 | 36 | ||
37 | #include <linux/workqueue.h> | 37 | #include <linux/workqueue.h> |
38 | 38 | ||
39 | #include "../net/mac80211/rate.h" | ||
40 | |||
41 | #include "iwl-3945.h" | 39 | #include "iwl-3945.h" |
42 | 40 | ||
43 | #define RS_NAME "iwl-3945-rs" | 41 | #define RS_NAME "iwl-3945-rs" |
@@ -319,10 +317,10 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, | |||
319 | } | 317 | } |
320 | } | 318 | } |
321 | 319 | ||
322 | static void rs_rate_init(void *priv_rate, void *priv_sta, | 320 | static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband, |
323 | struct ieee80211_local *local, struct sta_info *sta) | 321 | struct ieee80211_sta *sta, void *priv_sta) |
324 | { | 322 | { |
325 | struct iwl3945_rs_sta *rs_sta = (void *)sta->rate_ctrl_priv; | 323 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
326 | int i; | 324 | int i; |
327 | 325 | ||
328 | IWL_DEBUG_RATE("enter\n"); | 326 | IWL_DEBUG_RATE("enter\n"); |
@@ -333,22 +331,22 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
333 | * after assoc.. */ | 331 | * after assoc.. */ |
334 | 332 | ||
335 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { | 333 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { |
336 | if (sta->sta.supp_rates[local->hw.conf.channel->band] & (1 << i)) { | 334 | if (sta->supp_rates[sband->band] & (1 << i)) { |
337 | rs_sta->last_txrate_idx = i; | 335 | rs_sta->last_txrate_idx = i; |
338 | break; | 336 | break; |
339 | } | 337 | } |
340 | } | 338 | } |
341 | 339 | ||
342 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ | 340 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ |
343 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) | 341 | if (sband->band == IEEE80211_BAND_5GHZ) |
344 | rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; | 342 | rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
345 | 343 | ||
346 | IWL_DEBUG_RATE("leave\n"); | 344 | IWL_DEBUG_RATE("leave\n"); |
347 | } | 345 | } |
348 | 346 | ||
349 | static void *rs_alloc(struct ieee80211_local *local) | 347 | static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
350 | { | 348 | { |
351 | return local->hw.priv; | 349 | return hw->priv; |
352 | } | 350 | } |
353 | 351 | ||
354 | /* rate scale requires free function to be implemented */ | 352 | /* rate scale requires free function to be implemented */ |
@@ -356,17 +354,24 @@ static void rs_free(void *priv) | |||
356 | { | 354 | { |
357 | return; | 355 | return; |
358 | } | 356 | } |
357 | |||
359 | static void rs_clear(void *priv) | 358 | static void rs_clear(void *priv) |
360 | { | 359 | { |
361 | return; | 360 | return; |
362 | } | 361 | } |
363 | 362 | ||
364 | 363 | ||
365 | static void *rs_alloc_sta(void *priv, gfp_t gfp) | 364 | static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) |
366 | { | 365 | { |
367 | struct iwl3945_rs_sta *rs_sta; | 366 | struct iwl3945_rs_sta *rs_sta; |
367 | struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; | ||
368 | int i; | 368 | int i; |
369 | 369 | ||
370 | /* | ||
371 | * XXX: If it's using sta->drv_priv anyway, it might | ||
372 | * as well just put all the information there. | ||
373 | */ | ||
374 | |||
370 | IWL_DEBUG_RATE("enter\n"); | 375 | IWL_DEBUG_RATE("enter\n"); |
371 | 376 | ||
372 | rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); | 377 | rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); |
@@ -375,6 +380,8 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp) | |||
375 | return NULL; | 380 | return NULL; |
376 | } | 381 | } |
377 | 382 | ||
383 | psta->rs_sta = rs_sta; | ||
384 | |||
378 | spin_lock_init(&rs_sta->lock); | 385 | spin_lock_init(&rs_sta->lock); |
379 | 386 | ||
380 | rs_sta->start_rate = IWL_RATE_INVALID; | 387 | rs_sta->start_rate = IWL_RATE_INVALID; |
@@ -400,10 +407,14 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp) | |||
400 | return rs_sta; | 407 | return rs_sta; |
401 | } | 408 | } |
402 | 409 | ||
403 | static void rs_free_sta(void *priv, void *priv_sta) | 410 | static void rs_free_sta(void *priv, struct ieee80211_sta *sta, |
411 | void *priv_sta) | ||
404 | { | 412 | { |
413 | struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; | ||
405 | struct iwl3945_rs_sta *rs_sta = priv_sta; | 414 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
406 | 415 | ||
416 | psta->rs_sta = NULL; | ||
417 | |||
407 | IWL_DEBUG_RATE("enter\n"); | 418 | IWL_DEBUG_RATE("enter\n"); |
408 | del_timer_sync(&rs_sta->rate_scale_flush); | 419 | del_timer_sync(&rs_sta->rate_scale_flush); |
409 | kfree(rs_sta); | 420 | kfree(rs_sta); |
@@ -445,26 +456,19 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate) | |||
445 | * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by | 456 | * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by |
446 | * the hardware for each rate. | 457 | * the hardware for each rate. |
447 | */ | 458 | */ |
448 | static void rs_tx_status(void *priv_rate, | 459 | static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, |
449 | struct net_device *dev, | 460 | struct ieee80211_sta *sta, void *priv_sta, |
450 | struct sk_buff *skb) | 461 | struct sk_buff *skb) |
451 | { | 462 | { |
452 | u8 retries, current_count; | 463 | u8 retries, current_count; |
453 | int scale_rate_index, first_index, last_index; | 464 | int scale_rate_index, first_index, last_index; |
454 | unsigned long flags; | 465 | unsigned long flags; |
455 | struct sta_info *sta; | ||
456 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
457 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 466 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; |
458 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 467 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
459 | struct iwl3945_rs_sta *rs_sta; | ||
460 | struct ieee80211_supported_band *sband; | ||
461 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 468 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
462 | 469 | ||
463 | IWL_DEBUG_RATE("enter\n"); | 470 | IWL_DEBUG_RATE("enter\n"); |
464 | 471 | ||
465 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
466 | |||
467 | |||
468 | retries = info->status.retry_count; | 472 | retries = info->status.retry_count; |
469 | first_index = sband->bitrates[info->tx_rate_idx].hw_value; | 473 | first_index = sband->bitrates[info->tx_rate_idx].hw_value; |
470 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 474 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
@@ -472,17 +476,11 @@ static void rs_tx_status(void *priv_rate, | |||
472 | return; | 476 | return; |
473 | } | 477 | } |
474 | 478 | ||
475 | rcu_read_lock(); | 479 | if (!priv_sta) { |
476 | |||
477 | sta = sta_info_get(local, hdr->addr1); | ||
478 | if (!sta || !sta->rate_ctrl_priv) { | ||
479 | rcu_read_unlock(); | ||
480 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 480 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
481 | return; | 481 | return; |
482 | } | 482 | } |
483 | 483 | ||
484 | rs_sta = (void *)sta->rate_ctrl_priv; | ||
485 | |||
486 | rs_sta->tx_packets++; | 484 | rs_sta->tx_packets++; |
487 | 485 | ||
488 | scale_rate_index = first_index; | 486 | scale_rate_index = first_index; |
@@ -549,8 +547,6 @@ static void rs_tx_status(void *priv_rate, | |||
549 | 547 | ||
550 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 548 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
551 | 549 | ||
552 | rcu_read_unlock(); | ||
553 | |||
554 | IWL_DEBUG_RATE("leave\n"); | 550 | IWL_DEBUG_RATE("leave\n"); |
555 | 551 | ||
556 | return; | 552 | return; |
@@ -634,16 +630,15 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
634 | * rate table and must reference the driver allocated rate table | 630 | * rate table and must reference the driver allocated rate table |
635 | * | 631 | * |
636 | */ | 632 | */ |
637 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 633 | static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, |
638 | struct ieee80211_supported_band *sband, | 634 | struct ieee80211_sta *sta, void *priv_sta, |
639 | struct sk_buff *skb, | 635 | struct sk_buff *skb, struct rate_selection *sel) |
640 | struct rate_selection *sel) | ||
641 | { | 636 | { |
642 | u8 low = IWL_RATE_INVALID; | 637 | u8 low = IWL_RATE_INVALID; |
643 | u8 high = IWL_RATE_INVALID; | 638 | u8 high = IWL_RATE_INVALID; |
644 | u16 high_low; | 639 | u16 high_low; |
645 | int index; | 640 | int index; |
646 | struct iwl3945_rs_sta *rs_sta; | 641 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
647 | struct iwl3945_rate_scale_data *window = NULL; | 642 | struct iwl3945_rate_scale_data *window = NULL; |
648 | int current_tpt = IWL_INV_TPT; | 643 | int current_tpt = IWL_INV_TPT; |
649 | int low_tpt = IWL_INV_TPT; | 644 | int low_tpt = IWL_INV_TPT; |
@@ -651,34 +646,25 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
651 | u32 fail_count; | 646 | u32 fail_count; |
652 | s8 scale_action = 0; | 647 | s8 scale_action = 0; |
653 | unsigned long flags; | 648 | unsigned long flags; |
654 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
655 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 649 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
656 | struct sta_info *sta; | ||
657 | u16 fc, rate_mask; | 650 | u16 fc, rate_mask; |
658 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 651 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r; |
659 | DECLARE_MAC_BUF(mac); | 652 | DECLARE_MAC_BUF(mac); |
660 | 653 | ||
661 | IWL_DEBUG_RATE("enter\n"); | 654 | IWL_DEBUG_RATE("enter\n"); |
662 | 655 | ||
663 | rcu_read_lock(); | ||
664 | |||
665 | sta = sta_info_get(local, hdr->addr1); | ||
666 | |||
667 | /* Send management frames and broadcast/multicast data using lowest | 656 | /* Send management frames and broadcast/multicast data using lowest |
668 | * rate. */ | 657 | * rate. */ |
669 | fc = le16_to_cpu(hdr->frame_control); | 658 | fc = le16_to_cpu(hdr->frame_control); |
670 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || | 659 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || |
671 | is_multicast_ether_addr(hdr->addr1) || | 660 | is_multicast_ether_addr(hdr->addr1) || |
672 | !sta || !sta->rate_ctrl_priv) { | 661 | !sta || !priv_sta) { |
673 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 662 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
674 | sel->rate_idx = rate_lowest_index(local, sband, sta); | 663 | sel->rate_idx = rate_lowest_index(sband, sta); |
675 | rcu_read_unlock(); | ||
676 | return; | 664 | return; |
677 | } | 665 | } |
678 | 666 | ||
679 | rs_sta = (void *)sta->rate_ctrl_priv; | 667 | rate_mask = sta->supp_rates[sband->band]; |
680 | |||
681 | rate_mask = sta->sta.supp_rates[sband->band]; | ||
682 | index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); | 668 | index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
683 | 669 | ||
684 | if (sband->band == IEEE80211_BAND_5GHZ) | 670 | if (sband->band == IEEE80211_BAND_5GHZ) |
@@ -811,8 +797,6 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
811 | else | 797 | else |
812 | sel->rate_idx = rs_sta->last_txrate_idx; | 798 | sel->rate_idx = rs_sta->last_txrate_idx; |
813 | 799 | ||
814 | rcu_read_unlock(); | ||
815 | |||
816 | IWL_DEBUG_RATE("leave: %d\n", index); | 800 | IWL_DEBUG_RATE("leave: %d\n", index); |
817 | } | 801 | } |
818 | 802 | ||
@@ -829,114 +813,28 @@ static struct rate_control_ops rs_ops = { | |||
829 | .free_sta = rs_free_sta, | 813 | .free_sta = rs_free_sta, |
830 | }; | 814 | }; |
831 | 815 | ||
832 | int iwl3945_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | ||
833 | { | ||
834 | struct ieee80211_local *local = hw_to_local(hw); | ||
835 | struct iwl3945_priv *priv = hw->priv; | ||
836 | struct iwl3945_rs_sta *rs_sta; | ||
837 | struct sta_info *sta; | ||
838 | unsigned long flags; | ||
839 | int count = 0, i; | ||
840 | u32 samples = 0, success = 0, good = 0; | ||
841 | unsigned long now = jiffies; | ||
842 | u32 max_time = 0; | ||
843 | |||
844 | rcu_read_lock(); | ||
845 | |||
846 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | ||
847 | if (!sta || !sta->rate_ctrl_priv) { | ||
848 | if (sta) | ||
849 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | ||
850 | else | ||
851 | IWL_DEBUG_RATE("leave - no station!\n"); | ||
852 | rcu_read_unlock(); | ||
853 | return sprintf(buf, "station %d not found\n", sta_id); | ||
854 | } | ||
855 | |||
856 | rs_sta = (void *)sta->rate_ctrl_priv; | ||
857 | spin_lock_irqsave(&rs_sta->lock, flags); | ||
858 | i = IWL_RATE_54M_INDEX; | ||
859 | while (1) { | ||
860 | u64 mask; | ||
861 | int j; | ||
862 | |||
863 | count += | ||
864 | sprintf(&buf[count], " %2dMbs: ", iwl3945_rates[i].ieee / 2); | ||
865 | |||
866 | mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1)); | ||
867 | for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1) | ||
868 | buf[count++] = | ||
869 | (rs_sta->win[i].data & mask) ? '1' : '0'; | ||
870 | |||
871 | samples += rs_sta->win[i].counter; | ||
872 | good += rs_sta->win[i].success_counter; | ||
873 | success += rs_sta->win[i].success_counter * | ||
874 | iwl3945_rates[i].ieee; | ||
875 | |||
876 | if (rs_sta->win[i].stamp) { | ||
877 | int delta = | ||
878 | jiffies_to_msecs(now - rs_sta->win[i].stamp); | ||
879 | |||
880 | if (delta > max_time) | ||
881 | max_time = delta; | ||
882 | |||
883 | count += sprintf(&buf[count], "%5dms\n", delta); | ||
884 | } else | ||
885 | buf[count++] = '\n'; | ||
886 | |||
887 | j = iwl3945_get_prev_ieee_rate(i); | ||
888 | if (j == i) | ||
889 | break; | ||
890 | i = j; | ||
891 | } | ||
892 | spin_unlock_irqrestore(&rs_sta->lock, flags); | ||
893 | rcu_read_unlock(); | ||
894 | |||
895 | /* Display the average rate of all samples taken. | ||
896 | * | ||
897 | * NOTE: We multiple # of samples by 2 since the IEEE measurement | ||
898 | * added from iwl3945_rates is actually 2X the rate */ | ||
899 | if (samples) | ||
900 | count += sprintf( | ||
901 | &buf[count], | ||
902 | "\nAverage rate is %3d.%02dMbs over last %4dms\n" | ||
903 | "%3d%% success (%d good packets over %d tries)\n", | ||
904 | success / (2 * samples), (success * 5 / samples) % 10, | ||
905 | max_time, good * 100 / samples, good, samples); | ||
906 | else | ||
907 | count += sprintf(&buf[count], "\nAverage rate: 0Mbs\n"); | ||
908 | |||
909 | return count; | ||
910 | } | ||
911 | |||
912 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | 816 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) |
913 | { | 817 | { |
914 | struct iwl3945_priv *priv = hw->priv; | 818 | struct iwl3945_priv *priv = hw->priv; |
915 | s32 rssi = 0; | 819 | s32 rssi = 0; |
916 | unsigned long flags; | 820 | unsigned long flags; |
917 | struct ieee80211_local *local = hw_to_local(hw); | ||
918 | struct iwl3945_rs_sta *rs_sta; | 821 | struct iwl3945_rs_sta *rs_sta; |
919 | struct sta_info *sta; | 822 | struct ieee80211_sta *sta; |
823 | struct iwl3945_sta_priv *psta; | ||
920 | 824 | ||
921 | IWL_DEBUG_RATE("enter\n"); | 825 | IWL_DEBUG_RATE("enter\n"); |
922 | 826 | ||
923 | if (!local->rate_ctrl->ops->name || | ||
924 | strcmp(local->rate_ctrl->ops->name, RS_NAME)) { | ||
925 | IWL_WARNING("iwl-3945-rs not selected as rate control algo!\n"); | ||
926 | IWL_DEBUG_RATE("leave - mac80211 picked the wrong RC algo.\n"); | ||
927 | return; | ||
928 | } | ||
929 | |||
930 | rcu_read_lock(); | 827 | rcu_read_lock(); |
931 | 828 | ||
932 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | 829 | sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr); |
933 | if (!sta || !sta->rate_ctrl_priv) { | 830 | psta = (void *) sta->drv_priv; |
831 | if (!sta || !psta) { | ||
934 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | 832 | IWL_DEBUG_RATE("leave - no private rate data!\n"); |
935 | rcu_read_unlock(); | 833 | rcu_read_unlock(); |
936 | return; | 834 | return; |
937 | } | 835 | } |
938 | 836 | ||
939 | rs_sta = (void *)sta->rate_ctrl_priv; | 837 | rs_sta = psta->rs_sta; |
940 | 838 | ||
941 | spin_lock_irqsave(&rs_sta->lock, flags); | 839 | spin_lock_irqsave(&rs_sta->lock, flags); |
942 | 840 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h index f085d330bdcf..98b17ae6ef24 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h | |||
@@ -176,15 +176,6 @@ static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) | |||
176 | } | 176 | } |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * iwl3945_fill_rs_info - Fill an output text buffer with the rate representation | ||
180 | * | ||
181 | * NOTE: This is provided as a quick mechanism for a user to visualize | ||
182 | * the performance of the rate control algorithm and is not meant to be | ||
183 | * parsed software. | ||
184 | */ | ||
185 | extern int iwl3945_fill_rs_info(struct ieee80211_hw *, char *buf, u8 sta_id); | ||
186 | |||
187 | /** | ||
188 | * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info | 179 | * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info |
189 | * | 180 | * |
190 | * The specific throughput table used is based on the type of network | 181 | * The specific throughput table used is based on the type of network |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h index 2a4933b5fb64..bdd32475b99c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945.h | |||
@@ -73,6 +73,10 @@ extern struct pci_device_id iwl3945_hw_card_ids[]; | |||
73 | extern int iwl3945_param_hwcrypto; | 73 | extern int iwl3945_param_hwcrypto; |
74 | extern int iwl3945_param_queues_num; | 74 | extern int iwl3945_param_queues_num; |
75 | 75 | ||
76 | struct iwl3945_sta_priv { | ||
77 | struct iwl3945_rs_sta *rs_sta; | ||
78 | }; | ||
79 | |||
76 | enum iwl3945_antenna { | 80 | enum iwl3945_antenna { |
77 | IWL_ANTENNA_DIVERSITY, | 81 | IWL_ANTENNA_DIVERSITY, |
78 | IWL_ANTENNA_MAIN, | 82 | IWL_ANTENNA_MAIN, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 8b57b390c8ba..93944de923ca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -35,8 +35,6 @@ | |||
35 | 35 | ||
36 | #include <linux/workqueue.h> | 36 | #include <linux/workqueue.h> |
37 | 37 | ||
38 | #include "../net/mac80211/rate.h" | ||
39 | |||
40 | #include "iwl-dev.h" | 38 | #include "iwl-dev.h" |
41 | #include "iwl-sta.h" | 39 | #include "iwl-sta.h" |
42 | #include "iwl-core.h" | 40 | #include "iwl-core.h" |
@@ -169,9 +167,9 @@ struct iwl_lq_sta { | |||
169 | }; | 167 | }; |
170 | 168 | ||
171 | static void rs_rate_scale_perform(struct iwl_priv *priv, | 169 | static void rs_rate_scale_perform(struct iwl_priv *priv, |
172 | struct net_device *dev, | ||
173 | struct ieee80211_hdr *hdr, | 170 | struct ieee80211_hdr *hdr, |
174 | struct sta_info *sta); | 171 | struct ieee80211_sta *sta, |
172 | struct iwl_lq_sta *lq_sta); | ||
175 | static void rs_fill_link_cmd(const struct iwl_priv *priv, | 173 | static void rs_fill_link_cmd(const struct iwl_priv *priv, |
176 | struct iwl_lq_sta *lq_sta, u32 rate_n_flags); | 174 | struct iwl_lq_sta *lq_sta, u32 rate_n_flags); |
177 | 175 | ||
@@ -357,20 +355,20 @@ static u32 rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) | |||
357 | 355 | ||
358 | static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, | 356 | static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, |
359 | struct iwl_lq_sta *lq_data, u8 tid, | 357 | struct iwl_lq_sta *lq_data, u8 tid, |
360 | struct sta_info *sta) | 358 | struct ieee80211_sta *sta) |
361 | { | 359 | { |
362 | DECLARE_MAC_BUF(mac); | 360 | DECLARE_MAC_BUF(mac); |
363 | 361 | ||
364 | if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { | 362 | if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { |
365 | IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", | 363 | IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", |
366 | print_mac(mac, sta->sta.addr), tid); | 364 | print_mac(mac, sta->addr), tid); |
367 | ieee80211_start_tx_ba_session(priv->hw, sta->sta.addr, tid); | 365 | ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); |
368 | } | 366 | } |
369 | } | 367 | } |
370 | 368 | ||
371 | static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, | 369 | static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, |
372 | struct iwl_lq_sta *lq_data, | 370 | struct iwl_lq_sta *lq_data, |
373 | struct sta_info *sta) | 371 | struct ieee80211_sta *sta) |
374 | { | 372 | { |
375 | if ((tid < TID_MAX_LOAD_COUNT)) | 373 | if ((tid < TID_MAX_LOAD_COUNT)) |
376 | rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); | 374 | rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); |
@@ -770,7 +768,8 @@ out: | |||
770 | /* | 768 | /* |
771 | * mac80211 sends us Tx status | 769 | * mac80211 sends us Tx status |
772 | */ | 770 | */ |
773 | static void rs_tx_status(void *priv_rate, struct net_device *dev, | 771 | static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, |
772 | struct ieee80211_sta *sta, void *priv_sta, | ||
774 | struct sk_buff *skb) | 773 | struct sk_buff *skb) |
775 | { | 774 | { |
776 | int status; | 775 | int status; |
@@ -778,11 +777,9 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
778 | int rs_index, index = 0; | 777 | int rs_index, index = 0; |
779 | struct iwl_lq_sta *lq_sta; | 778 | struct iwl_lq_sta *lq_sta; |
780 | struct iwl_link_quality_cmd *table; | 779 | struct iwl_link_quality_cmd *table; |
781 | struct sta_info *sta; | ||
782 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 780 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
783 | struct iwl_priv *priv = (struct iwl_priv *)priv_rate; | 781 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; |
784 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 782 | struct ieee80211_hw *hw = priv->hw; |
785 | struct ieee80211_hw *hw = local_to_hw(local); | ||
786 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 783 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
787 | struct iwl_rate_scale_data *window = NULL; | 784 | struct iwl_rate_scale_data *window = NULL; |
788 | struct iwl_rate_scale_data *search_win = NULL; | 785 | struct iwl_rate_scale_data *search_win = NULL; |
@@ -808,15 +805,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
808 | if (retries > 15) | 805 | if (retries > 15) |
809 | retries = 15; | 806 | retries = 15; |
810 | 807 | ||
811 | rcu_read_lock(); | 808 | lq_sta = (struct iwl_lq_sta *)priv_sta; |
812 | |||
813 | sta = sta_info_get(local, hdr->addr1); | ||
814 | |||
815 | if (!sta || !sta->rate_ctrl_priv) | ||
816 | goto out; | ||
817 | |||
818 | |||
819 | lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; | ||
820 | 809 | ||
821 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && | 810 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && |
822 | !lq_sta->ibss_sta_added) | 811 | !lq_sta->ibss_sta_added) |
@@ -962,9 +951,8 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
962 | } | 951 | } |
963 | 952 | ||
964 | /* See if there's a better rate or modulation mode to try. */ | 953 | /* See if there's a better rate or modulation mode to try. */ |
965 | rs_rate_scale_perform(priv, dev, hdr, sta); | 954 | rs_rate_scale_perform(priv, hdr, sta, lq_sta); |
966 | out: | 955 | out: |
967 | rcu_read_unlock(); | ||
968 | return; | 956 | return; |
969 | } | 957 | } |
970 | 958 | ||
@@ -1140,7 +1128,7 @@ static s32 rs_get_best_rate(struct iwl_priv *priv, | |||
1140 | static int rs_switch_to_mimo2(struct iwl_priv *priv, | 1128 | static int rs_switch_to_mimo2(struct iwl_priv *priv, |
1141 | struct iwl_lq_sta *lq_sta, | 1129 | struct iwl_lq_sta *lq_sta, |
1142 | struct ieee80211_conf *conf, | 1130 | struct ieee80211_conf *conf, |
1143 | struct sta_info *sta, | 1131 | struct ieee80211_sta *sta, |
1144 | struct iwl_scale_tbl_info *tbl, int index) | 1132 | struct iwl_scale_tbl_info *tbl, int index) |
1145 | { | 1133 | { |
1146 | u16 rate_mask; | 1134 | u16 rate_mask; |
@@ -1148,10 +1136,10 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1148 | s8 is_green = lq_sta->is_green; | 1136 | s8 is_green = lq_sta->is_green; |
1149 | 1137 | ||
1150 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || | 1138 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || |
1151 | !sta->sta.ht_info.ht_supported) | 1139 | !sta->ht_info.ht_supported) |
1152 | return -1; | 1140 | return -1; |
1153 | 1141 | ||
1154 | if (((sta->sta.ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2) | 1142 | if (((sta->ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2) |
1155 | == WLAN_HT_CAP_SM_PS_STATIC) | 1143 | == WLAN_HT_CAP_SM_PS_STATIC) |
1156 | return -1; | 1144 | return -1; |
1157 | 1145 | ||
@@ -1208,7 +1196,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1208 | static int rs_switch_to_siso(struct iwl_priv *priv, | 1196 | static int rs_switch_to_siso(struct iwl_priv *priv, |
1209 | struct iwl_lq_sta *lq_sta, | 1197 | struct iwl_lq_sta *lq_sta, |
1210 | struct ieee80211_conf *conf, | 1198 | struct ieee80211_conf *conf, |
1211 | struct sta_info *sta, | 1199 | struct ieee80211_sta *sta, |
1212 | struct iwl_scale_tbl_info *tbl, int index) | 1200 | struct iwl_scale_tbl_info *tbl, int index) |
1213 | { | 1201 | { |
1214 | u16 rate_mask; | 1202 | u16 rate_mask; |
@@ -1216,7 +1204,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
1216 | s32 rate; | 1204 | s32 rate; |
1217 | 1205 | ||
1218 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || | 1206 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || |
1219 | !sta->sta.ht_info.ht_supported) | 1207 | !sta->ht_info.ht_supported) |
1220 | return -1; | 1208 | return -1; |
1221 | 1209 | ||
1222 | IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); | 1210 | IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); |
@@ -1268,7 +1256,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
1268 | static int rs_move_legacy_other(struct iwl_priv *priv, | 1256 | static int rs_move_legacy_other(struct iwl_priv *priv, |
1269 | struct iwl_lq_sta *lq_sta, | 1257 | struct iwl_lq_sta *lq_sta, |
1270 | struct ieee80211_conf *conf, | 1258 | struct ieee80211_conf *conf, |
1271 | struct sta_info *sta, | 1259 | struct ieee80211_sta *sta, |
1272 | int index) | 1260 | int index) |
1273 | { | 1261 | { |
1274 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1262 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
@@ -1376,7 +1364,7 @@ out: | |||
1376 | static int rs_move_siso_to_other(struct iwl_priv *priv, | 1364 | static int rs_move_siso_to_other(struct iwl_priv *priv, |
1377 | struct iwl_lq_sta *lq_sta, | 1365 | struct iwl_lq_sta *lq_sta, |
1378 | struct ieee80211_conf *conf, | 1366 | struct ieee80211_conf *conf, |
1379 | struct sta_info *sta, int index) | 1367 | struct ieee80211_sta *sta, int index) |
1380 | { | 1368 | { |
1381 | u8 is_green = lq_sta->is_green; | 1369 | u8 is_green = lq_sta->is_green; |
1382 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1370 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
@@ -1487,7 +1475,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1487 | static int rs_move_mimo_to_other(struct iwl_priv *priv, | 1475 | static int rs_move_mimo_to_other(struct iwl_priv *priv, |
1488 | struct iwl_lq_sta *lq_sta, | 1476 | struct iwl_lq_sta *lq_sta, |
1489 | struct ieee80211_conf *conf, | 1477 | struct ieee80211_conf *conf, |
1490 | struct sta_info *sta, int index) | 1478 | struct ieee80211_sta *sta, int index) |
1491 | { | 1479 | { |
1492 | s8 is_green = lq_sta->is_green; | 1480 | s8 is_green = lq_sta->is_green; |
1493 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1481 | struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
@@ -1680,12 +1668,11 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta) | |||
1680 | * Do rate scaling and search for new modulation mode. | 1668 | * Do rate scaling and search for new modulation mode. |
1681 | */ | 1669 | */ |
1682 | static void rs_rate_scale_perform(struct iwl_priv *priv, | 1670 | static void rs_rate_scale_perform(struct iwl_priv *priv, |
1683 | struct net_device *dev, | ||
1684 | struct ieee80211_hdr *hdr, | 1671 | struct ieee80211_hdr *hdr, |
1685 | struct sta_info *sta) | 1672 | struct ieee80211_sta *sta, |
1673 | struct iwl_lq_sta *lq_sta) | ||
1686 | { | 1674 | { |
1687 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1675 | struct ieee80211_hw *hw = priv->hw; |
1688 | struct ieee80211_hw *hw = local_to_hw(local); | ||
1689 | struct ieee80211_conf *conf = &hw->conf; | 1676 | struct ieee80211_conf *conf = &hw->conf; |
1690 | int low = IWL_RATE_INVALID; | 1677 | int low = IWL_RATE_INVALID; |
1691 | int high = IWL_RATE_INVALID; | 1678 | int high = IWL_RATE_INVALID; |
@@ -1700,7 +1687,6 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1700 | __le16 fc; | 1687 | __le16 fc; |
1701 | u16 rate_mask; | 1688 | u16 rate_mask; |
1702 | u8 update_lq = 0; | 1689 | u8 update_lq = 0; |
1703 | struct iwl_lq_sta *lq_sta; | ||
1704 | struct iwl_scale_tbl_info *tbl, *tbl1; | 1690 | struct iwl_scale_tbl_info *tbl, *tbl1; |
1705 | u16 rate_scale_index_msk = 0; | 1691 | u16 rate_scale_index_msk = 0; |
1706 | u32 rate; | 1692 | u32 rate; |
@@ -1721,11 +1707,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1721 | return; | 1707 | return; |
1722 | } | 1708 | } |
1723 | 1709 | ||
1724 | if (!sta || !sta->rate_ctrl_priv) | 1710 | if (!sta || !lq_sta) |
1725 | return; | 1711 | return; |
1726 | 1712 | ||
1727 | lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; | 1713 | lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; |
1728 | lq_sta->supp_rates = sta->sta.supp_rates[lq_sta->band]; | ||
1729 | 1714 | ||
1730 | tid = rs_tl_add_packet(lq_sta, hdr); | 1715 | tid = rs_tl_add_packet(lq_sta, hdr); |
1731 | 1716 | ||
@@ -2064,9 +2049,9 @@ out: | |||
2064 | 2049 | ||
2065 | static void rs_initialize_lq(struct iwl_priv *priv, | 2050 | static void rs_initialize_lq(struct iwl_priv *priv, |
2066 | struct ieee80211_conf *conf, | 2051 | struct ieee80211_conf *conf, |
2067 | struct sta_info *sta) | 2052 | struct ieee80211_sta *sta, |
2053 | struct iwl_lq_sta *lq_sta) | ||
2068 | { | 2054 | { |
2069 | struct iwl_lq_sta *lq_sta; | ||
2070 | struct iwl_scale_tbl_info *tbl; | 2055 | struct iwl_scale_tbl_info *tbl; |
2071 | int rate_idx; | 2056 | int rate_idx; |
2072 | int i; | 2057 | int i; |
@@ -2075,10 +2060,9 @@ static void rs_initialize_lq(struct iwl_priv *priv, | |||
2075 | u8 active_tbl = 0; | 2060 | u8 active_tbl = 0; |
2076 | u8 valid_tx_ant; | 2061 | u8 valid_tx_ant; |
2077 | 2062 | ||
2078 | if (!sta || !sta->rate_ctrl_priv) | 2063 | if (!sta || !lq_sta) |
2079 | goto out; | 2064 | goto out; |
2080 | 2065 | ||
2081 | lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; | ||
2082 | i = lq_sta->last_txrate_idx; | 2066 | i = lq_sta->last_txrate_idx; |
2083 | 2067 | ||
2084 | if ((lq_sta->lq.sta_id == 0xff) && | 2068 | if ((lq_sta->lq.sta_id == 0xff) && |
@@ -2119,37 +2103,30 @@ static void rs_initialize_lq(struct iwl_priv *priv, | |||
2119 | return; | 2103 | return; |
2120 | } | 2104 | } |
2121 | 2105 | ||
2122 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 2106 | static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, |
2123 | struct ieee80211_supported_band *sband, | 2107 | struct ieee80211_sta *sta, void *priv_sta, |
2124 | struct sk_buff *skb, | 2108 | struct sk_buff *skb, struct rate_selection *sel) |
2125 | struct rate_selection *sel) | ||
2126 | { | 2109 | { |
2127 | 2110 | ||
2128 | int i; | 2111 | int i; |
2129 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 2112 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; |
2130 | struct ieee80211_conf *conf = &local->hw.conf; | 2113 | struct ieee80211_conf *conf = &priv->hw->conf; |
2131 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 2114 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
2132 | struct sta_info *sta; | ||
2133 | __le16 fc; | 2115 | __le16 fc; |
2134 | struct iwl_priv *priv = (struct iwl_priv *)priv_rate; | ||
2135 | struct iwl_lq_sta *lq_sta; | 2116 | struct iwl_lq_sta *lq_sta; |
2136 | 2117 | ||
2137 | IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); | 2118 | IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); |
2138 | 2119 | ||
2139 | rcu_read_lock(); | ||
2140 | |||
2141 | sta = sta_info_get(local, hdr->addr1); | ||
2142 | |||
2143 | /* Send management frames and broadcast/multicast data using lowest | 2120 | /* Send management frames and broadcast/multicast data using lowest |
2144 | * rate. */ | 2121 | * rate. */ |
2145 | fc = hdr->frame_control; | 2122 | fc = hdr->frame_control; |
2146 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || | 2123 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || |
2147 | !sta || !sta->rate_ctrl_priv) { | 2124 | !sta || !priv_sta) { |
2148 | sel->rate_idx = rate_lowest_index(local, sband, sta); | 2125 | sel->rate_idx = rate_lowest_index(sband, sta); |
2149 | goto out; | 2126 | return; |
2150 | } | 2127 | } |
2151 | 2128 | ||
2152 | lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; | 2129 | lq_sta = (struct iwl_lq_sta *)priv_sta; |
2153 | i = lq_sta->last_txrate_idx; | 2130 | i = lq_sta->last_txrate_idx; |
2154 | 2131 | ||
2155 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && | 2132 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && |
@@ -2167,23 +2144,22 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2167 | lq_sta->lq.sta_id = sta_id; | 2144 | lq_sta->lq.sta_id = sta_id; |
2168 | lq_sta->lq.rs_table[0].rate_n_flags = 0; | 2145 | lq_sta->lq.rs_table[0].rate_n_flags = 0; |
2169 | lq_sta->ibss_sta_added = 1; | 2146 | lq_sta->ibss_sta_added = 1; |
2170 | rs_initialize_lq(priv, conf, sta); | 2147 | rs_initialize_lq(priv, conf, sta, lq_sta); |
2171 | } | 2148 | } |
2172 | } | 2149 | } |
2173 | 2150 | ||
2174 | if ((i < 0) || (i > IWL_RATE_COUNT)) { | 2151 | if ((i < 0) || (i > IWL_RATE_COUNT)) { |
2175 | sel->rate_idx = rate_lowest_index(local, sband, sta); | 2152 | sel->rate_idx = rate_lowest_index(sband, sta); |
2176 | goto out; | 2153 | return; |
2177 | } | 2154 | } |
2178 | 2155 | ||
2179 | if (sband->band == IEEE80211_BAND_5GHZ) | 2156 | if (sband->band == IEEE80211_BAND_5GHZ) |
2180 | i -= IWL_FIRST_OFDM_RATE; | 2157 | i -= IWL_FIRST_OFDM_RATE; |
2181 | sel->rate_idx = i; | 2158 | sel->rate_idx = i; |
2182 | out: | ||
2183 | rcu_read_unlock(); | ||
2184 | } | 2159 | } |
2185 | 2160 | ||
2186 | static void *rs_alloc_sta(void *priv_rate, gfp_t gfp) | 2161 | static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, |
2162 | gfp_t gfp) | ||
2187 | { | 2163 | { |
2188 | struct iwl_lq_sta *lq_sta; | 2164 | struct iwl_lq_sta *lq_sta; |
2189 | struct iwl_priv *priv; | 2165 | struct iwl_priv *priv; |
@@ -2206,20 +2182,16 @@ static void *rs_alloc_sta(void *priv_rate, gfp_t gfp) | |||
2206 | return lq_sta; | 2182 | return lq_sta; |
2207 | } | 2183 | } |
2208 | 2184 | ||
2209 | static void rs_rate_init(void *priv_rate, void *priv_sta, | 2185 | static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, |
2210 | struct ieee80211_local *local, | 2186 | struct ieee80211_sta *sta, void *priv_sta) |
2211 | struct sta_info *sta) | ||
2212 | { | 2187 | { |
2213 | int i, j; | 2188 | int i, j; |
2214 | struct ieee80211_conf *conf = &local->hw.conf; | 2189 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; |
2215 | struct ieee80211_supported_band *sband; | 2190 | struct ieee80211_conf *conf = &priv->hw->conf; |
2216 | struct iwl_priv *priv = (struct iwl_priv *)priv_rate; | ||
2217 | struct iwl_lq_sta *lq_sta = priv_sta; | 2191 | struct iwl_lq_sta *lq_sta = priv_sta; |
2218 | 2192 | ||
2219 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2220 | |||
2221 | lq_sta->flush_timer = 0; | 2193 | lq_sta->flush_timer = 0; |
2222 | lq_sta->supp_rates = sta->sta.supp_rates[sband->band]; | 2194 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
2223 | for (j = 0; j < LQ_SIZE; j++) | 2195 | for (j = 0; j < LQ_SIZE; j++) |
2224 | for (i = 0; i < IWL_RATE_COUNT; i++) | 2196 | for (i = 0; i < IWL_RATE_COUNT; i++) |
2225 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); | 2197 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); |
@@ -2232,17 +2204,17 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2232 | 2204 | ||
2233 | lq_sta->ibss_sta_added = 0; | 2205 | lq_sta->ibss_sta_added = 0; |
2234 | if (priv->iw_mode == NL80211_IFTYPE_AP) { | 2206 | if (priv->iw_mode == NL80211_IFTYPE_AP) { |
2235 | u8 sta_id = iwl_find_station(priv, sta->sta.addr); | 2207 | u8 sta_id = iwl_find_station(priv, sta->addr); |
2236 | DECLARE_MAC_BUF(mac); | 2208 | DECLARE_MAC_BUF(mac); |
2237 | 2209 | ||
2238 | /* for IBSS the call are from tasklet */ | 2210 | /* for IBSS the call are from tasklet */ |
2239 | IWL_DEBUG_RATE("LQ: ADD station %s\n", | 2211 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
2240 | print_mac(mac, sta->sta.addr)); | 2212 | print_mac(mac, sta->addr)); |
2241 | 2213 | ||
2242 | if (sta_id == IWL_INVALID_STATION) { | 2214 | if (sta_id == IWL_INVALID_STATION) { |
2243 | IWL_DEBUG_RATE("LQ: ADD station %s\n", | 2215 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
2244 | print_mac(mac, sta->sta.addr)); | 2216 | print_mac(mac, sta->addr)); |
2245 | sta_id = iwl_add_station_flags(priv, sta->sta.addr, | 2217 | sta_id = iwl_add_station_flags(priv, sta->addr, |
2246 | 0, CMD_ASYNC, NULL); | 2218 | 0, CMD_ASYNC, NULL); |
2247 | } | 2219 | } |
2248 | if ((sta_id != IWL_INVALID_STATION)) { | 2220 | if ((sta_id != IWL_INVALID_STATION)) { |
@@ -2256,11 +2228,11 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2256 | /* Find highest tx rate supported by hardware and destination station */ | 2228 | /* Find highest tx rate supported by hardware and destination station */ |
2257 | lq_sta->last_txrate_idx = 3; | 2229 | lq_sta->last_txrate_idx = 3; |
2258 | for (i = 0; i < sband->n_bitrates; i++) | 2230 | for (i = 0; i < sband->n_bitrates; i++) |
2259 | if (sta->sta.supp_rates[sband->band] & BIT(i)) | 2231 | if (sta->supp_rates[sband->band] & BIT(i)) |
2260 | lq_sta->last_txrate_idx = i; | 2232 | lq_sta->last_txrate_idx = i; |
2261 | 2233 | ||
2262 | /* For MODE_IEEE80211A, skip over cck rates in global rate table */ | 2234 | /* For MODE_IEEE80211A, skip over cck rates in global rate table */ |
2263 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) | 2235 | if (sband->band == IEEE80211_BAND_5GHZ) |
2264 | lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; | 2236 | lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
2265 | 2237 | ||
2266 | lq_sta->is_dup = 0; | 2238 | lq_sta->is_dup = 0; |
@@ -2301,7 +2273,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2301 | lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; | 2273 | lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; |
2302 | lq_sta->drv = priv; | 2274 | lq_sta->drv = priv; |
2303 | 2275 | ||
2304 | rs_initialize_lq(priv, conf, sta); | 2276 | rs_initialize_lq(priv, conf, sta, lq_sta); |
2305 | } | 2277 | } |
2306 | 2278 | ||
2307 | static void rs_fill_link_cmd(const struct iwl_priv *priv, | 2279 | static void rs_fill_link_cmd(const struct iwl_priv *priv, |
@@ -2423,9 +2395,9 @@ static void rs_fill_link_cmd(const struct iwl_priv *priv, | |||
2423 | lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); | 2395 | lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); |
2424 | } | 2396 | } |
2425 | 2397 | ||
2426 | static void *rs_alloc(struct ieee80211_local *local) | 2398 | static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
2427 | { | 2399 | { |
2428 | return local->hw.priv; | 2400 | return hw->priv; |
2429 | } | 2401 | } |
2430 | /* rate scale requires free function to be implemented */ | 2402 | /* rate scale requires free function to be implemented */ |
2431 | static void rs_free(void *priv_rate) | 2403 | static void rs_free(void *priv_rate) |
@@ -2446,12 +2418,12 @@ static void rs_clear(void *priv_rate) | |||
2446 | #endif /* CONFIG_IWLWIFI_DEBUG */ | 2418 | #endif /* CONFIG_IWLWIFI_DEBUG */ |
2447 | } | 2419 | } |
2448 | 2420 | ||
2449 | static void rs_free_sta(void *priv_rate, void *priv_sta) | 2421 | static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta, |
2422 | void *priv_sta) | ||
2450 | { | 2423 | { |
2451 | struct iwl_lq_sta *lq_sta = priv_sta; | 2424 | struct iwl_lq_sta *lq_sta = priv_sta; |
2452 | struct iwl_priv *priv; | 2425 | struct iwl_priv *priv = priv_r; |
2453 | 2426 | ||
2454 | priv = (struct iwl_priv *)priv_rate; | ||
2455 | IWL_DEBUG_RATE("enter\n"); | 2427 | IWL_DEBUG_RATE("enter\n"); |
2456 | kfree(lq_sta); | 2428 | kfree(lq_sta); |
2457 | IWL_DEBUG_RATE("leave\n"); | 2429 | IWL_DEBUG_RATE("leave\n"); |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 62b26befddc5..d15a2c997954 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -7370,15 +7370,6 @@ static ssize_t show_temperature(struct device *d, | |||
7370 | 7370 | ||
7371 | static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL); | 7371 | static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL); |
7372 | 7372 | ||
7373 | static ssize_t show_rs_window(struct device *d, | ||
7374 | struct device_attribute *attr, | ||
7375 | char *buf) | ||
7376 | { | ||
7377 | struct iwl3945_priv *priv = d->driver_data; | ||
7378 | return iwl3945_fill_rs_info(priv->hw, buf, IWL_AP_ID); | ||
7379 | } | ||
7380 | static DEVICE_ATTR(rs_window, S_IRUGO, show_rs_window, NULL); | ||
7381 | |||
7382 | static ssize_t show_tx_power(struct device *d, | 7373 | static ssize_t show_tx_power(struct device *d, |
7383 | struct device_attribute *attr, char *buf) | 7374 | struct device_attribute *attr, char *buf) |
7384 | { | 7375 | { |
@@ -7840,7 +7831,6 @@ static struct attribute *iwl3945_sysfs_entries[] = { | |||
7840 | #endif | 7831 | #endif |
7841 | &dev_attr_power_level.attr, | 7832 | &dev_attr_power_level.attr, |
7842 | &dev_attr_retry_rate.attr, | 7833 | &dev_attr_retry_rate.attr, |
7843 | &dev_attr_rs_window.attr, | ||
7844 | &dev_attr_statistics.attr, | 7834 | &dev_attr_statistics.attr, |
7845 | &dev_attr_status.attr, | 7835 | &dev_attr_status.attr, |
7846 | &dev_attr_temperature.attr, | 7836 | &dev_attr_temperature.attr, |
@@ -7908,6 +7898,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7908 | SET_IEEE80211_DEV(hw, &pdev->dev); | 7898 | SET_IEEE80211_DEV(hw, &pdev->dev); |
7909 | 7899 | ||
7910 | hw->rate_control_algorithm = "iwl-3945-rs"; | 7900 | hw->rate_control_algorithm = "iwl-3945-rs"; |
7901 | hw->sta_data_size = sizeof(struct iwl3945_sta_priv); | ||
7911 | 7902 | ||
7912 | IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); | 7903 | IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); |
7913 | priv = hw->priv; | 7904 | priv = hw->priv; |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 003e4a03874e..f5f5b1ff1584 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -1800,4 +1800,72 @@ void ieee80211_notify_mac(struct ieee80211_hw *hw, | |||
1800 | struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, | 1800 | struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, |
1801 | const u8 *addr); | 1801 | const u8 *addr); |
1802 | 1802 | ||
1803 | |||
1804 | /* Rate control API */ | ||
1805 | /** | ||
1806 | * struct rate_selection - rate information for/from rate control algorithms | ||
1807 | * | ||
1808 | * @rate_idx: selected transmission rate index | ||
1809 | * @nonerp_idx: Non-ERP rate to use instead if ERP cannot be used | ||
1810 | * @probe_idx: rate for probing (or -1) | ||
1811 | * @max_rate_idx: maximum rate index that can be used, this is | ||
1812 | * input to the algorithm and will be enforced | ||
1813 | */ | ||
1814 | struct rate_selection { | ||
1815 | s8 rate_idx, nonerp_idx, probe_idx, max_rate_idx; | ||
1816 | }; | ||
1817 | |||
1818 | struct rate_control_ops { | ||
1819 | struct module *module; | ||
1820 | const char *name; | ||
1821 | void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir); | ||
1822 | void (*clear)(void *priv); | ||
1823 | void (*free)(void *priv); | ||
1824 | |||
1825 | void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp); | ||
1826 | void (*rate_init)(void *priv, struct ieee80211_supported_band *sband, | ||
1827 | struct ieee80211_sta *sta, void *priv_sta); | ||
1828 | void (*free_sta)(void *priv, struct ieee80211_sta *sta, | ||
1829 | void *priv_sta); | ||
1830 | |||
1831 | void (*tx_status)(void *priv, struct ieee80211_supported_band *sband, | ||
1832 | struct ieee80211_sta *sta, void *priv_sta, | ||
1833 | struct sk_buff *skb); | ||
1834 | void (*get_rate)(void *priv, struct ieee80211_supported_band *sband, | ||
1835 | struct ieee80211_sta *sta, void *priv_sta, | ||
1836 | struct sk_buff *skb, | ||
1837 | struct rate_selection *sel); | ||
1838 | |||
1839 | void (*add_sta_debugfs)(void *priv, void *priv_sta, | ||
1840 | struct dentry *dir); | ||
1841 | void (*remove_sta_debugfs)(void *priv, void *priv_sta); | ||
1842 | }; | ||
1843 | |||
1844 | static inline int rate_supported(struct ieee80211_sta *sta, | ||
1845 | enum ieee80211_band band, | ||
1846 | int index) | ||
1847 | { | ||
1848 | return (sta == NULL || sta->supp_rates[band] & BIT(index)); | ||
1849 | } | ||
1850 | |||
1851 | static inline s8 | ||
1852 | rate_lowest_index(struct ieee80211_supported_band *sband, | ||
1853 | struct ieee80211_sta *sta) | ||
1854 | { | ||
1855 | int i; | ||
1856 | |||
1857 | for (i = 0; i < sband->n_bitrates; i++) | ||
1858 | if (rate_supported(sta, sband->band, i)) | ||
1859 | return i; | ||
1860 | |||
1861 | /* warn when we cannot find a rate. */ | ||
1862 | WARN_ON(1); | ||
1863 | |||
1864 | return 0; | ||
1865 | } | ||
1866 | |||
1867 | |||
1868 | int ieee80211_rate_control_register(struct rate_control_ops *ops); | ||
1869 | void ieee80211_rate_control_unregister(struct rate_control_ops *ops); | ||
1870 | |||
1803 | #endif /* MAC80211_H */ | 1871 | #endif /* MAC80211_H */ |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 89a183c2327a..855126a3039d 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -693,7 +693,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
693 | 693 | ||
694 | sta_apply_parameters(local, sta, params); | 694 | sta_apply_parameters(local, sta, params); |
695 | 695 | ||
696 | rate_control_rate_init(sta, local); | 696 | rate_control_rate_init(sta); |
697 | 697 | ||
698 | rcu_read_lock(); | 698 | rcu_read_lock(); |
699 | 699 | ||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 0b25b0f46b1a..8025b294588b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -724,6 +724,8 @@ struct ieee80211_local { | |||
724 | 724 | ||
725 | #ifdef CONFIG_MAC80211_DEBUGFS | 725 | #ifdef CONFIG_MAC80211_DEBUGFS |
726 | struct local_debugfsdentries { | 726 | struct local_debugfsdentries { |
727 | struct dentry *rcdir; | ||
728 | struct dentry *rcname; | ||
727 | struct dentry *frequency; | 729 | struct dentry *frequency; |
728 | struct dentry *antenna_sel_tx; | 730 | struct dentry *antenna_sel_tx; |
729 | struct dentry *antenna_sel_rx; | 731 | struct dentry *antenna_sel_rx; |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 7d2d5a041e26..d608c44047c0 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -542,6 +542,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
542 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 542 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
543 | u16 frag, type; | 543 | u16 frag, type; |
544 | __le16 fc; | 544 | __le16 fc; |
545 | struct ieee80211_supported_band *sband; | ||
545 | struct ieee80211_tx_status_rtap_hdr *rthdr; | 546 | struct ieee80211_tx_status_rtap_hdr *rthdr; |
546 | struct ieee80211_sub_if_data *sdata; | 547 | struct ieee80211_sub_if_data *sdata; |
547 | struct net_device *prev_dev = NULL; | 548 | struct net_device *prev_dev = NULL; |
@@ -588,7 +589,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
588 | sta->tx_retry_count += info->status.retry_count; | 589 | sta->tx_retry_count += info->status.retry_count; |
589 | } | 590 | } |
590 | 591 | ||
591 | rate_control_tx_status(local->mdev, skb); | 592 | sband = local->hw.wiphy->bands[info->band]; |
593 | rate_control_tx_status(local, sband, sta, skb); | ||
592 | } | 594 | } |
593 | 595 | ||
594 | rcu_read_unlock(); | 596 | rcu_read_unlock(); |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 8611a8318c9c..109c3a7e63ad 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -1323,7 +1323,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1323 | ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info); | 1323 | ieee80211_handle_ht(local, 1, &sta->sta.ht_info, &bss_info); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | rate_control_rate_init(sta, local); | 1326 | rate_control_rate_init(sta); |
1327 | 1327 | ||
1328 | if (elems.wmm_param) { | 1328 | if (elems.wmm_param) { |
1329 | set_sta_flags(sta, WLAN_STA_WME); | 1329 | set_sta_flags(sta, WLAN_STA_WME); |
@@ -2342,7 +2342,7 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
2342 | sta->sta.supp_rates[band] = supp_rates | | 2342 | sta->sta.supp_rates[band] = supp_rates | |
2343 | ieee80211_mandatory_rates(local, band); | 2343 | ieee80211_mandatory_rates(local, band); |
2344 | 2344 | ||
2345 | rate_control_rate_init(sta, local); | 2345 | rate_control_rate_init(sta); |
2346 | 2346 | ||
2347 | if (sta_info_insert(sta)) | 2347 | if (sta_info_insert(sta)) |
2348 | return NULL; | 2348 | return NULL; |
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 0388c090dfe9..5d786720d935 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/rtnetlink.h> | 12 | #include <linux/rtnetlink.h> |
13 | #include "rate.h" | 13 | #include "rate.h" |
14 | #include "ieee80211_i.h" | 14 | #include "ieee80211_i.h" |
15 | #include "debugfs.h" | ||
15 | 16 | ||
16 | struct rate_control_alg { | 17 | struct rate_control_alg { |
17 | struct list_head list; | 18 | struct list_head list; |
@@ -127,19 +128,46 @@ static void ieee80211_rate_control_ops_put(struct rate_control_ops *ops) | |||
127 | module_put(ops->module); | 128 | module_put(ops->module); |
128 | } | 129 | } |
129 | 130 | ||
131 | #ifdef CONFIG_MAC80211_DEBUGFS | ||
132 | static ssize_t rcname_read(struct file *file, char __user *userbuf, | ||
133 | size_t count, loff_t *ppos) | ||
134 | { | ||
135 | struct rate_control_ref *ref = file->private_data; | ||
136 | int len = strlen(ref->ops->name); | ||
137 | |||
138 | return simple_read_from_buffer(userbuf, count, ppos, | ||
139 | ref->ops->name, len); | ||
140 | } | ||
141 | |||
142 | static const struct file_operations rcname_ops = { | ||
143 | .read = rcname_read, | ||
144 | .open = mac80211_open_file_generic, | ||
145 | }; | ||
146 | #endif | ||
147 | |||
130 | struct rate_control_ref *rate_control_alloc(const char *name, | 148 | struct rate_control_ref *rate_control_alloc(const char *name, |
131 | struct ieee80211_local *local) | 149 | struct ieee80211_local *local) |
132 | { | 150 | { |
151 | struct dentry *debugfsdir = NULL; | ||
133 | struct rate_control_ref *ref; | 152 | struct rate_control_ref *ref; |
134 | 153 | ||
135 | ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL); | 154 | ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL); |
136 | if (!ref) | 155 | if (!ref) |
137 | goto fail_ref; | 156 | goto fail_ref; |
138 | kref_init(&ref->kref); | 157 | kref_init(&ref->kref); |
158 | ref->local = local; | ||
139 | ref->ops = ieee80211_rate_control_ops_get(name); | 159 | ref->ops = ieee80211_rate_control_ops_get(name); |
140 | if (!ref->ops) | 160 | if (!ref->ops) |
141 | goto fail_ops; | 161 | goto fail_ops; |
142 | ref->priv = ref->ops->alloc(local); | 162 | |
163 | #ifdef CONFIG_MAC80211_DEBUGFS | ||
164 | debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir); | ||
165 | local->debugfs.rcdir = debugfsdir; | ||
166 | local->debugfs.rcname = debugfs_create_file("name", 0400, debugfsdir, | ||
167 | ref, &rcname_ops); | ||
168 | #endif | ||
169 | |||
170 | ref->priv = ref->ops->alloc(&local->hw, debugfsdir); | ||
143 | if (!ref->priv) | 171 | if (!ref->priv) |
144 | goto fail_priv; | 172 | goto fail_priv; |
145 | return ref; | 173 | return ref; |
@@ -158,29 +186,46 @@ static void rate_control_release(struct kref *kref) | |||
158 | 186 | ||
159 | ctrl_ref = container_of(kref, struct rate_control_ref, kref); | 187 | ctrl_ref = container_of(kref, struct rate_control_ref, kref); |
160 | ctrl_ref->ops->free(ctrl_ref->priv); | 188 | ctrl_ref->ops->free(ctrl_ref->priv); |
189 | |||
190 | #ifdef CONFIG_MAC80211_DEBUGFS | ||
191 | debugfs_remove(ctrl_ref->local->debugfs.rcname); | ||
192 | ctrl_ref->local->debugfs.rcname = NULL; | ||
193 | debugfs_remove(ctrl_ref->local->debugfs.rcdir); | ||
194 | ctrl_ref->local->debugfs.rcdir = NULL; | ||
195 | #endif | ||
196 | |||
161 | ieee80211_rate_control_ops_put(ctrl_ref->ops); | 197 | ieee80211_rate_control_ops_put(ctrl_ref->ops); |
162 | kfree(ctrl_ref); | 198 | kfree(ctrl_ref); |
163 | } | 199 | } |
164 | 200 | ||
165 | void rate_control_get_rate(struct net_device *dev, | 201 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, |
166 | struct ieee80211_supported_band *sband, | 202 | struct ieee80211_supported_band *sband, |
167 | struct sk_buff *skb, | 203 | struct sta_info *sta, struct sk_buff *skb, |
168 | struct rate_selection *sel) | 204 | struct rate_selection *sel) |
169 | { | 205 | { |
170 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 206 | struct rate_control_ref *ref = sdata->local->rate_ctrl; |
171 | struct rate_control_ref *ref = local->rate_ctrl; | 207 | void *priv_sta = NULL; |
172 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 208 | struct ieee80211_sta *ista = NULL; |
173 | struct sta_info *sta; | ||
174 | int i; | 209 | int i; |
175 | 210 | ||
176 | rcu_read_lock(); | ||
177 | sta = sta_info_get(local, hdr->addr1); | ||
178 | |||
179 | sel->rate_idx = -1; | 211 | sel->rate_idx = -1; |
180 | sel->nonerp_idx = -1; | 212 | sel->nonerp_idx = -1; |
181 | sel->probe_idx = -1; | 213 | sel->probe_idx = -1; |
214 | sel->max_rate_idx = sdata->max_ratectrl_rateidx; | ||
215 | |||
216 | if (sta) { | ||
217 | ista = &sta->sta; | ||
218 | priv_sta = sta->rate_ctrl_priv; | ||
219 | } | ||
220 | |||
221 | if (sta && sdata->force_unicast_rateidx > -1) | ||
222 | sel->rate_idx = sdata->force_unicast_rateidx; | ||
223 | else | ||
224 | ref->ops->get_rate(ref->priv, sband, ista, priv_sta, skb, sel); | ||
182 | 225 | ||
183 | ref->ops->get_rate(ref->priv, dev, sband, skb, sel); | 226 | if (sdata->max_ratectrl_rateidx > -1 && |
227 | sel->rate_idx > sdata->max_ratectrl_rateidx) | ||
228 | sel->rate_idx = sdata->max_ratectrl_rateidx; | ||
184 | 229 | ||
185 | BUG_ON(sel->rate_idx < 0); | 230 | BUG_ON(sel->rate_idx < 0); |
186 | 231 | ||
@@ -191,13 +236,11 @@ void rate_control_get_rate(struct net_device *dev, | |||
191 | if (sband->bitrates[sel->rate_idx].bitrate < rate->bitrate) | 236 | if (sband->bitrates[sel->rate_idx].bitrate < rate->bitrate) |
192 | break; | 237 | break; |
193 | 238 | ||
194 | if (rate_supported(sta, sband->band, i) && | 239 | if (rate_supported(ista, sband->band, i) && |
195 | !(rate->flags & IEEE80211_RATE_ERP_G)) | 240 | !(rate->flags & IEEE80211_RATE_ERP_G)) |
196 | sel->nonerp_idx = i; | 241 | sel->nonerp_idx = i; |
197 | } | 242 | } |
198 | } | 243 | } |
199 | |||
200 | rcu_read_unlock(); | ||
201 | } | 244 | } |
202 | 245 | ||
203 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref) | 246 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref) |
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index 5f18c27eb900..eb94e584d24e 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h | |||
@@ -19,77 +19,48 @@ | |||
19 | #include "ieee80211_i.h" | 19 | #include "ieee80211_i.h" |
20 | #include "sta_info.h" | 20 | #include "sta_info.h" |
21 | 21 | ||
22 | /** | ||
23 | * struct rate_selection - rate selection for rate control algos | ||
24 | * @rate: selected transmission rate index | ||
25 | * @nonerp: Non-ERP rate to use instead if ERP cannot be used | ||
26 | * @probe: rate for probing (or -1) | ||
27 | * | ||
28 | */ | ||
29 | struct rate_selection { | ||
30 | s8 rate_idx, nonerp_idx, probe_idx; | ||
31 | }; | ||
32 | |||
33 | struct rate_control_ops { | ||
34 | struct module *module; | ||
35 | const char *name; | ||
36 | void (*tx_status)(void *priv, struct net_device *dev, | ||
37 | struct sk_buff *skb); | ||
38 | void (*get_rate)(void *priv, struct net_device *dev, | ||
39 | struct ieee80211_supported_band *band, | ||
40 | struct sk_buff *skb, | ||
41 | struct rate_selection *sel); | ||
42 | void (*rate_init)(void *priv, void *priv_sta, | ||
43 | struct ieee80211_local *local, struct sta_info *sta); | ||
44 | void (*clear)(void *priv); | ||
45 | |||
46 | void *(*alloc)(struct ieee80211_local *local); | ||
47 | void (*free)(void *priv); | ||
48 | void *(*alloc_sta)(void *priv, gfp_t gfp); | ||
49 | void (*free_sta)(void *priv, void *priv_sta); | ||
50 | |||
51 | int (*add_attrs)(void *priv, struct kobject *kobj); | ||
52 | void (*remove_attrs)(void *priv, struct kobject *kobj); | ||
53 | void (*add_sta_debugfs)(void *priv, void *priv_sta, | ||
54 | struct dentry *dir); | ||
55 | void (*remove_sta_debugfs)(void *priv, void *priv_sta); | ||
56 | }; | ||
57 | |||
58 | struct rate_control_ref { | 22 | struct rate_control_ref { |
23 | struct ieee80211_local *local; | ||
59 | struct rate_control_ops *ops; | 24 | struct rate_control_ops *ops; |
60 | void *priv; | 25 | void *priv; |
61 | struct kref kref; | 26 | struct kref kref; |
62 | }; | 27 | }; |
63 | 28 | ||
64 | int ieee80211_rate_control_register(struct rate_control_ops *ops); | ||
65 | void ieee80211_rate_control_unregister(struct rate_control_ops *ops); | ||
66 | |||
67 | /* Get a reference to the rate control algorithm. If `name' is NULL, get the | 29 | /* Get a reference to the rate control algorithm. If `name' is NULL, get the |
68 | * first available algorithm. */ | 30 | * first available algorithm. */ |
69 | struct rate_control_ref *rate_control_alloc(const char *name, | 31 | struct rate_control_ref *rate_control_alloc(const char *name, |
70 | struct ieee80211_local *local); | 32 | struct ieee80211_local *local); |
71 | void rate_control_get_rate(struct net_device *dev, | 33 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, |
72 | struct ieee80211_supported_band *sband, | 34 | struct ieee80211_supported_band *sband, |
73 | struct sk_buff *skb, | 35 | struct sta_info *sta, struct sk_buff *skb, |
74 | struct rate_selection *sel); | 36 | struct rate_selection *sel); |
75 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); | 37 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); |
76 | void rate_control_put(struct rate_control_ref *ref); | 38 | void rate_control_put(struct rate_control_ref *ref); |
77 | 39 | ||
78 | static inline void rate_control_tx_status(struct net_device *dev, | 40 | static inline void rate_control_tx_status(struct ieee80211_local *local, |
41 | struct ieee80211_supported_band *sband, | ||
42 | struct sta_info *sta, | ||
79 | struct sk_buff *skb) | 43 | struct sk_buff *skb) |
80 | { | 44 | { |
81 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
82 | struct rate_control_ref *ref = local->rate_ctrl; | 45 | struct rate_control_ref *ref = local->rate_ctrl; |
46 | struct ieee80211_sta *ista = &sta->sta; | ||
47 | void *priv_sta = sta->rate_ctrl_priv; | ||
83 | 48 | ||
84 | ref->ops->tx_status(ref->priv, dev, skb); | 49 | ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); |
85 | } | 50 | } |
86 | 51 | ||
87 | 52 | ||
88 | static inline void rate_control_rate_init(struct sta_info *sta, | 53 | static inline void rate_control_rate_init(struct sta_info *sta) |
89 | struct ieee80211_local *local) | ||
90 | { | 54 | { |
55 | struct ieee80211_local *local = sta->sdata->local; | ||
91 | struct rate_control_ref *ref = sta->rate_ctrl; | 56 | struct rate_control_ref *ref = sta->rate_ctrl; |
92 | ref->ops->rate_init(ref->priv, sta->rate_ctrl_priv, local, sta); | 57 | struct ieee80211_sta *ista = &sta->sta; |
58 | void *priv_sta = sta->rate_ctrl_priv; | ||
59 | struct ieee80211_supported_band *sband; | ||
60 | |||
61 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
62 | |||
63 | ref->ops->rate_init(ref->priv, sband, ista, priv_sta); | ||
93 | } | 64 | } |
94 | 65 | ||
95 | 66 | ||
@@ -100,15 +71,19 @@ static inline void rate_control_clear(struct ieee80211_local *local) | |||
100 | } | 71 | } |
101 | 72 | ||
102 | static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, | 73 | static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, |
74 | struct ieee80211_sta *sta, | ||
103 | gfp_t gfp) | 75 | gfp_t gfp) |
104 | { | 76 | { |
105 | return ref->ops->alloc_sta(ref->priv, gfp); | 77 | return ref->ops->alloc_sta(ref->priv, sta, gfp); |
106 | } | 78 | } |
107 | 79 | ||
108 | static inline void rate_control_free_sta(struct rate_control_ref *ref, | 80 | static inline void rate_control_free_sta(struct sta_info *sta) |
109 | void *priv) | ||
110 | { | 81 | { |
111 | ref->ops->free_sta(ref->priv, priv); | 82 | struct rate_control_ref *ref = sta->rate_ctrl; |
83 | struct ieee80211_sta *ista = &sta->sta; | ||
84 | void *priv_sta = sta->rate_ctrl_priv; | ||
85 | |||
86 | ref->ops->free_sta(ref->priv, ista, priv_sta); | ||
112 | } | 87 | } |
113 | 88 | ||
114 | static inline void rate_control_add_sta_debugfs(struct sta_info *sta) | 89 | static inline void rate_control_add_sta_debugfs(struct sta_info *sta) |
@@ -130,31 +105,6 @@ static inline void rate_control_remove_sta_debugfs(struct sta_info *sta) | |||
130 | #endif | 105 | #endif |
131 | } | 106 | } |
132 | 107 | ||
133 | static inline int rate_supported(struct sta_info *sta, | ||
134 | enum ieee80211_band band, | ||
135 | int index) | ||
136 | { | ||
137 | return (sta == NULL || sta->sta.supp_rates[band] & BIT(index)); | ||
138 | } | ||
139 | |||
140 | static inline s8 | ||
141 | rate_lowest_index(struct ieee80211_local *local, | ||
142 | struct ieee80211_supported_band *sband, | ||
143 | struct sta_info *sta) | ||
144 | { | ||
145 | int i; | ||
146 | |||
147 | for (i = 0; i < sband->n_bitrates; i++) | ||
148 | if (rate_supported(sta, sband->band, i)) | ||
149 | return i; | ||
150 | |||
151 | /* warn when we cannot find a rate. */ | ||
152 | WARN_ON(1); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | |||
158 | /* functions for rate control related to a device */ | 108 | /* functions for rate control related to a device */ |
159 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, | 109 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, |
160 | const char *name); | 110 | const char *name); |
diff --git a/net/mac80211/rc80211_pid.h b/net/mac80211/rc80211_pid.h index ffafc5da572e..01d64d53f3b9 100644 --- a/net/mac80211/rc80211_pid.h +++ b/net/mac80211/rc80211_pid.h | |||
@@ -124,7 +124,6 @@ struct rc_pid_events_file_info { | |||
124 | * struct rc_pid_debugfs_entries - tunable parameters | 124 | * struct rc_pid_debugfs_entries - tunable parameters |
125 | * | 125 | * |
126 | * Algorithm parameters, tunable via debugfs. | 126 | * Algorithm parameters, tunable via debugfs. |
127 | * @dir: the debugfs directory for a specific phy | ||
128 | * @target: target percentage for failed frames | 127 | * @target: target percentage for failed frames |
129 | * @sampling_period: error sampling interval in milliseconds | 128 | * @sampling_period: error sampling interval in milliseconds |
130 | * @coeff_p: absolute value of the proportional coefficient | 129 | * @coeff_p: absolute value of the proportional coefficient |
@@ -143,7 +142,6 @@ struct rc_pid_events_file_info { | |||
143 | * ordering of rates) | 142 | * ordering of rates) |
144 | */ | 143 | */ |
145 | struct rc_pid_debugfs_entries { | 144 | struct rc_pid_debugfs_entries { |
146 | struct dentry *dir; | ||
147 | struct dentry *target; | 145 | struct dentry *target; |
148 | struct dentry *sampling_period; | 146 | struct dentry *sampling_period; |
149 | struct dentry *coeff_p; | 147 | struct dentry *coeff_p; |
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index bc1c4569caa1..86eb374e3b87 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c | |||
@@ -68,18 +68,14 @@ | |||
68 | * exhibited a worse failed frames behaviour and we'll choose the highest rate | 68 | * exhibited a worse failed frames behaviour and we'll choose the highest rate |
69 | * whose failed frames behaviour is not worse than the one of the original rate | 69 | * whose failed frames behaviour is not worse than the one of the original rate |
70 | * target. While at it, check that the new rate is valid. */ | 70 | * target. While at it, check that the new rate is valid. */ |
71 | static void rate_control_pid_adjust_rate(struct ieee80211_local *local, | 71 | static void rate_control_pid_adjust_rate(struct ieee80211_supported_band *sband, |
72 | struct sta_info *sta, int adj, | 72 | struct ieee80211_sta *sta, |
73 | struct rc_pid_sta_info *spinfo, int adj, | ||
73 | struct rc_pid_rateinfo *rinfo) | 74 | struct rc_pid_rateinfo *rinfo) |
74 | { | 75 | { |
75 | struct ieee80211_sub_if_data *sdata; | ||
76 | struct ieee80211_supported_band *sband; | ||
77 | int cur_sorted, new_sorted, probe, tmp, n_bitrates, band; | 76 | int cur_sorted, new_sorted, probe, tmp, n_bitrates, band; |
78 | struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv; | ||
79 | int cur = spinfo->txrate_idx; | 77 | int cur = spinfo->txrate_idx; |
80 | 78 | ||
81 | sdata = sta->sdata; | ||
82 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
83 | band = sband->band; | 79 | band = sband->band; |
84 | n_bitrates = sband->n_bitrates; | 80 | n_bitrates = sband->n_bitrates; |
85 | 81 | ||
@@ -146,13 +142,11 @@ static void rate_control_pid_normalize(struct rc_pid_info *pinfo, int l) | |||
146 | } | 142 | } |
147 | 143 | ||
148 | static void rate_control_pid_sample(struct rc_pid_info *pinfo, | 144 | static void rate_control_pid_sample(struct rc_pid_info *pinfo, |
149 | struct ieee80211_local *local, | 145 | struct ieee80211_supported_band *sband, |
150 | struct sta_info *sta) | 146 | struct ieee80211_sta *sta, |
147 | struct rc_pid_sta_info *spinfo) | ||
151 | { | 148 | { |
152 | struct ieee80211_sub_if_data *sdata = sta->sdata; | ||
153 | struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv; | ||
154 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; | 149 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; |
155 | struct ieee80211_supported_band *sband; | ||
156 | u32 pf; | 150 | u32 pf; |
157 | s32 err_avg; | 151 | s32 err_avg; |
158 | u32 err_prop; | 152 | u32 err_prop; |
@@ -161,9 +155,6 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
161 | int adj, i, j, tmp; | 155 | int adj, i, j, tmp; |
162 | unsigned long period; | 156 | unsigned long period; |
163 | 157 | ||
164 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
165 | spinfo = sta->rate_ctrl_priv; | ||
166 | |||
167 | /* In case nothing happened during the previous control interval, turn | 158 | /* In case nothing happened during the previous control interval, turn |
168 | * the sharpening factor on. */ | 159 | * the sharpening factor on. */ |
169 | period = (HZ * pinfo->sampling_period + 500) / 1000; | 160 | period = (HZ * pinfo->sampling_period + 500) / 1000; |
@@ -179,11 +170,15 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
179 | if (unlikely(spinfo->tx_num_xmit == 0)) | 170 | if (unlikely(spinfo->tx_num_xmit == 0)) |
180 | pf = spinfo->last_pf; | 171 | pf = spinfo->last_pf; |
181 | else { | 172 | else { |
173 | /* XXX: BAD HACK!!! */ | ||
174 | struct sta_info *si = container_of(sta, struct sta_info, sta); | ||
175 | |||
182 | pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit; | 176 | pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit; |
183 | if (ieee80211_vif_is_mesh(&sdata->vif) && pf == 100) | 177 | |
184 | mesh_plink_broken(sta); | 178 | if (ieee80211_vif_is_mesh(&si->sdata->vif) && pf == 100) |
179 | mesh_plink_broken(si); | ||
185 | pf <<= RC_PID_ARITH_SHIFT; | 180 | pf <<= RC_PID_ARITH_SHIFT; |
186 | sta->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9) | 181 | si->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9) |
187 | >> RC_PID_ARITH_SHIFT; | 182 | >> RC_PID_ARITH_SHIFT; |
188 | } | 183 | } |
189 | 184 | ||
@@ -229,43 +224,25 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
229 | 224 | ||
230 | /* Change rate. */ | 225 | /* Change rate. */ |
231 | if (adj) | 226 | if (adj) |
232 | rate_control_pid_adjust_rate(local, sta, adj, rinfo); | 227 | rate_control_pid_adjust_rate(sband, sta, spinfo, adj, rinfo); |
233 | } | 228 | } |
234 | 229 | ||
235 | static void rate_control_pid_tx_status(void *priv, struct net_device *dev, | 230 | static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_band *sband, |
231 | struct ieee80211_sta *sta, void *priv_sta, | ||
236 | struct sk_buff *skb) | 232 | struct sk_buff *skb) |
237 | { | 233 | { |
238 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
239 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
240 | struct ieee80211_sub_if_data *sdata; | ||
241 | struct rc_pid_info *pinfo = priv; | 234 | struct rc_pid_info *pinfo = priv; |
242 | struct sta_info *sta; | 235 | struct rc_pid_sta_info *spinfo = priv_sta; |
243 | struct rc_pid_sta_info *spinfo; | ||
244 | unsigned long period; | 236 | unsigned long period; |
245 | struct ieee80211_supported_band *sband; | ||
246 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 237 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
247 | 238 | ||
248 | rcu_read_lock(); | 239 | if (!spinfo) |
249 | 240 | return; | |
250 | sta = sta_info_get(local, hdr->addr1); | ||
251 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
252 | |||
253 | if (!sta) | ||
254 | goto unlock; | ||
255 | |||
256 | spinfo = sta->rate_ctrl_priv; | ||
257 | |||
258 | /* Don't update the state if we're not controlling the rate. */ | ||
259 | sdata = sta->sdata; | ||
260 | if (sdata->force_unicast_rateidx > -1) { | ||
261 | spinfo->txrate_idx = sdata->max_ratectrl_rateidx; | ||
262 | goto unlock; | ||
263 | } | ||
264 | 241 | ||
265 | /* Ignore all frames that were sent with a different rate than the rate | 242 | /* Ignore all frames that were sent with a different rate than the rate |
266 | * we currently advise mac80211 to use. */ | 243 | * we currently advise mac80211 to use. */ |
267 | if (info->tx_rate_idx != spinfo->txrate_idx) | 244 | if (info->tx_rate_idx != spinfo->txrate_idx) |
268 | goto unlock; | 245 | return; |
269 | 246 | ||
270 | spinfo->tx_num_xmit++; | 247 | spinfo->tx_num_xmit++; |
271 | 248 | ||
@@ -289,78 +266,63 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev, | |||
289 | if (!period) | 266 | if (!period) |
290 | period = 1; | 267 | period = 1; |
291 | if (time_after(jiffies, spinfo->last_sample + period)) | 268 | if (time_after(jiffies, spinfo->last_sample + period)) |
292 | rate_control_pid_sample(pinfo, local, sta); | 269 | rate_control_pid_sample(pinfo, sband, sta, spinfo); |
293 | |||
294 | unlock: | ||
295 | rcu_read_unlock(); | ||
296 | } | 270 | } |
297 | 271 | ||
298 | static void rate_control_pid_get_rate(void *priv, struct net_device *dev, | 272 | static void |
299 | struct ieee80211_supported_band *sband, | 273 | rate_control_pid_get_rate(void *priv, struct ieee80211_supported_band *sband, |
300 | struct sk_buff *skb, | 274 | struct ieee80211_sta *sta, void *priv_sta, |
301 | struct rate_selection *sel) | 275 | struct sk_buff *skb, |
276 | struct rate_selection *sel) | ||
302 | { | 277 | { |
303 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
304 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 278 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
305 | struct ieee80211_sub_if_data *sdata; | 279 | struct rc_pid_sta_info *spinfo = priv_sta; |
306 | struct rc_pid_sta_info *spinfo; | ||
307 | struct sta_info *sta; | ||
308 | int rateidx; | 280 | int rateidx; |
309 | u16 fc; | 281 | u16 fc; |
310 | 282 | ||
311 | rcu_read_lock(); | ||
312 | |||
313 | sta = sta_info_get(local, hdr->addr1); | ||
314 | |||
315 | /* Send management frames and broadcast/multicast data using lowest | 283 | /* Send management frames and broadcast/multicast data using lowest |
316 | * rate. */ | 284 | * rate. */ |
317 | fc = le16_to_cpu(hdr->frame_control); | 285 | fc = le16_to_cpu(hdr->frame_control); |
318 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || | 286 | if (!sta || !spinfo || |
319 | is_multicast_ether_addr(hdr->addr1) || !sta) { | 287 | (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || |
320 | sel->rate_idx = rate_lowest_index(local, sband, sta); | 288 | is_multicast_ether_addr(hdr->addr1)) { |
321 | rcu_read_unlock(); | 289 | sel->rate_idx = rate_lowest_index(sband, sta); |
322 | return; | 290 | return; |
323 | } | 291 | } |
324 | 292 | ||
325 | /* If a forced rate is in effect, select it. */ | ||
326 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
327 | spinfo = (struct rc_pid_sta_info *)sta->rate_ctrl_priv; | ||
328 | if (sdata->force_unicast_rateidx > -1) | ||
329 | spinfo->txrate_idx = sdata->force_unicast_rateidx; | ||
330 | |||
331 | rateidx = spinfo->txrate_idx; | 293 | rateidx = spinfo->txrate_idx; |
332 | 294 | ||
333 | if (rateidx >= sband->n_bitrates) | 295 | if (rateidx >= sband->n_bitrates) |
334 | rateidx = sband->n_bitrates - 1; | 296 | rateidx = sband->n_bitrates - 1; |
335 | 297 | ||
336 | rcu_read_unlock(); | ||
337 | |||
338 | sel->rate_idx = rateidx; | 298 | sel->rate_idx = rateidx; |
339 | 299 | ||
340 | #ifdef CONFIG_MAC80211_DEBUGFS | 300 | #ifdef CONFIG_MAC80211_DEBUGFS |
341 | rate_control_pid_event_tx_rate( | 301 | rate_control_pid_event_tx_rate(&spinfo->events, |
342 | &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, | ||
343 | rateidx, sband->bitrates[rateidx].bitrate); | 302 | rateidx, sband->bitrates[rateidx].bitrate); |
344 | #endif | 303 | #endif |
345 | } | 304 | } |
346 | 305 | ||
347 | static void rate_control_pid_rate_init(void *priv, void *priv_sta, | 306 | static void |
348 | struct ieee80211_local *local, | 307 | rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband, |
349 | struct sta_info *sta) | 308 | struct ieee80211_sta *sta, void *priv_sta) |
350 | { | 309 | { |
310 | struct rc_pid_sta_info *spinfo = priv_sta; | ||
311 | struct sta_info *si; | ||
312 | |||
351 | /* TODO: This routine should consider using RSSI from previous packets | 313 | /* TODO: This routine should consider using RSSI from previous packets |
352 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. | 314 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. |
353 | * Until that method is implemented, we will use the lowest supported | 315 | * Until that method is implemented, we will use the lowest supported |
354 | * rate as a workaround. */ | 316 | * rate as a workaround. */ |
355 | struct ieee80211_supported_band *sband; | ||
356 | struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv; | ||
357 | 317 | ||
358 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 318 | spinfo->txrate_idx = rate_lowest_index(sband, sta); |
359 | spinfo->txrate_idx = rate_lowest_index(local, sband, sta); | 319 | /* HACK */ |
360 | sta->fail_avg = 0; | 320 | si = container_of(sta, struct sta_info, sta); |
321 | si->fail_avg = 0; | ||
361 | } | 322 | } |
362 | 323 | ||
363 | static void *rate_control_pid_alloc(struct ieee80211_local *local) | 324 | static void *rate_control_pid_alloc(struct ieee80211_hw *hw, |
325 | struct dentry *debugfsdir) | ||
364 | { | 326 | { |
365 | struct rc_pid_info *pinfo; | 327 | struct rc_pid_info *pinfo; |
366 | struct rc_pid_rateinfo *rinfo; | 328 | struct rc_pid_rateinfo *rinfo; |
@@ -371,7 +333,7 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local) | |||
371 | struct rc_pid_debugfs_entries *de; | 333 | struct rc_pid_debugfs_entries *de; |
372 | #endif | 334 | #endif |
373 | 335 | ||
374 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 336 | sband = hw->wiphy->bands[hw->conf.channel->band]; |
375 | 337 | ||
376 | pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); | 338 | pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); |
377 | if (!pinfo) | 339 | if (!pinfo) |
@@ -426,30 +388,28 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local) | |||
426 | 388 | ||
427 | #ifdef CONFIG_MAC80211_DEBUGFS | 389 | #ifdef CONFIG_MAC80211_DEBUGFS |
428 | de = &pinfo->dentries; | 390 | de = &pinfo->dentries; |
429 | de->dir = debugfs_create_dir("rc80211_pid", | ||
430 | local->hw.wiphy->debugfsdir); | ||
431 | de->target = debugfs_create_u32("target_pf", S_IRUSR | S_IWUSR, | 391 | de->target = debugfs_create_u32("target_pf", S_IRUSR | S_IWUSR, |
432 | de->dir, &pinfo->target); | 392 | debugfsdir, &pinfo->target); |
433 | de->sampling_period = debugfs_create_u32("sampling_period", | 393 | de->sampling_period = debugfs_create_u32("sampling_period", |
434 | S_IRUSR | S_IWUSR, de->dir, | 394 | S_IRUSR | S_IWUSR, debugfsdir, |
435 | &pinfo->sampling_period); | 395 | &pinfo->sampling_period); |
436 | de->coeff_p = debugfs_create_u32("coeff_p", S_IRUSR | S_IWUSR, | 396 | de->coeff_p = debugfs_create_u32("coeff_p", S_IRUSR | S_IWUSR, |
437 | de->dir, &pinfo->coeff_p); | 397 | debugfsdir, &pinfo->coeff_p); |
438 | de->coeff_i = debugfs_create_u32("coeff_i", S_IRUSR | S_IWUSR, | 398 | de->coeff_i = debugfs_create_u32("coeff_i", S_IRUSR | S_IWUSR, |
439 | de->dir, &pinfo->coeff_i); | 399 | debugfsdir, &pinfo->coeff_i); |
440 | de->coeff_d = debugfs_create_u32("coeff_d", S_IRUSR | S_IWUSR, | 400 | de->coeff_d = debugfs_create_u32("coeff_d", S_IRUSR | S_IWUSR, |
441 | de->dir, &pinfo->coeff_d); | 401 | debugfsdir, &pinfo->coeff_d); |
442 | de->smoothing_shift = debugfs_create_u32("smoothing_shift", | 402 | de->smoothing_shift = debugfs_create_u32("smoothing_shift", |
443 | S_IRUSR | S_IWUSR, de->dir, | 403 | S_IRUSR | S_IWUSR, debugfsdir, |
444 | &pinfo->smoothing_shift); | 404 | &pinfo->smoothing_shift); |
445 | de->sharpen_factor = debugfs_create_u32("sharpen_factor", | 405 | de->sharpen_factor = debugfs_create_u32("sharpen_factor", |
446 | S_IRUSR | S_IWUSR, de->dir, | 406 | S_IRUSR | S_IWUSR, debugfsdir, |
447 | &pinfo->sharpen_factor); | 407 | &pinfo->sharpen_factor); |
448 | de->sharpen_duration = debugfs_create_u32("sharpen_duration", | 408 | de->sharpen_duration = debugfs_create_u32("sharpen_duration", |
449 | S_IRUSR | S_IWUSR, de->dir, | 409 | S_IRUSR | S_IWUSR, debugfsdir, |
450 | &pinfo->sharpen_duration); | 410 | &pinfo->sharpen_duration); |
451 | de->norm_offset = debugfs_create_u32("norm_offset", | 411 | de->norm_offset = debugfs_create_u32("norm_offset", |
452 | S_IRUSR | S_IWUSR, de->dir, | 412 | S_IRUSR | S_IWUSR, debugfsdir, |
453 | &pinfo->norm_offset); | 413 | &pinfo->norm_offset); |
454 | #endif | 414 | #endif |
455 | 415 | ||
@@ -471,7 +431,6 @@ static void rate_control_pid_free(void *priv) | |||
471 | debugfs_remove(de->coeff_p); | 431 | debugfs_remove(de->coeff_p); |
472 | debugfs_remove(de->sampling_period); | 432 | debugfs_remove(de->sampling_period); |
473 | debugfs_remove(de->target); | 433 | debugfs_remove(de->target); |
474 | debugfs_remove(de->dir); | ||
475 | #endif | 434 | #endif |
476 | 435 | ||
477 | kfree(pinfo->rinfo); | 436 | kfree(pinfo->rinfo); |
@@ -482,7 +441,8 @@ static void rate_control_pid_clear(void *priv) | |||
482 | { | 441 | { |
483 | } | 442 | } |
484 | 443 | ||
485 | static void *rate_control_pid_alloc_sta(void *priv, gfp_t gfp) | 444 | static void *rate_control_pid_alloc_sta(void *priv, struct ieee80211_sta *sta, |
445 | gfp_t gfp) | ||
486 | { | 446 | { |
487 | struct rc_pid_sta_info *spinfo; | 447 | struct rc_pid_sta_info *spinfo; |
488 | 448 | ||
@@ -500,10 +460,10 @@ static void *rate_control_pid_alloc_sta(void *priv, gfp_t gfp) | |||
500 | return spinfo; | 460 | return spinfo; |
501 | } | 461 | } |
502 | 462 | ||
503 | static void rate_control_pid_free_sta(void *priv, void *priv_sta) | 463 | static void rate_control_pid_free_sta(void *priv, struct ieee80211_sta *sta, |
464 | void *priv_sta) | ||
504 | { | 465 | { |
505 | struct rc_pid_sta_info *spinfo = priv_sta; | 466 | kfree(priv_sta); |
506 | kfree(spinfo); | ||
507 | } | 467 | } |
508 | 468 | ||
509 | static struct rate_control_ops mac80211_rcpid = { | 469 | static struct rate_control_ops mac80211_rcpid = { |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index d9774ac2e0f7..9b72d15bc8dc 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -93,8 +93,7 @@ static int sta_info_hash_del(struct ieee80211_local *local, | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* protected by RCU */ | 95 | /* protected by RCU */ |
96 | static struct sta_info *__sta_info_find(struct ieee80211_local *local, | 96 | struct sta_info *sta_info_get(struct ieee80211_local *local, const u8 *addr) |
97 | const u8 *addr) | ||
98 | { | 97 | { |
99 | struct sta_info *sta; | 98 | struct sta_info *sta; |
100 | 99 | ||
@@ -107,12 +106,6 @@ static struct sta_info *__sta_info_find(struct ieee80211_local *local, | |||
107 | return sta; | 106 | return sta; |
108 | } | 107 | } |
109 | 108 | ||
110 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) | ||
111 | { | ||
112 | return __sta_info_find(local, addr); | ||
113 | } | ||
114 | EXPORT_SYMBOL(sta_info_get); | ||
115 | |||
116 | struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx, | 109 | struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx, |
117 | struct net_device *dev) | 110 | struct net_device *dev) |
118 | { | 111 | { |
@@ -146,7 +139,7 @@ static void __sta_info_free(struct ieee80211_local *local, | |||
146 | { | 139 | { |
147 | DECLARE_MAC_BUF(mbuf); | 140 | DECLARE_MAC_BUF(mbuf); |
148 | 141 | ||
149 | rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv); | 142 | rate_control_free_sta(sta); |
150 | rate_control_put(sta->rate_ctrl); | 143 | rate_control_put(sta->rate_ctrl); |
151 | 144 | ||
152 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 145 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
@@ -244,7 +237,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
244 | 237 | ||
245 | sta->rate_ctrl = rate_control_get(local->rate_ctrl); | 238 | sta->rate_ctrl = rate_control_get(local->rate_ctrl); |
246 | sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, | 239 | sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, |
247 | gfp); | 240 | &sta->sta, gfp); |
248 | if (!sta->rate_ctrl_priv) { | 241 | if (!sta->rate_ctrl_priv) { |
249 | rate_control_put(sta->rate_ctrl); | 242 | rate_control_put(sta->rate_ctrl); |
250 | kfree(sta); | 243 | kfree(sta); |
@@ -308,7 +301,7 @@ int sta_info_insert(struct sta_info *sta) | |||
308 | 301 | ||
309 | spin_lock_irqsave(&local->sta_lock, flags); | 302 | spin_lock_irqsave(&local->sta_lock, flags); |
310 | /* check if STA exists already */ | 303 | /* check if STA exists already */ |
311 | if (__sta_info_find(local, sta->sta.addr)) { | 304 | if (sta_info_get(local, sta->sta.addr)) { |
312 | spin_unlock_irqrestore(&local->sta_lock, flags); | 305 | spin_unlock_irqrestore(&local->sta_lock, flags); |
313 | err = -EEXIST; | 306 | err = -EEXIST; |
314 | goto out_free; | 307 | goto out_free; |
@@ -834,7 +827,7 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, | |||
834 | struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, | 827 | struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, |
835 | const u8 *addr) | 828 | const u8 *addr) |
836 | { | 829 | { |
837 | struct sta_info *sta = __sta_info_find(hw_to_local(hw), addr); | 830 | struct sta_info *sta = sta_info_get(hw_to_local(hw), addr); |
838 | 831 | ||
839 | if (!sta) | 832 | if (!sta) |
840 | return NULL; | 833 | return NULL; |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index daedfa9e1c63..c3f436964621 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -416,7 +416,7 @@ static inline u32 get_sta_flags(struct sta_info *sta) | |||
416 | /* | 416 | /* |
417 | * Get a STA info, must have be under RCU read lock. | 417 | * Get a STA info, must have be under RCU read lock. |
418 | */ | 418 | */ |
419 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr); | 419 | struct sta_info *sta_info_get(struct ieee80211_local *local, const u8 *addr); |
420 | /* | 420 | /* |
421 | * Get STA info by index, BROKEN! | 421 | * Get STA info by index, BROKEN! |
422 | */ | 422 | */ |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 00d96e63dce9..0cc2e23f082c 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -446,7 +446,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
446 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | 446 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; |
447 | 447 | ||
448 | if (likely(tx->rate_idx < 0)) { | 448 | if (likely(tx->rate_idx < 0)) { |
449 | rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); | 449 | rate_control_get_rate(tx->sdata, sband, tx->sta, |
450 | tx->skb, &rsel); | ||
450 | if (tx->sta) | 451 | if (tx->sta) |
451 | tx->sta->last_txrate_idx = rsel.rate_idx; | 452 | tx->sta->last_txrate_idx = rsel.rate_idx; |
452 | tx->rate_idx = rsel.rate_idx; | 453 | tx->rate_idx = rsel.rate_idx; |
@@ -1955,7 +1956,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1955 | skb->do_not_encrypt = 1; | 1956 | skb->do_not_encrypt = 1; |
1956 | 1957 | ||
1957 | info->band = band; | 1958 | info->band = band; |
1958 | rate_control_get_rate(local->mdev, sband, skb, &rsel); | 1959 | rate_control_get_rate(sdata, sband, NULL, skb, &rsel); |
1959 | 1960 | ||
1960 | if (unlikely(rsel.rate_idx < 0)) { | 1961 | if (unlikely(rsel.rate_idx < 0)) { |
1961 | if (net_ratelimit()) { | 1962 | if (net_ratelimit()) { |