diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-01-24 13:38:38 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-02-29 15:19:32 -0500 |
commit | 8318d78a44d49ac1edf2bdec7299de3617c4232e (patch) | |
tree | d434634418edd7399737801615d247be06616fdd /drivers/net/wireless/zd1211rw/zd_mac.c | |
parent | 10b6b80145cc93887dd8aab99bfffa375e9add31 (diff) |
cfg80211 API for channels/bitrates, mac80211 and driver conversion
This patch creates new cfg80211 wiphy API for channel and bitrate
registration and converts mac80211 and drivers to the new API. The
old mac80211 API is completely ripped out. All drivers (except ath5k)
are updated to the new API, in many cases I expect that optimisations
can be done.
Along with the regulatory code I've also ripped out the
IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be
unnecessary if the hardware simply gives us whatever channels it wants
to support and we then enable/disable them as required, which is pretty
much required for travelling.
Additionally, the patch adds proper "basic" rate handling for STA
mode interface, AP mode interface will have to have new API added
to allow userspace to set the basic rate set, currently it'll be
empty... However, the basic rate handling will need to be moved to
the BSS conf stuff.
I do expect there to be bugs in this, especially wrt. transmit
power handling where I'm basically clueless about how it should work.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw/zd_mac.c')
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.c | 170 |
1 files changed, 75 insertions, 95 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 76ef2d83919..21b65345883 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -34,76 +34,61 @@ | |||
34 | 34 | ||
35 | /* This table contains the hardware specific values for the modulation rates. */ | 35 | /* This table contains the hardware specific values for the modulation rates. */ |
36 | static const struct ieee80211_rate zd_rates[] = { | 36 | static const struct ieee80211_rate zd_rates[] = { |
37 | { .rate = 10, | 37 | { .bitrate = 10, |
38 | .val = ZD_CCK_RATE_1M, | 38 | .hw_value = ZD_CCK_RATE_1M, }, |
39 | .flags = IEEE80211_RATE_CCK }, | 39 | { .bitrate = 20, |
40 | { .rate = 20, | 40 | .hw_value = ZD_CCK_RATE_2M, |
41 | .val = ZD_CCK_RATE_2M, | 41 | .hw_value_short = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, |
42 | .val2 = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, | 42 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
43 | .flags = IEEE80211_RATE_CCK_2 }, | 43 | { .bitrate = 55, |
44 | { .rate = 55, | 44 | .hw_value = ZD_CCK_RATE_5_5M, |
45 | .val = ZD_CCK_RATE_5_5M, | 45 | .hw_value_short = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, |
46 | .val2 = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, | 46 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
47 | .flags = IEEE80211_RATE_CCK_2 }, | 47 | { .bitrate = 110, |
48 | { .rate = 110, | 48 | .hw_value = ZD_CCK_RATE_11M, |
49 | .val = ZD_CCK_RATE_11M, | 49 | .hw_value_short = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, |
50 | .val2 = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, | 50 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
51 | .flags = IEEE80211_RATE_CCK_2 }, | 51 | { .bitrate = 60, |
52 | { .rate = 60, | 52 | .hw_value = ZD_OFDM_RATE_6M, |
53 | .val = ZD_OFDM_RATE_6M, | 53 | .flags = 0 }, |
54 | .flags = IEEE80211_RATE_OFDM }, | 54 | { .bitrate = 90, |
55 | { .rate = 90, | 55 | .hw_value = ZD_OFDM_RATE_9M, |
56 | .val = ZD_OFDM_RATE_9M, | 56 | .flags = 0 }, |
57 | .flags = IEEE80211_RATE_OFDM }, | 57 | { .bitrate = 120, |
58 | { .rate = 120, | 58 | .hw_value = ZD_OFDM_RATE_12M, |
59 | .val = ZD_OFDM_RATE_12M, | 59 | .flags = 0 }, |
60 | .flags = IEEE80211_RATE_OFDM }, | 60 | { .bitrate = 180, |
61 | { .rate = 180, | 61 | .hw_value = ZD_OFDM_RATE_18M, |
62 | .val = ZD_OFDM_RATE_18M, | 62 | .flags = 0 }, |
63 | .flags = IEEE80211_RATE_OFDM }, | 63 | { .bitrate = 240, |
64 | { .rate = 240, | 64 | .hw_value = ZD_OFDM_RATE_24M, |
65 | .val = ZD_OFDM_RATE_24M, | 65 | .flags = 0 }, |
66 | .flags = IEEE80211_RATE_OFDM }, | 66 | { .bitrate = 360, |
67 | { .rate = 360, | 67 | .hw_value = ZD_OFDM_RATE_36M, |
68 | .val = ZD_OFDM_RATE_36M, | 68 | .flags = 0 }, |
69 | .flags = IEEE80211_RATE_OFDM }, | 69 | { .bitrate = 480, |
70 | { .rate = 480, | 70 | .hw_value = ZD_OFDM_RATE_48M, |
71 | .val = ZD_OFDM_RATE_48M, | 71 | .flags = 0 }, |
72 | .flags = IEEE80211_RATE_OFDM }, | 72 | { .bitrate = 540, |
73 | { .rate = 540, | 73 | .hw_value = ZD_OFDM_RATE_54M, |
74 | .val = ZD_OFDM_RATE_54M, | 74 | .flags = 0 }, |
75 | .flags = IEEE80211_RATE_OFDM }, | ||
76 | }; | 75 | }; |
77 | 76 | ||
78 | static const struct ieee80211_channel zd_channels[] = { | 77 | static const struct ieee80211_channel zd_channels[] = { |
79 | { .chan = 1, | 78 | { .center_freq = 2412, .hw_value = 1 }, |
80 | .freq = 2412}, | 79 | { .center_freq = 2417, .hw_value = 2 }, |
81 | { .chan = 2, | 80 | { .center_freq = 2422, .hw_value = 3 }, |
82 | .freq = 2417}, | 81 | { .center_freq = 2427, .hw_value = 4 }, |
83 | { .chan = 3, | 82 | { .center_freq = 2432, .hw_value = 5 }, |
84 | .freq = 2422}, | 83 | { .center_freq = 2437, .hw_value = 6 }, |
85 | { .chan = 4, | 84 | { .center_freq = 2442, .hw_value = 7 }, |
86 | .freq = 2427}, | 85 | { .center_freq = 2447, .hw_value = 8 }, |
87 | { .chan = 5, | 86 | { .center_freq = 2452, .hw_value = 9 }, |
88 | .freq = 2432}, | 87 | { .center_freq = 2457, .hw_value = 10 }, |
89 | { .chan = 6, | 88 | { .center_freq = 2462, .hw_value = 11 }, |
90 | .freq = 2437}, | 89 | { .center_freq = 2467, .hw_value = 12 }, |
91 | { .chan = 7, | 90 | { .center_freq = 2472, .hw_value = 13 }, |
92 | .freq = 2442}, | 91 | { .center_freq = 2484, .hw_value = 14 }, |
93 | { .chan = 8, | ||
94 | .freq = 2447}, | ||
95 | { .chan = 9, | ||
96 | .freq = 2452}, | ||
97 | { .chan = 10, | ||
98 | .freq = 2457}, | ||
99 | { .chan = 11, | ||
100 | .freq = 2462}, | ||
101 | { .chan = 12, | ||
102 | .freq = 2467}, | ||
103 | { .chan = 13, | ||
104 | .freq = 2472}, | ||
105 | { .chan = 14, | ||
106 | .freq = 2484} | ||
107 | }; | 92 | }; |
108 | 93 | ||
109 | static void housekeeping_init(struct zd_mac *mac); | 94 | static void housekeeping_init(struct zd_mac *mac); |
@@ -503,7 +488,9 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
503 | 488 | ||
504 | ZD_ASSERT(frag_len <= 0xffff); | 489 | ZD_ASSERT(frag_len <= 0xffff); |
505 | 490 | ||
506 | cs->modulation = control->tx_rate; | 491 | cs->modulation = control->tx_rate->hw_value; |
492 | if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | ||
493 | cs->modulation = control->tx_rate->hw_value_short; | ||
507 | 494 | ||
508 | cs->tx_length = cpu_to_le16(frag_len); | 495 | cs->tx_length = cpu_to_le16(frag_len); |
509 | 496 | ||
@@ -631,6 +618,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
631 | int bad_frame = 0; | 618 | int bad_frame = 0; |
632 | u16 fc; | 619 | u16 fc; |
633 | bool is_qos, is_4addr, need_padding; | 620 | bool is_qos, is_4addr, need_padding; |
621 | int i; | ||
622 | u8 rate; | ||
634 | 623 | ||
635 | if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + | 624 | if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + |
636 | FCS_LEN + sizeof(struct rx_status)) | 625 | FCS_LEN + sizeof(struct rx_status)) |
@@ -660,14 +649,19 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
660 | } | 649 | } |
661 | } | 650 | } |
662 | 651 | ||
663 | stats.channel = _zd_chip_get_channel(&mac->chip); | 652 | stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; |
664 | stats.freq = zd_channels[stats.channel - 1].freq; | 653 | stats.band = IEEE80211_BAND_2GHZ; |
665 | stats.phymode = MODE_IEEE80211G; | ||
666 | stats.ssi = status->signal_strength; | 654 | stats.ssi = status->signal_strength; |
667 | stats.signal = zd_rx_qual_percent(buffer, | 655 | stats.signal = zd_rx_qual_percent(buffer, |
668 | length - sizeof(struct rx_status), | 656 | length - sizeof(struct rx_status), |
669 | status); | 657 | status); |
670 | stats.rate = zd_rx_rate(buffer, status); | 658 | |
659 | rate = zd_rx_rate(buffer, status); | ||
660 | |||
661 | /* todo: return index in the big switches in zd_rx_rate instead */ | ||
662 | for (i = 0; i < mac->band.n_bitrates; i++) | ||
663 | if (rate == mac->band.bitrates[i].hw_value) | ||
664 | stats.rate_idx = i; | ||
671 | 665 | ||
672 | length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); | 666 | length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); |
673 | buffer += ZD_PLCP_HEADER_SIZE; | 667 | buffer += ZD_PLCP_HEADER_SIZE; |
@@ -736,7 +730,7 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw, | |||
736 | static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | 730 | static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) |
737 | { | 731 | { |
738 | struct zd_mac *mac = zd_hw_mac(hw); | 732 | struct zd_mac *mac = zd_hw_mac(hw); |
739 | return zd_chip_set_channel(&mac->chip, conf->channel); | 733 | return zd_chip_set_channel(&mac->chip, conf->channel->hw_value); |
740 | } | 734 | } |
741 | 735 | ||
742 | static int zd_op_config_interface(struct ieee80211_hw *hw, | 736 | static int zd_op_config_interface(struct ieee80211_hw *hw, |
@@ -894,7 +888,6 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) | |||
894 | { | 888 | { |
895 | struct zd_mac *mac; | 889 | struct zd_mac *mac; |
896 | struct ieee80211_hw *hw; | 890 | struct ieee80211_hw *hw; |
897 | int i; | ||
898 | 891 | ||
899 | hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); | 892 | hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); |
900 | if (!hw) { | 893 | if (!hw) { |
@@ -912,19 +905,14 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) | |||
912 | 905 | ||
913 | memcpy(mac->channels, zd_channels, sizeof(zd_channels)); | 906 | memcpy(mac->channels, zd_channels, sizeof(zd_channels)); |
914 | memcpy(mac->rates, zd_rates, sizeof(zd_rates)); | 907 | memcpy(mac->rates, zd_rates, sizeof(zd_rates)); |
915 | mac->modes[0].mode = MODE_IEEE80211G; | 908 | mac->band.n_bitrates = ARRAY_SIZE(zd_rates); |
916 | mac->modes[0].num_rates = ARRAY_SIZE(zd_rates); | 909 | mac->band.bitrates = mac->rates; |
917 | mac->modes[0].rates = mac->rates; | 910 | mac->band.n_channels = ARRAY_SIZE(zd_channels); |
918 | mac->modes[0].num_channels = ARRAY_SIZE(zd_channels); | 911 | mac->band.channels = mac->channels; |
919 | mac->modes[0].channels = mac->channels; | 912 | |
920 | mac->modes[1].mode = MODE_IEEE80211B; | 913 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; |
921 | mac->modes[1].num_rates = 4; | 914 | |
922 | mac->modes[1].rates = mac->rates; | 915 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS; |
923 | mac->modes[1].num_channels = ARRAY_SIZE(zd_channels); | ||
924 | mac->modes[1].channels = mac->channels; | ||
925 | |||
926 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | | ||
927 | IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; | ||
928 | hw->max_rssi = 100; | 916 | hw->max_rssi = 100; |
929 | hw->max_signal = 100; | 917 | hw->max_signal = 100; |
930 | 918 | ||
@@ -933,14 +921,6 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) | |||
933 | 921 | ||
934 | skb_queue_head_init(&mac->ack_wait_queue); | 922 | skb_queue_head_init(&mac->ack_wait_queue); |
935 | 923 | ||
936 | for (i = 0; i < 2; i++) { | ||
937 | if (ieee80211_register_hwmode(hw, &mac->modes[i])) { | ||
938 | dev_dbg_f(&intf->dev, "cannot register hwmode\n"); | ||
939 | ieee80211_free_hw(hw); | ||
940 | return NULL; | ||
941 | } | ||
942 | } | ||
943 | |||
944 | zd_chip_init(&mac->chip, hw, intf); | 924 | zd_chip_init(&mac->chip, hw, intf); |
945 | housekeeping_init(mac); | 925 | housekeeping_init(mac); |
946 | INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); | 926 | INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); |