0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef IEEE80211_RATE_H
0010 #define IEEE80211_RATE_H
0011
0012 #include <linux/netdevice.h>
0013 #include <linux/skbuff.h>
0014 #include <linux/types.h>
0015 #include <net/mac80211.h>
0016 #include "ieee80211_i.h"
0017 #include "sta_info.h"
0018 #include "driver-ops.h"
0019
0020 struct rate_control_ref {
0021 const struct rate_control_ops *ops;
0022 void *priv;
0023 };
0024
0025 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
0026 struct sta_info *sta,
0027 struct ieee80211_tx_rate_control *txrc);
0028
0029 void rate_control_tx_status(struct ieee80211_local *local,
0030 struct ieee80211_tx_status *st);
0031
0032 void rate_control_rate_init(struct sta_info *sta);
0033 void rate_control_rate_update(struct ieee80211_local *local,
0034 struct ieee80211_supported_band *sband,
0035 struct sta_info *sta,
0036 unsigned int link_id,
0037 u32 changed);
0038
0039 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
0040 struct sta_info *sta, gfp_t gfp)
0041 {
0042 spin_lock_init(&sta->rate_ctrl_lock);
0043 return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
0044 }
0045
0046 static inline void rate_control_free_sta(struct sta_info *sta)
0047 {
0048 struct rate_control_ref *ref = sta->rate_ctrl;
0049 struct ieee80211_sta *ista = &sta->sta;
0050 void *priv_sta = sta->rate_ctrl_priv;
0051
0052 ref->ops->free_sta(ref->priv, ista, priv_sta);
0053 }
0054
0055 static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
0056 {
0057 #ifdef CONFIG_MAC80211_DEBUGFS
0058 struct rate_control_ref *ref = sta->rate_ctrl;
0059 if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
0060 ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
0061 sta->debugfs_dir);
0062 #endif
0063 }
0064
0065 extern const struct file_operations rcname_ops;
0066
0067 static inline void rate_control_add_debugfs(struct ieee80211_local *local)
0068 {
0069 #ifdef CONFIG_MAC80211_DEBUGFS
0070 struct dentry *debugfsdir;
0071
0072 if (!local->rate_ctrl)
0073 return;
0074
0075 if (!local->rate_ctrl->ops->add_debugfs)
0076 return;
0077
0078 debugfsdir = debugfs_create_dir("rc", local->hw.wiphy->debugfsdir);
0079 local->debugfs.rcdir = debugfsdir;
0080 debugfs_create_file("name", 0400, debugfsdir,
0081 local->rate_ctrl, &rcname_ops);
0082
0083 local->rate_ctrl->ops->add_debugfs(&local->hw, local->rate_ctrl->priv,
0084 debugfsdir);
0085 #endif
0086 }
0087
0088 void ieee80211_check_rate_mask(struct ieee80211_link_data *link);
0089
0090
0091
0092 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
0093 const char *name);
0094 void rate_control_deinitialize(struct ieee80211_local *local);
0095
0096
0097
0098 #ifdef CONFIG_MAC80211_RC_MINSTREL
0099 int rc80211_minstrel_init(void);
0100 void rc80211_minstrel_exit(void);
0101 #else
0102 static inline int rc80211_minstrel_init(void)
0103 {
0104 return 0;
0105 }
0106 static inline void rc80211_minstrel_exit(void)
0107 {
0108 }
0109 #endif
0110
0111
0112 #endif