2007-08-05 06:23:45

by Larry Finger

[permalink] [raw]
Subject: [PATCH] bcm43xx-mac80211: Rescale link quality output

The link quality output from wireless extensions is too small by the ratio
of 100/BCM43xx_RX_MAX_SSI (60) for bcm43xx-mac80211. This patch puts the
quantity on the proper scale.

Signed-off-by: Larry Finger <[email protected]>
---

Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
===================================================================
--- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
+++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
@@ -537,7 +537,8 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
(phystat0 & BCM43xx_RX_PHYST0_GAINCTL),
(phystat3 & BCM43xx_RX_PHYST3_TRSTATE));
status.noise = dev->stats.link_noise;
- status.signal = jssi; /* this looks wrong, but is what mac80211 wants */
+ /* the next line looks wrong, but is what mac80211 wants */
+ status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
if (phystat0 & BCM43xx_RX_PHYST0_OFDM)
status.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp);
else


2007-08-05 07:31:36

by Andy Green

[permalink] [raw]
Subject: Re: [PATCH] bcm43xx-mac80211: Rescale link quality output

Somebody in the thread at some point said:
> Andy Green wrote:
>> Somebody in the thread at some point said:
>>> BCM43xx_RX_MAX_SSI (60)
>>
>>> + status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
>>
>> That can't be doing what you intended... (int)100/60 == 1, it just
>> multiplies jssi by 1. Maybe some brackets around the multiply?
>
> I think gcc does equal rank operations from left to right, and the
> change does have the desired result, but the parentheses should be there
> for clarity.

Man I don't know when * started to have equal precedence to /, but you
are right:

#include <stdio.h>
main()
{
printf("%d\n", 5 * 100 / 60);
printf("%d\n", (5 * 100) / 60);
printf("%d\n", 5 * (100 / 60));
}

$ gcc test.c -o test
$ ./test
8
8
5

Sorry for the noise.

-Andy

2007-08-05 07:26:34

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH] bcm43xx-mac80211: Rescale link quality output

Andy Green wrote:
> Somebody in the thread at some point said:
>> BCM43xx_RX_MAX_SSI (60)
>
>> + status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
>
> That can't be doing what you intended... (int)100/60 == 1, it just
> multiplies jssi by 1. Maybe some brackets around the multiply?

I think gcc does equal rank operations from left to right, and the change does have the desired
result, but the parentheses should be there for clarity.

Thanks,

Larry

2007-08-05 06:43:11

by Andy Green

[permalink] [raw]
Subject: Re: [PATCH] bcm43xx-mac80211: Rescale link quality output

Somebody in the thread at some point said:
> BCM43xx_RX_MAX_SSI (60)

> + status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;

That can't be doing what you intended... (int)100/60 == 1, it just
multiplies jssi by 1. Maybe some brackets around the multiply?

-Andy