diff options
author | Ulrich Kunitz <kune@deine-taler.de> | 2007-08-05 20:24:31 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:32 -0400 |
commit | 64f222cce2605420470d7a1f678783bdc2754af6 (patch) | |
tree | a1d4a6b61eca5d57a527860325717571c02682c0 /drivers/net/wireless/zd1211rw/zd_chip.c | |
parent | 8e97afe56984237af2115368ca0a5c525049cbd2 (diff) |
[PATCH] zd1211rw: consistent handling of ZD1211 specific rates
As pointed out by Daniel Drake, the zd1211rw driver used several
different rate values and names throughout the driver. He has
written a patch to change it and tweaked it after some pretty wild
ideas from my side. But the discussion helped me to understand the
problem better and I think I have nailed it down with this patch.
A zd-rate will consist from now on of a four-bit "pure" rate value
and a modulation type flag as used in the ZD1211 control set used
for packet transmission. This is consistent with the usage in the
zd_rates table. If possible these zd-rates should be used in the
code.
Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw/zd_chip.c')
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_chip.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 7e3c0625129b..495904218b1b 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -1009,19 +1009,19 @@ int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip, | |||
1009 | u32 value = 0; | 1009 | u32 value = 0; |
1010 | 1010 | ||
1011 | /* Modulation bit */ | 1011 | /* Modulation bit */ |
1012 | if (ZD_CS_TYPE(rts_rate) == ZD_CS_OFDM) | 1012 | if (ZD_MODULATION_TYPE(rts_rate) == ZD_OFDM) |
1013 | rts_mod = ZD_RX_OFDM; | 1013 | rts_mod = ZD_RX_OFDM; |
1014 | 1014 | ||
1015 | dev_dbg_f(zd_chip_dev(chip), "rts_rate=%x preamble=%x\n", | 1015 | dev_dbg_f(zd_chip_dev(chip), "rts_rate=%x preamble=%x\n", |
1016 | rts_rate, preamble); | 1016 | rts_rate, preamble); |
1017 | 1017 | ||
1018 | value |= rts_rate << RTSCTS_SH_RTS_RATE; | 1018 | value |= ZD_PURE_RATE(rts_rate) << RTSCTS_SH_RTS_RATE; |
1019 | value |= rts_mod << RTSCTS_SH_RTS_MOD_TYPE; | 1019 | value |= rts_mod << RTSCTS_SH_RTS_MOD_TYPE; |
1020 | value |= preamble << RTSCTS_SH_RTS_PMB_TYPE; | 1020 | value |= preamble << RTSCTS_SH_RTS_PMB_TYPE; |
1021 | value |= preamble << RTSCTS_SH_CTS_PMB_TYPE; | 1021 | value |= preamble << RTSCTS_SH_CTS_PMB_TYPE; |
1022 | 1022 | ||
1023 | /* We always send 11M self-CTS messages, like the vendor driver. */ | 1023 | /* We always send 11M self-CTS messages, like the vendor driver. */ |
1024 | value |= ZD_CCK_RATE_11M << RTSCTS_SH_CTS_RATE; | 1024 | value |= ZD_PURE_RATE(ZD_CCK_RATE_11M) << RTSCTS_SH_CTS_RATE; |
1025 | value |= ZD_RX_CCK << RTSCTS_SH_CTS_MOD_TYPE; | 1025 | value |= ZD_RX_CCK << RTSCTS_SH_CTS_MOD_TYPE; |
1026 | 1026 | ||
1027 | return zd_iowrite32_locked(chip, value, CR_RTS_CTS_RATE); | 1027 | return zd_iowrite32_locked(chip, value, CR_RTS_CTS_RATE); |
@@ -1328,7 +1328,7 @@ int zd_chip_set_basic_rates_locked(struct zd_chip *chip, u16 cr_rates) | |||
1328 | return zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL); | 1328 | return zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | 1331 | static int ofdm_qual_db(u8 status_quality, u8 zd_rate, unsigned int size) |
1332 | { | 1332 | { |
1333 | static const u16 constants[] = { | 1333 | static const u16 constants[] = { |
1334 | 715, 655, 585, 540, 470, 410, 360, 315, | 1334 | 715, 655, 585, 540, 470, 410, 360, 315, |
@@ -1342,7 +1342,7 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | |||
1342 | /* It seems that their quality parameter is somehow per signal | 1342 | /* It seems that their quality parameter is somehow per signal |
1343 | * and is now transferred per bit. | 1343 | * and is now transferred per bit. |
1344 | */ | 1344 | */ |
1345 | switch (rate) { | 1345 | switch (zd_rate) { |
1346 | case ZD_OFDM_RATE_6M: | 1346 | case ZD_OFDM_RATE_6M: |
1347 | case ZD_OFDM_RATE_12M: | 1347 | case ZD_OFDM_RATE_12M: |
1348 | case ZD_OFDM_RATE_24M: | 1348 | case ZD_OFDM_RATE_24M: |
@@ -1369,7 +1369,7 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | |||
1369 | break; | 1369 | break; |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | switch (rate) { | 1372 | switch (zd_rate) { |
1373 | case ZD_OFDM_RATE_6M: | 1373 | case ZD_OFDM_RATE_6M: |
1374 | case ZD_OFDM_RATE_9M: | 1374 | case ZD_OFDM_RATE_9M: |
1375 | i += 3; | 1375 | i += 3; |
@@ -1393,11 +1393,11 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | |||
1393 | return i; | 1393 | return i; |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | static int ofdm_qual_percent(u8 status_quality, u8 rate, unsigned int size) | 1396 | static int ofdm_qual_percent(u8 status_quality, u8 zd_rate, unsigned int size) |
1397 | { | 1397 | { |
1398 | int r; | 1398 | int r; |
1399 | 1399 | ||
1400 | r = ofdm_qual_db(status_quality, rate, size); | 1400 | r = ofdm_qual_db(status_quality, zd_rate, size); |
1401 | ZD_ASSERT(r >= 0); | 1401 | ZD_ASSERT(r >= 0); |
1402 | if (r < 0) | 1402 | if (r < 0) |
1403 | r = 0; | 1403 | r = 0; |
@@ -1458,12 +1458,17 @@ static int cck_qual_percent(u8 status_quality) | |||
1458 | return r <= 100 ? r : 100; | 1458 | return r <= 100 ? r : 100; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | static inline u8 zd_rate_from_ofdm_plcp_header(const void *rx_frame) | ||
1462 | { | ||
1463 | return ZD_OFDM | zd_ofdm_plcp_header_rate(rx_frame); | ||
1464 | } | ||
1465 | |||
1461 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, | 1466 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, |
1462 | const struct rx_status *status) | 1467 | const struct rx_status *status) |
1463 | { | 1468 | { |
1464 | return (status->frame_status&ZD_RX_OFDM) ? | 1469 | return (status->frame_status&ZD_RX_OFDM) ? |
1465 | ofdm_qual_percent(status->signal_quality_ofdm, | 1470 | ofdm_qual_percent(status->signal_quality_ofdm, |
1466 | zd_ofdm_plcp_header_rate(rx_frame), | 1471 | zd_rate_from_ofdm_plcp_header(rx_frame), |
1467 | size) : | 1472 | size) : |
1468 | cck_qual_percent(status->signal_quality_cck); | 1473 | cck_qual_percent(status->signal_quality_cck); |
1469 | } | 1474 | } |
@@ -1479,32 +1484,32 @@ u8 zd_rx_strength_percent(u8 rssi) | |||
1479 | u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status) | 1484 | u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status) |
1480 | { | 1485 | { |
1481 | static const u16 ofdm_rates[] = { | 1486 | static const u16 ofdm_rates[] = { |
1482 | [ZD_OFDM_RATE_6M] = 60, | 1487 | [ZD_OFDM_PLCP_RATE_6M] = 60, |
1483 | [ZD_OFDM_RATE_9M] = 90, | 1488 | [ZD_OFDM_PLCP_RATE_9M] = 90, |
1484 | [ZD_OFDM_RATE_12M] = 120, | 1489 | [ZD_OFDM_PLCP_RATE_12M] = 120, |
1485 | [ZD_OFDM_RATE_18M] = 180, | 1490 | [ZD_OFDM_PLCP_RATE_18M] = 180, |
1486 | [ZD_OFDM_RATE_24M] = 240, | 1491 | [ZD_OFDM_PLCP_RATE_24M] = 240, |
1487 | [ZD_OFDM_RATE_36M] = 360, | 1492 | [ZD_OFDM_PLCP_RATE_36M] = 360, |
1488 | [ZD_OFDM_RATE_48M] = 480, | 1493 | [ZD_OFDM_PLCP_RATE_48M] = 480, |
1489 | [ZD_OFDM_RATE_54M] = 540, | 1494 | [ZD_OFDM_PLCP_RATE_54M] = 540, |
1490 | }; | 1495 | }; |
1491 | u16 rate; | 1496 | u16 rate; |
1492 | if (status->frame_status & ZD_RX_OFDM) { | 1497 | if (status->frame_status & ZD_RX_OFDM) { |
1498 | /* Deals with PLCP OFDM rate (not zd_rates) */ | ||
1493 | u8 ofdm_rate = zd_ofdm_plcp_header_rate(rx_frame); | 1499 | u8 ofdm_rate = zd_ofdm_plcp_header_rate(rx_frame); |
1494 | rate = ofdm_rates[ofdm_rate & 0xf]; | 1500 | rate = ofdm_rates[ofdm_rate & 0xf]; |
1495 | } else { | 1501 | } else { |
1496 | u8 cck_rate = zd_cck_plcp_header_rate(rx_frame); | 1502 | switch (zd_cck_plcp_header_signal(rx_frame)) { |
1497 | switch (cck_rate) { | 1503 | case ZD_CCK_PLCP_SIGNAL_1M: |
1498 | case ZD_CCK_SIGNAL_1M: | ||
1499 | rate = 10; | 1504 | rate = 10; |
1500 | break; | 1505 | break; |
1501 | case ZD_CCK_SIGNAL_2M: | 1506 | case ZD_CCK_PLCP_SIGNAL_2M: |
1502 | rate = 20; | 1507 | rate = 20; |
1503 | break; | 1508 | break; |
1504 | case ZD_CCK_SIGNAL_5M5: | 1509 | case ZD_CCK_PLCP_SIGNAL_5M5: |
1505 | rate = 55; | 1510 | rate = 55; |
1506 | break; | 1511 | break; |
1507 | case ZD_CCK_SIGNAL_11M: | 1512 | case ZD_CCK_PLCP_SIGNAL_11M: |
1508 | rate = 110; | 1513 | rate = 110; |
1509 | break; | 1514 | break; |
1510 | default: | 1515 | default: |