Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev Remove VAP hack used for early bringup



details:   https://anonhg.NetBSD.org/src-all/rev/a4f60d94759f
branches:  trunk
changeset: 367065:a4f60d94759f
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/pci/if_iwm.c      |   14 +-
 sys/dev/usb/if_urtwn.c    |  608 +++++++++++++++++----------------------------
 sys/dev/usb/if_urtwnvar.h |    7 +-
 3 files changed, 239 insertions(+), 390 deletions(-)

diffs (truncated from 1378 to 300 lines):

diff -r cb163b38315f -r a4f60d94759f sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Thu Sep 24 13:02:27 2020 +1000
+++ b/sys/dev/pci/if_iwm.c      Fri Sep 25 19:35:32 2020 +0200
@@ -1934,7 +1934,7 @@
        struct ether_header *eh;
        int ac;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
+       DPRINTFN(3, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 
        KASSERT(vap != NULL);   /*  NNN need these? */
        KASSERT(ic != NULL);
@@ -1978,7 +1978,7 @@
        size_t pktlen = m->m_pkthdr.len;
         bool mcast = (m->m_flags & M_MCAST) != 0;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
+       DPRINTFN(3, ("%s: %s\n",ic->ic_name, __func__));
 
        s = splnet();
 
@@ -8460,9 +8460,9 @@
 static void
 iwm_parent(struct ieee80211com *ic)
 {
-       struct iwn_softc *sc __unused = ic->ic_softc;
-
-       DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
+       struct iwm_softc *sc __unused = ic->ic_softc;
+
+       DPRINTFN(3, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 
        /* Not sure what to do here yet. */
 } 
@@ -8477,7 +8477,7 @@
        struct ieee80211vap *vap;
        struct ifnet *ifp;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+       DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
        /* Allow only one VAP for the iwm driver. */
        if (!TAILQ_EMPTY(&ic->ic_vaps))
@@ -8530,7 +8530,7 @@
        struct ifnet *ifp = vap->iv_ifp;
        struct iwm_softc *sc __unused =vap->iv_ic->ic_softc;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+       DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
        iwm_stop(ifp, 0);
        ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
diff -r cb163b38315f -r a4f60d94759f 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),
@@ -256,8 +255,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);
@@ -265,7 +264,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 *);
@@ -276,7 +275,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);
@@ -284,10 +282,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);
@@ -300,8 +296,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 *);
@@ -329,9 +325,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);
@@ -342,21 +337,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,
@@ -366,6 +363,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)
 {
@@ -390,18 +396,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);
@@ -428,6 +429,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);
@@ -435,9 +437,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);
 
@@ -501,27 +501,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
@@ -538,20 +541,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);



Home | Main Index | Thread Index | Old Index