Subject: [PATCH v3] cfg80211/nl80211: Add support for NL80211_STA_INFO_RX_DURATION

From: Mohammed Shafi Shajakhan <[email protected]>

Add support for new netlink attribute 'NL80211_STA_INFO_RX_DURATION'
This flag will be set when drivers can fill rx_duration (aggregate
PPDU duration(usecs) for all the frames from a peer) via
'drv_sta_statistics' callback

Also make sta_info flags 'filled' as 64 bit to accommodate for new
per station stats. Extend 'PUT_SINFO' for supporting rx_duration
field and any new per sta information in future

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
include/net/cfg80211.h | 4 +++-
include/uapi/linux/nl80211.h | 3 +++
net/wireless/nl80211.c | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9bcaaf7..a9552f6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1060,11 +1060,12 @@ struct cfg80211_tid_stats {
* @rx_beacon: number of beacons received from this peer
* @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
* from this peer
+ * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
* @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
* (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
*/
struct station_info {
- u32 filled;
+ u64 filled;
u32 connected_time;
u32 inactive_time;
u64 rx_bytes;
@@ -1103,6 +1104,7 @@ struct station_info {
u32 expected_throughput;

u64 rx_beacon;
+ u64 rx_duration;
u8 rx_beacon_signal_avg;
struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
};
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 5b7b5eb..361b2cd 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2464,6 +2464,8 @@ enum nl80211_sta_bss_param {
* TID+1 and the special TID 16 (i.e. value 17) is used for non-QoS frames;
* each one of those is again nested with &enum nl80211_tid_stats
* attributes carrying the actual values.
+ * @NL80211_STA_INFO_RX_DURATION: aggregate PPDU duration(usecs) for all the
+ * frames from a peer
* @__NL80211_STA_INFO_AFTER_LAST: internal
* @NL80211_STA_INFO_MAX: highest possible station info attribute
*/
@@ -2500,6 +2502,7 @@ enum nl80211_sta_info {
NL80211_STA_INFO_BEACON_RX,
NL80211_STA_INFO_BEACON_SIGNAL_AVG,
NL80211_STA_INFO_TID_STATS,
+ NL80211_STA_INFO_RX_DURATION,

/* keep last */
__NL80211_STA_INFO_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d4786f2..a81c016 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3719,7 +3719,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
goto nla_put_failure;

#define PUT_SINFO(attr, memb, type) do { \
- if (sinfo->filled & BIT(NL80211_STA_INFO_ ## attr) && \
+ if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) && \
nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr, \
sinfo->memb)) \
goto nla_put_failure; \
@@ -3745,6 +3745,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
PUT_SINFO(LLID, llid, u16);
PUT_SINFO(PLID, plid, u16);
PUT_SINFO(PLINK_STATE, plink_state, u8);
+ PUT_SINFO(RX_DURATION, rx_duration, u64);

switch (rdev->wiphy.signal_type) {
case CFG80211_SIGNAL_TYPE_MBM:
--
1.7.9.5



Subject: [PATCH v3] iw: Add support for NL80211_STA_INFO_RX_DURATION netlink attribute

From: Mohammed Shafi Shajakhan <[email protected]>

Enable support for parsing per station rx-duration (usecs)
via adding support for new netlink attribute NL80211_STA_INFO_RX_DURATION

rx_duration is aggregate PPDU duration(usecs) for all the frames
frames from a peer . This will get dumped as part of
'iw dev wlan#N station dump'

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
nl80211.h | 3 +++
station.c | 5 +++++
2 files changed, 8 insertions(+)

diff --git a/nl80211.h b/nl80211.h
index 5b7b5eb..991b3ce 100644
--- a/nl80211.h
+++ b/nl80211.h
@@ -2464,6 +2464,8 @@ enum nl80211_sta_bss_param {
* TID+1 and the special TID 16 (i.e. value 17) is used for non-QoS frames;
* each one of those is again nested with &enum nl80211_tid_stats
* attributes carrying the actual values.
+ * @NL80210_STA_INFO_RX_DURATION: aggregate PPDU duration(usecs) for all the
+ * frames from a peer
* @__NL80211_STA_INFO_AFTER_LAST: internal
* @NL80211_STA_INFO_MAX: highest possible station info attribute
*/
@@ -2500,6 +2502,7 @@ enum nl80211_sta_info {
NL80211_STA_INFO_BEACON_RX,
NL80211_STA_INFO_BEACON_SIGNAL_AVG,
NL80211_STA_INFO_TID_STATS,
+ NL80211_STA_INFO_RX_DURATION,

/* keep last */
__NL80211_STA_INFO_AFTER_LAST,
diff --git a/station.c b/station.c
index b5ccf4a..a730db1 100644
--- a/station.c
+++ b/station.c
@@ -147,6 +147,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
[NL80211_STA_INFO_NONPEER_PM] = { .type = NLA_U32},
[NL80211_STA_INFO_CHAIN_SIGNAL] = { .type = NLA_NESTED },
[NL80211_STA_INFO_CHAIN_SIGNAL_AVG] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_RX_DURATION] = { .type = NLA_U64 },
};
char *chain;

@@ -226,6 +227,10 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
printf("\n\trx bitrate:\t%s", buf);
}

+ if (sinfo[NL80211_STA_INFO_RX_DURATION])
+ printf("\n\trx duration:\t%lld us",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_RX_DURATION]));
+
if (sinfo[NL80211_STA_INFO_EXPECTED_THROUGHPUT]) {
uint32_t thr;

--
1.7.9.5


2016-04-05 12:39:13

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [PATCH v3] cfg80211/nl80211: Add support for NL80211_STA_INFO_RX_DURATION

Hi Johannes,

On Tue, Apr 05, 2016 at 12:04:10PM +0200, Johannes Berg wrote:
> Hi,
>
> The implementation seems fine now, but I think the commit log needs some work.

[shafi] thanks for reviewing.

>
> > Add support for new netlink attribute 'NL80211_STA_INFO_RX_DURATION'
>
> I think it'd be worthwhile to describe the attribute a bit more,
> including why you're adding it.

[shafi] will update in v4

>
> > This flag
>
> There's no flag.

[shafi] i will replace it with the name 'NL80211_STA_INFO_RX_DURATION'

>
> > will be set when drivers can fill rx_duration (aggregate
> > PPDU duration(usecs) for all the frames from a peer)
>
> You have the description here, but putting it with the attribute would
> be better.

[shafi] ok

>
> > via 'drv_sta_statistics' callback
>
> drv_sta_statistics is a mac80211 detail, that's not relevant at
> cfg80211 level; mentioning that is just confusing. This can well used
> by non-mac80211 drivers.

[shafi] agreed, will remove it.

>
> > Also make sta_info flags 'filled' as 64 bit to accommodate for new
> > per station stats.
>
> That sentence doesn't parse well.
>
> > Extend 'PUT_SINFO' for supporting rx_duration
> > field and any new per sta information in future
>
> That sentence I think should just be removed.

[shafi] ok.

-shafi

2016-04-05 10:04:13

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v3] cfg80211/nl80211: Add support for NL80211_STA_INFO_RX_DURATION

Hi,

The implementation seems fine now, but I think the commit log needs some work.

> Add support for new netlink attribute 'NL80211_STA_INFO_RX_DURATION'

I think it'd be worthwhile to describe the attribute a bit more,
including why you're adding it.

> This flag

There's no flag.

> will be set when drivers can fill rx_duration (aggregate
> PPDU duration(usecs) for all the frames from a peer)

You have the description here, but putting it with the attribute would
be better.

> via 'drv_sta_statistics' callback

drv_sta_statistics is a mac80211 detail, that's not relevant at
cfg80211 level; mentioning that is just confusing. This can well used
by non-mac80211 drivers.

> Also make sta_info flags 'filled' as 64 bit to accommodate for new
> per station stats.

That sentence doesn't parse well.

> Extend 'PUT_SINFO' for supporting rx_duration
> field and any new per sta information in future

That sentence I think should just be removed.

johannes