diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-09-17 01:29:23 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:57 -0400 |
commit | 4150c57212ad134765dd78c654a4b9906252b66d (patch) | |
tree | c37ab7a3f75532a623ed00339782d769514422d2 /drivers/net/wireless/rt2x00/rt2400pci.c | |
parent | 070ac3a2651e3c1c4d277c5f1981517427c386a7 (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/rt2400pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 155 |
1 files changed, 85 insertions, 70 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, ®, sizeof(reg)); | 277 | rt2x00pci_register_multiwrite(rt2x00dev, CSR5, ®, sizeof(reg)); |
278 | } | 278 | } |
279 | 279 | ||
280 | static 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, ®); | ||
287 | rt2x00_set_field32(®, RXCSR0_DROP_NOT_TO_ME, !promisc); | ||
288 | rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); | ||
289 | } | ||
290 | |||
291 | static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type) | 280 | static 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, ®); | ||
301 | |||
302 | if (!is_monitor_present(&rt2x00dev->interface) && | ||
303 | (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA)) | ||
304 | rt2x00_set_field32(®, RXCSR0_DROP_TODS, 1); | ||
305 | else | ||
306 | rt2x00_set_field32(®, 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(®, RXCSR0_DROP_CRC, 1); | ||
316 | rt2x00_set_field32(®, RXCSR0_DROP_PHYSICAL, 1); | ||
317 | rt2x00_set_field32(®, RXCSR0_DROP_CONTROL, 1); | ||
318 | rt2x00_set_field32(®, RXCSR0_DROP_VERSION_ERROR, 1); | ||
319 | } else if (is_monitor_present(&rt2x00dev->interface)) { | ||
320 | rt2x00_set_field32(®, RXCSR0_DROP_CRC, 0); | ||
321 | rt2x00_set_field32(®, RXCSR0_DROP_PHYSICAL, 0); | ||
322 | rt2x00_set_field32(®, RXCSR0_DROP_CONTROL, 0); | ||
323 | rt2x00_set_field32(®, 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, ®); | 290 | rt2x00pci_register_read(rt2x00dev, BCNCSR1, ®); |
@@ -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, ®); | 298 | rt2x00pci_register_read(rt2x00dev, CSR14, ®); |
340 | if (is_interface_present(&rt2x00dev->interface)) { | 299 | rt2x00_set_field32(®, CSR14_TSF_COUNT, 1); |
341 | rt2x00_set_field32(®, CSR14_TSF_COUNT, 1); | 300 | rt2x00_set_field32(®, CSR14_TBCN, 1); |
342 | rt2x00_set_field32(®, CSR14_TBCN, 1); | ||
343 | } | ||
344 | |||
345 | rt2x00_set_field32(®, CSR14_BEACON_GEN, 0); | 301 | rt2x00_set_field32(®, 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(®, CSR14_TSF_SYNC, 2); | 304 | rt2x00_set_field32(®, 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(®, CSR14_TSF_SYNC, 1); | 306 | rt2x00_set_field32(®, CSR14_TSF_SYNC, 1); |
350 | else if (is_monitor_present(&rt2x00dev->interface) && | 307 | else |
351 | !is_interface_present(&rt2x00dev->interface)) | ||
352 | rt2x00_set_field32(®, CSR14_TSF_SYNC, 0); | 308 | rt2x00_set_field32(®, 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 | */ |
1105 | static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1060 | static 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 | */ |
1203 | static int rt2400pci_fill_rxdone(struct data_entry *entry, | 1158 | static 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 | */ |
1485 | static 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, ®); | ||
1533 | rt2x00_set_field32(®, RXCSR0_DROP_CRC, | ||
1534 | !(*total_flags & FIF_FCSFAIL)); | ||
1535 | rt2x00_set_field32(®, RXCSR0_DROP_PHYSICAL, | ||
1536 | !(*total_flags & FIF_PLCPFAIL)); | ||
1537 | rt2x00_set_field32(®, RXCSR0_DROP_CONTROL, | ||
1538 | !(*total_flags & FIF_CONTROL)); | ||
1539 | rt2x00_set_field32(®, RXCSR0_DROP_NOT_TO_ME, | ||
1540 | !(*total_flags & FIF_PROMISC_IN_BSS)); | ||
1541 | rt2x00_set_field32(®, RXCSR0_DROP_TODS, | ||
1542 | !(*total_flags & FIF_PROMISC_IN_BSS)); | ||
1543 | rt2x00_set_field32(®, RXCSR0_DROP_VERSION_ERROR, 1); | ||
1544 | rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); | ||
1545 | } | ||
1546 | |||
1533 | static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw, | 1547 | static 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 | ||
1603 | static const struct ieee80211_ops rt2400pci_mac80211_ops = { | 1617 | static 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 | }; |