device configuration changes
Subsystems (2)
Johannes Berg
maintainercover device configuration changes
The first patch introduces those PLCP/FCS CRC fail flags I had posted earlier, and the second one is the actual change.
johannes
Johannes Berg
maintainerRFC 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.
--- include/net/mac80211.h | 2 ++ net/mac80211/rx.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
include/net/mac80211.h +2 -0
@@ -241,6 +241,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 +20 -1
@@ -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));
Johannes Berg
maintainerRFC v2 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
@@ -241,6 +241,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));
@@ -1465,6 +1484,7 @@ void __ieee80211_rx(struct ieee80211_hwstruct 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);
@@ -1479,10 +1499,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;
Johannes Berg
maintainerRFC 2/2 mac80211: revamp interface and filter configuration
In reply to Johannes BergDrivers 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().
--- drivers/net/wireless/adm8211.c | 33 +- drivers/net/wireless/b43/b43.h | 15 - drivers/net/wireless/b43/main.c | 224 ++++++++-------- drivers/net/wireless/iwl-base.c | 25 + drivers/net/wireless/rtl8187_dev.c | 23 + drivers/net/wireless/zd1211rw-mac80211/zd_mac.c | 54 +-- include/net/mac80211.h | 134 +++++++-- net/mac80211/debugfs_netdev.c | 16 - net/mac80211/ieee80211.c | 333 +++++++++++------------- net/mac80211/ieee80211_i.h | 1 net/mac80211/rx.c | 4 11 files changed, 465 insertions(+), 397 deletions(-)
include/net/mac80211.h +99 -35
@@ -335,7 +335,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.
@@ -487,9 +486,10 @@ 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 has multicast filters. +*/ +#define IEEE80211_HW_MULTICAST_FILTER (1<<0)/* Device does not need BSSID filter set to broadcast in order to * receive all probe responses while scanning */
@@ -540,6 +540,34 @@ static inline void SET_IEEE80211_PERM_ADmemcpy (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 +/* +* show control frames, if PROMISC_IN_BSS is not set then +* only those addressed to this station +*/ +#define FIF_CONTROL 0x10 +/* show frames from other BSSes */ +#define FIF_OTHER_BSS 0x20 +/* 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. */
@@ -552,32 +580,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);
@@ -590,15 +641,28 @@ 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, otherwise the number of multicast +* addresses. +* +* 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 +153 -180
420 lines not on this page · raw message
net/mac80211/ieee80211_i.h +1 -0
@@ -457,6 +457,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
@@ -1417,7 +1417,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 ; }
@@ -1432,7 +1432,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
@@ -422,20 +422,6 @@ __IEEE80211_IF_FILE(beacon_tail_len);/* WDS attributes */ IEEE80211_IF_FILE (peer, u.wds.remote_addr,MAC ); -/* 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);
@@ -530,7 +516,6 @@ static void add_wds_files(struct ieee802static void add_monitor_files (struct ieee80211_sub_if_data *sdata) { -DEBUGFS_ADD (mode, monitor); }static void add_files (struct ieee80211_sub_if_data *sdata)
@@ -647,7 +632,6 @@ static void del_wds_files(struct ieee802static 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
@@ -572,9 +572,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). */
@@ -583,14 +582,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;
@@ -747,8 +742,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 +121 -103
321 lines not on this page · raw message
drivers/net/wireless/iwl-base.c +21 -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 ieee80211return 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(struif (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
@@ -7808,6 +7822,8 @@ static void iwl_mac_remove_interface(str }mutex_unlock (&priv->mutex); +/* TODO: clear MAC address in hardware */ +IWL_DEBUG_MAC80211 ("leave\n" ); }
@@ -9056,10 +9072,11 @@ static struct attribute_group iwl_attribstatic 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 irtl818x_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 ieee80211return 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 ieee80211usb_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(strureturn 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 +21 -12
@@ -349,8 +349,10 @@ static int adm8211_get_stats(struct ieeereturn 0 ; } -static void adm8211_set_rx_mode (struct ieee80211_hw *dev, -unsigned short flags,int mc_count) +static void adm8211_configure_filter (struct ieee80211_hw *dev, +int multi_count, +unsigned int changed, +unsigned int *flags) {struct adm8211_priv *priv = dev->priv;unsigned int bit_nr;
@@ -358,12 +360,15 @@ static void adm8211_set_rx_mode(struct istruct dev_mc_list *mclist;void *tmp; - mc_filter[1 ] = mc_filter[0 ] =0 ; -if (flags &IFF_PROMISC ) { +/* TODO: honour more flags */ + + mc_filter[1 ] = mc_filter[0 ] =0 ; + +if (*flags &FIF_PROMISC_IN_BSS ) { priv->nar |=ADM8211_NAR_PR ; priv->nar &= ~ADM8211_NAR_MM ; mc_filter[1 ] = mc_filter[0 ] =cpu_to_le32 (~0 ); - }else if ((flags &IFF_ALLMULTI ) || (mc_count >-1 )) { + }else if (*flags &FIF_ALLMULTI ) { priv->nar &= ~ADM8211_NAR_PR ; priv->nar |=ADM8211_NAR_MM ; mc_filter[1 ] = mc_filter[0 ] =cpu_to_le32 (~0 );
@@ -379,6 +384,8 @@ static void adm8211_set_rx_mode(struct i } } + *flags &=FIF_PROMISC_IN_BSS |FIF_ALLMULTI ; +ADM8211_IDLE_RX ();ADM8211_CSR_WRITE (MAR0 , mc_filter[0 ]);
@@ -1502,6 +1509,8 @@ static void adm8211_remove_interface(str {struct adm8211_priv *priv = dev->priv; priv->mode =IEEE80211_IF_TYPE_MGMT ; + +/* TODO: clear MAC address */ }static int adm8211_init_rings (struct ieee80211_hw *dev)
@@ -1585,7 +1594,7 @@ static void adm8211_free_rings(struct ie } } -static int adm8211_open (struct ieee80211_hw *dev) +static int adm8211_start (struct ieee80211_hw *dev) {struct adm8211_priv *priv = dev->priv;int retval;
@@ -1628,7 +1637,7 @@ fail:return retval; } -static int adm8211_stop (struct ieee80211_hw *dev) +static void adm8211_stop (struct ieee80211_hw *dev) {struct adm8211_priv *priv = dev->priv;
@@ -1640,7 +1649,6 @@ static int adm8211_stop(struct ieee80211free_irq (priv->pdev->irq, dev);adm8211_free_rings (dev); -return 0 ; } static void adm8211_calc_durations(int *dur, int *plcp, size_t payload_len, int len,
@@ -1841,13 +1849,13 @@ static int adm8211_alloc_rings(struct iestatic const struct ieee80211_ops adm8211_ops = { .tx = adm8211_tx, - .open = adm8211_open, + .start = adm8211_start, .stop = adm8211_stop, .add_interface = adm8211_add_interface, .remove_interface = adm8211_remove_interface, .config = adm8211_config, .config_interface = adm8211_config_interface, - .set_multicast_list = adm8211_set_rx_mode, + .configure_filter = adm8211_configure_filter, .get_stats = adm8211_get_stats, .get_tx_stats = adm8211_get_tx_stats, .get_tsf = adm8211_get_tsft
@@ -1953,7 +1961,8 @@ static int __devinit adm8211_probe(strucSET_IEEE80211_PERM_ADDR (dev, perm_addr); dev->extra_tx_headroom =sizeof (struct adm8211_tx_hdr ); - dev->flags =IEEE80211_HW_WEP_INCLUDE_IV |IEEE80211_HW_NO_TKIP_WMM_HWACCEL ; + dev->flags =IEEE80211_HW_WEP_INCLUDE_IV |IEEE80211_HW_NO_TKIP_WMM_HWACCEL | +IEEE80211_HW_MULTICAST_FILTER ;// however, IEEE80211_HW_RX_INCLUDES_FCS in promisc mode dev->channel_change_time =1000 ;
@@ -2082,7 +2091,7 @@ static int adm8211_resume(struct pci_devpci_restore_state (pdev);if (priv->mode !=IEEE80211_IF_TYPE_MGMT ) { -adm8211_open (dev); +adm8211_start (dev);ieee80211_start_queues (dev); }
drivers/net/wireless/zd1211rw-mac80211/zd_mac.c +24 -30
137 lines not on this page · raw message
Johannes Berg
maintainerRe: [RFC 2/2] mac80211: revamp interface and filter configuration
include/net/mac80211.h struct ieee80211_hw { · line 492
Quoted 8 lines · Johannes Berg
include/net/mac80211.h +4
-3-/* Device is capable of performing full monitor mode even during -* normal operation. */ -#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9) +/* +* Device has multicast filters. +*/ +#define IEEE80211_HW_MULTICAST_FILTER (1<<0)
Well. That should be (1<<9).
johannes
Johannes Berg
maintainerRFC v2 2/2 mac80211: revamp interface and filter configuration
In reply to Johannes BergDrivers 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.
---
Changes since v1:
* introduce FIF_BCN_PRBRESP_PROMISC,
remove IEEE80211_HW_NO_PROBE_FILTERING
b43 sees *A LOT* less frames because no beacons from other BSSes are shown, but I'm not sure if I haven't broken other drivers. Due to the semantics of the removed IEEE80211_HW_NO_PROBE_FILTERING flag I suspect most drivers should have set it but didn't.
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/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 | 340 ++++++++++-------------- net/mac80211/ieee80211_i.h | 1 net/mac80211/ieee80211_sta.c | 16 - net/mac80211/rx.c | 4 12 files changed, 535 insertions(+), 442 deletions(-)
include/net/mac80211.h +109 -39
@@ -335,7 +335,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.
@@ -487,13 +486,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 */
@@ -540,6 +538,39 @@ static inline void SET_IEEE80211_PERM_ADmemcpy (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. */
@@ -552,32 +583,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);
@@ -590,15 +644,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 +154 -186
439 lines not on this page · raw message
net/mac80211/ieee80211_i.h +1 -0
@@ -457,6 +457,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
@@ -1417,7 +1417,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 ; }
@@ -1432,7 +1432,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
@@ -422,20 +422,6 @@ __IEEE80211_IF_FILE(beacon_tail_len);/* WDS attributes */ IEEE80211_IF_FILE (peer, u.wds.remote_addr,MAC ); -/* 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);
@@ -530,7 +516,6 @@ static void add_wds_files(struct ieee802static void add_monitor_files (struct ieee80211_sub_if_data *sdata) { -DEBUGFS_ADD (mode, monitor); }static void add_files (struct ieee80211_sub_if_data *sdata)
@@ -647,7 +632,6 @@ static void del_wds_files(struct ieee802static 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
@@ -572,9 +572,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). */
@@ -583,14 +582,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;
@@ -747,8 +742,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 ieee80211return 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(struif (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(struIWL_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" ); }
@@ -9056,10 +9078,11 @@ static struct attribute_group iwl_attribstatic 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 irtl818x_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 ieee80211return 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 ieee80211usb_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(strureturn 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
@@ -3584,10 +3584,10 @@ void ieee80211_scan_completed(struct ieeprintk (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 );
@@ -3771,10 +3771,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,
Johannes Berg
maintainerRe: [RFC 2/2 v2] mac80211: revamp interface and filter configuration
For convenience, here are the patches for each driver.
johannes
drivers/net/wireless/adm8211.c +54 -31
@@ -349,25 +349,47 @@ static int adm8211_get_stats(struct ieeereturn 0 ; } -static void adm8211_set_rx_mode (struct ieee80211_hw *dev, -unsigned short flags,int mc_count) +static void adm8211_set_bssid (struct ieee80211_hw *dev,u8 *bssid) +{ +struct adm8211_priv *priv = dev->priv; +u32 reg; + + reg = bssid[0 ] | (bssid[1 ] <<8 ) | (bssid[2 ] <<16 ) | (bssid[3 ] <<24 ); +ADM8211_CSR_WRITE (BSSID0 , reg); + reg =ADM8211_CSR_READ (ABDA1 ); + reg &=0x0000ffff ; + reg |= (bssid[4 ] <<16 ) | (bssid[5 ] <<24 ); +ADM8211_CSR_WRITE (ABDA1 , reg); +} + +static void adm8211_configure_filter (struct ieee80211_hw *dev, +int multi_count, +unsigned int changed, +unsigned int *flags) {struct adm8211_priv *priv = dev->priv;unsigned int bit_nr;__le32 mc_filter[2 ];struct dev_mc_list *mclist;void *tmp; +int change =0 ; +u8 bcast_addr[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; - mc_filter[1 ] = mc_filter[0 ] =0 ; -if (flags &IFF_PROMISC ) { +/* TODO: honour more flags */ + + mc_filter[1 ] = mc_filter[0 ] =0 ; + +if (*flags &FIF_PROMISC_IN_BSS ) { priv->nar |=ADM8211_NAR_PR ; priv->nar &= ~ADM8211_NAR_MM ; mc_filter[1 ] = mc_filter[0 ] =cpu_to_le32 (~0 ); - }else if ((flags &IFF_ALLMULTI ) || (mc_count >-1 )) { + change =1 ; + }else if (*flags &FIF_ALLMULTI ) { priv->nar &= ~ADM8211_NAR_PR ; priv->nar |=ADM8211_NAR_MM ; mc_filter[1 ] = mc_filter[0 ] =cpu_to_le32 (~0 ); - }else { + change =1 ; + }else if (multi_count >=0 ) { priv->nar &= ~(ADM8211_NAR_MM |ADM8211_NAR_PR ); mc_filter[1 ] = mc_filter[0 ] =0 ; mclist =NULL ;
@@ -377,15 +399,27 @@ static void adm8211_set_rx_mode(struct i bit_nr &=0x3F ; mc_filter[bit_nr >>5 ] |=cpu_to_le32 (1 << (bit_nr &31 )); } + change =1 ; } -ADM8211_IDLE_RX (); + *flags &=FIF_PROMISC_IN_BSS |FIF_ALLMULTI |FIF_BCN_PRBRESP_PROMISC ; -ADM8211_CSR_WRITE (MAR0 , mc_filter[0 ]); -ADM8211_CSR_WRITE (MAR1 , mc_filter[1 ]); -ADM8211_CSR_READ (NAR ); +if (change &FIF_BCN_PRBRESP_PROMISC ) { +if (*flags &FIF_BCN_PRBRESP_PROMISC ) +adm8211_set_bssid (dev, bcast_addr); +else +adm8211_set_bssid (dev, priv->bssid); + } -ADM8211_RESTORE (); +if (change) { +ADM8211_IDLE_RX (); + +ADM8211_CSR_WRITE (MAR0 , mc_filter[0 ]); +ADM8211_CSR_WRITE (MAR1 , mc_filter[1 ]); +ADM8211_CSR_READ (NAR ); + +ADM8211_RESTORE (); + } } static int adm8211_get_tx_stats(struct ieee80211_hw *dev,
@@ -1414,19 +1448,6 @@ static void adm8211_set_interval(structADM8211_CSR_WRITE (BPLI , reg); } -static void adm8211_set_bssid (struct ieee80211_hw *dev,u8 *bssid) -{ -struct adm8211_priv *priv = dev->priv; -u32 reg; - - reg = bssid[0 ] | (bssid[1 ] <<8 ) | (bssid[2 ] <<16 ) | (bssid[3 ] <<24 ); -ADM8211_CSR_WRITE (BSSID0 , reg); - reg =ADM8211_CSR_READ (ABDA1 ); - reg &=0x0000ffff ; - reg |= (bssid[4 ] <<16 ) | (bssid[5 ] <<24 ); -ADM8211_CSR_WRITE (ABDA1 , reg); -} -static int adm8211_set_ssid (struct ieee80211_hw *dev,u8 *ssid,size_t ssid_len) {struct adm8211_priv *priv = dev->priv;
@@ -1502,6 +1523,8 @@ static void adm8211_remove_interface(str {struct adm8211_priv *priv = dev->priv; priv->mode =IEEE80211_IF_TYPE_MGMT ; + +/* TODO: clear MAC address */ }static int adm8211_init_rings (struct ieee80211_hw *dev)
@@ -1585,7 +1608,7 @@ static void adm8211_free_rings(struct ie } } -static int adm8211_open (struct ieee80211_hw *dev) +static int adm8211_start (struct ieee80211_hw *dev) {struct adm8211_priv *priv = dev->priv;int retval;
@@ -1628,7 +1651,7 @@ fail:return retval; } -static int adm8211_stop (struct ieee80211_hw *dev) +static void adm8211_stop (struct ieee80211_hw *dev) {struct adm8211_priv *priv = dev->priv;
@@ -1640,7 +1663,6 @@ static int adm8211_stop(struct ieee80211free_irq (priv->pdev->irq, dev);adm8211_free_rings (dev); -return 0 ; } static void adm8211_calc_durations(int *dur, int *plcp, size_t payload_len, int len,
@@ -1841,13 +1863,13 @@ static int adm8211_alloc_rings(struct iestatic const struct ieee80211_ops adm8211_ops = { .tx = adm8211_tx, - .open = adm8211_open, + .start = adm8211_start, .stop = adm8211_stop, .add_interface = adm8211_add_interface, .remove_interface = adm8211_remove_interface, .config = adm8211_config, .config_interface = adm8211_config_interface, - .set_multicast_list = adm8211_set_rx_mode, + .configure_filter = adm8211_configure_filter, .get_stats = adm8211_get_stats, .get_tx_stats = adm8211_get_tx_stats, .get_tsf = adm8211_get_tsft
@@ -1953,7 +1975,8 @@ static int __devinit adm8211_probe(strucSET_IEEE80211_PERM_ADDR (dev, perm_addr); dev->extra_tx_headroom =sizeof (struct adm8211_tx_hdr ); - dev->flags =IEEE80211_HW_WEP_INCLUDE_IV |IEEE80211_HW_NO_TKIP_WMM_HWACCEL ; + dev->flags =IEEE80211_HW_WEP_INCLUDE_IV |IEEE80211_HW_NO_TKIP_WMM_HWACCEL | +IEEE80211_HW_MULTICAST_FILTER ;// however, IEEE80211_HW_RX_INCLUDES_FCS in promisc mode dev->channel_change_time =1000 ;
@@ -2082,7 +2105,7 @@ static int adm8211_resume(struct pci_devpci_restore_state (pdev);if (priv->mode !=IEEE80211_IF_TYPE_MGMT ) { -adm8211_open (dev); +adm8211_start (dev);ieee80211_start_queues (dev); }
drivers/net/wireless/b43/b43.h +4 -11
@@ -572,9 +572,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). */
@@ -583,14 +582,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;
@@ -747,8 +742,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 ieee80211return 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(struif (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(struIWL_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" ); }
@@ -9056,10 +9078,11 @@ static struct attribute_group iwl_attribstatic 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 irtl818x_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 ieee80211return 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 ieee80211usb_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(strureturn 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/zd1211rw-mac80211/zd_mac.c +31 -35
150 lines not on this page · raw message
Re: [RFC 2/2 v2] mac80211: revamp interface and filter configuration
Quoted 4 lines · On Thursday 16 August 2007 16:58:50 Johannes Berg wrote:
For convenience, here are the patches for each driver.
johannes
b43 patch:
Signature · 1 line
Greetings Michael.