Commit c84387d2 authored by Johannes Berg's avatar Johannes Berg

mac80211: clean up station flags debugfs

Avoid the really strange %s%s%s expression, use an array
of flag names and check that all flags are present.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 3c5bcb2e
...@@ -52,31 +52,54 @@ static const struct file_operations sta_ ##name## _ops = { \ ...@@ -52,31 +52,54 @@ static const struct file_operations sta_ ##name## _ops = { \
STA_FILE(aid, sta.aid, D); STA_FILE(aid, sta.aid, D);
static const char * const sta_flag_names[] = {
#define FLAG(F) [WLAN_STA_##F] = #F
FLAG(AUTH),
FLAG(ASSOC),
FLAG(PS_STA),
FLAG(AUTHORIZED),
FLAG(SHORT_PREAMBLE),
FLAG(WDS),
FLAG(CLEAR_PS_FILT),
FLAG(MFP),
FLAG(BLOCK_BA),
FLAG(PS_DRIVER),
FLAG(PSPOLL),
FLAG(TDLS_PEER),
FLAG(TDLS_PEER_AUTH),
FLAG(TDLS_INITIATOR),
FLAG(TDLS_CHAN_SWITCH),
FLAG(TDLS_OFF_CHANNEL),
FLAG(TDLS_WIDER_BW),
FLAG(UAPSD),
FLAG(SP),
FLAG(4ADDR_EVENT),
FLAG(INSERTED),
FLAG(RATE_CONTROL),
FLAG(TOFFSET_KNOWN),
FLAG(MPSP_OWNER),
FLAG(MPSP_RECIPIENT),
FLAG(PS_DELIVER),
#undef FLAG
};
static ssize_t sta_flags_read(struct file *file, char __user *userbuf, static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[121]; char buf[16 * NUM_WLAN_STA_FLAGS], *pos = buf;
char *end = buf + sizeof(buf) - 1;
struct sta_info *sta = file->private_data; struct sta_info *sta = file->private_data;
unsigned int flg;
BUILD_BUG_ON(ARRAY_SIZE(sta_flag_names) != NUM_WLAN_STA_FLAGS);
for (flg = 0; flg < NUM_WLAN_STA_FLAGS; flg++) {
if (test_sta_flag(sta, flg))
pos += scnprintf(pos, end - pos, "%s\n",
sta_flag_names[flg]);
}
#define TEST(flg) \ return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
int res = scnprintf(buf, sizeof(buf),
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
TEST(PS_DRIVER), TEST(AUTHORIZED),
TEST(SHORT_PREAMBLE),
sta->sta.wme ? "WME\n" : "",
TEST(WDS), TEST(CLEAR_PS_FILT),
TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
TEST(TDLS_PEER_AUTH), TEST(TDLS_INITIATOR),
TEST(TDLS_CHAN_SWITCH), TEST(TDLS_OFF_CHANNEL),
TEST(4ADDR_EVENT), TEST(INSERTED),
TEST(RATE_CONTROL), TEST(TOFFSET_KNOWN),
TEST(MPSP_OWNER), TEST(MPSP_RECIPIENT));
#undef TEST
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
} }
STA_OPS(flags); STA_OPS(flags);
......
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
* @WLAN_STA_MPSP_RECIPIENT: local STA is recipient of a MPSP. * @WLAN_STA_MPSP_RECIPIENT: local STA is recipient of a MPSP.
* @WLAN_STA_PS_DELIVER: station woke up, but we're still blocking TX * @WLAN_STA_PS_DELIVER: station woke up, but we're still blocking TX
* until pending frames are delivered * until pending frames are delivered
*
* @NUM_WLAN_STA_FLAGS: number of defined flags
*/ */
enum ieee80211_sta_info_flags { enum ieee80211_sta_info_flags {
WLAN_STA_AUTH, WLAN_STA_AUTH,
...@@ -97,6 +99,8 @@ enum ieee80211_sta_info_flags { ...@@ -97,6 +99,8 @@ enum ieee80211_sta_info_flags {
WLAN_STA_MPSP_OWNER, WLAN_STA_MPSP_OWNER,
WLAN_STA_MPSP_RECIPIENT, WLAN_STA_MPSP_RECIPIENT,
WLAN_STA_PS_DELIVER, WLAN_STA_PS_DELIVER,
NUM_WLAN_STA_FLAGS,
}; };
#define ADDBA_RESP_INTERVAL HZ #define ADDBA_RESP_INTERVAL HZ
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment