Skip to contentSkip to conversation

b43: include full 64-bit timestamp in monitor mode

PATCH New Michael Buesch 1 participant 1 message Nov 23, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b43: include full 64-bit timestamp in monitor mode

From: Johannes Berg <[email protected]>

When monitor mode is enabled, this will make b43 read out the full 64-bit MAC time from the chip for each received packet.

---
 drivers/net/wireless/b43/b43.h  |    2 ++
 drivers/net/wireless/b43/main.c |    2 ++
 drivers/net/wireless/b43/xmit.c |   18 +++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/wireless/b43/b43.h +2 -0
@@ -635,6 +635,8 @@ struct b43_wl {
 	/* List of all wireless devices on this chip */
 	struct list_head devlist;
 	u8 nr_devs;
+
+	bool radiotap_enabled;
 };
 
 /* Pointers to the firmware data and meta information about it. */
drivers/net/wireless/b43/main.c +2 -0
@@ -2853,6 +2853,8 @@ static int b43_op_config(struct ieee8021
 			b43_short_slot_timing_disable(dev);
 	}
 
+	dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_RADIOTAP);
+
 	/* Adjust the desired TX power level. */
 	if (conf->power_level != 0) {
 		if (conf->power_level != phy->power_level) {
drivers/net/wireless/b43/xmit.c +17 -1
@@ -526,7 +526,23 @@ void b43_rx(struct b43_wldev *dev, struc
 	else
 		status.rate = b43_plcp_get_bitrate_cck(plcp);
 	status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT);
-	status.mactime = mactime;
+
+	/*
+	 * If monitors are present get full 64-bit timestamp. This
+	 * code assumes we get to process the packet within 16 bits
+	 * of timestamp, i.e. about 65 milliseconds after the PHY
+	 * received the first symbol.
+	 */
+	if (dev->wl->radiotap_enabled) {
+		u16 low_mactime_now;
+
+		b43_tsf_read(dev, &status.mactime);
+		low_mactime_now = status.mactime;
+		status.mactime = status.mactime & ~0xFFFFULL;
+		status.mactime += mactime;
+		if (low_mactime_now <= mactime)
+			status.mactime -= 0x10000;
+	}
 
 	chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT;
 	switch (chanstat & B43_RX_CHAN_PHYTYPE) {

-------------------------------------------------------

Signature · 1 line
Greetings Michael.