aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-03-25 09:13:18 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-03-25 16:42:00 -0400
commit3a643d244f09fa1fdd25d48a56a073c1a69583ee (patch)
tree3cd8423f72f37d66fdd2738409f72779da3911fc /drivers
parent866a05038481d77cac6fc0186250b4c44e691b42 (diff)
rt2x00: Fix in_atomic() usage
rt73usb and rt2500usb used in_atomic to determine if a configuration step should be rescheduled or not. Since in_atomic() is not a valid method to determine if sleeping is allowed we should fix the way this is handled by adding a new flag to rt2x00. In addition mark LED class support for the drivers broken since that also uses the broken in_atomic() method but so far no solution exists to have LED triggers work only in scheduled context. 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/Kconfig4
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c92
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c101
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c118
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c10
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c57
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c105
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c122
9 files changed, 234 insertions, 386 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 4709c11da419..ad1549592c00 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -134,7 +134,7 @@ config RT2500USB
134 134
135config RT2500USB_LEDS 135config RT2500USB_LEDS
136 bool "RT2500 leds support" 136 bool "RT2500 leds support"
137 depends on RT2500USB 137 depends on RT2500USB && BROKEN
138 select RT2X00_LIB_LEDS 138 select RT2X00_LIB_LEDS
139 ---help--- 139 ---help---
140 This adds support for led triggers provided my mac80211. 140 This adds support for led triggers provided my mac80211.
@@ -152,7 +152,7 @@ config RT73USB
152 152
153config RT73USB_LEDS 153config RT73USB_LEDS
154 bool "RT73 leds support" 154 bool "RT73 leds support"
155 depends on RT73USB 155 depends on RT73USB && BROKEN
156 select RT2X00_LIB_LEDS 156 select RT2X00_LIB_LEDS
157 ---help--- 157 ---help---
158 This adds support for led triggers provided my mac80211. 158 This adds support for led triggers provided my mac80211.
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index c58b1c0abc3c..a6e9c89c802a 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -270,6 +270,31 @@ static void rt2400pci_led_brightness(struct led_classdev *led_cdev,
270/* 270/*
271 * Configuration handlers. 271 * Configuration handlers.
272 */ 272 */
273static void rt2400pci_config_filter(struct rt2x00_dev *rt2x00dev,
274 const unsigned int filter_flags)
275{
276 u32 reg;
277
278 /*
279 * Start configuration steps.
280 * Note that the version error will always be dropped
281 * since there is no filter for it at this time.
282 */
283 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
284 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
285 !(filter_flags & FIF_FCSFAIL));
286 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
287 !(filter_flags & FIF_PLCPFAIL));
288 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
289 !(filter_flags & FIF_CONTROL));
290 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
291 !(filter_flags & FIF_PROMISC_IN_BSS));
292 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
293 !(filter_flags & FIF_PROMISC_IN_BSS));
294 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
295 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
296}
297
273static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev, 298static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev,
274 struct rt2x00_intf *intf, 299 struct rt2x00_intf *intf,
275 struct rt2x00intf_conf *conf, 300 struct rt2x00intf_conf *conf,
@@ -306,8 +331,8 @@ static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev,
306 conf->bssid, sizeof(conf->bssid)); 331 conf->bssid, sizeof(conf->bssid));
307} 332}
308 333
309static int rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev, 334static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
310 struct rt2x00lib_erp *erp) 335 struct rt2x00lib_erp *erp)
311{ 336{
312 int preamble_mask; 337 int preamble_mask;
313 u32 reg; 338 u32 reg;
@@ -347,8 +372,6 @@ static int rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
347 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 372 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
348 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 373 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
349 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 374 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
350
351 return 0;
352} 375}
353 376
354static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev, 377static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1397,64 +1420,6 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1397/* 1420/*
1398 * IEEE80211 stack callback functions. 1421 * IEEE80211 stack callback functions.
1399 */ 1422 */
1400static void rt2400pci_configure_filter(struct ieee80211_hw *hw,
1401 unsigned int changed_flags,
1402 unsigned int *total_flags,
1403 int mc_count,
1404 struct dev_addr_list *mc_list)
1405{
1406 struct rt2x00_dev *rt2x00dev = hw->priv;
1407 u32 reg;
1408
1409 /*
1410 * Mask off any flags we are going to ignore from
1411 * the total_flags field.
1412 */
1413 *total_flags &=
1414 FIF_ALLMULTI |
1415 FIF_FCSFAIL |
1416 FIF_PLCPFAIL |
1417 FIF_CONTROL |
1418 FIF_OTHER_BSS |
1419 FIF_PROMISC_IN_BSS;
1420
1421 /*
1422 * Apply some rules to the filters:
1423 * - Some filters imply different filters to be set.
1424 * - Some things we can't filter out at all.
1425 */
1426 *total_flags |= FIF_ALLMULTI;
1427 if (*total_flags & FIF_OTHER_BSS ||
1428 *total_flags & FIF_PROMISC_IN_BSS)
1429 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1430
1431 /*
1432 * Check if there is any work left for us.
1433 */
1434 if (rt2x00dev->packet_filter == *total_flags)
1435 return;
1436 rt2x00dev->packet_filter = *total_flags;
1437
1438 /*
1439 * Start configuration steps.
1440 * Note that the version error will always be dropped
1441 * since there is no filter for it at this time.
1442 */
1443 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1444 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1445 !(*total_flags & FIF_FCSFAIL));
1446 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1447 !(*total_flags & FIF_PLCPFAIL));
1448 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1449 !(*total_flags & FIF_CONTROL));
1450 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1451 !(*total_flags & FIF_PROMISC_IN_BSS));
1452 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1453 !(*total_flags & FIF_PROMISC_IN_BSS));
1454 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1455 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1456}
1457
1458static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw, 1423static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw,
1459 u32 short_retry, u32 long_retry) 1424 u32 short_retry, u32 long_retry)
1460{ 1425{
@@ -1580,7 +1545,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1580 .remove_interface = rt2x00mac_remove_interface, 1545 .remove_interface = rt2x00mac_remove_interface,
1581 .config = rt2x00mac_config, 1546 .config = rt2x00mac_config,
1582 .config_interface = rt2x00mac_config_interface, 1547 .config_interface = rt2x00mac_config_interface,
1583 .configure_filter = rt2400pci_configure_filter, 1548 .configure_filter = rt2x00mac_configure_filter,
1584 .get_stats = rt2x00mac_get_stats, 1549 .get_stats = rt2x00mac_get_stats,
1585 .set_retry_limit = rt2400pci_set_retry_limit, 1550 .set_retry_limit = rt2400pci_set_retry_limit,
1586 .bss_info_changed = rt2x00mac_bss_info_changed, 1551 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -1608,6 +1573,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1608 .write_tx_data = rt2x00pci_write_tx_data, 1573 .write_tx_data = rt2x00pci_write_tx_data,
1609 .kick_tx_queue = rt2400pci_kick_tx_queue, 1574 .kick_tx_queue = rt2400pci_kick_tx_queue,
1610 .fill_rxdone = rt2400pci_fill_rxdone, 1575 .fill_rxdone = rt2400pci_fill_rxdone,
1576 .config_filter = rt2400pci_config_filter,
1611 .config_intf = rt2400pci_config_intf, 1577 .config_intf = rt2400pci_config_intf,
1612 .config_erp = rt2400pci_config_erp, 1578 .config_erp = rt2400pci_config_erp,
1613 .config = rt2400pci_config, 1579 .config = rt2400pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 9468dde3c95e..1bdb873b65f2 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -270,6 +270,35 @@ static void rt2500pci_led_brightness(struct led_classdev *led_cdev,
270/* 270/*
271 * Configuration handlers. 271 * Configuration handlers.
272 */ 272 */
273static void rt2500pci_config_filter(struct rt2x00_dev *rt2x00dev,
274 const unsigned int filter_flags)
275{
276 u32 reg;
277
278 /*
279 * Start configuration steps.
280 * Note that the version error will always be dropped
281 * and broadcast frames will always be accepted since
282 * there is no filter for it at this time.
283 */
284 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
285 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
286 !(filter_flags & FIF_FCSFAIL));
287 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
288 !(filter_flags & FIF_PLCPFAIL));
289 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
290 !(filter_flags & FIF_CONTROL));
291 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
292 !(filter_flags & FIF_PROMISC_IN_BSS));
293 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
294 !(filter_flags & FIF_PROMISC_IN_BSS));
295 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
296 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
297 !(filter_flags & FIF_ALLMULTI));
298 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
299 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
300}
301
273static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev, 302static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
274 struct rt2x00_intf *intf, 303 struct rt2x00_intf *intf,
275 struct rt2x00intf_conf *conf, 304 struct rt2x00intf_conf *conf,
@@ -309,8 +338,8 @@ static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
309 conf->bssid, sizeof(conf->bssid)); 338 conf->bssid, sizeof(conf->bssid));
310} 339}
311 340
312static int rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev, 341static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
313 struct rt2x00lib_erp *erp) 342 struct rt2x00lib_erp *erp)
314{ 343{
315 int preamble_mask; 344 int preamble_mask;
316 u32 reg; 345 u32 reg;
@@ -350,8 +379,6 @@ static int rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
350 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 379 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
351 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 380 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
352 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 381 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
353
354 return 0;
355} 382}
356 383
357static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, 384static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1731,69 +1758,6 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1731/* 1758/*
1732 * IEEE80211 stack callback functions. 1759 * IEEE80211 stack callback functions.
1733 */ 1760 */
1734static void rt2500pci_configure_filter(struct ieee80211_hw *hw,
1735 unsigned int changed_flags,
1736 unsigned int *total_flags,
1737 int mc_count,
1738 struct dev_addr_list *mc_list)
1739{
1740 struct rt2x00_dev *rt2x00dev = hw->priv;
1741 u32 reg;
1742
1743 /*
1744 * Mask off any flags we are going to ignore from
1745 * the total_flags field.
1746 */
1747 *total_flags &=
1748 FIF_ALLMULTI |
1749 FIF_FCSFAIL |
1750 FIF_PLCPFAIL |
1751 FIF_CONTROL |
1752 FIF_OTHER_BSS |
1753 FIF_PROMISC_IN_BSS;
1754
1755 /*
1756 * Apply some rules to the filters:
1757 * - Some filters imply different filters to be set.
1758 * - Some things we can't filter out at all.
1759 */
1760 if (mc_count)
1761 *total_flags |= FIF_ALLMULTI;
1762 if (*total_flags & FIF_OTHER_BSS ||
1763 *total_flags & FIF_PROMISC_IN_BSS)
1764 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1765
1766 /*
1767 * Check if there is any work left for us.
1768 */
1769 if (rt2x00dev->packet_filter == *total_flags)
1770 return;
1771 rt2x00dev->packet_filter = *total_flags;
1772
1773 /*
1774 * Start configuration steps.
1775 * Note that the version error will always be dropped
1776 * and broadcast frames will always be accepted since
1777 * there is no filter for it at this time.
1778 */
1779 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1780 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1781 !(*total_flags & FIF_FCSFAIL));
1782 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1783 !(*total_flags & FIF_PLCPFAIL));
1784 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1785 !(*total_flags & FIF_CONTROL));
1786 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1787 !(*total_flags & FIF_PROMISC_IN_BSS));
1788 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1789 !(*total_flags & FIF_PROMISC_IN_BSS));
1790 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1791 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
1792 !(*total_flags & FIF_ALLMULTI));
1793 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
1794 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1795}
1796
1797static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw, 1761static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw,
1798 u32 short_retry, u32 long_retry) 1762 u32 short_retry, u32 long_retry)
1799{ 1763{
@@ -1894,7 +1858,7 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1894 .remove_interface = rt2x00mac_remove_interface, 1858 .remove_interface = rt2x00mac_remove_interface,
1895 .config = rt2x00mac_config, 1859 .config = rt2x00mac_config,
1896 .config_interface = rt2x00mac_config_interface, 1860 .config_interface = rt2x00mac_config_interface,
1897 .configure_filter = rt2500pci_configure_filter, 1861 .configure_filter = rt2x00mac_configure_filter,
1898 .get_stats = rt2x00mac_get_stats, 1862 .get_stats = rt2x00mac_get_stats,
1899 .set_retry_limit = rt2500pci_set_retry_limit, 1863 .set_retry_limit = rt2500pci_set_retry_limit,
1900 .bss_info_changed = rt2x00mac_bss_info_changed, 1864 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -1922,6 +1886,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1922 .write_tx_data = rt2x00pci_write_tx_data, 1886 .write_tx_data = rt2x00pci_write_tx_data,
1923 .kick_tx_queue = rt2500pci_kick_tx_queue, 1887 .kick_tx_queue = rt2500pci_kick_tx_queue,
1924 .fill_rxdone = rt2500pci_fill_rxdone, 1888 .fill_rxdone = rt2500pci_fill_rxdone,
1889 .config_filter = rt2500pci_config_filter,
1925 .config_intf = rt2500pci_config_intf, 1890 .config_intf = rt2500pci_config_intf,
1926 .config_erp = rt2500pci_config_erp, 1891 .config_erp = rt2500pci_config_erp,
1927 .config = rt2500pci_config, 1892 .config = rt2500pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 8959a684f40b..f5c18f011e93 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -316,6 +316,35 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
316/* 316/*
317 * Configuration handlers. 317 * Configuration handlers.
318 */ 318 */
319static void rt2500usb_config_filter(struct rt2x00_dev *rt2x00dev,
320 const unsigned int filter_flags)
321{
322 u16 reg;
323
324 /*
325 * Start configuration steps.
326 * Note that the version error will always be dropped
327 * and broadcast frames will always be accepted since
328 * there is no filter for it at this time.
329 */
330 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
331 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
332 !(filter_flags & FIF_FCSFAIL));
333 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
334 !(filter_flags & FIF_PLCPFAIL));
335 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
336 !(filter_flags & FIF_CONTROL));
337 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
338 !(filter_flags & FIF_PROMISC_IN_BSS));
339 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
340 !(filter_flags & FIF_PROMISC_IN_BSS));
341 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
342 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
343 !(filter_flags & FIF_ALLMULTI));
344 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
345 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
346}
347
319static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev, 348static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
320 struct rt2x00_intf *intf, 349 struct rt2x00_intf *intf,
321 struct rt2x00intf_conf *conf, 350 struct rt2x00intf_conf *conf,
@@ -358,18 +387,11 @@ static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
358 (3 * sizeof(__le16))); 387 (3 * sizeof(__le16)));
359} 388}
360 389
361static int rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev, 390static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
362 struct rt2x00lib_erp *erp) 391 struct rt2x00lib_erp *erp)
363{ 392{
364 u16 reg; 393 u16 reg;
365 394
366 /*
367 * When in atomic context, we should let rt2x00lib
368 * try this configuration again later.
369 */
370 if (in_atomic())
371 return -EAGAIN;
372
373 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg); 395 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg);
374 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, erp->ack_timeout); 396 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, erp->ack_timeout);
375 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg); 397 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
@@ -378,8 +400,6 @@ static int rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
378 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 400 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
379 !!erp->short_preamble); 401 !!erp->short_preamble);
380 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); 402 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
381
382 return 0;
383} 403}
384 404
385static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev, 405static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1644,6 +1664,7 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1644 */ 1664 */
1645 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags); 1665 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
1646 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags); 1666 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags);
1667 __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
1647 1668
1648 /* 1669 /*
1649 * Set the rssi offset. 1670 * Set the rssi offset.
@@ -1656,78 +1677,6 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1656/* 1677/*
1657 * IEEE80211 stack callback functions. 1678 * IEEE80211 stack callback functions.
1658 */ 1679 */
1659static void rt2500usb_configure_filter(struct ieee80211_hw *hw,
1660 unsigned int changed_flags,
1661 unsigned int *total_flags,
1662 int mc_count,
1663 struct dev_addr_list *mc_list)
1664{
1665 struct rt2x00_dev *rt2x00dev = hw->priv;
1666 u16 reg;
1667
1668 /*
1669 * Mask off any flags we are going to ignore from
1670 * the total_flags field.
1671 */
1672 *total_flags &=
1673 FIF_ALLMULTI |
1674 FIF_FCSFAIL |
1675 FIF_PLCPFAIL |
1676 FIF_CONTROL |
1677 FIF_OTHER_BSS |
1678 FIF_PROMISC_IN_BSS;
1679
1680 /*
1681 * Apply some rules to the filters:
1682 * - Some filters imply different filters to be set.
1683 * - Some things we can't filter out at all.
1684 */
1685 if (mc_count)
1686 *total_flags |= FIF_ALLMULTI;
1687 if (*total_flags & FIF_OTHER_BSS ||
1688 *total_flags & FIF_PROMISC_IN_BSS)
1689 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1690
1691 /*
1692 * Check if there is any work left for us.
1693 */
1694 if (rt2x00dev->packet_filter == *total_flags)
1695 return;
1696 rt2x00dev->packet_filter = *total_flags;
1697
1698 /*
1699 * When in atomic context, reschedule and let rt2x00lib
1700 * call this function again.
1701 */
1702 if (in_atomic()) {
1703 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1704 return;
1705 }
1706
1707 /*
1708 * Start configuration steps.
1709 * Note that the version error will always be dropped
1710 * and broadcast frames will always be accepted since
1711 * there is no filter for it at this time.
1712 */
1713 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
1714 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
1715 !(*total_flags & FIF_FCSFAIL));
1716 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
1717 !(*total_flags & FIF_PLCPFAIL));
1718 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
1719 !(*total_flags & FIF_CONTROL));
1720 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
1721 !(*total_flags & FIF_PROMISC_IN_BSS));
1722 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
1723 !(*total_flags & FIF_PROMISC_IN_BSS));
1724 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
1725 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
1726 !(*total_flags & FIF_ALLMULTI));
1727 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
1728 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
1729}
1730
1731static int rt2500usb_beacon_update(struct ieee80211_hw *hw, 1680static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1732 struct sk_buff *skb, 1681 struct sk_buff *skb,
1733 struct ieee80211_tx_control *control) 1682 struct ieee80211_tx_control *control)
@@ -1824,7 +1773,7 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1824 .remove_interface = rt2x00mac_remove_interface, 1773 .remove_interface = rt2x00mac_remove_interface,
1825 .config = rt2x00mac_config, 1774 .config = rt2x00mac_config,
1826 .config_interface = rt2x00mac_config_interface, 1775 .config_interface = rt2x00mac_config_interface,
1827 .configure_filter = rt2500usb_configure_filter, 1776 .configure_filter = rt2x00mac_configure_filter,
1828 .get_stats = rt2x00mac_get_stats, 1777 .get_stats = rt2x00mac_get_stats,
1829 .bss_info_changed = rt2x00mac_bss_info_changed, 1778 .bss_info_changed = rt2x00mac_bss_info_changed,
1830 .conf_tx = rt2x00mac_conf_tx, 1779 .conf_tx = rt2x00mac_conf_tx,
@@ -1848,6 +1797,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1848 .get_tx_data_len = rt2500usb_get_tx_data_len, 1797 .get_tx_data_len = rt2500usb_get_tx_data_len,
1849 .kick_tx_queue = rt2500usb_kick_tx_queue, 1798 .kick_tx_queue = rt2500usb_kick_tx_queue,
1850 .fill_rxdone = rt2500usb_fill_rxdone, 1799 .fill_rxdone = rt2500usb_fill_rxdone,
1800 .config_filter = rt2500usb_config_filter,
1851 .config_intf = rt2500usb_config_intf, 1801 .config_intf = rt2500usb_config_intf,
1852 .config_erp = rt2500usb_config_erp, 1802 .config_erp = rt2500usb_config_erp,
1853 .config = rt2500usb_config, 1803 .config = rt2500usb_config,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c016bfe1defd..333484ddb993 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -560,6 +560,8 @@ struct rt2x00lib_ops {
560 /* 560 /*
561 * Configuration handlers. 561 * Configuration handlers.
562 */ 562 */
563 void (*config_filter) (struct rt2x00_dev *rt2x00dev,
564 const unsigned int filter_flags);
563 void (*config_intf) (struct rt2x00_dev *rt2x00dev, 565 void (*config_intf) (struct rt2x00_dev *rt2x00dev,
564 struct rt2x00_intf *intf, 566 struct rt2x00_intf *intf,
565 struct rt2x00intf_conf *conf, 567 struct rt2x00intf_conf *conf,
@@ -568,8 +570,8 @@ struct rt2x00lib_ops {
568#define CONFIG_UPDATE_MAC ( 1 << 2 ) 570#define CONFIG_UPDATE_MAC ( 1 << 2 )
569#define CONFIG_UPDATE_BSSID ( 1 << 3 ) 571#define CONFIG_UPDATE_BSSID ( 1 << 3 )
570 572
571 int (*config_erp) (struct rt2x00_dev *rt2x00dev, 573 void (*config_erp) (struct rt2x00_dev *rt2x00dev,
572 struct rt2x00lib_erp *erp); 574 struct rt2x00lib_erp *erp);
573 void (*config) (struct rt2x00_dev *rt2x00dev, 575 void (*config) (struct rt2x00_dev *rt2x00dev,
574 struct rt2x00lib_conf *libconf, 576 struct rt2x00lib_conf *libconf,
575 const unsigned int flags); 577 const unsigned int flags);
@@ -624,6 +626,7 @@ enum rt2x00_flags {
624 DRIVER_REQUIRE_FIRMWARE, 626 DRIVER_REQUIRE_FIRMWARE,
625 DRIVER_REQUIRE_BEACON_GUARD, 627 DRIVER_REQUIRE_BEACON_GUARD,
626 DRIVER_REQUIRE_ATIM_QUEUE, 628 DRIVER_REQUIRE_ATIM_QUEUE,
629 DRIVER_REQUIRE_SCHEDULED,
627 630
628 /* 631 /*
629 * Driver configuration 632 * Driver configuration
@@ -987,6 +990,10 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
987int rt2x00mac_config_interface(struct ieee80211_hw *hw, 990int rt2x00mac_config_interface(struct ieee80211_hw *hw,
988 struct ieee80211_vif *vif, 991 struct ieee80211_vif *vif,
989 struct ieee80211_if_conf *conf); 992 struct ieee80211_if_conf *conf);
993void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
994 unsigned int changed_flags,
995 unsigned int *total_flags,
996 int mc_count, struct dev_addr_list *mc_list);
990int rt2x00mac_get_stats(struct ieee80211_hw *hw, 997int rt2x00mac_get_stats(struct ieee80211_hw *hw,
991 struct ieee80211_low_level_stats *stats); 998 struct ieee80211_low_level_stats *stats);
992int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw, 999int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 5e2d81a9e438..a9930a03f450 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -80,7 +80,6 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
80 struct ieee80211_bss_conf *bss_conf) 80 struct ieee80211_bss_conf *bss_conf)
81{ 81{
82 struct rt2x00lib_erp erp; 82 struct rt2x00lib_erp erp;
83 int retval;
84 83
85 memset(&erp, 0, sizeof(erp)); 84 memset(&erp, 0, sizeof(erp));
86 85
@@ -101,14 +100,7 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
101 erp.ack_consume_time += PREAMBLE; 100 erp.ack_consume_time += PREAMBLE;
102 } 101 }
103 102
104 retval = rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); 103 rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp);
105
106 if (retval) {
107 spin_lock(&intf->lock);
108 intf->delayed_flags |= DELAYED_CONFIG_ERP;
109 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
110 spin_unlock(&intf->lock);
111 }
112} 104}
113 105
114void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, 106void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 0a11c27d603b..17b6bb034ebf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -380,6 +380,50 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
380} 380}
381EXPORT_SYMBOL_GPL(rt2x00mac_config_interface); 381EXPORT_SYMBOL_GPL(rt2x00mac_config_interface);
382 382
383void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
384 unsigned int changed_flags,
385 unsigned int *total_flags,
386 int mc_count, struct dev_addr_list *mc_list)
387{
388 struct rt2x00_dev *rt2x00dev = hw->priv;
389
390 /*
391 * Mask off any flags we are going to ignore
392 * from the total_flags field.
393 */
394 *total_flags &=
395 FIF_ALLMULTI |
396 FIF_FCSFAIL |
397 FIF_PLCPFAIL |
398 FIF_CONTROL |
399 FIF_OTHER_BSS |
400 FIF_PROMISC_IN_BSS;
401
402 /*
403 * Apply some rules to the filters:
404 * - Some filters imply different filters to be set.
405 * - Some things we can't filter out at all.
406 * - Multicast filter seems to kill broadcast traffic so never use it.
407 */
408 *total_flags |= FIF_ALLMULTI;
409 if (*total_flags & FIF_OTHER_BSS ||
410 *total_flags & FIF_PROMISC_IN_BSS)
411 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
412
413 /*
414 * Check if there is any work left for us.
415 */
416 if (rt2x00dev->packet_filter == *total_flags)
417 return;
418 rt2x00dev->packet_filter = *total_flags;
419
420 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
421 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
422 else
423 rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags);
424}
425EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter);
426
383int rt2x00mac_get_stats(struct ieee80211_hw *hw, 427int rt2x00mac_get_stats(struct ieee80211_hw *hw,
384 struct ieee80211_low_level_stats *stats) 428 struct ieee80211_low_level_stats *stats)
385{ 429{
@@ -419,6 +463,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
419{ 463{
420 struct rt2x00_dev *rt2x00dev = hw->priv; 464 struct rt2x00_dev *rt2x00dev = hw->priv;
421 struct rt2x00_intf *intf = vif_to_intf(vif); 465 struct rt2x00_intf *intf = vif_to_intf(vif);
466 unsigned int delayed = 0;
422 467
423 /* 468 /*
424 * When the association status has changed we must reset the link 469 * When the association status has changed we must reset the link
@@ -439,11 +484,19 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
439 * When the erp information has changed, we should perform 484 * When the erp information has changed, we should perform
440 * additional configuration steps. For all other changes we are done. 485 * additional configuration steps. For all other changes we are done.
441 */ 486 */
442 if (changes & BSS_CHANGED_ERP_PREAMBLE) 487 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
443 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf); 488 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
489 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
490 else
491 delayed |= DELAYED_CONFIG_ERP;
492 }
444 493
445 spin_lock(&intf->lock); 494 spin_lock(&intf->lock);
446 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); 495 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf));
496 if (delayed) {
497 intf->delayed_flags |= delayed;
498 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
499 }
447 spin_unlock(&intf->lock); 500 spin_unlock(&intf->lock);
448} 501}
449EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed); 502EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed);
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 6e643c8db42e..0d2e6f7dd692 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -321,6 +321,37 @@ static void rt61pci_led_brightness(struct led_classdev *led_cdev,
321/* 321/*
322 * Configuration handlers. 322 * Configuration handlers.
323 */ 323 */
324static void rt61pci_config_filter(struct rt2x00_dev *rt2x00dev,
325 const unsigned int filter_flags)
326{
327 u32 reg;
328
329 /*
330 * Start configuration steps.
331 * Note that the version error will always be dropped
332 * and broadcast frames will always be accepted since
333 * there is no filter for it at this time.
334 */
335 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
336 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
337 !(filter_flags & FIF_FCSFAIL));
338 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
339 !(filter_flags & FIF_PLCPFAIL));
340 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
341 !(filter_flags & FIF_CONTROL));
342 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
343 !(filter_flags & FIF_PROMISC_IN_BSS));
344 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
345 !(filter_flags & FIF_PROMISC_IN_BSS));
346 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
347 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
348 !(filter_flags & FIF_ALLMULTI));
349 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
350 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
351 !(filter_flags & FIF_CONTROL));
352 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
353}
354
324static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev, 355static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev,
325 struct rt2x00_intf *intf, 356 struct rt2x00_intf *intf,
326 struct rt2x00intf_conf *conf, 357 struct rt2x00intf_conf *conf,
@@ -368,8 +399,8 @@ static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev,
368 } 399 }
369} 400}
370 401
371static int rt61pci_config_erp(struct rt2x00_dev *rt2x00dev, 402static void rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
372 struct rt2x00lib_erp *erp) 403 struct rt2x00lib_erp *erp)
373{ 404{
374 u32 reg; 405 u32 reg;
375 406
@@ -381,8 +412,6 @@ static int rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
381 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 412 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
382 !!erp->short_preamble); 413 !!erp->short_preamble);
383 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg); 414 rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
384
385 return 0;
386} 415}
387 416
388static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev, 417static void rt61pci_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -2284,71 +2313,6 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2284/* 2313/*
2285 * IEEE80211 stack callback functions. 2314 * IEEE80211 stack callback functions.
2286 */ 2315 */
2287static void rt61pci_configure_filter(struct ieee80211_hw *hw,
2288 unsigned int changed_flags,
2289 unsigned int *total_flags,
2290 int mc_count,
2291 struct dev_addr_list *mc_list)
2292{
2293 struct rt2x00_dev *rt2x00dev = hw->priv;
2294 u32 reg;
2295
2296 /*
2297 * Mask off any flags we are going to ignore from
2298 * the total_flags field.
2299 */
2300 *total_flags &=
2301 FIF_ALLMULTI |
2302 FIF_FCSFAIL |
2303 FIF_PLCPFAIL |
2304 FIF_CONTROL |
2305 FIF_OTHER_BSS |
2306 FIF_PROMISC_IN_BSS;
2307
2308 /*
2309 * Apply some rules to the filters:
2310 * - Some filters imply different filters to be set.
2311 * - Some things we can't filter out at all.
2312 * - Multicast filter seems to kill broadcast traffic so never use it.
2313 */
2314 *total_flags |= FIF_ALLMULTI;
2315 if (*total_flags & FIF_OTHER_BSS ||
2316 *total_flags & FIF_PROMISC_IN_BSS)
2317 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
2318
2319 /*
2320 * Check if there is any work left for us.
2321 */
2322 if (rt2x00dev->packet_filter == *total_flags)
2323 return;
2324 rt2x00dev->packet_filter = *total_flags;
2325
2326 /*
2327 * Start configuration steps.
2328 * Note that the version error will always be dropped
2329 * and broadcast frames will always be accepted since
2330 * there is no filter for it at this time.
2331 */
2332 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
2333 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
2334 !(*total_flags & FIF_FCSFAIL));
2335 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
2336 !(*total_flags & FIF_PLCPFAIL));
2337 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
2338 !(*total_flags & FIF_CONTROL));
2339 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
2340 !(*total_flags & FIF_PROMISC_IN_BSS));
2341 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
2342 !(*total_flags & FIF_PROMISC_IN_BSS));
2343 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
2344 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
2345 !(*total_flags & FIF_ALLMULTI));
2346 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
2347 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
2348 !(*total_flags & FIF_CONTROL));
2349 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
2350}
2351
2352static int rt61pci_set_retry_limit(struct ieee80211_hw *hw, 2316static int rt61pci_set_retry_limit(struct ieee80211_hw *hw,
2353 u32 short_retry, u32 long_retry) 2317 u32 short_retry, u32 long_retry)
2354{ 2318{
@@ -2457,7 +2421,7 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
2457 .remove_interface = rt2x00mac_remove_interface, 2421 .remove_interface = rt2x00mac_remove_interface,
2458 .config = rt2x00mac_config, 2422 .config = rt2x00mac_config,
2459 .config_interface = rt2x00mac_config_interface, 2423 .config_interface = rt2x00mac_config_interface,
2460 .configure_filter = rt61pci_configure_filter, 2424 .configure_filter = rt2x00mac_configure_filter,
2461 .get_stats = rt2x00mac_get_stats, 2425 .get_stats = rt2x00mac_get_stats,
2462 .set_retry_limit = rt61pci_set_retry_limit, 2426 .set_retry_limit = rt61pci_set_retry_limit,
2463 .bss_info_changed = rt2x00mac_bss_info_changed, 2427 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -2487,6 +2451,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2487 .write_tx_data = rt2x00pci_write_tx_data, 2451 .write_tx_data = rt2x00pci_write_tx_data,
2488 .kick_tx_queue = rt61pci_kick_tx_queue, 2452 .kick_tx_queue = rt61pci_kick_tx_queue,
2489 .fill_rxdone = rt61pci_fill_rxdone, 2453 .fill_rxdone = rt61pci_fill_rxdone,
2454 .config_filter = rt61pci_config_filter,
2490 .config_intf = rt61pci_config_intf, 2455 .config_intf = rt61pci_config_intf,
2491 .config_erp = rt61pci_config_erp, 2456 .config_erp = rt61pci_config_erp,
2492 .config = rt61pci_config, 2457 .config = rt61pci_config,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index b50f476e4bd1..187e832bab2e 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -333,6 +333,37 @@ static void rt73usb_led_brightness(struct led_classdev *led_cdev,
333/* 333/*
334 * Configuration handlers. 334 * Configuration handlers.
335 */ 335 */
336static void rt73usb_config_filter(struct rt2x00_dev *rt2x00dev,
337 const unsigned int filter_flags)
338{
339 u32 reg;
340
341 /*
342 * Start configuration steps.
343 * Note that the version error will always be dropped
344 * and broadcast frames will always be accepted since
345 * there is no filter for it at this time.
346 */
347 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
348 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
349 !(filter_flags & FIF_FCSFAIL));
350 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
351 !(filter_flags & FIF_PLCPFAIL));
352 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
353 !(filter_flags & FIF_CONTROL));
354 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
355 !(filter_flags & FIF_PROMISC_IN_BSS));
356 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
357 !(filter_flags & FIF_PROMISC_IN_BSS));
358 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
359 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
360 !(filter_flags & FIF_ALLMULTI));
361 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
362 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
363 !(filter_flags & FIF_CONTROL));
364 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
365}
366
336static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev, 367static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
337 struct rt2x00_intf *intf, 368 struct rt2x00_intf *intf,
338 struct rt2x00intf_conf *conf, 369 struct rt2x00intf_conf *conf,
@@ -380,18 +411,11 @@ static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
380 } 411 }
381} 412}
382 413
383static int rt73usb_config_erp(struct rt2x00_dev *rt2x00dev, 414static void rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
384 struct rt2x00lib_erp *erp) 415 struct rt2x00lib_erp *erp)
385{ 416{
386 u32 reg; 417 u32 reg;
387 418
388 /*
389 * When in atomic context, we should let rt2x00lib
390 * try this configuration again later.
391 */
392 if (in_atomic())
393 return -EAGAIN;
394
395 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg); 419 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
396 rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout); 420 rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
397 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); 421 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
@@ -400,8 +424,6 @@ static int rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
400 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 424 rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
401 !!erp->short_preamble); 425 !!erp->short_preamble);
402 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); 426 rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
403
404 return 0;
405} 427}
406 428
407static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev, 429static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev,
@@ -1872,6 +1894,7 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1872 * This device requires firmware. 1894 * This device requires firmware.
1873 */ 1895 */
1874 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); 1896 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
1897 __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
1875 1898
1876 /* 1899 /*
1877 * Set the rssi offset. 1900 * Set the rssi offset.
@@ -1884,80 +1907,6 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1884/* 1907/*
1885 * IEEE80211 stack callback functions. 1908 * IEEE80211 stack callback functions.
1886 */ 1909 */
1887static void rt73usb_configure_filter(struct ieee80211_hw *hw,
1888 unsigned int changed_flags,
1889 unsigned int *total_flags,
1890 int mc_count,
1891 struct dev_addr_list *mc_list)
1892{
1893 struct rt2x00_dev *rt2x00dev = hw->priv;
1894 u32 reg;
1895
1896 /*
1897 * Mask off any flags we are going to ignore from
1898 * the total_flags field.
1899 */
1900 *total_flags &=
1901 FIF_ALLMULTI |
1902 FIF_FCSFAIL |
1903 FIF_PLCPFAIL |
1904 FIF_CONTROL |
1905 FIF_OTHER_BSS |
1906 FIF_PROMISC_IN_BSS;
1907
1908 /*
1909 * Apply some rules to the filters:
1910 * - Some filters imply different filters to be set.
1911 * - Some things we can't filter out at all.
1912 * - Multicast filter seems to kill broadcast traffic so never use it.
1913 */
1914 *total_flags |= FIF_ALLMULTI;
1915 if (*total_flags & FIF_OTHER_BSS ||
1916 *total_flags & FIF_PROMISC_IN_BSS)
1917 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1918
1919 /*
1920 * Check if there is any work left for us.
1921 */
1922 if (rt2x00dev->packet_filter == *total_flags)
1923 return;
1924 rt2x00dev->packet_filter = *total_flags;
1925
1926 /*
1927 * When in atomic context, reschedule and let rt2x00lib
1928 * call this function again.
1929 */
1930 if (in_atomic()) {
1931 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1932 return;
1933 }
1934
1935 /*
1936 * Start configuration steps.
1937 * Note that the version error will always be dropped
1938 * and broadcast frames will always be accepted since
1939 * there is no filter for it at this time.
1940 */
1941 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1942 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
1943 !(*total_flags & FIF_FCSFAIL));
1944 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
1945 !(*total_flags & FIF_PLCPFAIL));
1946 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
1947 !(*total_flags & FIF_CONTROL));
1948 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
1949 !(*total_flags & FIF_PROMISC_IN_BSS));
1950 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
1951 !(*total_flags & FIF_PROMISC_IN_BSS));
1952 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
1953 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
1954 !(*total_flags & FIF_ALLMULTI));
1955 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
1956 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS,
1957 !(*total_flags & FIF_CONTROL));
1958 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1959}
1960
1961static int rt73usb_set_retry_limit(struct ieee80211_hw *hw, 1910static int rt73usb_set_retry_limit(struct ieee80211_hw *hw,
1962 u32 short_retry, u32 long_retry) 1911 u32 short_retry, u32 long_retry)
1963{ 1912{
@@ -2067,7 +2016,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2067 .remove_interface = rt2x00mac_remove_interface, 2016 .remove_interface = rt2x00mac_remove_interface,
2068 .config = rt2x00mac_config, 2017 .config = rt2x00mac_config,
2069 .config_interface = rt2x00mac_config_interface, 2018 .config_interface = rt2x00mac_config_interface,
2070 .configure_filter = rt73usb_configure_filter, 2019 .configure_filter = rt2x00mac_configure_filter,
2071 .get_stats = rt2x00mac_get_stats, 2020 .get_stats = rt2x00mac_get_stats,
2072 .set_retry_limit = rt73usb_set_retry_limit, 2021 .set_retry_limit = rt73usb_set_retry_limit,
2073 .bss_info_changed = rt2x00mac_bss_info_changed, 2022 .bss_info_changed = rt2x00mac_bss_info_changed,
@@ -2096,6 +2045,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2096 .get_tx_data_len = rt73usb_get_tx_data_len, 2045 .get_tx_data_len = rt73usb_get_tx_data_len,
2097 .kick_tx_queue = rt73usb_kick_tx_queue, 2046 .kick_tx_queue = rt73usb_kick_tx_queue,
2098 .fill_rxdone = rt73usb_fill_rxdone, 2047 .fill_rxdone = rt73usb_fill_rxdone,
2048 .config_filter = rt73usb_config_filter,
2099 .config_intf = rt73usb_config_intf, 2049 .config_intf = rt73usb_config_intf,
2100 .config_erp = rt73usb_config_erp, 2050 .config_erp = rt73usb_config_erp,
2101 .config = rt73usb_config, 2051 .config = rt73usb_config,