2012-04-13 19:06:48

by Wey-Yi Guy

[permalink] [raw]
Subject: [PATCH 1/1] mac80211: add function retrieve average rssi

From: Wey-Yi Guy <[email protected]>

Add utility function to provide the average rssi per vif

Signed-off-by: Wey-Yi Guy <[email protected]>
---
include/net/mac80211.h | 3 +++
net/mac80211/util.c | 8 ++++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 32cd517..20a2ddd 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3800,4 +3800,7 @@ int ieee80211_add_srates_ie(struct ieee80211_vif *vif,

int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif,
struct sk_buff *skb, bool need_basic);
+
+int ieee80211_ave_rssi(struct ieee80211_vif *vif);
+
#endif /* MAC80211_H */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index e67fe5c..f426fec 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1797,3 +1797,11 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif,
}
return 0;
}
+
+int ieee80211_ave_rssi(struct ieee80211_vif *vif)
+{
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+ struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+
+ return ifmgd->ave_beacon_signal;
+}
--
1.7.0.4



2012-04-18 01:30:50

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/1] mac80211: add function retrieve average rssi

On Fri, 2012-04-13 at 12:02 -0700, [email protected] wrote:
> From: Wey-Yi Guy <[email protected]>
>
> Add utility function to provide the average rssi per vif
>
> Signed-off-by: Wey-Yi Guy <[email protected]>
> ---
> include/net/mac80211.h | 3 +++
> net/mac80211/util.c | 8 ++++++++
> 2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 32cd517..20a2ddd 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -3800,4 +3800,7 @@ int ieee80211_add_srates_ie(struct ieee80211_vif *vif,
>
> int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif,
> struct sk_buff *skb, bool need_basic);
> +
> +int ieee80211_ave_rssi(struct ieee80211_vif *vif);

There should be some documentation here I think, especially about the
point below:

> +int ieee80211_ave_rssi(struct ieee80211_vif *vif)
> +{
> + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
> + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
> +
> + return ifmgd->ave_beacon_signal;
> +}

This will not return anything useful if the hardware implements beacon
filtering, so it should warn in that case I think. Also in the case
you're calling it on non-managed interface types.

johannes