aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/mac80211.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-18 12:14:18 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-24 16:18:03 -0400
commit4b7679a561e552eeda1e3567119bef2bca99b66e (patch)
treeb5f2b45c9186eb954f9329322d07e277e669b422 /include/net/mac80211.h
parent2ff6a6d4e92270283432690adf53a7e5ab186d19 (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>
Diffstat (limited to 'include/net/mac80211.h')
-rw-r--r--include/net/mac80211.h68
1 files changed, 68 insertions, 0 deletions
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,
1800struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw, 1800struct 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 */
1814struct rate_selection {
1815 s8 rate_idx, nonerp_idx, probe_idx, max_rate_idx;
1816};
1817
1818struct 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
1844static 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
1851static inline s8
1852rate_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
1868int ieee80211_rate_control_register(struct rate_control_ops *ops);
1869void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
1870
1803#endif /* MAC80211_H */ 1871#endif /* MAC80211_H */