ath9k: Implement sta_add_debugfs/sta_remove_debugfs
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Wed, 28 Nov 2012 09:38:54 +0000 (15:08 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 30 Nov 2012 18:38:15 +0000 (13:38 -0500)
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/debug.h
drivers/net/wireless/ath/ath9k/main.c

index 60bf784e557393c56c81c256fda94cf005ce5418..86e26a19efdac1923395543c1a50fb53a6cb8958 100644 (file)
@@ -259,6 +259,7 @@ struct ath_atx_tid {
 };
 
 struct ath_node {
+       struct ath_softc *sc;
        struct ieee80211_sta *sta; /* station struct we're part of */
        struct ieee80211_vif *vif; /* interface with which we're associated */
        struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
@@ -269,6 +270,10 @@ struct ath_node {
        u8 mpdudensity;
 
        bool sleeping;
+
+#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
+       struct dentry *node_stat;
+#endif
 };
 
 #define AGGR_CLEANUP         BIT(1)
index cb5e45798ac4f7f4a54de5bea15265bcefd9b7c1..13ff9edc24015e5e2126fc4f6c7fde8dcb003c90 100644 (file)
@@ -1509,6 +1509,96 @@ static const struct file_operations fops_btcoex = {
 };
 #endif
 
+static ssize_t read_file_node_stat(struct file *file, char __user *user_buf,
+                                  size_t count, loff_t *ppos)
+{
+       struct ath_node *an = file->private_data;
+       struct ath_softc *sc = an->sc;
+       struct ath_atx_tid *tid;
+       struct ath_atx_ac *ac;
+       struct ath_txq *txq;
+       u32 len = 0, size = 4096;
+       char *buf;
+       size_t retval;
+       int tidno, acno;
+
+       buf = kzalloc(size, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
+
+       if (!an->sta->ht_cap.ht_supported) {
+               len = snprintf(buf, size, "%s\n",
+                              "HT not supported");
+               goto exit;
+       }
+
+       len = snprintf(buf, size, "Max-AMPDU: %d\n",
+                      an->maxampdu);
+       len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n",
+                       an->mpdudensity);
+
+       len += snprintf(buf + len, size - len,
+                       "%2s%7s\n", "AC", "SCHED");
+
+       for (acno = 0, ac = &an->ac[acno];
+            acno < IEEE80211_NUM_ACS; acno++, ac++) {
+               txq = ac->txq;
+               ath_txq_lock(sc, txq);
+               len += snprintf(buf + len, size - len,
+                               "%2d%7d\n",
+                               acno, ac->sched);
+               ath_txq_unlock(sc, txq);
+       }
+
+       len += snprintf(buf + len, size - len,
+                       "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
+                       "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
+                       "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
+
+       for (tidno = 0, tid = &an->tid[tidno];
+            tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
+               txq = tid->ac->txq;
+               ath_txq_lock(sc, txq);
+               len += snprintf(buf + len, size - len,
+                               "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
+                               tid->tidno, tid->seq_start, tid->seq_next,
+                               tid->baw_size, tid->baw_head, tid->baw_tail,
+                               tid->bar_index, tid->sched, tid->paused);
+               ath_txq_unlock(sc, txq);
+       }
+exit:
+       retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+       kfree(buf);
+
+       return retval;
+}
+
+static const struct file_operations fops_node_stat = {
+       .read = read_file_node_stat,
+       .open = simple_open,
+       .owner = THIS_MODULE,
+       .llseek = default_llseek,
+};
+
+void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
+                          struct ieee80211_vif *vif,
+                          struct ieee80211_sta *sta,
+                          struct dentry *dir)
+{
+       struct ath_node *an = (struct ath_node *)sta->drv_priv;
+       an->node_stat = debugfs_create_file("node_stat", S_IRUGO,
+                                           dir, an, &fops_node_stat);
+}
+
+void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw,
+                             struct ieee80211_vif *vif,
+                             struct ieee80211_sta *sta,
+                             struct dentry *dir)
+{
+       struct ath_node *an = (struct ath_node *)sta->drv_priv;
+       debugfs_remove(an->node_stat);
+}
+
 /* Ethtool support for get-stats */
 
 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
index bfc21b37cb18d0d1e6c30b84dabeb495207b6ead..72d4893311b1cc05420697acff11e2d12428c03f 100644 (file)
@@ -315,7 +315,14 @@ void ath9k_get_et_stats(struct ieee80211_hw *hw,
 void ath9k_get_et_strings(struct ieee80211_hw *hw,
                          struct ieee80211_vif *vif,
                          u32 sset, u8 *data);
-
+void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
+                          struct ieee80211_vif *vif,
+                          struct ieee80211_sta *sta,
+                          struct dentry *dir);
+void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw,
+                             struct ieee80211_vif *vif,
+                             struct ieee80211_sta *sta,
+                             struct dentry *dir);
 #else
 
 #define RX_STAT_INC(c) /* NOP */
index ffae384276a6185f70b6bb27d515d3efbb3037b6..be30a9af152884d8e073b7a3be5b79e6b3d5a8ee 100644 (file)
@@ -331,6 +331,7 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
        u8 density;
        an = (struct ath_node *)sta->drv_priv;
 
+       an->sc = sc;
        an->sta = sta;
        an->vif = vif;
 
@@ -2275,7 +2276,12 @@ struct ieee80211_ops ath9k_ops = {
 
 #ifdef CONFIG_ATH9K_DEBUGFS
        .get_et_sset_count  = ath9k_get_et_sset_count,
-       .get_et_stats  = ath9k_get_et_stats,
-       .get_et_strings  = ath9k_get_et_strings,
+       .get_et_stats       = ath9k_get_et_stats,
+       .get_et_strings     = ath9k_get_et_strings,
+#endif
+
+#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
+       .sta_add_debugfs    = ath9k_sta_add_debugfs,
+       .sta_remove_debugfs = ath9k_sta_remove_debugfs,
 #endif
 };