aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 13:38:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:32 -0500
commit8318d78a44d49ac1edf2bdec7299de3617c4232e (patch)
treed434634418edd7399737801615d247be06616fdd /drivers/net/wireless/zd1211rw
parent10b6b80145cc93887dd8aab99bfffa375e9add31 (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')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c15
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c11
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c170
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h2
4 files changed, 85 insertions, 113 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 99e5b03b3f51..e3fba6f09455 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -986,7 +986,7 @@ static int print_fw_version(struct zd_chip *chip)
986 return 0; 986 return 0;
987} 987}
988 988
989static int set_mandatory_rates(struct zd_chip *chip, int mode) 989static int set_mandatory_rates(struct zd_chip *chip, int gmode)
990{ 990{
991 u32 rates; 991 u32 rates;
992 ZD_ASSERT(mutex_is_locked(&chip->mutex)); 992 ZD_ASSERT(mutex_is_locked(&chip->mutex));
@@ -994,17 +994,12 @@ static int set_mandatory_rates(struct zd_chip *chip, int mode)
994 * that the device is supporting. Until further notice we should try 994 * that the device is supporting. Until further notice we should try
995 * to support 802.11g also for full speed USB. 995 * to support 802.11g also for full speed USB.
996 */ 996 */
997 switch (mode) { 997 if (!gmode)
998 case MODE_IEEE80211B:
999 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M; 998 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M;
1000 break; 999 else
1001 case MODE_IEEE80211G:
1002 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M| 1000 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M|
1003 CR_RATE_6M|CR_RATE_12M|CR_RATE_24M; 1001 CR_RATE_6M|CR_RATE_12M|CR_RATE_24M;
1004 break; 1002
1005 default:
1006 return -EINVAL;
1007 }
1008 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); 1003 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL);
1009} 1004}
1010 1005
@@ -1108,7 +1103,7 @@ int zd_chip_init_hw(struct zd_chip *chip)
1108 * It might be discussed, whether we should suppport pure b mode for 1103 * It might be discussed, whether we should suppport pure b mode for
1109 * full speed USB. 1104 * full speed USB.
1110 */ 1105 */
1111 r = set_mandatory_rates(chip, MODE_IEEE80211G); 1106 r = set_mandatory_rates(chip, 1);
1112 if (r) 1107 if (r)
1113 goto out; 1108 goto out;
1114 /* Disabling interrupts is certainly a smart thing here. 1109 /* Disabling interrupts is certainly a smart thing here.
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
index 7c277ec43f79..d8dc41ec0e5d 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
@@ -65,16 +65,14 @@ static const struct channel_range *zd_channel_range(u8 regdomain)
65 65
66static void unmask_bg_channels(struct ieee80211_hw *hw, 66static void unmask_bg_channels(struct ieee80211_hw *hw,
67 const struct channel_range *range, 67 const struct channel_range *range,
68 struct ieee80211_hw_mode *mode) 68 struct ieee80211_supported_band *sband)
69{ 69{
70 u8 channel; 70 u8 channel;
71 71
72 for (channel = range->start; channel < range->end; channel++) { 72 for (channel = range->start; channel < range->end; channel++) {
73 struct ieee80211_channel *chan = 73 struct ieee80211_channel *chan =
74 &mode->channels[CHAN_TO_IDX(channel)]; 74 &sband->channels[CHAN_TO_IDX(channel)];
75 chan->flag |= IEEE80211_CHAN_W_SCAN | 75 chan->flags = 0;
76 IEEE80211_CHAN_W_ACTIVE_SCAN |
77 IEEE80211_CHAN_W_IBSS;
78 } 76 }
79} 77}
80 78
@@ -97,7 +95,6 @@ void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain)
97 range = zd_channel_range(ZD_REGDOMAIN_FCC); 95 range = zd_channel_range(ZD_REGDOMAIN_FCC);
98 } 96 }
99 97
100 unmask_bg_channels(hw, range, &mac->modes[0]); 98 unmask_bg_channels(hw, range, &mac->band);
101 unmask_bg_channels(hw, range, &mac->modes[1]);
102} 99}
103 100
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 76ef2d83919d..21b653458831 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. */
36static const struct ieee80211_rate zd_rates[] = { 36static 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
78static const struct ieee80211_channel zd_channels[] = { 77static 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
109static void housekeeping_init(struct zd_mac *mac); 94static 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,
736static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 730static 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
742static int zd_op_config_interface(struct ieee80211_hw *hw, 736static 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);
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 2dde108df767..67dea9739c8f 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -185,7 +185,7 @@ struct zd_mac {
185 struct sk_buff_head ack_wait_queue; 185 struct sk_buff_head ack_wait_queue;
186 struct ieee80211_channel channels[14]; 186 struct ieee80211_channel channels[14];
187 struct ieee80211_rate rates[12]; 187 struct ieee80211_rate rates[12];
188 struct ieee80211_hw_mode modes[2]; 188 struct ieee80211_supported_band band;
189 189
190 /* Short preamble (used for RTS/CTS) */ 190 /* Short preamble (used for RTS/CTS) */
191 unsigned int short_preamble:1; 191 unsigned int short_preamble:1;