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/fb08aa936a33
branches:  phil-wifi
changeset: 850616:fb08aa936a33
user:      phil <phil%NetBSD.org@localhost>
date:      Fri Aug 03 19:47:25 2018 +0000

description:
State Save:
   Scanning works, can see the broadcasts and stations.
   Association appears to work.  (open networks only, no encryption yet.)
   IP traffic doesn't flow yet, not sure where the error is.
   Added back more NetBSD ioctls not in the FreeBSD code.  Still have
      more to go.
   Updated my TESTWIFI kernel config.

diffstat:

 sys/arch/amd64/conf/TESTWIFI      |   10 +-
 sys/dev/usb/if_urtwn.c            |  192 +++++++++++++++++++++++++++----------
 sys/net80211/ieee80211_ioctl.c    |   49 +++++++++-
 sys/net80211/ieee80211_netbsd.c   |   81 ++++++++++++---
 sys/net80211/ieee80211_netbsd.h   |   47 ++++++--
 sys/net80211/ieee80211_node.c     |    8 +-
 sys/net80211/ieee80211_proto.c    |   14 ++-
 sys/net80211/ieee80211_ratectl.h  |    5 +-
 sys/net80211/ieee80211_scan_sta.c |   16 ++-
 sys/net80211/ieee80211_scan_sw.c  |    6 +-
 sys/net80211/ieee80211_sta.c      |    6 +-
 11 files changed, 329 insertions(+), 105 deletions(-)

diffs (truncated from 1155 to 300 lines):

diff -r 799ec7a240b6 -r fb08aa936a33 sys/arch/amd64/conf/TESTWIFI
--- a/sys/arch/amd64/conf/TESTWIFI      Sat Jul 28 00:49:43 2018 +0000
+++ b/sys/arch/amd64/conf/TESTWIFI      Fri Aug 03 19:47:25 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: TESTWIFI,v 1.1.2.1 2018/07/12 16:35:33 phil Exp $
+# $NetBSD: TESTWIFI,v 1.1.2.2 2018/08/03 19:47:25 phil Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.1.2.1 $"
+#ident         "GENERIC-$Revision: 1.1.2.2 $"
 
 maxusers       64              # estimated number of users
 
@@ -100,6 +100,8 @@
                                # XXX to be commented out on release branch
 options        DEBUG           # expensive debugging checks/support
 options        LOCKDEBUG       # expensive locking checks/support
+options                URTWN_DEBUG     # debug the urtwn driver
+options                IEEE80211_DEBUG # debug 802.11 code
 
 #
 # Because gcc omits the frame pointer for any -O level, the line below
@@ -108,9 +110,9 @@
 makeoptions    COPTS="-O2 -fno-omit-frame-pointer"
 options        DDB             # in-kernel debugger
 #options       DDB_COMMANDONENTER="bt" # execute command when ddb is entered
-#options       DDB_ONPANIC=1   # see also sysctl(7): `ddb.onpanic'
+options        DDB_ONPANIC=1   # see also sysctl(7): `ddb.onpanic'
 options        DDB_HISTORY_SIZE=512    # enable history editing in DDB
-#options       KGDB            # remote debugger
+options        KGDB            # remote debugger
 #options       KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
 makeoptions    DEBUG="-g"      # compile full symbol table for CTF
 #options       SYSCALL_STATS   # per syscall counts
diff -r 799ec7a240b6 -r fb08aa936a33 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sat Jul 28 00:49:43 2018 +0000
+++ b/sys/dev/usb/if_urtwn.c    Fri Aug 03 19:47:25 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $   */
+/*     $NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $   */
 /*     $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $       */
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -111,7 +111,7 @@
 #define        DBG_REG         __BIT(6)
 #define        DBG_ALL         0xffffffffU
 /* NNN Reset urtwn_debug to 0 when done debugging. */
-u_int urtwn_debug = DBG_ALL & ~DBG_REG;
+u_int urtwn_debug = DBG_FN;
 #define DPRINTFN(n, s) \
        do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
 #else
@@ -284,7 +284,7 @@
 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 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);
@@ -346,6 +346,7 @@
 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_send_mgmt(struct ieee80211_node *, int, int);
 static int     urtwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
                    const struct ieee80211_bpf_params *);
 static void    urtwn_getradiocaps(struct ieee80211com *, int, int *,
@@ -383,7 +384,7 @@
        char *devinfop;
        const struct urtwn_dev *dev;
        usb_device_request_t req;
-       size_t i;
+       // NNN loop below size_t i;
        int error;
 
        sc->sc_dev = self;
@@ -417,7 +418,6 @@
        (void) usbd_do_request(sc->sc_udev, &req, 0);
 
        mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
-       printf ("sc_tx_mtx INIT, addr 0x%lx\n", (long) &sc->sc_tx_mtx);
        mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
        mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
        mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
@@ -506,6 +506,7 @@
 
        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++) {
@@ -515,6 +516,10 @@
                    IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM |
                    IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
        }
+#else
+       urtwn_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, 
+           ic->ic_channels);
+#endif 
 
        ieee80211_ifattach(ic);
 
@@ -528,21 +533,22 @@
        ic->ic_scan_end = urtwn_scan_end;
        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_getradiocaps = urtwn_getradiocaps;
        
 
-       /* Shouldn't do it, but call vap_create??? */
-       uint8_t bssid[IEEE80211_ADDR_LEN] = {0};
+       /* How should this get called the first time?  Not here? */
+       // 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);
+               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 ("vap_create didn't work ...\n");
+               printf ("NNN vap_create didn't work ...\n");
                ieee80211_ifdetach(ic);
                goto fail;
        }
@@ -550,8 +556,6 @@
        /* Debug all! NNN */
        vap->iv_debug = IEEE80211_MSG_ANY;
 
-       printf ("Initial vap->iv_flags is 0x%lx\n", (long)vap->iv_flags);
-
        bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
            sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
            &sc->sc_drvbpf);
@@ -616,7 +620,6 @@
 
        mutex_destroy(&sc->sc_write_mtx);
        mutex_destroy(&sc->sc_fwcmd_mtx);
-       printf ("sc_tx_mtx destroy\n");
        mutex_destroy(&sc->sc_tx_mtx);
        mutex_destroy(&sc->sc_rx_mtx);
        mutex_destroy(&sc->sc_task_mtx);
@@ -761,7 +764,6 @@
        for (size_t j = 0; j < sc->rx_npipe; j++) {
                TAILQ_INIT(&sc->rx_free_list[j]);
                for (i = 0; i < URTWN_RX_LIST_COUNT; i++) {
-                       printf ("alloc rx_data[%ld][%ld]\n", j, i);
                        data = &sc->rx_data[j][i];
 
                        data->sc = sc;  /* Backpointer for callbacks. */
@@ -811,7 +813,6 @@
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
-       printf ("enter sc_tx_mtx, adr is 0x%lx\n", (long)&sc->sc_tx_mtx);
        mutex_enter(&sc->sc_tx_mtx);
        for (size_t j = 0; j < sc->tx_npipe; j++) {
                TAILQ_INIT(&sc->tx_free_list[j]);
@@ -837,14 +838,11 @@
                }
        }
        mutex_exit(&sc->sc_tx_mtx);
-       printf ("exit sc_tx_mtx\n");
        return 0;
 
  fail:
        urtwn_free_tx_list(sc);
        mutex_exit(&sc->sc_tx_mtx);
-       printf ("exit sc_tx_mtx\n");
-       printf ("Out of urtwn_alloc_tx_list with error.\n");
        return error;
 }
 
@@ -1537,6 +1535,8 @@
        mutex_exit(&sc->sc_write_mtx);
 }
 
+/*  NNN  Do we need to do something with this?  */
+
 static __unused int
 urtwn_media_change(struct ifnet *ifp)
 {
@@ -1808,7 +1808,6 @@
                return;
 
        /* Do it in a process context. */
-       printf ("Doing a urtwn_calib_to via do_async...\n");
        urtwn_do_async(sc, urtwn_calib_to_cb, vap, sizeof(struct ieee80211vap *));
 }
 
@@ -1859,7 +1858,7 @@
 static void
 urtwn_next_scan(void *arg)
 {
-       printf ("urtwn_next_scan called....\n");
+       printf ("NNN urtwn_next_scan called....\n");
 #ifdef notyet
        struct urtwn_softc *sc = arg;
        int s;
@@ -1881,6 +1880,7 @@
 {
        DPRINTFN(DBG_FN, ("%s: new node %s\n", __func__,
            ether_sprintf(ni->ni_macaddr)));
+
        /* start with lowest Tx rate */
        ni->ni_txrate = 0;
 }
@@ -2053,7 +2053,6 @@
                /* Start periodic scan. */
                if (!sc->sc_dying)
                        callout_schedule(&sc->sc_scan_to, hz / 5);
-               printf ("Finished to scan code\n");
                break;
 
        case IEEE80211_S_AUTH:
@@ -2083,8 +2082,7 @@
        case IEEE80211_S_ASSOC:
                break;
 
-       case IEEE80211_S_RUN:
-               printf ("if_urtwn: going to new state S_RUN\n");
+       case IEEE80211_S_RUN:       
                ni = vap->iv_bss;
 
                /* XXX: Set 20MHz mode */
@@ -2220,7 +2218,7 @@
 }
 #endif
 
-static __unused int
+static int
 urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
        struct urtwn_softc *sc = vap->iv_ic->ic_softc;
@@ -2366,7 +2364,6 @@
                /* Start periodic scan. */
                if (!sc->sc_dying)
                        callout_schedule(&sc->sc_scan_to, hz / 5);
-               printf ("Finished to scan code\n");
                break;
 
        case IEEE80211_S_AUTH:
@@ -2397,7 +2394,6 @@
                break;
 
        case IEEE80211_S_RUN:
-               printf ("if_urtwn: going to new state S_RUN\n");
                ni = vap->iv_bss;
 
                /* XXX: Set 20MHz mode */
@@ -2836,19 +2832,16 @@
 
        ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
 
-       printf ("urtwn rx_frame, ni is 0x%lx.\n", (long)ni);
        if (ni != NULL) {
-               printf ("  ... and vap = 0x%lx\n", (long)ni->ni_vap);
                if (ni->ni_vap != NULL) {
-                       printf ("  ... and iv_input = 0x%lx\n", (long)ni->ni_vap->iv_input);
 
                } else {
-                       printf ("iv_input is null, not continuing.\n");
                        splx(s);
                        return;
                }
                /* push the frame up to the 802.11 stack */
-               ieee80211_input(ni, m, rssi, 0);
+               /* NNN Convert rssi to -10 to 110 ? for 802.11 layer */
+               ieee80211_input(ni, m, rssi+90, 0);
 
                /* Node is no longer needed. */
                ieee80211_free_node(ni);
@@ -2856,7 +2849,7 @@
        } else {
 
                /* No node found ... process differently. */
-               (void) ieee80211_input_all(ic, m, rssi, 0);
+               (void) ieee80211_input_all(ic, m, rssi+90, 0);



Home | Main Index | Thread Index | Old Index