1 --- a/drivers/net/wireless/ath/ath9k/debug.c
2 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3 @@ -378,95 +378,6 @@ static const struct file_operations fops
7 -void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
9 - struct ath_rc_stats *stats;
11 - stats = &sc->debug.stats.rcstats[final_rate];
15 -void ath_debug_stat_retries(struct ath_softc *sc, int rix,
16 - int xretries, int retries, u8 per)
18 - struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix];
20 - stats->xretries += xretries;
21 - stats->retries += retries;
25 -static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
26 - size_t count, loff_t *ppos)
28 - struct ath_softc *sc = file->private_data;
30 - unsigned int len = 0, max;
34 - if (sc->cur_rate_table == NULL)
37 - max = 80 + sc->cur_rate_table->rate_cnt * 1024 + 1;
38 - buf = kmalloc(max, GFP_KERNEL);
42 - len += sprintf(buf, "%6s %6s %6s "
43 - "%10s %10s %10s %10s\n",
44 - "HT", "MCS", "Rate",
45 - "Success", "Retries", "XRetries", "PER");
47 - for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
48 - u32 ratekbps = sc->cur_rate_table->info[i].ratekbps;
49 - struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i];
52 - int used_mcs = 0, used_htmode = 0;
54 - if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) {
55 - used_mcs = snprintf(mcs, 5, "%d",
56 - sc->cur_rate_table->info[i].ratecode);
58 - if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy))
59 - used_htmode = snprintf(htmode, 5, "HT40");
60 - else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy))
61 - used_htmode = snprintf(htmode, 5, "HT20");
63 - used_htmode = snprintf(htmode, 5, "????");
66 - mcs[used_mcs] = '\0';
67 - htmode[used_htmode] = '\0';
69 - len += snprintf(buf + len, max - len,
71 - "%10u %10u %10u %10u\n",
75 - (ratekbps % 1000) / 100,
85 - retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
90 -static const struct file_operations fops_rcstat = {
91 - .read = read_file_rcstat,
92 - .open = ath9k_debugfs_open,
93 - .owner = THIS_MODULE
96 static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
99 @@ -1024,10 +935,6 @@ int ath9k_init_debug(struct ath_hw *ah)
100 sc, &fops_interrupt))
103 - if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy,
107 if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR,
108 sc->debug.debugfs_phy, sc, &fops_wiphy))
110 --- a/drivers/net/wireless/ath/ath9k/debug.h
111 +++ b/drivers/net/wireless/ath/ath9k/debug.h
112 @@ -80,13 +80,6 @@ struct ath_interrupt_stats {
116 -struct ath_rc_stats {
124 * struct ath_tx_stats - Statistics about TX
125 * @tx_pkts_all: No. of total frames transmitted, including ones that
126 @@ -160,7 +153,6 @@ struct ath_rx_stats {
129 struct ath_interrupt_stats istats;
130 - struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
131 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
132 struct ath_rx_stats rxstats;
134 @@ -177,12 +169,9 @@ void ath9k_exit_debug(struct ath_hw *ah)
135 int ath9k_debug_create_root(void);
136 void ath9k_debug_remove_root(void);
137 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
138 -void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
139 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
140 struct ath_buf *bf, struct ath_tx_status *ts);
141 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
142 -void ath_debug_stat_retries(struct ath_softc *sc, int rix,
143 - int xretries, int retries, u8 per);
147 @@ -209,11 +198,6 @@ static inline void ath_debug_stat_interr
151 -static inline void ath_debug_stat_rc(struct ath_softc *sc,
156 static inline void ath_debug_stat_tx(struct ath_softc *sc,
159 @@ -226,11 +210,6 @@ static inline void ath_debug_stat_rx(str
163 -static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
164 - int xretries, int retries, u8 per)
168 #endif /* CONFIG_ATH9K_DEBUGFS */
171 --- a/drivers/net/wireless/ath/ath9k/rc.c
172 +++ b/drivers/net/wireless/ath/ath9k/rc.c
173 @@ -1026,6 +1026,16 @@ static bool ath_rc_update_per(struct ath
177 +static void ath_debug_stat_retries(struct ath_rate_priv *rc, int rix,
178 + int xretries, int retries, u8 per)
180 + struct ath_rc_stats *stats = &rc->rcstats[rix];
182 + stats->xretries += xretries;
183 + stats->retries += retries;
187 /* Update PER, RSSI and whatever else that the code thinks it is doing.
188 If you can make sense of all this, you really need to go out more. */
190 @@ -1098,7 +1108,7 @@ static void ath_rc_update_ht(struct ath_
191 ath_rc_priv->per_down_time = now_msec;
194 - ath_debug_stat_retries(sc, tx_rate, xretries, retries,
195 + ath_debug_stat_retries(ath_rc_priv, tx_rate, xretries, retries,
196 ath_rc_priv->per[tx_rate]);
199 @@ -1294,6 +1304,7 @@ static void ath_rc_init(struct ath_softc
200 ath_rc_sort_validrates(rate_table, ath_rc_priv);
201 ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4];
202 sc->cur_rate_table = rate_table;
203 + ath_rc_priv->rate_table = rate_table;
205 ath_print(common, ATH_DBG_CONFIG,
206 "RC Initialized with capabilities: 0x%x\n",
207 @@ -1340,6 +1351,15 @@ static bool ath_tx_aggr_check(struct ath
208 /* mac80211 Rate Control callbacks */
209 /***********************************/
211 +static void ath_debug_stat_rc(struct ath_rate_priv *rc, int final_rate)
213 + struct ath_rc_stats *stats;
215 + stats = &rc->rcstats[final_rate];
220 static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
221 struct ieee80211_sta *sta, void *priv_sta,
223 @@ -1419,7 +1439,7 @@ static void ath_tx_status(void *priv, st
227 - ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table,
228 + ath_debug_stat_rc(ath_rc_priv, ath_rc_get_rateindex(sc->cur_rate_table,
229 &tx_info->status.rates[final_ts_idx]));
232 @@ -1521,6 +1541,94 @@ static void ath_rate_update(void *priv,
236 +#ifdef CONFIG_ATH9K_DEBUGFS
238 +static int ath9k_debugfs_open(struct inode *inode, struct file *file)
240 + file->private_data = inode->i_private;
244 +static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
245 + size_t count, loff_t *ppos)
247 + struct ath_rate_priv *rc = file->private_data;
249 + unsigned int len = 0, max;
253 + if (rc->rate_table == NULL)
256 + max = 80 + rc->rate_table->rate_cnt * 1024 + 1;
257 + buf = kmalloc(max, GFP_KERNEL);
261 + len += sprintf(buf, "%6s %6s %6s "
262 + "%10s %10s %10s %10s\n",
263 + "HT", "MCS", "Rate",
264 + "Success", "Retries", "XRetries", "PER");
266 + for (i = 0; i < rc->rate_table->rate_cnt; i++) {
267 + u32 ratekbps = rc->rate_table->info[i].ratekbps;
268 + struct ath_rc_stats *stats = &rc->rcstats[i];
271 + int used_mcs = 0, used_htmode = 0;
273 + if (WLAN_RC_PHY_HT(rc->rate_table->info[i].phy)) {
274 + used_mcs = snprintf(mcs, 5, "%d",
275 + rc->rate_table->info[i].ratecode);
277 + if (WLAN_RC_PHY_40(rc->rate_table->info[i].phy))
278 + used_htmode = snprintf(htmode, 5, "HT40");
279 + else if (WLAN_RC_PHY_20(rc->rate_table->info[i].phy))
280 + used_htmode = snprintf(htmode, 5, "HT20");
282 + used_htmode = snprintf(htmode, 5, "????");
285 + mcs[used_mcs] = '\0';
286 + htmode[used_htmode] = '\0';
288 + len += snprintf(buf + len, max - len,
290 + "%10u %10u %10u %10u\n",
294 + (ratekbps % 1000) / 100,
304 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
309 +static const struct file_operations fops_rcstat = {
310 + .read = read_file_rcstat,
311 + .open = ath9k_debugfs_open,
312 + .owner = THIS_MODULE
315 +static void ath_rate_add_sta_debugfs(void *priv, void *priv_sta,
316 + struct dentry *dir)
318 + struct ath_rate_priv *rc = priv_sta;
319 + debugfs_create_file("rc_stats", S_IRUGO, dir, rc, &fops_rcstat);
322 +#endif /* CONFIG_ATH9K_DEBUGFS */
324 static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
326 struct ath_wiphy *aphy = hw->priv;
327 @@ -1567,6 +1675,9 @@ static struct rate_control_ops ath_rate_
328 .free = ath_rate_free,
329 .alloc_sta = ath_rate_alloc_sta,
330 .free_sta = ath_rate_free_sta,
331 +#ifdef CONFIG_ATH9K_DEBUGFS
332 + .add_sta_debugfs = ath_rate_add_sta_debugfs,
336 int ath_rate_control_register(void)
337 --- a/drivers/net/wireless/ath/ath9k/rc.h
338 +++ b/drivers/net/wireless/ath/ath9k/rc.h
339 @@ -176,6 +176,13 @@ struct ath_rateset {
340 u8 rs_rates[ATH_RATE_MAX];
343 +struct ath_rc_stats {
351 * struct ath_rate_priv - Rate Control priv data
353 @@ -212,6 +219,10 @@ struct ath_rate_priv {
354 struct ath_rateset neg_rates;
355 struct ath_rateset neg_ht_rates;
356 struct ath_rate_softc *asc;
357 + const struct ath_rate_table *rate_table;
359 + struct dentry *debugfs_rcstats;
360 + struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
363 #define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0)