Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/usb Remove VAP hack used for early bringup
details: https://anonhg.NetBSD.org/src-all/rev/47acbdeb1fd6
branches: trunk
changeset: 939972:47acbdeb1fd6
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Fri Sep 25 19:35:32 2020 +0200
description:
Remove VAP hack used for early bringup
diffstat:
sys/dev/usb/if_urtwn.c | 616 +++++++++++++++++----------------------------
sys/dev/usb/if_urtwnvar.h | 7 +-
2 files changed, 231 insertions(+), 392 deletions(-)
diffs (truncated from 1324 to 300 lines):
diff -r 826371e6099e -r 47acbdeb1fd6 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Thu Sep 24 13:02:27 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c Fri Sep 25 19:35:32 2020 +0200
@@ -99,20 +99,19 @@
/*
* The sc_write_mtx locking is to prevent sequences of writes from
- * being intermingled with each other. I don't know if this is really
+ * being intermingled with each other. I don't know if this is really
* needed. I have added it just to be on the safe side.
*/
#ifdef URTWN_DEBUG
-#define DBG_INIT __BIT(0)
-#define DBG_FN __BIT(1)
-#define DBG_TX __BIT(2)
-#define DBG_RX __BIT(3)
-#define DBG_STM __BIT(4)
-#define DBG_RF __BIT(5)
-#define DBG_REG __BIT(6)
-#define DBG_ALL 0xffffffffU
-/* NNN Reset urtwn_debug to 0 when done debugging. */
+#define DBG_INIT __BIT(0)
+#define DBG_FN __BIT(1)
+#define DBG_TX __BIT(2)
+#define DBG_RX __BIT(3)
+#define DBG_STM __BIT(4)
+#define DBG_RF __BIT(5)
+#define DBG_REG __BIT(6)
+#define DBG_ALL 0xffffffffU
u_int urtwn_debug = 0;
#define DPRINTFN(n, s) \
do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
@@ -128,8 +127,8 @@
static const struct urtwn_dev {
struct usb_devno dev;
uint32_t flags;
-#define FLAG_RTL8188E __BIT(0)
-#define FLAG_RTL8192E __BIT(1)
+#define FLAG_RTL8188E __BIT(0)
+#define FLAG_RTL8192E __BIT(1)
} urtwn_devs[] = {
URTWN_DEV(ABOCOM, RTL8188CU_1),
URTWN_DEV(ABOCOM, RTL8188CU_2),
@@ -253,8 +252,8 @@
static int urtwn_read_region_1(struct urtwn_softc *, uint16_t, uint8_t *,
int);
static uint8_t urtwn_read_1(struct urtwn_softc *, uint16_t);
-static uint16_t urtwn_read_2(struct urtwn_softc *, uint16_t);
-static uint32_t urtwn_read_4(struct urtwn_softc *, uint16_t);
+static uint16_t urtwn_read_2(struct urtwn_softc *, uint16_t);
+static uint32_t urtwn_read_4(struct urtwn_softc *, uint16_t);
static int urtwn_fw_cmd(struct urtwn_softc *, uint8_t, const void *, int);
static void urtwn_r92c_rf_write(struct urtwn_softc *, int, uint8_t,
uint32_t);
@@ -262,7 +261,7 @@
uint32_t);
static void urtwn_r92e_rf_write(struct urtwn_softc *, int, uint8_t,
uint32_t);
-static uint32_t urtwn_rf_read(struct urtwn_softc *, int, uint8_t);
+static uint32_t urtwn_rf_read(struct urtwn_softc *, int, uint8_t);
static int urtwn_llt_write(struct urtwn_softc *, uint32_t, uint32_t);
static uint8_t urtwn_efuse_read_1(struct urtwn_softc *, uint16_t);
static void urtwn_efuse_read(struct urtwn_softc *);
@@ -273,7 +272,6 @@
#endif
static void urtwn_read_rom(struct urtwn_softc *);
static void urtwn_r88e_read_rom(struct urtwn_softc *);
-static int urtwn_media_change(struct ifnet *);
static int urtwn_ra_init(struct ieee80211vap *);
static int urtwn_get_nettype(struct urtwn_softc *);
static void urtwn_set_nettype0_msr(struct urtwn_softc *, uint8_t);
@@ -281,10 +279,8 @@
static void urtwn_set_led(struct urtwn_softc *, int, int);
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 ieee80211vap *, enum ieee80211_state,
int);
-//static void urtwn_newstate_cb(struct urtwn_softc *, void *);
static int urtwn_wme_update(struct ieee80211com *);
static void urtwn_wme_update_cb(struct urtwn_softc *, void *);
static void urtwn_update_avgrssi(struct urtwn_softc *, int, int8_t);
@@ -297,8 +293,8 @@
struct ieee80211_node *, struct urtwn_tx_data *);
static struct urtwn_tx_data *
urtwn_get_tx_data(struct urtwn_softc *, size_t);
-static void urtwn_start(struct ifnet *);
-static void urtwn_watchdog(struct ifnet *);
+static void urtwn_start(struct urtwn_softc *);
+static void urtwn_watchdog(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 *);
@@ -326,9 +322,8 @@
static void urtwn_iq_calib(struct urtwn_softc *, bool);
static void urtwn_lc_calib(struct urtwn_softc *);
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 ieee80211vap *, u_long);
+static int urtwn_init(struct urtwn_softc *);
+static void urtwn_stop(struct urtwn_softc *);
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);
@@ -339,21 +334,23 @@
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 *);
+// static int urtwn_ioctl(struct ifnet *, u_long, void *);
static void urtwn_parent(struct ieee80211com *);
-static void urtwn_init_channels(struct ieee80211com *);
+static void urtwn_get_radiocaps(struct ieee80211com *, int, int *,
+ struct ieee80211_channel chans[]);
static void urtwn_scan_start(struct ieee80211com *);
static void urtwn_scan_end(struct ieee80211com *);
static void urtwn_set_channel(struct ieee80211com *);
static int urtwn_transmit(struct ieee80211com *, struct mbuf *);
static int urtwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
-//static int urtwn_send_mgmt(struct ieee80211_node *, int, int);
+// static int urtwn_send_mgmt(struct ieee80211_node *, int, int);
+static void urtwn_update_mcast(struct ieee80211com *);
/* Aliases. */
#define urtwn_bb_read urtwn_read_4
-#define urtwn_lookup(d,v,p) ((const struct urtwn_dev *)usb_lookup(d,v,p))
+#define urtwn_lookup(d,v,p) ((const struct urtwn_dev *)usb_lookup(d,v,p))
static const uint16_t addaReg[] = {
R92C_FPGA0_XCD_SWITCHCTL, R92C_BLUETOOTH, R92C_RX_WAIT_CCA,
@@ -363,6 +360,15 @@
R92C_STANDBY, R92C_SLEEP, R92C_PMPD_ANAEN
};
+/*
+ * We ovveride the VAP's newstate method, so need to save the old
+ * function pointer for each VAP.
+ */
+struct urtwn_vap {
+ struct ieee80211vap vap;
+ int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+};
+
static int
urtwn_match(device_t parent, cfdata_t match, void *aux)
{
@@ -387,18 +393,13 @@
sc->sc_dev = self;
sc->sc_udev = uaa->uaa_device;
- /* Name the ic. */
- ic->ic_name = "urtwn";
-
- /* Driver Send queue, separate from the if send queue*/
- sc->sc_sendq.ifq_maxlen = 32;
- /* NNN how should this be initialized? */
- sc->sc_sendq.ifq_head = sc->sc_sendq.ifq_tail = NULL;
- sc->sc_sendq.ifq_len = 0;
- sc->sc_sendq.ifq_drops = 0;
+ /*
+ * Driver Send queue, separate from the (multiple) VAPs
+ * if send queue
+ */
+ sc->sc_sendq.ifq_maxlen = ifqmaxlen;
IFQ_LOCK_INIT(&sc->sc_sendq);
- sc->chip = 0;
dev = urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product);
if (dev != NULL && ISSET(dev->flags, FLAG_RTL8188E))
SET(sc->chip, URTWN_CHIP_88E);
@@ -425,6 +426,7 @@
mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
+ mutex_init(&sc->sc_media_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&sc->sc_state_mtx, MUTEX_DEFAULT, IPL_NONE);
@@ -432,9 +434,7 @@
mutex_enter(&sc->sc_write_mtx);
usb_init_task(&sc->sc_task, urtwn_task, sc, 0);
-/* NNN make these callouts use a vap ... in vap create??? */
- callout_init(&sc->sc_scan_to, 0);
- callout_setfunc(&sc->sc_scan_to, urtwn_next_scan, sc);
+ /* NNN make these callouts use a vap ... in vap create??? */
callout_init(&sc->sc_calib_to, 0);
callout_setfunc(&sc->sc_calib_to, urtwn_calib_to, sc);
@@ -498,27 +498,30 @@
* Setup the 802.11 device.
*/
ic->ic_softc = sc;
+ ic->ic_name = device_xname(self);
ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */
ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */
/* Set device capabilities. */
ic->ic_caps =
+ IEEE80211_C_STA | /* station mode */
IEEE80211_C_MONITOR | /* Monitor mode supported. */
IEEE80211_C_IBSS | /* IBSS mode supported */
IEEE80211_C_HOSTAP | /* HostAp mode supported */
IEEE80211_C_SHPREAMBLE | /* Short preamble supported. */
IEEE80211_C_SHSLOT | /* Short slot time supported. */
+ IEEE80211_C_BGSCAN | /* capable of bg scanning */
IEEE80211_C_WME | /* 802.11e */
IEEE80211_C_WPA; /* 802.11i */
ic->ic_htcaps =
IEEE80211_HTC_HT |
- IEEE80211_HTCAP_SHORTGI20 | /* short GI in 20MHz */
+ IEEE80211_HTCAP_SHORTGI20 | /* short GI in 20MHz */
#if 0
IEEE80211_HTCAP_MAXAMSDU_3839 | /* max A-MSDU length */
#endif
- IEEE80211_HTCAP_SMPS_OFF | /* SM PS mode disabled */
- IEEE80211_HTCAP_CHWIDTH40 | /* 40 MHz channel width */
+ IEEE80211_HTCAP_SMPS_OFF | /* SM PS mode disabled */
+ IEEE80211_HTCAP_CHWIDTH40 | /* 40 MHz channel width */
IEEE80211_HTCAP_SHORTGI40; /* short GI in 40MHz */
#ifdef notyet
@@ -535,20 +538,14 @@
ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-#ifdef should_delete_NNN
- /* Set supported .11b and .11g channels (1 through 14). */
- 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 =
- IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM |
- IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
- }
-#else
- urtwn_init_channels(ic);
-#endif
- /* XXX issues here ... Figure out proper attach and vap creation */
+ /* XXX TODO: setup regdomain if URTW_EPROM_CHANPLAN_BY_HW bit is set.*/
+ urtwn_get_radiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+ ic->ic_channels);
+
+ /*
+ * Initialize the global (non-VAP specific) structures and create
+ * the VAP list.
+ */
ieee80211_ifattach(ic);
/* override default methods NNN Need more here? */
@@ -559,11 +556,13 @@
ic->ic_parent = urtwn_parent;
ic->ic_scan_start = urtwn_scan_start;
ic->ic_scan_end = urtwn_scan_end;
+ ic->ic_getradiocaps = urtwn_get_radiocaps;
ic->ic_set_channel = urtwn_set_channel;
ic->ic_transmit = urtwn_transmit;
// ic->ic_send_mgmt = urtwn_send_mgmt;
ic->ic_raw_xmit = urtwn_raw_xmit;
-
+ ic->ic_update_mcast = urtwn_update_mcast;
+
sc->sc_rxtap_len = sizeof(sc->sc_rxtapu);
sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
sc->sc_rxtap.wr_ihdr.it_present = htole32(URTWN_RX_RADIOTAP_PRESENT);
@@ -579,21 +578,6 @@
SET(sc->sc_flags, URTWN_FLAG_ATTACHED);
- /* Should be called via an IOCTL. Temp call here for now. */
-
- struct ieee80211vap *vap =
- urtwn_vap_create(ic, device_xname(sc->sc_dev),
- device_unit(sc->sc_dev), IEEE80211_M_STA,
- IEEE80211_CLONE_MACADDR, ic->ic_macaddr, ic->ic_macaddr);
-
- if (vap == NULL) {
- /* Didn't work ... now what! */
- printf ("NNN vap_create didn't work ...\n");
- ieee80211_ifdetach(ic);
- goto fail;
- }
- ieee80211_com_vincref(vap);
-
ieee80211_announce(ic);
/* Allocate Tx/Rx buffers. */
@@ -626,7 +610,6 @@
{
struct urtwn_softc *sc = device_private(self);
struct ieee80211com *ic = &sc->sc_ic;
- struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
int s;
Home |
Main Index |
Thread Index |
Old Index