Module Name: src Committed By: phil Date: Fri Aug 3 19:47:25 UTC 2018
Modified Files: src/sys/arch/amd64/conf [phil-wifi]: TESTWIFI src/sys/dev/usb [phil-wifi]: if_urtwn.c src/sys/net80211 [phil-wifi]: ieee80211_ioctl.c ieee80211_netbsd.c ieee80211_netbsd.h ieee80211_node.c ieee80211_proto.c ieee80211_ratectl.h ieee80211_scan_sta.c ieee80211_scan_sw.c ieee80211_sta.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/amd64/conf/TESTWIFI cvs rdiff -u -r1.59.2.4 -r1.59.2.5 src/sys/dev/usb/if_urtwn.c cvs rdiff -u -r1.60.18.5 -r1.60.18.6 src/sys/net80211/ieee80211_ioctl.c cvs rdiff -u -r1.31.2.5 -r1.31.2.6 src/sys/net80211/ieee80211_netbsd.c cvs rdiff -u -r1.21.2.6 -r1.21.2.7 src/sys/net80211/ieee80211_netbsd.h cvs rdiff -u -r1.75.4.3 -r1.75.4.4 src/sys/net80211/ieee80211_node.c cvs rdiff -u -r1.34.14.5 -r1.34.14.6 src/sys/net80211/ieee80211_proto.c cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/net80211/ieee80211_ratectl.h cvs rdiff -u -r1.1.56.5 -r1.1.56.6 src/sys/net80211/ieee80211_scan_sta.c cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/net80211/ieee80211_scan_sw.c \ src/sys/net80211/ieee80211_sta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/amd64/conf/TESTWIFI diff -u src/sys/arch/amd64/conf/TESTWIFI:1.1.2.1 src/sys/arch/amd64/conf/TESTWIFI:1.1.2.2 --- src/sys/arch/amd64/conf/TESTWIFI:1.1.2.1 Thu Jul 12 16:35:33 2018 +++ src/sys/arch/amd64/conf/TESTWIFI Fri Aug 3 19:47:25 2018 @@ -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 @@ include "arch/amd64/conf/std.amd64" 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 @@ options DIAGNOSTIC # inexpensive kernel # 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 @@ options LOCKDEBUG # expensive locking c 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 Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.4 src/sys/dev/usb/if_urtwn.c:1.59.2.5 --- src/sys/dev/usb/if_urtwn.c:1.59.2.4 Sat Jul 28 00:49:43 2018 +++ src/sys/dev/usb/if_urtwn.c Fri Aug 3 19:47:25 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v #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_calib_to_cb(struct urt 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_start(struct ieee 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 @@ urtwn_attach(device_t parent, device_t s 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 @@ urtwn_attach(device_t parent, device_t s (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 @@ urtwn_attach(device_t parent, device_t s 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 @@ urtwn_attach(device_t parent, device_t s 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 @@ urtwn_attach(device_t parent, device_t s 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 @@ urtwn_attach(device_t parent, device_t s /* 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 @@ urtwn_detach(device_t self, int flags) 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 @@ urtwn_alloc_rx_list(struct urtwn_softc * 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 @@ urtwn_alloc_tx_list(struct urtwn_softc * 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 @@ urtwn_alloc_tx_list(struct urtwn_softc * } } 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 @@ urtwn_r88e_read_rom(struct urtwn_softc * 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 @@ urtwn_calib_to(void *arg) 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 @@ urtwn_calib_to_cb(struct urtwn_softc *sc 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 @@ urtwn_newassoc(struct ieee80211_node *ni { 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 @@ urtwn_newstate_cb(struct urtwn_softc *sc /* 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 @@ urtwn_newstate_cb(struct urtwn_softc *sc 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 @@ urtwn_newstate_cb(struct urtwn_softc *sc } #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 @@ urtwn_newstate(struct ieee80211vap *vap, /* 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 @@ urtwn_newstate(struct ieee80211vap *vap, 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 @@ urtwn_rx_frame(struct urtwn_softc *sc, u 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 @@ urtwn_rx_frame(struct urtwn_softc *sc, u } else { /* No node found ... process differently. */ - (void) ieee80211_input_all(ic, m, rssi, 0); + (void) ieee80211_input_all(ic, m, rssi+90, 0); } splx(s); @@ -2961,13 +2954,10 @@ urtwn_txeof(struct usbd_xfer *xfer, void DPRINTFN(DBG_FN|DBG_TX, ("%s: %s: status=%d\n", device_xname(sc->sc_dev), __func__, status)); - printf ("enter sc_tx_mtx, adr is 0x%lx (from txeof)\n", (long)&sc->sc_tx_mtx); mutex_enter(&sc->sc_tx_mtx); /* Put this Tx buffer back to our free list. */ TAILQ_INSERT_TAIL(&sc->tx_free_list[pidx], data, next); mutex_exit(&sc->sc_tx_mtx); - printf ("exit sc_tx_mtx (from txeof)\n"); - s = splnet(); sc->tx_timer = 0; @@ -3007,6 +2997,11 @@ urtwn_tx(struct urtwn_softc *sc, struct DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); + KASSERT(sc != NULL); // NNN + KASSERT(m != NULL); + KASSERT(ni != NULL); + KASSERT(data != NULL); + wh = mtod(m, struct ieee80211_frame *); type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; txd_len = sizeof(*txd); @@ -3014,8 +3009,7 @@ urtwn_tx(struct urtwn_softc *sc, struct if (!ISSET(sc->chip, URTWN_CHIP_92EU)) txd_len = 32; -#define IEEE80211_FC1_WEP 1 /* NNN need to find where we know there is WEP */ - if (wh->i_fc[1] & IEEE80211_FC1_WEP) { + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { k = ieee80211_crypto_encap(ni, m); if (k == NULL) return ENOBUFS; @@ -3024,14 +3018,13 @@ urtwn_tx(struct urtwn_softc *sc, struct wh = mtod(m, struct ieee80211_frame *); } - if (__predict_false(sc->sc_drvbpf != NULL)) { struct urtwn_tx_radiotap_header *tap = &sc->sc_txtap; tap->wt_flags = 0; tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq); tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags); - if (wh->i_fc[1] & IEEE80211_FC1_WEP) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; /* XXX: set tap->wt_rate? */ @@ -3059,6 +3052,7 @@ urtwn_tx(struct urtwn_softc *sc, struct /* Fill Tx descriptor. */ txd = (struct r92c_tx_desc *)data->buf; + KASSERT(txd != NULL); // NNN memset(txd, 0, txd_len + padsize); txd->txdw0 |= htole32( @@ -3183,6 +3177,8 @@ urtwn_tx(struct urtwn_softc *sc, struct xferlen = txd_len + m->m_pkthdr.len + padsize; m_copydata(m, 0, m->m_pkthdr.len, (char *)&txd[0] + txd_len + padsize); + printf ("urtwn_tx just before splnet()\n"); + KASSERT(data != NULL); s = splnet(); usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, URTWN_TX_TIMEOUT, @@ -3196,6 +3192,7 @@ urtwn_tx(struct urtwn_softc *sc, struct return error; } splx(s); + printf ("urtwn_tx just before splnet()\n"); return 0; } @@ -3204,14 +3201,12 @@ urtwn_get_tx_data(struct urtwn_softc *sc { struct urtwn_tx_data *data = NULL; - printf ("enter sc_tx_mtx, adr is 0x%lx (from tx_data)\n", (long)&sc->sc_tx_mtx); mutex_enter(&sc->sc_tx_mtx); if (!TAILQ_EMPTY(&sc->tx_free_list[pidx])) { data = TAILQ_FIRST(&sc->tx_free_list[pidx]); TAILQ_REMOVE(&sc->tx_free_list[pidx], data, next); } mutex_exit(&sc->sc_tx_mtx); - printf ("exit sc_tx_mtx (from tx_data)\n"); return data; } @@ -3355,8 +3350,6 @@ urtwn_vap_create(struct ieee80211com *ic 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; @@ -3390,8 +3383,9 @@ urtwn_vap_create(struct ieee80211com *ic memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); /* Override state transition machine. */ - // sc->sc_newstate = vap->iv_newstate; - // vap->iv_newstate = urtwn_newstate; + /* NNN --- many possible newstate machines ... issue! */ + sc->sc_newstate = vap->iv_newstate; + vap->iv_newstate = urtwn_newstate; /* Finish setup */ ieee80211_vap_attach(vap, urtwn_media_change, @@ -3429,21 +3423,93 @@ urtwn_parent(struct ieee80211com *ic) static void urtwn_scan_start(struct ieee80211com *ic) { - struct urtwn_softc *sc __unused = ic->ic_softc; + struct urtwn_softc *sc = ic->ic_softc; + //uint32_t reg; + //int s; DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__)); - /* Not sure what to do here yet. */ + /* + * Not sure what to do here yet. Try #1: do what was in the + * state machine. NNN + */ +#if NOTWITHSTATEMACHINEOVERRIDE + /* + * Begin of scanning + */ + + s = splnet(); + mutex_enter(&sc->sc_write_mtx); + + /* Set gain for scanning. */ + reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20); + urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg); + + if (!ISSET(sc->chip, URTWN_CHIP_88E)) { + reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1)); + reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20); + urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg); + } + + /* Set media status to 'No Link'. */ + urtwn_set_nettype0_msr(sc, R92C_CR_NETTYPE_NOLINK); + + /* Allow Rx from any BSSID. */ + urtwn_write_4(sc, R92C_RCR, + urtwn_read_4(sc, R92C_RCR) & + ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN)); + + /* Stop Rx of data frames. */ + urtwn_write_2(sc, R92C_RXFLTMAP2, 0); + + /* Disable update TSF */ + urtwn_write_1(sc, R92C_BCN_CTRL, + urtwn_read_1(sc, R92C_BCN_CTRL) | + R92C_BCN_CTRL_DIS_TSF_UDT0); + + /* Make link LED blink during scan. */ + urtwn_set_led(sc, URTWN_LED_LINK, !sc->ledlink); + + /* Pause AC Tx queues. */ + urtwn_write_1(sc, R92C_TXPAUSE, + urtwn_read_1(sc, R92C_TXPAUSE) | 0x0f); + + urtwn_set_chan(sc, ic->ic_curchan, + IEEE80211_HTINFO_2NDCHAN_NONE); + + mutex_exit(&sc->sc_write_mtx); + splx(s); +#endif } static void urtwn_scan_end(struct ieee80211com *ic) { - struct urtwn_softc *sc __unused = ic->ic_softc; + struct urtwn_softc *sc = ic->ic_softc; DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__)); - /* Not sure what to do here yet. */ +#ifdef NOTWITHSTATEMACHINEOVERRIDE + /* + * End of scanning + */ + + mutex_enter(&sc->sc_write_mtx); + + /* flush 4-AC Queue after site_survey */ + urtwn_write_1(sc, R92C_TXPAUSE, 0x0); + + /* Allow Rx from our BSSID only. */ + urtwn_write_4(sc, R92C_RCR, + urtwn_read_4(sc, R92C_RCR) | + R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN); + + /* Turn link LED off. */ + urtwn_set_led(sc, URTWN_LED_LINK, 0); + + mutex_exit(&sc->sc_write_mtx); +#endif } static void @@ -3490,6 +3556,14 @@ out: return error; } +static __unused int urtwn_send_mgmt(struct ieee80211_node *ni, int type, int arg) +{ + printf ("urtwn_send_mgmt: type %d, arg %d\n", type, arg); + return ENOENT; +} + + + static int urtwn_raw_xmit(struct ieee80211_node *ni , struct mbuf *m, const struct ieee80211_bpf_params *bpfp) @@ -3502,6 +3576,11 @@ urtwn_raw_xmit(struct ieee80211_node *ni DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__)); + KASSERT(vap != NULL); // NNN need these? + KASSERT(ic != NULL); + KASSERT(sc != NULL); + KASSERT(m != NULL); + data = urtwn_get_tx_data(sc, sc->ac2idx[WME_AC_VO]); if (data == NULL) { @@ -3517,6 +3596,9 @@ urtwn_raw_xmit(struct ieee80211_node *ni if (error != 0) { printf("ERROR3\n"); vap->iv_ifp->if_oerrors++; + } else { + sc->tx_timer = 5; + vap->iv_ifp->if_timer = 1; } m_freem(m); ieee80211_free_node(ni); @@ -3561,14 +3643,11 @@ urtwn_ioctl(struct ifnet *ifp, u_long cm break; switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) { case IFF_UP | IFF_RUNNING: - printf (" up and running...\n"); break; case IFF_UP: - printf (" just up ... will start\n"); urtwn_init(ifp); break; case IFF_RUNNING: - printf (" just running .. will stop\n"); urtwn_stop(ifp, 1); break; case 0: @@ -4109,12 +4188,12 @@ urtwn_load_firmware(struct urtwn_softc * if (ISSET(sc->chip, URTWN_CHIP_88E) || ISSET(sc->chip, URTWN_CHIP_92EU)) urtwn_r88e_fw_reset(sc); - for (ntries = 0; ntries < 1000; ntries++) { + for (ntries = 0; ntries < 1500; ntries++) { if (urtwn_read_4(sc, R92C_MCUFWDL) & R92C_MCUFWDL_WINTINI_RDY) break; DELAY(5); } - if (ntries == 1000) { + if (ntries == 1500) { aprint_error_dev(sc->sc_dev, "timeout waiting for firmware readiness\n"); error = ETIMEDOUT; @@ -5538,6 +5617,9 @@ urtwn_init(struct ifnet *ifp) ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); urtwn_wait_async(sc); + /* Init the rest of the 802.11 stuff */ + ieee80211_init(ifp); + return 0; fail: Index: src/sys/net80211/ieee80211_ioctl.c diff -u src/sys/net80211/ieee80211_ioctl.c:1.60.18.5 src/sys/net80211/ieee80211_ioctl.c:1.60.18.6 --- src/sys/net80211/ieee80211_ioctl.c:1.60.18.5 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_ioctl.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_ioctl.c,v 1.60.18.5 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_ioctl.c,v 1.60.18.6 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -3537,6 +3537,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_lon // struct ieee80211_nwkey *nwkey; // struct ieee80211_power *power; // struct ieee80211chanreq *chanreq; + struct ieee80211_bssid *bssid; ifr = (struct ifreq *)data; #endif @@ -3665,7 +3666,11 @@ ieee80211_ioctl(struct ifnet *ifp, u_lon case AF_INET: if ((ifp->if_flags & IFF_UP) == 0) { ifp->if_flags |= IFF_UP; +#if __FreeBSD__ ifp->if_init(ifp->if_softc); +#elif __NetBSD__ + ifp->if_init(ifp); +#endif } arp_ifinit(ifp, ifa); break; @@ -3673,7 +3678,11 @@ ieee80211_ioctl(struct ifnet *ifp, u_lon default: if ((ifp->if_flags & IFF_UP) == 0) { ifp->if_flags |= IFF_UP; +#if __FreeBSD__ ifp->if_init(ifp->if_softc); +#elif __NetBSD__ + ifp->if_init(ifp); +#endif } break; } @@ -3709,13 +3718,47 @@ ieee80211_ioctl(struct ifnet *ifp, u_lon break; case SIOCS80211NWKEY: case SIOCG80211NWKEY: - printf ("NetBSD NWKEY ioctl\n"); + printf ("NetBSD NWKEY ioctl\n"); // NNN error = ENOTTY; break; case SIOCS80211POWER: - printf ("NEtBSD POWER ioctl\n"); + printf ("NetBSD POWER ioctl\n"); // NNN error = ENOTTY; break; + case SIOCS80211BSSID: + bssid = (struct ieee80211_bssid *)data; + IEEE80211_ADDR_COPY(vap->iv_des_bssid, bssid->i_bssid); + if (IEEE80211_ADDR_EQ(vap->iv_des_bssid, zerobssid)) + vap->iv_flags &= ~IEEE80211_F_DESBSSID; + else + vap->iv_flags |= IEEE80211_F_DESBSSID; + error = ENETRESET; + break; + case SIOCG80211BSSID: + bssid = (struct ieee80211_bssid *)data; + switch (vap->iv_state) { + case IEEE80211_S_RUN: + case IEEE80211_S_SLEEP: + IEEE80211_ADDR_COPY(bssid->i_bssid, + vap->iv_opmode == IEEE80211_M_WDS ? + vap->iv_bss->ni_macaddr : vap->iv_bss->ni_bssid); + break; + case IEEE80211_S_INIT: + case IEEE80211_S_SCAN: + if (vap->iv_opmode == IEEE80211_M_HOSTAP) + IEEE80211_ADDR_COPY(bssid->i_bssid, + vap->iv_myaddr); + else if (vap->iv_flags & IEEE80211_F_DESBSSID) + IEEE80211_ADDR_COPY(bssid->i_bssid, + vap->iv_des_bssid); + else + memset(bssid->i_bssid, 0, IEEE80211_ADDR_LEN); + + break; + default: + memset(bssid->i_bssid, 0, IEEE80211_ADDR_LEN); + } + break; #endif default: /* Index: src/sys/net80211/ieee80211_netbsd.c diff -u src/sys/net80211/ieee80211_netbsd.c:1.31.2.5 src/sys/net80211/ieee80211_netbsd.c:1.31.2.6 --- src/sys/net80211/ieee80211_netbsd.c:1.31.2.5 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_netbsd.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.5 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.6 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -29,7 +29,7 @@ #include <sys/cdefs.h> /* __FBSDID("$FreeBSD$"); */ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.5 2018/07/28 00:49:43 phil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.6 2018/08/03 19:47:25 phil Exp $"); /* * IEEE 802.11 support (NetBSD-specific code) @@ -87,16 +87,21 @@ ieee80211_init0(void) } /* - * "taskqueue" support + * "taskqueue" support for doing FreeBSD style taskqueue operations using + * NetBSD's workqueue to do the actual function calls for the work. + * Many features of the FreeBSD taskqueue are not implemented. This should + * be enough features for the 802.11 stack to run its tasks and time delayed + * tasks. */ -void ieee80211_runwork(struct work *work2do, void *arg) + +void +ieee80211_runwork(struct work *work2do, void *arg) { struct task *work_task = (struct task *) work2do; - printf ("runwork called! work2do is 0x%lx, t_work.wk_dummy is 0x%lx\n", - (long) work2do, (long)work_task->t_work.wk_dummy); - printf (" runwork: t_func is 0x%lx, t_arg is 0x%lx\n", - (long)work_task->t_func, (long)work_task->t_arg); - +#ifdef IEEE80211_DEBUG + printf ("runwork: %s (t_arg is 0x%lx)\n", + work_task->t_func_name, (long)work_task->t_arg); +#endif mutex_enter(&work_task->t_mutex); work_task->t_onqueue = 0; mutex_exit(&work_task->t_mutex); @@ -104,24 +109,68 @@ void ieee80211_runwork(struct work *work work_task->t_func(work_task->t_arg, 0); } -void taskqueue_enqueue(struct workqueue *wq, struct task *task_item) +void +taskqueue_enqueue(struct workqueue *wq, struct task *task_item) { - printf ("taskqueue_enqueue called\n"); mutex_enter(&task_item->t_mutex); if (!task_item->t_onqueue) { - printf (" taskqueue_enqueue adding item to workqueue\n"); + printf ("taskqueue_enqueue function %s\n", task_item->t_func_name); workqueue_enqueue(wq, &task_item->t_work, NULL); task_item->t_onqueue = 1; } mutex_exit(&task_item->t_mutex); } -void taskqueue_drain(struct workqueue *wq, struct task *task_item) +void +taskqueue_drain(struct workqueue *wq, struct task *task_item) { printf ("taskqueue_drain called\n"); workqueue_wait(wq, &task_item->t_work); } +static void +taskqueue_callout_enqueue(void *arg) +{ + struct timeout_task *timeout_task = arg; + mutex_enter(&timeout_task->to_task.t_mutex); + timeout_task->to_scheduled = 0; + mutex_exit(&timeout_task->to_task.t_mutex); + + taskqueue_enqueue(timeout_task->to_wq, (struct task*) timeout_task); +} + +int +taskqueue_enqueue_timeout(struct workqueue *queue, + struct timeout_task *timeout_task, int nticks) +{ + mutex_enter(&timeout_task->to_task.t_mutex); + if (!timeout_task->to_scheduled) { + printf ("taskqueue_enqueue_timeout: Scheduling the function %s.\n", + timeout_task->to_task.t_func_name); + callout_reset(&timeout_task->to_callout, nticks, + taskqueue_callout_enqueue, timeout_task); + timeout_task->to_scheduled = 1; + } + mutex_exit(&timeout_task->to_task.t_mutex); + + return -1; +} + +int +taskqueue_cancel_timeout(struct workqueue *queue, + struct timeout_task *timeout_task, u_int *pendp) +{ + printf ("taskqueue_cancel_timeout called\n"); + return -1; +} + +void +taskqueue_drain_timeout(struct workqueue *queue, + struct timeout_task *timeout_task) +{ + printf ("taskqueue_drain_timeout called\n"); +} + static __unused int wlan_clone_create(struct if_clone *ifc, int unit, void * params) @@ -832,7 +881,7 @@ static void notify_macaddr(struct ifnet *ifp, int op, const uint8_t mac[IEEE80211_ADDR_LEN]) { struct ieee80211_join_event iev; - + printf ("NNN notify_macaddr called\n"); CURVNET_SET(ifp->if_vnet); memset(&iev, 0, sizeof(iev)); IEEE80211_ADDR_COPY(iev.iev_addr, mac); @@ -1096,7 +1145,7 @@ static eventhandler_tag wlan_ifllevent; static void bpf_track(void *arg, struct ifnet *ifp, int dlt, int attach) { - /* NB: identify vap's by if_init */ + /* NB: identify vap's by if_init */ // NNN won't work with urtwn ... if (dlt == DLT_IEEE802_11_RADIO && ifp->if_init == ieee80211_init) { struct ieee80211vap *vap = ifp->if_softc; @@ -1125,7 +1174,7 @@ bpf_track(void *arg, struct ifnet *ifp, static void wlan_iflladdr(void *arg __unused, struct ifnet *ifp) { - /* NB: identify vap's by if_init */ + /* NB: identify vap's by if_init */ // NNN wont work on urtwn if (ifp->if_init == ieee80211_init && (ifp->if_flags & IFF_UP) == 0) { struct ieee80211vap *vap = ifp->if_softc; Index: src/sys/net80211/ieee80211_netbsd.h diff -u src/sys/net80211/ieee80211_netbsd.h:1.21.2.6 src/sys/net80211/ieee80211_netbsd.h:1.21.2.7 --- src/sys/net80211/ieee80211_netbsd.h:1.21.2.6 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_netbsd.h Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_netbsd.h,v 1.21.2.6 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_netbsd.h,v 1.21.2.7 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -78,48 +78,71 @@ typedef void task_fn_t(void *context, int pending); +// NNN use more standard feature for getting pointers from fields ...??? struct task { - /* some kind of queue entry? */ - struct work t_work; + struct work t_work; /* Must be first so we can cast a work to a task */ task_fn_t *t_func; void *t_arg; kmutex_t t_mutex; int t_onqueue; + const char *t_func_name; }; +struct timeout_task { + struct task to_task; /* Must be first so we can cast to a task. */ + struct workqueue *to_wq; + callout_t to_callout; + int to_scheduled; +}; + + static __inline int dummy(void); static __inline int dummy(void) { return 0; } -struct timeout_task { int needsWork; }; - void ieee80211_runwork(struct work *, void *); void taskqueue_enqueue(struct workqueue *, struct task *); void taskqueue_drain(struct workqueue *, struct task *); +int taskqueue_enqueue_timeout(struct workqueue *queue, + struct timeout_task *timeout_task, int nticks); +int taskqueue_cancel_timeout(struct workqueue *queue, + struct timeout_task *timeout_task, u_int *pendp); +void taskqueue_drain_timeout(struct workqueue *queue, + struct timeout_task *timeout_task); + +/* NNN ---- Need to add a way to mutex_destroy at the right time. */ + #define TASK_INIT(var, pri, func, arg) do { \ (var)->t_func = func; \ (var)->t_arg = arg; \ - (var)->t_work.wk_dummy = var; \ mutex_init(&(var)->t_mutex, MUTEX_DEFAULT, IPL_SOFTNET);\ (var)->t_onqueue = 0;\ + (var)->t_func_name = #func; \ } while(0) +#define TIMEOUT_TASK_INIT(queue, task, pri, func, arg) do { \ + (task)->to_task.t_func = func; \ + (task)->to_task.t_arg = arg; \ + mutex_init(&(task)->to_task.t_mutex, MUTEX_DEFAULT, IPL_SOFTNET);\ + (task)->to_task.t_onqueue = 0;\ + (task)->to_task.t_func_name = #func; \ + (task)->to_wq = queue;\ + callout_init(&(task)->to_callout, CALLOUT_MPSAFE);\ + (task)->to_scheduled = 0;\ +} while (0) + #define taskqueue workqueue #define taskqueue_free(queue) workqueue_destroy(queue) #define taskqueue_block(queue) /* */ #define taskqueue_unblock(queue) /* */ -#define taskqueue_drain_timeout(queue, x) /* */ -#define taskqueue_enqueue_timeout(queue, x, y) { int __unused zzz = 0; } -#define taskqueue_cancel_timeout(queue, x, y) dummy() -#define TIMEOUT_TASK_INIT(queue, a2, a3, a4, a5) /* */ /* Other stuff that needs to be fixed NNN */ #define priv_check(x,y) 1 -/* Coult it be this simple? */ +/* Coult it be this simple? NNN */ #define if_addr_rlock(ifp) IFNET_LOCK(ifp) -#define if_addr_runlock(x) IFNET_UNLOCK(ifp) +#define if_addr_runlock(ifp) IFNET_UNLOCK(ifp) /* VNET defines to remove them ... NNN may need a lot of work! */ Index: src/sys/net80211/ieee80211_node.c diff -u src/sys/net80211/ieee80211_node.c:1.75.4.3 src/sys/net80211/ieee80211_node.c:1.75.4.4 --- src/sys/net80211/ieee80211_node.c:1.75.4.3 Mon Jul 16 20:11:11 2018 +++ src/sys/net80211/ieee80211_node.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_node.c,v 1.75.4.3 2018/07/16 20:11:11 phil Exp $ */ +/* $NetBSD: ieee80211_node.c,v 1.75.4.4 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -916,7 +916,8 @@ ieee80211_sta_join1(struct ieee80211_nod * mode is locked. */ ieee80211_reset_erp(ic); - ieee80211_wme_initparams(vap); + IEEE80211_UNLOCK(ic); // NNN BUG??? -- + ieee80211_wme_initparams(vap); if (vap->iv_opmode == IEEE80211_M_STA) { if (canreassoc) { @@ -934,6 +935,7 @@ ieee80211_sta_join1(struct ieee80211_nod } } else ieee80211_new_state(vap, IEEE80211_S_RUN, -1); + IEEE80211_LOCK(ic); // NNN BUG ??? --- unlock for full function? return 1; } @@ -1457,9 +1459,7 @@ ieee80211_alloc_node(struct ieee80211_no IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni, "%s: inact_reload %u", __func__, ni->ni_inact_reload); - printf ("before ratectl_node_init call\n"); ieee80211_ratectl_node_init(ni); - printf ("after ratectl_node_init\n"); return ni; } Index: src/sys/net80211/ieee80211_proto.c diff -u src/sys/net80211/ieee80211_proto.c:1.34.14.5 src/sys/net80211/ieee80211_proto.c:1.34.14.6 --- src/sys/net80211/ieee80211_proto.c:1.34.14.5 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_proto.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_proto.c,v 1.34.14.5 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_proto.c,v 1.34.14.6 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -371,6 +371,7 @@ ieee80211_proto_vattach(struct ieee80211 callout_init(&vap->iv_mgtsend, 1); #elif __NetBSD__ /* NNN need to do something with iv_swbmiss ... */ + callout_init(&vap->iv_swbmiss, CALLOUT_MPSAFE); callout_init(&vap->iv_mgtsend, CALLOUT_MPSAFE); #endif TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap); @@ -1156,7 +1157,7 @@ ieee80211_wme_initparams_locked(struct i wme->wme_hipri_switch_thresh = (HIGH_PRI_SWITCH_THRESH * vap->iv_bss->ni_intval) / 100; wme->wme_flags &= ~WME_F_AGGRMODE; - ieee80211_wme_updateparams(vap); + ieee80211_wme_updateparams_locked(vap); // BUG ??? } } @@ -1658,6 +1659,7 @@ ieee80211_init(struct ifnet *ifp) IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG, "%s\n", __func__); + printf ("ieee80211_init called.\n"); // NNN RUN_ONCE(&ieee80211_init_once, ieee80211_init0); @@ -1865,7 +1867,11 @@ ieee80211_swbmiss(void *arg) struct ieee80211vap *vap = arg; struct ieee80211com *ic = vap->iv_ic; +#if __FreeBSD__ IEEE80211_LOCK_ASSERT(ic); +#elif __NetBSD__ + IEEE80211_LOCK(ic); +#endif KASSERT(vap->iv_state >= IEEE80211_S_RUN, ("wrong state %d", vap->iv_state)); @@ -1889,6 +1895,10 @@ ieee80211_swbmiss(void *arg) vap->iv_swbmiss_count = 0; callout_reset(&vap->iv_swbmiss, vap->iv_swbmiss_period, ieee80211_swbmiss, vap); + +#if __NetBSD__ + IEEE80211_UNLOCK(ic); +#endif } /* Index: src/sys/net80211/ieee80211_ratectl.h diff -u src/sys/net80211/ieee80211_ratectl.h:1.1.2.4 src/sys/net80211/ieee80211_ratectl.h:1.1.2.5 --- src/sys/net80211/ieee80211_ratectl.h:1.1.2.4 Mon Jul 16 20:11:11 2018 +++ src/sys/net80211/ieee80211_ratectl.h Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_ratectl.h,v 1.1.2.4 2018/07/16 20:11:11 phil Exp $ */ +/* $NetBSD: ieee80211_ratectl.h,v 1.1.2.5 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -117,9 +117,6 @@ ieee80211_ratectl_node_init(struct ieee8 { const struct ieee80211vap *vap = ni->ni_vap; - printf ("ratectl_node_init, vap->iv_rate is 0x%lx\n", - (unsigned long)vap->iv_rate); - vap->iv_rate->ir_node_init(ni); } Index: src/sys/net80211/ieee80211_scan_sta.c diff -u src/sys/net80211/ieee80211_scan_sta.c:1.1.56.5 src/sys/net80211/ieee80211_scan_sta.c:1.1.56.6 --- src/sys/net80211/ieee80211_scan_sta.c:1.1.56.5 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_scan_sta.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_scan_sta.c,v 1.1.56.5 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_scan_sta.c,v 1.1.56.6 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -263,7 +263,7 @@ sta_add(struct ieee80211_scan_state *ss, const struct ieee80211_frame *wh, int subtype, int rssi, int noise) { - printf ("sta_add called\n"); + printf ("sta_add called, ss_flags 0x%x\n", ss->ss_flags); #define ISPROBE(_st) ((_st) == IEEE80211_FC0_SUBTYPE_PROBE_RESP) #define PICK1ST(_ss) \ ((ss->ss_flags & (IEEE80211_SCAN_PICK1ST | IEEE80211_SCAN_GOTPICK)) == \ @@ -989,6 +989,8 @@ match_ssid(const uint8_t *ie, { int i; + printf ("match_ssid called:;; %s vs %s\n", ie, ssids[0].ssid); + for (i = 0; i < nssid; i++) { if (match_id(ie, ssids[i].ssid, ssids[i].len)) return 1; @@ -1023,6 +1025,7 @@ match_bss(struct ieee80211vap *vap, uint8_t rate; int fail; + printf ("match_bss, iv_opmode is 0x%x\n", vap->iv_opmode); fail = 0; if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan))) fail |= MATCH_CHANNEL; @@ -1193,6 +1196,7 @@ match_bss(struct ieee80211vap *vap, printf("%s\n", fail & (MATCH_SSID | MATCH_MESHID) ? "!" : ""); } #endif + printf ("match_bss exit, fail = 0x%x\n", fail); return fail; } @@ -1264,6 +1268,14 @@ sta_pick_bss(struct ieee80211_scan_state struct sta_entry *selbs; struct ieee80211_channel *chan; + { int i; + printf ("sta_pick_bss called. vap des_ssid %s, scan ssids:", + vap->iv_des_ssid[0].ssid); + for (i=0; i < ss->ss_nssid; i++) + printf ("%s, ", ss->ss_ssid[i].ssid); + printf ("\n"); + } + KASSERT(vap->iv_opmode == IEEE80211_M_STA, ("wrong mode %u", vap->iv_opmode)); Index: src/sys/net80211/ieee80211_scan_sw.c diff -u src/sys/net80211/ieee80211_scan_sw.c:1.1.2.3 src/sys/net80211/ieee80211_scan_sw.c:1.1.2.4 --- src/sys/net80211/ieee80211_scan_sw.c:1.1.2.3 Fri Jul 20 20:33:05 2018 +++ src/sys/net80211/ieee80211_scan_sw.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_scan_sw.c,v 1.1.2.3 2018/07/20 20:33:05 phil Exp $ */ +/* $NetBSD: ieee80211_scan_sw.c,v 1.1.2.4 2018/08/03 19:47:25 phil Exp $ */ /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -633,7 +633,7 @@ scan_mindwell(struct ieee80211_scan_stat scan_signal(ss, 0); } -static __unused void +static void scan_start(void *arg, int pending) { #define ISCAN_REP (ISCAN_MINDWELL | ISCAN_DISCARD) @@ -655,6 +655,7 @@ scan_start(void *arg, int pending) "%s: no channels to scan\n", __func__); scan_done(ss, 1); return; + } /* @@ -714,6 +715,7 @@ end: (ss_priv->ss_iflags & ISCAN_ABORT) || ieee80211_time_after(ticks + ss->ss_mindwell, ss_priv->ss_scanend)) { ss_priv->ss_iflags &= ~ISCAN_RUNNING; + /* scan_end unlocks the IEEE80211_LOCK(ic) */ scan_end(ss, scandone); return; } else Index: src/sys/net80211/ieee80211_sta.c diff -u src/sys/net80211/ieee80211_sta.c:1.1.2.3 src/sys/net80211/ieee80211_sta.c:1.1.2.4 --- src/sys/net80211/ieee80211_sta.c:1.1.2.3 Sat Jul 28 00:49:43 2018 +++ src/sys/net80211/ieee80211_sta.c Fri Aug 3 19:47:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_sta.c,v 1.1.2.3 2018/07/28 00:49:43 phil Exp $ */ +/* $NetBSD: ieee80211_sta.c,v 1.1.2.4 2018/08/03 19:47:25 phil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -188,7 +188,9 @@ sta_beacon_miss(struct ieee80211vap *vap /* * Try to reassociate before scanning for a new ap. */ + IEEE80211_UNLOCK(ic); // NNN FreeBSD BUG? ieee80211_new_state(vap, IEEE80211_S_ASSOC, 1); + IEEE80211_LOCK(ic); // NNN FreeBSD BUG? } else { /* * Somebody else is controlling state changes (e.g. @@ -196,7 +198,9 @@ sta_beacon_miss(struct ieee80211vap *vap * confuse them; just drop into scan mode so they'll * notified of the state change and given control. */ + IEEE80211_UNLOCK(ic); // NNN FreeBSD BUG? ieee80211_new_state(vap, IEEE80211_S_SCAN, 0); + IEEE80211_LOCK(ic); // NNN FreeBSD BUG? } }