aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-09-17 01:29:23 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:57 -0400
commit4150c57212ad134765dd78c654a4b9906252b66d (patch)
treec37ab7a3f75532a623ed00339782d769514422d2 /drivers/net/wireless/rt2x00
parent070ac3a2651e3c1c4d277c5f1981517427c386a7 (diff)
[PATCH] mac80211: revamp interface and filter configuration
Drivers are currently supposed to keep track of monitor interfaces if they allow so-called "hard" monitor, and they are also supposed to keep track of multicast etc. This patch changes that, replaces the set_multicast_list() callback with a new configure_filter() callback that takes filter flags (FIF_*) instead of interface flags (IFF_*). For a driver, this means it should open the filter as much as necessary to get all frames requested by the filter flags. Accordingly, the filter flags are named "positively", e.g. FIF_ALLMULTI. Multicast filtering is a bit special in that drivers that have no multicast address filters need to allow multicast frames through when either the FIF_ALLMULTI flag is set or when the mc_count value is positive. At the same time, drivers are no longer notified about monitor interfaces at all, this means they now need to implement the start() and stop() callbacks and the new change_filter_flags() callback. Also, the start()/stop() ordering changed, start() is now called *before* any add_interface() as it really should be, and stop() after any remove_interface(). The patch also changes the behaviour of setting the bssid to multicast for scanning when IEEE80211_HW_NO_PROBE_FILTERING is set; the IEEE80211_HW_NO_PROBE_FILTERING flag is removed and the filter flag FIF_BCN_PRBRESP_PROMISC introduced. This is a lot more efficient for hardware like b43 that supports it and other hardware can still set the BSSID to all-ones. Driver modifications by Johannes Berg (b43 & iwlwifi), Michael Wu (rtl8187, adm8211, and p54), Larry Finger (b43legacy), and Ivo van Doorn (rt2x00). Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c155
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c165
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c179
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h37
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c60
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c33
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c104
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c31
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00ring.h17
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c16
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c164
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c175
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.h2
15 files changed, 556 insertions, 589 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 398c20105c81..03a94a33e6bd 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -277,55 +277,14 @@ static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg)); 277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
278} 278}
279 279
280static void rt2400pci_config_packet_filter(struct rt2x00_dev *rt2x00dev,
281 const unsigned int filter)
282{
283 int promisc = !!(filter & IFF_PROMISC);
284 u32 reg;
285
286 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
287 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME, !promisc);
288 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
289}
290
291static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type) 280static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
292{ 281{
282 struct interface *intf = &rt2x00dev->interface;
293 u32 reg; 283 u32 reg;
294 284
295 rt2x00pci_register_write(rt2x00dev, CSR14, 0); 285 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
296 286
297 /* 287 /*
298 * Apply hardware packet filter.
299 */
300 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
301
302 if (!is_monitor_present(&rt2x00dev->interface) &&
303 (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
304 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 1);
305 else
306 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 0);
307
308 /*
309 * If there is a non-monitor interface present
310 * the packet should be strict (even if a monitor interface is present!).
311 * When there is only 1 interface present which is in monitor mode
312 * we should start accepting _all_ frames.
313 */
314 if (is_interface_present(&rt2x00dev->interface)) {
315 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 1);
316 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 1);
317 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 1);
318 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
319 } else if (is_monitor_present(&rt2x00dev->interface)) {
320 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 0);
321 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 0);
322 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 0);
323 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 0);
324 }
325
326 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
327
328 /*
329 * Enable beacon config 288 * Enable beacon config
330 */ 289 */
331 rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg); 290 rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
@@ -337,20 +296,16 @@ static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
337 * Enable synchronisation. 296 * Enable synchronisation.
338 */ 297 */
339 rt2x00pci_register_read(rt2x00dev, CSR14, &reg); 298 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
340 if (is_interface_present(&rt2x00dev->interface)) { 299 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
341 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1); 300 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
342 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
343 }
344
345 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0); 301 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
346 if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP) 302 if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
303 is_interface_type(intf, IEEE80211_IF_TYPE_AP))
347 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2); 304 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
348 else if (type == IEEE80211_IF_TYPE_STA) 305 else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
349 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1); 306 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
350 else if (is_monitor_present(&rt2x00dev->interface) && 307 else
351 !is_interface_present(&rt2x00dev->interface))
352 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0); 308 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
353
354 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 309 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
355} 310}
356 311
@@ -1104,7 +1059,7 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1104 */ 1059 */
1105static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1060static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1106 struct data_desc *txd, 1061 struct data_desc *txd,
1107 struct data_entry_desc *desc, 1062 struct txdata_entry_desc *desc,
1108 struct ieee80211_hdr *ieee80211hdr, 1063 struct ieee80211_hdr *ieee80211hdr,
1109 unsigned int length, 1064 unsigned int length,
1110 struct ieee80211_tx_control *control) 1065 struct ieee80211_tx_control *control)
@@ -1200,8 +1155,8 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1200/* 1155/*
1201 * RX control handlers 1156 * RX control handlers
1202 */ 1157 */
1203static int rt2400pci_fill_rxdone(struct data_entry *entry, 1158static void rt2400pci_fill_rxdone(struct data_entry *entry,
1204 int *signal, int *rssi, int *ofdm, int *size) 1159 struct rxdata_entry_desc *desc)
1205{ 1160{
1206 struct data_desc *rxd = entry->priv; 1161 struct data_desc *rxd = entry->priv;
1207 u32 word0; 1162 u32 word0;
@@ -1210,20 +1165,20 @@ static int rt2400pci_fill_rxdone(struct data_entry *entry,
1210 rt2x00_desc_read(rxd, 0, &word0); 1165 rt2x00_desc_read(rxd, 0, &word0);
1211 rt2x00_desc_read(rxd, 2, &word2); 1166 rt2x00_desc_read(rxd, 2, &word2);
1212 1167
1213 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) || 1168 desc->flags = 0;
1214 rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) 1169 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1215 return -EINVAL; 1170 desc->flags |= RX_FLAG_FAILED_FCS_CRC;
1171 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
1172 desc->flags |= RX_FLAG_FAILED_PLCP_CRC;
1216 1173
1217 /* 1174 /*
1218 * Obtain the status about this packet. 1175 * Obtain the status about this packet.
1219 */ 1176 */
1220 *signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL); 1177 desc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
1221 *rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) - 1178 desc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
1222 entry->ring->rt2x00dev->rssi_offset; 1179 entry->ring->rt2x00dev->rssi_offset;
1223 *ofdm = 0; 1180 desc->ofdm = 0;
1224 *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1181 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1225
1226 return 0;
1227} 1182}
1228 1183
1229/* 1184/*
@@ -1460,10 +1415,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1460 /* 1415 /*
1461 * Initialize all hw fields. 1416 * Initialize all hw fields.
1462 */ 1417 */
1463 rt2x00dev->hw->flags = 1418 rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
1464 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1465 IEEE80211_HW_MONITOR_DURING_OPER |
1466 IEEE80211_HW_NO_PROBE_FILTERING;
1467 rt2x00dev->hw->extra_tx_headroom = 0; 1419 rt2x00dev->hw->extra_tx_headroom = 0;
1468 rt2x00dev->hw->max_signal = MAX_SIGNAL; 1420 rt2x00dev->hw->max_signal = MAX_SIGNAL;
1469 rt2x00dev->hw->max_rssi = MAX_RX_SSI; 1421 rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1530,6 +1482,68 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1530/* 1482/*
1531 * IEEE80211 stack callback functions. 1483 * IEEE80211 stack callback functions.
1532 */ 1484 */
1485static void rt2400pci_configure_filter(struct ieee80211_hw *hw,
1486 unsigned int changed_flags,
1487 unsigned int *total_flags,
1488 int mc_count,
1489 struct dev_addr_list *mc_list)
1490{
1491 struct rt2x00_dev *rt2x00dev = hw->priv;
1492 struct interface *intf = &rt2x00dev->interface;
1493 u32 reg;
1494
1495 /*
1496 * Mask off any flags we are going to ignore from
1497 * the total_flags field.
1498 */
1499 *total_flags &=
1500 FIF_ALLMULTI |
1501 FIF_FCSFAIL |
1502 FIF_PLCPFAIL |
1503 FIF_CONTROL |
1504 FIF_OTHER_BSS |
1505 FIF_PROMISC_IN_BSS;
1506
1507 /*
1508 * Apply some rules to the filters:
1509 * - Some filters imply different filters to be set.
1510 * - Some things we can't filter out at all.
1511 * - Some filters are set based on interface type.
1512 */
1513 *total_flags |= FIF_ALLMULTI;
1514 if (changed_flags & FIF_OTHER_BSS ||
1515 changed_flags & FIF_PROMISC_IN_BSS)
1516 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1517 if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
1518 *total_flags |= FIF_PROMISC_IN_BSS;
1519
1520 /*
1521 * Check if there is any work left for us.
1522 */
1523 if (intf->filter == *total_flags)
1524 return;
1525 intf->filter = *total_flags;
1526
1527 /*
1528 * Start configuration steps.
1529 * Note that the version error will always be dropped
1530 * since there is no filter for it at this time.
1531 */
1532 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1533 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1534 !(*total_flags & FIF_FCSFAIL));
1535 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1536 !(*total_flags & FIF_PLCPFAIL));
1537 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1538 !(*total_flags & FIF_CONTROL));
1539 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1540 !(*total_flags & FIF_PROMISC_IN_BSS));
1541 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1542 !(*total_flags & FIF_PROMISC_IN_BSS));
1543 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1544 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1545}
1546
1533static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw, 1547static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw,
1534 u32 short_retry, u32 long_retry) 1548 u32 short_retry, u32 long_retry)
1535{ 1549{
@@ -1602,11 +1616,13 @@ static int rt2400pci_tx_last_beacon(struct ieee80211_hw *hw)
1602 1616
1603static const struct ieee80211_ops rt2400pci_mac80211_ops = { 1617static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1604 .tx = rt2x00mac_tx, 1618 .tx = rt2x00mac_tx,
1619 .start = rt2x00mac_start,
1620 .stop = rt2x00mac_stop,
1605 .add_interface = rt2x00mac_add_interface, 1621 .add_interface = rt2x00mac_add_interface,
1606 .remove_interface = rt2x00mac_remove_interface, 1622 .remove_interface = rt2x00mac_remove_interface,
1607 .config = rt2x00mac_config, 1623 .config = rt2x00mac_config,
1608 .config_interface = rt2x00mac_config_interface, 1624 .config_interface = rt2x00mac_config_interface,
1609 .set_multicast_list = rt2x00mac_set_multicast_list, 1625 .configure_filter = rt2400pci_configure_filter,
1610 .get_stats = rt2x00mac_get_stats, 1626 .get_stats = rt2x00mac_get_stats,
1611 .set_retry_limit = rt2400pci_set_retry_limit, 1627 .set_retry_limit = rt2400pci_set_retry_limit,
1612 .conf_tx = rt2400pci_conf_tx, 1628 .conf_tx = rt2400pci_conf_tx,
@@ -1635,7 +1651,6 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1635 .fill_rxdone = rt2400pci_fill_rxdone, 1651 .fill_rxdone = rt2400pci_fill_rxdone,
1636 .config_mac_addr = rt2400pci_config_mac_addr, 1652 .config_mac_addr = rt2400pci_config_mac_addr,
1637 .config_bssid = rt2400pci_config_bssid, 1653 .config_bssid = rt2400pci_config_bssid,
1638 .config_packet_filter = rt2400pci_config_packet_filter,
1639 .config_type = rt2400pci_config_type, 1654 .config_type = rt2400pci_config_type,
1640 .config = rt2400pci_config, 1655 .config = rt2400pci_config,
1641}; 1656};
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index e8d63aaab7bc..892baa907a6b 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -277,59 +277,14 @@ static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg)); 277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
278} 278}
279 279
280static void rt2500pci_config_packet_filter(struct rt2x00_dev *rt2x00dev,
281 const unsigned int filter)
282{
283 int promisc = !!(filter & IFF_PROMISC);
284 int multicast = !!(filter & IFF_MULTICAST);
285 int broadcast = !!(filter & IFF_BROADCAST);
286 u32 reg;
287
288 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
289 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME, !promisc);
290 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST, !multicast);
291 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, !broadcast);
292 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
293}
294
295static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type) 280static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
296{ 281{
282 struct interface *intf = &rt2x00dev->interface;
297 u32 reg; 283 u32 reg;
298 284
299 rt2x00pci_register_write(rt2x00dev, CSR14, 0); 285 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
300 286
301 /* 287 /*
302 * Apply hardware packet filter.
303 */
304 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
305
306 if (!is_monitor_present(&rt2x00dev->interface) &&
307 (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
308 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 1);
309 else
310 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 0);
311
312 /*
313 * If there is a non-monitor interface present
314 * the packet should be strict (even if a monitor interface is present!).
315 * When there is only 1 interface present which is in monitor mode
316 * we should start accepting _all_ frames.
317 */
318 if (is_interface_present(&rt2x00dev->interface)) {
319 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 1);
320 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 1);
321 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 1);
322 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
323 } else if (is_monitor_present(&rt2x00dev->interface)) {
324 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 0);
325 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 0);
326 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 0);
327 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 0);
328 }
329
330 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
331
332 /*
333 * Enable beacon config 288 * Enable beacon config
334 */ 289 */
335 rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg); 290 rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
@@ -345,20 +300,16 @@ static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
345 * Enable synchronisation. 300 * Enable synchronisation.
346 */ 301 */
347 rt2x00pci_register_read(rt2x00dev, CSR14, &reg); 302 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
348 if (is_interface_present(&rt2x00dev->interface)) { 303 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
349 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1); 304 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
350 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
351 }
352
353 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0); 305 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
354 if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP) 306 if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
307 is_interface_type(intf, IEEE80211_IF_TYPE_AP))
355 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2); 308 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
356 else if (type == IEEE80211_IF_TYPE_STA) 309 else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
357 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1); 310 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
358 else if (is_monitor_present(&rt2x00dev->interface) && 311 else
359 !is_interface_present(&rt2x00dev->interface))
360 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0); 312 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
361
362 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 313 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
363} 314}
364 315
@@ -1269,7 +1220,7 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1269 */ 1220 */
1270static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1221static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1271 struct data_desc *txd, 1222 struct data_desc *txd,
1272 struct data_entry_desc *desc, 1223 struct txdata_entry_desc *desc,
1273 struct ieee80211_hdr *ieee80211hdr, 1224 struct ieee80211_hdr *ieee80211hdr,
1274 unsigned int length, 1225 unsigned int length,
1275 struct ieee80211_tx_control *control) 1226 struct ieee80211_tx_control *control)
@@ -1349,8 +1300,8 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1349/* 1300/*
1350 * RX control handlers 1301 * RX control handlers
1351 */ 1302 */
1352static int rt2500pci_fill_rxdone(struct data_entry *entry, 1303static void rt2500pci_fill_rxdone(struct data_entry *entry,
1353 int *signal, int *rssi, int *ofdm, int *size) 1304 struct rxdata_entry_desc *desc)
1354{ 1305{
1355 struct data_desc *rxd = entry->priv; 1306 struct data_desc *rxd = entry->priv;
1356 u32 word0; 1307 u32 word0;
@@ -1359,18 +1310,17 @@ static int rt2500pci_fill_rxdone(struct data_entry *entry,
1359 rt2x00_desc_read(rxd, 0, &word0); 1310 rt2x00_desc_read(rxd, 0, &word0);
1360 rt2x00_desc_read(rxd, 2, &word2); 1311 rt2x00_desc_read(rxd, 2, &word2);
1361 1312
1362 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) || 1313 desc->flags = 0;
1363 rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR) || 1314 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1364 rt2x00_get_field32(word0, RXD_W0_ICV_ERROR)) 1315 desc->flags |= RX_FLAG_FAILED_FCS_CRC;
1365 return -EINVAL; 1316 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
1317 desc->flags |= RX_FLAG_FAILED_PLCP_CRC;
1366 1318
1367 *signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL); 1319 desc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
1368 *rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) - 1320 desc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
1369 entry->ring->rt2x00dev->rssi_offset; 1321 entry->ring->rt2x00dev->rssi_offset;
1370 *ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); 1322 desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1371 *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1323 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1372
1373 return 0;
1374} 1324}
1375 1325
1376/* 1326/*
@@ -1779,10 +1729,7 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1779 /* 1729 /*
1780 * Initialize all hw fields. 1730 * Initialize all hw fields.
1781 */ 1731 */
1782 rt2x00dev->hw->flags = 1732 rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
1783 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1784 IEEE80211_HW_MONITOR_DURING_OPER |
1785 IEEE80211_HW_NO_PROBE_FILTERING;
1786 rt2x00dev->hw->extra_tx_headroom = 0; 1733 rt2x00dev->hw->extra_tx_headroom = 0;
1787 rt2x00dev->hw->max_signal = MAX_SIGNAL; 1734 rt2x00dev->hw->max_signal = MAX_SIGNAL;
1788 rt2x00dev->hw->max_rssi = MAX_RX_SSI; 1735 rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1867,6 +1814,73 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1867/* 1814/*
1868 * IEEE80211 stack callback functions. 1815 * IEEE80211 stack callback functions.
1869 */ 1816 */
1817static void rt2500pci_configure_filter(struct ieee80211_hw *hw,
1818 unsigned int changed_flags,
1819 unsigned int *total_flags,
1820 int mc_count,
1821 struct dev_addr_list *mc_list)
1822{
1823 struct rt2x00_dev *rt2x00dev = hw->priv;
1824 struct interface *intf = &rt2x00dev->interface;
1825 u32 reg;
1826
1827 /*
1828 * Mask off any flags we are going to ignore from
1829 * the total_flags field.
1830 */
1831 *total_flags &=
1832 FIF_ALLMULTI |
1833 FIF_FCSFAIL |
1834 FIF_PLCPFAIL |
1835 FIF_CONTROL |
1836 FIF_OTHER_BSS |
1837 FIF_PROMISC_IN_BSS;
1838
1839 /*
1840 * Apply some rules to the filters:
1841 * - Some filters imply different filters to be set.
1842 * - Some things we can't filter out at all.
1843 * - Some filters are set based on interface type.
1844 */
1845 if (mc_count)
1846 *total_flags |= FIF_ALLMULTI;
1847 if (changed_flags & FIF_OTHER_BSS ||
1848 changed_flags & FIF_PROMISC_IN_BSS)
1849 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1850 if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
1851 *total_flags |= FIF_PROMISC_IN_BSS;
1852
1853 /*
1854 * Check if there is any work left for us.
1855 */
1856 if (intf->filter == *total_flags)
1857 return;
1858 intf->filter = *total_flags;
1859
1860 /*
1861 * Start configuration steps.
1862 * Note that the version error will always be dropped
1863 * and broadcast frames will always be accepted since
1864 * there is no filter for it at this time.
1865 */
1866 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1867 rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
1868 !(*total_flags & FIF_FCSFAIL));
1869 rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
1870 !(*total_flags & FIF_PLCPFAIL));
1871 rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
1872 !(*total_flags & FIF_CONTROL));
1873 rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
1874 !(*total_flags & FIF_PROMISC_IN_BSS));
1875 rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
1876 !(*total_flags & FIF_PROMISC_IN_BSS));
1877 rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
1878 rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
1879 !(*total_flags & FIF_ALLMULTI));
1880 rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
1881 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1882}
1883
1870static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw, 1884static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw,
1871 u32 short_retry, u32 long_retry) 1885 u32 short_retry, u32 long_retry)
1872{ 1886{
@@ -1914,11 +1928,13 @@ static int rt2500pci_tx_last_beacon(struct ieee80211_hw *hw)
1914 1928
1915static const struct ieee80211_ops rt2500pci_mac80211_ops = { 1929static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1916 .tx = rt2x00mac_tx, 1930 .tx = rt2x00mac_tx,
1931 .start = rt2x00mac_start,
1932 .stop = rt2x00mac_stop,
1917 .add_interface = rt2x00mac_add_interface, 1933 .add_interface = rt2x00mac_add_interface,
1918 .remove_interface = rt2x00mac_remove_interface, 1934 .remove_interface = rt2x00mac_remove_interface,
1919 .config = rt2x00mac_config, 1935 .config = rt2x00mac_config,
1920 .config_interface = rt2x00mac_config_interface, 1936 .config_interface = rt2x00mac_config_interface,
1921 .set_multicast_list = rt2x00mac_set_multicast_list, 1937 .configure_filter = rt2500pci_configure_filter,
1922 .get_stats = rt2x00mac_get_stats, 1938 .get_stats = rt2x00mac_get_stats,
1923 .set_retry_limit = rt2500pci_set_retry_limit, 1939 .set_retry_limit = rt2500pci_set_retry_limit,
1924 .conf_tx = rt2x00mac_conf_tx, 1940 .conf_tx = rt2x00mac_conf_tx,
@@ -1947,7 +1963,6 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1947 .fill_rxdone = rt2500pci_fill_rxdone, 1963 .fill_rxdone = rt2500pci_fill_rxdone,
1948 .config_mac_addr = rt2500pci_config_mac_addr, 1964 .config_mac_addr = rt2500pci_config_mac_addr,
1949 .config_bssid = rt2500pci_config_bssid, 1965 .config_bssid = rt2500pci_config_bssid,
1950 .config_packet_filter = rt2500pci_config_packet_filter,
1951 .config_type = rt2500pci_config_type, 1966 .config_type = rt2500pci_config_type,
1952 .config = rt2500pci_config, 1967 .config = rt2500pci_config,
1953}; 1968};
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 614600c5510d..f4e6f6eb7fb5 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -282,65 +282,20 @@ static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
282 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, &reg, sizeof(reg)); 282 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, &reg, sizeof(reg));
283} 283}
284 284
285static void rt2500usb_config_packet_filter(struct rt2x00_dev *rt2x00dev,
286 const unsigned int filter)
287{
288 int promisc = !!(filter & IFF_PROMISC);
289 int multicast = !!(filter & IFF_MULTICAST);
290 int broadcast = !!(filter & IFF_BROADCAST);
291 u16 reg;
292
293 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
294 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME, !promisc);
295 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST, !multicast);
296 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, !broadcast);
297 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
298}
299
300static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type) 285static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
301{ 286{
287 struct interface *intf = &rt2x00dev->interface;
302 u16 reg; 288 u16 reg;
303 289
304 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0); 290 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0);
305 291
306 /* 292 /*
307 * Apply hardware packet filter.
308 */
309 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
310
311 if (!is_monitor_present(&rt2x00dev->interface) &&
312 (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
313 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS, 1);
314 else
315 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS, 0);
316
317 /*
318 * If there is a non-monitor interface present
319 * the packet should be strict (even if a monitor interface is present!).
320 * When there is only 1 interface present which is in monitor mode
321 * we should start accepting _all_ frames.
322 */
323 if (is_interface_present(&rt2x00dev->interface)) {
324 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC, 1);
325 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL, 1);
326 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL, 1);
327 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
328 } else if (is_monitor_present(&rt2x00dev->interface)) {
329 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC, 0);
330 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL, 0);
331 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL, 0);
332 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 0);
333 }
334
335 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
336
337 /*
338 * Enable beacon config 293 * Enable beacon config
339 */ 294 */
340 rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg); 295 rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
341 rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET, 296 rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET,
342 (PREAMBLE + get_duration(IEEE80211_HEADER, 2)) >> 6); 297 (PREAMBLE + get_duration(IEEE80211_HEADER, 2)) >> 6);
343 if (type == IEEE80211_IF_TYPE_STA) 298 if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
344 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 0); 299 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 0);
345 else 300 else
346 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 2); 301 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 2);
@@ -354,20 +309,16 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
354 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg); 309 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
355 310
356 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg); 311 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
357 if (is_interface_present(&rt2x00dev->interface)) { 312 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
358 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1); 313 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
359 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
360 }
361
362 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0); 314 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
363 if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP) 315 if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
316 is_interface_type(intf, IEEE80211_IF_TYPE_AP))
364 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 2); 317 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 2);
365 else if (type == IEEE80211_IF_TYPE_STA) 318 else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
366 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 1); 319 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 1);
367 else if (is_monitor_present(&rt2x00dev->interface) && 320 else
368 !is_interface_present(&rt2x00dev->interface))
369 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0); 321 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0);
370
371 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg); 322 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
372} 323}
373 324
@@ -1084,7 +1035,7 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1084 */ 1035 */
1085static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1036static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1086 struct data_desc *txd, 1037 struct data_desc *txd,
1087 struct data_entry_desc *desc, 1038 struct txdata_entry_desc *desc,
1088 struct ieee80211_hdr *ieee80211hdr, 1039 struct ieee80211_hdr *ieee80211hdr,
1089 unsigned int length, 1040 unsigned int length,
1090 struct ieee80211_tx_control *control) 1041 struct ieee80211_tx_control *control)
@@ -1156,8 +1107,8 @@ static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1156/* 1107/*
1157 * RX control handlers 1108 * RX control handlers
1158 */ 1109 */
1159static int rt2500usb_fill_rxdone(struct data_entry *entry, 1110static void rt2500usb_fill_rxdone(struct data_entry *entry,
1160 int *signal, int *rssi, int *ofdm, int *size) 1111 struct rxdata_entry_desc *desc)
1161{ 1112{
1162 struct urb *urb = entry->priv; 1113 struct urb *urb = entry->priv;
1163 struct data_desc *rxd = (struct data_desc *)(entry->skb->data + 1114 struct data_desc *rxd = (struct data_desc *)(entry->skb->data +
@@ -1169,21 +1120,22 @@ static int rt2500usb_fill_rxdone(struct data_entry *entry,
1169 rt2x00_desc_read(rxd, 0, &word0); 1120 rt2x00_desc_read(rxd, 0, &word0);
1170 rt2x00_desc_read(rxd, 1, &word1); 1121 rt2x00_desc_read(rxd, 1, &word1);
1171 1122
1172 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) || 1123 desc->flags = 0;
1173 rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR) || 1124 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1174 rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR)) 1125 desc->flags |= RX_FLAG_FAILED_FCS_CRC;
1175 return -EINVAL; 1126 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
1127 desc->flags |= RX_FLAG_FAILED_PLCP_CRC;
1176 1128
1177 /* 1129 /*
1178 * Obtain the status about this packet. 1130 * Obtain the status about this packet.
1179 */ 1131 */
1180 *signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1132 desc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1181 *rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) - 1133 desc->rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) -
1182 entry->ring->rt2x00dev->rssi_offset; 1134 entry->ring->rt2x00dev->rssi_offset;
1183 *ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); 1135 desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1184 *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1136 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1185 1137
1186 return 0; 1138 return;
1187} 1139}
1188 1140
1189/* 1141/*
@@ -1549,9 +1501,7 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1549 rt2x00dev->hw->flags = 1501 rt2x00dev->hw->flags =
1550 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 1502 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
1551 IEEE80211_HW_RX_INCLUDES_FCS | 1503 IEEE80211_HW_RX_INCLUDES_FCS |
1552 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1504 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
1553 IEEE80211_HW_MONITOR_DURING_OPER |
1554 IEEE80211_HW_NO_PROBE_FILTERING;
1555 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; 1505 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
1556 rt2x00dev->hw->max_signal = MAX_SIGNAL; 1506 rt2x00dev->hw->max_signal = MAX_SIGNAL;
1557 rt2x00dev->hw->max_rssi = MAX_RX_SSI; 1507 rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1621,10 +1571,8 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1621 rt2500usb_probe_hw_mode(rt2x00dev); 1571 rt2500usb_probe_hw_mode(rt2x00dev);
1622 1572
1623 /* 1573 /*
1624 * USB devices require scheduled packet filter toggling 1574 * This device requires the beacon ring
1625 *This device requires the beacon ring
1626 */ 1575 */
1627 __set_bit(PACKET_FILTER_SCHEDULED, &rt2x00dev->flags);
1628 __set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags); 1576 __set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
1629 1577
1630 /* 1578 /*
@@ -1638,6 +1586,82 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1638/* 1586/*
1639 * IEEE80211 stack callback functions. 1587 * IEEE80211 stack callback functions.
1640 */ 1588 */
1589static void rt2500usb_configure_filter(struct ieee80211_hw *hw,
1590 unsigned int changed_flags,
1591 unsigned int *total_flags,
1592 int mc_count,
1593 struct dev_addr_list *mc_list)
1594{
1595 struct rt2x00_dev *rt2x00dev = hw->priv;
1596 struct interface *intf = &rt2x00dev->interface;
1597 u16 reg;
1598
1599 /*
1600 * Mask off any flags we are going to ignore from
1601 * the total_flags field.
1602 */
1603 *total_flags &=
1604 FIF_ALLMULTI |
1605 FIF_FCSFAIL |
1606 FIF_PLCPFAIL |
1607 FIF_CONTROL |
1608 FIF_OTHER_BSS |
1609 FIF_PROMISC_IN_BSS;
1610
1611 /*
1612 * Apply some rules to the filters:
1613 * - Some filters imply different filters to be set.
1614 * - Some things we can't filter out at all.
1615 * - Some filters are set based on interface type.
1616 */
1617 if (mc_count)
1618 *total_flags |= FIF_ALLMULTI;
1619 if (changed_flags & FIF_OTHER_BSS ||
1620 changed_flags & FIF_PROMISC_IN_BSS)
1621 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1622 if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
1623 *total_flags |= FIF_PROMISC_IN_BSS;
1624
1625 /*
1626 * Check if there is any work left for us.
1627 */
1628 if (intf->filter == *total_flags)
1629 return;
1630 intf->filter = *total_flags;
1631
1632 /*
1633 * When in atomic context, reschedule and let rt2x00lib
1634 * call this function again.
1635 */
1636 if (in_atomic()) {
1637 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1638 return;
1639 }
1640
1641 /*
1642 * Start configuration steps.
1643 * Note that the version error will always be dropped
1644 * and broadcast frames will always be accepted since
1645 * there is no filter for it at this time.
1646 */
1647 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
1648 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
1649 !(*total_flags & FIF_FCSFAIL));
1650 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
1651 !(*total_flags & FIF_PLCPFAIL));
1652 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
1653 !(*total_flags & FIF_CONTROL));
1654 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
1655 !(*total_flags & FIF_PROMISC_IN_BSS));
1656 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
1657 !(*total_flags & FIF_PROMISC_IN_BSS));
1658 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
1659 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
1660 !(*total_flags & FIF_ALLMULTI));
1661 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
1662 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
1663}
1664
1641static int rt2500usb_beacon_update(struct ieee80211_hw *hw, 1665static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1642 struct sk_buff *skb, 1666 struct sk_buff *skb,
1643 struct ieee80211_tx_control *control) 1667 struct ieee80211_tx_control *control)
@@ -1714,11 +1738,13 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1714 1738
1715static const struct ieee80211_ops rt2500usb_mac80211_ops = { 1739static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1716 .tx = rt2x00mac_tx, 1740 .tx = rt2x00mac_tx,
1741 .start = rt2x00mac_start,
1742 .stop = rt2x00mac_stop,
1717 .add_interface = rt2x00mac_add_interface, 1743 .add_interface = rt2x00mac_add_interface,
1718 .remove_interface = rt2x00mac_remove_interface, 1744 .remove_interface = rt2x00mac_remove_interface,
1719 .config = rt2x00mac_config, 1745 .config = rt2x00mac_config,
1720 .config_interface = rt2x00mac_config_interface, 1746 .config_interface = rt2x00mac_config_interface,
1721 .set_multicast_list = rt2x00mac_set_multicast_list, 1747 .configure_filter = rt2500usb_configure_filter,
1722 .get_stats = rt2x00mac_get_stats, 1748 .get_stats = rt2x00mac_get_stats,
1723 .conf_tx = rt2x00mac_conf_tx, 1749 .conf_tx = rt2x00mac_conf_tx,
1724 .get_tx_stats = rt2x00mac_get_tx_stats, 1750 .get_tx_stats = rt2x00mac_get_tx_stats,
@@ -1739,7 +1765,6 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1739 .fill_rxdone = rt2500usb_fill_rxdone, 1765 .fill_rxdone = rt2500usb_fill_rxdone,
1740 .config_mac_addr = rt2500usb_config_mac_addr, 1766 .config_mac_addr = rt2500usb_config_mac_addr,
1741 .config_bssid = rt2500usb_config_bssid, 1767 .config_bssid = rt2500usb_config_bssid,
1742 .config_packet_filter = rt2500usb_config_packet_filter,
1743 .config_type = rt2500usb_config_type, 1768 .config_type = rt2500usb_config_type,
1744 .config = rt2500usb_config, 1769 .config = rt2500usb_config,
1745}; 1770};
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 80b079d723d6..046eecfb16c0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -294,9 +294,6 @@ struct interface {
294 294
295 /* 295 /*
296 * Current working type (IEEE80211_IF_TYPE_*). 296 * Current working type (IEEE80211_IF_TYPE_*).
297 * This excludes the type IEEE80211_IF_TYPE_MNTR
298 * since that is counted seperately in the monitor_count
299 * field.
300 * When set to INVALID_INTERFACE, no interface is configured. 297 * When set to INVALID_INTERFACE, no interface is configured.
301 */ 298 */
302 int type; 299 int type;
@@ -314,18 +311,8 @@ struct interface {
314 311
315 /* 312 /*
316 * Store the packet filter mode for the current interface. 313 * Store the packet filter mode for the current interface.
317 * monitor mode always disabled filtering. But in such
318 * cases we still need to store the value here in case
319 * the monitor mode interfaces are removed, while a
320 * non-monitor mode interface remains.
321 */ 314 */
322 unsigned short filter; 315 unsigned int filter;
323
324 /*
325 * Monitor mode count, the number of interfaces
326 * in monitor mode that that have been added.
327 */
328 unsigned short monitor_count;
329}; 316};
330 317
331static inline int is_interface_present(struct interface *intf) 318static inline int is_interface_present(struct interface *intf)
@@ -333,9 +320,9 @@ static inline int is_interface_present(struct interface *intf)
333 return !!intf->id; 320 return !!intf->id;
334} 321}
335 322
336static inline int is_monitor_present(struct interface *intf) 323static inline int is_interface_type(struct interface *intf, int type)
337{ 324{
338 return !!intf->monitor_count; 325 return intf->type == type;
339} 326}
340 327
341/* 328/*
@@ -402,7 +389,7 @@ struct rt2x00lib_ops {
402 */ 389 */
403 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, 390 void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev,
404 struct data_desc *txd, 391 struct data_desc *txd,
405 struct data_entry_desc *desc, 392 struct txdata_entry_desc *desc,
406 struct ieee80211_hdr *ieee80211hdr, 393 struct ieee80211_hdr *ieee80211hdr,
407 unsigned int length, 394 unsigned int length,
408 struct ieee80211_tx_control *control); 395 struct ieee80211_tx_control *control);
@@ -415,8 +402,8 @@ struct rt2x00lib_ops {
415 /* 402 /*
416 * RX control handlers 403 * RX control handlers
417 */ 404 */
418 int (*fill_rxdone) (struct data_entry *entry, 405 void (*fill_rxdone) (struct data_entry *entry,
419 int *signal, int *rssi, int *ofdm, int *size); 406 struct rxdata_entry_desc *desc);
420 407
421 /* 408 /*
422 * Configuration handlers. 409 * Configuration handlers.
@@ -511,11 +498,10 @@ struct rt2x00_dev {
511#define DEVICE_INITIALIZED 3 498#define DEVICE_INITIALIZED 3
512#define DEVICE_INITIALIZED_HW 4 499#define DEVICE_INITIALIZED_HW 4
513#define REQUIRE_FIRMWARE 5 500#define REQUIRE_FIRMWARE 5
514#define PACKET_FILTER_SCHEDULED 6 501/* Hole: Add new Flag here */
515#define PACKET_FILTER_PENDING 7
516#define INTERFACE_RESUME 8 502#define INTERFACE_RESUME 8
517#define INTERFACE_ENABLED 9 503#define INTERFACE_ENABLED 9
518#define INTERFACE_ENABLED_MONITOR 10 504/* Hole: Add new Flag here */
519#define REQUIRE_BEACON_RING 11 505#define REQUIRE_BEACON_RING 11
520#define DEVICE_SUPPORT_HW_BUTTON 12 506#define DEVICE_SUPPORT_HW_BUTTON 12
521#define CONFIG_FRAME_TYPE 13 507#define CONFIG_FRAME_TYPE 13
@@ -606,9 +592,10 @@ struct rt2x00_dev {
606 struct ieee80211_rx_status rx_status; 592 struct ieee80211_rx_status rx_status;
607 593
608 /* 594 /*
609 * Beacon scheduled work. 595 * Scheduled work.
610 */ 596 */
611 struct work_struct beacon_work; 597 struct work_struct beacon_work;
598 struct work_struct filter_work;
612 599
613 /* 600 /*
614 * Data ring arrays for RX, TX and Beacon. 601 * Data ring arrays for RX, TX and Beacon.
@@ -760,7 +747,7 @@ void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
760void rt2x00lib_txdone(struct data_entry *entry, 747void rt2x00lib_txdone(struct data_entry *entry,
761 const int status, const int retry); 748 const int status, const int retry);
762void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb, 749void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
763 const int signal, const int rssi, const int ofdm); 750 struct rxdata_entry_desc *desc);
764 751
765/* 752/*
766 * TX descriptor initializer 753 * TX descriptor initializer
@@ -785,8 +772,6 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
785int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 772int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
786int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id, 773int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
787 struct ieee80211_if_conf *conf); 774 struct ieee80211_if_conf *conf);
788void rt2x00mac_set_multicast_list(struct ieee80211_hw *hw,
789 unsigned short flags, int mc_count);
790int rt2x00mac_get_stats(struct ieee80211_hw *hw, 775int rt2x00mac_get_stats(struct ieee80211_hw *hw,
791 struct ieee80211_low_level_stats *stats); 776 struct ieee80211_low_level_stats *stats);
792int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw, 777int 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 de890a17d8fd..f962ce497086 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -46,72 +46,24 @@ void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
46 rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid); 46 rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid);
47} 47}
48 48
49void rt2x00lib_config_packet_filter(struct rt2x00_dev *rt2x00dev, int filter)
50{
51 /*
52 * Only configure the device when something has changed,
53 * or if we are in RESUME state in which case all configuration
54 * will be forced upon the device.
55 */
56 if (!test_bit(INTERFACE_RESUME, &rt2x00dev->flags) &&
57 !test_bit(PACKET_FILTER_PENDING, &rt2x00dev->flags))
58 return;
59
60 /*
61 * Write configuration to device and clear the update flag.
62 */
63 rt2x00dev->ops->lib->config_packet_filter(rt2x00dev, filter);
64 __clear_bit(PACKET_FILTER_PENDING, &rt2x00dev->flags);
65}
66
67void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type) 49void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
68{ 50{
69 struct interface *intf = &rt2x00dev->interface; 51 struct interface *intf = &rt2x00dev->interface;
70 52
71 /*
72 * Fallback when a invalid interface is attempted to
73 * be configured. If a monitor interface is present,
74 * we are going configure that, otherwise exit.
75 */
76 if (type == INVALID_INTERFACE) {
77 if (is_monitor_present(intf))
78 type = IEEE80211_IF_TYPE_MNTR;
79 else
80 return;
81 }
82
83 /*
84 * Only configure the device when something has changed,
85 * or if we are in RESUME state in which case all configuration
86 * will be forced upon the device.
87 */
88 if (!test_bit(INTERFACE_RESUME, &rt2x00dev->flags) && 53 if (!test_bit(INTERFACE_RESUME, &rt2x00dev->flags) &&
89 (!(is_interface_present(intf) ^ 54 (!!test_bit(INTERFACE_ENABLED, &rt2x00dev->flags) ==
90 test_bit(INTERFACE_ENABLED, &rt2x00dev->flags)) && 55 !!is_interface_present(intf)))
91 !(is_monitor_present(intf) ^
92 test_bit(INTERFACE_ENABLED_MONITOR, &rt2x00dev->flags))))
93 return; 56 return;
94 57
95 /*
96 * Configure device.
97 */
98 rt2x00dev->ops->lib->config_type(rt2x00dev, type); 58 rt2x00dev->ops->lib->config_type(rt2x00dev, type);
99 59
100 /* 60 /*
101 * Update the configuration flags. 61 * Update the configuration flags.
102 */ 62 */
103 if (type != IEEE80211_IF_TYPE_MNTR) { 63 if (is_interface_present(intf))
104 if (is_interface_present(intf)) 64 __set_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
105 __set_bit(INTERFACE_ENABLED, &rt2x00dev->flags); 65 else
106 else 66 __clear_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
107 __clear_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
108 } else {
109 if (is_monitor_present(intf))
110 __set_bit(INTERFACE_ENABLED_MONITOR, &rt2x00dev->flags);
111 else
112 __clear_bit(INTERFACE_ENABLED_MONITOR,
113 &rt2x00dev->flags);
114 }
115} 67}
116 68
117void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf) 69void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf)
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index cd82eeface8f..bbccb8933876 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -135,10 +135,12 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
135 return; 135 return;
136 136
137 /* 137 /*
138 * Stop beacon generation. 138 * Stop all scheduled work.
139 */ 139 */
140 if (work_pending(&rt2x00dev->beacon_work)) 140 if (work_pending(&rt2x00dev->beacon_work))
141 cancel_work_sync(&rt2x00dev->beacon_work); 141 cancel_work_sync(&rt2x00dev->beacon_work);
142 if (work_pending(&rt2x00dev->filter_work))
143 cancel_work_sync(&rt2x00dev->filter_work);
142 144
143 /* 145 /*
144 * Stop the TX queues. 146 * Stop the TX queues.
@@ -257,6 +259,17 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
257 LINK_TUNE_INTERVAL); 259 LINK_TUNE_INTERVAL);
258} 260}
259 261
262static void rt2x00lib_packetfilter_scheduled(struct work_struct *work)
263{
264 struct rt2x00_dev *rt2x00dev =
265 container_of(work, struct rt2x00_dev, filter_work);
266
267 rt2x00dev->ops->hw->configure_filter(rt2x00dev->hw,
268 rt2x00dev->interface.filter,
269 &rt2x00dev->interface.filter,
270 0, NULL);
271}
272
260/* 273/*
261 * Interrupt context handlers. 274 * Interrupt context handlers.
262 */ 275 */
@@ -337,7 +350,7 @@ void rt2x00lib_txdone(struct data_entry *entry,
337EXPORT_SYMBOL_GPL(rt2x00lib_txdone); 350EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
338 351
339void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb, 352void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
340 const int signal, const int rssi, const int ofdm) 353 struct rxdata_entry_desc *desc)
341{ 354{
342 struct rt2x00_dev *rt2x00dev = entry->ring->rt2x00dev; 355 struct rt2x00_dev *rt2x00dev = entry->ring->rt2x00dev;
343 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; 356 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
@@ -358,22 +371,24 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
358 * the signal is the PLCP value. If it was received with 371 * the signal is the PLCP value. If it was received with
359 * a CCK bitrate the signal is the rate in 0.5kbit/s. 372 * a CCK bitrate the signal is the rate in 0.5kbit/s.
360 */ 373 */
361 if (!ofdm) 374 if (!desc->ofdm)
362 val = DEVICE_GET_RATE_FIELD(rate->val, RATE); 375 val = DEVICE_GET_RATE_FIELD(rate->val, RATE);
363 else 376 else
364 val = DEVICE_GET_RATE_FIELD(rate->val, PLCP); 377 val = DEVICE_GET_RATE_FIELD(rate->val, PLCP);
365 378
366 if (val == signal) { 379 if (val == desc->signal) {
367 val = rate->val; 380 val = rate->val;
368 break; 381 break;
369 } 382 }
370 } 383 }
371 384
372 rt2x00_update_link_rssi(&rt2x00dev->link, rssi); 385 rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi);
373 rt2x00dev->link.rx_success++; 386 rt2x00dev->link.rx_success++;
374 rx_status->rate = val; 387 rx_status->rate = val;
375 rx_status->signal = rt2x00lib_calculate_link_signal(rt2x00dev, rssi); 388 rx_status->signal =
376 rx_status->ssi = rssi; 389 rt2x00lib_calculate_link_signal(rt2x00dev, desc->rssi);
390 rx_status->ssi = desc->rssi;
391 rx_status->flag = desc->flags;
377 392
378 /* 393 /*
379 * Send frame to mac80211 394 * Send frame to mac80211
@@ -391,7 +406,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
391 unsigned int length, 406 unsigned int length,
392 struct ieee80211_tx_control *control) 407 struct ieee80211_tx_control *control)
393{ 408{
394 struct data_entry_desc desc; 409 struct txdata_entry_desc desc;
395 struct data_ring *ring; 410 struct data_ring *ring;
396 int tx_rate; 411 int tx_rate;
397 int bitrate; 412 int bitrate;
@@ -956,6 +971,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
956 * Initialize configuration work. 971 * Initialize configuration work.
957 */ 972 */
958 INIT_WORK(&rt2x00dev->beacon_work, rt2x00lib_beacondone_scheduled); 973 INIT_WORK(&rt2x00dev->beacon_work, rt2x00lib_beacondone_scheduled);
974 INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled);
959 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); 975 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner);
960 976
961 /* 977 /*
@@ -1098,7 +1114,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1098 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac); 1114 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac);
1099 rt2x00lib_config_bssid(rt2x00dev, intf->bssid); 1115 rt2x00lib_config_bssid(rt2x00dev, intf->bssid);
1100 rt2x00lib_config_type(rt2x00dev, intf->type); 1116 rt2x00lib_config_type(rt2x00dev, intf->type);
1101 rt2x00lib_config_packet_filter(rt2x00dev, intf->filter);
1102 1117
1103 /* 1118 /*
1104 * When in Master or Ad-hoc mode, 1119 * When in Master or Ad-hoc mode,
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 3324090a96a7..fcc2ffdd1a3c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -51,7 +51,6 @@ void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev);
51 */ 51 */
52void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac); 52void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac);
53void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid); 53void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid);
54void rt2x00lib_config_packet_filter(struct rt2x00_dev *rt2x00dev, int filter);
55void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type); 54void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type);
56void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf); 55void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf);
57 56
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 778ed41e21ef..17802f6d3d6d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -176,46 +176,26 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
176{ 176{
177 struct rt2x00_dev *rt2x00dev = hw->priv; 177 struct rt2x00_dev *rt2x00dev = hw->priv;
178 struct interface *intf = &rt2x00dev->interface; 178 struct interface *intf = &rt2x00dev->interface;
179 int retval;
180 179
181 /* 180 /*
182 * We only support 1 non-monitor interface. 181 * We only support 1 non-monitor interface.
183 */ 182 */
184 if (conf->type != IEEE80211_IF_TYPE_MNTR && is_interface_present(intf)) 183 if (is_interface_present(intf))
185 return -ENOBUFS; 184 return -ENOBUFS;
186 185
187 /* 186 intf->id = conf->if_id;
188 * HACK: Placeholder until start/stop handler has been 187 intf->type = conf->type;
189 * added to the mac80211 callback functions structure. 188 if (conf->type == IEEE80211_IF_TYPE_AP)
190 */ 189 memcpy(&intf->bssid, conf->mac_addr, ETH_ALEN);
191 retval = rt2x00mac_start(hw); 190 memcpy(&intf->mac, conf->mac_addr, ETH_ALEN);
192 if (retval)
193 return retval;
194
195 /*
196 * We support muliple monitor mode interfaces.
197 * All we need to do is increase the monitor_count.
198 */
199 if (conf->type == IEEE80211_IF_TYPE_MNTR) {
200 intf->monitor_count++;
201 } else {
202 intf->id = conf->if_id;
203 intf->type = conf->type;
204 if (conf->type == IEEE80211_IF_TYPE_AP)
205 memcpy(&intf->bssid, conf->mac_addr, ETH_ALEN);
206 memcpy(&intf->mac, conf->mac_addr, ETH_ALEN);
207 intf->filter = 0;
208 }
209 191
210 /* 192 /*
211 * Configure interface.
212 * The MAC adddress must be configured after the device 193 * The MAC adddress must be configured after the device
213 * has been initialized. Else the device can reset the 194 * has been initialized. Otherwise the device can reset
214 * MAC registers. 195 * the MAC registers.
215 */ 196 */
216 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac); 197 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac);
217 rt2x00lib_config_type(rt2x00dev, conf->type); 198 rt2x00lib_config_type(rt2x00dev, conf->type);
218 rt2x00lib_config_packet_filter(rt2x00dev, intf->filter);
219 199
220 return 0; 200 return 0;
221} 201}
@@ -230,22 +210,13 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
230 /* 210 /*
231 * We only support 1 non-monitor interface. 211 * We only support 1 non-monitor interface.
232 */ 212 */
233 if (conf->type != IEEE80211_IF_TYPE_MNTR && !is_interface_present(intf)) 213 if (!is_interface_present(intf))
234 return; 214 return;
235 215
236 /* 216 intf->id = 0;
237 * When removing an monitor interface, decrease monitor_count. 217 intf->type = INVALID_INTERFACE;
238 * For non-monitor interfaces, all interface data needs to be reset. 218 memset(&intf->bssid, 0x00, ETH_ALEN);
239 */ 219 memset(&intf->mac, 0x00, ETH_ALEN);
240 if (conf->type == IEEE80211_IF_TYPE_MNTR) {
241 intf->monitor_count--;
242 } else if (intf->type == conf->type) {
243 intf->id = 0;
244 intf->type = INVALID_INTERFACE;
245 memset(&intf->bssid, 0x00, ETH_ALEN);
246 memset(&intf->mac, 0x00, ETH_ALEN);
247 intf->filter = 0;
248 }
249 220
250 /* 221 /*
251 * Make sure the bssid and mac address registers 222 * Make sure the bssid and mac address registers
@@ -254,12 +225,6 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
254 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac); 225 rt2x00lib_config_mac_addr(rt2x00dev, intf->mac);
255 rt2x00lib_config_bssid(rt2x00dev, intf->bssid); 226 rt2x00lib_config_bssid(rt2x00dev, intf->bssid);
256 rt2x00lib_config_type(rt2x00dev, intf->type); 227 rt2x00lib_config_type(rt2x00dev, intf->type);
257
258 /*
259 * HACK: Placeholder untill start/stop handler has been
260 * added to the mac80211 callback functions structure.
261 */
262 rt2x00mac_stop(hw);
263} 228}
264EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface); 229EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);
265 230
@@ -290,14 +255,6 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
290 rt2x00lib_config(rt2x00dev, conf); 255 rt2x00lib_config(rt2x00dev, conf);
291 256
292 /* 257 /*
293 * If promisc mode cannot be configured in irq context,
294 * then it is now the time to configure it.
295 */
296 if (test_bit(PACKET_FILTER_SCHEDULED, &rt2x00dev->flags))
297 rt2x00lib_config_packet_filter(rt2x00dev,
298 rt2x00dev->interface.filter);
299
300 /*
301 * Reenable RX only if the radio should be on. 258 * Reenable RX only if the radio should be on.
302 */ 259 */
303 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 260 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
@@ -326,13 +283,10 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
326 return 0; 283 return 0;
327 284
328 /* 285 /*
329 * Monitor mode does not need configuring.
330 * If the given type does not match the configured type, 286 * If the given type does not match the configured type,
331 * there has been a problem. 287 * there has been a problem.
332 */ 288 */
333 if (conf->type == IEEE80211_IF_TYPE_MNTR) 289 if (conf->type != intf->type)
334 return 0;
335 else if (conf->type != intf->type)
336 return -EINVAL; 290 return -EINVAL;
337 291
338 /* 292 /*
@@ -360,36 +314,6 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
360} 314}
361EXPORT_SYMBOL_GPL(rt2x00mac_config_interface); 315EXPORT_SYMBOL_GPL(rt2x00mac_config_interface);
362 316
363void rt2x00mac_set_multicast_list(struct ieee80211_hw *hw,
364 unsigned short flags, int mc_count)
365{
366 struct rt2x00_dev *rt2x00dev = hw->priv;
367
368 /*
369 * Check if the new state is different then the old state.
370 */
371 if (rt2x00dev->interface.filter == flags)
372 return;
373
374 rt2x00dev->interface.filter = flags;
375
376 /*
377 * Raise the pending bit to indicate the
378 * packet filter should be updated.
379 */
380 __set_bit(PACKET_FILTER_PENDING, &rt2x00dev->flags);
381
382 /*
383 * Check if Packet filter actions are allowed in
384 * atomic context. If not, raise the pending flag and
385 * let it be.
386 */
387 if (!test_bit(PACKET_FILTER_SCHEDULED, &rt2x00dev->flags) ||
388 !in_atomic())
389 rt2x00lib_config_packet_filter(rt2x00dev, flags);
390}
391EXPORT_SYMBOL_GPL(rt2x00mac_set_multicast_list);
392
393int rt2x00mac_get_stats(struct ieee80211_hw *hw, 317int rt2x00mac_get_stats(struct ieee80211_hw *hw,
394 struct ieee80211_low_level_stats *stats) 318 struct ieee80211_low_level_stats *stats)
395{ 319{
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 85629f1999ab..2780df00623c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -124,47 +124,40 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev)
124 struct data_entry *entry; 124 struct data_entry *entry;
125 struct data_desc *rxd; 125 struct data_desc *rxd;
126 struct sk_buff *skb; 126 struct sk_buff *skb;
127 u32 desc; 127 struct rxdata_entry_desc desc;
128 int retval; 128 u32 word;
129 int signal;
130 int rssi;
131 int ofdm;
132 int size;
133 129
134 while (1) { 130 while (1) {
135 entry = rt2x00_get_data_entry(ring); 131 entry = rt2x00_get_data_entry(ring);
136 rxd = entry->priv; 132 rxd = entry->priv;
137 rt2x00_desc_read(rxd, 0, &desc); 133 rt2x00_desc_read(rxd, 0, &word);
138 134
139 if (rt2x00_get_field32(desc, RXD_ENTRY_OWNER_NIC)) 135 if (rt2x00_get_field32(word, RXD_ENTRY_OWNER_NIC))
140 break; 136 break;
141 137
142 retval = rt2x00dev->ops->lib->fill_rxdone(entry, &signal, 138 memset(&desc, 0x00, sizeof(desc));
143 &rssi, &ofdm, &size); 139 rt2x00dev->ops->lib->fill_rxdone(entry, &desc);
144 if (retval)
145 goto skip_entry;
146 140
147 /* 141 /*
148 * Allocate the sk_buffer, initialize it and copy 142 * Allocate the sk_buffer, initialize it and copy
149 * all data into it. 143 * all data into it.
150 */ 144 */
151 skb = dev_alloc_skb(size + NET_IP_ALIGN); 145 skb = dev_alloc_skb(desc.size + NET_IP_ALIGN);
152 if (!skb) 146 if (!skb)
153 return; 147 return;
154 148
155 skb_reserve(skb, NET_IP_ALIGN); 149 skb_reserve(skb, NET_IP_ALIGN);
156 skb_put(skb, size); 150 skb_put(skb, desc.size);
157 memcpy(skb->data, entry->data_addr, size); 151 memcpy(skb->data, entry->data_addr, desc.size);
158 152
159 /* 153 /*
160 * Send the frame to rt2x00lib for further processing. 154 * Send the frame to rt2x00lib for further processing.
161 */ 155 */
162 rt2x00lib_rxdone(entry, skb, signal, rssi, ofdm); 156 rt2x00lib_rxdone(entry, skb, &desc);
163 157
164skip_entry:
165 if (test_bit(DEVICE_ENABLED_RADIO, &ring->rt2x00dev->flags)) { 158 if (test_bit(DEVICE_ENABLED_RADIO, &ring->rt2x00dev->flags)) {
166 rt2x00_set_field32(&desc, RXD_ENTRY_OWNER_NIC, 1); 159 rt2x00_set_field32(&word, RXD_ENTRY_OWNER_NIC, 1);
167 rt2x00_desc_write(rxd, 0, desc); 160 rt2x00_desc_write(rxd, 0, word);
168 } 161 }
169 162
170 rt2x00_ring_index_inc(ring); 163 rt2x00_ring_index_inc(ring);
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index dc5b696f4751..b54457c921c5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -45,11 +45,9 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
45 return 0; 45 return 0;
46 46
47 /* 47 /*
48 * Only continue if we have an active interface, 48 * Only continue if we have an active interface.
49 * either monitor or non-monitor should be present.
50 */ 49 */
51 if (!is_interface_present(&rt2x00dev->interface) && 50 if (!is_interface_present(&rt2x00dev->interface))
52 !is_monitor_present(&rt2x00dev->interface))
53 return 0; 51 return 0;
54 52
55 if (state == RFKILL_STATE_ON) { 53 if (state == RFKILL_STATE_ON) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00ring.h b/drivers/net/wireless/rt2x00/rt2x00ring.h
index 122c75248e74..1a864d32cfbd 100644
--- a/drivers/net/wireless/rt2x00/rt2x00ring.h
+++ b/drivers/net/wireless/rt2x00/rt2x00ring.h
@@ -41,11 +41,24 @@ struct data_desc {
41}; 41};
42 42
43/* 43/*
44 * data_entry_desc 44 * rxdata_entry_desc
45 * Summary of information that has been read from the
46 * RX frame descriptor.
47 */
48struct rxdata_entry_desc {
49 int signal;
50 int rssi;
51 int ofdm;
52 int size;
53 int flags;
54};
55
56/*
57 * txdata_entry_desc
45 * Summary of information that should be written into the 58 * Summary of information that should be written into the
46 * descriptor for sending a TX frame. 59 * descriptor for sending a TX frame.
47 */ 60 */
48struct data_entry_desc { 61struct txdata_entry_desc {
49 unsigned long flags; 62 unsigned long flags;
50#define ENTRY_TXDONE 1 63#define ENTRY_TXDONE 1
51#define ENTRY_TXD_RTS_FRAME 2 64#define ENTRY_TXD_RTS_FRAME 2
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index a0f05ca54bb4..8d2081189025 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -220,11 +220,7 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
220 struct data_ring *ring = entry->ring; 220 struct data_ring *ring = entry->ring;
221 struct rt2x00_dev *rt2x00dev = ring->rt2x00dev; 221 struct rt2x00_dev *rt2x00dev = ring->rt2x00dev;
222 struct sk_buff *skb; 222 struct sk_buff *skb;
223 int retval; 223 struct rxdata_entry_desc desc;
224 int signal;
225 int rssi;
226 int ofdm;
227 int size;
228 int frame_size; 224 int frame_size;
229 225
230 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 226 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) ||
@@ -239,10 +235,8 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
239 if (urb->actual_length < entry->ring->desc_size || urb->status) 235 if (urb->actual_length < entry->ring->desc_size || urb->status)
240 goto skip_entry; 236 goto skip_entry;
241 237
242 retval = rt2x00dev->ops->lib->fill_rxdone(entry, &signal, &rssi, 238 memset(&desc, 0x00, sizeof(desc));
243 &ofdm, &size); 239 rt2x00dev->ops->lib->fill_rxdone(entry, &desc);
244 if (retval)
245 goto skip_entry;
246 240
247 /* 241 /*
248 * Allocate a new sk buffer to replace the current one. 242 * Allocate a new sk buffer to replace the current one.
@@ -261,12 +255,12 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
261 * Trim the skb_buffer to only contain the valid 255 * Trim the skb_buffer to only contain the valid
262 * frame data (so ignore the device's descriptor). 256 * frame data (so ignore the device's descriptor).
263 */ 257 */
264 skb_trim(entry->skb, size); 258 skb_trim(entry->skb, desc.size);
265 259
266 /* 260 /*
267 * Send the frame to rt2x00lib for further processing. 261 * Send the frame to rt2x00lib for further processing.
268 */ 262 */
269 rt2x00lib_rxdone(entry, entry->skb, signal, rssi, ofdm); 263 rt2x00lib_rxdone(entry, entry->skb, &desc);
270 264
271 /* 265 /*
272 * Replace current entry's skb with the newly allocated one, 266 * Replace current entry's skb with the newly allocated one,
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 09c8c96e2f83..dea7a8a4fa00 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -312,23 +312,9 @@ static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
312 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg)); 312 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
313} 313}
314 314
315static void rt61pci_config_packet_filter(struct rt2x00_dev *rt2x00dev,
316 const unsigned int filter)
317{
318 int promisc = !!(filter & IFF_PROMISC);
319 int multicast = !!(filter & IFF_MULTICAST);
320 int broadcast = !!(filter & IFF_BROADCAST);
321 u32 reg;
322
323 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
324 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME, !promisc);
325 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST, !multicast);
326 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BORADCAST, !broadcast);
327 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
328}
329
330static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type) 315static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
331{ 316{
317 struct interface *intf = &rt2x00dev->interface;
332 u32 reg; 318 u32 reg;
333 319
334 /* 320 /*
@@ -344,56 +330,19 @@ static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
344 rt2x00pci_register_write(rt2x00dev, HW_BEACON_BASE3, 0); 330 rt2x00pci_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
345 331
346 /* 332 /*
347 * Apply hardware packet filter.
348 */
349 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
350
351 if (!is_monitor_present(&rt2x00dev->interface) &&
352 (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
353 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS, 1);
354 else
355 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS, 0);
356
357 /*
358 * If there is a non-monitor interface present
359 * the packet should be strict (even if a monitor interface is present!).
360 * When there is only 1 interface present which is in monitor mode
361 * we should start accepting _all_ frames.
362 */
363 if (is_interface_present(&rt2x00dev->interface)) {
364 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC, 1);
365 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL, 1);
366 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL, 1);
367 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
368 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 1);
369 } else if (is_monitor_present(&rt2x00dev->interface)) {
370 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC, 0);
371 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL, 0);
372 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL, 0);
373 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 0);
374 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 0);
375 }
376
377 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
378
379 /*
380 * Enable synchronisation. 333 * Enable synchronisation.
381 */ 334 */
382 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg); 335 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
383 if (is_interface_present(&rt2x00dev->interface)) { 336 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
384 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1); 337 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
385 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
386 }
387
388 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0); 338 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
389 if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP) 339 if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
340 is_interface_type(intf, IEEE80211_IF_TYPE_AP))
390 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2); 341 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
391 else if (type == IEEE80211_IF_TYPE_STA) 342 else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
392 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1); 343 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
393 else if (is_monitor_present(&rt2x00dev->interface) && 344 else
394 !is_interface_present(&rt2x00dev->interface))
395 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0); 345 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
396
397 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg); 346 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
398} 347}
399 348
@@ -1686,7 +1635,7 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1686 */ 1635 */
1687static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1636static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1688 struct data_desc *txd, 1637 struct data_desc *txd,
1689 struct data_entry_desc *desc, 1638 struct txdata_entry_desc *desc,
1690 struct ieee80211_hdr *ieee80211hdr, 1639 struct ieee80211_hdr *ieee80211hdr,
1691 unsigned int length, 1640 unsigned int length,
1692 struct ieee80211_tx_control *control) 1641 struct ieee80211_tx_control *control)
@@ -1826,8 +1775,8 @@ static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1826 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset; 1775 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset;
1827} 1776}
1828 1777
1829static int rt61pci_fill_rxdone(struct data_entry *entry, 1778static void rt61pci_fill_rxdone(struct data_entry *entry,
1830 int *signal, int *rssi, int *ofdm, int *size) 1779 struct rxdata_entry_desc *desc)
1831{ 1780{
1832 struct data_desc *rxd = entry->priv; 1781 struct data_desc *rxd = entry->priv;
1833 u32 word0; 1782 u32 word0;
@@ -1836,19 +1785,19 @@ static int rt61pci_fill_rxdone(struct data_entry *entry,
1836 rt2x00_desc_read(rxd, 0, &word0); 1785 rt2x00_desc_read(rxd, 0, &word0);
1837 rt2x00_desc_read(rxd, 1, &word1); 1786 rt2x00_desc_read(rxd, 1, &word1);
1838 1787
1839 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) || 1788 desc->flags = 0;
1840 rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR)) 1789 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1841 return -EINVAL; 1790 desc->flags |= RX_FLAG_FAILED_FCS_CRC;
1842 1791
1843 /* 1792 /*
1844 * Obtain the status about this packet. 1793 * Obtain the status about this packet.
1845 */ 1794 */
1846 *signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1795 desc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1847 *rssi = rt61pci_agc_to_rssi(entry->ring->rt2x00dev, word1); 1796 desc->rssi = rt61pci_agc_to_rssi(entry->ring->rt2x00dev, word1);
1848 *ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); 1797 desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1849 *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1798 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1850 1799
1851 return 0; 1800 return;
1852} 1801}
1853 1802
1854/* 1803/*
@@ -2340,9 +2289,7 @@ static void rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2340 */ 2289 */
2341 rt2x00dev->hw->flags = 2290 rt2x00dev->hw->flags =
2342 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 2291 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
2343 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 2292 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
2344 IEEE80211_HW_MONITOR_DURING_OPER |
2345 IEEE80211_HW_NO_PROBE_FILTERING;
2346 rt2x00dev->hw->extra_tx_headroom = 0; 2293 rt2x00dev->hw->extra_tx_headroom = 0;
2347 rt2x00dev->hw->max_signal = MAX_SIGNAL; 2294 rt2x00dev->hw->max_signal = MAX_SIGNAL;
2348 rt2x00dev->hw->max_rssi = MAX_RX_SSI; 2295 rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -2426,6 +2373,74 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2426/* 2373/*
2427 * IEEE80211 stack callback functions. 2374 * IEEE80211 stack callback functions.
2428 */ 2375 */
2376static void rt61pci_configure_filter(struct ieee80211_hw *hw,
2377 unsigned int changed_flags,
2378 unsigned int *total_flags,
2379 int mc_count,
2380 struct dev_addr_list *mc_list)
2381{
2382 struct rt2x00_dev *rt2x00dev = hw->priv;
2383 struct interface *intf = &rt2x00dev->interface;
2384 u32 reg;
2385
2386 /*
2387 * Mask off any flags we are going to ignore from
2388 * the total_flags field.
2389 */
2390 *total_flags &=
2391 FIF_ALLMULTI |
2392 FIF_FCSFAIL |
2393 FIF_PLCPFAIL |
2394 FIF_CONTROL |
2395 FIF_OTHER_BSS |
2396 FIF_PROMISC_IN_BSS;
2397
2398 /*
2399 * Apply some rules to the filters:
2400 * - Some filters imply different filters to be set.
2401 * - Some things we can't filter out at all.
2402 * - Some filters are set based on interface type.
2403 */
2404 if (mc_count)
2405 *total_flags |= FIF_ALLMULTI;
2406 if (changed_flags & FIF_OTHER_BSS ||
2407 changed_flags & FIF_PROMISC_IN_BSS)
2408 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
2409 if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
2410 *total_flags |= FIF_PROMISC_IN_BSS;
2411
2412 /*
2413 * Check if there is any work left for us.
2414 */
2415 if (intf->filter == *total_flags)
2416 return;
2417 intf->filter = *total_flags;
2418
2419 /*
2420 * Start configuration steps.
2421 * Note that the version error will always be dropped
2422 * and broadcast frames will always be accepted since
2423 * there is no filter for it at this time.
2424 */
2425 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
2426 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
2427 !(*total_flags & FIF_FCSFAIL));
2428 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
2429 !(*total_flags & FIF_PLCPFAIL));
2430 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
2431 !(*total_flags & FIF_CONTROL));
2432 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
2433 !(*total_flags & FIF_PROMISC_IN_BSS));
2434 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
2435 !(*total_flags & FIF_PROMISC_IN_BSS));
2436 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
2437 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
2438 !(*total_flags & FIF_ALLMULTI));
2439 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BORADCAST, 0);
2440 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 1);
2441 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
2442}
2443
2429static int rt61pci_set_retry_limit(struct ieee80211_hw *hw, 2444static int rt61pci_set_retry_limit(struct ieee80211_hw *hw,
2430 u32 short_retry, u32 long_retry) 2445 u32 short_retry, u32 long_retry)
2431{ 2446{
@@ -2506,11 +2521,13 @@ int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2506 2521
2507static const struct ieee80211_ops rt61pci_mac80211_ops = { 2522static const struct ieee80211_ops rt61pci_mac80211_ops = {
2508 .tx = rt2x00mac_tx, 2523 .tx = rt2x00mac_tx,
2524 .start = rt2x00mac_start,
2525 .stop = rt2x00mac_stop,
2509 .add_interface = rt2x00mac_add_interface, 2526 .add_interface = rt2x00mac_add_interface,
2510 .remove_interface = rt2x00mac_remove_interface, 2527 .remove_interface = rt2x00mac_remove_interface,
2511 .config = rt2x00mac_config, 2528 .config = rt2x00mac_config,
2512 .config_interface = rt2x00mac_config_interface, 2529 .config_interface = rt2x00mac_config_interface,
2513 .set_multicast_list = rt2x00mac_set_multicast_list, 2530 .configure_filter = rt61pci_configure_filter,
2514 .get_stats = rt2x00mac_get_stats, 2531 .get_stats = rt2x00mac_get_stats,
2515 .set_retry_limit = rt61pci_set_retry_limit, 2532 .set_retry_limit = rt61pci_set_retry_limit,
2516 .conf_tx = rt2x00mac_conf_tx, 2533 .conf_tx = rt2x00mac_conf_tx,
@@ -2540,7 +2557,6 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2540 .fill_rxdone = rt61pci_fill_rxdone, 2557 .fill_rxdone = rt61pci_fill_rxdone,
2541 .config_mac_addr = rt61pci_config_mac_addr, 2558 .config_mac_addr = rt61pci_config_mac_addr,
2542 .config_bssid = rt61pci_config_bssid, 2559 .config_bssid = rt61pci_config_bssid,
2543 .config_packet_filter = rt61pci_config_packet_filter,
2544 .config_type = rt61pci_config_type, 2560 .config_type = rt61pci_config_type,
2545 .config = rt61pci_config, 2561 .config = rt61pci_config,
2546}; 2562};
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 3397881bd63d..aac13aa4039c 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -293,23 +293,9 @@ static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
293 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg)); 293 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
294} 294}
295 295
296static void rt73usb_config_packet_filter(struct rt2x00_dev *rt2x00dev,
297 const unsigned int filter)
298{
299 int promisc = !!(filter & IFF_PROMISC);
300 int multicast = !!(filter & IFF_MULTICAST);
301 int broadcast = !!(filter & IFF_BROADCAST);
302 u32 reg;
303
304 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
305 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME, !promisc);
306 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST, !multicast);
307 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BORADCAST, !broadcast);
308 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
309}
310
311static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type) 296static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
312{ 297{
298 struct interface *intf = &rt2x00dev->interface;
313 u32 reg; 299 u32 reg;
314 300
315 /* 301 /*
@@ -325,56 +311,19 @@ static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
325 rt73usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0); 311 rt73usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
326 312
327 /* 313 /*
328 * Apply hardware packet filter.
329 */
330 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
331
332 if (!is_monitor_present(&rt2x00dev->interface) &&
333 (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
334 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS, 1);
335 else
336 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS, 0);
337
338 /*
339 * If there is a non-monitor interface present
340 * the packet should be strict (even if a monitor interface is present!).
341 * When there is only 1 interface present which is in monitor mode
342 * we should start accepting _all_ frames.
343 */
344 if (is_interface_present(&rt2x00dev->interface)) {
345 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC, 1);
346 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL, 1);
347 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL, 1);
348 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
349 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 1);
350 } else if (is_monitor_present(&rt2x00dev->interface)) {
351 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC, 0);
352 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL, 0);
353 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL, 0);
354 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 0);
355 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 0);
356 }
357
358 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
359
360 /*
361 * Enable synchronisation. 314 * Enable synchronisation.
362 */ 315 */
363 rt73usb_register_read(rt2x00dev, TXRX_CSR9, &reg); 316 rt73usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
364 if (is_interface_present(&rt2x00dev->interface)) { 317 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
365 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1); 318 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
366 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
367 }
368
369 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0); 319 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
370 if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP) 320 if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
321 is_interface_type(intf, IEEE80211_IF_TYPE_AP))
371 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2); 322 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
372 else if (type == IEEE80211_IF_TYPE_STA) 323 else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
373 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1); 324 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
374 else if (is_monitor_present(&rt2x00dev->interface) && 325 else
375 !is_interface_present(&rt2x00dev->interface))
376 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0); 326 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
377
378 rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg); 327 rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
379} 328}
380 329
@@ -1301,7 +1250,7 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1301 */ 1250 */
1302static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1251static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1303 struct data_desc *txd, 1252 struct data_desc *txd,
1304 struct data_entry_desc *desc, 1253 struct txdata_entry_desc *desc,
1305 struct ieee80211_hdr *ieee80211hdr, 1254 struct ieee80211_hdr *ieee80211hdr,
1306 unsigned int length, 1255 unsigned int length,
1307 struct ieee80211_tx_control *control) 1256 struct ieee80211_tx_control *control)
@@ -1429,8 +1378,8 @@ static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1429 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset; 1378 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset;
1430} 1379}
1431 1380
1432static int rt73usb_fill_rxdone(struct data_entry *entry, 1381static void rt73usb_fill_rxdone(struct data_entry *entry,
1433 int *signal, int *rssi, int *ofdm, int *size) 1382 struct rxdata_entry_desc *desc)
1434{ 1383{
1435 struct data_desc *rxd = (struct data_desc *)entry->skb->data; 1384 struct data_desc *rxd = (struct data_desc *)entry->skb->data;
1436 u32 word0; 1385 u32 word0;
@@ -1439,24 +1388,24 @@ static int rt73usb_fill_rxdone(struct data_entry *entry,
1439 rt2x00_desc_read(rxd, 0, &word0); 1388 rt2x00_desc_read(rxd, 0, &word0);
1440 rt2x00_desc_read(rxd, 1, &word1); 1389 rt2x00_desc_read(rxd, 1, &word1);
1441 1390
1442 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) || 1391 desc->flags = 0;
1443 rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR)) 1392 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1444 return -EINVAL; 1393 desc->flags |= RX_FLAG_FAILED_FCS_CRC;
1445 1394
1446 /* 1395 /*
1447 * Obtain the status about this packet. 1396 * Obtain the status about this packet.
1448 */ 1397 */
1449 *signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1398 desc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1450 *rssi = rt73usb_agc_to_rssi(entry->ring->rt2x00dev, word1); 1399 desc->rssi = rt73usb_agc_to_rssi(entry->ring->rt2x00dev, word1);
1451 *ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); 1400 desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1452 *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1401 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1453 1402
1454 /* 1403 /*
1455 * Pull the skb to clear the descriptor area. 1404 * Pull the skb to clear the descriptor area.
1456 */ 1405 */
1457 skb_pull(entry->skb, entry->ring->desc_size); 1406 skb_pull(entry->skb, entry->ring->desc_size);
1458 1407
1459 return 0; 1408 return;
1460} 1409}
1461 1410
1462/* 1411/*
@@ -1802,9 +1751,7 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1802 */ 1751 */
1803 rt2x00dev->hw->flags = 1752 rt2x00dev->hw->flags =
1804 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 1753 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
1805 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1754 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
1806 IEEE80211_HW_MONITOR_DURING_OPER |
1807 IEEE80211_HW_NO_PROBE_FILTERING;
1808 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; 1755 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
1809 rt2x00dev->hw->max_signal = MAX_SIGNAL; 1756 rt2x00dev->hw->max_signal = MAX_SIGNAL;
1810 rt2x00dev->hw->max_rssi = MAX_RX_SSI; 1757 rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1878,11 +1825,9 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1878 rt73usb_probe_hw_mode(rt2x00dev); 1825 rt73usb_probe_hw_mode(rt2x00dev);
1879 1826
1880 /* 1827 /*
1881 * USB devices require scheduled packet filter toggling
1882 * This device requires firmware 1828 * This device requires firmware
1883 */ 1829 */
1884 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->flags); 1830 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->flags);
1885 __set_bit(PACKET_FILTER_SCHEDULED, &rt2x00dev->flags);
1886 1831
1887 /* 1832 /*
1888 * Set the rssi offset. 1833 * Set the rssi offset.
@@ -1895,6 +1840,83 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1895/* 1840/*
1896 * IEEE80211 stack callback functions. 1841 * IEEE80211 stack callback functions.
1897 */ 1842 */
1843static void rt73usb_configure_filter(struct ieee80211_hw *hw,
1844 unsigned int changed_flags,
1845 unsigned int *total_flags,
1846 int mc_count,
1847 struct dev_addr_list *mc_list)
1848{
1849 struct rt2x00_dev *rt2x00dev = hw->priv;
1850 struct interface *intf = &rt2x00dev->interface;
1851 u32 reg;
1852
1853 /*
1854 * Mask off any flags we are going to ignore from
1855 * the total_flags field.
1856 */
1857 *total_flags &=
1858 FIF_ALLMULTI |
1859 FIF_FCSFAIL |
1860 FIF_PLCPFAIL |
1861 FIF_CONTROL |
1862 FIF_OTHER_BSS |
1863 FIF_PROMISC_IN_BSS;
1864
1865 /*
1866 * Apply some rules to the filters:
1867 * - Some filters imply different filters to be set.
1868 * - Some things we can't filter out at all.
1869 * - Some filters are set based on interface type.
1870 */
1871 if (mc_count)
1872 *total_flags |= FIF_ALLMULTI;
1873 if (changed_flags & FIF_OTHER_BSS ||
1874 changed_flags & FIF_PROMISC_IN_BSS)
1875 *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
1876 if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
1877 *total_flags |= FIF_PROMISC_IN_BSS;
1878
1879 /*
1880 * Check if there is any work left for us.
1881 */
1882 if (intf->filter == *total_flags)
1883 return;
1884 intf->filter = *total_flags;
1885
1886 /*
1887 * When in atomic context, reschedule and let rt2x00lib
1888 * call this function again.
1889 */
1890 if (in_atomic()) {
1891 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);
1892 return;
1893 }
1894
1895 /*
1896 * Start configuration steps.
1897 * Note that the version error will always be dropped
1898 * and broadcast frames will always be accepted since
1899 * there is no filter for it at this time.
1900 */
1901 rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1902 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CRC,
1903 !(*total_flags & FIF_FCSFAIL));
1904 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_PHYSICAL,
1905 !(*total_flags & FIF_PLCPFAIL));
1906 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_CONTROL,
1907 !(*total_flags & FIF_CONTROL));
1908 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_NOT_TO_ME,
1909 !(*total_flags & FIF_PROMISC_IN_BSS));
1910 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_TO_DS,
1911 !(*total_flags & FIF_PROMISC_IN_BSS));
1912 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_VERSION_ERROR, 1);
1913 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_MULTICAST,
1914 !(*total_flags & FIF_ALLMULTI));
1915 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_BROADCAST, 0);
1916 rt2x00_set_field32(&reg, TXRX_CSR0_DROP_ACK_CTS, 1);
1917 rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1918}
1919
1898static int rt73usb_set_retry_limit(struct ieee80211_hw *hw, 1920static int rt73usb_set_retry_limit(struct ieee80211_hw *hw,
1899 u32 short_retry, u32 long_retry) 1921 u32 short_retry, u32 long_retry)
1900{ 1922{
@@ -1977,11 +1999,13 @@ int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
1977 1999
1978static const struct ieee80211_ops rt73usb_mac80211_ops = { 2000static const struct ieee80211_ops rt73usb_mac80211_ops = {
1979 .tx = rt2x00mac_tx, 2001 .tx = rt2x00mac_tx,
2002 .start = rt2x00mac_start,
2003 .stop = rt2x00mac_stop,
1980 .add_interface = rt2x00mac_add_interface, 2004 .add_interface = rt2x00mac_add_interface,
1981 .remove_interface = rt2x00mac_remove_interface, 2005 .remove_interface = rt2x00mac_remove_interface,
1982 .config = rt2x00mac_config, 2006 .config = rt2x00mac_config,
1983 .config_interface = rt2x00mac_config_interface, 2007 .config_interface = rt2x00mac_config_interface,
1984 .set_multicast_list = rt2x00mac_set_multicast_list, 2008 .configure_filter = rt73usb_configure_filter,
1985 .get_stats = rt2x00mac_get_stats, 2009 .get_stats = rt2x00mac_get_stats,
1986 .set_retry_limit = rt73usb_set_retry_limit, 2010 .set_retry_limit = rt73usb_set_retry_limit,
1987 .conf_tx = rt2x00mac_conf_tx, 2011 .conf_tx = rt2x00mac_conf_tx,
@@ -2012,7 +2036,6 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2012 .fill_rxdone = rt73usb_fill_rxdone, 2036 .fill_rxdone = rt73usb_fill_rxdone,
2013 .config_mac_addr = rt73usb_config_mac_addr, 2037 .config_mac_addr = rt73usb_config_mac_addr,
2014 .config_bssid = rt73usb_config_bssid, 2038 .config_bssid = rt73usb_config_bssid,
2015 .config_packet_filter = rt73usb_config_packet_filter,
2016 .config_type = rt73usb_config_type, 2039 .config_type = rt73usb_config_type,
2017 .config = rt73usb_config, 2040 .config = rt73usb_config,
2018}; 2041};
diff --git a/drivers/net/wireless/rt2x00/rt73usb.h b/drivers/net/wireless/rt2x00/rt73usb.h
index 5d63a1a714f3..f0951519f74b 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.h
+++ b/drivers/net/wireless/rt2x00/rt73usb.h
@@ -290,7 +290,7 @@ struct hw_pairwise_ta_entry {
290#define TXRX_CSR0_DROP_TO_DS FIELD32(0x00200000) 290#define TXRX_CSR0_DROP_TO_DS FIELD32(0x00200000)
291#define TXRX_CSR0_DROP_VERSION_ERROR FIELD32(0x00400000) 291#define TXRX_CSR0_DROP_VERSION_ERROR FIELD32(0x00400000)
292#define TXRX_CSR0_DROP_MULTICAST FIELD32(0x00800000) 292#define TXRX_CSR0_DROP_MULTICAST FIELD32(0x00800000)
293#define TXRX_CSR0_DROP_BORADCAST FIELD32(0x01000000) 293#define TXRX_CSR0_DROP_BROADCAST FIELD32(0x01000000)
294#define TXRX_CSR0_DROP_ACK_CTS FIELD32(0x02000000) 294#define TXRX_CSR0_DROP_ACK_CTS FIELD32(0x02000000)
295#define TXRX_CSR0_TX_WITHOUT_WAITING FIELD32(0x04000000) 295#define TXRX_CSR0_TX_WITHOUT_WAITING FIELD32(0x04000000)
296 296