diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-09-12 11:42:45 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-12 11:42:45 -0400 |
commit | 8083e1656211eb1487329923d592ee061d08d7b3 (patch) | |
tree | 92a44787484996b82365fab21f2dec960ab4f2d3 /drivers/net/wireless | |
parent | 6b12a3d35ff6cb09f8b777ab258ea1e32c680d62 (diff) | |
parent | 1802ca745280b916cda4090e459741b8c9b3e8d0 (diff) |
Merge branch 'upstream-fixes' into upstream
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_chip.c | 61 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.c | 43 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.h | 11 |
3 files changed, 88 insertions, 27 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 58419985e00f..7c4e32cf0d47 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -1435,9 +1435,43 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | |||
1435 | break; | 1435 | break; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | switch (rate) { | ||
1439 | case ZD_OFDM_RATE_6M: | ||
1440 | case ZD_OFDM_RATE_9M: | ||
1441 | i += 3; | ||
1442 | break; | ||
1443 | case ZD_OFDM_RATE_12M: | ||
1444 | case ZD_OFDM_RATE_18M: | ||
1445 | i += 5; | ||
1446 | break; | ||
1447 | case ZD_OFDM_RATE_24M: | ||
1448 | case ZD_OFDM_RATE_36M: | ||
1449 | i += 9; | ||
1450 | break; | ||
1451 | case ZD_OFDM_RATE_48M: | ||
1452 | case ZD_OFDM_RATE_54M: | ||
1453 | i += 15; | ||
1454 | break; | ||
1455 | default: | ||
1456 | return -EINVAL; | ||
1457 | } | ||
1458 | |||
1438 | return i; | 1459 | return i; |
1439 | } | 1460 | } |
1440 | 1461 | ||
1462 | static int ofdm_qual_percent(u8 status_quality, u8 rate, unsigned int size) | ||
1463 | { | ||
1464 | int r; | ||
1465 | |||
1466 | r = ofdm_qual_db(status_quality, rate, size); | ||
1467 | ZD_ASSERT(r >= 0); | ||
1468 | if (r < 0) | ||
1469 | r = 0; | ||
1470 | |||
1471 | r = (r * 100)/29; | ||
1472 | return r <= 100 ? r : 100; | ||
1473 | } | ||
1474 | |||
1441 | static unsigned int log10times100(unsigned int x) | 1475 | static unsigned int log10times100(unsigned int x) |
1442 | { | 1476 | { |
1443 | static const u8 log10[] = { | 1477 | static const u8 log10[] = { |
@@ -1481,31 +1515,28 @@ static int cck_snr_db(u8 status_quality) | |||
1481 | return r; | 1515 | return r; |
1482 | } | 1516 | } |
1483 | 1517 | ||
1484 | static int rx_qual_db(const void *rx_frame, unsigned int size, | 1518 | static int cck_qual_percent(u8 status_quality) |
1485 | const struct rx_status *status) | ||
1486 | { | 1519 | { |
1487 | return (status->frame_status&ZD_RX_OFDM) ? | 1520 | int r; |
1488 | ofdm_qual_db(status->signal_quality_ofdm, | 1521 | |
1489 | zd_ofdm_plcp_header_rate(rx_frame), | 1522 | r = cck_snr_db(status_quality); |
1490 | size) : | 1523 | r = (100*r)/17; |
1491 | cck_snr_db(status->signal_quality_cck); | 1524 | return r <= 100 ? r : 100; |
1492 | } | 1525 | } |
1493 | 1526 | ||
1494 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, | 1527 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, |
1495 | const struct rx_status *status) | 1528 | const struct rx_status *status) |
1496 | { | 1529 | { |
1497 | int r = rx_qual_db(rx_frame, size, status); | 1530 | return (status->frame_status&ZD_RX_OFDM) ? |
1498 | if (r < 0) | 1531 | ofdm_qual_percent(status->signal_quality_ofdm, |
1499 | r = 0; | 1532 | zd_ofdm_plcp_header_rate(rx_frame), |
1500 | r = (r * 100) / 14; | 1533 | size) : |
1501 | if (r > 100) | 1534 | cck_qual_percent(status->signal_quality_cck); |
1502 | r = 100; | ||
1503 | return r; | ||
1504 | } | 1535 | } |
1505 | 1536 | ||
1506 | u8 zd_rx_strength_percent(u8 rssi) | 1537 | u8 zd_rx_strength_percent(u8 rssi) |
1507 | { | 1538 | { |
1508 | int r = (rssi*100) / 30; | 1539 | int r = (rssi*100) / 41; |
1509 | if (r > 100) | 1540 | if (r > 100) |
1510 | r = 100; | 1541 | r = 100; |
1511 | return (u8) r; | 1542 | return (u8) r; |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 0eda534a648c..0ddccf893989 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -814,13 +814,25 @@ static int filter_rx(struct ieee80211_device *ieee, | |||
814 | return -EINVAL; | 814 | return -EINVAL; |
815 | } | 815 | } |
816 | 816 | ||
817 | static void update_qual_rssi(struct zd_mac *mac, u8 qual_percent, u8 rssi) | 817 | static void update_qual_rssi(struct zd_mac *mac, |
818 | const u8 *buffer, unsigned int length, | ||
819 | u8 qual_percent, u8 rssi_percent) | ||
818 | { | 820 | { |
819 | unsigned long flags; | 821 | unsigned long flags; |
822 | struct ieee80211_hdr_3addr *hdr; | ||
823 | int i; | ||
824 | |||
825 | hdr = (struct ieee80211_hdr_3addr *)buffer; | ||
826 | if (length < offsetof(struct ieee80211_hdr_3addr, addr3)) | ||
827 | return; | ||
828 | if (memcmp(hdr->addr2, zd_mac_to_ieee80211(mac)->bssid, ETH_ALEN) != 0) | ||
829 | return; | ||
820 | 830 | ||
821 | spin_lock_irqsave(&mac->lock, flags); | 831 | spin_lock_irqsave(&mac->lock, flags); |
822 | mac->qual_average = (7 * mac->qual_average + qual_percent) / 8; | 832 | i = mac->stats_count % ZD_MAC_STATS_BUFFER_SIZE; |
823 | mac->rssi_average = (7 * mac->rssi_average + rssi) / 8; | 833 | mac->qual_buffer[i] = qual_percent; |
834 | mac->rssi_buffer[i] = rssi_percent; | ||
835 | mac->stats_count++; | ||
824 | spin_unlock_irqrestore(&mac->lock, flags); | 836 | spin_unlock_irqrestore(&mac->lock, flags); |
825 | } | 837 | } |
826 | 838 | ||
@@ -851,7 +863,6 @@ static int fill_rx_stats(struct ieee80211_rx_stats *stats, | |||
851 | if (stats->rate) | 863 | if (stats->rate) |
852 | stats->mask |= IEEE80211_STATMASK_RATE; | 864 | stats->mask |= IEEE80211_STATMASK_RATE; |
853 | 865 | ||
854 | update_qual_rssi(mac, stats->signal, stats->rssi); | ||
855 | return 0; | 866 | return 0; |
856 | } | 867 | } |
857 | 868 | ||
@@ -875,6 +886,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length) | |||
875 | sizeof(struct rx_status); | 886 | sizeof(struct rx_status); |
876 | buffer += ZD_PLCP_HEADER_SIZE; | 887 | buffer += ZD_PLCP_HEADER_SIZE; |
877 | 888 | ||
889 | update_qual_rssi(mac, buffer, length, stats.signal, stats.rssi); | ||
890 | |||
878 | r = filter_rx(ieee, buffer, length, &stats); | 891 | r = filter_rx(ieee, buffer, length, &stats); |
879 | if (r <= 0) | 892 | if (r <= 0) |
880 | return r; | 893 | return r; |
@@ -979,17 +992,31 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev) | |||
979 | { | 992 | { |
980 | struct zd_mac *mac = zd_netdev_mac(ndev); | 993 | struct zd_mac *mac = zd_netdev_mac(ndev); |
981 | struct iw_statistics *iw_stats = &mac->iw_stats; | 994 | struct iw_statistics *iw_stats = &mac->iw_stats; |
995 | unsigned int i, count, qual_total, rssi_total; | ||
982 | 996 | ||
983 | memset(iw_stats, 0, sizeof(struct iw_statistics)); | 997 | memset(iw_stats, 0, sizeof(struct iw_statistics)); |
984 | /* We are not setting the status, because ieee->state is not updated | 998 | /* We are not setting the status, because ieee->state is not updated |
985 | * at all and this driver doesn't track authentication state. | 999 | * at all and this driver doesn't track authentication state. |
986 | */ | 1000 | */ |
987 | spin_lock_irq(&mac->lock); | 1001 | spin_lock_irq(&mac->lock); |
988 | iw_stats->qual.qual = mac->qual_average; | 1002 | count = mac->stats_count < ZD_MAC_STATS_BUFFER_SIZE ? |
989 | iw_stats->qual.level = mac->rssi_average; | 1003 | mac->stats_count : ZD_MAC_STATS_BUFFER_SIZE; |
990 | iw_stats->qual.updated = IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED| | 1004 | qual_total = rssi_total = 0; |
991 | IW_QUAL_NOISE_INVALID; | 1005 | for (i = 0; i < count; i++) { |
1006 | qual_total += mac->qual_buffer[i]; | ||
1007 | rssi_total += mac->rssi_buffer[i]; | ||
1008 | } | ||
992 | spin_unlock_irq(&mac->lock); | 1009 | spin_unlock_irq(&mac->lock); |
1010 | iw_stats->qual.updated = IW_QUAL_NOISE_INVALID; | ||
1011 | if (count > 0) { | ||
1012 | iw_stats->qual.qual = qual_total / count; | ||
1013 | iw_stats->qual.level = rssi_total / count; | ||
1014 | iw_stats->qual.updated |= | ||
1015 | IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED; | ||
1016 | } else { | ||
1017 | iw_stats->qual.updated |= | ||
1018 | IW_QUAL_QUAL_INVALID|IW_QUAL_LEVEL_INVALID; | ||
1019 | } | ||
993 | /* TODO: update counter */ | 1020 | /* TODO: update counter */ |
994 | return iw_stats; | 1021 | return iw_stats; |
995 | } | 1022 | } |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index 082bcf8ec8dc..2b596cc8a41a 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* zd_mac.c | 1 | /* zd_mac.h |
2 | * | 2 | * |
3 | * This program is free software; you can redistribute it and/or modify | 3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
@@ -87,9 +87,9 @@ struct rx_length_info { | |||
87 | #define RX_LENGTH_INFO_TAG 0x697e | 87 | #define RX_LENGTH_INFO_TAG 0x697e |
88 | 88 | ||
89 | struct rx_status { | 89 | struct rx_status { |
90 | u8 signal_quality_cck; | ||
90 | /* rssi */ | 91 | /* rssi */ |
91 | u8 signal_strength; | 92 | u8 signal_strength; |
92 | u8 signal_quality_cck; | ||
93 | u8 signal_quality_ofdm; | 93 | u8 signal_quality_ofdm; |
94 | u8 decryption_type; | 94 | u8 decryption_type; |
95 | u8 frame_status; | 95 | u8 frame_status; |
@@ -120,14 +120,17 @@ enum mac_flags { | |||
120 | MAC_FIXED_CHANNEL = 0x01, | 120 | MAC_FIXED_CHANNEL = 0x01, |
121 | }; | 121 | }; |
122 | 122 | ||
123 | #define ZD_MAC_STATS_BUFFER_SIZE 16 | ||
124 | |||
123 | struct zd_mac { | 125 | struct zd_mac { |
124 | struct zd_chip chip; | 126 | struct zd_chip chip; |
125 | spinlock_t lock; | 127 | spinlock_t lock; |
126 | struct net_device *netdev; | 128 | struct net_device *netdev; |
127 | /* Unlocked reading possible */ | 129 | /* Unlocked reading possible */ |
128 | struct iw_statistics iw_stats; | 130 | struct iw_statistics iw_stats; |
129 | u8 qual_average; | 131 | unsigned int stats_count; |
130 | u8 rssi_average; | 132 | u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; |
133 | u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; | ||
131 | u8 regdomain; | 134 | u8 regdomain; |
132 | u8 default_regdomain; | 135 | u8 default_regdomain; |
133 | u8 requested_channel; | 136 | u8 requested_channel; |