svn commit: r309806 - head/sys/dev/usb/wlan

Andriy Voskoboinyk avos at FreeBSD.org
Sat Dec 10 13:30:17 UTC 2016


Author: avos
Date: Sat Dec 10 13:30:16 2016
New Revision: 309806
URL: https://svnweb.freebsd.org/changeset/base/309806

Log:
  rsu: add TSF field into Rx radiotap.
  
  Tested with Asus USB-N10.

Modified:
  head/sys/dev/usb/wlan/if_rsu.c
  head/sys/dev/usb/wlan/if_rsureg.h

Modified: head/sys/dev/usb/wlan/if_rsu.c
==============================================================================
--- head/sys/dev/usb/wlan/if_rsu.c	Sat Dec 10 13:29:51 2016	(r309805)
+++ head/sys/dev/usb/wlan/if_rsu.c	Sat Dec 10 13:30:16 2016	(r309806)
@@ -234,6 +234,8 @@ static void	rsu_rx_multi_event(struct rs
 static int8_t	rsu_get_rssi(struct rsu_softc *, int, void *);
 static struct mbuf * rsu_rx_copy_to_mbuf(struct rsu_softc *,
 		    struct r92s_rx_stat *, int);
+static uint32_t	rsu_get_tsf_low(struct rsu_softc *);
+static uint32_t	rsu_get_tsf_high(struct rsu_softc *);
 static struct ieee80211_node * rsu_rx_frame(struct rsu_softc *, struct mbuf *,
 		    int8_t *);
 static struct mbuf * rsu_rx_multi_frame(struct rsu_softc *, uint8_t *, int);
@@ -2223,6 +2225,18 @@ fail:
 	return (NULL);
 }
 
+static uint32_t
+rsu_get_tsf_low(struct rsu_softc *sc)
+{
+	return (rsu_read_4(sc, R92S_TSFTR));
+}
+
+static uint32_t
+rsu_get_tsf_high(struct rsu_softc *sc)
+{
+	return (rsu_read_4(sc, R92S_TSFTR + 4));
+}
+
 static struct ieee80211_node *
 rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m, int8_t *rssi_p)
 {
@@ -2254,6 +2268,12 @@ rsu_rx_frame(struct rsu_softc *sc, struc
 
 		/* Map HW rate index to 802.11 rate. */
 		tap->wr_flags = 0;		/* TODO */
+		tap->wr_tsft = rsu_get_tsf_high(sc);
+		if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc))
+			tap->wr_tsft--;
+		tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32;
+		tap->wr_tsft += stat->tsf_low;
+
 		if (rate < 12) {
 			switch (rate) {
 			/* CCK. */

Modified: head/sys/dev/usb/wlan/if_rsureg.h
==============================================================================
--- head/sys/dev/usb/wlan/if_rsureg.h	Sat Dec 10 13:29:51 2016	(r309805)
+++ head/sys/dev/usb/wlan/if_rsureg.h	Sat Dec 10 13:30:16 2016	(r309806)
@@ -51,6 +51,9 @@
 #define R92S_MACID		(R92S_MACIDSETTING + 0x000)
 #define R92S_MAR		(R92S_MACIDSETTING + 0x010)
 
+#define R92S_TIMECTRL		0x0080
+#define R92S_TSFTR		(R92S_TIMECTRL + 0x000)
+
 #define R92S_SECURITY		0x0240
 #define R92S_CAMCMD		(R92S_SECURITY + 0x000)
 #define R92S_CAMWRITE		(R92S_SECURITY + 0x004)
@@ -592,7 +595,7 @@ struct r92s_rx_stat {
 #define R92S_RXDW3_HTC		0x00004000
 
 	uint32_t	rxdw4;
-	uint32_t	rxdw5;
+	uint32_t	tsf_low;
 } __packed __aligned(4);
 
 /* Rx PHY descriptor. */
@@ -735,6 +738,7 @@ static const uint8_t rsu_qid2idx_11ep[] 
 
 struct rsu_rx_radiotap_header {
 	struct ieee80211_radiotap_header wr_ihdr;
+	uint64_t	wr_tsft;
 	uint8_t		wr_flags;
 	uint8_t		wr_rate;
 	uint16_t	wr_chan_freq;
@@ -743,7 +747,8 @@ struct rsu_rx_radiotap_header {
 } __packed __aligned(8);
 
 #define RSU_RX_RADIOTAP_PRESENT			\
-	(1 << IEEE80211_RADIOTAP_FLAGS |	\
+	(1 << IEEE80211_RADIOTAP_TSFT |		\
+	 1 << IEEE80211_RADIOTAP_FLAGS |	\
 	 1 << IEEE80211_RADIOTAP_RATE |		\
 	 1 << IEEE80211_RADIOTAP_CHANNEL |	\
 	 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)


More information about the svn-src-all mailing list