linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mac80211: better definition of mactime
@ 2008-02-15  7:01 Bruno Randolf
  2008-02-15  7:01 ` [PATCH 2/3] mac80211: move function ieee80211_sta_join_ibss() Bruno Randolf
                   ` (2 more replies)
  0 siblings, 3 replies; 61+ messages in thread
From: Bruno Randolf @ 2008-02-15  7:01 UTC (permalink / raw)
  To: ath5k-devel
  Cc: mcgrof, jirislaby, mickflemm, linux-wireless, linville, johannes,
	flamingice, jbenc

define mactime as the time when the first data symbol arrived at the HW. the
old definition was questionable because 802.11 defines timestamp only for
beacon and probe response frames, and there it means the timestamp field.

a stricter definition of mactime is necessary for correct merging of IBSS.

note that it is up to the driver to convert whatever its hardware returns to
this definition. unfortunately we don't know for example when atheros hardware
takes its rx timestamp exactly :(

Signed-off-by: Bruno Randolf <bruno@thinktube.com>
---

 include/net/mac80211.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 460da54..1b807f4 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -295,7 +295,8 @@ enum mac80211_rx_flags {
  * The low-level driver should provide this information (the subset
  * supported by hardware) to the 802.11 code with each received
  * frame.
- * @mactime: MAC timestamp as defined by 802.11
+ * @mactime: value in microseconds of the 64-bit Time Synchronization Function
+ * 	(TSF) timer when the first data symbol (MPDU) arrived at the hardware.
  * @band: the active band when this frame was received
  * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  * @ssi: signal strength when receiving this frame


^ permalink raw reply related	[flat|nested] 61+ messages in thread
* Re: [PATCH] mac80211: enable IBSS merging
@ 2008-02-08  9:41 Joerg Pommnitz
  0 siblings, 0 replies; 61+ messages in thread
From: Joerg Pommnitz @ 2008-02-08  9:41 UTC (permalink / raw)
  To: linux-wireless

Johannes Berg wrote:
> I think we should simply allow setting the BSSID (SIOCSIWAP maybe?) on
> IBSS interfaces and punt this issue to userspace.

This is exactly what we did/do with a Madwifi based IBSS network. I would
miss this feature when we switch to ath5k. So if you are taking votes on 
this, you will get mine.

Regards
  Joerg


      Lesen Sie Ihre E-Mails jetzt einfach von unterwegs.
www.yahoo.de/go

^ permalink raw reply	[flat|nested] 61+ messages in thread
* Re: [PATCH 2/2] mac80211: enable IBSS merging
@ 2008-02-05 11:08 Johannes Berg
  2008-02-06  2:49 ` [PATCH] " Bruno Randolf
  0 siblings, 1 reply; 61+ messages in thread
From: Johannes Berg @ 2008-02-05 11:08 UTC (permalink / raw)
  To: Bruno Randolf
  Cc: ath5k-devel, mcgrof, jirislaby, mickflemm, linux-wireless,
	linville, flamingice, jbenc

[-- Attachment #1: Type: text/plain, Size: 735 bytes --]


> +	/* check if we need to merge IBSS */
> +	if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon &&
> +	    !local->sta_sw_scanning && !local->sta_hw_scanning &&
> +	    mgmt->u.beacon.capab_info & WLAN_CAPABILITY_IBSS &&
> +	    memcmp(elems.ssid, sdata->u.sta.ssid, sdata->u.sta.ssid_len) == 0) {

This needs to test whether elems.ssid_len == sdata->u.sta.ssid_len
(before doing the memcmp to not overrun the frame).

> +		if (rx_status->flag & RX_FLAG_TSFT)
> +			/* in order for correct IBSS merging we need mactime */
> +			mactime = rx_status->mactime;

This needs to be documented (with the RX flag I guess) and b43(legacy)
should be changed to include the TSFT in beacon frames in IBSS mode...

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 61+ messages in thread
* [PATCH] mac80211: enable IBSS merging
@ 2008-01-18 12:52 Bruno Randolf
  2008-01-20 10:17 ` Luis R. Rodriguez
  2008-01-23 14:48 ` Johannes Berg
  0 siblings, 2 replies; 61+ messages in thread
From: Bruno Randolf @ 2008-01-18 12:52 UTC (permalink / raw)
  To: ath5k-devel; +Cc: mcgrof, jirislaby, mickflemm, linux-wireless, linville

enable IBSS cell merging. if an IBSS beacon with the same ESSID and a TSF
higher than the local TSF (mactime) is received, we have to join its BSSID.

* move the relevant code section (previously only containing debug code) down
to the end of the function, so we can reuse the bss structure.

* we have to compare the mactime (TSF at the time of packet receive) rather
than the current TSF.

* in IBSS mode we want to allow beacons to override probe response info so we
can correctly do merges.

* we don't only configure beacons based on scan results, so change that
message.

* to enable all this we have to let all beacons thru in IBSS mode, even if they
have a different BSSID.

Signed-off-by: Bruno Randolf <bruno@thinktube.com>
---

 net/mac80211/ieee80211_sta.c |   75 ++++++++++++++++++++++++++----------------
 net/mac80211/rx.c            |    5 ++-
 2 files changed, 51 insertions(+), 29 deletions(-)


diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index e7da1cd..f6b76a3 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -80,6 +80,9 @@ static void ieee80211_rx_bss_put(struct net_device *dev,
 				 struct ieee80211_sta_bss *bss);
 static int ieee80211_sta_find_ibss(struct net_device *dev,
 				   struct ieee80211_if_sta *ifsta);
+static int ieee80211_sta_join_ibss(struct net_device *dev,
+				   struct ieee80211_if_sta *ifsta,
+				   struct ieee80211_sta_bss *bss);
 static int ieee80211_sta_wep_configured(struct net_device *dev);
 static int ieee80211_sta_start_scan(struct net_device *dev,
 				    u8 *ssid, size_t ssid_len);
@@ -1825,7 +1828,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
 	struct ieee80211_sta_bss *bss;
 	struct sta_info *sta;
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-	u64 timestamp;
+	u64 timestamp, mactime;
 	DECLARE_MAC_BUF(mac);
 	DECLARE_MAC_BUF(mac2);
 
@@ -1843,30 +1846,6 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
 		return;
 
 	timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
-
-	if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon &&
-	    memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
-#ifdef CONFIG_MAC80211_IBSS_DEBUG
-		static unsigned long last_tsf_debug = 0;
-		u64 tsf;
-		if (local->ops->get_tsf)
-			tsf = local->ops->get_tsf(local_to_hw(local));
-		else
-			tsf = -1LLU;
-		if (time_after(jiffies, last_tsf_debug + 5 * HZ)) {
-			printk(KERN_DEBUG "RX beacon SA=%s BSSID="
-			       "%s TSF=0x%llx BCN=0x%llx diff=%lld "
-			       "@%lu\n",
-			       print_mac(mac, mgmt->sa), print_mac(mac2, mgmt->bssid),
-			       (unsigned long long)tsf,
-			       (unsigned long long)timestamp,
-			       (unsigned long long)(tsf - timestamp),
-			       jiffies);
-			last_tsf_debug = jiffies;
-		}
-#endif /* CONFIG_MAC80211_IBSS_DEBUG */
-	}
-
 	ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
 
 	if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
@@ -1951,7 +1930,8 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
 #endif
 	}
 
-	if (bss->probe_resp && beacon) {
+	if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
+	    bss->probe_resp && beacon) {
 		/* Do not allow beacon to override data from Probe Response. */
 		ieee80211_rx_bss_put(dev, bss);
 		return;
@@ -2070,6 +2050,45 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
 	bss->noise = rx_status->noise;
 	if (!beacon)
 		bss->probe_resp++;
+
+	/* check if we need to merge IBSS */
+	if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon &&
+	    !local->sta_sw_scanning && !local->sta_hw_scanning &&
+	    mgmt->u.beacon.capab_info & WLAN_CAPABILITY_IBSS &&
+	    memcmp(elems.ssid, sdata->u.sta.ssid, sdata->u.sta.ssid_len) == 0) {
+#ifdef CONFIG_MAC80211_IBSS_DEBUG
+		static unsigned long last_tsf_debug;
+#endif
+		if (rx_status->flag & RX_FLAG_TSFT)
+			mactime = rx_status->mactime;
+		else {
+			mactime = -1LLU;
+			printk(KERN_WARNING "%s: IBSS mode needs mactime for "
+				"beacons\n", dev->name);
+		}
+#ifdef CONFIG_MAC80211_IBSS_DEBUG
+		if (time_after(jiffies, last_tsf_debug + 5 * HZ)) {
+			printk(KERN_DEBUG "RX beacon SA=%s BSSID="
+			       "%s TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n",
+			       print_mac(mac, mgmt->sa),
+			       print_mac(mac2, mgmt->bssid),
+			       (unsigned long long)mactime,
+			       (unsigned long long)timestamp,
+			       (unsigned long long)(mactime - timestamp),
+			       jiffies);
+			last_tsf_debug = jiffies;
+		}
+#endif /* CONFIG_MAC80211_IBSS_DEBUG */
+		if (mactime <= timestamp) {
+			printk(KERN_DEBUG "%s: beacon TSF higher than local TSF"
+				" -> IBSS merge with BSSID %s\n",
+				dev->name, print_mac(mac, mgmt->bssid));
+			ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss);
+			ieee80211_ibss_add_sta(dev, NULL,
+				mgmt->bssid, mgmt->sa);
+		}
+	}
+
 	ieee80211_rx_bss_put(dev, bss);
 }
 
@@ -2724,7 +2743,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev,
 		return -1;
 	}
 
-	/* Set beacon template based on scan results */
+	/* Set beacon template */
 	skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
 	do {
 		if (!skb)
@@ -2810,7 +2829,7 @@ static int ieee80211_sta_join_ibss(struct net_device *dev,
 		    local->ops->beacon_update(local_to_hw(local),
 					     skb, &control) == 0) {
 			printk(KERN_DEBUG "%s: Configured IBSS beacon "
-			       "template based on scan results\n", dev->name);
+			       "template\n", dev->name);
 			skb = NULL;
 		}
 
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 6cc1e7e..5617e17 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1609,7 +1609,10 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
 	case IEEE80211_IF_TYPE_IBSS:
 		if (!bssid)
 			return 0;
-		if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
+		if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT &&
+		    (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
+			return 1;
+		else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
 			if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
 				return 0;
 			rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;


^ permalink raw reply related	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2008-02-18 11:16 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15  7:01 [PATCH 1/3] mac80211: better definition of mactime Bruno Randolf
2008-02-15  7:01 ` [PATCH 2/3] mac80211: move function ieee80211_sta_join_ibss() Bruno Randolf
2008-02-15 12:52   ` Johannes Berg
2008-02-15  7:02 ` [PATCH 3/3] mac80211: enable IBSS merging Bruno Randolf
2008-02-15 15:09   ` Johannes Berg
2008-02-16  2:29     ` [PATCH] " Bruno Randolf
2008-02-17  9:11       ` Johannes Berg
2008-02-18  1:42         ` bruno randolf
2008-02-18 11:15           ` Johannes Berg
2008-02-18  2:03         ` bruno randolf
2008-02-18 11:16           ` Johannes Berg
2008-02-15 12:52 ` [PATCH 1/3] mac80211: better definition of mactime Johannes Berg
  -- strict thread matches above, loose matches on Subject: below --
2008-02-08  9:41 [PATCH] mac80211: enable IBSS merging Joerg Pommnitz
2008-02-05 11:08 [PATCH 2/2] " Johannes Berg
2008-02-06  2:49 ` [PATCH] " Bruno Randolf
2008-02-06 23:52   ` Johannes Berg
2008-02-08  9:25     ` Luis R. Rodriguez
2008-02-12  3:25     ` bruno randolf
2008-02-12  9:50       ` Johannes Berg
2008-02-14  6:19         ` bruno randolf
2008-02-14 14:12           ` Johannes Berg
2008-02-12  9:52       ` Johannes Berg
2008-02-14 10:19         ` bruno randolf
2008-01-18 12:52 Bruno Randolf
2008-01-20 10:17 ` Luis R. Rodriguez
2008-01-20 10:43   ` Ivo van Doorn
2008-01-21  1:52     ` bruno randolf
2008-01-21 16:05       ` Ivo van Doorn
2008-01-22 19:47         ` Luis R. Rodriguez
2008-01-22 19:54           ` Ivo van Doorn
2008-01-22 20:32             ` Luis R. Rodriguez
2008-01-22 20:51               ` Ivo van Doorn
2008-01-22 23:16             ` Adam Baker
2008-01-22 23:25               ` Ivo van Doorn
2008-01-23 14:49     ` Johannes Berg
2008-01-24  5:51       ` bruno randolf
2008-01-21  1:57   ` bruno randolf
2008-01-23 14:48 ` Johannes Berg
2008-01-23 17:22   ` Dan Williams
2008-01-24  3:49     ` bruno randolf
2008-01-24  3:26   ` bruno randolf
2008-01-24 16:55     ` Johannes Berg
2008-01-25  8:01       ` bruno randolf
2008-02-02 23:22         ` Luis R. Rodriguez
2008-02-05  1:50           ` bruno randolf
2008-02-05  1:56             ` Luis R. Rodriguez
2008-02-06 10:01             ` Johannes Berg
2008-02-06  4:34           ` Jouni Malinen
2008-02-06 18:33             ` Luis R. Rodriguez
2008-02-06 20:10               ` John W. Linville
2008-02-07  3:58                 ` Jouni Malinen
2008-02-08  9:22                   ` Luis R. Rodriguez
2008-02-12  2:00                     ` bruno randolf
2008-02-15  1:06                       ` Luis R. Rodriguez
2008-02-15  1:40                         ` bruno randolf
2008-02-07  3:52               ` Jouni Malinen
2008-02-08  9:10                 ` Luis R. Rodriguez
2008-01-24  5:43   ` bruno randolf
2008-01-24  8:51     ` Kalle Valo
2008-01-24 14:27       ` Johannes Berg
2008-01-24 14:30     ` Johannes Berg
2008-01-25  6:16       ` bruno randolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).