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/b43/main.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/b43/main.c')
-rw-r--r-- | drivers/net/wireless/b43/main.c | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 51dfce16178a..017a041d07d0 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -96,25 +96,29 @@ MODULE_DEVICE_TABLE(ssb, b43_ssb_tbl); | |||
96 | * data in there. This data is the same for all devices, so we don't | 96 | * data in there. This data is the same for all devices, so we don't |
97 | * get concurrency issues */ | 97 | * get concurrency issues */ |
98 | #define RATETAB_ENT(_rateid, _flags) \ | 98 | #define RATETAB_ENT(_rateid, _flags) \ |
99 | { \ | 99 | { \ |
100 | .rate = B43_RATE_TO_BASE100KBPS(_rateid), \ | 100 | .bitrate = B43_RATE_TO_BASE100KBPS(_rateid), \ |
101 | .val = (_rateid), \ | 101 | .hw_value = (_rateid), \ |
102 | .val2 = (_rateid), \ | 102 | .flags = (_flags), \ |
103 | .flags = (_flags), \ | ||
104 | } | 103 | } |
104 | |||
105 | /* | ||
106 | * NOTE: When changing this, sync with xmit.c's | ||
107 | * b43_plcp_get_bitrate_idx_* functions! | ||
108 | */ | ||
105 | static struct ieee80211_rate __b43_ratetable[] = { | 109 | static struct ieee80211_rate __b43_ratetable[] = { |
106 | RATETAB_ENT(B43_CCK_RATE_1MB, IEEE80211_RATE_CCK), | 110 | RATETAB_ENT(B43_CCK_RATE_1MB, 0), |
107 | RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_CCK_2), | 111 | RATETAB_ENT(B43_CCK_RATE_2MB, IEEE80211_RATE_SHORT_PREAMBLE), |
108 | RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_CCK_2), | 112 | RATETAB_ENT(B43_CCK_RATE_5MB, IEEE80211_RATE_SHORT_PREAMBLE), |
109 | RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_CCK_2), | 113 | RATETAB_ENT(B43_CCK_RATE_11MB, IEEE80211_RATE_SHORT_PREAMBLE), |
110 | RATETAB_ENT(B43_OFDM_RATE_6MB, IEEE80211_RATE_OFDM), | 114 | RATETAB_ENT(B43_OFDM_RATE_6MB, 0), |
111 | RATETAB_ENT(B43_OFDM_RATE_9MB, IEEE80211_RATE_OFDM), | 115 | RATETAB_ENT(B43_OFDM_RATE_9MB, 0), |
112 | RATETAB_ENT(B43_OFDM_RATE_12MB, IEEE80211_RATE_OFDM), | 116 | RATETAB_ENT(B43_OFDM_RATE_12MB, 0), |
113 | RATETAB_ENT(B43_OFDM_RATE_18MB, IEEE80211_RATE_OFDM), | 117 | RATETAB_ENT(B43_OFDM_RATE_18MB, 0), |
114 | RATETAB_ENT(B43_OFDM_RATE_24MB, IEEE80211_RATE_OFDM), | 118 | RATETAB_ENT(B43_OFDM_RATE_24MB, 0), |
115 | RATETAB_ENT(B43_OFDM_RATE_36MB, IEEE80211_RATE_OFDM), | 119 | RATETAB_ENT(B43_OFDM_RATE_36MB, 0), |
116 | RATETAB_ENT(B43_OFDM_RATE_48MB, IEEE80211_RATE_OFDM), | 120 | RATETAB_ENT(B43_OFDM_RATE_48MB, 0), |
117 | RATETAB_ENT(B43_OFDM_RATE_54MB, IEEE80211_RATE_OFDM), | 121 | RATETAB_ENT(B43_OFDM_RATE_54MB, 0), |
118 | }; | 122 | }; |
119 | 123 | ||
120 | #define b43_a_ratetable (__b43_ratetable + 4) | 124 | #define b43_a_ratetable (__b43_ratetable + 4) |
@@ -126,14 +130,8 @@ static struct ieee80211_rate __b43_ratetable[] = { | |||
126 | 130 | ||
127 | #define CHANTAB_ENT(_chanid, _freq) \ | 131 | #define CHANTAB_ENT(_chanid, _freq) \ |
128 | { \ | 132 | { \ |
129 | .chan = (_chanid), \ | 133 | .center_freq = (_freq), \ |
130 | .freq = (_freq), \ | 134 | .hw_value = (_chanid), \ |
131 | .val = (_chanid), \ | ||
132 | .flag = IEEE80211_CHAN_W_SCAN | \ | ||
133 | IEEE80211_CHAN_W_ACTIVE_SCAN | \ | ||
134 | IEEE80211_CHAN_W_IBSS, \ | ||
135 | .power_level = 0xFF, \ | ||
136 | .antenna_max = 0xFF, \ | ||
137 | } | 135 | } |
138 | static struct ieee80211_channel b43_2ghz_chantable[] = { | 136 | static struct ieee80211_channel b43_2ghz_chantable[] = { |
139 | CHANTAB_ENT(1, 2412), | 137 | CHANTAB_ENT(1, 2412), |
@@ -151,9 +149,8 @@ static struct ieee80211_channel b43_2ghz_chantable[] = { | |||
151 | CHANTAB_ENT(13, 2472), | 149 | CHANTAB_ENT(13, 2472), |
152 | CHANTAB_ENT(14, 2484), | 150 | CHANTAB_ENT(14, 2484), |
153 | }; | 151 | }; |
154 | #define b43_2ghz_chantable_size ARRAY_SIZE(b43_2ghz_chantable) | ||
155 | 152 | ||
156 | #if 0 | 153 | #ifdef NOTYET |
157 | static struct ieee80211_channel b43_5ghz_chantable[] = { | 154 | static struct ieee80211_channel b43_5ghz_chantable[] = { |
158 | CHANTAB_ENT(36, 5180), | 155 | CHANTAB_ENT(36, 5180), |
159 | CHANTAB_ENT(40, 5200), | 156 | CHANTAB_ENT(40, 5200), |
@@ -169,9 +166,22 @@ static struct ieee80211_channel b43_5ghz_chantable[] = { | |||
169 | CHANTAB_ENT(161, 5805), | 166 | CHANTAB_ENT(161, 5805), |
170 | CHANTAB_ENT(165, 5825), | 167 | CHANTAB_ENT(165, 5825), |
171 | }; | 168 | }; |
172 | #define b43_5ghz_chantable_size ARRAY_SIZE(b43_5ghz_chantable) | 169 | |
170 | static struct ieee80211_supported_band b43_band_5GHz = { | ||
171 | .channels = b43_5ghz_chantable, | ||
172 | .n_channels = ARRAY_SIZE(b43_5ghz_chantable), | ||
173 | .bitrates = b43_a_ratetable, | ||
174 | .n_bitrates = b43_a_ratetable_size, | ||
175 | }; | ||
173 | #endif | 176 | #endif |
174 | 177 | ||
178 | static struct ieee80211_supported_band b43_band_2GHz = { | ||
179 | .channels = b43_2ghz_chantable, | ||
180 | .n_channels = ARRAY_SIZE(b43_2ghz_chantable), | ||
181 | .bitrates = b43_g_ratetable, | ||
182 | .n_bitrates = b43_g_ratetable_size, | ||
183 | }; | ||
184 | |||
175 | static void b43_wireless_core_exit(struct b43_wldev *dev); | 185 | static void b43_wireless_core_exit(struct b43_wldev *dev); |
176 | static int b43_wireless_core_init(struct b43_wldev *dev); | 186 | static int b43_wireless_core_init(struct b43_wldev *dev); |
177 | static void b43_wireless_core_stop(struct b43_wldev *dev); | 187 | static void b43_wireless_core_stop(struct b43_wldev *dev); |
@@ -1222,17 +1232,18 @@ static void b43_write_beacon_template(struct b43_wldev *dev, | |||
1222 | } | 1232 | } |
1223 | 1233 | ||
1224 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, | 1234 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, |
1225 | u16 shm_offset, u16 size, u8 rate) | 1235 | u16 shm_offset, u16 size, |
1236 | struct ieee80211_rate *rate) | ||
1226 | { | 1237 | { |
1227 | struct b43_plcp_hdr4 plcp; | 1238 | struct b43_plcp_hdr4 plcp; |
1228 | u32 tmp; | 1239 | u32 tmp; |
1229 | __le16 dur; | 1240 | __le16 dur; |
1230 | 1241 | ||
1231 | plcp.data = 0; | 1242 | plcp.data = 0; |
1232 | b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate); | 1243 | b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->hw_value); |
1233 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 1244 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
1234 | dev->wl->vif, size, | 1245 | dev->wl->vif, size, |
1235 | B43_RATE_TO_BASE100KBPS(rate)); | 1246 | rate); |
1236 | /* Write PLCP in two parts and timing for packet transfer */ | 1247 | /* Write PLCP in two parts and timing for packet transfer */ |
1237 | tmp = le32_to_cpu(plcp.data); | 1248 | tmp = le32_to_cpu(plcp.data); |
1238 | b43_shm_write16(dev, B43_SHM_SHARED, shm_offset, tmp & 0xFFFF); | 1249 | b43_shm_write16(dev, B43_SHM_SHARED, shm_offset, tmp & 0xFFFF); |
@@ -1247,7 +1258,8 @@ static void b43_write_probe_resp_plcp(struct b43_wldev *dev, | |||
1247 | * 3) Stripping TIM | 1258 | * 3) Stripping TIM |
1248 | */ | 1259 | */ |
1249 | static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | 1260 | static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, |
1250 | u16 *dest_size, u8 rate) | 1261 | u16 *dest_size, |
1262 | struct ieee80211_rate *rate) | ||
1251 | { | 1263 | { |
1252 | const u8 *src_data; | 1264 | const u8 *src_data; |
1253 | u8 *dest_data; | 1265 | u8 *dest_data; |
@@ -1292,7 +1304,7 @@ static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | |||
1292 | IEEE80211_STYPE_PROBE_RESP); | 1304 | IEEE80211_STYPE_PROBE_RESP); |
1293 | dur = ieee80211_generic_frame_duration(dev->wl->hw, | 1305 | dur = ieee80211_generic_frame_duration(dev->wl->hw, |
1294 | dev->wl->vif, *dest_size, | 1306 | dev->wl->vif, *dest_size, |
1295 | B43_RATE_TO_BASE100KBPS(rate)); | 1307 | rate); |
1296 | hdr->duration_id = dur; | 1308 | hdr->duration_id = dur; |
1297 | 1309 | ||
1298 | return dest_data; | 1310 | return dest_data; |
@@ -1300,7 +1312,8 @@ static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, | |||
1300 | 1312 | ||
1301 | static void b43_write_probe_resp_template(struct b43_wldev *dev, | 1313 | static void b43_write_probe_resp_template(struct b43_wldev *dev, |
1302 | u16 ram_offset, | 1314 | u16 ram_offset, |
1303 | u16 shm_size_offset, u8 rate) | 1315 | u16 shm_size_offset, |
1316 | struct ieee80211_rate *rate) | ||
1304 | { | 1317 | { |
1305 | const u8 *probe_resp_data; | 1318 | const u8 *probe_resp_data; |
1306 | u16 size; | 1319 | u16 size; |
@@ -1313,14 +1326,15 @@ static void b43_write_probe_resp_template(struct b43_wldev *dev, | |||
1313 | /* Looks like PLCP headers plus packet timings are stored for | 1326 | /* Looks like PLCP headers plus packet timings are stored for |
1314 | * all possible basic rates | 1327 | * all possible basic rates |
1315 | */ | 1328 | */ |
1316 | b43_write_probe_resp_plcp(dev, 0x31A, size, B43_CCK_RATE_1MB); | 1329 | b43_write_probe_resp_plcp(dev, 0x31A, size, &b43_b_ratetable[0]); |
1317 | b43_write_probe_resp_plcp(dev, 0x32C, size, B43_CCK_RATE_2MB); | 1330 | b43_write_probe_resp_plcp(dev, 0x32C, size, &b43_b_ratetable[1]); |
1318 | b43_write_probe_resp_plcp(dev, 0x33E, size, B43_CCK_RATE_5MB); | 1331 | b43_write_probe_resp_plcp(dev, 0x33E, size, &b43_b_ratetable[2]); |
1319 | b43_write_probe_resp_plcp(dev, 0x350, size, B43_CCK_RATE_11MB); | 1332 | b43_write_probe_resp_plcp(dev, 0x350, size, &b43_b_ratetable[3]); |
1320 | 1333 | ||
1321 | size = min((size_t) size, 0x200 - sizeof(struct b43_plcp_hdr6)); | 1334 | size = min((size_t) size, 0x200 - sizeof(struct b43_plcp_hdr6)); |
1322 | b43_write_template_common(dev, probe_resp_data, | 1335 | b43_write_template_common(dev, probe_resp_data, |
1323 | size, ram_offset, shm_size_offset, rate); | 1336 | size, ram_offset, shm_size_offset, |
1337 | rate->hw_value); | ||
1324 | kfree(probe_resp_data); | 1338 | kfree(probe_resp_data); |
1325 | } | 1339 | } |
1326 | 1340 | ||
@@ -1388,7 +1402,7 @@ static void handle_irq_beacon(struct b43_wldev *dev) | |||
1388 | b43_write_beacon_template(dev, 0x68, 0x18, | 1402 | b43_write_beacon_template(dev, 0x68, 0x18, |
1389 | B43_CCK_RATE_1MB); | 1403 | B43_CCK_RATE_1MB); |
1390 | b43_write_probe_resp_template(dev, 0x268, 0x4A, | 1404 | b43_write_probe_resp_template(dev, 0x268, 0x4A, |
1391 | B43_CCK_RATE_11MB); | 1405 | &__b43_ratetable[3]); |
1392 | wl->beacon0_uploaded = 1; | 1406 | wl->beacon0_uploaded = 1; |
1393 | } | 1407 | } |
1394 | cmd |= B43_MACCMD_BEACON0_VALID; | 1408 | cmd |= B43_MACCMD_BEACON0_VALID; |
@@ -2830,14 +2844,11 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | |||
2830 | mutex_lock(&wl->mutex); | 2844 | mutex_lock(&wl->mutex); |
2831 | 2845 | ||
2832 | /* Switch the PHY mode (if necessary). */ | 2846 | /* Switch the PHY mode (if necessary). */ |
2833 | switch (conf->phymode) { | 2847 | switch (conf->channel->band) { |
2834 | case MODE_IEEE80211A: | 2848 | case IEEE80211_BAND_5GHZ: |
2835 | new_phymode = B43_PHYMODE_A; | 2849 | new_phymode = B43_PHYMODE_A; |
2836 | break; | 2850 | break; |
2837 | case MODE_IEEE80211B: | 2851 | case IEEE80211_BAND_2GHZ: |
2838 | new_phymode = B43_PHYMODE_B; | ||
2839 | break; | ||
2840 | case MODE_IEEE80211G: | ||
2841 | new_phymode = B43_PHYMODE_G; | 2852 | new_phymode = B43_PHYMODE_G; |
2842 | break; | 2853 | break; |
2843 | default: | 2854 | default: |
@@ -2863,8 +2874,8 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | |||
2863 | 2874 | ||
2864 | /* Switch to the requested channel. | 2875 | /* Switch to the requested channel. |
2865 | * The firmware takes care of races with the TX handler. */ | 2876 | * The firmware takes care of races with the TX handler. */ |
2866 | if (conf->channel_val != phy->channel) | 2877 | if (conf->channel->hw_value != phy->channel) |
2867 | b43_radio_selectchannel(dev, conf->channel_val, 0); | 2878 | b43_radio_selectchannel(dev, conf->channel->hw_value, 0); |
2868 | 2879 | ||
2869 | /* Enable/Disable ShortSlot timing. */ | 2880 | /* Enable/Disable ShortSlot timing. */ |
2870 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) != | 2881 | if ((!!(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)) != |
@@ -3810,9 +3821,7 @@ static int b43_setup_modes(struct b43_wldev *dev, | |||
3810 | bool have_2ghz_phy, bool have_5ghz_phy) | 3821 | bool have_2ghz_phy, bool have_5ghz_phy) |
3811 | { | 3822 | { |
3812 | struct ieee80211_hw *hw = dev->wl->hw; | 3823 | struct ieee80211_hw *hw = dev->wl->hw; |
3813 | struct ieee80211_hw_mode *mode; | ||
3814 | struct b43_phy *phy = &dev->phy; | 3824 | struct b43_phy *phy = &dev->phy; |
3815 | int err; | ||
3816 | 3825 | ||
3817 | /* XXX: This function will go away soon, when mac80211 | 3826 | /* XXX: This function will go away soon, when mac80211 |
3818 | * band stuff is rewritten. So this is just a hack. | 3827 | * band stuff is rewritten. So this is just a hack. |
@@ -3821,15 +3830,7 @@ static int b43_setup_modes(struct b43_wldev *dev, | |||
3821 | * This assumption is OK, as any B, N or A PHY will already | 3830 | * This assumption is OK, as any B, N or A PHY will already |
3822 | * have died a horrible sanity check death earlier. */ | 3831 | * have died a horrible sanity check death earlier. */ |
3823 | 3832 | ||
3824 | mode = &phy->hwmodes[0]; | 3833 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &b43_band_2GHz; |
3825 | mode->mode = MODE_IEEE80211G; | ||
3826 | mode->num_channels = b43_2ghz_chantable_size; | ||
3827 | mode->channels = b43_2ghz_chantable; | ||
3828 | mode->num_rates = b43_g_ratetable_size; | ||
3829 | mode->rates = b43_g_ratetable; | ||
3830 | err = ieee80211_register_hwmode(hw, mode); | ||
3831 | if (err) | ||
3832 | return err; | ||
3833 | phy->possible_phymodes |= B43_PHYMODE_G; | 3834 | phy->possible_phymodes |= B43_PHYMODE_G; |
3834 | 3835 | ||
3835 | return 0; | 3836 | return 0; |