CVS commit: [phil-wifi] src/sys/net80211

2020-04-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Apr 27 07:45:57 UTC 2020

Modified Files:
src/sys/net80211 [phil-wifi]: ieee80211_ioctl.c

Log Message:
Pass the error through to the hardware to initialize.


To generate a diff of this commit:
cvs rdiff -u -r1.60.18.9 -r1.60.18.10 src/sys/net80211/ieee80211_ioctl.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/net80211/ieee80211_ioctl.c
diff -u src/sys/net80211/ieee80211_ioctl.c:1.60.18.9 src/sys/net80211/ieee80211_ioctl.c:1.60.18.10
--- src/sys/net80211/ieee80211_ioctl.c:1.60.18.9	Mon Apr 13 08:05:16 2020
+++ src/sys/net80211/ieee80211_ioctl.c	Mon Apr 27 07:45:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ioctl.c,v 1.60.18.9 2020/04/13 08:05:16 martin Exp $	*/
+/*	$NetBSD: ieee80211_ioctl.c,v 1.60.18.10 2020/04/27 07:45:57 nat Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #include 
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.60.18.9 2020/04/13 08:05:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.60.18.10 2020/04/27 07:45:57 nat Exp $");
 #endif
 
 /*
@@ -3638,11 +3638,11 @@ ieee80211_ioctl_set80211(struct ieee8021
 		if (IS_UP_AUTO(vap))
 #if __FreeBSD__
 			ieee80211_init(vap);
+		error = 0;
 #elif __NetBSD__
 			/* arg is a vap in 802.11 code */ 
 			ieee80211_init((struct ifnet *)vap);
 #endif
-		error = 0;
 	}
 	return error;
 }



CVS commit: [phil-wifi] src/sys/net80211

2020-04-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Apr 27 07:40:50 UTC 2020

Modified Files:
src/sys/net80211 [phil-wifi]: ieee80211_sta.c

Log Message:
Make ostate reflect the updated state.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 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/net80211/ieee80211_sta.c
diff -u src/sys/net80211/ieee80211_sta.c:1.1.2.6 src/sys/net80211/ieee80211_sta.c:1.1.2.7
--- src/sys/net80211/ieee80211_sta.c:1.1.2.6	Mon Jun 10 22:09:46 2019
+++ src/sys/net80211/ieee80211_sta.c	Mon Apr 27 07:40:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_sta.c,v 1.1.2.6 2019/06/10 22:09:46 christos Exp $ */
+/*	$NetBSD: ieee80211_sta.c,v 1.1.2.7 2020/04/27 07:40:50 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,7 +29,7 @@
 
 #include 
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_sta.c,v 1.1.2.6 2019/06/10 22:09:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_sta.c,v 1.1.2.7 2020/04/27 07:40:50 nat Exp $");
 #endif
 
 
@@ -298,6 +298,7 @@ sta_newstate(struct ieee80211vap *vap, e
 		default:
 			break;
 		}
+		ostate = vap->iv_state;
 		if (ostate != IEEE80211_S_INIT) {
 			/* NB: optimize INIT -> INIT case */
 			ieee80211_reset_bss(vap);
@@ -464,6 +465,7 @@ sta_newstate(struct ieee80211vap *vap, e
 			goto invalid;
 		}
 		ieee80211_sync_curchan(ic);
+		ostate = vap->iv_state;
 		if (ostate != IEEE80211_S_RUN)
 			sta_swbmiss_start(vap);
 		/*



CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Apr 27 07:38:25 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Software crypto definitions from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.17 -r1.59.2.18 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.17 src/sys/dev/usb/if_urtwn.c:1.59.2.18
--- src/sys/dev/usb/if_urtwn.c:1.59.2.17	Mon Apr 27 07:37:01 2020
+++ src/sys/dev/usb/if_urtwn.c	Mon Apr 27 07:38:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.17 2020/04/27 07:37:01 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.18 2020/04/27 07:38:25 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.17 2020/04/27 07:37:01 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.18 2020/04/27 07:38:25 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -527,6 +527,11 @@ urtwn_attach(device_t parent, device_t s
 	IEEE80211_HTCAP_SHORTGI40;		/* short GI in 40MHz */
 #endif
 
+	ic->ic_cryptocaps =
+		IEEE80211_CRYPTO_WEP |
+		IEEE80211_CRYPTO_TKIP |
+		IEEE80211_CRYPTO_AES_CCM;
+
 	ic->ic_txstream = sc->ntxchains;
 	ic->ic_rxstream = sc->nrxchains;
 



CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Apr 27 07:37:01 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Fix resource leak in rx/tx free lists.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.16 -r1.59.2.17 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.16 src/sys/dev/usb/if_urtwn.c:1.59.2.17
--- src/sys/dev/usb/if_urtwn.c:1.59.2.16	Sat Apr 25 14:40:11 2020
+++ src/sys/dev/usb/if_urtwn.c	Mon Apr 27 07:37:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.16 2020/04/25 14:40:11 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.17 2020/04/27 07:37:01 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.16 2020/04/25 14:40:11 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.17 2020/04/27 07:37:01 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -814,19 +814,23 @@ urtwn_alloc_rx_list(struct urtwn_softc *
 static void
 urtwn_free_rx_list(struct urtwn_softc *sc)
 {
+	struct urtwn_rx_data *data = NULL;
 	struct usbd_xfer *xfer;
-	size_t i;
 
 	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
 	/* NB: Caller must abort pipe first. */
 	for (size_t j = 0; j < sc->rx_npipe; j++) {
-		for (i = 0; i < URTWN_RX_LIST_COUNT; i++) {
+		mutex_enter(&sc->sc_rx_mtx); 
+		while (!TAILQ_EMPTY(&sc->rx_free_list[j])) {
+			data = TAILQ_FIRST(&sc->rx_free_list[j]);
+			TAILQ_REMOVE(&sc->rx_free_list[j], data, next);
 			CTASSERT(sizeof(xfer) == sizeof(void *));
-			xfer = atomic_swap_ptr(&sc->rx_data[j][i].xfer, NULL);
+			xfer = atomic_swap_ptr(&data->xfer, NULL);
 			if (xfer != NULL)
 usbd_destroy_xfer(xfer);
 		}
+		mutex_exit(&sc->sc_rx_mtx);
 	}
 }
 
@@ -875,19 +879,23 @@ urtwn_alloc_tx_list(struct urtwn_softc *
 static void
 urtwn_free_tx_list(struct urtwn_softc *sc)
 {
+	struct urtwn_tx_data *data = NULL;
 	struct usbd_xfer *xfer;
-	size_t i;
 
 	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
 	/* NB: Caller must abort pipe first. */
 	for (size_t j = 0; j < sc->tx_npipe; j++) {
-		for (i = 0; i < URTWN_TX_LIST_COUNT; i++) {
+		mutex_enter(&sc->sc_tx_mtx); 
+		while (!TAILQ_EMPTY(&sc->tx_free_list[j])) {
+			data = TAILQ_FIRST(&sc->tx_free_list[j]);
+			TAILQ_REMOVE(&sc->tx_free_list[j], data, next);
 			CTASSERT(sizeof(xfer) == sizeof(void *));
-			xfer = atomic_swap_ptr(&sc->tx_data[j][i].xfer, NULL);
+			xfer = atomic_swap_ptr(&data->xfer, NULL);
 			if (xfer != NULL)
 usbd_destroy_xfer(xfer);
 		}
+		mutex_exit(&sc->sc_tx_mtx);
 	}
 }
 



CVS commit: [phil-wifi] src/sys/net

2020-04-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Mon Apr 27 07:27:35 UTC 2020

Modified Files:
src/sys/net [phil-wifi]: pfil.c

Log Message:
Skip pfil_run_hooks if no packet filter enabled in the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.35.14.1 -r1.35.14.2 src/sys/net/pfil.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/net/pfil.c
diff -u src/sys/net/pfil.c:1.35.14.1 src/sys/net/pfil.c:1.35.14.2
--- src/sys/net/pfil.c:1.35.14.1	Wed Apr  8 14:08:57 2020
+++ src/sys/net/pfil.c	Mon Apr 27 07:27:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pfil.c,v 1.35.14.1 2020/04/08 14:08:57 martin Exp $	*/
+/*	$NetBSD: pfil.c,v 1.35.14.2 2020/04/27 07:27:35 nat Exp $	*/
 
 /*
  * Copyright (c) 2013 Mindaugas Rasiukevicius 
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.35.14.1 2020/04/08 14:08:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.35.14.2 2020/04/27 07:27:35 nat Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_net_mpsafe.h"
@@ -398,6 +398,11 @@ pfil_run_hooks(pfil_head_t *ph, struct m
 	int ret = 0;
 
 	KASSERT(dir == PFIL_IN || dir == PFIL_OUT);
+	
+	if (__predict_false(ph == NULL)) {
+		return ret;
+	}
+
 	if (__predict_false((phlistset = pfil_hook_get(dir, ph)) == NULL)) {
 		return ret;
 	}



CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-25 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Apr 25 14:40:12 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Remove configuring 40Mhz channels for now.

Avoid duplicate state transitions in urtwn_newstate.
Avoid changing channel parameters in urtwn_newstate.

Rework of tx desc parameters for all types of packets.

Don't create a percpuq as the stack is not expecting it //XXX not sure

Tested connections to an open 11n network with 8188CUS, 8192CU and 8192EU
usb adaptors.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.15 -r1.59.2.16 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.15 src/sys/dev/usb/if_urtwn.c:1.59.2.16
--- src/sys/dev/usb/if_urtwn.c:1.59.2.15	Sat Apr 25 09:32:16 2020
+++ src/sys/dev/usb/if_urtwn.c	Sat Apr 25 14:40:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.15 2020/04/25 09:32:16 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.16 2020/04/25 14:40:11 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.15 2020/04/25 09:32:16 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.16 2020/04/25 14:40:11 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2173,7 +2173,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc
 			/* 802.11b/g */
 			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 3);
 		} else /* IEEE_MODE_11NG */
-			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 12); /* MCS 0 */
+			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 11);
 
 		/* Enable Rx of data frames. */
 		urtwn_write_2(sc, R92C_RXFLTMAP2, 0x);
@@ -2227,7 +2227,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc
 		urtwn_write_1(sc, R92C_T2T_SIFS + 1, sifs_time);
 
 		/* Initialize rate adaptation. */
-		if (ISSET(sc->chip, URTWN_CHIP_88E) ||
+		if (1 || ISSET(sc->chip, URTWN_CHIP_88E) ||
 		ISSET(sc->chip, URTWN_CHIP_92EU))
 			ni->ni_txrate = ni->ni_rates.rs_nrates - 1;
 		else
@@ -2311,6 +2311,8 @@ urtwn_newstate(struct ieee80211vap *vap,
 		break;
 
 	case IEEE80211_S_RUN:
+		if (nstate == IEEE80211_S_RUN)
+			break;
 		/* Turn link LED off. */
 		urtwn_set_led(sc, URTWN_LED_LINK, 0);
 
@@ -2328,9 +2330,11 @@ urtwn_newstate(struct ieee80211vap *vap,
 		urtwn_read_1(sc, R92C_BCN_CTRL) |
 		  R92C_BCN_CTRL_DIS_TSF_UDT0);
 
+#if 0
 		/* Back to 20MHz mode */
 		urtwn_set_chan(sc, ic->ic_curchan,
 		IEEE80211_HTINFO_2NDCHAN_NONE);
+#endif
 
 		if (ic->ic_opmode == IEEE80211_M_IBSS ||
 		ic->ic_opmode == IEEE80211_M_HOSTAP) {
@@ -2364,6 +2368,8 @@ urtwn_newstate(struct ieee80211vap *vap,
 		break;
 
 	case IEEE80211_S_SCAN:
+		if (ostate == IEEE80211_S_SCAN)
+			break;
 		if (ostate != IEEE80211_S_SCAN) {
 			/*
 			 * Begin of scanning
@@ -2404,8 +2410,10 @@ urtwn_newstate(struct ieee80211vap *vap,
 		urtwn_write_1(sc, R92C_TXPAUSE,
 		urtwn_read_1(sc, R92C_TXPAUSE) | 0x0f);
 
+#if 0
 		urtwn_set_chan(sc, ic->ic_curchan,
 		IEEE80211_HTINFO_2NDCHAN_NONE);
+#endif
 
 		/* Start periodic scan. */
 		if (!sc->sc_dying)
@@ -2413,6 +2421,8 @@ urtwn_newstate(struct ieee80211vap *vap,
 		break;
 
 	case IEEE80211_S_AUTH:
+		if (ostate == IEEE80211_S_AUTH)
+			break;
 		/* Set initial gain under link. */
 		reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
 		reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32);
@@ -2432,24 +2442,32 @@ urtwn_newstate(struct ieee80211vap *vap,
 		urtwn_read_4(sc, R92C_RCR) &
 		  ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN));
 
+#if 0
 		urtwn_set_chan(sc, ic->ic_curchan,
 		IEEE80211_HTINFO_2NDCHAN_NONE);
+#endif
 		break;
 
 	case IEEE80211_S_ASSOC:
 		break;
 
 	case IEEE80211_S_RUN:
+		if (ostate == IEEE80211_S_RUN)
+			break;
 		ni = vap->iv_bss;
 
+#if 0
 		/* XXX: Set 20MHz mode */
 		urtwn_set_chan(sc, ic->ic_curchan,
 		IEEE80211_HTINFO_2NDCHAN_NONE);
+#endif
 
 		if (ic->ic_opmode == IEEE80211_M_MONITOR) {
+#if 0
 			/* Back to 20MHz mode */
 			urtwn_set_chan(sc, ic->ic_curchan,
 			IEEE80211_HTINFO_2NDCHAN_NONE);
+#endif
 
 			/* Set media status to 'No Link'. */
 			urtwn_set_nettype0_msr(sc, R92C_CR_NETTYPE_NOLINK);
@@ -3108,9 +3126,6 @@ urtwn_tx(struct urtwn_softc *sc, struct 
 		R92C_TXDW0_OWN | R92C_TXDW0_FSG | R92C_TXDW0_LSG);
 	}
 
-	if (ic->ic_curmode == IEEE80211_MODE_11NG)
-		txd->txdw5 |= htole32(R92C_TXDW5_SGI);
-
 	if (IEEE80211_IS_MULTICAST(wh->i_addr1))
 		txd->txdw0 |= htole32(R92C_TXDW0_BMCAST);
 
@@ -3120,15 +3135,21 @@ urtwn_tx(struct urtwn_softc *sc, struct 
 		device_xname(sc->sc_dev), __func__, padsize));
 		txd->txdw1 |= htole32(SM(R92C_TXDW1_PKTOFF, (padsize / 8)));
 	}
+	if (ic->ic_curmode == IEEE80211_MODE_11B) {
+		raid = R92C_RAID_11B;
+		txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 0));
+	} else if (ic->ic_curmode == IEEE80211_MODE_11G) {
+		

CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-25 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Apr 25 09:32:16 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Compete some more of 11n support.
htcaps and streams values from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.14 -r1.59.2.15 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.14 src/sys/dev/usb/if_urtwn.c:1.59.2.15
--- src/sys/dev/usb/if_urtwn.c:1.59.2.14	Tue Apr 21 18:42:38 2020
+++ src/sys/dev/usb/if_urtwn.c	Sat Apr 25 09:32:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.14 2020/04/21 18:42:38 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.15 2020/04/25 09:32:16 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.14 2020/04/21 18:42:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.15 2020/04/25 09:32:16 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -515,6 +515,21 @@ urtwn_attach(device_t parent, device_t s
 	IEEE80211_C_WME |		/* 802.11e */
 	IEEE80211_C_WPA;		/* 802.11i */
 
+	ic->ic_htcaps =
+	IEEE80211_HTC_HT |
+	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 */
+#if 0
+	IEEE80211_HTCAP_CHWIDTH40 |		/* 40 MHz channel width */
+	IEEE80211_HTCAP_SHORTGI40;		/* short GI in 40MHz */
+#endif
+
+	ic->ic_txstream = sc->ntxchains;
+	ic->ic_rxstream = sc->nrxchains;
+
 	ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 
 #ifdef should_delete_NNN
@@ -3667,7 +3682,8 @@ urtwn_getradiocaps(struct ieee80211com *
 	setbit(bands, IEEE80211_MODE_11G);
 	setbit(bands, IEEE80211_MODE_11NG);
 	ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
-	urtwn_chan_2ghz, nitems(urtwn_chan_2ghz), bands, 0);
+	urtwn_chan_2ghz, nitems(urtwn_chan_2ghz), bands, IEEE80211_CHAN_HT20 |
+	IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D);
 }
 
 



CVS commit: [phil-wifi] src

2020-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 21 19:37:57 UTC 2020

Added Files:
src [phil-wifi]: BUILDING Makefile Makefile.inc README.md UPDATING
build.sh
src/bin [phil-wifi]: Makefile Makefile.inc
src/bin/cat [phil-wifi]: Makefile cat.1 cat.c
src/bin/chio [phil-wifi]: Makefile chio.1 chio.c defs.h pathnames.h
src/bin/chmod [phil-wifi]: Makefile chmod.1 chmod.c
src/bin/cp [phil-wifi]: Makefile cp.1 cp.c extern.h utils.c
src/bin/csh [phil-wifi]: Makefile alloc.c char.c char.h const.c csh.1
csh.c csh.h dir.c dir.h dol.c err.c exec.c exp.c extern.h file.c
func.c glob.c hist.c init.c lex.c misc.c parse.c pathnames.h proc.c
proc.h sem.c set.c str.c time.c
src/bin/csh/USD.doc [phil-wifi]: Makefile csh.1 csh.2 csh.3 csh.4
csh.ap csh.g tabs
src/bin/date [phil-wifi]: Makefile date.1 date.c extern.h netdate.c
src/bin/dd [phil-wifi]: Makefile args.c conv.c conv_tab.c dd.1 dd.c
dd.h dd_hostops.c dd_rumpops.c dd_swab.c extern.h misc.c position.c
src/bin/df [phil-wifi]: Makefile df.1 df.c
src/bin/domainname [phil-wifi]: Makefile domainname.1 domainname.c
src/bin/echo [phil-wifi]: Makefile echo.1 echo.c
src/bin/ed [phil-wifi]: Makefile POSIX README buf.c cbc.c ed.1 ed.h
glbl.c io.c main.c re.c sub.c undo.c
src/bin/ed/test [phil-wifi]: =.err Makefile README TODO a.d a.r a.t
a1.err a2.err addr.d addr.r addr.t addr1.err addr2.err ascii.d
ascii.r ascii.t bang1.d bang1.err bang1.r bang1.t bang2.err c.d c.r
c.t c1.err c2.err ckscripts.sh d.d d.err d.r d.t e1.d e1.err e1.r
e1.t e2.d e2.err e2.r e2.t e3.d e3.err e3.r e3.t e4.d e4.r e4.t
f1.err f2.err g1.d g1.err g1.r g1.t g2.d g2.err g2.r g2.t g3.d
g3.err g3.r g3.t g4.d g4.r g4.t g5.d g5.r g5.t h.err i.d i.r i.t
i1.err i2.err i3.err j.d j.r j.t k.d k.r k.t k1.err k2.err k3.err
k4.err l.d l.r l.t m.d m.err m.r m.t mkscripts.sh n.d n.r n.t
nl.err nl1.d nl1.r nl1.t nl2.d nl2.r nl2.t p.d p.r p.t q.d q.r q.t
q1.err r1.d r1.err r1.r r1.t r2.d r2.err r2.r r2.t r3.d r3.r r3.t
s1.d s1.err s1.r s1.t s10.err s2.d s2.err s2.r s2.t s3.d s3.err
s3.r s3.t s4.err s5.err s6.err s7.err s8.err s9.err t.d t.r t1.d
t1.err t1.r t1.t t2.d t2.err t2.r t2.t u.d u.err u.r u.t v.d v.r
v.t w.d w.r w.t w1.err w2.err w3.err x.err z.err
src/bin/expr [phil-wifi]: Makefile expr.1 expr.y
src/bin/hostname [phil-wifi]: Makefile hostname.1 hostname.c
src/bin/kill [phil-wifi]: Makefile kill.1 kill.c
src/bin/ksh [phil-wifi]: Makefile alloc.c c_ksh.c c_sh.c c_test.c
c_test.h c_ulimit.c conf-end.h config.h edit.c edit.h emacs-gen.sh
emacs.c eval.c exec.c expand.h expr.c history.c io.c jobs.c ksh.Man
ksh_dir.h ksh_limval.h lex.c lex.h mail.c main.c misc.c mkman
path.c proto.h sh.h shf.c shf.h siglist.in siglist.sh syn.c table.c
table.h trap.c tree.c tree.h tty.c tty.h var.c version.c vi.c
src/bin/ln [phil-wifi]: Makefile ln.1 ln.c
src/bin/ls [phil-wifi]: Makefile cmp.c extern.h ls.1 ls.c ls.h main.c
print.c util.c
src/bin/mkdir [phil-wifi]: Makefile mkdir.1 mkdir.c
src/bin/mt [phil-wifi]: Makefile mt.1 mt.c
src/bin/mv [phil-wifi]: Makefile mv.1 mv.c pathnames.h
src/bin/pax [phil-wifi]: Makefile ar_io.c ar_subs.c buf_subs.c cpio.1
cpio.c cpio.h dumptar.c extern.h file_subs.c ftree.c ftree.h
gen_subs.c getoldopt.c options.c options.h pat_rep.c pat_rep.h
pax.1 pax.c pax.h sel_subs.c sel_subs.h tables.c tables.h tar.1
tar.c tar.h tty_subs.c
src/bin/ps [phil-wifi]: Makefile extern.h fmt.c keyword.c nlist.c
print.c ps.1 ps.c ps.h
src/bin/pwd [phil-wifi]: Makefile pwd.1 pwd.c
src/bin/rcmd [phil-wifi]: Makefile rcmd.1
src/bin/rcp [phil-wifi]: Makefile extern.h pathnames.h rcp.1 rcp.c
util.c
src/bin/rm [phil-wifi]: Makefile rm.1 rm.c
src/bin/rmdir [phil-wifi]: Makefile rmdir.1 rmdir.c
src/bin/sh [phil-wifi]: Makefile TOUR alias.c alias.h arith_token.c
arith_tokens.h arithmetic.c arithmetic.h builtins.def cd.c cd.h
error.c error.h eval.c eval.h exec.c exec.h expand.c expand.h
histedit.c init.h input.c input.h jobs.c jobs.h machdep.h mail.c
mail.h main.c main.h memalloc.c memalloc.h miscbltin.c miscbltin.h
mkbuiltins mkinit.sh mknodenames.sh mknodes.sh mkoptions.sh
mktokens myhistedit.h mystring.c mystring.h nodes.c.pat nodetypes
option.list options.c options.h output.c output.h parser.c parser.h
redir.c redir.h sh.1 shell.h show.c show.h syntax.c syntax.h trap.c
   

CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-19 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun Apr 19 13:57:23 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Initial 11n support for urtwn.

Compile tested only... More to come.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.12 -r1.59.2.13 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.12 src/sys/dev/usb/if_urtwn.c:1.59.2.13
--- src/sys/dev/usb/if_urtwn.c:1.59.2.12	Fri Apr 17 13:44:37 2020
+++ src/sys/dev/usb/if_urtwn.c	Sun Apr 19 13:57:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.12 2020/04/17 13:44:37 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.13 2020/04/19 13:57:23 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.12 2020/04/17 13:44:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.13 2020/04/19 13:57:23 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1651,9 +1651,10 @@ urtwn_ra_init(struct ieee80211vap *vap)
 	}
 	if (ic->ic_curmode == IEEE80211_MODE_11B) {
 		mode = R92C_RAID_11B;
-	} else {
+	} else if (ic->ic_curmode == IEEE80211_MODE_11G) {
 		mode = R92C_RAID_11BG;
-	}
+	} else /* mode = IEEE80211_MODE_11NG */
+		mode = R92C_RAID_11GN;
 	DPRINTFN(DBG_INIT, ("%s: %s: mode=%#x rates=%#x, basicrates=%#x, "
 	"maxrate=%zx, maxbasicrate=%zx\n",
 	device_xname(sc->sc_dev), __func__, mode, rates, basicrates,
@@ -2153,10 +2154,11 @@ urtwn_newstate_cb(struct urtwn_softc *sc
 
 		if (ic->ic_curmode == IEEE80211_MODE_11B) {
 			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 0);
-		} else {
+		} else if (ic->ic_curmode == IEEE80211_MODE_11G) {
 			/* 802.11b/g */
 			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 3);
-		}
+		} else /* IEEE_MODE_11NG */
+			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 12); /* MCS 0 */
 
 		/* Enable Rx of data frames. */
 		urtwn_write_2(sc, R92C_RXFLTMAP2, 0x);
@@ -2464,10 +2466,11 @@ urtwn_newstate(struct ieee80211vap *vap,
 
 		if (ic->ic_curmode == IEEE80211_MODE_11B) {
 			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 0);
-		} else {
+		} else if (ic->ic_curmode == IEEE80211_MODE_11G) {
 			/* 802.11b/g */
 			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 3);
-		}
+		} else /* IEEE_MODE_11NG */
+			urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 12); /* MCS 0 */
 
 		/* Enable Rx of data frames. */
 		urtwn_write_2(sc, R92C_RXFLTMAP2, 0x);
@@ -3090,6 +3093,9 @@ urtwn_tx(struct urtwn_softc *sc, struct 
 		R92C_TXDW0_OWN | R92C_TXDW0_FSG | R92C_TXDW0_LSG);
 	}
 
+	if (ic->ic_curmode == IEEE80211_MODE_11NG)
+		txd->txdw5 |= htole32(R92C_TXDW5_SGI);
+
 	if (IEEE80211_IS_MULTICAST(wh->i_addr1))
 		txd->txdw0 |= htole32(R92C_TXDW0_BMCAST);
 
@@ -3104,8 +3110,10 @@ urtwn_tx(struct urtwn_softc *sc, struct 
 	type == IEEE80211_FC0_TYPE_DATA) {
 		if (ic->ic_curmode == IEEE80211_MODE_11B)
 			raid = R92C_RAID_11B;
-		else
+		else if (ic->ic_curmode == IEEE80211_MODE_11G)
 			raid = R92C_RAID_11BG;
+		else	/* IEEE80211_MODE_11NG */
+			raid = R92C_RAID_11GN;
 		DPRINTFN(DBG_TX,
 		("%s: %s: data packet: tid=%d, raid=%d\n",
 		device_xname(sc->sc_dev), __func__, tid, raid));
@@ -3657,6 +3665,7 @@ urtwn_getradiocaps(struct ieee80211com *
 	memset(bands, 0, sizeof(bands));
 	setbit(bands, IEEE80211_MODE_11B);
 	setbit(bands, IEEE80211_MODE_11G);
+	setbit(bands, IEEE80211_MODE_11NG);
 	ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
 	urtwn_chan_2ghz, nitems(urtwn_chan_2ghz), bands, 0);
 }



CVS commit: [phil-wifi] src/external/bsd/tmux/dist

2020-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 17 16:18:09 UTC 2020

Modified Files:
src/external/bsd/tmux/dist [phil-wifi]: screen-write.c

Log Message:
Fix merge botch


To generate a diff of this commit:
cvs rdiff -u -r1.8.4.3 -r1.8.4.4 src/external/bsd/tmux/dist/screen-write.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/tmux/dist/screen-write.c
diff -u src/external/bsd/tmux/dist/screen-write.c:1.8.4.3 src/external/bsd/tmux/dist/screen-write.c:1.8.4.4
--- src/external/bsd/tmux/dist/screen-write.c:1.8.4.3	Mon Apr 13 07:56:33 2020
+++ src/external/bsd/tmux/dist/screen-write.c	Fri Apr 17 16:18:09 2020
@@ -448,51 +448,6 @@ screen_write_menu(struct screen_write_ct
 	screen_write_set_cursor(ctx, cx, cy);
 }
 
-/* Draw a menu on screen. */
-void
-screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, int choice)
-{
-	struct screen		*s = ctx->s;
-	struct grid_cell	 gc;
-	u_int			 cx, cy, i, j;
-	const char		*name;
-
-	cx = s->cx;
-	cy = s->cy;
-
-	memcpy(&gc, &grid_default_cell, sizeof gc);
-
-	screen_write_box(ctx, menu->width + 4, menu->count + 2);
-	screen_write_cursormove(ctx, cx + 2, cy, 0);
-	format_draw(ctx, &gc, menu->width, menu->title, NULL);
-
-	for (i = 0; i < menu->count; i++) {
-		name = menu->items[i].name;
-		if (name == NULL) {
-			screen_write_cursormove(ctx, cx, cy + 1 + i, 0);
-			screen_write_hline(ctx, menu->width + 4, 1, 1);
-		} else {
-			if (choice >= 0 && i == (u_int)choice && *name != '-')
-gc.attr |= GRID_ATTR_REVERSE;
-			screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0);
-			for (j = 0; j < menu->width; j++)
-screen_write_putc(ctx, &gc, ' ');
-			screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0);
-			if (*name == '-') {
-name++;
-gc.attr |= GRID_ATTR_DIM;
-format_draw(ctx, &gc, menu->width, name, NULL);
-gc.attr &= ~GRID_ATTR_DIM;
-			} else
-format_draw(ctx, &gc, menu->width, name, NULL);
-			if (choice >= 0 && i == (u_int)choice)
-gc.attr &= ~GRID_ATTR_REVERSE;
-		}
-	}
-
-	screen_write_set_cursor(ctx, cx, cy);
-}
-
 /* Draw a box on screen. */
 void
 screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny)



CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 17 13:44:38 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Make it compilable with URTWN_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.11 -r1.59.2.12 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.11 src/sys/dev/usb/if_urtwn.c:1.59.2.12
--- src/sys/dev/usb/if_urtwn.c:1.59.2.11	Thu Apr 16 17:24:49 2020
+++ src/sys/dev/usb/if_urtwn.c	Fri Apr 17 13:44:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.11 2020/04/16 17:24:49 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.12 2020/04/17 13:44:37 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.11 2020/04/16 17:24:49 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.12 2020/04/17 13:44:37 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3452,7 +3452,9 @@ urtwn_parent(struct ieee80211com *ic)
 static void
 urtwn_scan_start(struct ieee80211com *ic)
 {
-	//struct urtwn_softc *sc = ic->ic_softc;
+#ifdef URTWN_DEBUG
+	struct urtwn_softc *sc = ic->ic_softc;
+#endif
 	//uint32_t reg;
 	//int s;
 
@@ -3515,7 +3517,9 @@ urtwn_scan_start(struct ieee80211com *ic
 static void
 urtwn_scan_end(struct ieee80211com *ic)
 {
-	//struct urtwn_softc *sc = ic->ic_softc;
+#ifdef URTWN_DEBUG
+	struct urtwn_softc *sc = ic->ic_softc;
+#endif
 
 	DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 



CVS commit: [phil-wifi] src/sys/dev

2020-04-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Apr 16 17:24:49 UTC 2020

Modified Files:
src/sys/dev/ic [phil-wifi]: rtwnreg.h
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Update with 92EU changes from -current.


To generate a diff of this commit:
cvs rdiff -u -r1.1.8.3 -r1.1.8.4 src/sys/dev/ic/rtwnreg.h
cvs rdiff -u -r1.59.2.10 -r1.59.2.11 src/sys/dev/usb/if_urtwn.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/dev/ic/rtwnreg.h
diff -u src/sys/dev/ic/rtwnreg.h:1.1.8.3 src/sys/dev/ic/rtwnreg.h:1.1.8.4
--- src/sys/dev/ic/rtwnreg.h:1.1.8.3	Mon Apr 13 08:04:22 2020
+++ src/sys/dev/ic/rtwnreg.h	Thu Apr 16 17:24:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtwnreg.h,v 1.1.8.3 2020/04/13 08:04:22 martin Exp $	*/
+/*	$NetBSD: rtwnreg.h,v 1.1.8.4 2020/04/16 17:24:49 nat Exp $	*/
 /*	$OpenBSD: r92creg.h,v 1.16 2017/09/22 13:41:56 kevlo Exp $	*/
 
 /*-
@@ -1341,6 +1341,8 @@ struct r92c_rx_desc_usb {
 
 #define R92C_RXDW2_PKTCNT_M	0x00ff
 #define R92C_RXDW2_PKTCNT_S	16
+#define R92E_RXDW2_PKTCNT_M	0x3fc0
+#define R92E_RXDW2_PKTCNT_S	22
 
 #define R92C_RXDW3_RATE_M	0x003f
 #define R92C_RXDW3_RATE_S	0

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.10 src/sys/dev/usb/if_urtwn.c:1.59.2.11
--- src/sys/dev/usb/if_urtwn.c:1.59.2.10	Thu Apr 16 15:33:07 2020
+++ src/sys/dev/usb/if_urtwn.c	Thu Apr 16 17:24:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.10 2020/04/16 15:33:07 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.11 2020/04/16 17:24:49 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.10 2020/04/16 15:33:07 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.11 2020/04/16 17:24:49 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2923,7 +2923,10 @@ urtwn_rxeof(struct usbd_xfer *xfer, void
 
 	/* Get the number of encapsulated frames. */
 	stat = (struct r92c_rx_desc_usb *)buf;
-	npkts = MS(le32toh(stat->rxdw2), R92C_RXDW2_PKTCNT);
+	if (ISSET(sc->chip, URTWN_CHIP_92EU))
+		npkts = MS(le32toh(stat->rxdw2), R92E_RXDW2_PKTCNT);
+	else
+		npkts = MS(le32toh(stat->rxdw2), R92C_RXDW2_PKTCNT);
 	DPRINTFN(DBG_RX, ("%s: %s: Rx %d frames in one chunk\n",
 	device_xname(sc->sc_dev), __func__, npkts));
 



CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Apr 16 15:33:08 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c

Log Message:
Use if_stat functions.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.9 -r1.59.2.10 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.9 src/sys/dev/usb/if_urtwn.c:1.59.2.10
--- src/sys/dev/usb/if_urtwn.c:1.59.2.9	Mon Apr 13 08:04:49 2020
+++ src/sys/dev/usb/if_urtwn.c	Thu Apr 16 15:33:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.9 2020/04/13 08:04:49 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.10 2020/04/16 15:33:07 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.9 2020/04/13 08:04:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.10 2020/04/16 15:33:07 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2762,7 +2762,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 		 */
 		DPRINTFN(DBG_RX, ("%s: %s: CRC error\n",
 		device_xname(sc->sc_dev), __func__));
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -2775,13 +2775,13 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 		DPRINTFN(DBG_RX, ("%s: %s: packet too short %d\n",
 		device_xname(sc->sc_dev), __func__, pktlen));
 		vap->iv_stats.is_rx_tooshort++;
-		ifp->if_ierrors++;
+		if_statinc(ifp,if_ierrors);
 		return;
 	}
 	if (__predict_false(pktlen > MCLBYTES)) {
 		DPRINTFN(DBG_RX, ("%s: %s: packet too big %d\n",
 		device_xname(sc->sc_dev), __func__, pktlen));
-		ifp->if_ierrors++;
+   	if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -2805,7 +2805,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 	if (__predict_false(m == NULL)) {
 		aprint_error_dev(sc->sc_dev, "couldn't allocate rx mbuf\n");
 		vap->iv_stats.is_rx_nobuf++;
-		ifp->if_ierrors++;
+   	if_statinc(ifp, if_ierrors);
 		return;
 	}
 	if (pktlen > (int)MHLEN) {
@@ -2815,7 +2815,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 			"couldn't allocate rx mbuf cluster\n");
 			m_freem(m);
 			vap->iv_stats.is_rx_nobuf++;
-			ifp->if_ierrors++;
+	if_statinc(ifp, if_ierrors);
 			return;
 		}
 	}
@@ -3000,13 +3000,13 @@ urtwn_txeof(struct usbd_xfer *xfer, void
 usbd_clear_endpoint_stall_async(pipe);
 			}
 			printf("ERROR1\n");
-			ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 		}
 		splx(s);
 		return;
 	}
 
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 	urtwn_start(ifp); 
 	splx(s);
 
@@ -3308,7 +3308,7 @@ urtwn_start(struct ifnet *ifp)
 		if (m->m_len < (int)sizeof(*eh) &&
 		(m = m_pullup(m, sizeof(*eh))) == NULL) {
 			printf("ERROR6\n");
-			ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 			continue;
 		}
 		eh = mtod(m, struct ether_header *);
@@ -3316,7 +3316,7 @@ urtwn_start(struct ifnet *ifp)
 		if (ni == NULL) {
 			m_freem(m);
 			printf("ERROR5\n");
-			ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -3327,7 +3327,7 @@ urtwn_start(struct ifnet *ifp)
 			m_freem(m);
 			ieee80211_free_node(ni);
 			printf("ERROR3\n");
-			ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 			continue;
 		}
 		m_freem(m);
@@ -3352,7 +3352,7 @@ urtwn_watchdog(struct ifnet *ifp)
 			aprint_error_dev(sc->sc_dev, "device timeout\n");
 			/* urtwn_init(ifp); XXX needs a process context! */
 			printf("ERROR2\n");
-			ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;
@@ -3449,7 +3449,7 @@ urtwn_parent(struct ieee80211com *ic)
 static void
 urtwn_scan_start(struct ieee80211com *ic)
 {
-	struct urtwn_softc *sc = ic->ic_softc;
+	//struct urtwn_softc *sc = ic->ic_softc;
 	//uint32_t reg;
 	//int s;
 
@@ -3512,7 +3512,7 @@ urtwn_scan_start(struct ieee80211com *ic
 static void
 urtwn_scan_end(struct ieee80211com *ic)
 {
-	struct urtwn_softc *sc = ic->ic_softc;
+	//struct urtwn_softc *sc = ic->ic_softc;
 
 	DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 
@@ -3565,9 +3565,9 @@ urtwn_transmit(struct ieee80211com *ic, 
 
 IF_ENQUEUE(&sc->sc_sendq, m);
 
-vap->iv_ifp->if_obytes += pktlen;
+if_statadd(vap->iv_ifp, if_obytes, pktlen);
 if (mcast)
-vap->iv_ifp->if_omcasts++;
+if_statinc(vap->iv_ifp, if_omcasts);
 
 if ((vap->iv_ifp->if_flags & IFF_OACTIVE) == 0)
 if_start_lock(vap->iv_ifp);
@@ -3626,7 +3626,7 @@ urtwn_raw_xmit(struct ieee80211_node *ni
 	error = urtwn_tx(sc, m, ni, data);
 	if (error != 0) {
 		printf("ERROR3\n");
-		vap->iv_ifp->if_oerrors++;
+if_statinc(vap->iv_ifp, if_oerrors);
 	} else {
 		sc->tx_timer = 5;
 		vap->iv_ifp->if_t

CVS commit: [phil-wifi] src/sys/dev/usb

2020-04-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Apr 16 15:32:24 UTC 2020

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwnvar.h

Log Message:
Pull in 


To generate a diff of this commit:
cvs rdiff -u -r1.10.16.5 -r1.10.16.6 src/sys/dev/usb/if_urtwnvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwnvar.h
diff -u src/sys/dev/usb/if_urtwnvar.h:1.10.16.5 src/sys/dev/usb/if_urtwnvar.h:1.10.16.6
--- src/sys/dev/usb/if_urtwnvar.h:1.10.16.5	Mon Apr 13 08:04:49 2020
+++ src/sys/dev/usb/if_urtwnvar.h	Thu Apr 16 15:32:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwnvar.h,v 1.10.16.5 2020/04/13 08:04:49 martin Exp $	*/
+/*	$NetBSD: if_urtwnvar.h,v 1.10.16.6 2020/04/16 15:32:24 nat Exp $	*/
 /*	$OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $	*/
 
 /*-
@@ -19,6 +19,8 @@
 #ifndef _IF_URTWNVAR_H_
 #define _IF_URTWNVAR_H_
 
+#include 
+
 /*
  * Driver definitions.
  */



CVS commit: [phil-wifi] src/sys/net80211

2020-04-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Thu Apr 16 15:30:00 UTC 2020

Modified Files:
src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_netbsd.c
ieee80211_netbsd.h

Log Message:
Use if_stat functions.


To generate a diff of this commit:
cvs rdiff -u -r1.56.18.8 -r1.56.18.9 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.31.2.9 -r1.31.2.10 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.11 -r1.21.2.12 src/sys/net80211/ieee80211_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net80211/ieee80211.c
diff -u src/sys/net80211/ieee80211.c:1.56.18.8 src/sys/net80211/ieee80211.c:1.56.18.9
--- src/sys/net80211/ieee80211.c:1.56.18.8	Mon Apr 13 08:05:15 2020
+++ src/sys/net80211/ieee80211.c	Thu Apr 16 15:30:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.56.18.8 2020/04/13 08:05:15 martin Exp $ */
+/*	$NetBSD: ieee80211.c,v 1.56.18.9 2020/04/16 15:30:00 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #include 
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.56.18.8 2020/04/13 08:05:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.56.18.9 2020/04/16 15:30:00 nat Exp $");
 #endif
 
 /*
@@ -2016,7 +2016,13 @@ ieee80211_media_init(struct ieee80211com
 	ifm_change_cb_t media_change, ifm_stat_cb_t media_stat)
 {
 
-	ieee80211_media_init_with_lock(ic, media_change, media_stat, NULL);
+	struct ieee80211vap *vap;
+
+	vap = TAILQ_FIRST(&ic->ic_vaps);
+	KASSERT(vap != NULL, ("media vap is null"));
+
+	ifmedia_init_with_lock(&vap->iv_media, 0, media_change,
+	media_stat, NULL);
 }
 
 void
@@ -2030,8 +2036,8 @@ ieee80211_announce(struct ieee80211com *
 	for (mode = IEEE80211_MODE_AUTO+1; mode < IEEE80211_MODE_11NA; mode++) {
 		if (isclr(ic->ic_modecaps, mode))
 			continue;
-		aprint_debug("%s: %s rates: ", ifp->if_xname,
-		ieee80211_phymode_name[mode]);
+		//aprint_debug("%s: %s rates: ", ifp->if_xname,
+		 //   ieee80211_phymode_name[mode]);
 		ic_printf(ic, "%s rates: ", ieee80211_phymode_name[mode]);
 		rs = &ic->ic_sup_rates[mode];
 		for (i = 0; i < rs->rs_nrates; i++) {

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.31.2.9 src/sys/net80211/ieee80211_netbsd.c:1.31.2.10
--- src/sys/net80211/ieee80211_netbsd.c:1.31.2.9	Tue Nov 19 19:17:16 2019
+++ src/sys/net80211/ieee80211_netbsd.c	Thu Apr 16 15:30:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.9 2019/11/19 19:17:16 phil Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.31.2.10 2020/04/16 15:30:00 nat Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,7 +29,7 @@
 
 #include 
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.9 2019/11/19 19:17:16 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31.2.10 2020/04/16 15:30:00 nat Exp $");
 #endif
 
 /*
@@ -1183,45 +1183,59 @@ wlan_iflladdr(void *arg __unused, struct
 }
 #endif
 
+int64_t
+if_get_counter_default(struct ifnet * ifp, ift_counter cnt)
+{
+	struct if_data if_stats;
+	int64_t result;
+
+	if_stats_to_if_data(ifp, &if_stats, false);
+
+	result = (cnt == IFCOUNTER_OERRORS ? if_stats.ifi_oerrors :
+	(cnt == IFCOUNTER_IERRORS ? if_stats.ifi_ierrors : 0 ));
+
+	return result;
+}
+
 void
 if_inc_counter(struct ifnet *ifp, ift_counter ifc, int64_t value)
 {
 	switch (ifc) {
 	case IFCOUNTER_IPACKETS:
-		ifp->if_data.ifi_ipackets += value;
+		if_statadd(ifp, if_ipackets, value);
 		break;
 	case IFCOUNTER_IERRORS:
-		ifp->if_data.ifi_ierrors += value;
+		if_statadd(ifp, if_ierrors, value);
 		break;
 	case IFCOUNTER_OPACKETS:
-		ifp->if_data.ifi_opackets += value;
+		if_statadd(ifp, if_opackets, value);
 		break;
 	case IFCOUNTER_OERRORS:
-		ifp->if_data.ifi_oerrors += value;
+		if_statadd(ifp, if_oerrors, value);
 		break;
 case IFCOUNTER_COLLISIONS:
-		ifp->if_data.ifi_collisions += value;
+		if_statadd(ifp, if_collisions, value);
 		break;
 case IFCOUNTER_IBYTES:
-		ifp->if_data.ifi_ibytes += value;
+		if_statadd(ifp, if_ibytes, value);
 		break;
 case IFCOUNTER_OBYTES:
-		ifp->if_data.ifi_obytes += value;
+		if_statadd(ifp, if_obytes, value);
 		break;
 case IFCOUNTER_IMCASTS:
-		ifp->if_data.ifi_imcasts += value;
+		if_statadd(ifp, if_imcasts, value);
 		break;
 case IFCOUNTER_OMCASTS:
-		ifp->if_data.ifi_omcasts += value;
+		if_statadd(ifp, if_omcasts, value);
 		break;
 case IFCOUNTER_IQDROPS:
-		ifp->if_data.ifi_iqdrops += value;
+		if_statadd(ifp, if_iqdrops, value);
 		break;
 case IFCOUNTER_OQDROPS:
 		/* ifp->if_data.ifi_oqdrops += value; No such field, just ignore it q*/
 		break;
 case IFCOUNTER_NOPROTO:
-		ifp->if_data.ifi_noproto += value;
+		if_statadd(ifp, if_noproto, value);
 		break;
 	default:
 		panic("if_inc_counter: non-existant counter");

Index: src/sys/net80211/ieee80211_netbsd.h

CVS commit: [phil-wifi] src/sys

2018-08-15 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Wed Aug 15 17:07:03 UTC 2018

Modified Files:
src/sys/arch/amd64/conf [phil-wifi]: TESTWIFI
src/sys/dev/usb [phil-wifi]: if_urtwn.c if_urtwnvar.h
src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_input.c
ieee80211_ioctl.c ieee80211_ioctl.h ieee80211_netbsd.c
ieee80211_netbsd.h ieee80211_node.c ieee80211_output.c
ieee80211_proto.c ieee80211_scan_sta.c ieee80211_sta.c

Log Message:
Final changes for 200 hour contract.  Still a lot of work to do.
With these changes, Station mode works with an open AP.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/amd64/conf/TESTWIFI
cvs rdiff -u -r1.59.2.5 -r1.59.2.6 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.10.16.1 -r1.10.16.2 src/sys/dev/usb/if_urtwnvar.h
cvs rdiff -u -r1.56.18.5 -r1.56.18.6 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.114.2.4 -r1.114.2.5 src/sys/net80211/ieee80211_input.c
cvs rdiff -u -r1.60.18.6 -r1.60.18.7 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.24.2.4 -r1.24.2.5 src/sys/net80211/ieee80211_ioctl.h
cvs rdiff -u -r1.31.2.6 -r1.31.2.7 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.7 -r1.21.2.8 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.75.4.4 -r1.75.4.5 src/sys/net80211/ieee80211_node.c
cvs rdiff -u -r1.63.2.3 -r1.63.2.4 src/sys/net80211/ieee80211_output.c
cvs rdiff -u -r1.34.14.6 -r1.34.14.7 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.1.56.6 -r1.1.56.7 src/sys/net80211/ieee80211_scan_sta.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 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.2 src/sys/arch/amd64/conf/TESTWIFI:1.1.2.3
--- src/sys/arch/amd64/conf/TESTWIFI:1.1.2.2	Fri Aug  3 19:47:25 2018
+++ src/sys/arch/amd64/conf/TESTWIFI	Wed Aug 15 17:07:02 2018
@@ -1,4 +1,4 @@
-# $NetBSD: TESTWIFI,v 1.1.2.2 2018/08/03 19:47:25 phil Exp $
+# $NetBSD: TESTWIFI,v 1.1.2.3 2018/08/15 17:07:02 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.2 $"
+#ident		"GENERIC-$Revision: 1.1.2.3 $"
 
 maxusers	64		# estimated number of users
 
@@ -194,7 +194,7 @@ options 	NFSSERVER	# Network File System
 # Networking options
 #options 	GATEWAY		# packet forwarding
 options 	INET		# IP + ICMP + TCP + UDP
-options 	INET6		# IPV6
+#options 	INET6		# IPV6
 options 	IPSEC		# IP security
 #options 	IPSEC_DEBUG	# debug for IP security
 #options 	MPLS		# MultiProtocol Label Switching (needs mpls)
@@ -1306,7 +1306,7 @@ pseudo-device	gre			# generic L3 over IP
 pseudo-device	gif			# IPv[46] over IPv[46] tunnel (RFC1933)
 pseudo-device	ipsecif			# tunnel interface for routing based ipsec
 #pseudo-device	faith			# IPv[46] tcp relay translation i/f
-pseudo-device	stf			# 6to4 IPv6 over IPv4 encapsulation
+#pseudo-device	stf			# 6to4 IPv6 over IPv4 encapsulation
 pseudo-device	vlan			# IEEE 802.1q encapsulation
 pseudo-device	bridge			# simple inter-network bridging
 #options 	BRIDGE_IPF		# bridge uses IP/IPv6 pfil hooks too

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.5 src/sys/dev/usb/if_urtwn.c:1.59.2.6
--- src/sys/dev/usb/if_urtwn.c:1.59.2.5	Fri Aug  3 19:47:25 2018
+++ src/sys/dev/usb/if_urtwn.c	Wed Aug 15 17:07:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.6 2018/08/15 17:07:02 phil Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.6 2018/08/15 17:07:02 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		0xU
 /* NNN Reset urtwn_debug to 0 when done debugging. */
-u_int urtwn_debug = DBG_FN;
+u_int urtwn_debug = 0;
 #define DPRINTFN(n, s)	\
 	do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
 #else
@@ -342,15 +342,15 @@ static struct ieee80211vap *
 static void	urtwn_vap_delete(struct ieee80211vap *);
 static int	urtwn_ioctl(struct ifnet *, u_long, void *);
 static void	urtwn_parent(struct ieee80211com *);
+static void	urtwn_getradiocaps(struct ieee80211com *, int, int *,
+		struct ieee80211_channel []);
 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_send_mgmt(struct ieee80211_node *, int, int);
 static int	urtw

CVS commit: [phil-wifi] src/sys

2018-08-03 Thread Phil Nelson
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 
-__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		0xU
 /* 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,

CVS commit: [phil-wifi] src/sys

2018-07-27 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Sat Jul 28 00:49:44 UTC 2018

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c
src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_adhoc.c
ieee80211_hostap.c ieee80211_input.c ieee80211_ioctl.c
ieee80211_mesh.c ieee80211_monitor.c ieee80211_netbsd.c
ieee80211_netbsd.h ieee80211_proto.c ieee80211_scan.c
ieee80211_scan_sta.c ieee80211_sta.c ieee80211_tdma.c
ieee80211_wds.c

Log Message:
End of the week state save:
   Got workqueues doing FreeBSD tasks.  (still questions on how correct it is.)
   Incremental changes in many places.
   Still *lots* of debugging code that needs to go away some day.
   "ifconfig urtwn0 up" now does not crash, still needs scan to work properly.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.3 -r1.59.2.4 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.56.18.4 -r1.56.18.5 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/net80211/ieee80211_adhoc.c \
src/sys/net80211/ieee80211_hostap.c src/sys/net80211/ieee80211_monitor.c \
src/sys/net80211/ieee80211_sta.c src/sys/net80211/ieee80211_tdma.c \
src/sys/net80211/ieee80211_wds.c
cvs rdiff -u -r1.114.2.3 -r1.114.2.4 src/sys/net80211/ieee80211_input.c
cvs rdiff -u -r1.60.18.4 -r1.60.18.5 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/net80211/ieee80211_mesh.c
cvs rdiff -u -r1.31.2.4 -r1.31.2.5 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.5 -r1.21.2.6 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.34.14.4 -r1.34.14.5 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.1.56.4 -r1.1.56.5 src/sys/net80211/ieee80211_scan.c \
src/sys/net80211/ieee80211_scan_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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.3 src/sys/dev/usb/if_urtwn.c:1.59.2.4
--- src/sys/dev/usb/if_urtwn.c:1.59.2.3	Fri Jul 20 20:33:05 2018
+++ src/sys/dev/usb/if_urtwn.c	Sat Jul 28 00:49:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -19,13 +19,30 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+/* Some code taken from FreeBSD dev/usb/wlan/if_urtw.c with copyright */
+/*-
+ * Copyright (c) 2008 Weongyo Jeong 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
 /*-
  * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU
  * RTL8192EU.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -94,7 +111,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #define	DBG_REG		__BIT(6)
 #define	DBG_ALL		0xU
 /* NNN Reset urtwn_debug to 0 when done debugging. */
-u_int urtwn_debug = DBG_INIT|DBG_FN|DBG_STM;
+u_int urtwn_debug = DBG_ALL & ~DBG_REG;
 #define DPRINTFN(n, s)	\
 	do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
 #else
@@ -203,6 +220,11 @@ static const struct urtwn_dev {
 #undef URTWN_RTL8188E_DEV
 #undef URTWN_RTL8192EU_DEV
 
+/* urtwn data */
+static const uint8_t urtwn_chan_2ghz[] =
+{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+
+
 static int	urtwn_match(device_t, cfdata_t, void *);
 static void	urtwn_attach(device_t, device_t, void *);
 static int	urtwn_detach(device_t, int);
@@ -252,7 +274,7 @@ static void	urtwn_dump_rom(struct urtwn_
 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 urtwn_softc *);
+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);
 static void	urtwn_tsf_sync_enable(struct urtwn_softc *);
@@ -262,7 +284,7 @@ static void	urtwn_calib_to_cb(struct urt
 static void	urtwn_next_scan(void *);
 st

CVS commit: [phil-wifi] src/sys

2018-07-20 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Fri Jul 20 20:33:05 UTC 2018

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c
src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_amrr.c
ieee80211_ioctl.c ieee80211_ioctl.h ieee80211_netbsd.c
ieee80211_netbsd.h ieee80211_proto.c ieee80211_rssadapt.c
ieee80211_scan_sw.c ieee80211_var.h

Log Message:
State save:
  urtwn: ifp->if_softc points to a vap, not the urtwn softc, fix code for this.
 add missing routines, need to get them filled out correctly.
  80211: Add back some NetBSD ioctls, start working on the sysctl tree.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.2 -r1.59.2.3 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.56.18.3 -r1.56.18.4 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.3.18.3 -r1.3.18.4 src/sys/net80211/ieee80211_amrr.c
cvs rdiff -u -r1.60.18.3 -r1.60.18.4 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.24.2.3 -r1.24.2.4 src/sys/net80211/ieee80211_ioctl.h
cvs rdiff -u -r1.31.2.3 -r1.31.2.4 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.4 -r1.21.2.5 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.34.14.3 -r1.34.14.4 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.21.16.3 -r1.21.16.4 src/sys/net80211/ieee80211_rssadapt.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/net80211/ieee80211_scan_sw.c
cvs rdiff -u -r1.33.2.4 -r1.33.2.5 src/sys/net80211/ieee80211_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.2 src/sys/dev/usb/if_urtwn.c:1.59.2.3
--- src/sys/dev/usb/if_urtwn.c:1.59.2.2	Mon Jul 16 20:11:11 2018
+++ src/sys/dev/usb/if_urtwn.c	Fri Jul 20 20:33:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.2 2018/07/16 20:11:11 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -311,6 +311,7 @@ static int	urtwn_reset(struct ieee80211v
 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);
+/* Functions for wifi refresh */
 static struct ieee80211vap *
 		urtwn_vap_create(struct ieee80211com *,
 		const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
@@ -318,6 +319,14 @@ static struct ieee80211vap *
 		const uint8_t [IEEE80211_ADDR_LEN]);
 static void	urtwn_vap_delete(struct ieee80211vap *);
 static int	urtwn_ioctl(struct ifnet *, u_long, void *);
+static void	urtwn_parent(struct ieee80211com *);
+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 *);
+
 
 /* Aliases. */
 #define	urtwn_bb_write	urtwn_write_4
@@ -357,6 +366,9 @@ urtwn_attach(device_t parent, device_t s
 	sc->sc_dev = self;
 	sc->sc_udev = uaa->uaa_device;
 
+	/* Name the ic. */
+	ic->ic_name = "urtwn";
+
 	sc->chip = 0;
 	dev = urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product);
 	if (dev != NULL && ISSET(dev->flags, FLAG_RTL8188E))
@@ -491,6 +503,13 @@ urtwn_attach(device_t parent, device_t s
 	ic->ic_wme.wme_update = urtwn_wme_update;
 	ic->ic_vap_create = urtwn_vap_create;
 	ic->ic_vap_delete = urtwn_vap_delete;
+	ic->ic_parent = urtwn_parent;
+	ic->ic_scan_start = urtwn_scan_start;
+	ic->ic_scan_end = urtwn_scan_end;
+	ic->ic_set_channel = urtwn_set_channel;
+	ic->ic_transmit = urtwn_transmit;
+	ic->ic_raw_xmit = urtwn_raw_xmit;
+	
 
 	/* Shouldn't do it, but call vap_create??? */
 	uint8_t bssid[IEEE80211_ADDR_LEN] = {0};
@@ -507,6 +526,9 @@ urtwn_attach(device_t parent, device_t s
 		goto fail;
 	}
 
+	/* Debug all! NNN */
+	vap->iv_debug = IEEE80211_MSG_ANY;
+
 	bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
 	sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
 	&sc->sc_drvbpf);
@@ -1489,7 +1511,8 @@ static __unused int
 urtwn_media_change(struct ifnet *ifp)
 {
 #ifdef URTWN_DEBUG
-	struct urtwn_softc *sc = ifp->if_softc;
+	struct ieee80211vap *vap = ifp->if_softc;
+	struct urtwn_softc *sc = vap->iv_ic->ic_softc;
 #endif
 	int error;
 
@@ -1808,6 +1831,7 @@ urtwn_calib_to_cb(struct urtwn_softc *sc
 static void
 urtwn_next_scan(void *arg)
 {
+	printf ("urtwn_next_scan called\n");
 #ifdef notyet
 	struct urtwn_softc *sc = arg;
 	int s;
@@ -1942,6 +1966,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc
 	case IEEE80211_S_CAC:
 	cas

CVS commit: [phil-wifi] src/sys

2018-07-16 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Mon Jul 16 20:11:12 UTC 2018

Modified Files:
src/sys/dev/usb [phil-wifi]: if_urtwn.c if_urtwnvar.h
src/sys/net80211 [phil-wifi]: ieee80211.c ieee80211_acl.c
ieee80211_amrr.c ieee80211_crypto.c ieee80211_crypto_tkip.c
ieee80211_crypto_wep.c ieee80211_ht.c ieee80211_hwmp.c
ieee80211_input.c ieee80211_ioctl.c ieee80211_mesh.c
ieee80211_netbsd.c ieee80211_netbsd.h ieee80211_node.c
ieee80211_output.c ieee80211_proto.c ieee80211_proto.h
ieee80211_ratectl.c ieee80211_ratectl.h ieee80211_ratectl_none.c
ieee80211_rssadapt.c ieee80211_scan.c ieee80211_scan_sta.c
ieee80211_var.h ieee80211_xauth.c

Log Message:
State save.
urtwn now can attach and shows up in the "ifconfig -a" list.


To generate a diff of this commit:
cvs rdiff -u -r1.59.2.1 -r1.59.2.2 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.10 -r1.10.16.1 src/sys/dev/usb/if_urtwnvar.h
cvs rdiff -u -r1.56.18.2 -r1.56.18.3 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.9.54.2 -r1.9.54.3 src/sys/net80211/ieee80211_acl.c
cvs rdiff -u -r1.3.18.2 -r1.3.18.3 src/sys/net80211/ieee80211_amrr.c
cvs rdiff -u -r1.23.2.2 -r1.23.2.3 src/sys/net80211/ieee80211_crypto.c
cvs rdiff -u -r1.14.4.2 -r1.14.4.3 src/sys/net80211/ieee80211_crypto_tkip.c
cvs rdiff -u -r1.12.2.2 -r1.12.2.3 src/sys/net80211/ieee80211_crypto_wep.c
cvs rdiff -u -r1.1.56.3 -r1.1.56.4 src/sys/net80211/ieee80211_ht.c \
src/sys/net80211/ieee80211_scan.c src/sys/net80211/ieee80211_scan_sta.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/net80211/ieee80211_hwmp.c \
src/sys/net80211/ieee80211_mesh.c src/sys/net80211/ieee80211_ratectl.c \
src/sys/net80211/ieee80211_ratectl_none.c
cvs rdiff -u -r1.114.2.2 -r1.114.2.3 src/sys/net80211/ieee80211_input.c
cvs rdiff -u -r1.60.18.2 -r1.60.18.3 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.31.2.2 -r1.31.2.3 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.75.4.2 -r1.75.4.3 src/sys/net80211/ieee80211_node.c
cvs rdiff -u -r1.63.2.2 -r1.63.2.3 src/sys/net80211/ieee80211_output.c
cvs rdiff -u -r1.34.14.2 -r1.34.14.3 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.23.16.3 -r1.23.16.4 src/sys/net80211/ieee80211_proto.h
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/net80211/ieee80211_ratectl.h
cvs rdiff -u -r1.21.16.2 -r1.21.16.3 src/sys/net80211/ieee80211_rssadapt.c
cvs rdiff -u -r1.33.2.3 -r1.33.2.4 src/sys/net80211/ieee80211_var.h
cvs rdiff -u -r1.5.158.2 -r1.5.158.3 src/sys/net80211/ieee80211_xauth.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.1 src/sys/dev/usb/if_urtwn.c:1.59.2.2
--- src/sys/dev/usb/if_urtwn.c:1.59.2.1	Thu Jul 12 16:35:33 2018
+++ src/sys/dev/usb/if_urtwn.c	Mon Jul 16 20:11:11 2018
@@ -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 
-__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 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -92,7 +93,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #define	DBG_RF		__BIT(5)
 #define	DBG_REG		__BIT(6)
 #define	DBG_ALL		0xU
-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_set_led(struct urtwn_s
 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 @@ 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 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_lc_calib(struct urtwn_
 static void	urtwn_temp_calib(struct urtwn_softc *);
 static int	urtwn_init(struct if

CVS commit: [phil-wifi] src/sys

2018-07-12 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Thu Jul 12 16:02:50 UTC 2018

Added Files:
src/sys/kern [phil-wifi]: subr_sbuf.c
src/sys/sys [phil-wifi]: sbuf.h

Log Message:
Add sbuf files from FreeBSD to support net80211.
Files from same version as net80211 files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/kern/subr_sbuf.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/sys/sbuf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/kern/subr_sbuf.c
diff -u /dev/null src/sys/kern/subr_sbuf.c:1.1.2.1
--- /dev/null	Thu Jul 12 16:02:50 2018
+++ src/sys/kern/subr_sbuf.c	Thu Jul 12 16:02:50 2018
@@ -0,0 +1,884 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2000-2008 Poul-Henning Kamp
+ * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer
+ *in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+
+#ifdef _KERNEL
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#else /* _KERNEL */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif /* _KERNEL */
+
+#include 
+
+#ifdef _KERNEL
+static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers");
+#define	SBMALLOC(size)		malloc(size, M_SBUF, M_WAITOK|M_ZERO)
+#define	SBFREE(buf)		free(buf, M_SBUF)
+#else /* _KERNEL */
+#define	KASSERT(e, m)
+#define	SBMALLOC(size)		calloc(1, size)
+#define	SBFREE(buf)		free(buf)
+#endif /* _KERNEL */
+
+/*
+ * Predicates
+ */
+#define	SBUF_ISDYNAMIC(s)	((s)->s_flags & SBUF_DYNAMIC)
+#define	SBUF_ISDYNSTRUCT(s)	((s)->s_flags & SBUF_DYNSTRUCT)
+#define	SBUF_ISFINISHED(s)	((s)->s_flags & SBUF_FINISHED)
+#define	SBUF_HASROOM(s)		((s)->s_len < (s)->s_size - 1)
+#define	SBUF_FREESPACE(s)	((s)->s_size - ((s)->s_len + 1))
+#define	SBUF_CANEXTEND(s)	((s)->s_flags & SBUF_AUTOEXTEND)
+#define	SBUF_ISSECTION(s)	((s)->s_flags & SBUF_INSECTION)
+#define	SBUF_NULINCLUDED(s)	((s)->s_flags & SBUF_INCLUDENUL)
+#define	SBUF_ISDRAINTOEOR(s)	((s)->s_flags & SBUF_DRAINTOEOR)
+#define	SBUF_DODRAINTOEOR(s)	(SBUF_ISSECTION(s) && SBUF_ISDRAINTOEOR(s))
+
+/*
+ * Set / clear flags
+ */
+#define	SBUF_SETFLAG(s, f)	do { (s)->s_flags |= (f); } while (0)
+#define	SBUF_CLEARFLAG(s, f)	do { (s)->s_flags &= ~(f); } while (0)
+
+#define	SBUF_MINSIZE		 2		/* Min is 1 byte + nulterm. */
+#define	SBUF_MINEXTENDSIZE	16		/* Should be power of 2. */
+
+#ifdef PAGE_SIZE
+#define	SBUF_MAXEXTENDSIZE	PAGE_SIZE
+#define	SBUF_MAXEXTENDINCR	PAGE_SIZE
+#else
+#define	SBUF_MAXEXTENDSIZE	4096
+#define	SBUF_MAXEXTENDINCR	4096
+#endif
+
+/*
+ * Debugging support
+ */
+#if defined(_KERNEL) && defined(INVARIANTS)
+
+static void
+_assert_sbuf_integrity(const char *fun, struct sbuf *s)
+{
+
+	KASSERT(s != NULL,
+	("%s called with a NULL sbuf pointer", fun));
+	KASSERT(s->s_buf != NULL,
+	("%s called with uninitialized or corrupt sbuf", fun));
+	if (SBUF_ISFINISHED(s) && SBUF_NULINCLUDED(s)) {
+		KASSERT(s->s_len <= s->s_size,
+		("wrote past end of sbuf (%jd >= %jd)",
+		(intmax_t)s->s_len, (intmax_t)s->s_size));
+	} else {
+		KASSERT(s->s_len < s->s_size,
+		("wrote past end of sbuf (%jd >= %jd)",
+		(intmax_t)s->s_len, (intmax_t)s->s_size));
+	}
+}
+
+static void
+_assert_sbuf_state(const char *fun, struct sbuf *s, int state)
+{
+
+	KASSERT((s->s_flags & SBUF_FINISHED) == state,
+	("%s called with %sfinished or corrupt sbuf", fun,
+	(state ? "un" : "")));
+}
+
+#define	assert_sbuf_integrity(s) _assert_sbuf_integrity(__func__, (s))
+#define	assert_sbuf_state(s, i)	 _assert_sbuf_state(__func__,

CVS commit: [phil-wifi] src/sys/net80211

2018-06-28 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Thu Jun 28 21:23:01 UTC 2018

Modified Files:
src/sys/net80211 [phil-wifi]: _ieee80211.h ieee80211.h
ieee80211_action.h ieee80211_adhoc.h ieee80211_ageq.h
ieee80211_alq.h ieee80211_amrr.h ieee80211_crypto.h ieee80211_dfs.h
ieee80211_hostap.h ieee80211_ht.h ieee80211_input.h
ieee80211_ioctl.h ieee80211_mesh.h ieee80211_monitor.h
ieee80211_netbsd.h ieee80211_node.h ieee80211_phy.h
ieee80211_power.h ieee80211_proto.h ieee80211_radiotap.h
ieee80211_ratectl.h ieee80211_regdomain.h ieee80211_rssadapt.h
ieee80211_scan.h ieee80211_scan_sw.h ieee80211_sta.h
ieee80211_superg.h ieee80211_tdma.h ieee80211_var.h ieee80211_vht.h
ieee80211_wds.h

Log Message:
Add RCS ID at the top of all the files.


To generate a diff of this commit:
cvs rdiff -u -r1.10.38.1 -r1.10.38.2 src/sys/net80211/_ieee80211.h
cvs rdiff -u -r1.28.16.1 -r1.28.16.2 src/sys/net80211/ieee80211.h
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/net80211/ieee80211_action.h \
src/sys/net80211/ieee80211_adhoc.h src/sys/net80211/ieee80211_ageq.h \
src/sys/net80211/ieee80211_alq.h src/sys/net80211/ieee80211_dfs.h \
src/sys/net80211/ieee80211_hostap.h src/sys/net80211/ieee80211_input.h \
src/sys/net80211/ieee80211_mesh.h src/sys/net80211/ieee80211_monitor.h \
src/sys/net80211/ieee80211_phy.h src/sys/net80211/ieee80211_ratectl.h \
src/sys/net80211/ieee80211_scan_sw.h src/sys/net80211/ieee80211_sta.h \
src/sys/net80211/ieee80211_superg.h src/sys/net80211/ieee80211_tdma.h \
src/sys/net80211/ieee80211_vht.h src/sys/net80211/ieee80211_wds.h
cvs rdiff -u -r1.1.148.1 -r1.1.148.2 src/sys/net80211/ieee80211_amrr.h
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/sys/net80211/ieee80211_crypto.h
cvs rdiff -u -r1.1.56.2 -r1.1.56.3 src/sys/net80211/ieee80211_ht.h \
src/sys/net80211/ieee80211_power.h src/sys/net80211/ieee80211_regdomain.h \
src/sys/net80211/ieee80211_scan.h
cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/net80211/ieee80211_ioctl.h
cvs rdiff -u -r1.21.2.1 -r1.21.2.2 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.30.2.1 -r1.30.2.2 src/sys/net80211/ieee80211_node.h
cvs rdiff -u -r1.23.16.1 -r1.23.16.2 src/sys/net80211/ieee80211_proto.h
cvs rdiff -u -r1.24.56.1 -r1.24.56.2 src/sys/net80211/ieee80211_radiotap.h
cvs rdiff -u -r1.9.18.1 -r1.9.18.2 src/sys/net80211/ieee80211_rssadapt.h
cvs rdiff -u -r1.33.2.1 -r1.33.2.2 src/sys/net80211/ieee80211_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net80211/_ieee80211.h
diff -u src/sys/net80211/_ieee80211.h:1.10.38.1 src/sys/net80211/_ieee80211.h:1.10.38.2
--- src/sys/net80211/_ieee80211.h:1.10.38.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/_ieee80211.h	Thu Jun 28 21:23:01 2018
@@ -1,3 +1,5 @@
+/*	$NetBSD: _ieee80211.h,v 1.10.38.2 2018/06/28 21:23:01 phil Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *

Index: src/sys/net80211/ieee80211.h
diff -u src/sys/net80211/ieee80211.h:1.28.16.1 src/sys/net80211/ieee80211.h:1.28.16.2
--- src/sys/net80211/ieee80211.h:1.28.16.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/ieee80211.h	Thu Jun 28 21:23:01 2018
@@ -1,3 +1,5 @@
+/*	$NetBSD: ieee80211.h,v 1.28.16.2 2018/06/28 21:23:01 phil Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *

Index: src/sys/net80211/ieee80211_action.h
diff -u src/sys/net80211/ieee80211_action.h:1.1.2.1 src/sys/net80211/ieee80211_action.h:1.1.2.2
--- src/sys/net80211/ieee80211_action.h:1.1.2.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/ieee80211_action.h	Thu Jun 28 21:23:01 2018
@@ -1,3 +1,5 @@
+/*	$NetBSD: ieee80211_action.h,v 1.1.2.2 2018/06/28 21:23:01 phil Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
Index: src/sys/net80211/ieee80211_adhoc.h
diff -u src/sys/net80211/ieee80211_adhoc.h:1.1.2.1 src/sys/net80211/ieee80211_adhoc.h:1.1.2.2
--- src/sys/net80211/ieee80211_adhoc.h:1.1.2.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/ieee80211_adhoc.h	Thu Jun 28 21:23:01 2018
@@ -1,3 +1,5 @@
+/*	$NetBSD: ieee80211_adhoc.h,v 1.1.2.2 2018/06/28 21:23:01 phil Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
Index: src/sys/net80211/ieee80211_ageq.h
diff -u src/sys/net80211/ieee80211_ageq.h:1.1.2.1 src/sys/net80211/ieee80211_ageq.h:1.1.2.2
--- src/sys/net80211/ieee80211_ageq.h:1.1.2.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/ieee80211_ageq.h	Thu Jun 28 21:23:01 2018
@@ -1,3 +1,5 @@
+/*	$NetBSD: ieee80211_ageq.h,v 1.1.2.2 2018/06/28 21:23:01 phil Exp $ */
+
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
Index: src/sys/net80211/ieee80211_alq.h
diff -u src/sys/net80211/ieee80211_alq.h:1.1.2.1 src/sys/net80211/ieee80211_alq.h:1.1.2.2
--- src/sys/net80211/ieee80211_alq.h:1.1.2.1	Thu Jun 28 21:03:07 2018
+++ src/sys/net80211/ieee80211_alq.h	Thu Jun 28 21:2

CVS commit: [phil-wifi] src/sys/net80211

2018-06-28 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Thu Jun 28 21:03:08 UTC 2018

Modified Files:
src/sys/net80211 [phil-wifi]: CHANGES _ieee80211.h ieee80211.c
ieee80211.h ieee80211_acl.c ieee80211_amrr.c ieee80211_amrr.h
ieee80211_crypto.c ieee80211_crypto.h ieee80211_crypto_ccmp.c
ieee80211_crypto_none.c ieee80211_crypto_tkip.c
ieee80211_crypto_wep.c ieee80211_input.c ieee80211_ioctl.c
ieee80211_ioctl.h ieee80211_netbsd.c ieee80211_netbsd.h
ieee80211_node.c ieee80211_node.h ieee80211_output.c
ieee80211_proto.c ieee80211_proto.h ieee80211_radiotap.h
ieee80211_rssadapt.c ieee80211_rssadapt.h ieee80211_var.h
ieee80211_xauth.c
Added Files:
src/sys/net80211 [phil-wifi]: ieee80211_action.c ieee80211_action.h
ieee80211_adhoc.c ieee80211_adhoc.h ieee80211_ageq.c
ieee80211_ageq.h ieee80211_alq.c ieee80211_alq.h ieee80211_ddb.c
ieee80211_dfs.c ieee80211_dfs.h ieee80211_hostap.c
ieee80211_hostap.h ieee80211_ht.c ieee80211_ht.h ieee80211_hwmp.c
ieee80211_input.h ieee80211_mesh.c ieee80211_mesh.h
ieee80211_monitor.c ieee80211_monitor.h ieee80211_phy.c
ieee80211_phy.h ieee80211_power.c ieee80211_power.h
ieee80211_radiotap.c ieee80211_ratectl.c ieee80211_ratectl.h
ieee80211_ratectl_none.c ieee80211_regdomain.c
ieee80211_regdomain.h ieee80211_scan.c ieee80211_scan.h
ieee80211_scan_sta.c ieee80211_scan_sw.c ieee80211_scan_sw.h
ieee80211_sta.c ieee80211_sta.h ieee80211_superg.c
ieee80211_superg.h ieee80211_tdma.c ieee80211_tdma.h
ieee80211_vht.c ieee80211_vht.h ieee80211_wds.c ieee80211_wds.h

Log Message:
Start of WiFi refresh.  Copy of FreeBSD net80211 directory with git
mirror commit id of 09e3123164ec345822e00465039503686efde455, no
changes yet.  ieee80211_netbsd.[ch] from ieee80211_freebsd.[ch].


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.166.1 src/sys/net80211/CHANGES
cvs rdiff -u -r1.10 -r1.10.38.1 src/sys/net80211/_ieee80211.h
cvs rdiff -u -r1.56 -r1.56.18.1 src/sys/net80211/ieee80211.c
cvs rdiff -u -r1.28 -r1.28.16.1 src/sys/net80211/ieee80211.h
cvs rdiff -u -r1.9 -r1.9.54.1 src/sys/net80211/ieee80211_acl.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/net80211/ieee80211_action.c \
src/sys/net80211/ieee80211_action.h src/sys/net80211/ieee80211_adhoc.c \
src/sys/net80211/ieee80211_adhoc.h src/sys/net80211/ieee80211_ageq.c \
src/sys/net80211/ieee80211_ageq.h src/sys/net80211/ieee80211_alq.c \
src/sys/net80211/ieee80211_alq.h src/sys/net80211/ieee80211_ddb.c \
src/sys/net80211/ieee80211_dfs.c src/sys/net80211/ieee80211_dfs.h \
src/sys/net80211/ieee80211_hostap.c src/sys/net80211/ieee80211_hostap.h \
src/sys/net80211/ieee80211_hwmp.c src/sys/net80211/ieee80211_input.h \
src/sys/net80211/ieee80211_mesh.c src/sys/net80211/ieee80211_mesh.h \
src/sys/net80211/ieee80211_monitor.c src/sys/net80211/ieee80211_monitor.h \
src/sys/net80211/ieee80211_phy.c src/sys/net80211/ieee80211_phy.h \
src/sys/net80211/ieee80211_radiotap.c \
src/sys/net80211/ieee80211_ratectl.c src/sys/net80211/ieee80211_ratectl.h \
src/sys/net80211/ieee80211_ratectl_none.c \
src/sys/net80211/ieee80211_scan_sw.c src/sys/net80211/ieee80211_scan_sw.h \
src/sys/net80211/ieee80211_sta.c src/sys/net80211/ieee80211_sta.h \
src/sys/net80211/ieee80211_superg.c src/sys/net80211/ieee80211_superg.h \
src/sys/net80211/ieee80211_tdma.c src/sys/net80211/ieee80211_tdma.h \
src/sys/net80211/ieee80211_vht.c src/sys/net80211/ieee80211_vht.h \
src/sys/net80211/ieee80211_wds.c src/sys/net80211/ieee80211_wds.h
cvs rdiff -u -r1.3 -r1.3.18.1 src/sys/net80211/ieee80211_amrr.c
cvs rdiff -u -r1.1 -r1.1.148.1 src/sys/net80211/ieee80211_amrr.h
cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/net80211/ieee80211_crypto.c
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/net80211/ieee80211_crypto.h
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/net80211/ieee80211_crypto_ccmp.c
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/net80211/ieee80211_crypto_none.c
cvs rdiff -u -r1.14 -r1.14.4.1 src/sys/net80211/ieee80211_crypto_tkip.c
cvs rdiff -u -r1.12 -r1.12.2.1 src/sys/net80211/ieee80211_crypto_wep.c
cvs rdiff -u -r0 -r1.1.56.2 src/sys/net80211/ieee80211_ht.c \
src/sys/net80211/ieee80211_ht.h src/sys/net80211/ieee80211_power.c \
src/sys/net80211/ieee80211_power.h src/sys/net80211/ieee80211_regdomain.c \
src/sys/net80211/ieee80211_regdomain.h src/sys/net80211/ieee80211_scan.c \
src/sys/net80211/ieee80211_scan.h src/sys/net80211/ieee80211_scan_sta.c
cvs rdiff -u -r1.114 -r1.114.2.1 src/sys/net80211/ieee80211_input.c
cvs rdiff -u -r1.60 -r1.60.18.1 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/net80211/ieee80211_ioctl.h
cvs rdiff -u -r1.31 -r1.31.2.1 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21 -r1.21.2.1