2008-11-15 14:15:28

by Andrey Borzenkov

[permalink] [raw]
Subject: [PATCH] orinoco: indicate it is using dBm in wireless_stats and spy

Subject: [PATCH] orinoco: indicate it is using dBm in wireless_stats and spy
From: Andrey Borzenkov <[email protected]>

Since WE7 /proc/net/wireless checks whether level and noise are in dBm
and shows them accordingly. Indicate that we return signal and noice
levels in dBm.

Before:
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
eth1: 0000 65. 219. 165. 0 0 148 41 0 0

After:
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
eth1: 0000 65. -37. -91. 0 0 0 0 0 0

While at it, replace raw numbers with appropriate macro.

Signed-off-by: Andrey Borzenkov <[email protected]>

---

drivers/net/wireless/orinoco.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index bc4f5a2..5038b76 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -821,7 +821,7 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
wstats->qual.qual = (int)le16_to_cpu(cq.qual);
wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
- wstats->qual.updated = 7;
+ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
}
}

@@ -1179,7 +1179,7 @@ static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac,
wstats.level = level - 0x95;
wstats.noise = noise - 0x95;
wstats.qual = (level > noise) ? (level - noise) : 0;
- wstats.updated = 7;
+ wstats.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
/* Update spy records */
wireless_spy_update(dev, mac, &wstats);
}


Attachments:
(No filename) (1.86 kB)
signature.asc (197.00 B)
This is a digitally signed message part.
Download all attachments

2008-11-19 22:12:24

by Pavel Roskin

[permalink] [raw]
Subject: Re: [PATCH] orinoco: indicate it is using dBm in wireless_stats and spy

On Sat, 2008-11-15 at 17:15 +0300, Andrey Borzenkov wrote:
> Subject: [PATCH] orinoco: indicate it is using dBm in wireless_stats and spy
> From: Andrey Borzenkov <[email protected]>
>
> Since WE7 /proc/net/wireless checks whether level and noise are in dBm
> and shows them accordingly. Indicate that we return signal and noice
> levels in dBm.

I believe the formula we are using is not exact. Intersil firmware has
a separate register (HERMES_RID_DBMCOMMSQUALITY_INTERSIL) that provides
the dBm data. It relates to the data we are using
(HERMES_RID_COMMSQUALITY) in a linear way, but the multiplier is not 1.
I remember I tried to recover the formula but didn't have time to
complete it. Besides, different brands and version of the firmware do
it differently.

Anyway, we are using the same formula everywhere, yet we are
inconsistent. In some places the code uses IW_QUAL_DBM, in some places
is doesn't. It's better to be consistent. We can improve the formula
later. The numbers are in the reasonable range.

> Signed-off-by: Andrey Borzenkov <[email protected]>

(with some hesitation)
Signed-off-by: Pavel Roskin <[email protected]>

--
Regards,
Pavel Roskin