diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2006-01-14 12:40:40 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2006-01-14 12:40:40 +0000 |
commit | cbcea85fb72e29c931b2d3492cf13cb777e5a8ed (patch) | |
tree | 577ff5a924b74354e139af3d4eff9b7712e875e0 /sys | |
parent | e16b2d8bff470be957d02471a8a2bc856d817a08 (diff) |
- give rate to rx radiotap
- swap rssi/rate fields in ural_rx_desc
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_ral.c | 42 | ||||
-rw-r--r-- | sys/dev/usb/if_ralreg.h | 3 | ||||
-rw-r--r-- | sys/dev/usb/if_ralvar.h | 4 |
3 files changed, 45 insertions, 4 deletions
diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 87e468f383e..99d74634551 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.59 2006/01/14 08:50:38 jsg Exp $ */ +/* $OpenBSD: if_ral.c,v 1.60 2006/01/14 12:40:39 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -121,6 +121,9 @@ Static void ural_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status); Static void ural_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status); +#if NBPFILTER > 0 +Static uint8_t ural_rxrate(struct ural_rx_desc *); +#endif Static int ural_ack_rate(struct ieee80211com *, int); Static uint16_t ural_txtime(int, int, uint32_t); Static uint8_t ural_plcp_signal(int); @@ -938,7 +941,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) /* finalize mbuf */ m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = (letoh32(desc->flags) >> 16) & 0xfff; - m->m_flags |= M_HASFCS; /* hardware appends FCS */ + m->m_flags |= M_HASFCS; /* h/w leaves FCS */ s = splnet(); @@ -948,6 +951,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ural_rx_radiotap_header *tap = &sc->sc_rxtap; tap->wr_flags = 0; + tap->wr_rate = ural_rxrate(desc); tap->wr_chan_freq = htole16(ic->ic_ibss_chan->ic_freq); tap->wr_chan_flags = htole16(ic->ic_ibss_chan->ic_flags); tap->wr_antenna = sc->rx_ant; @@ -989,6 +993,40 @@ skip: /* setup a new transfer */ } /* + * This function is only used by the Rx radiotap code. It returns the rate at + * which a given frame was received. + */ +#if NBPFILTER > 0 +Static uint8_t +ural_rxrate(struct ural_rx_desc *desc) +{ + if (letoh32(desc->flags) & RAL_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/usb/if_ralreg.h b/sys/dev/usb/if_ralreg.h index 245003740ab..871c1e5acb0 100644 --- a/sys/dev/usb/if_ralreg.h +++ b/sys/dev/usb/if_ralreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ralreg.h,v 1.7 2006/01/13 21:00:55 damien Exp $ */ +/* $OpenBSD: if_ralreg.h,v 1.8 2006/01/14 12:40:39 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -180,6 +180,7 @@ struct ural_tx_desc { struct ural_rx_desc { uint32_t flags; #define RAL_RX_CRC_ERROR (1 << 5) +#define RAL_RX_OFDM (1 << 6) #define RAL_RX_PHY_ERROR (1 << 7) uint8_t rate; diff --git a/sys/dev/usb/if_ralvar.h b/sys/dev/usb/if_ralvar.h index 6c9eb9eefd6..b3f5ba8b0de 100644 --- a/sys/dev/usb/if_ralvar.h +++ b/sys/dev/usb/if_ralvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ralvar.h,v 1.3 2005/11/23 20:23:48 damien Exp $ */ +/* $OpenBSD: if_ralvar.h,v 1.4 2006/01/14 12:40:39 damien Exp $ */ /*- * Copyright (c) 2005 @@ -23,6 +23,7 @@ struct ural_rx_radiotap_header { struct ieee80211_radiotap_header wr_ihdr; uint8_t wr_flags; + uint8_t wr_rate; uint16_t wr_chan_freq; uint16_t wr_chan_flags; uint8_t wr_antenna; @@ -31,6 +32,7 @@ struct ural_rx_radiotap_header { #define RAL_RX_RADIOTAP_PRESENT \ ((1 << IEEE80211_RADIOTAP_FLAGS) | \ + (1 << IEEE80211_RADIOTAP_RATE) | \ (1 << IEEE80211_RADIOTAP_CHANNEL) | \ (1 << IEEE80211_RADIOTAP_ANTENNA) | \ (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)) |