aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/rc.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-10-13 10:43:26 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-15 15:48:44 -0400
commit772d5515635fef5bc7a9d0efee785b58b0181ee5 (patch)
treeab01946e53486d79b831c83456af71d8ab495b63 /drivers/net/wireless/ath/ath9k/rc.c
parent88eac2dad876a58b9c6a4c4805c3fc27b02c048f (diff)
ath9k: make rate control debugfs stats per station
Move them to the same debugfs file that the other rc modules use. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/rc.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c115
1 files changed, 113 insertions, 2 deletions
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index abebf2466a13..5db3a12356ec 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1026,6 +1026,16 @@ static bool ath_rc_update_per(struct ath_softc *sc,
1026 return state_change; 1026 return state_change;
1027} 1027}
1028 1028
1029static void ath_debug_stat_retries(struct ath_rate_priv *rc, int rix,
1030 int xretries, int retries, u8 per)
1031{
1032 struct ath_rc_stats *stats = &rc->rcstats[rix];
1033
1034 stats->xretries += xretries;
1035 stats->retries += retries;
1036 stats->per = per;
1037}
1038
1029/* Update PER, RSSI and whatever else that the code thinks it is doing. 1039/* Update PER, RSSI and whatever else that the code thinks it is doing.
1030 If you can make sense of all this, you really need to go out more. */ 1040 If you can make sense of all this, you really need to go out more. */
1031 1041
@@ -1098,7 +1108,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
1098 ath_rc_priv->per_down_time = now_msec; 1108 ath_rc_priv->per_down_time = now_msec;
1099 } 1109 }
1100 1110
1101 ath_debug_stat_retries(sc, tx_rate, xretries, retries, 1111 ath_debug_stat_retries(ath_rc_priv, tx_rate, xretries, retries,
1102 ath_rc_priv->per[tx_rate]); 1112 ath_rc_priv->per[tx_rate]);
1103 1113
1104} 1114}
@@ -1294,6 +1304,7 @@ static void ath_rc_init(struct ath_softc *sc,
1294 ath_rc_sort_validrates(rate_table, ath_rc_priv); 1304 ath_rc_sort_validrates(rate_table, ath_rc_priv);
1295 ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; 1305 ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4];
1296 sc->cur_rate_table = rate_table; 1306 sc->cur_rate_table = rate_table;
1307 ath_rc_priv->rate_table = rate_table;
1297 1308
1298 ath_print(common, ATH_DBG_CONFIG, 1309 ath_print(common, ATH_DBG_CONFIG,
1299 "RC Initialized with capabilities: 0x%x\n", 1310 "RC Initialized with capabilities: 0x%x\n",
@@ -1340,6 +1351,15 @@ static bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an,
1340/* mac80211 Rate Control callbacks */ 1351/* mac80211 Rate Control callbacks */
1341/***********************************/ 1352/***********************************/
1342 1353
1354static void ath_debug_stat_rc(struct ath_rate_priv *rc, int final_rate)
1355{
1356 struct ath_rc_stats *stats;
1357
1358 stats = &rc->rcstats[final_rate];
1359 stats->success++;
1360}
1361
1362
1343static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, 1363static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1344 struct ieee80211_sta *sta, void *priv_sta, 1364 struct ieee80211_sta *sta, void *priv_sta,
1345 struct sk_buff *skb) 1365 struct sk_buff *skb)
@@ -1419,7 +1439,7 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1419 } 1439 }
1420 } 1440 }
1421 1441
1422 ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table, 1442 ath_debug_stat_rc(ath_rc_priv, ath_rc_get_rateindex(sc->cur_rate_table,
1423 &tx_info->status.rates[final_ts_idx])); 1443 &tx_info->status.rates[final_ts_idx]));
1424} 1444}
1425 1445
@@ -1521,6 +1541,94 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1521 } 1541 }
1522} 1542}
1523 1543
1544#ifdef CONFIG_ATH9K_DEBUGFS
1545
1546static int ath9k_debugfs_open(struct inode *inode, struct file *file)
1547{
1548 file->private_data = inode->i_private;
1549 return 0;
1550}
1551
1552static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
1553 size_t count, loff_t *ppos)
1554{
1555 struct ath_rate_priv *rc = file->private_data;
1556 char *buf;
1557 unsigned int len = 0, max;
1558 int i = 0;
1559 ssize_t retval;
1560
1561 if (rc->rate_table == NULL)
1562 return 0;
1563
1564 max = 80 + rc->rate_table->rate_cnt * 1024 + 1;
1565 buf = kmalloc(max, GFP_KERNEL);
1566 if (buf == NULL)
1567 return -ENOMEM;
1568
1569 len += sprintf(buf, "%6s %6s %6s "
1570 "%10s %10s %10s %10s\n",
1571 "HT", "MCS", "Rate",
1572 "Success", "Retries", "XRetries", "PER");
1573
1574 for (i = 0; i < rc->rate_table->rate_cnt; i++) {
1575 u32 ratekbps = rc->rate_table->info[i].ratekbps;
1576 struct ath_rc_stats *stats = &rc->rcstats[i];
1577 char mcs[5];
1578 char htmode[5];
1579 int used_mcs = 0, used_htmode = 0;
1580
1581 if (WLAN_RC_PHY_HT(rc->rate_table->info[i].phy)) {
1582 used_mcs = snprintf(mcs, 5, "%d",
1583 rc->rate_table->info[i].ratecode);
1584
1585 if (WLAN_RC_PHY_40(rc->rate_table->info[i].phy))
1586 used_htmode = snprintf(htmode, 5, "HT40");
1587 else if (WLAN_RC_PHY_20(rc->rate_table->info[i].phy))
1588 used_htmode = snprintf(htmode, 5, "HT20");
1589 else
1590 used_htmode = snprintf(htmode, 5, "????");
1591 }
1592
1593 mcs[used_mcs] = '\0';
1594 htmode[used_htmode] = '\0';
1595
1596 len += snprintf(buf + len, max - len,
1597 "%6s %6s %3u.%d: "
1598 "%10u %10u %10u %10u\n",
1599 htmode,
1600 mcs,
1601 ratekbps / 1000,
1602 (ratekbps % 1000) / 100,
1603 stats->success,
1604 stats->retries,
1605 stats->xretries,
1606 stats->per);
1607 }
1608
1609 if (len > max)
1610 len = max;
1611
1612 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1613 kfree(buf);
1614 return retval;
1615}
1616
1617static const struct file_operations fops_rcstat = {
1618 .read = read_file_rcstat,
1619 .open = ath9k_debugfs_open,
1620 .owner = THIS_MODULE
1621};
1622
1623static void ath_rate_add_sta_debugfs(void *priv, void *priv_sta,
1624 struct dentry *dir)
1625{
1626 struct ath_rate_priv *rc = priv_sta;
1627 debugfs_create_file("rc_stats", S_IRUGO, dir, rc, &fops_rcstat);
1628}
1629
1630#endif /* CONFIG_ATH9K_DEBUGFS */
1631
1524static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 1632static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
1525{ 1633{
1526 struct ath_wiphy *aphy = hw->priv; 1634 struct ath_wiphy *aphy = hw->priv;
@@ -1567,6 +1675,9 @@ static struct rate_control_ops ath_rate_ops = {
1567 .free = ath_rate_free, 1675 .free = ath_rate_free,
1568 .alloc_sta = ath_rate_alloc_sta, 1676 .alloc_sta = ath_rate_alloc_sta,
1569 .free_sta = ath_rate_free_sta, 1677 .free_sta = ath_rate_free_sta,
1678#ifdef CONFIG_ATH9K_DEBUGFS
1679 .add_sta_debugfs = ath_rate_add_sta_debugfs,
1680#endif
1570}; 1681};
1571 1682
1572int ath_rate_control_register(void) 1683int ath_rate_control_register(void)