Blame view

net/mac80211/rate.h 4.21 KB
f0706e828   Jiri Benc   [MAC80211]: Add m...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  /*
   * Copyright 2002-2005, Instant802 Networks, Inc.
   * Copyright 2005, Devicescape Software, Inc.
   * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #ifndef IEEE80211_RATE_H
  #define IEEE80211_RATE_H
  
  #include <linux/netdevice.h>
  #include <linux/skbuff.h>
  #include <linux/types.h>
d0709a651   Johannes Berg   mac80211: RCU-ify...
17
  #include <linux/kref.h>
f0706e828   Jiri Benc   [MAC80211]: Add m...
18
19
20
  #include <net/mac80211.h>
  #include "ieee80211_i.h"
  #include "sta_info.h"
f0706e828   Jiri Benc   [MAC80211]: Add m...
21
  struct rate_control_ref {
4b7679a56   Johannes Berg   mac80211: clean u...
22
  	struct ieee80211_local *local;
f0706e828   Jiri Benc   [MAC80211]: Add m...
23
24
25
26
  	struct rate_control_ops *ops;
  	void *priv;
  	struct kref kref;
  };
4b7679a56   Johannes Berg   mac80211: clean u...
27
  void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
e6a9854b0   Johannes Berg   mac80211/drivers:...
28
29
  			   struct sta_info *sta,
  			   struct ieee80211_tx_rate_control *txrc);
f0706e828   Jiri Benc   [MAC80211]: Add m...
30
31
  struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
  void rate_control_put(struct rate_control_ref *ref);
4b7679a56   Johannes Berg   mac80211: clean u...
32
33
34
  static inline void rate_control_tx_status(struct ieee80211_local *local,
  					  struct ieee80211_supported_band *sband,
  					  struct sta_info *sta,
e039fa4a4   Johannes Berg   mac80211: move TX...
35
  					  struct sk_buff *skb)
f0706e828   Jiri Benc   [MAC80211]: Add m...
36
37
  {
  	struct rate_control_ref *ref = local->rate_ctrl;
4b7679a56   Johannes Berg   mac80211: clean u...
38
39
  	struct ieee80211_sta *ista = &sta->sta;
  	void *priv_sta = sta->rate_ctrl_priv;
3c384053c   Vasanthakumar   mac80211: Don't c...
40
41
42
  
  	if (!ref)
  		return;
37eb0b164   Jouni Malinen   cfg80211/mac80211...
43
  	ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
f0706e828   Jiri Benc   [MAC80211]: Add m...
44
  }
4b7679a56   Johannes Berg   mac80211: clean u...
45
  static inline void rate_control_rate_init(struct sta_info *sta)
f0706e828   Jiri Benc   [MAC80211]: Add m...
46
  {
4b7679a56   Johannes Berg   mac80211: clean u...
47
  	struct ieee80211_local *local = sta->sdata->local;
f0706e828   Jiri Benc   [MAC80211]: Add m...
48
  	struct rate_control_ref *ref = sta->rate_ctrl;
4b7679a56   Johannes Berg   mac80211: clean u...
49
50
51
  	struct ieee80211_sta *ista = &sta->sta;
  	void *priv_sta = sta->rate_ctrl_priv;
  	struct ieee80211_supported_band *sband;
af65cd96d   Johannes Berg   mac80211: make so...
52
53
  	if (!ref)
  		return;
4b7679a56   Johannes Berg   mac80211: clean u...
54
55
56
  	sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  
  	ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
f0706e828   Jiri Benc   [MAC80211]: Add m...
57
  }
81cb7623a   Sujith   mac80211: Extend ...
58
59
  static inline void rate_control_rate_update(struct ieee80211_local *local,
  				    struct ieee80211_supported_band *sband,
4fa004373   Sujith   mac80211: Fix HT ...
60
61
  				    struct sta_info *sta, u32 changed,
  				    enum nl80211_channel_type oper_chan_type)
81cb7623a   Sujith   mac80211: Extend ...
62
63
64
65
  {
  	struct rate_control_ref *ref = local->rate_ctrl;
  	struct ieee80211_sta *ista = &sta->sta;
  	void *priv_sta = sta->rate_ctrl_priv;
af65cd96d   Johannes Berg   mac80211: make so...
66
  	if (ref && ref->ops->rate_update)
81cb7623a   Sujith   mac80211: Extend ...
67
  		ref->ops->rate_update(ref->priv, sband, ista,
4fa004373   Sujith   mac80211: Fix HT ...
68
  				      priv_sta, changed, oper_chan_type);
81cb7623a   Sujith   mac80211: Extend ...
69
  }
f0706e828   Jiri Benc   [MAC80211]: Add m...
70

f0706e828   Jiri Benc   [MAC80211]: Add m...
71
  static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
4b7679a56   Johannes Berg   mac80211: clean u...
72
  					   struct ieee80211_sta *sta,
f0706e828   Jiri Benc   [MAC80211]: Add m...
73
74
  					   gfp_t gfp)
  {
4b7679a56   Johannes Berg   mac80211: clean u...
75
  	return ref->ops->alloc_sta(ref->priv, sta, gfp);
f0706e828   Jiri Benc   [MAC80211]: Add m...
76
  }
4b7679a56   Johannes Berg   mac80211: clean u...
77
  static inline void rate_control_free_sta(struct sta_info *sta)
f0706e828   Jiri Benc   [MAC80211]: Add m...
78
  {
4b7679a56   Johannes Berg   mac80211: clean u...
79
80
81
82
83
  	struct rate_control_ref *ref = sta->rate_ctrl;
  	struct ieee80211_sta *ista = &sta->sta;
  	void *priv_sta = sta->rate_ctrl_priv;
  
  	ref->ops->free_sta(ref->priv, ista, priv_sta);
f0706e828   Jiri Benc   [MAC80211]: Add m...
84
  }
e9f207f0f   Jiri Benc   [MAC80211]: Add d...
85
86
87
88
  static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
  {
  #ifdef CONFIG_MAC80211_DEBUGFS
  	struct rate_control_ref *ref = sta->rate_ctrl;
af65cd96d   Johannes Berg   mac80211: make so...
89
  	if (ref && sta->debugfs.dir && ref->ops->add_sta_debugfs)
e9f207f0f   Jiri Benc   [MAC80211]: Add d...
90
91
92
93
94
95
96
97
98
  		ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
  					  sta->debugfs.dir);
  #endif
  }
  
  static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
  {
  #ifdef CONFIG_MAC80211_DEBUGFS
  	struct rate_control_ref *ref = sta->rate_ctrl;
af65cd96d   Johannes Berg   mac80211: make so...
99
  	if (ref && ref->ops->remove_sta_debugfs)
e9f207f0f   Jiri Benc   [MAC80211]: Add d...
100
101
102
  		ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
  #endif
  }
209c671db   Andres Salomon   mac80211: make ra...
103
104
  /* Get a reference to the rate control algorithm. If `name' is NULL, get the
   * first available algorithm. */
ff6880892   Johannes Berg   [MAC80211]: move ...
105
106
107
  int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  				 const char *name);
  void rate_control_deinitialize(struct ieee80211_local *local);
4b475898e   Johannes Berg   mac80211: better ...
108
109
  
  /* Rate control algorithms */
e5f5e7339   Adrian Bunk   build algorithms ...
110
  #ifdef CONFIG_MAC80211_RC_PID
4b475898e   Johannes Berg   mac80211: better ...
111
112
113
114
115
116
117
118
119
120
121
  extern int rc80211_pid_init(void);
  extern void rc80211_pid_exit(void);
  #else
  static inline int rc80211_pid_init(void)
  {
  	return 0;
  }
  static inline void rc80211_pid_exit(void)
  {
  }
  #endif
cccf129f8   Felix Fietkau   mac80211: add the...
122
123
124
125
126
127
128
129
130
131
132
133
  #ifdef CONFIG_MAC80211_RC_MINSTREL
  extern int rc80211_minstrel_init(void);
  extern void rc80211_minstrel_exit(void);
  #else
  static inline int rc80211_minstrel_init(void)
  {
  	return 0;
  }
  static inline void rc80211_minstrel_exit(void)
  {
  }
  #endif
ec8aa669b   Felix Fietkau   mac80211: add the...
134
135
136
137
138
139
140
141
142
143
144
145
  #ifdef CONFIG_MAC80211_RC_MINSTREL_HT
  extern int rc80211_minstrel_ht_init(void);
  extern void rc80211_minstrel_ht_exit(void);
  #else
  static inline int rc80211_minstrel_ht_init(void)
  {
  	return 0;
  }
  static inline void rc80211_minstrel_ht_exit(void)
  {
  }
  #endif
cccf129f8   Felix Fietkau   mac80211: add the...
146

f0706e828   Jiri Benc   [MAC80211]: Add m...
147
  #endif /* IEEE80211_RATE_H */