Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Read supported rates from the card and report the...



details:   https://anonhg.NetBSD.org/src/rev/1acfecdcac7e
branches:  trunk
changeset: 535129:1acfecdcac7e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Aug 11 00:00:41 2002 +0000

description:
Read supported rates from the card and report them.  Only add
media types if that rate is supported.

Adapted from OpenBSD.

diffstat:

 sys/dev/ic/wi.c    |  61 +++++++++++++++++++++++++++++++++++++++--------------
 sys/dev/ic/wireg.h |  15 ++++++++++--
 sys/dev/ic/wivar.h |   3 +-
 3 files changed, 59 insertions(+), 20 deletions(-)

diffs (147 lines):

diff -r adadf2824256 -r 1acfecdcac7e sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c   Sat Aug 10 23:29:53 2002 +0000
+++ b/sys/dev/ic/wi.c   Sun Aug 11 00:00:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wi.c,v 1.74 2002/08/10 23:16:14 thorpej Exp $  */
+/*     $NetBSD: wi.c,v 1.75 2002/08/11 00:00:41 thorpej Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.74 2002/08/10 23:16:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.75 2002/08/11 00:00:41 thorpej Exp $");
 
 #define WI_HERMES_AUTOINC_WAR  /* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR    /* Work around stats counter bug. */
@@ -181,6 +181,7 @@
        struct wi_softc *sc;
 {
        struct ifnet *ifp = sc->sc_ifp;
+       const char *sep = "";
        struct wi_ltv_macaddr   mac;
        struct wi_ltv_gen       gen;
        static const u_int8_t empty_macaddr[ETHER_ADDR_LEN] = {
@@ -282,25 +283,53 @@
        wi_read_record(sc, &gen);
        sc->wi_has_wep = le16toh(gen.wi_val);
 
+       /* Find supported rates. */
+       gen.wi_type = WI_RID_SUPPORT_RATE;
+       gen.wi_len = 2;
+       if (wi_read_record(sc, &gen))
+               sc->wi_supprates = WI_SUPPRATES_1M | WI_SUPPRATES_2M |
+                   WI_SUPPRATES_5M | WI_SUPPRATES_11M;
+       else
+               sc->wi_supprates = le16toh(gen.wi_val);
+
        ifmedia_init(&sc->sc_media, 0, wi_media_change, wi_media_status);
+       if (sc->wi_supprates != 0)
+               printf("%s: supported rates: ", sc->sc_dev.dv_xname);
 #define        ADD(m, c)       ifmedia_add(&sc->sc_media, (m), (c), NULL)
+#define        PRINT(n)        printf("%s%s", sep, (n)); sep = ", "
        ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0);
        ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, IFM_IEEE80211_ADHOC, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1,
-           IFM_IEEE80211_ADHOC, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2,
-           IFM_IEEE80211_ADHOC, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5,
-           IFM_IEEE80211_ADHOC, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
-           IFM_IEEE80211_ADHOC, 0), 0);
-       ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_MANUAL, 0, 0), 0);
+       if (sc->wi_supprates & WI_SUPPRATES_1M) {
+               PRINT("1Mbps");
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0);
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1,
+                   IFM_IEEE80211_ADHOC, 0), 0);
+       }
+       if (sc->wi_supprates & WI_SUPPRATES_2M) {
+               PRINT("2Mbps");
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0);
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2,
+                   IFM_IEEE80211_ADHOC, 0), 0);
+       }
+       if (sc->wi_supprates & WI_SUPPRATES_5M) {
+               PRINT("5.5Mbps");
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0);
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5,
+                   IFM_IEEE80211_ADHOC, 0), 0);
+       }
+       if (sc->wi_supprates & WI_SUPPRATES_11M) {
+               PRINT("11Mbps");
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0);
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11,
+                   IFM_IEEE80211_ADHOC, 0), 0);
+               ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_MANUAL, 0, 0), 0);
+       }
+       if (sc->wi_supprates != 0)
+               printf("\n");
+       ifmedia_set(&sc->sc_media,
+           IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0));
 #undef ADD
-       ifmedia_set(&sc->sc_media, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0));
+#undef PRINT
 
        /*
         * Call MI attach routines.
diff -r adadf2824256 -r 1acfecdcac7e sys/dev/ic/wireg.h
--- a/sys/dev/ic/wireg.h        Sat Aug 10 23:29:53 2002 +0000
+++ b/sys/dev/ic/wireg.h        Sun Aug 11 00:00:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wireg.h,v 1.35 2002/08/10 23:29:53 thorpej Exp $       */
+/*     $NetBSD: wireg.h,v 1.36 2002/08/11 00:00:41 thorpej Exp $       */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -609,6 +609,14 @@
 };
 
 /*
+ * Supported rates.
+ */
+#define        WI_SUPPRATES_1M         0x0001
+#define        WI_SUPPRATES_2M         0x0002
+#define        WI_SUPPRATES_5M         0x0004
+#define        WI_SUPPRATES_11M        0x0008
+
+/*
  * Information frame types.
  */
 #define WI_INFO_NOTIFY         0xF000  /* Handover address */
@@ -688,8 +696,9 @@
        u_int16_t               wi_rsvd0;       /* 0x02 */ /* 0 */
        u_int16_t               wi_rsvd1;       /* 0x04 */ /* 0 */
        u_int16_t               wi_q_info;      /* 0x06 */
-       u_int16_t               wi_txrate;      /* 0x08 */ /* (Prism2 Only) */
-       u_int16_t               wi_retcount;    /* 0x0A */ /* (Prism2 Only) */
+       u_int16_t               wi_rsvd2;       /* 0x08 */
+       u_int8_t                wi_tx_rtry;     /* 0x0A */ /* (Prism2 Only) */
+       u_int8_t                wi_tx_rate;     /* 0x0B */ /* (Prism2 Only) */
        u_int16_t               wi_tx_ctl;      /* 0x0C */
        u_int16_t               wi_frame_ctl;   /* 0x0E */
        u_int16_t               wi_id;          /* 0x10 */
diff -r adadf2824256 -r 1acfecdcac7e sys/dev/ic/wivar.h
--- a/sys/dev/ic/wivar.h        Sat Aug 10 23:29:53 2002 +0000
+++ b/sys/dev/ic/wivar.h        Sun Aug 11 00:00:41 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wivar.h,v 1.14 2002/04/05 00:54:52 ichiro Exp $        */
+/*     $NetBSD: wivar.h,v 1.15 2002/08/11 00:00:42 thorpej Exp $       */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -82,6 +82,7 @@
        u_int16_t               wi_max_sleep;
        u_int16_t               wi_authtype;
        u_int16_t               wi_roaming;
+       u_int16_t               wi_supprates;
 
        struct ieee80211_nwid   wi_nodeid;
        struct ieee80211_nwid   wi_netid;



Home | Main Index | Thread Index | Old Index