2011-04-05 13:40:02

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC] mac80211: Add station uptime in debugfs

From: Mohammed Shafi Shajakhan <[email protected]>

Add station uptime parameter in debugfs. This will be helpful to get a
measure of stability of connection and also during stress testing.

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
net/mac80211/debugfs_sta.c | 22 ++++++++++++++++++++++
net/mac80211/sta_info.c | 1 +
net/mac80211/sta_info.h | 2 ++
3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index c04a139..cc79e76 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -73,6 +73,27 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
}
STA_OPS(flags);

+static ssize_t sta_station_uptime_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct sta_info *sta = file->private_data;
+ struct tm result;
+ unsigned long uptime_msecs;
+ unsigned long uptime_secs;
+ char buf[100];
+ int res;
+ uptime_msecs = jiffies_to_msecs(jiffies - (sta->sta_uptime));
+ uptime_secs = uptime_msecs / 1000;
+ uptime_msecs %= 1000;
+ time_to_tm(uptime_secs, 0, &result);
+ res = scnprintf(buf, sizeof(buf),
+ "days - %d\nclock - %d:%d:%d\nmsecs - %lu\n",
+ result.tm_yday, result.tm_hour,
+ result.tm_min, result.tm_sec, uptime_msecs);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(station_uptime);
+
static ssize_t sta_num_ps_buf_frames_read(struct file *file,
char __user *userbuf,
size_t count, loff_t *ppos)
@@ -324,6 +345,7 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
DEBUGFS_ADD(flags);
DEBUGFS_ADD(num_ps_buf_frames);
DEBUGFS_ADD(inactive_ms);
+ DEBUGFS_ADD(station_uptime);
DEBUGFS_ADD(last_seq_ctrl);
DEBUGFS_ADD(agg_status);
DEBUGFS_ADD(dev);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 999f8fb..08b9f51 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -244,6 +244,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
sta->local = local;
sta->sdata = sdata;
sta->last_rx = jiffies;
+ sta->sta_uptime = jiffies;

ewma_init(&sta->avg_signal, 1024, 8);

diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 43238e9..e704270 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -226,6 +226,7 @@ enum plink_state {
* @rx_bytes: Number of bytes received from this STA
* @wep_weak_iv_count: number of weak WEP IVs received from this station
* @last_rx: time (in jiffies) when last frame was received from this STA
+ * @sta_uptime: time (in jiffies) when the station gets associated
* @num_duplicates: number of duplicate frames received from this STA
* @rx_fragments: number of received MPDUs
* @rx_dropped: number of dropped MPDUs from this STA
@@ -295,6 +296,7 @@ struct sta_info {
unsigned long rx_packets, rx_bytes;
unsigned long wep_weak_iv_count;
unsigned long last_rx;
+ unsigned long sta_uptime;
unsigned long num_duplicates;
unsigned long rx_fragments;
unsigned long rx_dropped;
--
1.7.0.4



2011-04-05 15:05:59

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tuesday 05 April 2011 07:34 PM, Helmut Schaa wrote:
> Am Dienstag, 5. April 2011 schrieb Mohammed Shafi Shajakhan:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> Add station uptime parameter in debugfs. This will be helpful to get a
>> measure of stability of connection and also during stress testing.
>>
> It might even make sense to make this available through nl80211. At least
> in AP mode it would be interesting to see how long each STA is already
> connected.
>
did a quick check with only one station connected to AP and this seems
to work fine. Need to test with many other stations connecting at
different time and may be even with ibss.
> Helmut
> .
>
>

2011-04-05 14:08:42

by Felix Fietkau

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On 2011-04-05 3:39 PM, Mohammed Shafi Shajakhan wrote:
> From: Mohammed Shafi Shajakhan<[email protected]>
>
> Add station uptime parameter in debugfs. This will be helpful to get a
> measure of stability of connection and also during stress testing.
>
> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>

> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
> index 999f8fb..08b9f51 100644
> --- a/net/mac80211/sta_info.c
> +++ b/net/mac80211/sta_info.c
> @@ -244,6 +244,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
> sta->local = local;
> sta->sdata = sdata;
> sta->last_rx = jiffies;
> + sta->sta_uptime = jiffies;
>
> ewma_init(&sta->avg_signal, 1024, 8);
>
I think jiffies can easily overflow. Maybe it would be better to get a
timeval from the monotonic clock.

- Felix

2011-04-05 15:04:31

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tuesday 05 April 2011 07:38 PM, Felix Fietkau wrote:
> On 2011-04-05 3:39 PM, Mohammed Shafi Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> Add station uptime parameter in debugfs. This will be helpful to get a
>> measure of stability of connection and also during stress testing.
>>
>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>>
>
>> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
>> index 999f8fb..08b9f51 100644
>> --- a/net/mac80211/sta_info.c
>> +++ b/net/mac80211/sta_info.c
>> @@ -244,6 +244,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
>> sta->local = local;
>> sta->sdata = sdata;
>> sta->last_rx = jiffies;
>> + sta->sta_uptime = jiffies;
>>
>> ewma_init(&sta->avg_signal, 1024, 8);
>>
>>
> I think jiffies can easily overflow. Maybe it would be better to get a
> timeval from the monotonic clock.
>
Thanks, yes thats true and I assumed this will work fine for 49 days
assuming 32 bit(please correct me if my calculations are wrong). will
the overflow will take place in less than this time?. I will dig more
into it by looking at the time val.
> - Felix
> .
>
>

2011-04-05 14:59:36

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tuesday 05 April 2011 08:20 PM, Johannes Berg wrote:
> On Tue, 2011-04-05 at 20:06 +0530, Mohammed Shafi wrote:
>
>> On Tuesday 05 April 2011 07:34 PM, Helmut Schaa wrote:
>>
>>> Am Dienstag, 5. April 2011 schrieb Mohammed Shafi Shajakhan:
>>>
>>>
>>>> From: Mohammed Shafi Shajakhan<[email protected]>
>>>>
>>>> Add station uptime parameter in debugfs. This will be helpful to get a
>>>> measure of stability of connection and also during stress testing.
>>>>
>>>>
>>> It might even make sense to make this available through nl80211. At least
>>> in AP mode it would be interesting to see how long each STA is already
>>> connected.
>>>
>>> Helmut
>>>
>>>
>> Thanks, will do it once the maintainers are ok with this patch.
>>
> Fine with me, but you should probably not call it "uptime" but rather
> "connected_time" or something, and address Felix's point.
>
Thanks for the review, I will look to address both the things.
thanks,
shafi
> johannes
>
>

2011-04-05 15:25:32

by Felix Fietkau

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On 2011-04-05 5:04 PM, Mohammed Shafi wrote:
> On Tuesday 05 April 2011 07:38 PM, Felix Fietkau wrote:
>> On 2011-04-05 3:39 PM, Mohammed Shafi Shajakhan wrote:
>>
>>> From: Mohammed Shafi Shajakhan<[email protected]>
>>>
>>> Add station uptime parameter in debugfs. This will be helpful to get a
>>> measure of stability of connection and also during stress testing.
>>>
>>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>>>
>>
>>> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
>>> index 999f8fb..08b9f51 100644
>>> --- a/net/mac80211/sta_info.c
>>> +++ b/net/mac80211/sta_info.c
>>> @@ -244,6 +244,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
>>> sta->local = local;
>>> sta->sdata = sdata;
>>> sta->last_rx = jiffies;
>>> + sta->sta_uptime = jiffies;
>>>
>>> ewma_init(&sta->avg_signal, 1024, 8);
>>>
>>>
>> I think jiffies can easily overflow. Maybe it would be better to get a
>> timeval from the monotonic clock.
>>
> Thanks, yes thats true and I assumed this will work fine for 49 days
> assuming 32 bit(please correct me if my calculations are wrong). will
> the overflow will take place in less than this time?.
Yes, but there are people that deploy point to point links that can last
longer than that ;)

> I will dig more into it by looking at the time val.
Thanks.

- Felix

2011-04-05 14:36:26

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tuesday 05 April 2011 07:34 PM, Helmut Schaa wrote:
> Am Dienstag, 5. April 2011 schrieb Mohammed Shafi Shajakhan:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> Add station uptime parameter in debugfs. This will be helpful to get a
>> measure of stability of connection and also during stress testing.
>>
> It might even make sense to make this available through nl80211. At least
> in AP mode it would be interesting to see how long each STA is already
> connected.
>
> Helmut
>
Thanks, will do it once the maintainers are ok with this patch.
> .
>
>

2011-04-05 15:29:21

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tuesday 05 April 2011 08:55 PM, Felix Fietkau wrote:
> On 2011-04-05 5:04 PM, Mohammed Shafi wrote:
>
>> On Tuesday 05 April 2011 07:38 PM, Felix Fietkau wrote:
>>
>>> On 2011-04-05 3:39 PM, Mohammed Shafi Shajakhan wrote:
>>>
>>>
>>>> From: Mohammed Shafi Shajakhan<[email protected]>
>>>>
>>>> Add station uptime parameter in debugfs. This will be helpful to get a
>>>> measure of stability of connection and also during stress testing.
>>>>
>>>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>>>>
>>>>
>>>
>>>> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
>>>> index 999f8fb..08b9f51 100644
>>>> --- a/net/mac80211/sta_info.c
>>>> +++ b/net/mac80211/sta_info.c
>>>> @@ -244,6 +244,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
>>>> sta->local = local;
>>>> sta->sdata = sdata;
>>>> sta->last_rx = jiffies;
>>>> + sta->sta_uptime = jiffies;
>>>>
>>>> ewma_init(&sta->avg_signal, 1024, 8);
>>>>
>>>>
>>>>
>>> I think jiffies can easily overflow. Maybe it would be better to get a
>>> timeval from the monotonic clock.
>>>
>>>
>> Thanks, yes thats true and I assumed this will work fine for 49 days
>> assuming 32 bit(please correct me if my calculations are wrong). will
>> the overflow will take place in less than this time?.
>>
> Yes, but there are people that deploy point to point links that can last
> longer than that ;)
>
Oh ok, then I will look into it. Thanks for the review!
>
>> I will dig more into it by looking at the time val.
>>
> Thanks.
>
> - Felix
> .
>
>

2011-04-05 14:06:07

by Helmut Schaa

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

Am Dienstag, 5. April 2011 schrieb Mohammed Shafi Shajakhan:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> Add station uptime parameter in debugfs. This will be helpful to get a
> measure of stability of connection and also during stress testing.

It might even make sense to make this available through nl80211. At least
in AP mode it would be interesting to see how long each STA is already
connected.

Helmut

2011-04-05 14:50:48

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC] mac80211: Add station uptime in debugfs

On Tue, 2011-04-05 at 20:06 +0530, Mohammed Shafi wrote:
> On Tuesday 05 April 2011 07:34 PM, Helmut Schaa wrote:
> > Am Dienstag, 5. April 2011 schrieb Mohammed Shafi Shajakhan:
> >
> >> From: Mohammed Shafi Shajakhan<[email protected]>
> >>
> >> Add station uptime parameter in debugfs. This will be helpful to get a
> >> measure of stability of connection and also during stress testing.
> >>
> > It might even make sense to make this available through nl80211. At least
> > in AP mode it would be interesting to see how long each STA is already
> > connected.
> >
> > Helmut
> >
> Thanks, will do it once the maintainers are ok with this patch.

Fine with me, but you should probably not call it "uptime" but rather
"connected_time" or something, and address Felix's point.

johannes