Skip to contentSkip to conversation

d80211: AP mode fixes

PATCH In review Jiri Benc 2 participants 7 messages Jun 23, 2006 – Jun 24, 2006

Subsystems (3)
lore
Share & tools
lore

Jiri Benc

author
#0 lore raw

cover d80211: AP mode fixes

This a series of experimental AP mode fixes.

It is also available (together with patches for bcm43xx AP mode support) in a 'devel' branch of my dscape tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/jbenc/dscape.git devel

Signature · 2 lines
Jiri Benc
SUSE Labs
author
#1 lore raw

PATCH 1/3 d80211: do not receive through master interface

Arrived packets should not go into master interface - it leads to duplicate packets reception.

---
 net/d80211/ieee80211.c |    4 ++++
 1 files changed, 4 insertions(+)
net/d80211/ieee80211.c +4 -0
@@ -3586,6 +3586,10 @@ void __ieee80211_rx(struct net_device *d
 					   !ieee80211_bssid_match(bssid,
 							sdata->dev->dev_addr))
 					continue;
+				if (sdata->dev == sdata->master)
+					/* do not receive anything via
+					 * master device */
+					continue;
 				break;
 			case IEEE80211_IF_TYPE_WDS:
 				if (bssid ||
author
#2 lore raw

PATCH 1/3 d80211: experimental: do not receive through master interface when not scanning

This is a corrected version of the patch. I also updated the 'devel' branch of my tree.

---

Arrived packets should not go into master interface except when scanning
- it leads to duplicate packets reception. This also fixes a race when scanning is finished during invoking of rx handlers.

---
 net/d80211/ieee80211.c   |   17 +++++++++++++++--
 net/d80211/ieee80211_i.h |    1 +
 2 files changed, 16 insertions(+), 2 deletions(-)
net/d80211/ieee80211.c +15 -2
@@ -3348,6 +3348,12 @@ ieee80211_rx_h_passive_scan(struct ieee8
                 }
         }
 
+	if (unlikely(rx->u.rx.in_scan)) {
+		/* scanning finished during invoking of handlers */
+		I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
+		return TXRX_DROP;
+	}
+
         return TXRX_CONTINUE;
 }
 
@@ -3539,6 +3545,9 @@ void __ieee80211_rx(struct net_device *d
 		goto end;
         }
 
+	if (unlikely(local->sta_scanning || local->scan.in_scan))
+		rx.u.rx.in_scan = 1;
+
 	if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) &&
 	    !local->iff_promiscs && !multicast) {
 		rx.dev = sta->dev;
@@ -3581,11 +3590,15 @@ void __ieee80211_rx(struct net_device *d
 					if (memcmp(sdata->dev->dev_addr,
 						   hdr->addr1, ETH_ALEN) != 0)
 						continue;
-				} else if (!local->sta_scanning &&
-					   !local->scan.in_scan &&
+				} else if (!rx.u.rx.in_scan &&
 					   !ieee80211_bssid_match(bssid,
 							sdata->dev->dev_addr))
 					continue;
+				if (sdata->dev == sdata->master &&
+				    !rx.u.rx.in_scan)
+					/* do not receive anything via
+					 * master device when not scanning */
+					continue;
 				break;
 			case IEEE80211_IF_TYPE_WDS:
 				if (bssid ||
net/d80211/ieee80211_i.h +1 -0
@@ -137,6 +137,7 @@ struct ieee80211_txrx_data {
 			struct ieee80211_rx_status *status;
 			int sent_ps_buffered;
 			int queue;
+			int in_scan:1;
 		} rx;
 	} u;
 #ifdef CONFIG_HOSTAPD_WPA_TESTING
author
#3 lore raw

PATCH 2/3 d80211: host_gen_beacon_template flag

In reply to Jiri Benc

This is a partial support for devices requiring beacon template. Please note that there is no support for PS mode for such cards yet.

---
 include/net/d80211.h         |    6 ++++++
 net/d80211/ieee80211.c       |   22 +++++++++++++++++++++-
 net/d80211/ieee80211_i.h     |    1 +
 net/d80211/ieee80211_ioctl.c |    2 +-
 4 files changed, 29 insertions(+), 2 deletions(-)
include/net/d80211.h +6 -0
@@ -349,6 +349,9 @@ struct ieee80211_if_init_conf {
  *	only during config_interface() callback (so copy the value somewhere
  *	if you need it).
  * @generic_elem_len: length of the generic element.
+ * @beacon: beacon template. Valid only if @host_gen_beacon_template in
+ *	&struct ieee80211_hw is set. The driver is responsible of freeing
+ *	the sk_buff.
  *
  * This structure is passed to config_interface() callback of
  * &struct ieee80211_hw.
@@ -360,6 +363,7 @@ struct ieee80211_if_conf {
 	size_t ssid_len;
 	u8 *generic_elem;
 	size_t generic_elem_len;
+	struct sk_buff *beacon;
 };
 
 typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL }
@@ -439,6 +443,8 @@ struct ieee80211_hw {
 	 * beacon frame. */
 	int host_gen_beacon:1;
 
+	/* The device needs to be supplied with a beacon template only. */
+	int host_gen_beacon_template:1;
 
 	/* Some devices handle decryption internally and do not
 	 * indicate whether the frame was encrypted (unencrypted frames
net/d80211/ieee80211.c +21 -1
@@ -1902,7 +1902,8 @@ ieee80211_get_buffered_bc(struct net_dev
 	return skb;
 }
 
-int ieee80211_if_config(struct net_device *dev)
+static int __ieee80211_if_config(struct net_device *dev,
+				 struct sk_buff *beacon)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct ieee80211_local *local = dev->ieee80211_ptr;
@@ -1925,10 +1926,29 @@ int ieee80211_if_config(struct net_devic
 		conf.ssid_len = sdata->u.ap.ssid_len;
 		conf.generic_elem = sdata->u.ap.generic_elem;
 		conf.generic_elem_len = sdata->u.ap.generic_elem_len;
+		conf.beacon = beacon;
 	}
 	return local->hw->config_interface(local->mdev, dev->ifindex, &conf);
 }
 
+int ieee80211_if_config(struct net_device *dev)
+{
+	return __ieee80211_if_config(dev, NULL);
+}
+
+int ieee80211_if_config_beacon(struct net_device *dev)
+{
+	struct ieee80211_local *local = dev->ieee80211_ptr;
+	struct sk_buff *skb;
+
+	if (!local->hw->host_gen_beacon_template)
+		return 0;
+	skb = ieee80211_beacon_get(local->mdev, dev->ifindex, NULL);
+	if (!skb)
+		return -ENOMEM;
+	return __ieee80211_if_config(dev, skb);
+}
+
 int ieee80211_hw_config(struct net_device *dev)
 {
 	struct ieee80211_local *local = dev->ieee80211_ptr;
net/d80211/ieee80211_i.h +1 -0
@@ -545,6 +545,7 @@ struct sta_attribute {
 void ieee80211_release_hw(struct ieee80211_local *local);
 int ieee80211_hw_config(struct net_device *dev);
 int ieee80211_if_config(struct net_device *dev);
+int ieee80211_if_config_beacon(struct net_device *dev);
 struct ieee80211_key_conf *
 ieee80211_key_data2conf(struct ieee80211_local *local,
 			struct ieee80211_key *data);
net/d80211/ieee80211_ioctl.c +1 -1
@@ -110,7 +110,7 @@ static int ieee80211_ioctl_set_beacon(st
 		}
 	}
 
-	return 0;
+	return ieee80211_if_config_beacon(dev);
 }
 
 
author
#4 lore raw

PATCH 3/3 bcm43xx-d80211: use host_gen_beacon_template

In reply to Jiri Benc

Use new host_gen_beacon_template flag. This also means workaround with "iwconfig essid" after hostapd is run is not necessary anymore.

---

 drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c |   36 ++++++---------------
 1 files changed, 11 insertions(+), 25 deletions(-)
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +11 -25
@@ -1710,17 +1710,12 @@ static void bcm43xx_write_probe_resp_tem
 	kfree(probe_resp_data);
 }
 
-static int bcm43xx_refresh_cached_beacon(struct bcm43xx_private *bcm)
+static int bcm43xx_refresh_cached_beacon(struct bcm43xx_private *bcm,
+					 struct sk_buff *beacon)
 {
-	struct ieee80211_tx_control control;
-
 	if (bcm->cached_beacon)
 		kfree_skb(bcm->cached_beacon);
-	bcm->cached_beacon = ieee80211_beacon_get(bcm->net_dev,
-						  bcm->interface.if_id,
-						  &control);
-	if (unlikely(!bcm->cached_beacon))
-		return -ENOMEM;
+	bcm->cached_beacon = beacon;
 
 	return 0;
 }
@@ -1743,16 +1738,15 @@ static void bcm43xx_update_templates(str
 	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD, status);
 }
 
-static void bcm43xx_refresh_templates(struct bcm43xx_private *bcm)
+static void bcm43xx_refresh_templates(struct bcm43xx_private *bcm,
+				      struct sk_buff *beacon)
 {
 	int err;
 
-	err = bcm43xx_refresh_cached_beacon(bcm);
+	err = bcm43xx_refresh_cached_beacon(bcm, beacon);
 	if (unlikely(err))
 		return;
 	bcm43xx_update_templates(bcm);
-	kfree_skb(bcm->cached_beacon);
-	bcm->cached_beacon = NULL;
 }
 
 static void bcm43xx_set_ssid(struct bcm43xx_private *bcm,
@@ -1792,19 +1786,11 @@ static void bcm43xx_set_beacon_int(struc
 static void handle_irq_beacon(struct bcm43xx_private *bcm)
 {
 	u32 status;
-	int err;
 
 	bcm->irq_savedstate &= ~BCM43xx_IRQ_BEACON;
 	status = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD);
 
-	if (!bcm->cached_beacon) {
-		err = bcm43xx_refresh_cached_beacon(bcm);
-		if (unlikely(err))
-			goto ack;
-	}
-
-	if ((status & 0x1) && (status & 0x2)) {
-ack:
+	if (!bcm->cached_beacon || ((status & 0x1) && (status & 0x2))) {
 		/* ACK beacon IRQ. */
 		bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON,
 				BCM43xx_IRQ_BEACON);
@@ -4382,7 +4368,6 @@ static int bcm43xx_net_config(struct net
 
 	if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP)) {
 		bcm43xx_set_beacon_int(bcm, conf->beacon_int);
-		bcm43xx_refresh_templates(bcm);
 	}
 
 	bcm43xx_unlock_irqonly(bcm, flags);
@@ -4553,7 +4538,7 @@ static int bcm43xx_add_interface(struct 
 	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
 		bcm43xx_select_opmode(bcm);
 		if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP))
-			bcm43xx_refresh_templates(bcm);
+			bcm43xx_refresh_templates(bcm, NULL);
 	}
 	err = 0;
 
@@ -4606,7 +4591,8 @@ static int bcm43xx_config_interface(stru
 		if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP)) {
 			assert(conf->type == IEEE80211_IF_TYPE_AP);
 			bcm43xx_set_ssid(bcm, conf->ssid, conf->ssid_len);
-			bcm43xx_refresh_templates(bcm);
+			if (conf->beacon)
+				bcm43xx_refresh_templates(bcm, conf->beacon);
 		}
 	}
 	bcm43xx_unlock_irqsafe(bcm, flags);
@@ -4701,7 +4687,7 @@ static int __devinit bcm43xx_init_one(st
 		goto out;
 	ieee->version = IEEE80211_VERSION;
 	ieee->name = KBUILD_MODNAME;
-	ieee->host_gen_beacon = 1;
+	ieee->host_gen_beacon_template = 1;
 	ieee->rx_includes_fcs = 1;
 	ieee->monitor_during_oper = 1;
 	ieee->tx = bcm43xx_net_hard_start_xmit;
#5 lore raw

Re: [PATCH 3/3] bcm43xx-d80211: use host_gen_beacon_template

Quoted 4 lines · Jiri Benc

Use new host_gen_beacon_template flag. This also means workaround with "iwconfig essid" after hostapd is run is not necessary anymore.

John, please apply.

Quoted 106 lines

---

 drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c |   36 ++++++---------------
 1 files changed, 11 insertions(+), 25 deletions(-)
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +11 -25
@@ -1710,17 +1710,12 @@ static void bcm43xx_write_probe_resp_tem
 	kfree(probe_resp_data);
 }
 
-static int bcm43xx_refresh_cached_beacon(struct bcm43xx_private *bcm)
+static int bcm43xx_refresh_cached_beacon(struct bcm43xx_private *bcm,
+					 struct sk_buff *beacon)
 {
-	struct ieee80211_tx_control control;
-
 	if (bcm->cached_beacon)
 		kfree_skb(bcm->cached_beacon);
-	bcm->cached_beacon = ieee80211_beacon_get(bcm->net_dev,
-						  bcm->interface.if_id,
-						  &control);
-	if (unlikely(!bcm->cached_beacon))
-		return -ENOMEM;
+	bcm->cached_beacon = beacon;
 
 	return 0;
 }
@@ -1743,16 +1738,15 @@ static void bcm43xx_update_templates(str
 	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD, status);
 }
 
-static void bcm43xx_refresh_templates(struct bcm43xx_private *bcm)
+static void bcm43xx_refresh_templates(struct bcm43xx_private *bcm,
+				      struct sk_buff *beacon)
 {
 	int err;
 
-	err = bcm43xx_refresh_cached_beacon(bcm);
+	err = bcm43xx_refresh_cached_beacon(bcm, beacon);
 	if (unlikely(err))
 		return;
 	bcm43xx_update_templates(bcm);
-	kfree_skb(bcm->cached_beacon);
-	bcm->cached_beacon = NULL;
 }
 
 static void bcm43xx_set_ssid(struct bcm43xx_private *bcm,
@@ -1792,19 +1786,11 @@ static void bcm43xx_set_beacon_int(struc
 static void handle_irq_beacon(struct bcm43xx_private *bcm)
 {
 	u32 status;
-	int err;
 
 	bcm->irq_savedstate &= ~BCM43xx_IRQ_BEACON;
 	status = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD);
 
-	if (!bcm->cached_beacon) {
-		err = bcm43xx_refresh_cached_beacon(bcm);
-		if (unlikely(err))
-			goto ack;
-	}
-
-	if ((status & 0x1) && (status & 0x2)) {
-ack:
+	if (!bcm->cached_beacon || ((status & 0x1) && (status & 0x2))) {
 		/* ACK beacon IRQ. */
 		bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON,
 				BCM43xx_IRQ_BEACON);
@@ -4382,7 +4368,6 @@ static int bcm43xx_net_config(struct net
 
 	if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP)) {
 		bcm43xx_set_beacon_int(bcm, conf->beacon_int);
-		bcm43xx_refresh_templates(bcm);
 	}
 
 	bcm43xx_unlock_irqonly(bcm, flags);
@@ -4553,7 +4538,7 @@ static int bcm43xx_add_interface(struct 
 	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
 		bcm43xx_select_opmode(bcm);
 		if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP))
-			bcm43xx_refresh_templates(bcm);
+			bcm43xx_refresh_templates(bcm, NULL);
 	}
 	err = 0;
 
@@ -4606,7 +4591,8 @@ static int bcm43xx_config_interface(stru
 		if (bcm43xx_is_mode(bcm, IEEE80211_IF_TYPE_AP)) {
 			assert(conf->type == IEEE80211_IF_TYPE_AP);
 			bcm43xx_set_ssid(bcm, conf->ssid, conf->ssid_len);
-			bcm43xx_refresh_templates(bcm);
+			if (conf->beacon)
+				bcm43xx_refresh_templates(bcm, conf->beacon);
 		}
 	}
 	bcm43xx_unlock_irqsafe(bcm, flags);
@@ -4701,7 +4687,7 @@ static int __devinit bcm43xx_init_one(st
 		goto out;
 	ieee->version = IEEE80211_VERSION;
 	ieee->name = KBUILD_MODNAME;
-	ieee->host_gen_beacon = 1;
+	ieee->host_gen_beacon_template = 1;
 	ieee->rx_includes_fcs = 1;
 	ieee->monitor_during_oper = 1;
 	ieee->tx = bcm43xx_net_hard_start_xmit;
Signature · 1 line
Greetings Michael.
author
#6 lore raw

Re: [PATCH 3/3] bcm43xx-d80211: use host_gen_beacon_template

Quoted 1 line · Michael Buesch

John, please apply.

Please do not apply the whole series yet, it is experimental and not well tested (I wrote it in the introduction e-mail but will ensure I put it also in subjects next time).

For example, I just realized that the first patch breaks scanning in STA mode.

Thanks,

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs