Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Use a table to convert the hardware's bit rates (...



details:   https://anonhg.NetBSD.org/src/rev/a8982e9333cb
branches:  trunk
changeset: 572259:a8982e9333cb
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Mon Dec 27 20:04:45 2004 +0000

description:
Use a table to convert the hardware's bit rates (0, 1, 2, 3) to
net80211 bit rates (2, 4, 11, 22).

Count input errors (if_ierrors++) for "DMA error/FIFO overflow"
and unknown bit rate.

diffstat:

 sys/dev/ic/rtw.c |  28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diffs (68 lines):

diff -r 6780eaabbb35 -r a8982e9333cb sys/dev/ic/rtw.c
--- a/sys/dev/ic/rtw.c  Mon Dec 27 19:49:16 2004 +0000
+++ b/sys/dev/ic/rtw.c  Mon Dec 27 20:04:45 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */
+/* $NetBSD: rtw.c,v 1.30 2004/12/27 20:04:45 dyoung Exp $ */
 /*-
  * Copyright (c) 2004, 2005 David Young.  All rights reserved.
  *
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.30 2004/12/27 20:04:45 dyoung Exp $");
 
 #include "bpfilter.h"
 
@@ -1228,8 +1228,11 @@
 static void
 rtw_intr_rx(struct rtw_softc *sc, u_int16_t isr)
 {
+       static const int ratetbl[4] = {2, 4, 11, 22};   /* convert rates:
+                                                        * hardware -> net80211
+                                                        */
        u_int next, nproc = 0;
-       int len, rate, rssi;
+       int hwrate, len, rate, rssi;
        u_int32_t hrssi, hstat, htsfth, htsftl;
        struct rtw_rxdesc *hrx;
        struct rtw_rxctl *srx;
@@ -1282,6 +1285,7 @@
                        printf("%s: DMA error/FIFO overflow %08x, "
                            "rx descriptor %d\n", sc->sc_dev.dv_xname,
                            hstat & RTW_RXSTAT_IOERROR, next);
+                       sc->sc_if.if_ierrors++;
                        goto next;
                }
 
@@ -1291,24 +1295,14 @@
                        goto next;
                }
 
-               switch (hstat & RTW_RXSTAT_RATE_MASK) {
-               case RTW_RXSTAT_RATE_1MBPS:
-                       rate = 2;
-                       break;
-               case RTW_RXSTAT_RATE_2MBPS:
-                       rate = 4;
-                       break;
-               case RTW_RXSTAT_RATE_5MBPS:
-                       rate = 11;
-                       break;
-               case RTW_RXSTAT_RATE_11MBPS:
-                       rate = 22;
-                       break;
-               default:
+               hwrate = MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK);
+               if (hwrate >= sizeof(ratetbl) / sizeof(ratetbl[0])) {
                        printf("%s: unknown rate #%d\n", sc->sc_dev.dv_xname,
                            MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK));
+                       sc->sc_if.if_ierrors++;
                        goto next;
                }
+               rate = ratetbl[hwrate];
 
 #ifdef RTW_DEBUG
 #define PRINTSTAT(flag) do { \



Home | Main Index | Thread Index | Old Index