[email protected]
[Top] [All Lists]

PERFORCE change 115110 for review

Subject: PERFORCE change 115110 for review
From: Sepherosa Ziehau
Date: Tue, 27 Feb 2007 10:41:32 GMT
http://perforce.freebsd.org/chv.cgi?CH=115110

Change 115110 by [email protected]_zealot:sam_wifi on 2007/02/27 10:41:29

        Convert RSSI to receive signal strength for rt2661 part.
        
        Reviewed by:    [email protected]
        Approved by:    [email protected]

Affected files ...

.. //depot/projects/wifi/sys/dev/ral/rt2661.c#8 edit
.. //depot/projects/wifi/sys/dev/ral/rt2661reg.h#2 edit

Differences ...

==== //depot/projects/wifi/sys/dev/ral/rt2661.c#8 (text) ====

@@ -1008,6 +1008,8 @@
            BUS_DMASYNC_POSTREAD);
 
        for (;;) {
+               int rssi;
+
                desc = &sc->rxq.desc[sc->rxq.cur];
                data = &sc->rxq.data[sc->rxq.cur];
 
@@ -1080,6 +1082,8 @@
                m->m_pkthdr.len = m->m_len =
                    (le32toh(desc->flags) >> 16) & 0xfff;
 
+               rssi = rt2661_get_rssi(sc, desc->rssi);
+
                if (bpf_peers_present(sc->sc_drvbpf)) {
                        struct rt2661_rx_radiotap_header *tap = &sc->sc_rxtap;
                        uint32_t tsf_lo, tsf_hi;
@@ -1094,7 +1098,7 @@
                        tap->wr_rate = rt2661_rxrate(desc);
                        tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
                        tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
-                       tap->wr_antsignal = desc->rssi;
+                       tap->wr_antsignal = rssi < 0 ? 0 : rssi;
 
                        bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m);
                }
@@ -1104,15 +1108,18 @@
                ni = ieee80211_find_rxnode(ic,
                    (struct ieee80211_frame_min *)wh);
 
+               /* Error happened during RSSI conversion. */
+               if (rssi < 0)
+                       rssi = ni->ni_rssi;
+
                /* send the frame to the 802.11 layer */
-               ieee80211_input(ic, m, ni, desc->rssi, 0, 0);
+               ieee80211_input(ic, m, ni, rssi, RT2661_NOISE_FLOOR, 0);
 
                /* give rssi to the rate adatation algorithm */
                rn = (struct rt2661_node *)ni;
                RAL_LOCK(sc);
                sc->sc_flags &= ~RAL_INPUT_RUNNING;
-               ral_rssadapt_input(ic, ni, &rn->rssadapt,
-                   rt2661_get_rssi(sc, desc->rssi));
+               ral_rssadapt_input(ic, ni, &rn->rssadapt, rssi);
 
                /* node is no longer needed */
                ieee80211_free_node(ni);
@@ -2334,10 +2341,18 @@
        if ((val & 0xff) != 0xff)
                sc->rssi_2ghz_corr = (int8_t)(val & 0xff);      /* signed */
 
+       /* Only [-10, 10] is valid */
+       if (sc->rssi_2ghz_corr < -10 || sc->rssi_2ghz_corr > 10)
+               sc->rssi_2ghz_corr = 0;
+
        val = rt2661_eeprom_read(sc, RT2661_EEPROM_RSSI_5GHZ_OFFSET);
        if ((val & 0xff) != 0xff)
                sc->rssi_5ghz_corr = (int8_t)(val & 0xff);      /* signed */
 
+       /* Only [-10, 10] is valid */
+       if (sc->rssi_5ghz_corr < -10 || sc->rssi_5ghz_corr > 10)
+               sc->rssi_5ghz_corr = 0;
+
        /* adjust RSSI correction for external low-noise amplifier */
        if (sc->ext_2ghz_lna)
                sc->rssi_2ghz_corr -= 14;
@@ -2836,7 +2851,17 @@
        lna = (raw >> 5) & 0x3;
        agc = raw & 0x1f;
 
-       rssi = 2 * agc;
+       if (lna == 0) {
+               /*
+                * No mapping available.
+                *
+                * NB: Since RSSI is relative to noise floor, -1 is
+                *     adequate for caller to know error happened.
+                */
+               return -1;
+       }
+
+       rssi = (2 * agc) - RT2661_NOISE_FLOOR;
 
        if (IEEE80211_IS_CHAN_2GHZ(sc->sc_curchan)) {
                rssi += sc->rssi_2ghz_corr;

==== //depot/projects/wifi/sys/dev/ral/rt2661reg.h#2 (text) ====

@@ -17,6 +17,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#define RT2661_NOISE_FLOOR     -95
+
 #define RT2661_TX_RING_COUNT   32
 #define RT2661_MGT_RING_COUNT  32
 #define RT2661_RX_RING_COUNT   64
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 115110 for review, Sepherosa Ziehau <=