Still more consolidation of 802.11 media-handling, moving moving
common code from awi and wi into the 802.11 framework. Inspired by Sam Leffler's patches to FreeBSD.
This commit is contained in:
parent
096118cb48
commit
6e3daf0a07
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: awi.c,v 1.52 2003/02/25 01:57:35 dyoung Exp $ */
|
||||
/* $NetBSD: awi.c,v 1.53 2003/07/06 20:01:17 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
|
||||
@ -85,7 +85,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.52 2003/02/25 01:57:35 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.53 2003/07/06 20:01:17 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "bpfilter.h"
|
||||
@ -250,48 +250,40 @@ awi_attach(struct awi_softc *sc)
|
||||
memcpy(ic->ic_sup_rates, sc->sc_mib_phy.aSuprt_Data_Rates + 2, nrate);
|
||||
IEEE80211_ADDR_COPY(ic->ic_myaddr, sc->sc_mib_addr.aMAC_Address);
|
||||
|
||||
printf("%s: IEEE802.11 %s %dMbps (firmware %s)\n",
|
||||
sc->sc_dev.dv_xname,
|
||||
sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH ? "FH" : "DS",
|
||||
(ic->ic_sup_rates[nrate - 1] & IEEE80211_RATE_VAL) / 2,
|
||||
sc->sc_banner);
|
||||
printf("%s: IEEE802.11 %s (firmware %s)\n", sc->sc_dev.dv_xname,
|
||||
(ic->ic_phytype == IEEE80211_T_FH) ? "FH" : "DS", sc->sc_banner);
|
||||
printf("%s: 802.11 address: %s\n", sc->sc_dev.dv_xname,
|
||||
ether_sprintf(ic->ic_myaddr));
|
||||
|
||||
if_attach(ifp);
|
||||
ieee80211_ifattach(ifp);
|
||||
|
||||
/* probe request is handled by hardware */
|
||||
ic->ic_send_mgmt[IEEE80211_FC0_SUBTYPE_PROBE_REQ
|
||||
>> IEEE80211_FC0_SUBTYPE_SHIFT] = NULL;
|
||||
ic->ic_recv_mgmt[IEEE80211_FC0_SUBTYPE_PROBE_REQ
|
||||
>> IEEE80211_FC0_SUBTYPE_SHIFT] = NULL;
|
||||
|
||||
ifmedia_init(&sc->sc_media, 0, awi_media_change, awi_media_status);
|
||||
#define ADD(s, o) ifmedia_add(&sc->sc_media, \
|
||||
if_attach(ifp);
|
||||
ieee80211_ifattach(ifp);
|
||||
|
||||
/* Melco compatibility mode. */
|
||||
#define ADD(s, o) ifmedia_add(&ic->ic_media, \
|
||||
IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL)
|
||||
ADD(IFM_AUTO, 0); /* infra mode */
|
||||
ADD(IFM_AUTO, IFM_FLAG0); /* melco compat mode */
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC); /* IBSS mode */
|
||||
if (sc->sc_mib_phy.IEEE_PHY_Type != AWI_PHY_TYPE_FH)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
/* lucent compat mode */
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_HOSTAP);
|
||||
ADD(IFM_AUTO, IFM_FLAG0);
|
||||
|
||||
for (i = 0; i < nrate; i++) {
|
||||
mword = ieee80211_rate2media(ic->ic_sup_rates[i],
|
||||
ic->ic_phytype);
|
||||
if (mword == 0)
|
||||
continue;
|
||||
ADD(mword, 0);
|
||||
ADD(mword, IFM_FLAG0);
|
||||
ADD(mword, IFM_IEEE80211_ADHOC);
|
||||
if (sc->sc_mib_phy.IEEE_PHY_Type != AWI_PHY_TYPE_FH)
|
||||
ADD(mword, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
ADD(mword, IFM_IEEE80211_HOSTAP);
|
||||
}
|
||||
#undef ADD
|
||||
|
||||
/* override defaults */
|
||||
ic->ic_media.ifm_status = awi_media_status;
|
||||
ic->ic_media.ifm_change = awi_media_change;
|
||||
|
||||
awi_media_status(ifp, &imr);
|
||||
ifmedia_set(&sc->sc_media, imr.ifm_active);
|
||||
ifmedia_set(&ic->ic_media, imr.ifm_active);
|
||||
|
||||
if ((sc->sc_sdhook = shutdownhook_establish(awi_shutdown, sc)) == NULL)
|
||||
printf("%s: WARNING: unable to establish shutdown hook\n",
|
||||
@ -324,7 +316,6 @@ awi_detach(struct awi_softc *sc)
|
||||
wakeup(sc);
|
||||
(void)tsleep(sc, PWAIT, "awidet", 1);
|
||||
}
|
||||
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
|
||||
ieee80211_ifdetach(ifp);
|
||||
if_detach(ifp);
|
||||
shutdownhook_disestablish(sc->sc_sdhook);
|
||||
@ -828,7 +819,7 @@ awi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCGIFMEDIA:
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ic.ic_media, cmd);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
@ -871,7 +862,7 @@ awi_media_change(struct ifnet *ifp)
|
||||
enum ieee80211_opmode newmode;
|
||||
int i, rate, newadhoc_ap, error = 0;
|
||||
|
||||
ime = sc->sc_media.ifm_cur;
|
||||
ime = ic->ic_media.ifm_cur;
|
||||
if (IFM_SUBTYPE(ime->ifm_media) == IFM_AUTO) {
|
||||
i = -1;
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: awivar.h,v 1.17 2002/09/30 15:48:48 onoe Exp $ */
|
||||
/* $NetBSD: awivar.h,v 1.18 2003/07/06 20:01:17 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
|
||||
@ -89,7 +89,6 @@ struct awi_softc {
|
||||
sc_enab_intr:1,
|
||||
sc_adhoc_ap:1,
|
||||
sc_invalid:1;
|
||||
struct ifmedia sc_media;
|
||||
enum ieee80211_state sc_nstate;
|
||||
enum awi_sub_state sc_substate;
|
||||
int sc_sleep_cnt;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: wi.c,v 1.131 2003/07/06 07:15:55 dyoung Exp $ */
|
||||
/* $NetBSD: wi.c,v 1.132 2003/07/06 20:01:17 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
@ -70,7 +70,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.131 2003/07/06 07:15:55 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.132 2003/07/06 20:01:17 dyoung Exp $");
|
||||
|
||||
#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
|
||||
#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
|
||||
@ -207,8 +207,7 @@ wi_attach(struct wi_softc *sc)
|
||||
{
|
||||
struct ieee80211com *ic = &sc->sc_ic;
|
||||
struct ifnet *ifp = &ic->ic_if;
|
||||
int i, nrate, mword, buflen;
|
||||
u_int8_t r;
|
||||
int i, nrate, buflen;
|
||||
u_int16_t val;
|
||||
u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
|
||||
static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
|
||||
@ -370,45 +369,15 @@ wi_attach(struct wi_softc *sc)
|
||||
sc->sc_cnfauthmode = IEEE80211_AUTH_OPEN;
|
||||
sc->sc_roaming_mode = 1;
|
||||
|
||||
ifmedia_init(&sc->sc_media, 0, wi_media_change, wi_media_status);
|
||||
printf("%s: supported rates: ", sc->sc_dev.dv_xname);
|
||||
#define ADD(s, o) ifmedia_add(&sc->sc_media, \
|
||||
IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL)
|
||||
ADD(IFM_AUTO, 0);
|
||||
if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_HOSTAP);
|
||||
if (ic->ic_flags & IEEE80211_F_HASIBSS)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC);
|
||||
if (ic->ic_flags & IEEE80211_F_HASMONITOR)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_MONITOR);
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
for (i = 0; i < nrate; i++) {
|
||||
r = ic->ic_sup_rates[i];
|
||||
mword = ieee80211_rate2media(r, IEEE80211_T_DS);
|
||||
if (mword == 0)
|
||||
continue;
|
||||
printf("%s%d%sMbps", (i != 0 ? " " : ""),
|
||||
(r & IEEE80211_RATE_VAL) / 2, ((r & 0x1) != 0 ? ".5" : ""));
|
||||
ADD(mword, 0);
|
||||
if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
|
||||
ADD(mword, IFM_IEEE80211_HOSTAP);
|
||||
if (ic->ic_flags & IEEE80211_F_HASIBSS)
|
||||
ADD(mword, IFM_IEEE80211_ADHOC);
|
||||
if (ic->ic_flags & IEEE80211_F_HASMONITOR)
|
||||
ADD(mword, IFM_IEEE80211_MONITOR);
|
||||
ADD(mword, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
}
|
||||
printf("\n");
|
||||
ifmedia_set(&sc->sc_media, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0));
|
||||
#undef ADD
|
||||
|
||||
/*
|
||||
* Call MI attach routines.
|
||||
*/
|
||||
|
||||
if_attach(ifp);
|
||||
ieee80211_ifattach(ifp);
|
||||
|
||||
ic->ic_media.ifm_status = wi_media_status;
|
||||
ic->ic_media.ifm_change = wi_media_change;
|
||||
|
||||
/* Attach is successful. */
|
||||
sc->sc_attached = 1;
|
||||
|
||||
@ -431,7 +400,7 @@ wi_detach(struct wi_softc *sc)
|
||||
wi_stop(ifp, 1);
|
||||
|
||||
/* Delete all remaining media. */
|
||||
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
|
||||
ifmedia_delete_instance(&sc->sc_ic.ic_media, IFM_INST_ANY);
|
||||
|
||||
ieee80211_ifdetach(ifp);
|
||||
if_detach(ifp);
|
||||
@ -1022,7 +991,7 @@ wi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
break;
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCGIFMEDIA:
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
|
||||
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
@ -1081,7 +1050,7 @@ wi_media_change(struct ifnet *ifp)
|
||||
enum ieee80211_opmode newmode;
|
||||
int i, rate, error = 0;
|
||||
|
||||
ime = sc->sc_media.ifm_cur;
|
||||
ime = ic->ic_media.ifm_cur;
|
||||
if (IFM_SUBTYPE(ime->ifm_media) == IFM_AUTO) {
|
||||
i = -1;
|
||||
} else {
|
||||
@ -1121,7 +1090,7 @@ wi_media_change(struct ifnet *ifp)
|
||||
else
|
||||
error = 0;
|
||||
}
|
||||
ifp->if_baudrate = ifmedia_baudrate(sc->sc_media.ifm_cur->ifm_media);
|
||||
ifp->if_baudrate = ifmedia_baudrate(ic->ic_media.ifm_cur->ifm_media);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1161,7 +1130,7 @@ wi_media_status(struct ifnet *ifp, struct ifmediareq *imr)
|
||||
rate = 22; /* 11Mbps */
|
||||
}
|
||||
}
|
||||
imr->ifm_active |= ieee80211_rate2media(rate, IEEE80211_T_DS);
|
||||
imr->ifm_active |= ieee80211_rate2media(rate, ic->ic_phytype);
|
||||
switch (ic->ic_opmode) {
|
||||
case IEEE80211_M_STA:
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: wivar.h,v 1.35 2003/07/06 07:15:56 dyoung Exp $ */
|
||||
/* $NetBSD: wivar.h,v 1.36 2003/07/06 20:01:18 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
@ -59,7 +59,6 @@ struct wi_softc {
|
||||
bus_space_tag_t sc_iot; /* bus cookie */
|
||||
bus_space_handle_t sc_ioh; /* bus i/o handle */
|
||||
|
||||
struct ifmedia sc_media;
|
||||
caddr_t sc_drvbpf;
|
||||
int sc_flags;
|
||||
int sc_bap_id;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ieee80211subr.c,v 1.40 2003/07/06 08:40:00 dyoung Exp $ */
|
||||
/* $NetBSD: if_ieee80211subr.c,v 1.41 2003/07/06 20:01:18 dyoung Exp $ */
|
||||
/* $FreeBSD: src/sys/net/if_ieee80211subr.c,v 1.4 2003/01/21 08:55:59 alfred Exp $ */
|
||||
|
||||
/*-
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.40 2003/07/06 08:40:00 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.41 2003/07/06 20:01:18 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "bpfilter.h"
|
||||
@ -136,7 +136,8 @@ void
|
||||
ieee80211_ifattach(struct ifnet *ifp)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
int i, rate;
|
||||
int i, rate, mword;
|
||||
struct ifmediareq imr;
|
||||
|
||||
ether_ifattach(ifp, ic->ic_myaddr);
|
||||
#if NBPFILTER > 0
|
||||
@ -155,6 +156,10 @@ ieee80211_ifattach(struct ifnet *ifp)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ic->ic_bss.ni_chan must always be a valid channel */
|
||||
if (isclr(ic->ic_chan_active, ic->ic_bss.ni_chan))
|
||||
ic->ic_bss.ni_chan = ic->ic_ibss_chan;
|
||||
|
||||
ic->ic_des_chan = IEEE80211_CHAN_ANY;
|
||||
ic->ic_fixed_rate = -1;
|
||||
if (ic->ic_lintval == 0)
|
||||
@ -212,6 +217,45 @@ ieee80211_ifattach(struct ifnet *ifp)
|
||||
>> IEEE80211_FC0_SUBTYPE_SHIFT] = ieee80211_send_asresp;
|
||||
ic->ic_send_mgmt[IEEE80211_FC0_SUBTYPE_DISASSOC
|
||||
>> IEEE80211_FC0_SUBTYPE_SHIFT] = ieee80211_send_disassoc;
|
||||
|
||||
#define ADD(s, o) ifmedia_add(&ic->ic_media, \
|
||||
IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL)
|
||||
|
||||
ifmedia_init(&ic->ic_media, 0, ieee80211_media_change,
|
||||
ieee80211_media_status);
|
||||
printf("%s: supported rates: ", ic->ic_if.if_xname);
|
||||
ADD(IFM_AUTO, 0); /* infrastructure */
|
||||
if (ic->ic_flags & IEEE80211_F_HASAHDEMO)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_HOSTAP);
|
||||
if (ic->ic_flags & IEEE80211_F_HASIBSS)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_ADHOC);
|
||||
if (ic->ic_flags & IEEE80211_F_HASMONITOR)
|
||||
ADD(IFM_AUTO, IFM_IEEE80211_MONITOR);
|
||||
|
||||
for (i = 0; i < IEEE80211_RATE_SIZE; i++) {
|
||||
rate = ic->ic_sup_rates[i];
|
||||
mword = ieee80211_rate2media(rate, ic->ic_phytype);
|
||||
if (mword == 0)
|
||||
continue;
|
||||
printf("%s%d%sMbps", (i != 0 ? " " : ""),
|
||||
(rate & IEEE80211_RATE_VAL) / 2,
|
||||
((rate & 0x1) != 0 ? ".5" : ""));
|
||||
ADD(mword, 0); /* infrastructure */
|
||||
if (ic->ic_flags & IEEE80211_F_HASAHDEMO)
|
||||
ADD(mword, IFM_IEEE80211_ADHOC | IFM_FLAG0);
|
||||
if (ic->ic_flags & IEEE80211_F_HASHOSTAP)
|
||||
ADD(mword, IFM_IEEE80211_HOSTAP);
|
||||
if (ic->ic_flags & IEEE80211_F_HASIBSS)
|
||||
ADD(mword, IFM_IEEE80211_ADHOC);
|
||||
if (ic->ic_flags & IEEE80211_F_HASMONITOR)
|
||||
ADD(mword, IFM_IEEE80211_MONITOR);
|
||||
}
|
||||
printf("\n");
|
||||
(*ic->ic_media.ifm_status)(ifp, &imr);
|
||||
ifmedia_set(&ic->ic_media, imr.ifm_active);
|
||||
#undef ADD
|
||||
}
|
||||
|
||||
void
|
||||
@ -228,6 +272,10 @@ ieee80211_ifdetach(struct ifnet *ifp)
|
||||
ic->ic_wep_ctx = NULL;
|
||||
}
|
||||
ieee80211_free_allnodes(ic);
|
||||
ifmedia_delete_instance(&ic->ic_media, IFM_INST_ANY);
|
||||
#if NBPFILTER > 0
|
||||
bpfdetach(ifp);
|
||||
#endif
|
||||
ether_ifdetach(ifp);
|
||||
splx(s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user