Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/pci Refactor vap_create, vap_delete and iwn ne...
details: https://anonhg.NetBSD.org/src-all/rev/23c8a3d2ba40
branches: trunk
changeset: 377106:23c8a3d2ba40
user: Nathanial Sloss <nat%netbsd.org@localhost>
date: Sun Aug 07 20:10:43 2022 +1000
description:
Refactor vap_create, vap_delete and iwn newstate.
Make these functions in line with other drivers.
Also in this dont allow overriding of ifp->if_start and friends.
diffstat:
sys/dev/pci/if_iwn.c | 51 +++++++++++++++++++++++-------------------------
sys/dev/pci/if_iwnvar.h | 2 -
2 files changed, 24 insertions(+), 29 deletions(-)
diffs (123 lines):
diff -r 58ca93664ef0 -r 23c8a3d2ba40 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c Fri Aug 05 23:32:36 2022 +1000
+++ b/sys/dev/pci/if_iwn.c Sun Aug 07 20:10:43 2022 +1000
@@ -438,6 +438,15 @@ int iwn_debug = 0;
#define DPRINTFN(n, x)
#endif
+/*
+ * We ovveride the VAP's newstate method, so need to save the old
+ * function pointer for each VAP.
+ */
+struct iwn_vap {
+ struct ieee80211vap vap;
+ int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+};
+
CFATTACH_DECL_NEW(iwn, sizeof(struct iwn_softc), iwn_match, iwn_attach,
iwn_detach, NULL);
@@ -834,16 +843,12 @@ iwn_config_complete(device_t self)
static void
iwn_vap_delete(struct ieee80211vap *vap)
{
- struct ifnet *ifp = vap->iv_ifp;
- struct iwn_softc *sc __unused =vap->iv_ic->ic_softc;
+ struct iwn_vap *my_vap = (struct iwn_vap *)vap;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
- iwn_stop(ifp, 0);
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- bpf_detach(ifp);
- if_detach(ifp);
- kmem_free(vap, sizeof(struct ieee80211vap));
+ ieee80211_vap_detach(vap);
+ kmem_free(my_vap, sizeof(*my_vap));
}
static int
@@ -989,9 +994,7 @@ iwn_vap_create(struct ieee80211com *ic,
const uint8_t bssid[IEEE80211_ADDR_LEN],
const uint8_t macaddr[IEEE80211_ADDR_LEN])
{
- struct iwn_softc *sc = ic->ic_softc;
- struct ieee80211vap *vap;
- struct ifnet *ifp;
+ struct iwn_vap *vap;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -1001,33 +1004,27 @@ iwn_vap_create(struct ieee80211com *ic,
/* Allocate the vap and setup. */
vap = kmem_zalloc(sizeof(struct ieee80211vap), KM_SLEEP);
- if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
+ if (ieee80211_vap_setup(ic, &vap->vap, name, unit, opmode,
flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
kmem_free(vap, sizeof(struct ieee80211vap));
return NULL;
}
/* Local setup */
- vap->iv_reset = iwn_reset;
-
- ifp = vap->iv_ifp;
- //ifp->if_init = iwn_init;
- //ifp->if_ioctl = iwn_ioctl;
- ifp->if_start = iwn_start;
- // ifp->if_watchdog = i_watchdog; NNN
- ifp->if_extflags |= IFEF_MPSAFE;
+ vap->vap.iv_reset = iwn_reset;
/* Finish setup */
- ieee80211_vap_attach(vap, iwn_media_change,
+ ieee80211_vap_attach(&vap->vap, iwn_media_change,
ieee80211_media_status, macaddr);
/* Override state transition machine. */
/* NNN --- many possible newstate machines ... issue! */
- sc->sc_newstate = vap->iv_newstate;
- vap->iv_newstate = iwn_newstate;
-
- ieee80211_init(ifp);
- return vap;
+ vap->newstate = vap->vap.iv_newstate;
+ vap->vap.iv_newstate = iwn_newstate;
+
+ ic->ic_opmode = opmode;
+
+ return &vap->vap;
}
static int
@@ -2231,6 +2228,7 @@ iwn_media_change(struct ifnet *ifp)
static int
iwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
{
+ struct iwn_vap *my_vap = (struct iwn_vap*)vap;
struct ieee80211com *ic = vap->iv_ic;
struct iwn_softc *sc = ic->ic_softc;
struct ifnet *ifp = vap->iv_ifp;
@@ -2338,8 +2336,7 @@ iwn_newstate(struct ieee80211vap *vap, e
break;
}
- error = (*sc->sc_newstate)(vap, nstate, arg);
- return error;
+ return (*my_vap->newstate)(vap, nstate, arg);
}
static void __unused
diff -r 58ca93664ef0 -r 23c8a3d2ba40 sys/dev/pci/if_iwnvar.h
--- a/sys/dev/pci/if_iwnvar.h Fri Aug 05 23:32:36 2022 +1000
+++ b/sys/dev/pci/if_iwnvar.h Sun Aug 07 20:10:43 2022 +1000
@@ -201,8 +201,6 @@ struct iwn_softc {
struct ethercom sc_ec;
struct ieee80211com sc_ic;
- int (*sc_newstate)(struct ieee80211vap *,
- enum ieee80211_state, int);
struct ieee80211_amrr amrr;
uint8_t fixed_ridx;
Home |
Main Index |
Thread Index |
Old Index