Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2013 Qualcomm Atheros, Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #include "ath9k.h"
0018 
0019 /*************/
0020 /* node_aggr */
0021 /*************/
0022 
0023 static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
0024                    size_t count, loff_t *ppos)
0025 {
0026     struct ath_node *an = file->private_data;
0027     struct ath_softc *sc = an->sc;
0028     struct ath_atx_tid *tid;
0029     struct ath_txq *txq;
0030     u32 len = 0, size = 4096;
0031     char *buf;
0032     size_t retval;
0033     int tidno;
0034 
0035     buf = kzalloc(size, GFP_KERNEL);
0036     if (buf == NULL)
0037         return -ENOMEM;
0038 
0039     if (!an->sta->deflink.ht_cap.ht_supported) {
0040         len = scnprintf(buf, size, "%s\n",
0041                 "HT not supported");
0042         goto exit;
0043     }
0044 
0045     len = scnprintf(buf, size, "Max-AMPDU: %d\n",
0046             an->maxampdu);
0047     len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n",
0048              an->mpdudensity);
0049 
0050     len += scnprintf(buf + len, size - len,
0051              "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
0052              "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
0053              "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
0054 
0055     for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
0056         tid = ath_node_to_tid(an, tidno);
0057         txq = tid->txq;
0058         ath_txq_lock(sc, txq);
0059         if (tid->active) {
0060             len += scnprintf(buf + len, size - len,
0061                      "%3d%11d%10d%10d%10d%10d%9d%6d\n",
0062                      tid->tidno,
0063                      tid->seq_start,
0064                      tid->seq_next,
0065                      tid->baw_size,
0066                      tid->baw_head,
0067                      tid->baw_tail,
0068                      tid->bar_index,
0069                      !list_empty(&tid->list));
0070         }
0071         ath_txq_unlock(sc, txq);
0072     }
0073 exit:
0074     retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0075     kfree(buf);
0076 
0077     return retval;
0078 }
0079 
0080 static const struct file_operations fops_node_aggr = {
0081     .read = read_file_node_aggr,
0082     .open = simple_open,
0083     .owner = THIS_MODULE,
0084     .llseek = default_llseek,
0085 };
0086 
0087 /*************/
0088 /* node_recv */
0089 /*************/
0090 
0091 void ath_debug_rate_stats(struct ath_softc *sc,
0092               struct ath_rx_status *rs,
0093               struct sk_buff *skb)
0094 {
0095     struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
0096     struct ath_hw *ah = sc->sc_ah;
0097     struct ieee80211_rx_status *rxs;
0098     struct ath_rx_rate_stats *rstats;
0099     struct ieee80211_sta *sta;
0100     struct ath_node *an;
0101 
0102     if (!ieee80211_is_data(hdr->frame_control))
0103         return;
0104 
0105     rcu_read_lock();
0106 
0107     sta = ieee80211_find_sta_by_ifaddr(sc->hw, hdr->addr2, NULL);
0108     if (!sta)
0109         goto exit;
0110 
0111     an = (struct ath_node *) sta->drv_priv;
0112     rstats = &an->rx_rate_stats;
0113     rxs = IEEE80211_SKB_RXCB(skb);
0114 
0115     if (IS_HT_RATE(rs->rs_rate)) {
0116         if (rxs->rate_idx >= ARRAY_SIZE(rstats->ht_stats))
0117             goto exit;
0118 
0119         if (rxs->bw == RATE_INFO_BW_40)
0120             rstats->ht_stats[rxs->rate_idx].ht40_cnt++;
0121         else
0122             rstats->ht_stats[rxs->rate_idx].ht20_cnt++;
0123 
0124         if (rxs->enc_flags & RX_ENC_FLAG_SHORT_GI)
0125             rstats->ht_stats[rxs->rate_idx].sgi_cnt++;
0126         else
0127             rstats->ht_stats[rxs->rate_idx].lgi_cnt++;
0128 
0129         goto exit;
0130     }
0131 
0132     if (IS_CCK_RATE(rs->rs_rate)) {
0133         if (rxs->enc_flags & RX_ENC_FLAG_SHORTPRE)
0134             rstats->cck_stats[rxs->rate_idx].cck_sp_cnt++;
0135         else
0136             rstats->cck_stats[rxs->rate_idx].cck_lp_cnt++;
0137 
0138         goto exit;
0139     }
0140 
0141     if (IS_OFDM_RATE(rs->rs_rate)) {
0142         if (ah->curchan->chan->band == NL80211_BAND_2GHZ)
0143             rstats->ofdm_stats[rxs->rate_idx - 4].ofdm_cnt++;
0144         else
0145             rstats->ofdm_stats[rxs->rate_idx].ofdm_cnt++;
0146     }
0147 exit:
0148     rcu_read_unlock();
0149 }
0150 
0151 #define PRINT_CCK_RATE(str, i, sp)                  \
0152     do {                                \
0153         len += scnprintf(buf + len, size - len,         \
0154              "%11s : %10u\n",               \
0155              str,                       \
0156              (sp) ? rstats->cck_stats[i].cck_sp_cnt :   \
0157              rstats->cck_stats[i].cck_lp_cnt);      \
0158     } while (0)
0159 
0160 #define PRINT_OFDM_RATE(str, i)                 \
0161     do {                            \
0162         len += scnprintf(buf + len, size - len,     \
0163              "%11s : %10u\n",           \
0164              str,                   \
0165              rstats->ofdm_stats[i].ofdm_cnt);   \
0166     } while (0)
0167 
0168 static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
0169                    size_t count, loff_t *ppos)
0170 {
0171     struct ath_node *an = file->private_data;
0172     struct ath_softc *sc = an->sc;
0173     struct ath_hw *ah = sc->sc_ah;
0174     struct ath_rx_rate_stats *rstats;
0175     struct ieee80211_sta *sta = an->sta;
0176     enum nl80211_band band;
0177     u32 len = 0, size = 4096;
0178     char *buf;
0179     size_t retval;
0180     int i;
0181 
0182     buf = kzalloc(size, GFP_KERNEL);
0183     if (buf == NULL)
0184         return -ENOMEM;
0185 
0186     band = ah->curchan->chan->band;
0187     rstats = &an->rx_rate_stats;
0188 
0189     if (!sta->deflink.ht_cap.ht_supported)
0190         goto legacy;
0191 
0192     len += scnprintf(buf + len, size - len,
0193              "%24s%10s%10s%10s\n",
0194              "HT20", "HT40", "SGI", "LGI");
0195 
0196     for (i = 0; i < 24; i++) {
0197         len += scnprintf(buf + len, size - len,
0198                  "%8s%3u : %10u%10u%10u%10u\n",
0199                  "MCS", i,
0200                  rstats->ht_stats[i].ht20_cnt,
0201                  rstats->ht_stats[i].ht40_cnt,
0202                  rstats->ht_stats[i].sgi_cnt,
0203                  rstats->ht_stats[i].lgi_cnt);
0204     }
0205 
0206     len += scnprintf(buf + len, size - len, "\n");
0207 
0208 legacy:
0209     if (band == NL80211_BAND_2GHZ) {
0210         PRINT_CCK_RATE("CCK-1M/LP", 0, false);
0211         PRINT_CCK_RATE("CCK-2M/LP", 1, false);
0212         PRINT_CCK_RATE("CCK-5.5M/LP", 2, false);
0213         PRINT_CCK_RATE("CCK-11M/LP", 3, false);
0214 
0215         PRINT_CCK_RATE("CCK-2M/SP", 1, true);
0216         PRINT_CCK_RATE("CCK-5.5M/SP", 2, true);
0217         PRINT_CCK_RATE("CCK-11M/SP", 3, true);
0218     }
0219 
0220     PRINT_OFDM_RATE("OFDM-6M", 0);
0221     PRINT_OFDM_RATE("OFDM-9M", 1);
0222     PRINT_OFDM_RATE("OFDM-12M", 2);
0223     PRINT_OFDM_RATE("OFDM-18M", 3);
0224     PRINT_OFDM_RATE("OFDM-24M", 4);
0225     PRINT_OFDM_RATE("OFDM-36M", 5);
0226     PRINT_OFDM_RATE("OFDM-48M", 6);
0227     PRINT_OFDM_RATE("OFDM-54M", 7);
0228 
0229     retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0230     kfree(buf);
0231 
0232     return retval;
0233 }
0234 
0235 #undef PRINT_OFDM_RATE
0236 #undef PRINT_CCK_RATE
0237 
0238 static const struct file_operations fops_node_recv = {
0239     .read = read_file_node_recv,
0240     .open = simple_open,
0241     .owner = THIS_MODULE,
0242     .llseek = default_llseek,
0243 };
0244 
0245 void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
0246                struct ieee80211_vif *vif,
0247                struct ieee80211_sta *sta,
0248                struct dentry *dir)
0249 {
0250     struct ath_node *an = (struct ath_node *)sta->drv_priv;
0251 
0252     debugfs_create_file("node_aggr", 0444, dir, an, &fops_node_aggr);
0253     debugfs_create_file("node_recv", 0444, dir, an, &fops_node_recv);
0254 }