Skip to contentSkip to conversation

the filter stuff again

RFC In review Johannes Berg 6 participants 20 messages Aug 21, 2007 – Sep 5, 2007

Subsystems (2)
lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

cover the filter stuff again

Repost of my filtering patches slightly bug-fixed. This works great for me (in that I don't see beacons from other BSSes etc), but we don't seem to have reached concensus yet whether we want to do it this way.

johannes

author maintainer
#1 lore raw

RFC 1/2 mac80211: allow drivers to indicate failed FCS/PLCP checksum

This patch allows drivers to indicate bad FCS/PLCP CRC to the stack and have the stack drop packets like that except for monitor interfaces.

---
Changes since v1:
* filter bad frames early in the RX code and don't count them nor try to get a STA for them

 include/net/mac80211.h |    2 ++
 net/mac80211/rx.c      |   31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)
include/net/mac80211.h +2 -0
@@ -243,6 +243,8 @@ struct ieee80211_rx_status {
 #define RX_FLAG_MMIC_ERROR	(1<<0)
 #define RX_FLAG_DECRYPTED	(1<<1)
 #define RX_FLAG_RADIOTAP	(1<<2)
+#define RX_FLAG_FAILED_FCS_CRC	(1<<3)
+#define RX_FLAG_FAILED_PLCP_CRC	(1<<4)
 	int flag;
 };
 
net/mac80211/rx.c +28 -3
@@ -154,6 +154,7 @@ ieee80211_rx_monitor(struct net_device *
 		__le16 chan_freq;
 		__le16 chan_flags;
 		u8 antsignal;
+		__le16 rx_flags;
 	} __attribute__ ((packed)) *rthdr;
 
 	skb->dev = dev;
@@ -178,12 +179,21 @@ ieee80211_rx_monitor(struct net_device *
 		cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
 			    (1 << IEEE80211_RADIOTAP_RATE) |
 			    (1 << IEEE80211_RADIOTAP_CHANNEL) |
-			    (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL));
+			    (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
+			    (1 << IEEE80211_RADIOTAP_RX_FLAGS));
 	rthdr->flags = local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS ?
 		       IEEE80211_RADIOTAP_F_FCS : 0;
+
+	/* FIXME: when radiotap gets a 'bad PLCP' flag use it here */
+	rthdr->rx_flags = 0;
+	if (status->flag &
+	    (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
+		rthdr->rx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS);
+
 	rate = ieee80211_get_rate(local, status->phymode, status->rate);
 	if (rate)
 		rthdr->rate = rate->rate / 5;
+
 	rthdr->chan_freq = cpu_to_le16(status->freq);
 	rthdr->chan_flags =
 		status->phymode == MODE_IEEE80211A ?
@@ -211,6 +221,15 @@ ieee80211_rx_h_monitor(struct ieee80211_
 		return TXRX_QUEUED;
 	}
 
+	/*
+	 * Drop frames with failed FCS/PLCP checksums here, they are only
+	 * relevant for monitor mode, the rest of the stack should never
+	 * see them.
+	 */
+	if (rx->u.rx.status->flag &
+	    (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
+		return TXRX_DROP;
+
 	if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
 		skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb->data));
 
@@ -1498,6 +1517,7 @@ void __ieee80211_rx(struct ieee80211_hw 
 	struct ieee80211_sub_if_data *prev = NULL;
 	struct sk_buff *skb_new;
 	u8 *bssid;
+	int bogon;
 
 	if (status->flag & RX_FLAG_RADIOTAP) {
 		radiotap_len = ieee80211_get_radiotap_len(skb->data);
@@ -1512,10 +1532,15 @@ void __ieee80211_rx(struct ieee80211_hw 
 	rx.u.rx.status = status;
 	rx.fc = skb->len >= 2 ? le16_to_cpu(hdr->frame_control) : 0;
 	type = rx.fc & IEEE80211_FCTL_FTYPE;
-	if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
+
+	bogon = status->flag & (RX_FLAG_FAILED_FCS_CRC |
+				RX_FLAG_FAILED_PLCP_CRC);
+
+	if (!bogon && (type == IEEE80211_FTYPE_DATA ||
+		       type == IEEE80211_FTYPE_MGMT))
 		local->dot11ReceivedFragmentCount++;
 
-	if (skb->len >= 16) {
+	if (!bogon && skb->len >= 16) {
 		sta = rx.sta = sta_info_get(local, hdr->addr2);
 		if (sta) {
 			rx.dev = rx.sta->dev;
#2 lore raw

Re: [RFC 1/2] mac80211: allow drivers to indicate failed FCS/PLCP checksum

Quoted 16 lines · Johannes Berg

This patch allows drivers to indicate bad FCS/PLCP CRC to the stack and have the stack drop packets like that except for monitor interfaces.

---
Changes since v1:
* filter bad frames early in the RX code and don't count them nor try to get a STA for them

 include/net/mac80211.h |    2 ++
 net/mac80211/rx.c      |   31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

include/net/mac80211.h struct ieee80211_rx_status { · line 249

Quoted 7 lines
include/net/mac80211.h +2 -0
@@ -243,6 +243,8 @@ struct ieee80211_rx_status {
 #define RX_FLAG_MMIC_ERROR	(1<<0)
 #define RX_FLAG_DECRYPTED	(1<<1)
 #define RX_FLAG_RADIOTAP	(1<<2)
+#define RX_FLAG_FAILED_FCS_CRC	(1<<3)
+#define RX_FLAG_FAILED_PLCP_CRC	(1<<4)
 	int flag;
 };

Do we need another flag to indicate ICV errors?
rt2x00 has the following fields to indicate problems during hardware decryption:

	ICV error -> How to report this to mac80211?
	MIC error -> The RX_FLAG_MMIC_ERROR flag can be set
	invalid key -> Could best be done by just not setting RX_FLAG_DECRYPTED I assume.

Ivo

author maintainer
#3 lore raw

Re: [RFC 1/2] mac80211: allow drivers to indicate failed FCS/PLCP checksum

Quoted 5 lines · Ivo van Doorn

Do we need another flag to indicate ICV errors?
rt2x00 has the following fields to indicate problems during hardware decryption:

	ICV error -> How to report this to mac80211?
	MIC error -> The RX_FLAG_MMIC_ERROR flag can be set
	invalid key -> Could best be done by just not setting RX_FLAG_DECRYPTED I assume.

I think you either just drop the packet or give it to mac80211 decrypted but with ICV still on so that mac80211 will verify the ICV (again) and do whatever is appropriate. But I think dropping it ought to be fine. Do we want this for monitoring maybe?

johannes

#4 lore raw

Re: [RFC 1/2] mac80211: allow drivers to indicate failed FCS/PLCP checksum

Quoted 8 lines · Johannes Berg
Quoted 5 lines · Ivo van Doorn

Do we need another flag to indicate ICV errors?
rt2x00 has the following fields to indicate problems during hardware decryption:

	ICV error -> How to report this to mac80211?
	MIC error -> The RX_FLAG_MMIC_ERROR flag can be set
	invalid key -> Could best be done by just not setting RX_FLAG_DECRYPTED I assume.
Quoted 4 lines

I think you either just drop the packet or give it to mac80211 decrypted but with ICV still on so that mac80211 will verify the ICV (again) and do whatever is appropriate. But I think dropping it ought to be fine. Do we want this for monitoring maybe?

Not sure how interesting a frame with a ICV error will be, on the other hand I am not even sure how a frame with a ICV error looks like in rt2x00, discovering that will probably happen during the hardware encryption implementation. ;)

Ivo

author maintainer
#5 lore raw

Re: [RFC 1/2] mac80211: allow drivers to indicate failed FCS/PLCP checksum

Quoted 1 line · Ivo van Doorn

Not sure how interesting a frame with a ICV error will be,

It *could* be interesting in monitor mode if you're interested in lower levels than I usually care about ;)

Quoted 3 lines

on the other hand I am not even sure how a frame with a ICV error looks like in rt2x00, discovering that will probably happen during the hardware encryption implementation. ;)

Yup :) I'd hold off on that for a bit though, I've been revamping that part of mac80211 because it currently makes not much sense.

johannes

author maintainer
#6 lore raw

RFC 2/2 mac80211: revamp interface and filter configuration

In reply to Johannes Berg

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 according to the filter flags.

Multicast filtering is a bit special, which is why drivers that do not require FIF_ALLMULTI for multicast address filters (i.e. they actually have filters for multicast addresses) need to set the new IEEE80211_HW_MULTICAST_FILTER flag and call the ieee80211_get_mc_list_item() function.

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 multicast.

WARNING: This patch makes the ralink drivers BUG_ON().

---
Changes since v1:
* introduce FIF_BCN_PRBRESP_PROMISC,
remove IEEE80211_HW_NO_PROBE_FILTERING

 drivers/net/wireless/adm8211.c                  |   85 +++--
 drivers/net/wireless/b43/b43.h                  |   15 -
 drivers/net/wireless/b43/main.c                 |  232 ++++++++--------
 drivers/net/wireless/iwl-base.c                 |   31 +-
 drivers/net/wireless/rt2x00/rt2400pci.c         |    7 
 drivers/net/wireless/rt2x00/rt2500pci.c         |    7 
 drivers/net/wireless/rt2x00/rt2500usb.c         |    6 
 drivers/net/wireless/rt2x00/rt61pci.c           |    7 
 drivers/net/wireless/rt2x00/rt73usb.c           |    6 
 drivers/net/wireless/rtl8187_dev.c              |   23 +
 drivers/net/wireless/zd1211rw-mac80211/zd_mac.c |   66 ++--
 include/net/mac80211.h                          |  148 +++++++---
 net/mac80211/debugfs_netdev.c                   |   16 -
 net/mac80211/ieee80211.c                        |  343 ++++++++++--------------
 net/mac80211/ieee80211_i.h                      |    1 
 net/mac80211/ieee80211_sta.c                    |   16 -
 net/mac80211/rx.c                               |    4 
 17 files changed, 547 insertions(+), 466 deletions(-)
include/net/mac80211.h +109 -39
@@ -339,7 +339,6 @@ enum ieee80211_if_types {
  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
  *	until the interface is removed (i.e. it cannot be used after
  *	remove_interface() callback was called for this interface).
- *	This pointer will be %NULL for monitor interfaces, be careful.
  *
  * This structure is used in add_interface() and remove_interface()
  * callbacks of &struct ieee80211_hw.
@@ -526,13 +525,12 @@ struct ieee80211_hw {
 	 */
 #define IEEE80211_HW_DEVICE_STRIPS_MIC (1<<8)
 
-	/* Device is capable of performing full monitor mode even during
-	 * normal operation. */
-#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
-
-	/* Device does not need BSSID filter set to broadcast in order to
-	 * receive all probe responses while scanning */
-#define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
+	/*
+	 * Device has multicast filters.
+	 */
+#define IEEE80211_HW_MULTICAST_FILTER (1<<9)
+
+/* hole at 10 */
 
 	/* Channels are already configured to the default regulatory domain
 	 * specified in the device's EEPROM */
@@ -579,6 +577,39 @@ static inline void SET_IEEE80211_PERM_AD
 	memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
 }
 
+/*
+ * flags for change_filter_flags()
+ *
+ * Note that e.g. if PROMISC_IN_BSS is unset then
+ * you should still do MAC address filtering if
+ * possible even if OTHER_BSS is set to indicate
+ * no BSSID filtering should be done.
+ */
+/*
+ * promiscuous mode within your BSS,
+ * think of the BSS as your network segment and then this corresponds
+ * to the regular ethernet device promiscuous mode
+ */
+#define FIF_PROMISC_IN_BSS	0x01
+/* show all multicast frames */
+#define FIF_ALLMULTI		0x02
+/* show frames with failed FCS, but set RX_FLAG_FAILED_FCS_CRC for them */
+#define FIF_FCSFAIL		0x04
+/* show frames with failed PLCP CRC, but set RX_FLAG_FAILED_PLCP_CRC for them */
+#define FIF_PLCPFAIL		0x08
+/*
+ * This flag is set during scanning to indicate to the hardware
+ * that it should not filter beacons or probe responses by BSSID.
+ */
+#define FIF_BCN_PRBRESP_PROMISC	0x10
+/*
+ * show control frames, if PROMISC_IN_BSS is not set then
+ * only those addressed to this station
+ */
+#define FIF_CONTROL		0x20
+/* show frames from other BSSes */
+#define FIF_OTHER_BSS		0x40
+
 /* Configuration block used by the low-level driver to tell the 802.11 code
  * about supported hardware features and to pass function pointers to callback
  * functions. */
@@ -591,32 +622,55 @@ struct ieee80211_ops {
 	int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
 		  struct ieee80211_tx_control *control);
 
-	/* Handler that is called when any netdevice attached to the hardware
-	 * device is set UP for the first time. This can be used, e.g., to
-	 * enable interrupts and beacon sending. */
-	int (*open)(struct ieee80211_hw *hw);
-
-	/* Handler that is called when the last netdevice attached to the
-	 * hardware device is set DOWN. This can be used, e.g., to disable
-	 * interrupts and beacon sending. */
-	int (*stop)(struct ieee80211_hw *hw);
-
-	/* Handler for asking a driver if a new interface can be added (or,
-	 * more exactly, set UP). If the handler returns zero, the interface
-	 * is added. Driver should perform any initialization it needs prior
-	 * to returning zero. By returning non-zero addition of the interface
-	 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
-	 * that monitor interfaces and normal interfaces are mutually
-	 * exclusive. If assigned, the open() handler is called after
-	 * add_interface() if this is the first device added. The
-	 * add_interface() callback has to be assigned because it is the only
-	 * way to obtain the requested MAC address for any interface.
+	/*
+	 * Called before the first netdevice attached to the hardware
+	 * is enabled. This should turn on the hardware and must turn on
+	 * frame reception (for possibly enabled monitor interfaces.)
+	 * Returns negative error codes, these may be seen in userspace,
+	 * or zero.
+	 * When the device is started it should not have a MAC address
+	 * to avoid acknowledging frames before a non-monitor device
+	 * is added.
+	 *
+	 * Must be implemented.
+	 */
+	int (*start)(struct ieee80211_hw *hw);
+
+	/*
+	 * Called after last netdevice attached to the hardware
+	 * is disabled. This should turn off the hardware (at least
+	 * it must turn off frame reception.)
+	 * May be called right after add_interface if that rejects
+	 * an interface.
+	 *
+	 * Must be implemented.
+	 */
+	void (*stop)(struct ieee80211_hw *hw);
+
+	/*
+	 * Called when a netdevice attached to the hardware is enabled.
+	 * Because it is not called for monitor mode devices, open()
+	 * and stop() must be implemented.
+	 * The driver should perform any initialization it needs before
+	 * the device can be enabled. The initial configuration for the
+	 * interface is given in the conf parameter.
+	 *
+	 * Must be implemented.
 	 */
 	int (*add_interface)(struct ieee80211_hw *hw,
 			     struct ieee80211_if_init_conf *conf);
 
-	/* Notify a driver that an interface is going down. The stop() handler
-	 * is called prior to this if this is a last interface. */
+	/*
+	 * Notifies a driver that an interface is going down. The stop() handler
+	 * is called after this if it is the last interface and no monitor
+	 * interfaces are present.
+	 * When all interfaces are removed, the MAC address in the hardware
+	 * must be cleared so the device no longer acknowledges packets,
+	 * the mac_addr member of the conf structure is, however, set to the
+	 * MAC address of the device going away.
+	 *
+	 * Hence, this callback must be implemented.
+	 */
 	void (*remove_interface)(struct ieee80211_hw *hw,
 				 struct ieee80211_if_init_conf *conf);
 
@@ -629,15 +683,31 @@ struct ieee80211_ops {
 	int (*config_interface)(struct ieee80211_hw *hw,
 				int if_id, struct ieee80211_if_conf *conf);
 
-	/* ieee80211 drivers do not have access to the &struct net_device
-	 * that is (are) connected with their device. Hence (and because
-	 * we need to combine the multicast lists and flags for multiple
-	 * virtual interfaces), they cannot assign set_multicast_list.
-	 * The parameters here replace dev->flags and dev->mc_count,
-	 * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
-	 * Must be atomic. */
-	void (*set_multicast_list)(struct ieee80211_hw *hw,
-				   unsigned short flags, int mc_count);
+	/*
+	 * Configure the device's RX filter.
+	 *
+	 * The multi_count parameter tells how many multicast addresses are
+	 * enabled. Use ieee80211_get_mc_list_item() to get the items.
+	 * It will be -1 if the IEEE80211_HW_MULTICAST_FILTER flag is not
+	 * included in the features or if the multicast list hasn't changed
+	 * since the last call, otherwise the number of multicast addresses.
+	 *
+	 * NOTE: If the count is -1 then you may not call
+	 *	 ieee80211_get_mc_list_item() from this function!
+	 *
+	 * NOTE: The count currently doesn't take into account duplicate
+	 *	 addresses from different virtual interfaces!
+	 *
+	 * All unsupported flags in 'total_flags' must be cleared,
+	 * clear all bits except those you honoured.
+	 *
+	 * Must be atomic due to running under the tx lock.
+	 *
+	 * This callback is must be implemented.
+	 */
+	void (*configure_filter)(struct ieee80211_hw *hw, int multi_count,
+				 unsigned int changed_flags,
+				 unsigned int *total_flags);
 
 	/* Set TIM bit handler. If the hardware/firmware takes care of beacon
 	 * generation, IEEE 802.11 code uses this function to tell the
net/mac80211/ieee80211.c +156 -187

445 lines not on this page · raw message

net/mac80211/ieee80211_i.h +1 -0
@@ -476,6 +476,7 @@ struct ieee80211_local {
 	struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
 	int open_count;
 	int monitors;
+	unsigned int filter_flags; /* FIF_* */
 	struct iw_statistics wstats;
 	u8 wstats_flags;
 	int tx_headroom; /* required headroom for hardware/radiotap */
net/mac80211/rx.c +2 -2
@@ -1450,7 +1450,7 @@ static int prepare_for_handlers(struct i
 		} else if (!multicast &&
 			   compare_ether_addr(sdata->dev->dev_addr,
 					      hdr->addr1) != 0) {
-			if (!sdata->promisc)
+			if (!(sdata->dev->flags & IFF_PROMISC))
 				return 0;
 			rx->u.rx.ra_match = 0;
 		}
@@ -1465,7 +1465,7 @@ static int prepare_for_handlers(struct i
 		} else if (!multicast &&
 			   compare_ether_addr(sdata->dev->dev_addr,
 					      hdr->addr1) != 0) {
-			if (!sdata->promisc)
+			if (!(sdata->dev->flags & IFF_PROMISC))
 				return 0;
 			rx->u.rx.ra_match = 0;
 		} else if (!rx->sta)
net/mac80211/debugfs_netdev.c +0 -16
@@ -425,20 +425,6 @@ IEEE80211_IF_FILE(peer, u.wds.remote_add
 /* VLAN attributes */
 IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
 
-/* MONITOR attributes */
-static ssize_t ieee80211_if_fmt_mode(
-	const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
-{
-	struct ieee80211_local *local = sdata->local;
-
-	return scnprintf(buf, buflen, "%s\n",
-			 ((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
-			  local->open_count == local->monitors) ?
-			 "hard" : "soft");
-}
-__IEEE80211_IF_FILE(mode);
-
-
 #define DEBUGFS_ADD(name, type)\
 	sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
 		sdata->debugfsdir, sdata, &name##_ops);
@@ -542,7 +528,6 @@ static void add_vlan_files(struct ieee80
 
 static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
 {
-	DEBUGFS_ADD(mode, monitor);
 }
 
 static void add_files(struct ieee80211_sub_if_data *sdata)
@@ -671,7 +656,6 @@ static void del_vlan_files(struct ieee80
 
 static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
 {
-	DEBUGFS_DEL(mode, monitor);
 }
 
 static void del_files(struct ieee80211_sub_if_data *sdata, int type)
drivers/net/wireless/b43/b43.h +4 -11
@@ -593,9 +593,8 @@ struct b43_wl {
 	 * at a time. General information about this interface follows.
 	 */
 
-	/* Opaque ID of the operating interface (!= monitor
-	 * interface) from the ieee80211 subsystem.
-	 * Do not modify.
+	/* Opaque ID of the operating interface from the ieee80211
+	 * subsystem. Do not modify.
 	 */
 	int if_id;
 	/* MAC address (can be NULL). */
@@ -604,14 +603,10 @@ struct b43_wl {
 	const u8 *bssid;
 	/* Interface type. (IEEE80211_IF_TYPE_XXX) */
 	int if_type;
-	/* Counter of active monitor interfaces. */
-	int monitor;
 	/* Is the card operating in AP, STA or IBSS mode? */
 	bool operating;
-	/* Promisc mode active?
-	 * Note that (monitor != 0) implies promisc.
-	 */
-	bool promisc;
+	/* filter flags */
+	unsigned int filter_flags;
 	/* Stats about the wireless interface */
 	struct ieee80211_low_level_stats ieee_stats;
 
@@ -768,8 +763,6 @@ static inline struct b43_wldev *dev_to_b
 /* Is the device operating in a specified mode (IEEE80211_IF_TYPE_XXX). */
 static inline int b43_is_mode(struct b43_wl *wl, int type)
 {
-	if (type == IEEE80211_IF_TYPE_MNTR)
-		return !!(wl->monitor);
 	return (wl->operating && wl->if_type == type);
 }
 
drivers/net/wireless/b43/main.c +126 -106

337 lines not on this page · raw message

drivers/net/wireless/iwl-base.c +27 -4
@@ -2591,6 +2591,8 @@ static void iwl_set_flags_for_phymode(st
 
 /*
  * initilize rxon structure with default values fromm eeprom
+ *
+ * XXX: This function should use the filter flags instead!
  */
 static void iwl_connection_init_rx_config(struct iwl_priv *priv)
 {
@@ -7502,7 +7504,7 @@ static void iwl_bg_scan_completed(struct
  *
  *****************************************************************************/
 
-static int iwl_mac_open(struct ieee80211_hw *hw)
+static int iwl_mac_start(struct ieee80211_hw *hw)
 {
 	struct iwl_priv *priv = hw->priv;
 
@@ -7521,7 +7523,7 @@ static int iwl_mac_open(struct ieee80211
 	return 0;
 }
 
-static int iwl_mac_stop(struct ieee80211_hw *hw)
+static void iwl_mac_stop(struct ieee80211_hw *hw)
 {
 	struct iwl_priv *priv = hw->priv;
 
@@ -7530,8 +7532,18 @@ static int iwl_mac_stop(struct ieee80211
 	/*netif_stop_queue(dev); */
 	flush_workqueue(priv->workqueue);
 	IWL_DEBUG_MAC80211("leave\n");
+}
 
-	return 0;
+static void iwl_configure_filter(struct ieee80211_hw *hw,
+				 int multi_count,
+				 unsigned int changed_flags,
+				 unsigned int *total_flags)
+{
+	/*
+	 * XXX: dummy
+	 * see also iwl_connection_init_rx_config
+	 */
+	*total_flags = 0;
 }
 
 static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -7700,6 +7712,8 @@ static int iwl_mac_config_interface(stru
 	if (conf == NULL)
 		return -EIO;
 
+	/* TODO: use conf->mac_addr */
+
 	if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) &&
 	    (!conf->beacon || !conf->ssid_len)) {
 		IWL_DEBUG_MAC80211
@@ -7714,8 +7728,14 @@ static int iwl_mac_config_interface(stru
 		IWL_DEBUG_MAC80211("bssid: " MAC_FMT "\n",
 				   MAC_ARG(conf->bssid));
 
+	/*
+	 * XXX: there was a test for IEEE80211_HW_NO_PROBE_FILTERING here
+	 *	which must have been wrong since it was always true.
+	 *	the test was:
 	if (unlikely(priv->status & STATUS_SCANNING) &&
 	    !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
+	 */
+	if (unlikely(priv->status & STATUS_SCANNING)) {
 		IWL_DEBUG_MAC80211("leave - scanning\n");
 		mutex_unlock(&priv->mutex);
 		return 0;
@@ -7808,6 +7828,8 @@ static void iwl_mac_remove_interface(str
 	}
 	mutex_unlock(&priv->mutex);
 
+	/* TODO: clear MAC address in hardware */
+
 	IWL_DEBUG_MAC80211("leave\n");
 
 }
@@ -9059,10 +9081,11 @@ static struct attribute_group iwl_attrib
 
 static struct ieee80211_ops iwl_hw_ops = {
 	.tx = iwl_mac_tx,
-	.open = iwl_mac_open,
+	.start = iwl_mac_start,
 	.stop = iwl_mac_stop,
 	.add_interface = iwl_mac_add_interface,
 	.remove_interface = iwl_mac_remove_interface,
+	.configure_filter = iwl_configure_filter,
 	.config = iwl_mac_config,
 	.config_interface = iwl_mac_config_interface,
 	.set_key = iwl_mac_set_key,
drivers/net/wireless/rtl8187_dev.c +19 -4
@@ -365,7 +365,7 @@ static void rtl8187_set_channel(struct i
 	rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg);
 }
 
-static int rtl8187_open(struct ieee80211_hw *dev)
+static int rtl8187_start(struct ieee80211_hw *dev)
 {
 	struct rtl8187_priv *priv = dev->priv;
 	u32 reg;
@@ -419,7 +419,7 @@ static int rtl8187_open(struct ieee80211
 	return 0;
 }
 
-static int rtl8187_stop(struct ieee80211_hw *dev)
+static void rtl8187_stop(struct ieee80211_hw *dev)
 {
 	struct rtl8187_priv *priv = dev->priv;
 	struct rtl8187_rx_info *info;
@@ -445,7 +445,6 @@ static int rtl8187_stop(struct ieee80211
 		usb_kill_urb(info->urb);
 		kfree_skb(skb);
 	}
-	return 0;
 }
 
 static int rtl8187_add_interface(struct ieee80211_hw *dev,
@@ -476,6 +475,8 @@ static void rtl8187_remove_interface(str
 {
 	struct rtl8187_priv *priv = dev->priv;
 	priv->mode = IEEE80211_IF_TYPE_MGMT;
+
+	/* TODO: reset MAC address to zeroes */
 }
 
 static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
@@ -523,14 +524,28 @@ static int rtl8187_config_interface(stru
 	return 0;
 }
 
+static void rtl8187_configure_filter(struct ieee80211_hw *dev,
+				     int multi_count,
+				     unsigned int changed,
+				     unsigned int *flags)
+{
+	/*
+	 * XXX: dummy
+	 *
+	 * TODO: change filter flags
+	 */
+	*flags = 0;
+}
+
 static const struct ieee80211_ops rtl8187_ops = {
 	.tx			= rtl8187_tx,
-	.open			= rtl8187_open,
+	.start			= rtl8187_start,
 	.stop			= rtl8187_stop,
 	.add_interface		= rtl8187_add_interface,
 	.remove_interface	= rtl8187_remove_interface,
 	.config			= rtl8187_config,
 	.config_interface	= rtl8187_config_interface,
+	.configure_filter	= rtl8187_configure_filter,
 };
 
 static void rtl8187_eeprom_register_read(struct eeprom_93cx6 *eeprom)
drivers/net/wireless/adm8211.c +54 -31

167 lines not on this page · raw message

drivers/net/wireless/zd1211rw-mac80211/zd_mac.c +31 -35

150 lines not on this page · raw message

net/mac80211/ieee80211_sta.c +8 -8
@@ -3583,10 +3583,10 @@ void ieee80211_scan_completed(struct iee
 		printk(KERN_DEBUG "%s: failed to restore operational"
 		       "channel after scan\n", dev->name);
 
-	if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
-	    ieee80211_if_config(dev))
-		printk(KERN_DEBUG "%s: failed to restore operational"
-		       "BSSID after scan\n", dev->name);
+	local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC;
+	local->ops->configure_filter(local_to_hw(local), -1,
+				     FIF_BCN_PRBRESP_PROMISC,
+				     &local->filter_flags);
 
 	memset(&wrqu, 0, sizeof(wrqu));
 	wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
@@ -3770,10 +3770,10 @@ static int ieee80211_sta_start_scan(stru
 	local->scan_channel_idx = 0;
 	local->scan_dev = dev;
 
-	if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
-	    ieee80211_if_config(dev))
-		printk(KERN_DEBUG "%s: failed to set BSSID for scan\n",
-		       dev->name);
+	local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
+	local->ops->configure_filter(local_to_hw(local), -1,
+				     FIF_BCN_PRBRESP_PROMISC,
+				     &local->filter_flags);
 
 	/* TODO: start scan as soon as all nullfunc frames are ACKed */
 	queue_delayed_work(local->hw.workqueue, &local->scan_work,
drivers/net/wireless/rt2x00/rt2400pci.c +2 -5
@@ -1447,10 +1447,7 @@ static void rt2400pci_probe_hw_mode(stru
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1593,7 +1590,7 @@ static const struct ieee80211_ops rt2400
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt2400pci_set_retry_limit,
 	.conf_tx		= rt2400pci_conf_tx,
drivers/net/wireless/rt2x00/rt2500pci.c +2 -5
@@ -1745,10 +1745,7 @@ static void rt2500pci_probe_hw_mode(stru
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1884,7 +1881,7 @@ static const struct ieee80211_ops rt2500
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt2500pci_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,
drivers/net/wireless/rt2x00/rt61pci.c +2 -5
@@ -2118,10 +2118,7 @@ static void rt61pci_probe_hw_mode(struct
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -2247,7 +2244,7 @@ static const struct ieee80211_ops rt61pc
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt61pci_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,
drivers/net/wireless/rt2x00/rt2500usb.c +2 -4
@@ -1467,9 +1467,7 @@ static void rt2500usb_probe_hw_mode(stru
 	rt2x00dev->hw->flags =
 	    IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
 	    IEEE80211_HW_RX_INCLUDES_FCS |
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1562,7 +1560,7 @@ static const struct ieee80211_ops rt2500
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.conf_tx		= rt2x00mac_conf_tx,
 	.get_tx_stats		= rt2x00mac_get_tx_stats,
drivers/net/wireless/rt2x00/rt73usb.c +2 -4
@@ -1713,9 +1713,7 @@ static void rt73usb_probe_hw_mode(struct
 	 */
 	rt2x00dev->hw->flags =
 	    IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1856,7 +1854,7 @@ static const struct ieee80211_ops rt73us
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt73usb_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,
#7 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 24 lines · Johannes Berg

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 according to the filter flags.

Multicast filtering is a bit special, which is why drivers that do not require FIF_ALLMULTI for multicast address filters (i.e. they actually have filters for multicast addresses) need to set the new IEEE80211_HW_MULTICAST_FILTER flag and call the ieee80211_get_mc_list_item() function.

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().

Quoted 7 lines

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 multicast.

Personally I like the idea of this packet filtering, implementation and driver interface looks allright to me.

Quoted 1 line

WARNING: This patch makes the ralink drivers BUG_ON().

If you can give me a warning when you are going to submit this for inclusion, I'll cook up a patch to make it work for rt2x00. :)

Ivo

author maintainer
#8 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 4 lines · Ivo van Doorn
Quoted 1 line

WARNING: This patch makes the ralink drivers BUG_ON().

If you can give me a warning when you are going to submit this for inclusion, I'll cook up a patch to make it work for rt2x00. :)

Will do, thanks :)

johannes

#9 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

In reply to Johannes Berg
Quoted 2 lines · Johannes Berg
include/net/mac80211.h +2 -0
+	/*
+	 * Configure the device's RX filter.

[...]

include/net/mac80211.h struct ieee80211_ops { · line 704

Quoted 1 line
include/net/mac80211.h +1 -0
+	 * Must be atomic due to running under the tx lock.

This is slightly freaky for zd1211rw and probably other USB drivers. In most cases we can't act upon any of those filter flag changes in atomic context.

We could defer work like we do for multicast lists, but then the driver would be lying in that it would return from configure_filter saying that it has honoured some flags without actually having done so (yet).

Will that be a problem? I'm thinking maybe not, since the flags only affect RX and we can't determine which frames will be in the air at any time. [as opposed to such atomicity problems that relate to TX, we can just disable TX until the work has completed]

include/net/mac80211.h struct ieee80211_ops { · line 707

Quoted 2 lines
include/net/mac80211.h +2 -0
+	 * This callback is must be implemented.
+	 */

Typo.

Daniel

author maintainer
#10 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 3 lines · Daniel Drake

This is slightly freaky for zd1211rw and probably other USB drivers. In most cases we can't act upon any of those filter flag changes in atomic context.

Yeah, I know, but it's running under the tx lock and I haven't seen a way to drop that (yet)

Quoted 3 lines

We could defer work like we do for multicast lists, but then the driver would be lying in that it would return from configure_filter saying that it has honoured some flags without actually having done so (yet).

Yup, I saw that you do that anyway so didn't think much of it.

Quoted 4 lines

Will that be a problem? I'm thinking maybe not, since the flags only affect RX and we can't determine which frames will be in the air at any time. [as opposed to such atomicity problems that relate to TX, we can just disable TX until the work has completed]

It does matter a bit for scanning, if you have BSSID filters that affect beacons and probe responses then you would want to turn those off before transmitting the next probe response. However, when the multicast_count parameter is -1 to indicate no changes in the multicast list (and you then need to use the cached hash value in zd1211) the callback actually *can* sleep.

This is a rather weird area of the patch. Splitting it up into two callbacks makes no sense, and so far I have not understood why it runs under the TX lock so haven't changed it.

Quoted 4 lines

include/net/mac80211.h struct ieee80211_ops { · line 707

Quoted 2 lines
include/net/mac80211.h +2 -0
+	 * This callback is must be implemented.
+	 */

Typo.

Good point, thanks.

Slightly updated patch at
http://johannes.sipsolutions.net/patches/kernel/all/2007-09-03-08:32/021-mac80211-filter-flags.patch

johannes

author maintainer
#11 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

In reply to Daniel Drake

Just had another idea related to this patch:

Currently, we pass multi_count >= 0 or == -1. And then we expect the driver to call ieee80211_get_mc_list_item() to get the items. However, the count is bogus because we add up all counts of the virtual interfaces and don't account for duplicates. Also, however, no driver cares about the count anyway.

Hence, we could instead of passing multi_count pass the getter function:

- void (*configure_filter)(struct ieee80211_hw *hw, int multi_count,
- unsigned int changed_flags,
- unsigned int *total_flags);
+ void (*configure_filter)(struct ieee80211_hw *hw,
+ struct dev_mc_list * (*get_mc_item)(struct ieee80211_hw *hw,
+ void *cookie),
+ void *cookie,
+ unsigned int changed_flags, unsigned int total_flags)

That way,
(1) we get rid of the export of ieee80211_get_mc_list_item
(2) get_mc_item gets to have a nicer interface without double pointers
(3) there's no danger of somebody calling it outside the right place
(4) we can use a NULL function/cookie ptr to indicate that the list hasn't changed.

Thoughts? I think I'll implement this, I like it much better than the current interface. And I'll also look into getting it non-atomic. We're not protected against concurrent execution anyway, but I expect drivers would handle that? Or do we want that here? We can't protect all callbacks among each other anyway with the tx() callback etc...

johannes

author maintainer
#12 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 4 lines · Johannes Berg

And I'll also look into getting it non-atomic. We're
not protected against concurrent execution anyway, but I expect drivers would handle that? Or do we want that here? We can't protect all callbacks among each other anyway with the tx() callback etc...

Ah, I see now, no way to do it because the networking core already locks around set_multicast_list using netif_tx_lock_bh, probably for good reason. And then propagating that lock to the master device is the right thing to do as well. Looks like you'll have to continue offloading the actual reconfiguration to the workqueue when called from set_multicast.

And in fact, it seems that to protect against concurrent modification in different code paths I'll have to use the tx lock when calling this from the MLME code. Can you make sure that the filter will be reconfigured before further packets are transmitted, that is packets that are going to go into ->tx() after ->configure_filter()?

johannes

#13 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 5 lines · Johannes Berg

And in fact, it seems that to protect against concurrent modification in different code paths I'll have to use the tx lock when calling this from the MLME code. Can you make sure that the filter will be reconfigured before further packets are transmitted, that is packets that are going to go into ->tx() after ->configure_filter()?

I see three options to achieve this:

1) Use ieee80211_stop_queues() in ->configure_filter() and ieee80211_wake_queues() at the end of the workqueue function.

2) Throw away all packets until the workqueue function terminates.

3) Implement our own tx queue.

I prefer to do option (1) because it wouldn't require adding additional fields to our private structure beside the work_struct for the workqueue function, it is simple to implement and it would not throw away any packets. Are there any side effects that I have overlooked?

Signature · 1 line
Uli Kunitz
author maintainer
#14 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 8 lines · Ulrich Kunitz

I see three options to achieve this:

1) Use ieee80211_stop_queues() in ->configure_filter() and ieee80211_wake_queues() at the end of the workqueue function.

2) Throw away all packets until the workqueue function terminates.

Quoted 7 lines

3) Implement our own tx queue.

I prefer to do option (1) because it wouldn't require adding additional fields to our private structure beside the work_struct for the workqueue function, it is simple to implement and it would not throw away any packets. Are there any side effects that I have overlooked?

I think Michael says it's currently buggy if called outside of ->tx().

johannes

#15 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 12 lines · Johannes Berg
Quoted 10 lines · Ulrich Kunitz

I see three options to achieve this:

1) Use ieee80211_stop_queues() in ->configure_filter() and ieee80211_wake_queues() at the end of the workqueue function.

2) Throw away all packets until the workqueue function terminates.

3) Implement our own tx queue.

Quoted 7 lines
Quoted 5 lines

I prefer to do option (1) because it wouldn't require adding additional fields to our private structure beside the work_struct for the workqueue function, it is simple to implement and it would not throw away any packets. Are there any side effects that I have overlooked?

I think Michael says it's currently buggy if called outside of ->tx().

Yes, we had a bug in b43 where we used it in the periodic workqueue. It causes really hard to track down system freezes on UP systems due to races with the TX code.
It will hang and busy wait in the qdisc code when this triggers. I didn't see a fix for this, yet.
But I think a fix could probably be to take the netif_tx_lock in the ieee80211_stop_queues() function, so we make sure that no TX is in progress while we stop it.

author maintainer
#16 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 16 lines · Michael Buesch
Quoted 8 lines
Quoted 8 lines

1) Use ieee80211_stop_queues() in ->configure_filter() and ieee80211_wake_queues() at the end of the workqueue function.

2) Throw away all packets until the workqueue function terminates.

3) Implement our own tx queue.

Quoted 7 lines
Quoted 5 lines

I prefer to do option (1) because it wouldn't require adding additional fields to our private structure beside the work_struct for the workqueue function, it is simple to implement and it would not throw away any packets. Are there any side effects that I have overlooked?

I think Michael says it's currently buggy if called outside of ->tx().

Quoted 8 lines

Yes, we had a bug in b43 where we used it in the periodic workqueue. It causes really hard to track down system freezes on UP systems due to races with the TX code.
It will hang and busy wait in the qdisc code when this triggers. I didn't see a fix for this, yet.
But I think a fix could probably be to take the netif_tx_lock in the ieee80211_stop_queues() function, so we make sure that no TX is in progress while we stop it.

Ok. Of course, for zd1211 it'd be easy to set a flag in configure_filter() and check that flag in tx() and if it's set then call stop_queues().

johannes

#17 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

In reply to Johannes Berg
Quoted 8 lines · Johannes Berg
Quoted 5 lines

I prefer to do option (1) because it wouldn't require adding additional fields to our private structure beside the work_struct for the workqueue function, it is simple to implement and it would not throw away any packets. Are there any side effects that I have overlooked?

I think Michael says it's currently buggy if called outside of ->tx().

That's just a general rule of thumb. configure_filter holds the tx lock so it's actually safe to do that there. In other cases, it can be buggy (some tx code can get stuck) and racy (frames can get enqueued after stopping the queues). The first can be fixed in mac80211, but the second can't be. For most cases, stopping the hardware queue(s) should be done instead and possibly flushing the queue or waiting for it to empty, if you're trying to adjust the radio.

-Michael Wu

author maintainer
#18 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

Quoted 2 lines · Michael Wu

That's just a general rule of thumb. configure_filter holds the tx lock so it's actually safe to do that there.

Good point.

Quoted 3 lines

In other cases, it can be buggy (some tx
code can get stuck) and racy (frames can get enqueued after stopping the queues). The first can be fixed in mac80211, but the second can't be.

I think that we should be able to get all this resolved when we rip out the queue code and implement multiqueue devices. But if I want to do that I need to reverse engineer b43 QoS first to have multiple queues ;)

Quoted 4 lines

For
most cases, stopping the hardware queue(s) should be done instead and possibly flushing the queue or waiting for it to empty, if you're trying to adjust the radio.

In this case it's about adjusting the MAC (filtering) and I'm not even sure the the USB device has a queue that can be stopped.

johannes

author maintainer
#19 lore raw

Re: [RFC 2/2] mac80211: revamp interface and filter configuration

In reply to Johannes Berg
Quoted 1 line · Johannes Berg

Just had another idea related to this patch:

Just implemented that along with the race fix. Patch below.

johannes

Subject: 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, which is why drivers that do not require FIF_ALLMULTI for multicast address filters (i.e. they actually have filters for multicast addresses) need to set the new IEEE80211_HW_MULTICAST_FILTER flag and call the get_mc_item() function passed to the configure_filter callback.

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.

WARNING: This patch makes the ralink and p54 drivers BUG_ON().

---
Changes since v1:
* introduce FIF_BCN_PRBRESP_PROMISC,
remove IEEE80211_HW_NO_PROBE_FILTERING

 drivers/net/wireless/adm8211.c                  |   89 +++--
 drivers/net/wireless/b43/b43.h                  |   15 
 drivers/net/wireless/b43/main.c                 |  244 +++++++------
 drivers/net/wireless/iwl-base.c                 |   33 +
 drivers/net/wireless/rt2x00/rt2400pci.c         |    7 
 drivers/net/wireless/rt2x00/rt2500pci.c         |    7 
 drivers/net/wireless/rt2x00/rt2500usb.c         |    6 
 drivers/net/wireless/rt2x00/rt61pci.c           |    7 
 drivers/net/wireless/rt2x00/rt73usb.c           |    6 
 drivers/net/wireless/rtl8187_dev.c              |   25 +
 drivers/net/wireless/zd1211rw-mac80211/zd_mac.c |   76 ++--
 include/net/mac80211.h                          |  160 +++++----
 net/mac80211/debugfs_netdev.c                   |   16 
 net/mac80211/ieee80211.c                        |  419 +++++++++++-------------
 net/mac80211/ieee80211_i.h                      |    1 
 net/mac80211/ieee80211_sta.c                    |   32 +
 net/mac80211/rx.c                               |    4 
 17 files changed, 624 insertions(+), 523 deletions(-)
include/net/mac80211.h +103 -57
@@ -371,7 +371,6 @@ enum ieee80211_if_types {
  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
  *	until the interface is removed (i.e. it cannot be used after
  *	remove_interface() callback was called for this interface).
- *	This pointer will be %NULL for monitor interfaces, be careful.
  *
  * This structure is used in add_interface() and remove_interface()
  * callbacks of &struct ieee80211_hw.
@@ -557,13 +556,12 @@ struct ieee80211_hw {
 
 /* hole at 8 */
 
-	/* Device is capable of performing full monitor mode even during
-	 * normal operation. */
-#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
-
-	/* Device does not need BSSID filter set to broadcast in order to
-	 * receive all probe responses while scanning */
-#define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
+	/*
+	 * Device has multicast filters.
+	 */
+#define IEEE80211_HW_MULTICAST_FILTER (1<<9)
+
+/* hole at 10 */
 
 	/* Channels are already configured to the default regulatory domain
 	 * specified in the device's EEPROM */
@@ -601,6 +599,39 @@ static inline void SET_IEEE80211_PERM_AD
 	memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
 }
 
+/*
+ * flags for change_filter_flags()
+ *
+ * Note that e.g. if PROMISC_IN_BSS is unset then
+ * you should still do MAC address filtering if
+ * possible even if OTHER_BSS is set to indicate
+ * no BSSID filtering should be done.
+ */
+/*
+ * promiscuous mode within your BSS,
+ * think of the BSS as your network segment and then this corresponds
+ * to the regular ethernet device promiscuous mode
+ */
+#define FIF_PROMISC_IN_BSS	0x01
+/* show all multicast frames */
+#define FIF_ALLMULTI		0x02
+/* show frames with failed FCS, but set RX_FLAG_FAILED_FCS_CRC for them */
+#define FIF_FCSFAIL		0x04
+/* show frames with failed PLCP CRC, but set RX_FLAG_FAILED_PLCP_CRC for them */
+#define FIF_PLCPFAIL		0x08
+/*
+ * This flag is set during scanning to indicate to the hardware
+ * that it should not filter beacons or probe responses by BSSID.
+ */
+#define FIF_BCN_PRBRESP_PROMISC	0x10
+/*
+ * show control frames, if PROMISC_IN_BSS is not set then
+ * only those addressed to this station
+ */
+#define FIF_CONTROL		0x20
+/* show frames from other BSSes */
+#define FIF_OTHER_BSS		0x40
+
 /* Configuration block used by the low-level driver to tell the 802.11 code
  * about supported hardware features and to pass function pointers to callback
  * functions. */
@@ -613,32 +644,55 @@ struct ieee80211_ops {
 	int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
 		  struct ieee80211_tx_control *control);
 
-	/* Handler that is called when any netdevice attached to the hardware
-	 * device is set UP for the first time. This can be used, e.g., to
-	 * enable interrupts and beacon sending. */
-	int (*open)(struct ieee80211_hw *hw);
-
-	/* Handler that is called when the last netdevice attached to the
-	 * hardware device is set DOWN. This can be used, e.g., to disable
-	 * interrupts and beacon sending. */
-	int (*stop)(struct ieee80211_hw *hw);
-
-	/* Handler for asking a driver if a new interface can be added (or,
-	 * more exactly, set UP). If the handler returns zero, the interface
-	 * is added. Driver should perform any initialization it needs prior
-	 * to returning zero. By returning non-zero addition of the interface
-	 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
-	 * that monitor interfaces and normal interfaces are mutually
-	 * exclusive. If assigned, the open() handler is called after
-	 * add_interface() if this is the first device added. The
-	 * add_interface() callback has to be assigned because it is the only
-	 * way to obtain the requested MAC address for any interface.
+	/*
+	 * Called before the first netdevice attached to the hardware
+	 * is enabled. This should turn on the hardware and must turn on
+	 * frame reception (for possibly enabled monitor interfaces.)
+	 * Returns negative error codes, these may be seen in userspace,
+	 * or zero.
+	 * When the device is started it should not have a MAC address
+	 * to avoid acknowledging frames before a non-monitor device
+	 * is added.
+	 *
+	 * Must be implemented.
+	 */
+	int (*start)(struct ieee80211_hw *hw);
+
+	/*
+	 * Called after last netdevice attached to the hardware
+	 * is disabled. This should turn off the hardware (at least
+	 * it must turn off frame reception.)
+	 * May be called right after add_interface if that rejects
+	 * an interface.
+	 *
+	 * Must be implemented.
+	 */
+	void (*stop)(struct ieee80211_hw *hw);
+
+	/*
+	 * Called when a netdevice attached to the hardware is enabled.
+	 * Because it is not called for monitor mode devices, open()
+	 * and stop() must be implemented.
+	 * The driver should perform any initialization it needs before
+	 * the device can be enabled. The initial configuration for the
+	 * interface is given in the conf parameter.
+	 *
+	 * Must be implemented.
 	 */
 	int (*add_interface)(struct ieee80211_hw *hw,
 			     struct ieee80211_if_init_conf *conf);
 
-	/* Notify a driver that an interface is going down. The stop() handler
-	 * is called prior to this if this is a last interface. */
+	/*
+	 * Notifies a driver that an interface is going down. The stop() handler
+	 * is called after this if it is the last interface and no monitor
+	 * interfaces are present.
+	 * When all interfaces are removed, the MAC address in the hardware
+	 * must be cleared so the device no longer acknowledges packets,
+	 * the mac_addr member of the conf structure is, however, set to the
+	 * MAC address of the device going away.
+	 *
+	 * Hence, this callback must be implemented.
+	 */
 	void (*remove_interface)(struct ieee80211_hw *hw,
 				 struct ieee80211_if_init_conf *conf);
 
@@ -651,15 +705,25 @@ struct ieee80211_ops {
 	int (*config_interface)(struct ieee80211_hw *hw,
 				int if_id, struct ieee80211_if_conf *conf);
 
-	/* ieee80211 drivers do not have access to the &struct net_device
-	 * that is (are) connected with their device. Hence (and because
-	 * we need to combine the multicast lists and flags for multiple
-	 * virtual interfaces), they cannot assign set_multicast_list.
-	 * The parameters here replace dev->flags and dev->mc_count,
-	 * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
-	 * Must be atomic. */
-	void (*set_multicast_list)(struct ieee80211_hw *hw,
-				   unsigned short flags, int mc_count);
+	/*
+	 * Configure the device's RX filter.
+	 *
+	 * If get_mc_item is assigned, then the multicast address filter
+	 * must be changed if the hardware flags indicate that one is
+	 * present. The get_mc_item function should be called until it
+	 * returns %NULL, it must be passed the @get_mc_data pointer
+	 * each time.
+	 *
+	 * All unsupported flags in 'total_flags' must be cleared,
+	 * clear all bits except those you honoured.
+	 *
+	 * The callback must be implemented and must be atomic.
+	 */
+	void (*configure_filter)(struct ieee80211_hw *hw,
+				 struct dev_mc_list *(get_mc_item)(void *data),
+				 void *get_mc_data,
+				 unsigned int changed_flags,
+				 unsigned int *total_flags);
 
 	/* Set TIM bit handler. If the hardware/firmware takes care of beacon
 	 * generation, IEEE 802.11 code uses this function to tell the
@@ -1078,24 +1142,6 @@ void ieee80211_stop_queues(struct ieee80
  */
 void ieee80211_wake_queues(struct ieee80211_hw *hw);
 
-/**
- * ieee80211_get_mc_list_item - iteration over items in multicast list
- * @hw: pointer as obtained from ieee80211_alloc_hw().
- * @prev: value returned by previous call to ieee80211_get_mc_list_item() or
- *	NULL to start a new iteration.
- * @ptr: pointer to buffer of void * type for internal usage of
- *	ieee80211_get_mc_list_item().
- *
- * Iterates over items in multicast list of given device. To get the first
- * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
- * value returned by previous call in @prev. Don't alter *@ptr during
- * iteration. When there are no more items, NULL is returned.
- */
-struct dev_mc_list *
-ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
-			   struct dev_mc_list *prev,
-			   void **ptr);
-
 /* called by driver to notify scan status completed */
 void ieee80211_scan_completed(struct ieee80211_hw *hw);
 
net/mac80211/ieee80211.c +205 -214

529 lines not on this page · raw message

net/mac80211/ieee80211_i.h +1 -0
@@ -482,6 +482,7 @@ struct ieee80211_local {
 	struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
 	int open_count;
 	int monitors;
+	unsigned int filter_flags; /* FIF_* */
 	struct iw_statistics wstats;
 	u8 wstats_flags;
 	int tx_headroom; /* required headroom for hardware/radiotap */
net/mac80211/rx.c +2 -2
@@ -1457,7 +1457,7 @@ static int prepare_for_handlers(struct i
 		} else if (!multicast &&
 			   compare_ether_addr(sdata->dev->dev_addr,
 					      hdr->addr1) != 0) {
-			if (!(sdata->flags & IEEE80211_SDATA_PROMISC))
+			if (!(sdata->dev->flags & IFF_PROMISC))
 				return 0;
 			rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
 		}
@@ -1472,7 +1472,7 @@ static int prepare_for_handlers(struct i
 		} else if (!multicast &&
 			   compare_ether_addr(sdata->dev->dev_addr,
 					      hdr->addr1) != 0) {
-			if (!(sdata->flags & IEEE80211_SDATA_PROMISC))
+			if (!(sdata->dev->flags & IFF_PROMISC))
 				return 0;
 			rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
 		} else if (!rx->sta)
net/mac80211/debugfs_netdev.c +0 -16
@@ -425,20 +425,6 @@ IEEE80211_IF_FILE(peer, u.wds.remote_add
 /* VLAN attributes */
 IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
 
-/* MONITOR attributes */
-static ssize_t ieee80211_if_fmt_mode(
-	const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
-{
-	struct ieee80211_local *local = sdata->local;
-
-	return scnprintf(buf, buflen, "%s\n",
-			 ((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
-			  local->open_count == local->monitors) ?
-			 "hard" : "soft");
-}
-__IEEE80211_IF_FILE(mode);
-
-
 #define DEBUGFS_ADD(name, type)\
 	sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
 		sdata->debugfsdir, sdata, &name##_ops);
@@ -542,7 +528,6 @@ static void add_vlan_files(struct ieee80
 
 static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
 {
-	DEBUGFS_ADD(mode, monitor);
 }
 
 static void add_files(struct ieee80211_sub_if_data *sdata)
@@ -671,7 +656,6 @@ static void del_vlan_files(struct ieee80
 
 static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
 {
-	DEBUGFS_DEL(mode, monitor);
 }
 
 static void del_files(struct ieee80211_sub_if_data *sdata, int type)
drivers/net/wireless/b43/b43.h +4 -11
@@ -595,9 +595,8 @@ struct b43_wl {
 	 * at a time. General information about this interface follows.
 	 */
 
-	/* Opaque ID of the operating interface (!= monitor
-	 * interface) from the ieee80211 subsystem.
-	 * Do not modify.
+	/* Opaque ID of the operating interface from the ieee80211
+	 * subsystem. Do not modify.
 	 */
 	int if_id;
 	/* The MAC address of the operating interface. */
@@ -606,14 +605,10 @@ struct b43_wl {
 	u8 bssid[ETH_ALEN];
 	/* Interface type. (IEEE80211_IF_TYPE_XXX) */
 	int if_type;
-	/* Counter of active monitor interfaces. */
-	int monitor;
 	/* Is the card operating in AP, STA or IBSS mode? */
 	bool operating;
-	/* Promisc mode active?
-	 * Note that (monitor != 0) implies promisc.
-	 */
-	bool promisc;
+	/* filter flags */
+	unsigned int filter_flags;
 	/* Stats about the wireless interface */
 	struct ieee80211_low_level_stats ieee_stats;
 
@@ -770,8 +765,6 @@ static inline struct b43_wldev *dev_to_b
 /* Is the device operating in a specified mode (IEEE80211_IF_TYPE_XXX). */
 static inline int b43_is_mode(struct b43_wl *wl, int type)
 {
-	if (type == IEEE80211_IF_TYPE_MNTR)
-		return !!(wl->monitor);
 	return (wl->operating && wl->if_type == type);
 }
 
drivers/net/wireless/b43/main.c +131 -113

349 lines not on this page · raw message

drivers/net/wireless/iwl-base.c +29 -4
@@ -2589,6 +2589,8 @@ static void iwl_set_flags_for_phymode(st
 
 /*
  * initilize rxon structure with default values fromm eeprom
+ *
+ * XXX: This function should use the filter flags instead!
  */
 static void iwl_connection_init_rx_config(struct iwl_priv *priv)
 {
@@ -7481,7 +7483,7 @@ static void iwl_bg_scan_completed(struct
  *
  *****************************************************************************/
 
-static int iwl_mac_open(struct ieee80211_hw *hw)
+static int iwl_mac_start(struct ieee80211_hw *hw)
 {
 	struct iwl_priv *priv = hw->priv;
 
@@ -7500,7 +7502,7 @@ static int iwl_mac_open(struct ieee80211
 	return 0;
 }
 
-static int iwl_mac_stop(struct ieee80211_hw *hw)
+static void iwl_mac_stop(struct ieee80211_hw *hw)
 {
 	struct iwl_priv *priv = hw->priv;
 
@@ -7509,8 +7511,20 @@ static int iwl_mac_stop(struct ieee80211
 	/*netif_stop_queue(dev); */
 	flush_workqueue(priv->workqueue);
 	IWL_DEBUG_MAC80211("leave\n");
+}
 
-	return 0;
+static void
+iwl_configure_filter(struct ieee80211_hw *hw,
+		     struct dev_mc_list *(*get_mc_item)(void *data),
+		     void *get_mc_data,
+		     unsigned int changed_flags,
+		     unsigned int *total_flags)
+{
+	/*
+	 * XXX: dummy
+	 * see also iwl_connection_init_rx_config
+	 */
+	*total_flags = 0;
 }
 
 static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -7679,6 +7693,8 @@ static int iwl_mac_config_interface(stru
 	if (conf == NULL)
 		return -EIO;
 
+	/* TODO: use conf->mac_addr */
+
 	if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) &&
 	    (!conf->beacon || !conf->ssid_len)) {
 		IWL_DEBUG_MAC80211
@@ -7693,8 +7709,14 @@ static int iwl_mac_config_interface(stru
 		IWL_DEBUG_MAC80211("bssid: " MAC_FMT "\n",
 				   MAC_ARG(conf->bssid));
 
+	/*
+	 * XXX: there was a test for IEEE80211_HW_NO_PROBE_FILTERING here
+	 *	which must have been wrong since it was always true.
+	 *	the test was:
 	if (unlikely(priv->status & STATUS_SCANNING) &&
 	    !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
+	 */
+	if (unlikely(priv->status & STATUS_SCANNING)) {
 		IWL_DEBUG_MAC80211("leave - scanning\n");
 		mutex_unlock(&priv->mutex);
 		return 0;
@@ -7787,6 +7809,8 @@ static void iwl_mac_remove_interface(str
 	}
 	mutex_unlock(&priv->mutex);
 
+	/* TODO: clear MAC address in hardware */
+
 	IWL_DEBUG_MAC80211("leave\n");
 
 }
@@ -9039,10 +9063,11 @@ static struct attribute_group iwl_attrib
 
 static struct ieee80211_ops iwl_hw_ops = {
 	.tx = iwl_mac_tx,
-	.open = iwl_mac_open,
+	.start = iwl_mac_start,
 	.stop = iwl_mac_stop,
 	.add_interface = iwl_mac_add_interface,
 	.remove_interface = iwl_mac_remove_interface,
+	.configure_filter = iwl_configure_filter,
 	.config = iwl_mac_config,
 	.config_interface = iwl_mac_config_interface,
 	.set_key = iwl_mac_set_key,
drivers/net/wireless/rtl8187_dev.c +21 -4
@@ -365,7 +365,7 @@ static void rtl8187_set_channel(struct i
 	rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg);
 }
 
-static int rtl8187_open(struct ieee80211_hw *dev)
+static int rtl8187_start(struct ieee80211_hw *dev)
 {
 	struct rtl8187_priv *priv = dev->priv;
 	u32 reg;
@@ -419,7 +419,7 @@ static int rtl8187_open(struct ieee80211
 	return 0;
 }
 
-static int rtl8187_stop(struct ieee80211_hw *dev)
+static void rtl8187_stop(struct ieee80211_hw *dev)
 {
 	struct rtl8187_priv *priv = dev->priv;
 	struct rtl8187_rx_info *info;
@@ -445,7 +445,6 @@ static int rtl8187_stop(struct ieee80211
 		usb_kill_urb(info->urb);
 		kfree_skb(skb);
 	}
-	return 0;
 }
 
 static int rtl8187_add_interface(struct ieee80211_hw *dev,
@@ -476,6 +475,8 @@ static void rtl8187_remove_interface(str
 {
 	struct rtl8187_priv *priv = dev->priv;
 	priv->mode = IEEE80211_IF_TYPE_MGMT;
+
+	/* TODO: reset MAC address to zeroes */
 }
 
 static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
@@ -523,14 +524,30 @@ static int rtl8187_config_interface(stru
 	return 0;
 }
 
+static void
+rtl8187_configure_filter(struct ieee80211_hw *dev,
+			 struct dev_mc_list *(*get_mc_item)(void *data),
+			 void *get_mc_data,
+			 unsigned int changed,
+			 unsigned int *flags)
+{
+	/*
+	 * XXX: dummy
+	 *
+	 * TODO: change filter flags
+	 */
+	*flags = 0;
+}
+
 static const struct ieee80211_ops rtl8187_ops = {
 	.tx			= rtl8187_tx,
-	.open			= rtl8187_open,
+	.start			= rtl8187_start,
 	.stop			= rtl8187_stop,
 	.add_interface		= rtl8187_add_interface,
 	.remove_interface	= rtl8187_remove_interface,
 	.config			= rtl8187_config,
 	.config_interface	= rtl8187_config_interface,
+	.configure_filter	= rtl8187_configure_filter,
 };
 
 static void rtl8187_eeprom_register_read(struct eeprom_93cx6 *eeprom)
drivers/net/wireless/adm8211.c +56 -33

172 lines not on this page · raw message

drivers/net/wireless/zd1211rw-mac80211/zd_mac.c +38 -38

161 lines not on this page · raw message

net/mac80211/ieee80211_sta.c +24 -8
@@ -3581,10 +3581,19 @@ void ieee80211_scan_completed(struct iee
 		printk(KERN_DEBUG "%s: failed to restore operational"
 		       "channel after scan\n", dev->name);
 
-	if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
-	    ieee80211_if_config(dev))
-		printk(KERN_DEBUG "%s: failed to restore operational"
-		       "BSSID after scan\n", dev->name);
+
+	/*
+	 * We need to take this lock in the set_multicast_list path
+	 * leading to configure_filter, so use it to protect the
+	 * local->filter_flags as well.
+	 */
+	netif_tx_lock(local->mdev);
+	local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC;
+	local->ops->configure_filter(local_to_hw(local), NULL, NULL,
+				     FIF_BCN_PRBRESP_PROMISC,
+				     &local->filter_flags);
+
+	netif_tx_unlock(local->mdev);
 
 	memset(&wrqu, 0, sizeof(wrqu));
 	wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
@@ -3768,10 +3777,17 @@ static int ieee80211_sta_start_scan(stru
 	local->scan_channel_idx = 0;
 	local->scan_dev = dev;
 
-	if (!(local->hw.flags & IEEE80211_HW_NO_PROBE_FILTERING) &&
-	    ieee80211_if_config(dev))
-		printk(KERN_DEBUG "%s: failed to set BSSID for scan\n",
-		       dev->name);
+	/*
+	 * We need to take this lock in the set_multicast_list path
+	 * leading to configure_filter, so use it to protect the
+	 * local->filter_flags as well.
+	 */
+	netif_tx_lock(local->mdev);
+	local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
+	local->ops->configure_filter(local_to_hw(local), NULL, NULL,
+				     FIF_BCN_PRBRESP_PROMISC,
+				     &local->filter_flags);
+	netif_tx_unlock(local->mdev);
 
 	/* TODO: start scan as soon as all nullfunc frames are ACKed */
 	queue_delayed_work(local->hw.workqueue, &local->scan_work,
drivers/net/wireless/rt2x00/rt2400pci.c +2 -5
@@ -1447,10 +1447,7 @@ static void rt2400pci_probe_hw_mode(stru
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1593,7 +1590,7 @@ static const struct ieee80211_ops rt2400
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt2400pci_set_retry_limit,
 	.conf_tx		= rt2400pci_conf_tx,
drivers/net/wireless/rt2x00/rt2500pci.c +2 -5
@@ -1745,10 +1745,7 @@ static void rt2500pci_probe_hw_mode(stru
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1884,7 +1881,7 @@ static const struct ieee80211_ops rt2500
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt2500pci_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,
drivers/net/wireless/rt2x00/rt61pci.c +2 -5
@@ -2118,10 +2118,7 @@ static void rt61pci_probe_hw_mode(struct
 	/*
 	 * Initialize all hw fields.
 	 */
-	rt2x00dev->hw->flags =
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = 0;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -2247,7 +2244,7 @@ static const struct ieee80211_ops rt61pc
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt61pci_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,
drivers/net/wireless/rt2x00/rt2500usb.c +2 -4
@@ -1467,9 +1467,7 @@ static void rt2500usb_probe_hw_mode(stru
 	rt2x00dev->hw->flags =
 	    IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
 	    IEEE80211_HW_RX_INCLUDES_FCS |
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1562,7 +1560,7 @@ static const struct ieee80211_ops rt2500
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.conf_tx		= rt2x00mac_conf_tx,
 	.get_tx_stats		= rt2x00mac_get_tx_stats,
drivers/net/wireless/rt2x00/rt73usb.c +2 -4
@@ -1713,9 +1713,7 @@ static void rt73usb_probe_hw_mode(struct
 	 */
 	rt2x00dev->hw->flags =
 	    IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
-	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-	    IEEE80211_HW_MONITOR_DURING_OPER |
-	    IEEE80211_HW_NO_PROBE_FILTERING;
+	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
 	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
 	rt2x00dev->hw->max_signal = MAX_SIGNAL;
 	rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1856,7 +1854,7 @@ static const struct ieee80211_ops rt73us
 	.remove_interface	= rt2x00mac_remove_interface,
 	.config			= rt2x00mac_config,
 	.config_interface	= rt2x00mac_config_interface,
-	.set_multicast_list	= rt2x00mac_set_multicast_list,
+//	.set_multicast_list	= rt2x00mac_set_multicast_list,
 	.get_stats		= rt2x00mac_get_stats,
 	.set_retry_limit	= rt73usb_set_retry_limit,
 	.conf_tx		= rt2x00mac_conf_tx,