mac80211: remove sta_info debugfs sub-struct
[linux-2.6-block.git] / net / mac80211 / debugfs_sta.c
index a39512f09f9eb2992f825d479a609474414d9af5..af034912abbe7f7d3d0d1bbaae555cb6d94c8f06 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (c) 2006  Jiri Benc <jbenc@suse.cz>
  * Copyright 2007      Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * 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
@@ -151,11 +152,12 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
 static ssize_t sta_agg_status_write(struct file *file, const char __user *userbuf,
                                    size_t count, loff_t *ppos)
 {
-       char _buf[12] = {}, *buf = _buf;
+       char _buf[25] = {}, *buf = _buf;
        struct sta_info *sta = file->private_data;
        bool start, tx;
        unsigned long tid;
-       int ret;
+       char *pos;
+       int ret, timeout = 5000;
 
        if (count > sizeof(_buf))
                return -EINVAL;
@@ -164,37 +166,48 @@ static ssize_t sta_agg_status_write(struct file *file, const char __user *userbu
                return -EFAULT;
 
        buf[sizeof(_buf) - 1] = '\0';
+       pos = buf;
+       buf = strsep(&pos, " ");
+       if (!buf)
+               return -EINVAL;
 
-       if (strncmp(buf, "tx ", 3) == 0) {
-               buf += 3;
+       if (!strcmp(buf, "tx"))
                tx = true;
-       } else if (strncmp(buf, "rx ", 3) == 0) {
-               buf += 3;
+       else if (!strcmp(buf, "rx"))
                tx = false;
-       else
+       else
                return -EINVAL;
 
-       if (strncmp(buf, "start ", 6) == 0) {
-               buf += 6;
+       buf = strsep(&pos, " ");
+       if (!buf)
+               return -EINVAL;
+       if (!strcmp(buf, "start")) {
                start = true;
                if (!tx)
                        return -EINVAL;
-       } else if (strncmp(buf, "stop ", 5) == 0) {
-               buf += 5;
+       } else if (!strcmp(buf, "stop")) {
                start = false;
-       } else
+       } else {
                return -EINVAL;
+       }
 
-       ret = kstrtoul(buf, 0, &tid);
-       if (ret)
-               return ret;
+       buf = strsep(&pos, " ");
+       if (!buf)
+               return -EINVAL;
+       if (sscanf(buf, "timeout=%d", &timeout) == 1) {
+               buf = strsep(&pos, " ");
+               if (!buf || !tx || !start)
+                       return -EINVAL;
+       }
 
-       if (tid >= IEEE80211_NUM_TIDS)
+       ret = kstrtoul(buf, 0, &tid);
+       if (ret || tid >= IEEE80211_NUM_TIDS)
                return -EINVAL;
 
        if (tx) {
                if (start)
-                       ret = ieee80211_start_tx_ba_session(&sta->sta, tid, 5000);
+                       ret = ieee80211_start_tx_ba_session(&sta->sta, tid,
+                                                           timeout);
                else
                        ret = ieee80211_stop_tx_ba_session(&sta->sta, tid);
        } else {
@@ -322,14 +335,14 @@ STA_OPS(vht_capa);
 
 #define DEBUGFS_ADD(name) \
        debugfs_create_file(#name, 0400, \
-               sta->debugfs.dir, sta, &sta_ ##name## _ops);
+               sta->debugfs_dir, sta, &sta_ ##name## _ops);
 
 #define DEBUGFS_ADD_COUNTER(name, field)                               \
        if (sizeof(sta->field) == sizeof(u32))                          \
-               debugfs_create_u32(#name, 0400, sta->debugfs.dir,       \
+               debugfs_create_u32(#name, 0400, sta->debugfs_dir,       \
                        (u32 *) &sta->field);                           \
        else                                                            \
-               debugfs_create_u64(#name, 0400, sta->debugfs.dir,       \
+               debugfs_create_u64(#name, 0400, sta->debugfs_dir,       \
                        (u64 *) &sta->field);
 
 void ieee80211_sta_debugfs_add(struct sta_info *sta)
@@ -339,8 +352,6 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
        struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations;
        u8 mac[3*ETH_ALEN];
 
-       sta->debugfs.add_has_run = true;
-
        if (!stations_dir)
                return;
 
@@ -355,8 +366,8 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
         * destroyed quickly enough the old station's debugfs
         * dir might still be around.
         */
-       sta->debugfs.dir = debugfs_create_dir(mac, stations_dir);
-       if (!sta->debugfs.dir)
+       sta->debugfs_dir = debugfs_create_dir(mac, stations_dir);
+       if (!sta->debugfs_dir)
                return;
 
        DEBUGFS_ADD(flags);
@@ -372,14 +383,14 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
 
        if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
                debugfs_create_x32("driver_buffered_tids", 0400,
-                                  sta->debugfs.dir,
+                                  sta->debugfs_dir,
                                   (u32 *)&sta->driver_buffered_tids);
        else
                debugfs_create_x64("driver_buffered_tids", 0400,
-                                  sta->debugfs.dir,
+                                  sta->debugfs_dir,
                                   (u64 *)&sta->driver_buffered_tids);
 
-       drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
+       drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs_dir);
 }
 
 void ieee80211_sta_debugfs_remove(struct sta_info *sta)
@@ -387,7 +398,7 @@ void ieee80211_sta_debugfs_remove(struct sta_info *sta)
        struct ieee80211_local *local = sta->local;
        struct ieee80211_sub_if_data *sdata = sta->sdata;
 
-       drv_sta_remove_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
-       debugfs_remove_recursive(sta->debugfs.dir);
-       sta->debugfs.dir = NULL;
+       drv_sta_remove_debugfs(local, sdata, &sta->sta, sta->debugfs_dir);
+       debugfs_remove_recursive(sta->debugfs_dir);
+       sta->debugfs_dir = NULL;
 }