Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/phil-wifi]: src/sys State save.
details: https://anonhg.NetBSD.org/src/rev/70077198073f
branches: phil-wifi
changeset: 320706:70077198073f
user: phil <phil%NetBSD.org@localhost>
date: Mon Jul 16 20:11:11 2018 +0000
description:
State save.
urtwn now can attach and shows up in the "ifconfig -a" list.
diffstat:
sys/dev/usb/if_urtwn.c | 179 ++++++++++++++++++++++++---------
sys/dev/usb/if_urtwnvar.h | 8 +-
sys/net80211/ieee80211.c | 46 +++++++-
sys/net80211/ieee80211_acl.c | 10 +-
sys/net80211/ieee80211_amrr.c | 10 +-
sys/net80211/ieee80211_crypto.c | 11 +-
sys/net80211/ieee80211_crypto_tkip.c | 12 ++-
sys/net80211/ieee80211_crypto_wep.c | 8 +-
sys/net80211/ieee80211_ht.c | 6 +-
sys/net80211/ieee80211_hwmp.c | 7 +-
sys/net80211/ieee80211_input.c | 10 +-
sys/net80211/ieee80211_ioctl.c | 13 ++-
sys/net80211/ieee80211_mesh.c | 20 +++-
sys/net80211/ieee80211_netbsd.c | 37 +++---
sys/net80211/ieee80211_netbsd.h | 5 +-
sys/net80211/ieee80211_node.c | 19 +++-
sys/net80211/ieee80211_output.c | 8 +-
sys/net80211/ieee80211_proto.c | 45 +++++++-
sys/net80211/ieee80211_proto.h | 15 ++-
sys/net80211/ieee80211_ratectl.c | 32 +++++-
sys/net80211/ieee80211_ratectl.h | 5 +-
sys/net80211/ieee80211_ratectl_none.c | 11 +-
sys/net80211/ieee80211_rssadapt.c | 10 +-
sys/net80211/ieee80211_scan.c | 11 +-
sys/net80211/ieee80211_scan_sta.c | 11 +-
sys/net80211/ieee80211_var.h | 9 +-
sys/net80211/ieee80211_xauth.c | 10 +-
27 files changed, 427 insertions(+), 141 deletions(-)
diffs (truncated from 1546 to 300 lines):
diff -r 35180a97c725 -r 70077198073f sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Thu Jul 12 16:35:33 2018 +0000
+++ b/sys/dev/usb/if_urtwn.c Mon Jul 16 20:11:11 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urtwn.c,v 1.59.2.1 2018/07/12 16:35:33 phil Exp $ */
+/* $NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $ */
/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */
/*-
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.1 2018/07/12 16:35:33 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -37,6 +37,7 @@
#include <sys/sysctl.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
+#include <sys/kmem.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/module.h>
@@ -92,7 +93,8 @@
#define DBG_RF __BIT(5)
#define DBG_REG __BIT(6)
#define DBG_ALL 0xffffffffU
-u_int urtwn_debug = 0;
+/* NNN Reset urtwn_debug to 0 when done debugging. */
+u_int urtwn_debug = DBG_INIT|DBG_FN|DBG_STM;
#define DPRINTFN(n, s) \
do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
#else
@@ -258,7 +260,7 @@
static void urtwn_calib_to(void *);
static void urtwn_calib_to_cb(struct urtwn_softc *, void *);
static void urtwn_next_scan(void *);
-static int urtwn_newstate(struct urtwn_softc *, enum ieee80211_state,
+static int urtwn_newstate(struct ieee80211vap *, enum ieee80211_state,
int);
static void urtwn_newstate_cb(struct urtwn_softc *, void *);
static int urtwn_wme_update(struct ieee80211com *);
@@ -275,7 +277,6 @@
urtwn_get_tx_data(struct urtwn_softc *, size_t);
static void urtwn_start(struct ifnet *);
static void urtwn_watchdog(struct ifnet *);
-static int urtwn_ioctl(struct ifnet *, u_long, void *);
static int urtwn_r92c_power_on(struct urtwn_softc *);
static int urtwn_r92e_power_on(struct urtwn_softc *);
static int urtwn_r88e_power_on(struct urtwn_softc *);
@@ -306,10 +307,17 @@
static void urtwn_temp_calib(struct urtwn_softc *);
static int urtwn_init(struct ifnet *);
static void urtwn_stop(struct ifnet *, int);
-static int urtwn_reset(struct ifnet *);
+static int urtwn_reset(struct ieee80211vap *, u_long);
static void urtwn_chip_stop(struct urtwn_softc *);
static void urtwn_newassoc(struct ieee80211_node *, int);
static void urtwn_delay_ms(struct urtwn_softc *, int ms);
+static struct ieee80211vap *
+ urtwn_vap_create(struct ieee80211com *,
+ const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
+ const uint8_t [IEEE80211_ADDR_LEN],
+ const uint8_t [IEEE80211_ADDR_LEN]);
+static void urtwn_vap_delete(struct ieee80211vap *);
+static int urtwn_ioctl(struct ifnet *, u_long, void *);
/* Aliases. */
#define urtwn_bb_write urtwn_write_4
@@ -339,7 +347,6 @@
{
struct urtwn_softc *sc = device_private(self);
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
struct usb_attach_arg *uaa = aux;
char *devinfop;
const struct urtwn_dev *dev;
@@ -447,8 +454,7 @@
/*
* Setup the 802.11 device.
*/
- /* ic->ic_ifp = ifp; NNN need to do this later... */
- /* ic->ic_state = IEEE80211_S_INIT; NNN do this to the vap */
+ ic->ic_softc = sc;
ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */
ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */
@@ -462,8 +468,11 @@
IEEE80211_C_WME | /* 802.11e */
IEEE80211_C_WPA; /* 802.11i */
+ ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+
/* Set supported .11b and .11g channels (1 through 14). */
- for (i = 1; i <= 14; i++) {
+ ic->ic_nchans = 14; /* NNN ? get this from somewhere? */
+ for (i = 0; i < 14; i++) {
ic->ic_channels[i].ic_freq =
ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ);
ic->ic_channels[i].ic_flags =
@@ -471,33 +480,34 @@
IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
}
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_init = urtwn_init;
- ifp->if_ioctl = urtwn_ioctl;
- ifp->if_start = urtwn_start;
- ifp->if_watchdog = urtwn_watchdog;
- IFQ_SET_READY(&ifp->if_snd);
- memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
-
- if_attach(ifp);
+ printf ("eurtwn: Calling ieee80211_ifattach()\n");
+
ieee80211_ifattach(ic);
+ printf ("urtwn: Returned from ieee80211_ifattach().\n");
+
/* override default methods NNN Need a lot more here!!! */
ic->ic_newassoc = urtwn_newassoc;
ic->ic_wme.wme_update = urtwn_wme_update;
-
-#if 0
- /* XXX .... vap routines ... in vap_create? */
- vap->iv_reset = urtwn_reset;
-
- /* Override state transition machine. */
- sc->sc_newstate = ic->ic_newstate;
- ic->ic_newstate = urtwn_newstate;
- ieee80211_media_init(ic, urtwn_media_change, ieee80211_media_status);
-#endif
-
- bpf_attach2(ifp, DLT_IEEE802_11_RADIO,
+ ic->ic_vap_create = urtwn_vap_create;
+ ic->ic_vap_delete = urtwn_vap_delete;
+
+ /* Shouldn't do it, but call vap_create??? */
+ uint8_t bssid[IEEE80211_ADDR_LEN] = {0};
+
+ struct ieee80211vap *vap =
+ urtwn_vap_create(ic, device_xname(sc->sc_dev),
+ device_unit(sc->sc_dev), IEEE80211_M_IBSS,
+ IEEE80211_CLONE_MACADDR, bssid, ic->ic_macaddr);
+
+ if (vap == NULL) {
+ /* Didn't work ... now what! */
+ printf ("vap_create didn't work ...\n");
+ ieee80211_ifdetach(ic);
+ goto fail;
+ }
+
+ bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
&sc->sc_drvbpf);
@@ -517,6 +527,7 @@
aprint_error_dev(self, "couldn't establish power handler\n");
SET(sc->sc_flags, URTWN_FLAG_ATTACHED);
+printf ("urtwn: Finished attach.\n");
return;
fail:
@@ -528,7 +539,6 @@
urtwn_detach(device_t self, int flags)
{
struct urtwn_softc *sc = device_private(self);
- struct ifnet *ifp = &sc->sc_if;
int s;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -544,12 +554,8 @@
if (ISSET(sc->sc_flags, URTWN_FLAG_ATTACHED)) {
usb_rem_task(sc->sc_udev, &sc->sc_task);
- urtwn_stop(ifp, 0);
-
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- bpf_detach(ifp);
+
ieee80211_ifdetach(&sc->sc_ic);
- if_detach(ifp);
/* Close Tx/Rx pipes. Abort done by urtwn_stop. */
urtwn_close_pipes(sc);
@@ -574,18 +580,14 @@
static int
urtwn_activate(device_t self, enum devact act)
{
-#if notyet
struct urtwn_softc *sc = device_private(self);
-#endif
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
switch (act) {
case DVACT_DEACTIVATE:
-#if notyet
- FOR_EACH(vap in sc->sc_vaps) ???
- if_deactivate(vap->iv_ifp);
-#endif
+ if_deactivate(TAILQ_FIRST(&(sc->sc_ic.ic_vaps))->iv_ifp);
+
return 0;
default:
return EOPNOTSUPP;
@@ -1832,8 +1834,9 @@
}
static __unused int
-urtwn_newstate(struct urtwn_softc *sc, enum ieee80211_state nstate, int arg)
+urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
{
+ struct urtwn_softc *sc = vap->iv_ic->ic_softc;
struct urtwn_cmd_newstate cmd;
DPRINTFN(DBG_FN, ("%s: %s: nstate=%s(%d), arg=%d\n",
@@ -2151,7 +2154,7 @@
break;
}
- (*sc->sc_newstate)(ic, nstate, cmd->arg);
+ (*sc->sc_newstate)(vap, nstate, cmd->arg);
mutex_exit(&sc->sc_write_mtx);
splx(s);
@@ -2561,7 +2564,7 @@
{
struct urtwn_tx_data *data = priv;
struct urtwn_softc *sc = data->sc;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = TAILQ_FIRST(&sc->sc_ic.ic_vaps)->iv_ifp;
size_t pidx = data->pidx;
int s;
@@ -2955,10 +2958,85 @@
//NNN ieee80211_watchdog(&sc->sc_ic); Not sure what is happening!
}
+/*
+ * Create a VAP node for use with the urtwn driver.
+ */
+
+static struct ieee80211vap *
+urtwn_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
+ int unit, enum ieee80211_opmode opmode, int flags,
+ const uint8_t bssid[IEEE80211_ADDR_LEN],
+ const uint8_t macaddr[IEEE80211_ADDR_LEN])
+{
+ printf ("in urtwn_vap_create ... \n");
+
+ struct urtwn_softc *sc = ic->ic_softc;
+ struct ifnet *ifp;
+ struct ieee80211vap *vap;
+
+ DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+
+ /* Allow only one VAP for the urtwn driver. */
+ if (!TAILQ_EMPTY(&ic->ic_vaps))
+ return NULL;
+
+ /* Allocate the vap and setup. */
+ vap = kmem_zalloc(sizeof(struct ieee80211vap), KM_SLEEP);
+ if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
+ flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
+ kmem_free(vap, sizeof(struct ieee80211vap));
+ return NULL;
+ }
+
+ printf ("vap_create: after vap_setup\n");
+
+ /* Local setup */
+ vap->iv_reset = urtwn_reset;
+
+ ifp = vap->iv_ifp;
+ ifp->if_init = urtwn_init;
+ ifp->if_ioctl = urtwn_ioctl;
+ ifp->if_start = urtwn_start;
+ ifp->if_watchdog = urtwn_watchdog;
+ IFQ_SET_READY(&ifp->if_snd);
+ memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
+
+ /* NNN needed ??? */
+ /* if_attach(ifp); */
+
+ /* Override state transition machine. */
+ sc->sc_newstate = vap->iv_newstate;
+ vap->iv_newstate = urtwn_newstate;
+
+ /* Finish setup */
+ ieee80211_vap_attach(vap, urtwn_media_change,
+ ieee80211_media_status, macaddr);
+ ic->ic_opmode = opmode;
+
+ return vap;
Home |
Main Index |
Thread Index |
Old Index