summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2006-01-14 12:43:28 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2006-01-14 12:43:28 +0000
commit6853f9a1e6456e59edad87964e51b253a552b6bb (patch)
treec436f01276310aac1a3a44df34d63dfbbfd8eed0 /sys/dev/ic
parentcbcea85fb72e29c931b2d3492cf13cb777e5a8ed (diff)
- give rate to rx radiotap
- read TSF high 32bit word before low 32bit word to avoid wraparounds
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/rt2560.c44
-rw-r--r--sys/dev/ic/rt2560reg.h3
-rw-r--r--sys/dev/ic/rt2560var.h4
-rw-r--r--sys/dev/ic/rt2661.c44
-rw-r--r--sys/dev/ic/rt2661reg.h4
-rw-r--r--sys/dev/ic/rt2661var.h4
6 files changed, 92 insertions, 11 deletions
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c
index fa3a618e66d..f829af55070 100644
--- a/sys/dev/ic/rt2560.c
+++ b/sys/dev/ic/rt2560.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560.c,v 1.9 2006/01/14 08:50:38 jsg Exp $ */
+/* $OpenBSD: rt2560.c,v 1.10 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -104,6 +104,9 @@ void rt2560_decryption_intr(struct rt2560_softc *);
void rt2560_rx_intr(struct rt2560_softc *);
void rt2560_beacon_expire(struct rt2560_softc *);
void rt2560_wakeup_expire(struct rt2560_softc *);
+#if NBPFILTER > 0
+uint8_t rt2560_rxrate(struct rt2560_rx_desc *);
+#endif
int rt2560_ack_rate(struct ieee80211com *, int);
uint16_t rt2560_txtime(int, int, uint32_t);
uint8_t rt2560_plcp_signal(int);
@@ -1330,12 +1333,13 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
uint32_t tsf_lo, tsf_hi;
/* get timestamp (low and high 32 bits) */
- tsf_lo = RAL_READ(sc, RT2560_CSR16);
tsf_hi = RAL_READ(sc, RT2560_CSR17);
+ tsf_lo = RAL_READ(sc, RT2560_CSR16);
tap->wr_tsf =
htole64(((uint64_t)tsf_hi << 32) | tsf_lo);
tap->wr_flags = 0;
+ tap->wr_rate = rt2560_rxrate(desc);
tap->wr_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
tap->wr_chan_flags =
htole16(ic->ic_ibss_chan->ic_flags);
@@ -1344,7 +1348,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
M_DUP_PKTHDR(&mb, m);
mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
+ mb.m_len = sc->sc_txtap_len;
mb.m_next = m;
mb.m_pkthdr.len += mb.m_len;
bpf_mtap(sc->sc_drvbpf, &mb);
@@ -1520,6 +1524,40 @@ rt2560_intr(void *arg)
#define RT2560_RXTX_TURNAROUND 10 /* us */
/*
+ * This function is only used by the Rx radiotap code. It returns the rate at
+ * which a given frame was received.
+ */
+#if NBPFILTER > 0
+uint8_t
+rt2560_rxrate(struct rt2560_rx_desc *desc)
+{
+ if (letoh32(desc->flags) & RT2560_RX_OFDM) {
+ /* reverse function of rt2560_plcp_signal */
+ switch (desc->rate) {
+ case 0xb: return 12;
+ case 0xf: return 18;
+ case 0xa: return 24;
+ case 0xe: return 36;
+ case 0x9: return 48;
+ case 0xd: return 72;
+ case 0x8: return 96;
+ case 0xc: return 108;
+ }
+ } else {
+ if (desc->rate == 10)
+ return 2;
+ if (desc->rate == 20)
+ return 4;
+ if (desc->rate == 55)
+ return 11;
+ if (desc->rate == 110)
+ return 22;
+ }
+ return 2; /* should not get there */
+}
+#endif
+
+/*
* Return the expected ack rate for a frame transmitted at rate `rate'.
* XXX: this should depend on the destination node basic rate set.
*/
diff --git a/sys/dev/ic/rt2560reg.h b/sys/dev/ic/rt2560reg.h
index d104f14f96d..d0f6909d18b 100644
--- a/sys/dev/ic/rt2560reg.h
+++ b/sys/dev/ic/rt2560reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560reg.h,v 1.2 2006/01/10 17:40:29 damien Exp $ */
+/* $OpenBSD: rt2560reg.h,v 1.3 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -230,6 +230,7 @@ struct rt2560_rx_desc {
uint32_t flags;
#define RT2560_RX_BUSY (1 << 0)
#define RT2560_RX_CRC_ERROR (1 << 5)
+#define RT2560_RX_OFDM (1 << 6)
#define RT2560_RX_PHY_ERROR (1 << 7)
#define RT2560_RX_CIPHER_BUSY (1 << 8)
#define RT2560_RX_ICV_ERROR (1 << 9)
diff --git a/sys/dev/ic/rt2560var.h b/sys/dev/ic/rt2560var.h
index 0f117f608bd..a8fe71f8840 100644
--- a/sys/dev/ic/rt2560var.h
+++ b/sys/dev/ic/rt2560var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560var.h,v 1.1 2006/01/09 20:03:34 damien Exp $ */
+/* $OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -21,6 +21,7 @@ struct rt2560_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsf;
uint8_t wr_flags;
+ uint8_t wr_rate;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
uint8_t wr_antenna;
@@ -30,6 +31,7 @@ struct rt2560_rx_radiotap_header {
#define RT2560_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_ANTENNA) | \
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index 6db0f3e608d..415b62f1ff1 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661.c,v 1.7 2006/01/14 08:50:38 jsg Exp $ */
+/* $OpenBSD: rt2661.c,v 1.8 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2006
@@ -105,6 +105,9 @@ void rt2661_mcu_beacon_expire(struct rt2661_softc *);
void rt2661_mcu_wakeup(struct rt2661_softc *);
void rt2661_mcu_cmd_intr(struct rt2661_softc *);
int rt2661_intr(void *);
+#if NBPFILTER > 0
+uint8_t rt2661_rxrate(struct rt2661_rx_desc *);
+#endif
int rt2661_ack_rate(struct ieee80211com *, int);
uint16_t rt2661_txtime(int, int, uint32_t);
uint8_t rt2661_plcp_signal(int);
@@ -1227,12 +1230,13 @@ rt2661_rx_intr(struct rt2661_softc *sc)
uint32_t tsf_lo, tsf_hi;
/* get timestamp (low and high 32 bits) */
- tsf_lo = RAL_READ(sc, RT2661_TXRX_CSR12);
tsf_hi = RAL_READ(sc, RT2661_TXRX_CSR13);
+ tsf_lo = RAL_READ(sc, RT2661_TXRX_CSR12);
tap->wr_tsf =
htole64(((uint64_t)tsf_hi << 32) | tsf_lo);
tap->wr_flags = 0;
+ tap->wr_rate = rt2661_rxrate(desc);
tap->wr_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
tap->wr_chan_flags =
htole16(ic->ic_ibss_chan->ic_flags);
@@ -1240,7 +1244,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
M_DUP_PKTHDR(&mb, m);
mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
+ mb.m_len = sc->sc_txtap_len;
mb.m_next = m;
mb.m_pkthdr.len += mb.m_len;
bpf_mtap(sc->sc_drvbpf, &mb);
@@ -1369,6 +1373,40 @@ rt2661_intr(void *arg)
#define RAL_SIFS 10 /* us */
/*
+ * This function is only used by the Rx radiotap code. It returns the rate at
+ * which a given frame was received.
+ */
+#if NBPFILTER > 0
+uint8_t
+rt2661_rxrate(struct rt2661_rx_desc *desc)
+{
+ if (letoh32(desc->flags) & RT2661_RX_OFDM) {
+ /* reverse function of rt2661_plcp_signal */
+ switch (desc->rate & 0xf) {
+ case 0xb: return 12;
+ case 0xf: return 18;
+ case 0xa: return 24;
+ case 0xe: return 36;
+ case 0x9: return 48;
+ case 0xd: return 72;
+ case 0x8: return 96;
+ case 0xc: return 108;
+ }
+ } else {
+ if (desc->rate == 10)
+ return 2;
+ if (desc->rate == 20)
+ return 4;
+ if (desc->rate == 55)
+ return 11;
+ if (desc->rate == 110)
+ return 22;
+ }
+ return 2; /* should not get there */
+}
+#endif
+
+/*
* Return the expected ack rate for a frame transmitted at rate `rate'.
* XXX: this should depend on the destination node basic rate set.
*/
diff --git a/sys/dev/ic/rt2661reg.h b/sys/dev/ic/rt2661reg.h
index 659a8fb48f7..9584cb0ec0b 100644
--- a/sys/dev/ic/rt2661reg.h
+++ b/sys/dev/ic/rt2661reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661reg.h,v 1.4 2006/01/11 21:44:17 damien Exp $ */
+/* $OpenBSD: rt2661reg.h,v 1.5 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2006
@@ -266,7 +266,7 @@ struct rt2661_rx_desc {
#define RT2661_RX_PHY_ERROR (1 << 8)
#define RT2661_RX_CIPHER_MASK 0x00000600
- uint8_t signal;
+ uint8_t rate;
uint8_t rssi;
uint8_t reserved1;
uint8_t offset;
diff --git a/sys/dev/ic/rt2661var.h b/sys/dev/ic/rt2661var.h
index 0f911753810..e7bae7400de 100644
--- a/sys/dev/ic/rt2661var.h
+++ b/sys/dev/ic/rt2661var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661var.h,v 1.2 2006/01/10 21:20:46 damien Exp $ */
+/* $OpenBSD: rt2661var.h,v 1.3 2006/01/14 12:43:27 damien Exp $ */
/*-
* Copyright (c) 2006
@@ -21,6 +21,7 @@ struct rt2661_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsf;
uint8_t wr_flags;
+ uint8_t wr_rate;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
uint8_t wr_antsignal;
@@ -29,6 +30,7 @@ struct rt2661_rx_radiotap_header {
#define RT2661_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))