diff options
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_chip.c | 51 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_ieee80211.h | 43 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.c | 99 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.h | 65 |
4 files changed, 126 insertions, 132 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: |
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h index c4f36d39642b..fbf6491dce7e 100644 --- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h +++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h | |||
@@ -43,21 +43,25 @@ struct ofdm_plcp_header { | |||
43 | __le16 service; | 43 | __le16 service; |
44 | } __attribute__((packed)); | 44 | } __attribute__((packed)); |
45 | 45 | ||
46 | static inline u8 zd_ofdm_plcp_header_rate( | 46 | static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header) |
47 | const struct ofdm_plcp_header *header) | ||
48 | { | 47 | { |
49 | return header->prefix[0] & 0xf; | 48 | return header->prefix[0] & 0xf; |
50 | } | 49 | } |
51 | 50 | ||
52 | /* These are referred to as zd_rates */ | 51 | /* The following defines give the encoding of the 4-bit rate field in the |
53 | #define ZD_OFDM_RATE_6M 0xb | 52 | * OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to |
54 | #define ZD_OFDM_RATE_9M 0xf | 53 | * define the zd-rate values for OFDM. |
55 | #define ZD_OFDM_RATE_12M 0xa | 54 | * |
56 | #define ZD_OFDM_RATE_18M 0xe | 55 | * See the struct zd_ctrlset definition in zd_mac.h. |
57 | #define ZD_OFDM_RATE_24M 0x9 | 56 | */ |
58 | #define ZD_OFDM_RATE_36M 0xd | 57 | #define ZD_OFDM_PLCP_RATE_6M 0xb |
59 | #define ZD_OFDM_RATE_48M 0x8 | 58 | #define ZD_OFDM_PLCP_RATE_9M 0xf |
60 | #define ZD_OFDM_RATE_54M 0xc | 59 | #define ZD_OFDM_PLCP_RATE_12M 0xa |
60 | #define ZD_OFDM_PLCP_RATE_18M 0xe | ||
61 | #define ZD_OFDM_PLCP_RATE_24M 0x9 | ||
62 | #define ZD_OFDM_PLCP_RATE_36M 0xd | ||
63 | #define ZD_OFDM_PLCP_RATE_48M 0x8 | ||
64 | #define ZD_OFDM_PLCP_RATE_54M 0xc | ||
61 | 65 | ||
62 | struct cck_plcp_header { | 66 | struct cck_plcp_header { |
63 | u8 signal; | 67 | u8 signal; |
@@ -66,15 +70,22 @@ struct cck_plcp_header { | |||
66 | __le16 crc16; | 70 | __le16 crc16; |
67 | } __attribute__((packed)); | 71 | } __attribute__((packed)); |
68 | 72 | ||
69 | static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header) | 73 | static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header) |
70 | { | 74 | { |
71 | return header->signal; | 75 | return header->signal; |
72 | } | 76 | } |
73 | 77 | ||
74 | #define ZD_CCK_SIGNAL_1M 0x0a | 78 | /* These defines give the encodings of the signal field in the 802.11b PLCP |
75 | #define ZD_CCK_SIGNAL_2M 0x14 | 79 | * header. The signal field gives the bit rate of the following packet. Even |
76 | #define ZD_CCK_SIGNAL_5M5 0x37 | 80 | * if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s |
77 | #define ZD_CCK_SIGNAL_11M 0x6e | 81 | * rate to stay consistent with Zydas and our use of the term. |
82 | * | ||
83 | * Notify that these values are *not* used in the zd-rates. | ||
84 | */ | ||
85 | #define ZD_CCK_PLCP_SIGNAL_1M 0x0a | ||
86 | #define ZD_CCK_PLCP_SIGNAL_2M 0x14 | ||
87 | #define ZD_CCK_PLCP_SIGNAL_5M5 0x37 | ||
88 | #define ZD_CCK_PLCP_SIGNAL_11M 0x6e | ||
78 | 89 | ||
79 | enum ieee80211_std { | 90 | enum ieee80211_std { |
80 | IEEE80211B = 0x01, | 91 | IEEE80211B = 0x01, |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 7ec1fcf37fc3..451308d7095d 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -610,28 +610,6 @@ u8 zd_mac_get_channel(struct zd_mac *mac) | |||
610 | return channel; | 610 | return channel; |
611 | } | 611 | } |
612 | 612 | ||
613 | /* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */ | ||
614 | static u8 zd_rate_typed(u8 zd_rate) | ||
615 | { | ||
616 | static const u8 typed_rates[16] = { | ||
617 | [ZD_CCK_RATE_1M] = ZD_CS_CCK|ZD_CCK_RATE_1M, | ||
618 | [ZD_CCK_RATE_2M] = ZD_CS_CCK|ZD_CCK_RATE_2M, | ||
619 | [ZD_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CCK_RATE_5_5M, | ||
620 | [ZD_CCK_RATE_11M] = ZD_CS_CCK|ZD_CCK_RATE_11M, | ||
621 | [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M, | ||
622 | [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M, | ||
623 | [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M, | ||
624 | [ZD_OFDM_RATE_18M] = ZD_CS_OFDM|ZD_OFDM_RATE_18M, | ||
625 | [ZD_OFDM_RATE_24M] = ZD_CS_OFDM|ZD_OFDM_RATE_24M, | ||
626 | [ZD_OFDM_RATE_36M] = ZD_CS_OFDM|ZD_OFDM_RATE_36M, | ||
627 | [ZD_OFDM_RATE_48M] = ZD_CS_OFDM|ZD_OFDM_RATE_48M, | ||
628 | [ZD_OFDM_RATE_54M] = ZD_CS_OFDM|ZD_OFDM_RATE_54M, | ||
629 | }; | ||
630 | |||
631 | ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f); | ||
632 | return typed_rates[zd_rate & ZD_CS_RATE_MASK]; | ||
633 | } | ||
634 | |||
635 | int zd_mac_set_mode(struct zd_mac *mac, u32 mode) | 613 | int zd_mac_set_mode(struct zd_mac *mac, u32 mode) |
636 | { | 614 | { |
637 | struct ieee80211_device *ieee; | 615 | struct ieee80211_device *ieee; |
@@ -739,25 +717,30 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range) | |||
739 | 717 | ||
740 | static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length) | 718 | static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length) |
741 | { | 719 | { |
720 | /* ZD_PURE_RATE() must be used to remove the modulation type flag of | ||
721 | * the zd-rate values. */ | ||
742 | static const u8 rate_divisor[] = { | 722 | static const u8 rate_divisor[] = { |
743 | [ZD_CCK_RATE_1M] = 1, | 723 | [ZD_PURE_RATE(ZD_CCK_RATE_1M)] = 1, |
744 | [ZD_CCK_RATE_2M] = 2, | 724 | [ZD_PURE_RATE(ZD_CCK_RATE_2M)] = 2, |
745 | [ZD_CCK_RATE_5_5M] = 11, /* bits must be doubled */ | 725 | |
746 | [ZD_CCK_RATE_11M] = 11, | 726 | /* bits must be doubled */ |
747 | [ZD_OFDM_RATE_6M] = 6, | 727 | [ZD_PURE_RATE(ZD_CCK_RATE_5_5M)] = 11, |
748 | [ZD_OFDM_RATE_9M] = 9, | 728 | |
749 | [ZD_OFDM_RATE_12M] = 12, | 729 | [ZD_PURE_RATE(ZD_CCK_RATE_11M)] = 11, |
750 | [ZD_OFDM_RATE_18M] = 18, | 730 | [ZD_PURE_RATE(ZD_OFDM_RATE_6M)] = 6, |
751 | [ZD_OFDM_RATE_24M] = 24, | 731 | [ZD_PURE_RATE(ZD_OFDM_RATE_9M)] = 9, |
752 | [ZD_OFDM_RATE_36M] = 36, | 732 | [ZD_PURE_RATE(ZD_OFDM_RATE_12M)] = 12, |
753 | [ZD_OFDM_RATE_48M] = 48, | 733 | [ZD_PURE_RATE(ZD_OFDM_RATE_18M)] = 18, |
754 | [ZD_OFDM_RATE_54M] = 54, | 734 | [ZD_PURE_RATE(ZD_OFDM_RATE_24M)] = 24, |
735 | [ZD_PURE_RATE(ZD_OFDM_RATE_36M)] = 36, | ||
736 | [ZD_PURE_RATE(ZD_OFDM_RATE_48M)] = 48, | ||
737 | [ZD_PURE_RATE(ZD_OFDM_RATE_54M)] = 54, | ||
755 | }; | 738 | }; |
756 | 739 | ||
757 | u32 bits = (u32)tx_length * 8; | 740 | u32 bits = (u32)tx_length * 8; |
758 | u32 divisor; | 741 | u32 divisor; |
759 | 742 | ||
760 | divisor = rate_divisor[zd_rate]; | 743 | divisor = rate_divisor[ZD_PURE_RATE(zd_rate)]; |
761 | if (divisor == 0) | 744 | if (divisor == 0) |
762 | return -EINVAL; | 745 | return -EINVAL; |
763 | 746 | ||
@@ -780,52 +763,24 @@ static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length) | |||
780 | return bits/divisor; | 763 | return bits/divisor; |
781 | } | 764 | } |
782 | 765 | ||
783 | enum { | ||
784 | R2M_SHORT_PREAMBLE = 0x01, | ||
785 | R2M_11A = 0x02, | ||
786 | }; | ||
787 | |||
788 | static u8 zd_rate_to_modulation(u8 zd_rate, int flags) | ||
789 | { | ||
790 | u8 modulation; | ||
791 | |||
792 | modulation = zd_rate_typed(zd_rate); | ||
793 | if (flags & R2M_SHORT_PREAMBLE) { | ||
794 | switch (ZD_CS_RATE(modulation)) { | ||
795 | case ZD_CCK_RATE_2M: | ||
796 | case ZD_CCK_RATE_5_5M: | ||
797 | case ZD_CCK_RATE_11M: | ||
798 | modulation |= ZD_CS_CCK_PREA_SHORT; | ||
799 | return modulation; | ||
800 | } | ||
801 | } | ||
802 | if (flags & R2M_11A) { | ||
803 | if (ZD_CS_TYPE(modulation) == ZD_CS_OFDM) | ||
804 | modulation |= ZD_CS_OFDM_MODE_11A; | ||
805 | } | ||
806 | return modulation; | ||
807 | } | ||
808 | |||
809 | static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs, | 766 | static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs, |
810 | struct ieee80211_hdr_4addr *hdr) | 767 | struct ieee80211_hdr_4addr *hdr) |
811 | { | 768 | { |
812 | struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); | 769 | struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); |
813 | u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); | 770 | u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); |
814 | u8 rate, zd_rate; | 771 | u8 rate; |
815 | int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; | 772 | int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; |
816 | int is_multicast = is_multicast_ether_addr(hdr->addr1); | 773 | int is_multicast = is_multicast_ether_addr(hdr->addr1); |
817 | int short_preamble = ieee80211softmac_short_preamble_ok(softmac, | 774 | int short_preamble = ieee80211softmac_short_preamble_ok(softmac, |
818 | is_multicast, is_mgt); | 775 | is_multicast, is_mgt); |
819 | int flags = 0; | ||
820 | 776 | ||
821 | /* FIXME: 802.11a? */ | ||
822 | rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt); | 777 | rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt); |
778 | cs->modulation = rate_to_zd_rate(rate); | ||
823 | 779 | ||
824 | if (short_preamble) | 780 | /* Set short preamble bit when appropriate */ |
825 | flags |= R2M_SHORT_PREAMBLE; | 781 | if (short_preamble && ZD_MODULATION_TYPE(cs->modulation) == ZD_CCK |
826 | 782 | && cs->modulation != ZD_CCK_RATE_1M) | |
827 | zd_rate = rate_to_zd_rate(rate); | 783 | cs->modulation |= ZD_CCK_PREA_SHORT; |
828 | cs->modulation = zd_rate_to_modulation(zd_rate, flags); | ||
829 | } | 784 | } |
830 | 785 | ||
831 | static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, | 786 | static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, |
@@ -864,7 +819,7 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, | |||
864 | cs->control |= ZD_CS_RTS; | 819 | cs->control |= ZD_CS_RTS; |
865 | 820 | ||
866 | /* Use CTS-to-self protection if required */ | 821 | /* Use CTS-to-self protection if required */ |
867 | if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM && | 822 | if (ZD_MODULATION_TYPE(cs->modulation) == ZD_OFDM && |
868 | ieee80211softmac_protection_needed(softmac)) { | 823 | ieee80211softmac_protection_needed(softmac)) { |
869 | /* FIXME: avoid sending RTS *and* self-CTS, is that correct? */ | 824 | /* FIXME: avoid sending RTS *and* self-CTS, is that correct? */ |
870 | cs->control &= ~ZD_CS_RTS; | 825 | cs->control &= ~ZD_CS_RTS; |
@@ -925,7 +880,7 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
925 | * - see line 53 of zdinlinef.h | 880 | * - see line 53 of zdinlinef.h |
926 | */ | 881 | */ |
927 | cs->service = 0; | 882 | cs->service = 0; |
928 | r = zd_calc_tx_length_us(&cs->service, ZD_CS_RATE(cs->modulation), | 883 | r = zd_calc_tx_length_us(&cs->service, ZD_RATE(cs->modulation), |
929 | le16_to_cpu(cs->tx_length)); | 884 | le16_to_cpu(cs->tx_length)); |
930 | if (r < 0) | 885 | if (r < 0) |
931 | return r; | 886 | return r; |
@@ -934,7 +889,7 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
934 | if (next_frag_len == 0) { | 889 | if (next_frag_len == 0) { |
935 | cs->next_frame_length = 0; | 890 | cs->next_frame_length = 0; |
936 | } else { | 891 | } else { |
937 | r = zd_calc_tx_length_us(NULL, ZD_CS_RATE(cs->modulation), | 892 | r = zd_calc_tx_length_us(NULL, ZD_RATE(cs->modulation), |
938 | next_frag_len); | 893 | next_frag_len); |
939 | if (r < 0) | 894 | if (r < 0) |
940 | return r; | 895 | return r; |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index 9f9344eb50f9..1b15bde3ff60 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -40,28 +40,51 @@ struct zd_ctrlset { | |||
40 | 40 | ||
41 | #define ZD_CS_RESERVED_SIZE 25 | 41 | #define ZD_CS_RESERVED_SIZE 25 |
42 | 42 | ||
43 | /* zd_crtlset field modulation */ | 43 | /* The field modulation of struct zd_ctrlset controls the bit rate, the use |
44 | #define ZD_CS_RATE_MASK 0x0f | 44 | * of short or long preambles in 802.11b (CCK mode) or the use of 802.11a or |
45 | #define ZD_CS_TYPE_MASK 0x10 | 45 | * 802.11g in OFDM mode. |
46 | #define ZD_CS_RATE(modulation) ((modulation) & ZD_CS_RATE_MASK) | 46 | * |
47 | #define ZD_CS_TYPE(modulation) ((modulation) & ZD_CS_TYPE_MASK) | 47 | * The term zd-rate is used for the combination of the modulation type flag |
48 | 48 | * and the "pure" rate value. | |
49 | #define ZD_CS_CCK 0x00 | ||
50 | #define ZD_CS_OFDM 0x10 | ||
51 | |||
52 | /* These are referred to as zd_rates */ | ||
53 | #define ZD_CCK_RATE_1M 0x00 | ||
54 | #define ZD_CCK_RATE_2M 0x01 | ||
55 | #define ZD_CCK_RATE_5_5M 0x02 | ||
56 | #define ZD_CCK_RATE_11M 0x03 | ||
57 | /* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*. | ||
58 | */ | 49 | */ |
59 | 50 | #define ZD_PURE_RATE_MASK 0x0f | |
60 | /* bit 5 is preamble (when in CCK mode), or a/g selection (when in OFDM mode) */ | 51 | #define ZD_MODULATION_TYPE_MASK 0x10 |
61 | #define ZD_CS_CCK_PREA_LONG 0x00 | 52 | #define ZD_RATE_MASK (ZD_PURE_RATE_MASK|ZD_MODULATION_TYPE_MASK) |
62 | #define ZD_CS_CCK_PREA_SHORT 0x20 | 53 | #define ZD_PURE_RATE(modulation) ((modulation) & ZD_PURE_RATE_MASK) |
63 | #define ZD_CS_OFDM_MODE_11G 0x00 | 54 | #define ZD_MODULATION_TYPE(modulation) ((modulation) & ZD_MODULATION_TYPE_MASK) |
64 | #define ZD_CS_OFDM_MODE_11A 0x20 | 55 | #define ZD_RATE(modulation) ((modulation) & ZD_RATE_MASK) |
56 | |||
57 | /* The two possible modulation types. Notify that 802.11b doesn't use the CCK | ||
58 | * codeing for the 1 and 2 MBit/s rate. We stay with the term here to remain | ||
59 | * consistent with uses the term at other places. | ||
60 | */ | ||
61 | #define ZD_CCK 0x00 | ||
62 | #define ZD_OFDM 0x10 | ||
63 | |||
64 | /* The ZD1211 firmware uses proprietary encodings of the 802.11b (CCK) rates. | ||
65 | * For OFDM the PLCP rate encodings are used. We combine these "pure" rates | ||
66 | * with the modulation type flag and call the resulting values zd-rates. | ||
67 | */ | ||
68 | #define ZD_CCK_RATE_1M (ZD_CCK|0x00) | ||
69 | #define ZD_CCK_RATE_2M (ZD_CCK|0x01) | ||
70 | #define ZD_CCK_RATE_5_5M (ZD_CCK|0x02) | ||
71 | #define ZD_CCK_RATE_11M (ZD_CCK|0x03) | ||
72 | #define ZD_OFDM_RATE_6M (ZD_OFDM|ZD_OFDM_PLCP_RATE_6M) | ||
73 | #define ZD_OFDM_RATE_9M (ZD_OFDM|ZD_OFDM_PLCP_RATE_9M) | ||
74 | #define ZD_OFDM_RATE_12M (ZD_OFDM|ZD_OFDM_PLCP_RATE_12M) | ||
75 | #define ZD_OFDM_RATE_18M (ZD_OFDM|ZD_OFDM_PLCP_RATE_18M) | ||
76 | #define ZD_OFDM_RATE_24M (ZD_OFDM|ZD_OFDM_PLCP_RATE_24M) | ||
77 | #define ZD_OFDM_RATE_36M (ZD_OFDM|ZD_OFDM_PLCP_RATE_36M) | ||
78 | #define ZD_OFDM_RATE_48M (ZD_OFDM|ZD_OFDM_PLCP_RATE_48M) | ||
79 | #define ZD_OFDM_RATE_54M (ZD_OFDM|ZD_OFDM_PLCP_RATE_54M) | ||
80 | |||
81 | /* The bit 5 of the zd_ctrlset modulation field controls the preamble in CCK | ||
82 | * mode or the 802.11a/802.11g selection in OFDM mode. | ||
83 | */ | ||
84 | #define ZD_CCK_PREA_LONG 0x00 | ||
85 | #define ZD_CCK_PREA_SHORT 0x20 | ||
86 | #define ZD_OFDM_MODE_11G 0x00 | ||
87 | #define ZD_OFDM_MODE_11A 0x20 | ||
65 | 88 | ||
66 | /* zd_ctrlset control field */ | 89 | /* zd_ctrlset control field */ |
67 | #define ZD_CS_NEED_RANDOM_BACKOFF 0x01 | 90 | #define ZD_CS_NEED_RANDOM_BACKOFF 0x01 |