From 4087336d982c1de30b06c9f4b845ce3e42607b78 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 6 Feb 2007 13:50:25 +0000 Subject: [PATCH] Use relative RX signal strength (relative to noise floor) as RSSI. RSSI correction value is obtained from Linux RT25USB driver. --- sys/dev/netif/ural/if_ural.c | 14 +++++++++----- sys/dev/netif/ural/if_uralreg.h | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/dev/netif/ural/if_ural.c b/sys/dev/netif/ural/if_ural.c index e4668f109a..148b4b5e1b 100644 --- a/sys/dev/netif/ural/if_ural.c +++ b/sys/dev/netif/ural/if_ural.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/usb/if_ural.c,v 1.10.2.8 2006/07/08 07:48:43 maxim Exp $ */ -/* $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.4 2006/12/24 06:18:22 sephe Exp $ */ +/* $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.5 2007/02/06 14:50:25 sephe Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -51,8 +51,8 @@ #include #include -#include "if_uralreg.h" -#include "if_uralvar.h" +#include +#include #ifdef USB_DEBUG #define DPRINTF(x) do { if (uraldebug > 0) logprintf x; } while (0) @@ -66,6 +66,10 @@ SYSCTL_INT(_hw_usb_ural, OID_AUTO, debug, CTLFLAG_RW, &uraldebug, 0, #define DPRINTFN(n, x) #endif +#define URAL_RSSI(rssi) \ + ((rssi) > (RAL_NOISE_FLOOR + RAL_RSSI_CORR) ? \ + ((rssi) - RAL_NOISE_FLOOR + RAL_RSSI_CORR) : 0) + /* various supported device vendors/products */ static const struct usb_devno ural_devs[] = { { USB_VENDOR_ASUS, USB_PRODUCT_ASUS_WL167G }, @@ -998,7 +1002,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); tap->wr_antenna = sc->rx_ant; - tap->wr_antsignal = desc->rssi; + tap->wr_antsignal = URAL_RSSI(desc->rssi); bpf_ptap(sc->sc_drvbpf, m, tap, sc->sc_rxtap_len); } @@ -1010,7 +1014,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); /* send the frame to the 802.11 layer */ - ieee80211_input(ic, m, ni, desc->rssi, 0); + ieee80211_input(ic, m, ni, URAL_RSSI(desc->rssi), 0); /* node is no longer needed */ ieee80211_free_node(ni); diff --git a/sys/dev/netif/ural/if_uralreg.h b/sys/dev/netif/ural/if_uralreg.h index d229974f07..a73d321492 100644 --- a/sys/dev/netif/ural/if_uralreg.h +++ b/sys/dev/netif/ural/if_uralreg.h @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/usb/if_uralreg.h,v 1.1.2.1 2006/01/29 14:16:36 damien Exp $ */ -/* $DragonFly: src/sys/dev/netif/ural/if_uralreg.h,v 1.1 2006/12/10 03:53:34 sephe Exp $ */ +/* $DragonFly: src/sys/dev/netif/ural/if_uralreg.h,v 1.2 2007/02/06 14:50:25 sephe Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -18,6 +18,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define RAL_NOISE_FLOOR -95 +#define RAL_RSSI_CORR 120 + #define RAL_RX_DESC_SIZE (sizeof (struct ural_rx_desc)) #define RAL_TX_DESC_SIZE (sizeof (struct ural_tx_desc)) -- 2.11.4.GIT