rsu: add TSF field into Rx radiotap.

Tested with Asus USB-N10.
This commit is contained in:
Andriy Voskoboinyk 2016-12-10 13:30:16 +00:00
parent 58551dc674
commit 88e8709ef1
2 changed files with 27 additions and 2 deletions

View File

@ -234,6 +234,8 @@ static void rsu_rx_multi_event(struct rsu_softc *, uint8_t *, int);
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 @@ rsu_rx_copy_to_mbuf(struct rsu_softc *sc, struct r92s_rx_stat *stat,
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, struct mbuf *m, int8_t *rssi_p)
/* 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. */

View File

@ -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)