diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2011-04-18 09:33:41 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-04-19 15:39:56 -0400 |
commit | 46a01ec00d05581c5bd0c37e680d5b37af4953b4 (patch) | |
tree | f5bca6d09ed4cb90f06e171b749356be691cbae6 /drivers | |
parent | ea81966ccc2edd324c1fa382260a62a4400a032a (diff) |
rt2x00: Merge rt2x00ht.c contents in other files.
The two functions that are in rt2x00ht.c can be much better placed
closer to the places where the call-sites of these functions are (one
in rt2x00config.c and one in rt2x00queue.c) allowing us to make these
functions static.
Also, conditional compilations doesn't seem to be necessary anymore as
802.11n support is quite common nowadays.
This makes the code a bit easier readable and searchable.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/Kconfig | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00config.c | 28 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00ht.c | 137 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00lib.h | 24 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 81 |
6 files changed, 108 insertions, 168 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index d7e27b348363..c45773108283 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig | |||
@@ -59,7 +59,6 @@ config RT2800PCI | |||
59 | select RT2800_LIB | 59 | select RT2800_LIB |
60 | select RT2X00_LIB_PCI if PCI | 60 | select RT2X00_LIB_PCI if PCI |
61 | select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X | 61 | select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X |
62 | select RT2X00_LIB_HT | ||
63 | select RT2X00_LIB_FIRMWARE | 62 | select RT2X00_LIB_FIRMWARE |
64 | select RT2X00_LIB_CRYPTO | 63 | select RT2X00_LIB_CRYPTO |
65 | select CRC_CCITT | 64 | select CRC_CCITT |
@@ -133,7 +132,6 @@ config RT2800USB | |||
133 | depends on USB | 132 | depends on USB |
134 | select RT2800_LIB | 133 | select RT2800_LIB |
135 | select RT2X00_LIB_USB | 134 | select RT2X00_LIB_USB |
136 | select RT2X00_LIB_HT | ||
137 | select RT2X00_LIB_FIRMWARE | 135 | select RT2X00_LIB_FIRMWARE |
138 | select RT2X00_LIB_CRYPTO | 136 | select RT2X00_LIB_CRYPTO |
139 | select CRC_CCITT | 137 | select CRC_CCITT |
@@ -196,9 +194,6 @@ config RT2X00_LIB_USB | |||
196 | config RT2X00_LIB | 194 | config RT2X00_LIB |
197 | tristate | 195 | tristate |
198 | 196 | ||
199 | config RT2X00_LIB_HT | ||
200 | boolean | ||
201 | |||
202 | config RT2X00_LIB_FIRMWARE | 197 | config RT2X00_LIB_FIRMWARE |
203 | boolean | 198 | boolean |
204 | select FW_LOADER | 199 | select FW_LOADER |
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile index 971339858297..349d5b8284a4 100644 --- a/drivers/net/wireless/rt2x00/Makefile +++ b/drivers/net/wireless/rt2x00/Makefile | |||
@@ -7,7 +7,6 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.o | |||
7 | rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o | 7 | rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o |
8 | rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o | 8 | rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o |
9 | rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o | 9 | rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o |
10 | rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2x00ht.o | ||
11 | 10 | ||
12 | obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o | 11 | obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o |
13 | obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o | 12 | obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o |
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index e225a66f59a0..f70a2b45d430 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c | |||
@@ -163,6 +163,34 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
163 | rt2x00queue_start_queue(rt2x00dev->rx); | 163 | rt2x00queue_start_queue(rt2x00dev->rx); |
164 | } | 164 | } |
165 | 165 | ||
166 | static u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev, | ||
167 | struct ieee80211_conf *conf) | ||
168 | { | ||
169 | struct hw_mode_spec *spec = &rt2x00dev->spec; | ||
170 | int center_channel; | ||
171 | u16 i; | ||
172 | |||
173 | /* | ||
174 | * Initialize center channel to current channel. | ||
175 | */ | ||
176 | center_channel = spec->channels[conf->channel->hw_value].channel; | ||
177 | |||
178 | /* | ||
179 | * Adjust center channel to HT40+ and HT40- operation. | ||
180 | */ | ||
181 | if (conf_is_ht40_plus(conf)) | ||
182 | center_channel += 2; | ||
183 | else if (conf_is_ht40_minus(conf)) | ||
184 | center_channel -= (center_channel == 14) ? 1 : 2; | ||
185 | |||
186 | for (i = 0; i < spec->num_channels; i++) | ||
187 | if (spec->channels[i].channel == center_channel) | ||
188 | return i; | ||
189 | |||
190 | WARN_ON(1); | ||
191 | return conf->channel->hw_value; | ||
192 | } | ||
193 | |||
166 | void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, | 194 | void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, |
167 | struct ieee80211_conf *conf, | 195 | struct ieee80211_conf *conf, |
168 | unsigned int ieee80211_flags) | 196 | unsigned int ieee80211_flags) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00ht.c b/drivers/net/wireless/rt2x00/rt2x00ht.c deleted file mode 100644 index a30f68c7fd7e..000000000000 --- a/drivers/net/wireless/rt2x00/rt2x00ht.c +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> | ||
3 | <http://rt2x00.serialmonkey.com> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the | ||
17 | Free Software Foundation, Inc., | ||
18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Module: rt2x00lib | ||
23 | Abstract: rt2x00 HT specific routines. | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | #include "rt2x00.h" | ||
30 | #include "rt2x00lib.h" | ||
31 | |||
32 | void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, | ||
33 | struct txentry_desc *txdesc, | ||
34 | const struct rt2x00_rate *hwrate) | ||
35 | { | ||
36 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); | ||
37 | struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0]; | ||
38 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; | ||
39 | |||
40 | if (tx_info->control.sta) | ||
41 | txdesc->u.ht.mpdu_density = | ||
42 | tx_info->control.sta->ht_cap.ampdu_density; | ||
43 | |||
44 | txdesc->u.ht.ba_size = 7; /* FIXME: What value is needed? */ | ||
45 | |||
46 | /* | ||
47 | * Only one STBC stream is supported for now. | ||
48 | */ | ||
49 | if (tx_info->flags & IEEE80211_TX_CTL_STBC) | ||
50 | txdesc->u.ht.stbc = 1; | ||
51 | |||
52 | /* | ||
53 | * If IEEE80211_TX_RC_MCS is set txrate->idx just contains the | ||
54 | * mcs rate to be used | ||
55 | */ | ||
56 | if (txrate->flags & IEEE80211_TX_RC_MCS) { | ||
57 | txdesc->u.ht.mcs = txrate->idx; | ||
58 | |||
59 | /* | ||
60 | * MIMO PS should be set to 1 for STA's using dynamic SM PS | ||
61 | * when using more then one tx stream (>MCS7). | ||
62 | */ | ||
63 | if (tx_info->control.sta && txdesc->u.ht.mcs > 7 && | ||
64 | ((tx_info->control.sta->ht_cap.cap & | ||
65 | IEEE80211_HT_CAP_SM_PS) >> | ||
66 | IEEE80211_HT_CAP_SM_PS_SHIFT) == | ||
67 | WLAN_HT_CAP_SM_PS_DYNAMIC) | ||
68 | __set_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags); | ||
69 | } else { | ||
70 | txdesc->u.ht.mcs = rt2x00_get_rate_mcs(hwrate->mcs); | ||
71 | if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) | ||
72 | txdesc->u.ht.mcs |= 0x08; | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * This frame is eligible for an AMPDU, however, don't aggregate | ||
77 | * frames that are intended to probe a specific tx rate. | ||
78 | */ | ||
79 | if (tx_info->flags & IEEE80211_TX_CTL_AMPDU && | ||
80 | !(tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) | ||
81 | __set_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags); | ||
82 | |||
83 | /* | ||
84 | * Set 40Mhz mode if necessary (for legacy rates this will | ||
85 | * duplicate the frame to both channels). | ||
86 | */ | ||
87 | if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH || | ||
88 | txrate->flags & IEEE80211_TX_RC_DUP_DATA) | ||
89 | __set_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags); | ||
90 | if (txrate->flags & IEEE80211_TX_RC_SHORT_GI) | ||
91 | __set_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags); | ||
92 | |||
93 | /* | ||
94 | * Determine IFS values | ||
95 | * - Use TXOP_BACKOFF for management frames except beacons | ||
96 | * - Use TXOP_SIFS for fragment bursts | ||
97 | * - Use TXOP_HTTXOP for everything else | ||
98 | * | ||
99 | * Note: rt2800 devices won't use CTS protection (if used) | ||
100 | * for frames not transmitted with TXOP_HTTXOP | ||
101 | */ | ||
102 | if (ieee80211_is_mgmt(hdr->frame_control) && | ||
103 | !ieee80211_is_beacon(hdr->frame_control)) | ||
104 | txdesc->u.ht.txop = TXOP_BACKOFF; | ||
105 | else if (!(tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)) | ||
106 | txdesc->u.ht.txop = TXOP_SIFS; | ||
107 | else | ||
108 | txdesc->u.ht.txop = TXOP_HTTXOP; | ||
109 | } | ||
110 | |||
111 | u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev, | ||
112 | struct ieee80211_conf *conf) | ||
113 | { | ||
114 | struct hw_mode_spec *spec = &rt2x00dev->spec; | ||
115 | int center_channel; | ||
116 | u16 i; | ||
117 | |||
118 | /* | ||
119 | * Initialize center channel to current channel. | ||
120 | */ | ||
121 | center_channel = spec->channels[conf->channel->hw_value].channel; | ||
122 | |||
123 | /* | ||
124 | * Adjust center channel to HT40+ and HT40- operation. | ||
125 | */ | ||
126 | if (conf_is_ht40_plus(conf)) | ||
127 | center_channel += 2; | ||
128 | else if (conf_is_ht40_minus(conf)) | ||
129 | center_channel -= (center_channel == 14) ? 1 : 2; | ||
130 | |||
131 | for (i = 0; i < spec->num_channels; i++) | ||
132 | if (spec->channels[i].channel == center_channel) | ||
133 | return i; | ||
134 | |||
135 | WARN_ON(1); | ||
136 | return conf->channel->hw_value; | ||
137 | } | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 57ede6ccf40c..322cc4f3de5d 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h | |||
@@ -388,30 +388,6 @@ static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, | |||
388 | #endif /* CONFIG_RT2X00_LIB_CRYPTO */ | 388 | #endif /* CONFIG_RT2X00_LIB_CRYPTO */ |
389 | 389 | ||
390 | /* | 390 | /* |
391 | * HT handlers. | ||
392 | */ | ||
393 | #ifdef CONFIG_RT2X00_LIB_HT | ||
394 | void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, | ||
395 | struct txentry_desc *txdesc, | ||
396 | const struct rt2x00_rate *hwrate); | ||
397 | |||
398 | u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev, | ||
399 | struct ieee80211_conf *conf); | ||
400 | #else | ||
401 | static inline void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, | ||
402 | struct txentry_desc *txdesc, | ||
403 | const struct rt2x00_rate *hwrate) | ||
404 | { | ||
405 | } | ||
406 | |||
407 | static inline u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev, | ||
408 | struct ieee80211_conf *conf) | ||
409 | { | ||
410 | return conf->channel->hw_value; | ||
411 | } | ||
412 | #endif /* CONFIG_RT2X00_LIB_HT */ | ||
413 | |||
414 | /* | ||
415 | * RFkill handlers. | 391 | * RFkill handlers. |
416 | */ | 392 | */ |
417 | static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) | 393 | static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index 0d79278a0a19..56f9d0df9c61 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -302,6 +302,85 @@ static void rt2x00queue_create_tx_descriptor_plcp(struct queue_entry *entry, | |||
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | static void rt2x00queue_create_tx_descriptor_ht(struct queue_entry *entry, | ||
306 | struct txentry_desc *txdesc, | ||
307 | const struct rt2x00_rate *hwrate) | ||
308 | { | ||
309 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); | ||
310 | struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0]; | ||
311 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; | ||
312 | |||
313 | if (tx_info->control.sta) | ||
314 | txdesc->u.ht.mpdu_density = | ||
315 | tx_info->control.sta->ht_cap.ampdu_density; | ||
316 | |||
317 | txdesc->u.ht.ba_size = 7; /* FIXME: What value is needed? */ | ||
318 | |||
319 | /* | ||
320 | * Only one STBC stream is supported for now. | ||
321 | */ | ||
322 | if (tx_info->flags & IEEE80211_TX_CTL_STBC) | ||
323 | txdesc->u.ht.stbc = 1; | ||
324 | |||
325 | /* | ||
326 | * If IEEE80211_TX_RC_MCS is set txrate->idx just contains the | ||
327 | * mcs rate to be used | ||
328 | */ | ||
329 | if (txrate->flags & IEEE80211_TX_RC_MCS) { | ||
330 | txdesc->u.ht.mcs = txrate->idx; | ||
331 | |||
332 | /* | ||
333 | * MIMO PS should be set to 1 for STA's using dynamic SM PS | ||
334 | * when using more then one tx stream (>MCS7). | ||
335 | */ | ||
336 | if (tx_info->control.sta && txdesc->u.ht.mcs > 7 && | ||
337 | ((tx_info->control.sta->ht_cap.cap & | ||
338 | IEEE80211_HT_CAP_SM_PS) >> | ||
339 | IEEE80211_HT_CAP_SM_PS_SHIFT) == | ||
340 | WLAN_HT_CAP_SM_PS_DYNAMIC) | ||
341 | __set_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags); | ||
342 | } else { | ||
343 | txdesc->u.ht.mcs = rt2x00_get_rate_mcs(hwrate->mcs); | ||
344 | if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) | ||
345 | txdesc->u.ht.mcs |= 0x08; | ||
346 | } | ||
347 | |||
348 | /* | ||
349 | * This frame is eligible for an AMPDU, however, don't aggregate | ||
350 | * frames that are intended to probe a specific tx rate. | ||
351 | */ | ||
352 | if (tx_info->flags & IEEE80211_TX_CTL_AMPDU && | ||
353 | !(tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) | ||
354 | __set_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags); | ||
355 | |||
356 | /* | ||
357 | * Set 40Mhz mode if necessary (for legacy rates this will | ||
358 | * duplicate the frame to both channels). | ||
359 | */ | ||
360 | if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH || | ||
361 | txrate->flags & IEEE80211_TX_RC_DUP_DATA) | ||
362 | __set_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags); | ||
363 | if (txrate->flags & IEEE80211_TX_RC_SHORT_GI) | ||
364 | __set_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags); | ||
365 | |||
366 | /* | ||
367 | * Determine IFS values | ||
368 | * - Use TXOP_BACKOFF for management frames except beacons | ||
369 | * - Use TXOP_SIFS for fragment bursts | ||
370 | * - Use TXOP_HTTXOP for everything else | ||
371 | * | ||
372 | * Note: rt2800 devices won't use CTS protection (if used) | ||
373 | * for frames not transmitted with TXOP_HTTXOP | ||
374 | */ | ||
375 | if (ieee80211_is_mgmt(hdr->frame_control) && | ||
376 | !ieee80211_is_beacon(hdr->frame_control)) | ||
377 | txdesc->u.ht.txop = TXOP_BACKOFF; | ||
378 | else if (!(tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)) | ||
379 | txdesc->u.ht.txop = TXOP_SIFS; | ||
380 | else | ||
381 | txdesc->u.ht.txop = TXOP_HTTXOP; | ||
382 | } | ||
383 | |||
305 | static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, | 384 | static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, |
306 | struct txentry_desc *txdesc) | 385 | struct txentry_desc *txdesc) |
307 | { | 386 | { |
@@ -397,7 +476,7 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, | |||
397 | rt2x00queue_create_tx_descriptor_seq(entry, txdesc); | 476 | rt2x00queue_create_tx_descriptor_seq(entry, txdesc); |
398 | 477 | ||
399 | if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags)) | 478 | if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags)) |
400 | rt2x00ht_create_tx_descriptor(entry, txdesc, hwrate); | 479 | rt2x00queue_create_tx_descriptor_ht(entry, txdesc, hwrate); |
401 | else | 480 | else |
402 | rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate); | 481 | rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate); |
403 | } | 482 | } |