Read supported rates from the card and report them. Only add
media types if that rate is supported. Adapted from OpenBSD.
This commit is contained in:
parent
dbae3bd18f
commit
375eb183ff
|
@ -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 @@ wi_attach(sc)
|
|||
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_attach(sc)
|
|||
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.
|
||||
|
|
|
@ -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
|
||||
|
@ -608,6 +608,14 @@ struct wi_ltv_mcast {
|
|||
struct ether_addr wi_mcast[16];
|
||||
};
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -688,8 +696,9 @@ struct wi_frame {
|
|||
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 */
|
||||
|
|
|
@ -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 @@ struct wi_softc {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue