aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl818x
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2008-12-03 23:21:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-12-12 13:48:19 -0500
commita7db74f4be3835fd16c6c582d320f692ccccc622 (patch)
tree1dfd8f6293d3db7403ba0c71001bf7c8f8dc1e9b /drivers/net/wireless/rtl818x
parent7a3c66e2d322c638e9306e739d96b2192dacde88 (diff)
rtl8187: Improve wireless statistics for RTL8187
The current wireless statistics for the RTL8187 poorly indicate the signal strength and quality. With testing, I found that the AGC value is inversely correlated with the strength as in the RTL8187B. By implementing a similar calculation, much more code becomes common to the two devices. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Tested by: Martín Ernesto Barreyro <barreyromartin@gmail.com> Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rtl818x')
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index dbf52e8bbd7a..417a2d7b5764 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -313,29 +313,14 @@ static void rtl8187_rx_cb(struct urb *urb)
313 struct rtl8187_rx_hdr *hdr = 313 struct rtl8187_rx_hdr *hdr =
314 (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr)); 314 (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
315 flags = le32_to_cpu(hdr->flags); 315 flags = le32_to_cpu(hdr->flags);
316 signal = hdr->signal & 0x7f; 316 /* As with the RTL8187B below, the AGC is used to calculate
317 * signal strength and quality. In this case, the scaling
318 * constants are derived from the output of p54usb.
319 */
320 quality = 130 - ((41 * hdr->agc) >> 6);
321 signal = -4 - ((27 * hdr->agc) >> 6);
317 rx_status.antenna = (hdr->signal >> 7) & 1; 322 rx_status.antenna = (hdr->signal >> 7) & 1;
318 rx_status.noise = hdr->noise;
319 rx_status.mactime = le64_to_cpu(hdr->mac_time); 323 rx_status.mactime = le64_to_cpu(hdr->mac_time);
320 priv->quality = signal;
321 rx_status.qual = priv->quality;
322 priv->noise = hdr->noise;
323 rate = (flags >> 20) & 0xF;
324 if (rate > 3) { /* OFDM rate */
325 if (signal > 90)
326 signal = 90;
327 else if (signal < 25)
328 signal = 25;
329 signal = 90 - signal;
330 } else { /* CCK rate */
331 if (signal > 95)
332 signal = 95;
333 else if (signal < 30)
334 signal = 30;
335 signal = 95 - signal;
336 }
337 rx_status.signal = signal;
338 priv->signal = signal;
339 } else { 324 } else {
340 struct rtl8187b_rx_hdr *hdr = 325 struct rtl8187b_rx_hdr *hdr =
341 (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr)); 326 (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr));
@@ -353,18 +338,18 @@ static void rtl8187_rx_cb(struct urb *urb)
353 */ 338 */
354 flags = le32_to_cpu(hdr->flags); 339 flags = le32_to_cpu(hdr->flags);
355 quality = 170 - hdr->agc; 340 quality = 170 - hdr->agc;
356 if (quality > 100)
357 quality = 100;
358 signal = 14 - hdr->agc / 2; 341 signal = 14 - hdr->agc / 2;
359 rx_status.qual = quality;
360 priv->quality = quality;
361 rx_status.signal = signal;
362 priv->signal = signal;
363 rx_status.antenna = (hdr->rssi >> 7) & 1; 342 rx_status.antenna = (hdr->rssi >> 7) & 1;
364 rx_status.mactime = le64_to_cpu(hdr->mac_time); 343 rx_status.mactime = le64_to_cpu(hdr->mac_time);
365 rate = (flags >> 20) & 0xF;
366 } 344 }
367 345
346 if (quality > 100)
347 quality = 100;
348 rx_status.qual = quality;
349 priv->quality = quality;
350 rx_status.signal = signal;
351 priv->signal = signal;
352 rate = (flags >> 20) & 0xF;
368 skb_trim(skb, flags & 0x0FFF); 353 skb_trim(skb, flags & 0x0FFF);
369 rx_status.rate_idx = rate; 354 rx_status.rate_idx = rate;
370 rx_status.freq = dev->conf.channel->center_freq; 355 rx_status.freq = dev->conf.channel->center_freq;
@@ -1293,6 +1278,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1293 1278
1294 priv->mode = NL80211_IFTYPE_MONITOR; 1279 priv->mode = NL80211_IFTYPE_MONITOR;
1295 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1280 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1281 IEEE80211_HW_SIGNAL_DBM |
1296 IEEE80211_HW_RX_INCLUDES_FCS; 1282 IEEE80211_HW_RX_INCLUDES_FCS;
1297 1283
1298 eeprom.data = dev; 1284 eeprom.data = dev;
@@ -1408,13 +1394,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1408 (*channel++).hw_value = txpwr >> 8; 1394 (*channel++).hw_value = txpwr >> 8;
1409 } 1395 }
1410 1396
1411 if (priv->is_rtl8187b) { 1397 if (priv->is_rtl8187b)
1412 printk(KERN_WARNING "rtl8187: 8187B chip detected.\n"); 1398 printk(KERN_WARNING "rtl8187: 8187B chip detected.\n");
1413 dev->flags |= IEEE80211_HW_SIGNAL_DBM;
1414 } else {
1415 dev->flags |= IEEE80211_HW_SIGNAL_UNSPEC;
1416 dev->max_signal = 65;
1417 }
1418 1399
1419 /* 1400 /*
1420 * XXX: Once this driver supports anything that requires 1401 * XXX: Once this driver supports anything that requires