All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Try 2: Add wireless statistics to d80211
@ 2006-08-24  3:02 Larry Finger
  2006-08-24 11:59 ` Jiri Benc
  2006-08-24 17:45 ` Simon Barber
  0 siblings, 2 replies; 7+ messages in thread
From: Larry Finger @ 2006-08-24  3:02 UTC (permalink / raw)
  To: Jiri Benc; +Cc: John Linville, netdev

This patch modifies d80211 to add wireless statistics.

Signed-Off-By: Larry Finger@lwfinger.net>

======================================
diff --git a/include/net/d80211.h b/include/net/d80211.h
index 42fdbf7..70655dc 100644
--- a/include/net/d80211.h
+++ b/include/net/d80211.h
@@ -205,6 +205,8 @@ struct ieee80211_rx_status {
          int channel;
          int phymode;
          int ssi;
+	int signal;
+	int noise;
          int antenna;
          int rate;
          int flag;
@@ -499,6 +501,9 @@ struct ieee80211_hw {
          /* This is the time in us to change channels
           */
          int channel_change_time;
+	/* This is maximum value of rssi reported by this interface
+	 */
+	int maxssi;

  	int num_modes;
  	struct ieee80211_hw_modes *modes;
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index e72721f..2549484 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -3175,6 +3175,8 @@ ieee80211_rx_h_sta_process(struct ieee80
  	sta->rx_fragments++;
  	sta->rx_bytes += rx->skb->len;
  	sta->last_rssi = rx->u.rx.status->ssi;
+	sta->last_signal = rx->u.rx.status->signal;
+	sta->last_noise = rx->u.rx.status->noise;

  	if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
  		/* Change STA power saving mode only in the end of a frame
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 0d2d79d..1271513 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -336,6 +336,7 @@ struct ieee80211_local {
  	struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
  	int open_count;
  	int monitors;
+	struct iw_statistics wstats;
  	struct ieee80211_conf conf;

  	int dev_index;
diff --git a/net/d80211/ieee80211_ioctl.c b/net/d80211/ieee80211_ioctl.c
index 89a58e3..b121302 100644
--- a/net/d80211/ieee80211_ioctl.c
+++ b/net/d80211/ieee80211_ioctl.c
@@ -1581,6 +1581,16 @@ static int ieee80211_ioctl_giwrange(stru
  	range->min_frag = 256;
  	range->max_frag = 2346;

+	range->max_qual.qual = 100;
+	range->max_qual.level = 146;  /* set floor at -110 dBm (146 - 256) */
+	range->max_qual.noise = 146;
+	range->max_qual.updated = IW_QUAL_ALL_UPDATED;
+
+	range->avg_qual.qual = 50;
+	range->avg_qual.level = 0;
+	range->avg_qual.noise = 0;
+	range->avg_qual.updated = IW_QUAL_ALL_UPDATED;
+
  	return 0;
  }

@@ -2996,6 +3006,39 @@ static int ieee80211_ioctl_siwauth(struc
  	return ret;
  }

+/* Get wireless statistics.  Called by /proc/net/wireless and by SIOCGIWSTATS */
+static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *net_dev)
+{
+	struct ieee80211_local *local = net_dev->ieee80211_ptr;
+	struct iw_statistics * wstats = &local->wstats;
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(net_dev);
+	struct sta_info *sta;
+	static int tmp_level = 0;
+	static int tmp_qual = 0;
+
+	sta = sta_info_get(local, sdata->u.sta.bssid);
+	if (!sta) {
+		wstats->discard.fragment = 0;
+		wstats->discard.misc = 0;
+		wstats->qual.qual = 0;
+		wstats->qual.level = 0;
+		wstats->qual.noise = 0;
+		wstats->qual.updated = IW_QUAL_ALL_INVALID;
+	} else {
+		if (!tmp_level) {       /* get initial values */
+			tmp_level = sta->last_signal;
+			tmp_qual = sta->last_rssi;
+		} else {                        /* smooth results */
+			tmp_level = (15 * tmp_level + sta->last_signal)/16;
+			tmp_qual = (15 * tmp_qual + sta->last_rssi)/16;
+		}
+		wstats->qual.level = tmp_level;
+		wstats->qual.qual = 100*tmp_qual/local->hw->maxssi;
+		wstats->qual.noise = sta->last_noise;
+		wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
+	}
+	return wstats;
+}

  static int ieee80211_ioctl_giwauth(struct net_device *dev,
  				   struct iw_request_info *info,
@@ -3019,7 +3062,6 @@ static int ieee80211_ioctl_giwauth(struc
  	return ret;
  }

-
  static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
  					struct iw_request_info *info,
  					struct iw_point *erq, char *extra)
@@ -3184,6 +3226,7 @@ const struct iw_handler_def ieee80211_iw
  	.standard	= (iw_handler *) ieee80211_handler,
  	.private	= (iw_handler *) ieee80211_private_handler,
  	.private_args	= (struct iw_priv_args *) ieee80211_ioctl_priv,
+	.get_wireless_stats = ieee80211_get_wireless_stats,
  };

  /* Wireless handlers for master interface */
diff --git a/net/d80211/ieee80211_sysfs_sta.c b/net/d80211/ieee80211_sysfs_sta.c
index 94c6dd8..dd92b02 100644
--- a/net/d80211/ieee80211_sysfs_sta.c
+++ b/net/d80211/ieee80211_sysfs_sta.c
@@ -72,6 +72,8 @@ STA_ATTR(last_txrate, last_txrate, RATE)
  STA_ATTR(tx_retry_failed, tx_retry_failed, LU);
  STA_ATTR(tx_retry_count, tx_retry_count, LU);
  STA_ATTR(last_rssi, last_rssi, D);
+STA_ATTR(last_signal, last_signal, D);
+STA_ATTR(last_noise, last_noise, D);
  STA_ATTR(channel_use, channel_use, D);
  STA_ATTR(wep_weak_iv_count, wep_weak_iv_count, D);
@@ -175,6 +177,8 @@ static struct attribute *sta_ktype_attrs
  	&sta_attr_tx_retry_failed.attr,
  	&sta_attr_tx_retry_count.attr,
  	&sta_attr_last_rssi.attr,
+	&sta_attr_last_signal.attr,
+	&sta_attr_last_noise.attr,
  	&sta_attr_channel_use.attr,
  	&sta_attr_wep_weak_iv_count.attr,

diff --git a/net/d80211/sta_info.h b/net/d80211/sta_info.h
index 8d23047..100d039 100644
--- a/net/d80211/sta_info.h
+++ b/net/d80211/sta_info.h
@@ -82,6 +82,8 @@ struct sta_info {
  	unsigned long rx_dropped; /* number of dropped MPDUs from this STA */

  	int last_rssi; /* RSSI of last received frame from this STA */
+	int last_signal; /* signal of last received frame from this STA */
+	int last_noise; /* noise of last received frame from this STA */
  	int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
  	unsigned long last_ack;
          int channel_use;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] Try 2: Add wireless statistics to d80211
  2006-08-24  3:02 [PATCH 1/4] Try 2: Add wireless statistics to d80211 Larry Finger
@ 2006-08-24 11:59 ` Jiri Benc
  2006-08-24 14:39   ` Larry Finger
  2006-08-24 17:45 ` Simon Barber
  1 sibling, 1 reply; 7+ messages in thread
From: Jiri Benc @ 2006-08-24 11:59 UTC (permalink / raw)
  To: Larry Finger; +Cc: John Linville, netdev

On Wed, 23 Aug 2006 22:02:03 -0500, Larry Finger wrote:
> This patch modifies d80211 to add wireless statistics.
> 
> Signed-Off-By: Larry Finger@lwfinger.net>

Please fix the Signed-off-by line.

> 
> ======================================
> diff --git a/include/net/d80211.h b/include/net/d80211.h
> index 42fdbf7..70655dc 100644
> --- a/include/net/d80211.h
> +++ b/include/net/d80211.h
> @@ -205,6 +205,8 @@ struct ieee80211_rx_status {
>           int channel;
>           int phymode;
>           int ssi;
> +	int signal;
> +	int noise;
>           int antenna;
>           int rate;
>           int flag;
> @@ -499,6 +501,9 @@ struct ieee80211_hw {
>           /* This is the time in us to change channels
>            */
>           int channel_change_time;
> +	/* This is maximum value of rssi reported by this interface
> +	 */
> +	int maxssi;

Device, not interface. And please do not put */ to a new line.

> [...]
> --- a/net/d80211/ieee80211_ioctl.c
> +++ b/net/d80211/ieee80211_ioctl.c
> [...]
> @@ -3019,7 +3062,6 @@ static int ieee80211_ioctl_giwauth(struc
>   	return ret;
>   }
> 
> -
>   static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
>   					struct iw_request_info *info,
>   					struct iw_point *erq, char *extra)

Please do not touch parts outside of the code you are
fixing/improving/etc. We'll need a code style patch later, but not now -
there are still too many patches floating around and I don't want to
break them more than is necessary.

Other then that, it looks good.

Thanks,

 Jiri

-- 
Jiri Benc
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] Try 2: Add wireless statistics to d80211
  2006-08-24 11:59 ` Jiri Benc
@ 2006-08-24 14:39   ` Larry Finger
  2006-08-24 15:03     ` Jiri Benc
  0 siblings, 1 reply; 7+ messages in thread
From: Larry Finger @ 2006-08-24 14:39 UTC (permalink / raw)
  To: Jiri Benc; +Cc: John Linville, netdev

Jiri Benc wrote:
> On Wed, 23 Aug 2006 22:02:03 -0500, Larry Finger wrote:
>> This patch modifies d80211 to add wireless statistics.
>> +	/* This is maximum value of rssi reported by this interface
>> +	 */
>> +	int maxssi;
> 
> Device, not interface. And please do not put */ to a new line.

Noted on the first part, but I would like a clarification regarding style. I put the */ on the 
second line to match the rest of that section. Should a patch try to keep the local style in that 
part of the code, or change it to a some other standard?

Larry


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] Try 2: Add wireless statistics to d80211
  2006-08-24 14:39   ` Larry Finger
@ 2006-08-24 15:03     ` Jiri Benc
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Benc @ 2006-08-24 15:03 UTC (permalink / raw)
  To: Larry Finger; +Cc: John Linville, netdev

On Thu, 24 Aug 2006 09:39:52 -0500, Larry Finger wrote:
> Noted on the first part, but I would like a clarification regarding style. I put the */ on the 
> second line to match the rest of that section. Should a patch try to keep the local style in that 
> part of the code, or change it to a some other standard?

Patches should convert the code they are touching to coding style common
in the kernel. This way we will gradually convert at least part of
d80211 to the kernel coding style; the rest will be addressed by one big
patch just before merging into the vanilla (or -mm).

Thanks,

 Jiri

-- 
Jiri Benc
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 1/4] Try 2: Add wireless statistics to d80211
  2006-08-24  3:02 [PATCH 1/4] Try 2: Add wireless statistics to d80211 Larry Finger
  2006-08-24 11:59 ` Jiri Benc
@ 2006-08-24 17:45 ` Simon Barber
  2006-08-24 18:17   ` Larry Finger
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Barber @ 2006-08-24 17:45 UTC (permalink / raw)
  To: Larry Finger, Jiri Benc; +Cc: John Linville, netdev

Why have both signal and rssi measures?

Simon 

-----Original Message-----
From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
On Behalf Of Larry Finger
Sent: Wednesday, August 23, 2006 8:02 PM
To: Jiri Benc
Cc: John Linville; netdev@vger.kernel.org
Subject: [PATCH 1/4] Try 2: Add wireless statistics to d80211

This patch modifies d80211 to add wireless statistics.

Signed-Off-By: Larry Finger@lwfinger.net>

======================================
diff --git a/include/net/d80211.h b/include/net/d80211.h index
42fdbf7..70655dc 100644
--- a/include/net/d80211.h
+++ b/include/net/d80211.h
@@ -205,6 +205,8 @@ struct ieee80211_rx_status {
          int channel;
          int phymode;
          int ssi;
+	int signal;
+	int noise;
          int antenna;
          int rate;
          int flag;
@@ -499,6 +501,9 @@ struct ieee80211_hw {
          /* This is the time in us to change channels
           */
          int channel_change_time;
+	/* This is maximum value of rssi reported by this interface
+	 */
+	int maxssi;

  	int num_modes;
  	struct ieee80211_hw_modes *modes;
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c index
e72721f..2549484 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -3175,6 +3175,8 @@ ieee80211_rx_h_sta_process(struct ieee80
  	sta->rx_fragments++;
  	sta->rx_bytes += rx->skb->len;
  	sta->last_rssi = rx->u.rx.status->ssi;
+	sta->last_signal = rx->u.rx.status->signal;
+	sta->last_noise = rx->u.rx.status->noise;

  	if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
  		/* Change STA power saving mode only in the end of a
frame diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 0d2d79d..1271513 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -336,6 +336,7 @@ struct ieee80211_local {
  	struct net_device *apdev; /* wlan#ap - management frames
(hostapd) */
  	int open_count;
  	int monitors;
+	struct iw_statistics wstats;
  	struct ieee80211_conf conf;

  	int dev_index;
diff --git a/net/d80211/ieee80211_ioctl.c b/net/d80211/ieee80211_ioctl.c
index 89a58e3..b121302 100644
--- a/net/d80211/ieee80211_ioctl.c
+++ b/net/d80211/ieee80211_ioctl.c
@@ -1581,6 +1581,16 @@ static int ieee80211_ioctl_giwrange(stru
  	range->min_frag = 256;
  	range->max_frag = 2346;

+	range->max_qual.qual = 100;
+	range->max_qual.level = 146;  /* set floor at -110 dBm (146 -
256) */
+	range->max_qual.noise = 146;
+	range->max_qual.updated = IW_QUAL_ALL_UPDATED;
+
+	range->avg_qual.qual = 50;
+	range->avg_qual.level = 0;
+	range->avg_qual.noise = 0;
+	range->avg_qual.updated = IW_QUAL_ALL_UPDATED;
+
  	return 0;
  }

@@ -2996,6 +3006,39 @@ static int ieee80211_ioctl_siwauth(struc
  	return ret;
  }

+/* Get wireless statistics.  Called by /proc/net/wireless and by 
+SIOCGIWSTATS */ static struct iw_statistics 
+*ieee80211_get_wireless_stats(struct net_device *net_dev) {
+	struct ieee80211_local *local = net_dev->ieee80211_ptr;
+	struct iw_statistics * wstats = &local->wstats;
+	struct ieee80211_sub_if_data *sdata =
IEEE80211_DEV_TO_SUB_IF(net_dev);
+	struct sta_info *sta;
+	static int tmp_level = 0;
+	static int tmp_qual = 0;
+
+	sta = sta_info_get(local, sdata->u.sta.bssid);
+	if (!sta) {
+		wstats->discard.fragment = 0;
+		wstats->discard.misc = 0;
+		wstats->qual.qual = 0;
+		wstats->qual.level = 0;
+		wstats->qual.noise = 0;
+		wstats->qual.updated = IW_QUAL_ALL_INVALID;
+	} else {
+		if (!tmp_level) {       /* get initial values */
+			tmp_level = sta->last_signal;
+			tmp_qual = sta->last_rssi;
+		} else {                        /* smooth results */
+			tmp_level = (15 * tmp_level +
sta->last_signal)/16;
+			tmp_qual = (15 * tmp_qual + sta->last_rssi)/16;
+		}
+		wstats->qual.level = tmp_level;
+		wstats->qual.qual = 100*tmp_qual/local->hw->maxssi;
+		wstats->qual.noise = sta->last_noise;
+		wstats->qual.updated = IW_QUAL_ALL_UPDATED |
IW_QUAL_DBM;
+	}
+	return wstats;
+}

  static int ieee80211_ioctl_giwauth(struct net_device *dev,
  				   struct iw_request_info *info,
@@ -3019,7 +3062,6 @@ static int ieee80211_ioctl_giwauth(struc
  	return ret;
  }

-
  static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
  					struct iw_request_info *info,
  					struct iw_point *erq, char
*extra) @@ -3184,6 +3226,7 @@ const struct iw_handler_def ieee80211_iw
  	.standard	= (iw_handler *) ieee80211_handler,
  	.private	= (iw_handler *) ieee80211_private_handler,
  	.private_args	= (struct iw_priv_args *) ieee80211_ioctl_priv,
+	.get_wireless_stats = ieee80211_get_wireless_stats,
  };

  /* Wireless handlers for master interface */ diff --git
a/net/d80211/ieee80211_sysfs_sta.c b/net/d80211/ieee80211_sysfs_sta.c
index 94c6dd8..dd92b02 100644
--- a/net/d80211/ieee80211_sysfs_sta.c
+++ b/net/d80211/ieee80211_sysfs_sta.c
@@ -72,6 +72,8 @@ STA_ATTR(last_txrate, last_txrate, RATE)
  STA_ATTR(tx_retry_failed, tx_retry_failed, LU);
  STA_ATTR(tx_retry_count, tx_retry_count, LU);
  STA_ATTR(last_rssi, last_rssi, D);
+STA_ATTR(last_signal, last_signal, D);
+STA_ATTR(last_noise, last_noise, D);
  STA_ATTR(channel_use, channel_use, D);
  STA_ATTR(wep_weak_iv_count, wep_weak_iv_count, D); @@ -175,6 +177,8 @@
static struct attribute *sta_ktype_attrs
  	&sta_attr_tx_retry_failed.attr,
  	&sta_attr_tx_retry_count.attr,
  	&sta_attr_last_rssi.attr,
+	&sta_attr_last_signal.attr,
+	&sta_attr_last_noise.attr,
  	&sta_attr_channel_use.attr,
  	&sta_attr_wep_weak_iv_count.attr,

diff --git a/net/d80211/sta_info.h b/net/d80211/sta_info.h index
8d23047..100d039 100644
--- a/net/d80211/sta_info.h
+++ b/net/d80211/sta_info.h
@@ -82,6 +82,8 @@ struct sta_info {
  	unsigned long rx_dropped; /* number of dropped MPDUs from this
STA */

  	int last_rssi; /* RSSI of last received frame from this STA */
+	int last_signal; /* signal of last received frame from this STA
*/
+	int last_noise; /* noise of last received frame from this STA */
  	int last_ack_rssi[3]; /* RSSI of last received ACKs from this
STA */
  	unsigned long last_ack;
          int channel_use;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in the
body of a message to majordomo@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] Try 2: Add wireless statistics to d80211
  2006-08-24 17:45 ` Simon Barber
@ 2006-08-24 18:17   ` Larry Finger
  0 siblings, 0 replies; 7+ messages in thread
From: Larry Finger @ 2006-08-24 18:17 UTC (permalink / raw)
  To: Simon Barber; +Cc: Jiri Benc, John Linville, netdev

Simon Barber wrote:
> Why have both signal and rssi measures?

In the bcm43xx driver, the values are different. There is a routine that converts from rssi as a 
positive number into signal in a negative number that looks like dBm. Because of the reverse 
engineering, we have no idea what the logic behind this is, but I thought that we should keep it.

Larry


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] Try 2: Add wireless statistics to d80211
@ 2006-08-24 14:28 Larry Finger
  0 siblings, 0 replies; 7+ messages in thread
From: Larry Finger @ 2006-08-24 14:28 UTC (permalink / raw)
  To: Jiri Benc; +Cc: John Linville, netdev

This patch modifies d80211 to add wireless statistics.

Signed-Off-By: Larry Finger <Larry.Finger@lwfinger.net>

======================================
diff --git a/include/net/d80211.h b/include/net/d80211.h
index 42fdbf7..70655dc 100644
--- a/include/net/d80211.h
+++ b/include/net/d80211.h
@@ -205,6 +205,8 @@ struct ieee80211_rx_status {
          int channel;
          int phymode;
          int ssi;
+	int signal;
+	int noise;
          int antenna;
          int rate;
          int flag;
@@ -499,6 +501,9 @@ struct ieee80211_hw {
          /* This is the time in us to change channels
           */
          int channel_change_time;
+	/* This is maximum value of rssi reported by this interface
+	 */
+	int maxssi;

  	int num_modes;
  	struct ieee80211_hw_modes *modes;
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index e72721f..2549484 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -3175,6 +3175,8 @@ ieee80211_rx_h_sta_process(struct ieee80
  	sta->rx_fragments++;
  	sta->rx_bytes += rx->skb->len;
  	sta->last_rssi = rx->u.rx.status->ssi;
+	sta->last_signal = rx->u.rx.status->signal;
+	sta->last_noise = rx->u.rx.status->noise;

  	if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
  		/* Change STA power saving mode only in the end of a frame
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 0d2d79d..1271513 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -336,6 +336,7 @@ struct ieee80211_local {
  	struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
  	int open_count;
  	int monitors;
+	struct iw_statistics wstats;
  	struct ieee80211_conf conf;

  	int dev_index;
diff --git a/net/d80211/ieee80211_ioctl.c b/net/d80211/ieee80211_ioctl.c
index 89a58e3..b121302 100644
--- a/net/d80211/ieee80211_ioctl.c
+++ b/net/d80211/ieee80211_ioctl.c
@@ -1581,6 +1581,16 @@ static int ieee80211_ioctl_giwrange(stru
  	range->min_frag = 256;
  	range->max_frag = 2346;

+	range->max_qual.qual = 100;
+	range->max_qual.level = 146;  /* set floor at -110 dBm (146 - 256) */
+	range->max_qual.noise = 146;
+	range->max_qual.updated = IW_QUAL_ALL_UPDATED;
+
+	range->avg_qual.qual = 50;
+	range->avg_qual.level = 0;
+	range->avg_qual.noise = 0;
+	range->avg_qual.updated = IW_QUAL_ALL_UPDATED;
+
  	return 0;
  }

@@ -2996,6 +3006,39 @@ static int ieee80211_ioctl_siwauth(struc
  	return ret;
  }

+/* Get wireless statistics.  Called by /proc/net/wireless and by SIOCGIWSTATS */
+static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *net_dev)
+{
+	struct ieee80211_local *local = net_dev->ieee80211_ptr;
+	struct iw_statistics * wstats = &local->wstats;
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(net_dev);
+	struct sta_info *sta;
+	static int tmp_level = 0;
+	static int tmp_qual = 0;
+
+	sta = sta_info_get(local, sdata->u.sta.bssid);
+	if (!sta) {
+		wstats->discard.fragment = 0;
+		wstats->discard.misc = 0;
+		wstats->qual.qual = 0;
+		wstats->qual.level = 0;
+		wstats->qual.noise = 0;
+		wstats->qual.updated = IW_QUAL_ALL_INVALID;
+	} else {
+		if (!tmp_level) {       /* get initial values */
+			tmp_level = sta->last_signal;
+			tmp_qual = sta->last_rssi;
+		} else {                        /* smooth results */
+			tmp_level = (15 * tmp_level + sta->last_signal)/16;
+			tmp_qual = (15 * tmp_qual + sta->last_rssi)/16;
+		}
+		wstats->qual.level = tmp_level;
+		wstats->qual.qual = 100*tmp_qual/local->hw->maxssi;
+		wstats->qual.noise = sta->last_noise;
+		wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
+	}
+	return wstats;
+}

  static int ieee80211_ioctl_giwauth(struct net_device *dev,
  				   struct iw_request_info *info,
@@ -3019,7 +3062,6 @@ static int ieee80211_ioctl_giwauth(struc
  	return ret;
  }

-
  static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
  					struct iw_request_info *info,
  					struct iw_point *erq, char *extra)
@@ -3184,6 +3226,7 @@ const struct iw_handler_def ieee80211_iw
  	.standard	= (iw_handler *) ieee80211_handler,
  	.private	= (iw_handler *) ieee80211_private_handler,
  	.private_args	= (struct iw_priv_args *) ieee80211_ioctl_priv,
+	.get_wireless_stats = ieee80211_get_wireless_stats,
  };

  /* Wireless handlers for master interface */
diff --git a/net/d80211/ieee80211_sysfs_sta.c b/net/d80211/ieee80211_sysfs_sta.c
index 94c6dd8..dd92b02 100644
--- a/net/d80211/ieee80211_sysfs_sta.c
+++ b/net/d80211/ieee80211_sysfs_sta.c
@@ -72,6 +72,8 @@ STA_ATTR(last_txrate, last_txrate, RATE)
  STA_ATTR(tx_retry_failed, tx_retry_failed, LU);
  STA_ATTR(tx_retry_count, tx_retry_count, LU);
  STA_ATTR(last_rssi, last_rssi, D);
+STA_ATTR(last_signal, last_signal, D);
+STA_ATTR(last_noise, last_noise, D);
  STA_ATTR(channel_use, channel_use, D);
  STA_ATTR(wep_weak_iv_count, wep_weak_iv_count, D);
@@ -175,6 +177,8 @@ static struct attribute *sta_ktype_attrs
  	&sta_attr_tx_retry_failed.attr,
  	&sta_attr_tx_retry_count.attr,
  	&sta_attr_last_rssi.attr,
+	&sta_attr_last_signal.attr,
+	&sta_attr_last_noise.attr,
  	&sta_attr_channel_use.attr,
  	&sta_attr_wep_weak_iv_count.attr,

diff --git a/net/d80211/sta_info.h b/net/d80211/sta_info.h
index 8d23047..100d039 100644
--- a/net/d80211/sta_info.h
+++ b/net/d80211/sta_info.h
@@ -82,6 +82,8 @@ struct sta_info {
  	unsigned long rx_dropped; /* number of dropped MPDUs from this STA */

  	int last_rssi; /* RSSI of last received frame from this STA */
+	int last_signal; /* signal of last received frame from this STA */
+	int last_noise; /* noise of last received frame from this STA */
  	int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
  	unsigned long last_ack;
          int channel_use;


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-08-24 18:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-24  3:02 [PATCH 1/4] Try 2: Add wireless statistics to d80211 Larry Finger
2006-08-24 11:59 ` Jiri Benc
2006-08-24 14:39   ` Larry Finger
2006-08-24 15:03     ` Jiri Benc
2006-08-24 17:45 ` Simon Barber
2006-08-24 18:17   ` Larry Finger
2006-08-24 14:28 Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.