summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-07-20 21:38:20 +0000
committersam <sam@FreeBSD.org>2003-07-20 21:38:20 +0000
commitf0b61fc4ed6649cdf254804603bce900b087cbea (patch)
tree3aa807a06b9e14633b89b127dd57467d8745e651 /sys
parent51c8bf1aebf18e644d2c3354aa5e0e5048baab1e (diff)
downloadFreeBSD-src-f0b61fc4ed6649cdf254804603bce900b087cbea.zip
FreeBSD-src-f0b61fc4ed6649cdf254804603bce900b087cbea.tar.gz
track changes to 802.11 code:
o override new_state method per new model o use ieee80211_state_name instead of private copy
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ath/if_ath.c44
-rw-r--r--sys/dev/ath/if_athvar.h2
-rw-r--r--sys/dev/wi/if_wi.c43
-rw-r--r--sys/dev/wi/if_wivar.h2
4 files changed, 47 insertions, 44 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 3642abd..98812fd 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -129,7 +129,7 @@ static void ath_stoprecv(struct ath_softc *);
static int ath_startrecv(struct ath_softc *);
static void ath_next_scan(void *);
static void ath_calibrate(void *);
-static int ath_newstate(void *, enum ieee80211_state);
+static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int);
static void ath_newassoc(struct ieee80211com *,
struct ieee80211_node *, int);
static int ath_getchannels(struct ath_softc *, u_int cc, HAL_BOOL outdoor);
@@ -281,7 +281,6 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ic->ic_softc = sc;
- ic->ic_newstate = ath_newstate;
ic->ic_newassoc = ath_newassoc;
/* XXX not right but it's not used anywhere important */
ic->ic_phytype = IEEE80211_T_OFDM;
@@ -300,7 +299,9 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
ic->ic_node_alloc = ath_node_alloc;
ic->ic_node_free = ath_node_free;
ic->ic_node_copy = ath_node_copy;
-
+ sc->sc_newstate = ic->ic_newstate;
+ ic->ic_newstate = ath_newstate;
+ /* complete initialization */
ieee80211_media_init(ifp, ath_media_change, ieee80211_media_status);
if_printf(ifp, "802.11 address: %s\n", ether_sprintf(ic->ic_myaddr));
@@ -453,13 +454,12 @@ ath_bmiss_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &ic->ic_if;
DPRINTF(("ath_bmiss_proc: pending %u\n", pending));
KASSERT(ic->ic_opmode == IEEE80211_M_STA,
("unexpect operating mode %u", ic->ic_opmode));
if (ic->ic_state == IEEE80211_S_RUN)
- ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+ ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
}
static u_int
@@ -546,7 +546,7 @@ ath_init(void *arg)
mode = ieee80211_chan2mode(ic, ni->ni_chan);
if (mode != sc->sc_curmode)
ath_setcurmode(sc, mode);
- ieee80211_new_state(ifp, IEEE80211_S_SCAN, -1);
+ ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
done:
mtx_unlock(&sc->sc_mtx);
}
@@ -554,6 +554,7 @@ done:
static void
ath_stop(struct ifnet *ifp)
{
+ struct ieee80211com *ic = (struct ieee80211com *) ifp;
struct ath_softc *sc = ifp->if_softc;
struct ath_hal *ah = sc->sc_ah;
@@ -587,7 +588,7 @@ ath_stop(struct ifnet *ifp)
sc->sc_rxlink = NULL;
IF_DRAIN(&ifp->if_snd);
ath_beacon_free(sc);
- ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+ ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
if (!sc->sc_invalid)
ath_hal_setpower(ah, HAL_PM_FULL_SLEEP, 0);
}
@@ -2156,21 +2157,15 @@ ath_calibrate(void *arg)
}
static int
-ath_newstate(void *arg, enum ieee80211_state nstate)
+ath_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
{
- struct ath_softc *sc = arg;
- struct ath_hal *ah = sc->sc_ah;
- struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &ic->ic_if;
+ struct ath_softc *sc = ifp->if_softc;
+ struct ath_hal *ah = sc->sc_ah;
struct ieee80211_node *ni;
int i, error;
u_int8_t *bssid;
u_int32_t rfilt;
- enum ieee80211_state ostate;
-#ifdef AR_DEBUG
- static const char *stname[] =
- { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
-#endif /* AR_DEBUG */
static const HAL_LED_STATE leds[] = {
HAL_LED_INIT, /* IEEE80211_S_INIT */
HAL_LED_SCAN, /* IEEE80211_S_SCAN */
@@ -2179,17 +2174,18 @@ ath_newstate(void *arg, enum ieee80211_state nstate)
HAL_LED_RUN, /* IEEE80211_S_RUN */
};
- ostate = ic->ic_state;
-
- DPRINTF(("%s: %s -> %s\n", __func__, stname[ostate], stname[nstate]));
+ DPRINTF(("%s: %s -> %s\n", __func__,
+ ieee80211_state_name[ic->ic_state],
+ ieee80211_state_name[nstate]));
ath_hal_setledstate(ah, leds[nstate]); /* set LED */
if (nstate == IEEE80211_S_INIT) {
sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
ath_hal_intrset(ah, sc->sc_imask);
- error = 0; /* cheat + use error return */
- goto bad;
+ callout_stop(&sc->sc_scan_ch);
+ callout_stop(&sc->sc_cal_ch);
+ return (*sc->sc_newstate)(ic, nstate, arg);
}
ni = ic->ic_bss;
error = ath_chan_set(sc, ni->ni_chan);
@@ -2259,10 +2255,14 @@ ath_newstate(void *arg, enum ieee80211_state nstate)
* Reset the rate control state.
*/
ath_rate_ctl_reset(sc, nstate);
- return 0;
+ /*
+ * Invoke the parent method to complete the work.
+ */
+ return (*sc->sc_newstate)(ic, nstate, arg);
bad:
callout_stop(&sc->sc_scan_ch);
callout_stop(&sc->sc_cal_ch);
+ /* NB: do not invoke the parent */
return error;
}
diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h
index 0a3ca07..ea27809 100644
--- a/sys/dev/ath/if_athvar.h
+++ b/sys/dev/ath/if_athvar.h
@@ -78,6 +78,8 @@ struct ath_buf {
struct ath_softc {
struct ieee80211com sc_ic; /* IEEE 802.11 common */
+ int (*sc_newstate)(struct ieee80211com *,
+ enum ieee80211_state, int);
device_t sc_dev;
bus_space_tag_t sc_st; /* bus space tag */
bus_space_handle_t sc_sh; /* bus space handle */
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index f9f0b8f..37e9ab8 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -146,7 +146,7 @@ static int wi_mwrite_bap(struct wi_softc *, int, int, struct mbuf *, int);
static int wi_read_rid(struct wi_softc *, int, void *, int *);
static int wi_write_rid(struct wi_softc *, int, void *, int);
-static int wi_newstate(void *, enum ieee80211_state);
+static int wi_newstate(struct ieee80211com *, enum ieee80211_state, int);
static int wi_scan_ap(struct wi_softc *, u_int16_t, u_int16_t);
static void wi_scan_result(struct wi_softc *, int, int);
@@ -312,7 +312,6 @@ wi_attach(device_t dev)
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_AHDEMO;
ic->ic_state = IEEE80211_S_INIT;
- ic->ic_newstate = wi_newstate;
/*
* Query the card for available channels and setup the
@@ -452,6 +451,9 @@ wi_attach(device_t dev)
* Call MI attach routine.
*/
ieee80211_ifattach(ifp);
+ /* override state transition method */
+ sc->sc_newstate = ic->ic_newstate;
+ ic->ic_newstate = wi_newstate;
ieee80211_media_init(ifp, wi_media_change, wi_media_status);
return (0);
@@ -716,7 +718,7 @@ wi_init(void *arg)
ifp->if_flags &= ~IFF_OACTIVE;
if (ic->ic_opmode == IEEE80211_M_AHDEMO ||
ic->ic_opmode == IEEE80211_M_HOSTAP)
- wi_newstate(sc, IEEE80211_S_RUN);
+ ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
/* Enable interrupts */
CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
@@ -758,12 +760,13 @@ out:
void
wi_stop(struct ifnet *ifp, int disable)
{
+ struct ieee80211com *ic = (struct ieee80211com *) ifp;
struct wi_softc *sc = ifp->if_softc;
WI_LOCK_DECL();
WI_LOCK(sc);
- ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+ ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
if (sc->sc_enabled && !sc->wi_gone) {
CSR_WRITE_2(sc, WI_INT_EN, 0);
wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
@@ -996,10 +999,11 @@ wi_watchdog(struct ifnet *ifp)
if (sc->sc_syn_timer) {
if (--sc->sc_syn_timer == 0) {
+ struct ieee80211com *ic = (struct ieee80211com *) ifp;
DPRINTF2(("wi_watchdog: %d false syns\n",
sc->sc_false_syns));
sc->sc_false_syns = 0;
- ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+ ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
sc->sc_syn_timer = 5;
}
ifp->if_timer = 1;
@@ -1244,7 +1248,7 @@ wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN])
sc->sc_false_syns >= WI_MAX_FALSE_SYNS)
return;
- ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+ ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
}
static void
@@ -1547,7 +1551,7 @@ wi_info_intr(struct wi_softc *sc)
break;
/* FALLTHROUGH */
case WI_INFO_LINK_STAT_AP_CHG:
- ieee80211_new_state(ifp, IEEE80211_S_RUN, -1);
+ ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
break;
case WI_INFO_LINK_STAT_AP_INR:
sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
@@ -1566,7 +1570,7 @@ wi_info_intr(struct wi_softc *sc)
case WI_INFO_LINK_STAT_DISCONNECTED:
case WI_INFO_LINK_STAT_ASSOC_FAILED:
if (ic->ic_opmode == IEEE80211_M_STA)
- ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+ ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
break;
}
break;
@@ -2519,30 +2523,25 @@ wi_write_rid(struct wi_softc *sc, int rid, void *buf, int buflen)
}
static int
-wi_newstate(void *arg, enum ieee80211_state nstate)
+wi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
{
- struct wi_softc *sc = arg;
- struct ieee80211com *ic = &sc->sc_ic;
+ struct ifnet *ifp = &ic->ic_if;
+ struct wi_softc *sc = ifp->if_softc;
struct ieee80211_node *ni = ic->ic_bss;
int buflen;
u_int16_t val;
struct wi_ssid ssid;
u_int8_t old_bssid[IEEE80211_ADDR_LEN];
- enum ieee80211_state ostate;
-#ifdef WI_DEBUG
- static const char *stname[] =
- { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" };
-#endif /* WI_DEBUG */
- ostate = ic->ic_state;
- DPRINTF(("wi_newstate: %s -> %s\n", stname[ostate], stname[nstate]));
+ DPRINTF(("%s: %s -> %s\n", __func__,
+ ieee80211_state_name[ic->ic_state],
+ ieee80211_state_name[nstate]));
- ic->ic_state = nstate;
switch (nstate) {
case IEEE80211_S_INIT:
ic->ic_flags &= ~IEEE80211_F_SIBSS;
sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
- return 0;
+ return (*sc->sc_newstate)(ic, nstate, arg);
case IEEE80211_S_RUN:
sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
@@ -2584,8 +2583,8 @@ wi_newstate(void *arg, enum ieee80211_state nstate)
break;
}
- /* skip standard ieee80211 handling */
- return EINPROGRESS;
+ ic->ic_state = nstate; /* NB: skip normal ieee80211 handling */
+ return 0;
}
static int
diff --git a/sys/dev/wi/if_wivar.h b/sys/dev/wi/if_wivar.h
index 5e90067..0ec3df3 100644
--- a/sys/dev/wi/if_wivar.h
+++ b/sys/dev/wi/if_wivar.h
@@ -61,6 +61,8 @@
struct wi_softc {
struct ieee80211com sc_ic;
+ int (*sc_newstate)(struct ieee80211com *,
+ enum ieee80211_state, int);
device_t sc_dev;
#if __FreeBSD_version >= 500000
struct mtx sc_mtx;
OpenPOWER on IntegriCloud