Skip to contentSkip to conversation

wext: Add noise, flags, and rate to /proc/net/wireless

PATCH New Ben Greear 1 participant 1 message Oct 8, 2010

Subsystems (2)
lore
Share & tools
lore

Ben Greear

author
#0 lore raw

PATCH 1/3 wext: Add noise, flags, and rate to /proc/net/wireless

This seems unlikely to ever go upstream. The noise probing code may not work for all drivers, the flags are a copy of internal data, and rate is a new field in /proc/net/wireless which might confuse something.

---
:100644 100644 4395b28... e538c2d... M include/linux/wireless.h
:100644 100644 6187c2e... 6e48883... M include/net/cfg80211.h
:100644 100644 18bd0e5... 1c01f8f... M net/mac80211/cfg.c
:100644 100644 12222ee... b78ddfc... M net/wireless/wext-compat.c
:100644 100644 8bafa31... 9ccc338... M net/wireless/wext-proc.c

 include/linux/wireless.h   |    5 +++--
 include/net/cfg80211.h     |    7 ++++++-
 net/mac80211/cfg.c         |    8 ++++++++
 net/wireless/wext-compat.c |    3 +++
 net/wireless/wext-proc.c   |    8 +++++---
 5 files changed, 25 insertions(+), 6 deletions(-)
include/linux/wireless.h +3 -2
index 4395b28..e538c2d 100644
@@ -898,8 +898,9 @@ struct	iw_pmkid_cand
  */
 struct	iw_statistics
 {
-	__u16		status;		/* Status
-					 * - device dependent for now */
+	__u16		status;		/* Status: ieee80211_sta_info_flags
+					 *   plus: (1<<15):  Scanning */
+	__u16		txrate;		/* Current rate, in 100Kbps units. */
 
 	struct iw_quality	qual;		/* Quality of the link
 						 * (instant/mean/max) */
include/net/cfg80211.h +6 -1
index 6187c2e..6e48883 100644
@@ -485,6 +485,8 @@ struct rate_info {
  * @plid: mesh peer link id
  * @plink_state: mesh peer link state
  * @signal: signal strength of last received packet in dBm
+ * @status: ieee80211_sta_info_flags plus:  (1<<15) Scanning.
+ * @noise: noise, as obtained from dump_survey of index 0.
  * @txrate: current unicast bitrate to this station
  * @rx_packets: packets received from this station
  * @tx_packets: packets transmitted to this station
@@ -505,7 +507,10 @@ struct station_info {
 	u16 plid;
 	u8 plink_state;
 	s8 signal;
-	struct rate_info txrate;
+	u16 status;
+	u8 noise;
+	/* 3 byte hole */
+struct rate_info txrate;
 	u32 rx_packets;
 	u32 tx_packets;
 	u32 tx_retries;
net/mac80211/cfg.c +8 -0
index 18bd0e5..1c01f8f 100644
@@ -319,6 +319,7 @@ static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 {
 	struct ieee80211_sub_if_data *sdata = sta->sdata;
+	struct survey_info survey;
 
 	sinfo->generation = sdata->local->sta_generation;
 
@@ -375,6 +376,13 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 		sinfo->plink_state = sta->plink_state;
 #endif
 	}
+
+	sinfo->status = sta->flags;
+	if (sdata->local->scanning)
+		sinfo->status |= (1<<15);
+
+	if (drv_get_survey(sdata->local, 0, &survey) == 0)
+		sinfo->noise = survey.noise;
 }
 
 
net/wireless/wext-compat.c +3 -0
index 12222ee..b78ddfc 100644
@@ -1370,6 +1370,9 @@ struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
 		wstats.discard.misc = sinfo.rx_dropped_misc;
 	if (sinfo.filled & STATION_INFO_TX_FAILED)
 		wstats.discard.retries = sinfo.tx_failed;
+	wstats.status = sinfo.status;
+	wstats.qual.noise = sinfo.noise;
+	wstats.txrate = cfg80211_calculate_bitrate(&sinfo.txrate);
 
 	return &wstats;
 }
net/wireless/wext-proc.c +5 -3
index 8bafa31..9ccc338 100644
@@ -46,8 +46,9 @@ static void wireless_seq_printf_stats(struct seq_file *seq,
 	}
 
 	if (stats) {
+		u32 rt = 100000 * (u32)(stats->txrate);
 		seq_printf(seq, "%6s: %04x  %3d%c  %3d%c  %3d%c  %6d %6d %6d "
-				"%6d %6d   %6d\n",
+				"%6d %6d   %6d  %d\n",
 			   dev->name, stats->status, stats->qual.qual,
 			   stats->qual.updated & IW_QUAL_QUAL_UPDATED
 			   ? '.' : ' ',
@@ -61,7 +62,8 @@ static void wireless_seq_printf_stats(struct seq_file *seq,
 			   ? '.' : ' ',
 			   stats->discard.nwid, stats->discard.code,
 			   stats->discard.fragment, stats->discard.retries,
-			   stats->discard.misc, stats->miss.beacon);
+			   stats->discard.misc, stats->miss.beacon,
+			   rt);
 
 		if (stats != &nullstats)
 			stats->qual.updated &= ~IW_QUAL_ALL_UPDATED;
@@ -78,7 +80,7 @@ static int wireless_dev_seq_show(struct seq_file *seq, void *v)
 
 	if (v == SEQ_START_TOKEN)
 		seq_printf(seq, "Inter-| sta-|   Quality        |   Discarded "
-				"packets               | Missed | WE\n"
+				"packets               | Missed | WE   RATE\n"
 				" face | tus | link level noise |  nwid  "
 				"crypt   frag  retry   misc | beacon | %d\n",
 			   WIRELESS_EXT);
Signature · 4 lines
1.7.2.2


--------------020602090802010706000601--