aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/nl80211.h2
-rw-r--r--include/net/cfg80211.h4
-rw-r--r--net/mac80211/cfg.c7
-rw-r--r--net/mac80211/debugfs_sta.c26
-rw-r--r--net/mac80211/sta_info.c3
-rw-r--r--net/mac80211/sta_info.h2
-rw-r--r--net/wireless/nl80211.c3
7 files changed, 46 insertions, 1 deletions
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index b87481866dde..be8df57b789d 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1297,6 +1297,7 @@ enum nl80211_sta_bss_param {
1297 * attribute, like NL80211_STA_INFO_TX_BITRATE. 1297 * attribute, like NL80211_STA_INFO_TX_BITRATE.
1298 * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute 1298 * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
1299 * containing info as possible, see &enum nl80211_sta_bss_param 1299 * containing info as possible, see &enum nl80211_sta_bss_param
1300 * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
1300 * @__NL80211_STA_INFO_AFTER_LAST: internal 1301 * @__NL80211_STA_INFO_AFTER_LAST: internal
1301 * @NL80211_STA_INFO_MAX: highest possible station info attribute 1302 * @NL80211_STA_INFO_MAX: highest possible station info attribute
1302 */ 1303 */
@@ -1317,6 +1318,7 @@ enum nl80211_sta_info {
1317 NL80211_STA_INFO_SIGNAL_AVG, 1318 NL80211_STA_INFO_SIGNAL_AVG,
1318 NL80211_STA_INFO_RX_BITRATE, 1319 NL80211_STA_INFO_RX_BITRATE,
1319 NL80211_STA_INFO_BSS_PARAM, 1320 NL80211_STA_INFO_BSS_PARAM,
1321 NL80211_STA_INFO_CONNECTED_TIME,
1320 1322
1321 /* keep last */ 1323 /* keep last */
1322 __NL80211_STA_INFO_AFTER_LAST, 1324 __NL80211_STA_INFO_AFTER_LAST,
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f40cd30847de..d30eada7c6cd 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -423,6 +423,7 @@ struct station_parameters {
423 * @STATION_INFO_SIGNAL_AVG: @signal_avg filled 423 * @STATION_INFO_SIGNAL_AVG: @signal_avg filled
424 * @STATION_INFO_RX_BITRATE: @rxrate fields are filled 424 * @STATION_INFO_RX_BITRATE: @rxrate fields are filled
425 * @STATION_INFO_BSS_PARAM: @bss_param filled 425 * @STATION_INFO_BSS_PARAM: @bss_param filled
426 * @STATION_INFO_CONNECTED_TIME: @connected_time filled
426 */ 427 */
427enum station_info_flags { 428enum station_info_flags {
428 STATION_INFO_INACTIVE_TIME = 1<<0, 429 STATION_INFO_INACTIVE_TIME = 1<<0,
@@ -441,6 +442,7 @@ enum station_info_flags {
441 STATION_INFO_SIGNAL_AVG = 1<<13, 442 STATION_INFO_SIGNAL_AVG = 1<<13,
442 STATION_INFO_RX_BITRATE = 1<<14, 443 STATION_INFO_RX_BITRATE = 1<<14,
443 STATION_INFO_BSS_PARAM = 1<<15, 444 STATION_INFO_BSS_PARAM = 1<<15,
445 STATION_INFO_CONNECTED_TIME = 1<<16
444}; 446};
445 447
446/** 448/**
@@ -511,6 +513,7 @@ struct sta_bss_parameters {
511 * Station information filled by driver for get_station() and dump_station. 513 * Station information filled by driver for get_station() and dump_station.
512 * 514 *
513 * @filled: bitflag of flags from &enum station_info_flags 515 * @filled: bitflag of flags from &enum station_info_flags
516 * @connected_time: time(in secs) since a station is last connected
514 * @inactive_time: time since last station activity (tx/rx) in milliseconds 517 * @inactive_time: time since last station activity (tx/rx) in milliseconds
515 * @rx_bytes: bytes received from this station 518 * @rx_bytes: bytes received from this station
516 * @tx_bytes: bytes transmitted to this station 519 * @tx_bytes: bytes transmitted to this station
@@ -533,6 +536,7 @@ struct sta_bss_parameters {
533 */ 536 */
534struct station_info { 537struct station_info {
535 u32 filled; 538 u32 filled;
539 u32 connected_time;
536 u32 inactive_time; 540 u32 inactive_time;
537 u32 rx_bytes; 541 u32 rx_bytes;
538 u32 tx_bytes; 542 u32 tx_bytes;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 1c25723eacda..a6d191f2a0fe 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -330,6 +330,7 @@ static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, in
330static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) 330static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
331{ 331{
332 struct ieee80211_sub_if_data *sdata = sta->sdata; 332 struct ieee80211_sub_if_data *sdata = sta->sdata;
333 struct timespec uptime;
333 334
334 sinfo->generation = sdata->local->sta_generation; 335 sinfo->generation = sdata->local->sta_generation;
335 336
@@ -343,7 +344,11 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
343 STATION_INFO_TX_BITRATE | 344 STATION_INFO_TX_BITRATE |
344 STATION_INFO_RX_BITRATE | 345 STATION_INFO_RX_BITRATE |
345 STATION_INFO_RX_DROP_MISC | 346 STATION_INFO_RX_DROP_MISC |
346 STATION_INFO_BSS_PARAM; 347 STATION_INFO_BSS_PARAM |
348 STATION_INFO_CONNECTED_TIME;
349
350 do_posix_clock_monotonic_gettime(&uptime);
351 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
347 352
348 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); 353 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
349 sinfo->rx_bytes = sta->rx_bytes; 354 sinfo->rx_bytes = sta->rx_bytes;
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index c04a1396cf8d..c008232731eb 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -92,6 +92,31 @@ static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf,
92} 92}
93STA_OPS(inactive_ms); 93STA_OPS(inactive_ms);
94 94
95
96static ssize_t sta_connected_time_read(struct file *file, char __user *userbuf,
97 size_t count, loff_t *ppos)
98{
99 struct sta_info *sta = file->private_data;
100 struct timespec uptime;
101 struct tm result;
102 long connected_time_secs;
103 char buf[100];
104 int res;
105 do_posix_clock_monotonic_gettime(&uptime);
106 connected_time_secs = uptime.tv_sec - sta->last_connected;
107 time_to_tm(connected_time_secs, 0, &result);
108 result.tm_year -= 70;
109 result.tm_mday -= 1;
110 res = scnprintf(buf, sizeof(buf),
111 "years - %d\nmonths - %d\ndays - %d\nclock - %d:%d:%d\n\n",
112 result.tm_year, result.tm_mon, result.tm_mday,
113 result.tm_hour, result.tm_min, result.tm_sec);
114 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
115}
116STA_OPS(connected_time);
117
118
119
95static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf, 120static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf,
96 size_t count, loff_t *ppos) 121 size_t count, loff_t *ppos)
97{ 122{
@@ -324,6 +349,7 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
324 DEBUGFS_ADD(flags); 349 DEBUGFS_ADD(flags);
325 DEBUGFS_ADD(num_ps_buf_frames); 350 DEBUGFS_ADD(num_ps_buf_frames);
326 DEBUGFS_ADD(inactive_ms); 351 DEBUGFS_ADD(inactive_ms);
352 DEBUGFS_ADD(connected_time);
327 DEBUGFS_ADD(last_seq_ctrl); 353 DEBUGFS_ADD(last_seq_ctrl);
328 DEBUGFS_ADD(agg_status); 354 DEBUGFS_ADD(agg_status);
329 DEBUGFS_ADD(dev); 355 DEBUGFS_ADD(dev);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 999f8fbf0b4b..8a9068ac0673 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -228,6 +228,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
228{ 228{
229 struct ieee80211_local *local = sdata->local; 229 struct ieee80211_local *local = sdata->local;
230 struct sta_info *sta; 230 struct sta_info *sta;
231 struct timespec uptime;
231 int i; 232 int i;
232 233
233 sta = kzalloc(sizeof(*sta) + local->hw.sta_data_size, gfp); 234 sta = kzalloc(sizeof(*sta) + local->hw.sta_data_size, gfp);
@@ -245,6 +246,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
245 sta->sdata = sdata; 246 sta->sdata = sdata;
246 sta->last_rx = jiffies; 247 sta->last_rx = jiffies;
247 248
249 do_posix_clock_monotonic_gettime(&uptime);
250 sta->last_connected = uptime.tv_sec;
248 ewma_init(&sta->avg_signal, 1024, 8); 251 ewma_init(&sta->avg_signal, 1024, 8);
249 252
250 if (sta_prepare_rate_control(local, sta, gfp)) { 253 if (sta_prepare_rate_control(local, sta, gfp)) {
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 43238e99cfb3..984a03db3553 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -226,6 +226,7 @@ enum plink_state {
226 * @rx_bytes: Number of bytes received from this STA 226 * @rx_bytes: Number of bytes received from this STA
227 * @wep_weak_iv_count: number of weak WEP IVs received from this station 227 * @wep_weak_iv_count: number of weak WEP IVs received from this station
228 * @last_rx: time (in jiffies) when last frame was received from this STA 228 * @last_rx: time (in jiffies) when last frame was received from this STA
229 * @last_connected: time (in seconds) when a station got connected
229 * @num_duplicates: number of duplicate frames received from this STA 230 * @num_duplicates: number of duplicate frames received from this STA
230 * @rx_fragments: number of received MPDUs 231 * @rx_fragments: number of received MPDUs
231 * @rx_dropped: number of dropped MPDUs from this STA 232 * @rx_dropped: number of dropped MPDUs from this STA
@@ -295,6 +296,7 @@ struct sta_info {
295 unsigned long rx_packets, rx_bytes; 296 unsigned long rx_packets, rx_bytes;
296 unsigned long wep_weak_iv_count; 297 unsigned long wep_weak_iv_count;
297 unsigned long last_rx; 298 unsigned long last_rx;
299 long last_connected;
298 unsigned long num_duplicates; 300 unsigned long num_duplicates;
299 unsigned long rx_fragments; 301 unsigned long rx_fragments;
300 unsigned long rx_dropped; 302 unsigned long rx_dropped;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 58f501a35022..0efa7fd01150 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2020,6 +2020,9 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
2020 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); 2020 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
2021 if (!sinfoattr) 2021 if (!sinfoattr)
2022 goto nla_put_failure; 2022 goto nla_put_failure;
2023 if (sinfo->filled & STATION_INFO_CONNECTED_TIME)
2024 NLA_PUT_U32(msg, NL80211_STA_INFO_CONNECTED_TIME,
2025 sinfo->connected_time);
2023 if (sinfo->filled & STATION_INFO_INACTIVE_TIME) 2026 if (sinfo->filled & STATION_INFO_INACTIVE_TIME)
2024 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME, 2027 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME,
2025 sinfo->inactive_time); 2028 sinfo->inactive_time);