Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jan 2004 15:20:22 -0800 (PST)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 45818 for review
Message-ID:  <200401232320.i0NNKMYW036736@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=45818

Change 45818 by sam@sam_ebb on 2004/01/23 15:19:23

	IFC

Affected files ...

.. //depot/projects/netperf+sockets/sys/alpha/alpha/support.s#2 integrate
.. //depot/projects/netperf+sockets/sys/amd64/amd64/cpu_switch.S#3 integrate
.. //depot/projects/netperf+sockets/sys/boot/i386/libi386/biosdisk.c#2 integrate
.. //depot/projects/netperf+sockets/sys/compat/ndis/kern_ndis.c#12 integrate
.. //depot/projects/netperf+sockets/sys/compat/ndis/ndis_var.h#11 integrate
.. //depot/projects/netperf+sockets/sys/compat/ndis/ntoskrnl_var.h#5 integrate
.. //depot/projects/netperf+sockets/sys/compat/ndis/subr_ndis.c#12 integrate
.. //depot/projects/netperf+sockets/sys/compat/ndis/subr_ntoskrnl.c#10 integrate
.. //depot/projects/netperf+sockets/sys/compat/svr4/svr4_misc.c#3 integrate
.. //depot/projects/netperf+sockets/sys/conf/files.i386#5 integrate
.. //depot/projects/netperf+sockets/sys/conf/files.pc98#4 integrate
.. //depot/projects/netperf+sockets/sys/conf/files.powerpc#3 integrate
.. //depot/projects/netperf+sockets/sys/conf/kern.post.mk#6 integrate
.. //depot/projects/netperf+sockets/sys/conf/kern.pre.mk#5 integrate
.. //depot/projects/netperf+sockets/sys/conf/options.i386#6 integrate
.. //depot/projects/netperf+sockets/sys/conf/options.powerpc#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/acpica/acpi_pci_link.c#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/amd/amd.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-all.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-all.h#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-chipset.c#7 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-disk.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-pci.h#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/ata-queue.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/ata/atapi-cd.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/fb/fbreg.h#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/firewire/fwdev.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/firewire/fwohci.c#6 integrate
.. //depot/projects/netperf+sockets/sys/dev/firewire/fwohci_pci.c#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/firewire/sbp_targ.c#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/if_ndis/if_ndis.c#12 integrate
.. //depot/projects/netperf+sockets/sys/dev/if_ndis/if_ndisvar.h#6 integrate
.. //depot/projects/netperf+sockets/sys/dev/lnc/if_lnc_pci.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/pccard/pccarddevs#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/pccard/pccarddevs.h#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/ac97.c#3 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/dsp.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/dsp.h#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/sound.c#4 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/sound.h#3 integrate
.. //depot/projects/netperf+sockets/sys/dev/sound/pcm/vchan.c#3 integrate
.. //depot/projects/netperf+sockets/sys/dev/syscons/scgfbrndr.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/syscons/schistory.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/syscons/scterm-dumb.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/syscons/scterm-sc.c#2 integrate
.. //depot/projects/netperf+sockets/sys/dev/syscons/syscons.c#3 integrate
.. //depot/projects/netperf+sockets/sys/dev/usb/umass.c#5 integrate
.. //depot/projects/netperf+sockets/sys/dev/usb/usbdevs#10 integrate
.. //depot/projects/netperf+sockets/sys/dev/usb/usbdevs.h#10 integrate
.. //depot/projects/netperf+sockets/sys/dev/usb/usbdevs_data.h#10 integrate
.. //depot/projects/netperf+sockets/sys/fs/devfs/devfs_rule.c#2 integrate
.. //depot/projects/netperf+sockets/sys/geom/bde/g_bde_crypt.c#2 integrate
.. //depot/projects/netperf+sockets/sys/geom/geom_dev.c#2 integrate
.. //depot/projects/netperf+sockets/sys/geom/geom_disk.c#3 integrate
.. //depot/projects/netperf+sockets/sys/geom/geom_event.c#4 integrate
.. //depot/projects/netperf+sockets/sys/geom/geom_subr.c#4 integrate
.. //depot/projects/netperf+sockets/sys/gnu/ext2fs/ext2_readwrite.c#2 integrate
.. //depot/projects/netperf+sockets/sys/i386/conf/NOTES#7 integrate
.. //depot/projects/netperf+sockets/sys/i386/i386/p4tcc.c#1 branch
.. //depot/projects/netperf+sockets/sys/i386/i386/swtch.s#2 integrate
.. //depot/projects/netperf+sockets/sys/i386/include/specialreg.h#2 integrate
.. //depot/projects/netperf+sockets/sys/ia64/ia64/interrupt.c#3 integrate
.. //depot/projects/netperf+sockets/sys/ia64/ia64/trap.c#4 integrate
.. //depot/projects/netperf+sockets/sys/isofs/cd9660/cd9660_vnops.c#2 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_exit.c#3 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_fork.c#5 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_jail.c#3 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_ktrace.c#3 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_prot.c#4 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_shutdown.c#2 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_tc.c#3 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_thread.c#6 integrate
.. //depot/projects/netperf+sockets/sys/kern/kern_uuid.c#2 integrate
.. //depot/projects/netperf+sockets/sys/kern/sys_generic.c#3 integrate
.. //depot/projects/netperf+sockets/sys/kern/uipc_sem.c#2 integrate
.. //depot/projects/netperf+sockets/sys/kern/uipc_syscalls.c#8 integrate
.. //depot/projects/netperf+sockets/sys/modules/firewire/Makefile#2 integrate
.. //depot/projects/netperf+sockets/sys/modules/if_ef/Makefile#2 integrate
.. //depot/projects/netperf+sockets/sys/modules/ncp/Makefile#2 integrate
.. //depot/projects/netperf+sockets/sys/modules/netgraph/Makefile#2 integrate
.. //depot/projects/netperf+sockets/sys/modules/nwfs/Makefile#3 integrate
.. //depot/projects/netperf+sockets/sys/modules/smbfs/Makefile#3 integrate
.. //depot/projects/netperf+sockets/sys/modules/syscons/Makefile#2 integrate
.. //depot/projects/netperf+sockets/sys/net/if.c#5 integrate
.. //depot/projects/netperf+sockets/sys/net/if_media.h#4 integrate
.. //depot/projects/netperf+sockets/sys/net/if_ppp.c#3 integrate
.. //depot/projects/netperf+sockets/sys/net/if_spppsubr.c#3 integrate
.. //depot/projects/netperf+sockets/sys/net/if_vlan_var.h#4 integrate
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_ioctl.c#10 integrate
.. //depot/projects/netperf+sockets/sys/netgraph/ng_cisco.c#2 integrate
.. //depot/projects/netperf+sockets/sys/netgraph/ng_socket.c#3 integrate
.. //depot/projects/netperf+sockets/sys/netinet/tcp_input.c#7 integrate
.. //depot/projects/netperf+sockets/sys/netinet/tcp_output.c#3 integrate
.. //depot/projects/netperf+sockets/sys/netinet/tcp_syncache.c#5 integrate
.. //depot/projects/netperf+sockets/sys/netipsec/ipsec.h#2 integrate
.. //depot/projects/netperf+sockets/sys/netipsec/ipsec_output.c#2 integrate
.. //depot/projects/netperf+sockets/sys/netipsec/xform_ipip.c#2 integrate
.. //depot/projects/netperf+sockets/sys/pc98/conf/NOTES#6 integrate
.. //depot/projects/netperf+sockets/sys/pc98/pc98/sio.c#4 integrate
.. //depot/projects/netperf+sockets/sys/pci/if_rl.c#5 integrate
.. //depot/projects/netperf+sockets/sys/pci/if_sk.c#3 integrate
.. //depot/projects/netperf+sockets/sys/powerpc/conf/GENERIC#2 integrate
.. //depot/projects/netperf+sockets/sys/powerpc/include/float.h#2 integrate
.. //depot/projects/netperf+sockets/sys/powerpc/include/sc_machdep.h#1 branch
.. //depot/projects/netperf+sockets/sys/powerpc/ofw/ofw_syscons.c#1 branch
.. //depot/projects/netperf+sockets/sys/powerpc/ofw/ofw_syscons.h#1 branch
.. //depot/projects/netperf+sockets/sys/powerpc/powerpc/clock.c#2 integrate
.. //depot/projects/netperf+sockets/sys/powerpc/powerpc/machdep.c#5 integrate
.. //depot/projects/netperf+sockets/sys/powerpc/powerpc/sc_machdep.c#1 branch
.. //depot/projects/netperf+sockets/sys/powerpc/powerpc/trap_subr.S#2 integrate
.. //depot/projects/netperf+sockets/sys/security/mac_portacl/mac_portacl.c#2 integrate
.. //depot/projects/netperf+sockets/sys/sys/_task.h#1 branch
.. //depot/projects/netperf+sockets/sys/sys/jail.h#2 integrate
.. //depot/projects/netperf+sockets/sys/sys/proc.h#5 integrate
.. //depot/projects/netperf+sockets/sys/sys/systm.h#4 integrate
.. //depot/projects/netperf+sockets/sys/sys/taskqueue.h#2 integrate
.. //depot/projects/netperf+sockets/sys/sys/user.h#2 integrate
.. //depot/projects/netperf+sockets/sys/ufs/ffs/ffs_vnops.c#2 integrate

Differences ...

==== //depot/projects/netperf+sockets/sys/alpha/alpha/support.s#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/alpha/support.s,v 1.15 2003/07/24 07:49:45 marcel Exp $
+ * $FreeBSD: src/sys/alpha/alpha/support.s,v 1.16 2004/01/19 21:27:10 phk Exp $
  */
 
 /*
@@ -680,8 +680,10 @@
 
 longjmp_botch:
 	lda	a0, longjmp_botchmsg
-	mov	ra, a1
-	CALL(panic)
+	mov	0, a1
+	mov	0, a2
+	mov	ra, a3
+	CALL(__panic)
 	call_pal PAL_bugchk
 
 	.data

==== //depot/projects/netperf+sockets/sys/amd64/amd64/cpu_switch.S#3 (text+ko) ====

@@ -34,7 +34,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.144 2003/11/17 08:58:12 peter Exp $
+ * $FreeBSD: src/sys/amd64/amd64/cpu_switch.S,v 1.145 2004/01/23 01:04:28 peter Exp $
  */
 
 #include <machine/asmacros.h>
@@ -243,7 +243,7 @@
 	pushq	%r14
 	pushq	%r15
 	pushq	$sw0_1
-	call	panic
+	call	__panic
 sw0_1:	.asciz	"cpu_throw: no newthread supplied"
 
 badsw2:
@@ -263,7 +263,7 @@
 	pushq	%r14
 	pushq	%r15
 	pushq	$sw0_2
-	call	panic
+	call	__panic
 sw0_2:	.asciz	"cpu_switch: no curthread supplied"
 
 badsw3:
@@ -283,7 +283,7 @@
 	pushq	%r14
 	pushq	%r15
 	pushq	$sw0_3
-	call	panic
+	call	__panic
 sw0_3:	.asciz	"cpu_switch: no newthread supplied"
 #endif
 

==== //depot/projects/netperf+sockets/sys/boot/i386/libi386/biosdisk.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosdisk.c,v 1.40 2003/08/25 23:28:31 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosdisk.c,v 1.41 2004/01/21 23:22:29 jhb Exp $");
 
 /*
  * BIOS disk device handling.
@@ -867,7 +867,7 @@
 	 */
 	x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
 	bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
-	if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(dest + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
+	if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
 	    breg = bbuf;
 	} else {
 	    breg = bbuf + x * BIOSDISK_SECSIZE;
@@ -1000,7 +1000,7 @@
 
 	x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
 	bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
-	if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(dest + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
+	if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
 	    breg = bbuf;
 	} else {
 	    breg = bbuf + x * BIOSDISK_SECSIZE;

==== //depot/projects/netperf+sockets/sys/compat/ndis/kern_ndis.c#12 (text+ko) ====

@@ -31,23 +31,25 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.29 2004/01/13 22:49:45 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.32 2004/01/21 19:14:52 wpaul Exp $");
 
 #include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/unistd.h>
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <sys/callout.h>
 #include <sys/socket.h>
 #include <sys/queue.h>
 #include <sys/sysctl.h>
-#include <sys/systm.h>
+#include <sys/proc.h>
 #include <sys/malloc.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/conf.h>
-#include <sys/taskqueue.h>
 
 #include <sys/kernel.h>
+#include <sys/kthread.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <sys/bus.h>
@@ -85,7 +87,35 @@
 __stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
 __stdcall static void ndis_sendrsrcavail_func(ndis_handle);
 
+struct ndis_req {
+	void			(*nr_func)(void *);
+	void			*nr_arg;
+	int			nr_exit;
+	STAILQ_ENTRY(ndis_req)	link;
+};
+
+struct ndisproc {
+	struct ndisqhead	*np_q;
+	struct proc		*np_p;
+};
+
+static int ndis_create_kthreads(void);
+static void ndis_destroy_kthreads(void);
+static void ndis_stop_thread(int);
+static int ndis_enlarge_thrqueue(int);
+static int ndis_shrink_thrqueue(int);
+static void ndis_runq(void *);
+
+extern struct mtx_pool *ndis_mtxpool;
 static uma_zone_t ndis_packet_zone, ndis_buffer_zone;
+struct mtx *ndis_thr_mtx;
+static STAILQ_HEAD(ndisqhead, ndis_req) ndis_ttodo;
+struct ndisqhead ndis_itodo;
+struct ndisqhead ndis_free;
+static int ndis_jobs = 32;
+
+static struct ndisproc ndis_tproc;
+static struct ndisproc ndis_iproc;
 
 /*
  * This allows us to export our symbols to other modules.
@@ -111,9 +141,15 @@
 		ndis_buffer_zone = uma_zcreate("NDIS buffer",
 		    sizeof(ndis_buffer), NULL, NULL, NULL,
 		    NULL, UMA_ALIGN_PTR, 0);
+
+		ndis_create_kthreads();
+
 		break;
 	case MOD_UNLOAD:
 	case MOD_SHUTDOWN:
+		/* stop kthreads */
+		ndis_destroy_kthreads();
+
 		/* Shut down subsystems */
 		ndis_libfini();
 		ntoskrnl_libfini();
@@ -132,7 +168,268 @@
 DEV_MODULE(ndisapi, ndis_modevent, NULL);
 MODULE_VERSION(ndisapi, 1);
 
+/*
+ * We create two kthreads for the NDIS subsystem. One of them is a task
+ * queue for performing various odd jobs. The other is an swi thread
+ * reserved exclusively for running interrupt handlers. The reason we
+ * have our own task queue is that there are some cases where we may
+ * need to sleep for a significant amount of time, and if we were to
+ * use one of the taskqueue threads, we might delay the processing
+ * of other pending tasks which might need to run right away. We have
+ * a separate swi thread because we don't want our interrupt handling
+ * to be delayed either.
+ *
+ * By default there are 32 jobs available to start, and another 8
+ * are added to the free list each time a new device is created.
+ */
+
+static void
+ndis_runq(arg)
+	void			*arg;
+{
+	struct ndis_req		*r = NULL, *die = NULL;
+	struct ndisproc		*p;
+
+	p = arg;
+
+	while (1) {
+		kthread_suspend(p->np_p, 0);
+
+		/* Look for any jobs on the work queue. */
+
+		mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+		while(STAILQ_FIRST(p->np_q) != NULL) {
+			r = STAILQ_FIRST(p->np_q);
+			STAILQ_REMOVE_HEAD(p->np_q, link);
+			mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+
+			/* Do the work. */
+
+			if (r->nr_func != NULL)
+				(*r->nr_func)(r->nr_arg);
+
+			mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+			STAILQ_INSERT_HEAD(&ndis_free, r, link);
+
+			/* Check for a shutdown request */
+
+			if (r->nr_exit == TRUE)
+				die = r;
+		}
+		mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+
+		/* Bail if we were told to shut down. */
+
+		if (die != NULL)
+			break;
+	}
+
+	wakeup(die);
+	mtx_lock(&Giant);
+	kthread_exit(0);
+}
+
+static int
+ndis_create_kthreads()
+{
+	struct ndis_req		*r;
+	int			i, error = 0;
+
+	ndis_thr_mtx = mtx_pool_alloc(ndis_mtxpool);
+	STAILQ_INIT(&ndis_ttodo);
+	STAILQ_INIT(&ndis_itodo);
+	STAILQ_INIT(&ndis_free);
+
+	for (i = 0; i < ndis_jobs; i++) {
+		r = malloc(sizeof(struct ndis_req), M_DEVBUF, M_WAITOK);
+		if (r == NULL) {
+			error = ENOMEM;
+			break;
+		}
+		STAILQ_INSERT_HEAD(&ndis_free, r, link);
+	}
+
+	if (error == 0) {
+		ndis_tproc.np_q = &ndis_ttodo;
+		error = kthread_create(ndis_runq, &ndis_tproc,
+		    &ndis_tproc.np_p, RFHIGHPID, 0, "ndis taskqueue");
+	}
+
+	if (error == 0) {
+		ndis_iproc.np_q = &ndis_itodo;
+		error = kthread_create(ndis_runq, &ndis_iproc,
+		    &ndis_iproc.np_p, RFHIGHPID, 0, "ndis swi");
+	}
+
+	if (error) {
+		while ((r = STAILQ_FIRST(&ndis_free)) != NULL) {
+			STAILQ_REMOVE_HEAD(&ndis_free, link);
+			free(r, M_DEVBUF);
+		}
+		return(error);
+	}
+
+	return(0);
+}
+
+static void
+ndis_destroy_kthreads()
+{
+	struct ndis_req		*r;
+
+	/* Stop the threads. */
+
+	ndis_stop_thread(NDIS_TASKQUEUE);
+	ndis_stop_thread(NDIS_SWI);
+
+	/* Destroy request structures. */
 
+	while ((r = STAILQ_FIRST(&ndis_free)) != NULL) {
+		STAILQ_REMOVE_HEAD(&ndis_free, link);
+		free(r, M_DEVBUF);
+	}
+
+	return;
+}
+
+static void
+ndis_stop_thread(t)
+	int			t;
+{
+	struct ndis_req		*r;
+	struct timeval		tv;
+	struct ndisqhead	*q;
+	struct proc		*p;
+
+	if (t == NDIS_TASKQUEUE) {
+		q = &ndis_ttodo;
+		p = ndis_tproc.np_p;
+	} else {
+		q = &ndis_itodo;
+		p = ndis_iproc.np_p;
+	}
+
+	/* Create and post a special 'exit' job. */
+
+	mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+	r = STAILQ_FIRST(&ndis_free);
+	STAILQ_REMOVE_HEAD(&ndis_free, link);
+	r->nr_func = NULL;
+	r->nr_arg = NULL;
+	r->nr_exit = TRUE;
+	STAILQ_INSERT_TAIL(q, r, link);
+	mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+
+	kthread_resume(p);
+
+	/* wait for thread exit */
+
+	tv.tv_sec = 60;
+	tv.tv_usec = 0;
+	tsleep(r, PPAUSE|PCATCH, "ndisthrexit", tvtohz(&tv));
+
+	/* Now empty the job list. */
+
+	mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+	while ((r = STAILQ_FIRST(q)) != NULL) {
+		STAILQ_REMOVE_HEAD(q, link);
+		STAILQ_INSERT_HEAD(&ndis_free, r, link);
+	}
+	mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+
+	return;
+}
+
+static int
+ndis_enlarge_thrqueue(cnt)
+	int			cnt;
+{
+	struct ndis_req		*r;
+	int			i;
+
+	for (i = 0; i < cnt; i++) {
+		r = malloc(sizeof(struct ndis_req), M_DEVBUF, M_WAITOK);
+		if (r == NULL)
+			return(ENOMEM);
+		mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+		STAILQ_INSERT_HEAD(&ndis_free, r, link);
+		ndis_jobs++;
+		mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+	}
+
+	return(0);
+}
+
+static int
+ndis_shrink_thrqueue(cnt)
+	int			cnt;
+{
+	struct ndis_req		*r;
+	int			i;
+
+	for (i = 0; i < cnt; i++) {
+		mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+		r = STAILQ_FIRST(&ndis_free);
+		if (r == NULL) {
+			mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+			return(ENOMEM);
+		}
+		STAILQ_REMOVE_HEAD(&ndis_free, link);
+		ndis_jobs--;
+		mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+		free(r, M_DEVBUF);
+	}
+
+	return(0);
+}
+
+int
+ndis_sched(func, arg, t)
+	void			(*func)(void *);
+	void			*arg;
+	int			t;
+{
+	struct ndis_req		*r;
+	struct ndisqhead	*q;
+	struct proc		*p;
+
+	if (t == NDIS_TASKQUEUE) {
+		q = &ndis_ttodo;
+		p = ndis_tproc.np_p;
+	} else {
+		q = &ndis_itodo;
+		p = ndis_iproc.np_p;
+	}
+
+	mtx_pool_lock(ndis_mtxpool, ndis_thr_mtx);
+	/*
+	 * Check to see if an instance of this job is already
+	 * pending. If so, don't bother queuing it again.
+	 */
+	STAILQ_FOREACH(r, q, link) {
+		if (r->nr_func == func && r->nr_arg == arg) {
+			mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+			return(0);
+		}
+	}
+	r = STAILQ_FIRST(&ndis_free);
+	if (r == NULL) {
+		mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+		return(EAGAIN);
+	}
+	STAILQ_REMOVE_HEAD(&ndis_free, link);
+	r->nr_func = func;
+	r->nr_arg = arg;
+	r->nr_exit = FALSE;
+	STAILQ_INSERT_TAIL(q, r, link);
+	mtx_pool_unlock(ndis_mtxpool, ndis_thr_mtx);
+
+	/* Post the job. */
+	kthread_resume(p);
+
+	return(0);
+}
+
 __stdcall static void
 ndis_sendrsrcavail_func(adapter)
 	ndis_handle		adapter;
@@ -704,6 +1001,9 @@
 	    rval == NDIS_STATUS_NOT_ACCEPTED)
 		return(ENOTSUP);
 
+	if (rval != NDIS_STATUS_SUCCESS)
+		return(ENODEV);
+
 	return(0);
 }
 
@@ -1065,6 +1365,9 @@
 	    rval == NDIS_STATUS_NOT_ACCEPTED)
 		return(ENOTSUP);
 
+	if (rval != NDIS_STATUS_SUCCESS)
+		return(ENODEV);
+
 	return(0);
 }
 
@@ -1080,6 +1383,8 @@
 
 	ndis_flush_sysctls(sc);
 
+	ndis_shrink_thrqueue(8);
+
 	return(0);
 }
 
@@ -1186,5 +1491,7 @@
 	block->nmb_dev = sc->ndis_dev;
 	block->nmb_img = img;
 
+	ndis_enlarge_thrqueue(8);
+
 	return(0);
 }

==== //depot/projects/netperf+sockets/sys/compat/ndis/ndis_var.h#11 (text+ko) ====

@@ -29,7 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.16 2004/01/16 02:07:04 obrien Exp $
+ * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.18 2004/01/21 21:09:09 wpaul Exp $
  */
 
 #ifndef _NDIS_VAR_H_
@@ -573,6 +573,110 @@
 
 typedef struct ndis_80211_test ndis_80211_test;
 
+/* TCP OIDs. */
+
+#define OID_TCP_TASK_OFFLOAD			0xFC010201
+#define OID_TCP_TASK_IPSEC_ADD_SA		0xFC010202
+#define OID_TCP_TASK_IPSEC_DELETE_SA		0xFC010203
+#define OID_TCP_SAN_SUPPORT			0xFC010204
+
+
+#define NDIS_TASK_OFFLOAD_VERSION 1
+
+#define NDIS_TASK_TCPIP_CSUM			0x00000000
+#define NDIS_TASK_IPSEC				0x00000001
+#define NDIS_TASK_TCP_LARGESEND			0x00000002
+
+#define NDIS_ENCAP_UNSPEC			0x00000000
+#define NDIS_ENCAP_NULL				0x00000001
+#define NDIS_ENCAP_IEEE802_3			0x00000002
+#define NDIS_ENCAP_IEEE802_5			0x00000003
+#define NDIS_ENCAP_SNAP_ROUTED			0x00000004
+#define NDIS_ENCAP_SNAP_BRIDGED			0x00000005
+
+#define NDIS_ENCAPFLAG_FIXEDHDRLEN		0x00000001
+
+struct ndis_encap_fmt {
+	uint32_t		nef_encap;
+	uint32_t		nef_flags;
+	uint32_t		nef_encaphdrlen;
+};
+
+typedef struct ndis_encap_fmt ndis_encap_fmt;
+
+struct ndis_task_offload_hdr {
+	uint32_t		ntoh_vers;
+	uint32_t		ntoh_len;
+	uint32_t		ntoh_rsvd;
+	uint32_t		ntoh_offset_firsttask;
+	ndis_encap_fmt		ntoh_encapfmt;
+};
+
+typedef struct ndis_task_offload_hdr ndis_task_offload_hdr;
+
+struct ndis_task_offload {
+	uint32_t		nto_vers;
+	uint32_t		nto_len;
+	uint32_t		nto_task;
+	uint32_t		nto_offset_nexttask;
+	uint32_t		nto_taskbuflen;
+	uint8_t			nto_taskbuf[1];
+};
+
+typedef struct ndis_task_offload ndis_task_offload;
+
+#define NDIS_TCPSUM_FLAGS_IP_OPTS	0x00000001
+#define NDIS_TCPSUM_FLAGS_TCP_OPTS	0x00000002
+#define NDIS_TCPSUM_FLAGS_TCP_CSUM	0x00000004
+#define NDIS_TCPSUM_FLAGS_UDP_CSUM	0x00000008
+#define NDIS_TCPSUM_FLAGS_IP_CSUM	0x00000010
+
+struct ndis_task_tcpip_csum {
+	uint32_t		nttc_v4tx;
+	uint32_t		nttc_v4rx;
+	uint32_t		nttc_v6tx;
+	uint32_t		nttc_v6rx;
+};
+
+typedef struct ndis_task_tcpip_csum ndis_task_tcpip_csum;
+
+struct ndis_task_tcp_largesend {
+	uint32_t		nttl_vers;
+	uint32_t		nttl_maxofflen;
+	uint32_t		nttl_minsegcnt;
+	uint8_t			nttl_tcpopt;
+	uint8_t			nttl_ipopt;
+};
+
+typedef struct ndis_task_tcp_largesend ndis_task_tcp_largesend;
+
+#define NDIS_IPSEC_AH_MD5		0x00000001
+#define NDIS_IPSEC_AH_SHA1		0x00000002
+#define NDIS_IPSEC_AH_TRANSPORT		0x00000004
+#define NDIS_IPSEC_AH_TUNNEL		0x00000008
+#define NDIS_IPSEC_AH_SEND		0x00000010
+#define NDIS_IPSEC_AH_RECEIVE		0x00000020
+
+#define NDIS_IPSEC_ESP_DES		0x00000001
+#define NDIS_IPSEC_ESP_RSVD		0x00000002
+#define NDIS_IPSEC_ESP_3DES		0x00000004
+#define NDIS_IPSEC_ESP_NULL		0x00000008
+#define NDIS_IPSEC_ESP_TRANSPORT	0x00000010
+#define NDIS_IPSEC_ESP_TUNNEL		0x00000020
+#define NDIS_IPSEC_ESP_SEND		0x00000040
+#define NDIS_IPSEC_ESP_RECEIVE		0x00000080
+
+struct ndis_task_ipsec {
+	uint32_t		nti_ah_esp_combined;
+	uint32_t		nti_ah_transport_tunnel_combined;
+	uint32_t		nti_v4_options;
+	uint32_t		nti_rsvd;
+	uint32_t		nti_v4ah;
+	uint32_t		nti_v4esp;
+};
+
+typedef struct ndis_task_ipsec ndis_task_ipsec;
+
 /*
  * Attribures of NDIS drivers. Not all drivers support
  * all attributes.
@@ -872,6 +976,43 @@
 
 typedef struct ndis_sc_list ndis_sc_list;
 
+struct ndis_tcpip_csum {
+	union {
+		uint32_t		ntc_txflags;
+		uint32_t		ntc_rxflags;
+		uint32_t		ntc_val;
+	} u;
+};
+
+typedef struct ndis_tcpip_csum ndis_tcpip_csum;
+
+#define NDIS_TXCSUM_DO_IPV4		0x00000001
+#define NDIS_TXCSUM_DO_IPV6		0x00000002
+#define NDIS_TXCSUM_DO_TCP		0x00000004
+#define NDIS_TXCSUM_DO_UDP		0x00000008
+#define NDIS_TXCSUM_DO_IP		0x00000010
+
+#define NDIS_RXCSUM_TCP_FAILED		0x00000001
+#define NDIS_RXCSUM_UDP_FAILED		0x00000002
+#define NDIS_RXCSUM_IP_FAILED		0x00000004
+#define NDIS_RXCSUM_TCP_PASSED		0x00000008
+#define NDIS_RXCSUM_UDP_PASSED		0x00000010
+#define NDIS_RXCSUM_IP_PASSED		0x00000020
+#define NDIS_RXCSUM_LOOPBACK		0x00000040
+
+struct ndis_vlan {
+	union {
+		struct {
+			uint32_t			nvt_userprio:3;
+			uint32_t			nvt_canformatid:1;
+			uint32_t			nvt_vlanid:12;
+			uint32_t			nvt_rsvd:16;
+		} nv_taghdr;
+	} u;
+};
+
+typedef struct ndis_vlan ndis_vlan;
+
 enum ndis_perpkt_info {
 	ndis_tcpipcsum_info,
 	ndis_ipsec_info,
@@ -1321,6 +1462,9 @@
 
 extern image_patch_table ndis_functbl[];
 
+#define NDIS_TASKQUEUE	1
+#define NDIS_SWI	2
+
 __BEGIN_DECLS
 extern int ndis_libinit(void);
 extern int ndis_libfini(void);
@@ -1353,6 +1497,7 @@
 extern int ndis_create_sysctls(void *);
 extern int ndis_add_sysctl(void *, char *, char *, char *, int);
 extern int ndis_flush_sysctls(void *);
+extern int ndis_sched(void (*)(void *), void *, int);
 __END_DECLS
 
 #endif /* _NDIS_VAR_H_ */

==== //depot/projects/netperf+sockets/sys/compat/ndis/ntoskrnl_var.h#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.5 2004/01/16 02:07:04 obrien Exp $
+ * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.6 2004/01/19 20:45:27 wpaul Exp $
  */
 
 #ifndef _NTOSKRNL_VAR_H_
@@ -55,6 +55,13 @@
 #define MDL_VA(b)						\
 	((void *)((char *)((b)->nb_startva) + (b)->nb_byteoffset))
 
+#define WDM_MAJOR		1
+#define WDM_MINOR_WIN98		0x00
+#define WDM_MINOR_WINME		0x05
+#define WDM_MINOR_WIN2000	0x10
+#define WDM_MINOR_WINXP		0x20
+#define WDM_MINOR_WIN2003	0x30
+
 /*-
  * The ndis_kspin_lock type is called KSPIN_LOCK in MS-Windows.
  * According to the Windows DDK header files, KSPIN_LOCK is defined like this:

==== //depot/projects/netperf+sockets/sys/compat/ndis/subr_ndis.c#12 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.37 2004/01/15 07:42:26 wpaul Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.38 2004/01/18 22:57:11 wpaul Exp $");
 
 /*
  * This file implements a translation layer between the BSD networking
@@ -64,7 +64,6 @@
 #include <sys/timespec.h>
 #include <sys/smp.h>
 #include <sys/queue.h>
-#include <sys/taskqueue.h>
 #include <sys/proc.h>
 #include <sys/namei.h>
 #include <sys/fcntl.h>
@@ -261,7 +260,7 @@
 __stdcall static void ndis_ind_statusdone(ndis_handle);
 __stdcall static void ndis_ind_status(ndis_handle, ndis_status,
         void *, uint32_t);
-static void ndis_workfunc(void *, int);
+static void ndis_workfunc(void *);
 __stdcall static ndis_status ndis_sched_workitem(ndis_work_item *);
 __stdcall static void ndis_pkt_to_pkt(ndis_packet *, uint32_t, uint32_t,
 	ndis_packet *, uint32_t, uint32_t *);
@@ -601,18 +600,18 @@
 	ndis_config_parm	*parm;
 	char			*val;
 {
-	uint16_t		*unicode;
 	ndis_unicode_string	*ustr;
+	char			*astr = NULL;
 
-	unicode = (uint16_t *)&block->nmb_dummybuf;
-
 	switch(parm->ncp_type) {
 	case ndis_parm_string:
 		ustr = &parm->ncp_parmdata.ncp_stringdata;
-		ndis_unicode_to_ascii(ustr->nus_buf, ustr->nus_len, &val);
+		ndis_unicode_to_ascii(ustr->nus_buf, ustr->nus_len, &astr);
+		bcopy(astr, val, 254);
+		free(astr, M_DEVBUF);
 		break;
 	case ndis_parm_int:
-		sprintf(val, "%ul", parm->ncp_parmdata.ncp_intdata);
+		sprintf(val, "%d", parm->ncp_parmdata.ncp_intdata);
 		break;
 	case ndis_parm_hexint:
 		sprintf(val, "%xu", parm->ncp_parmdata.ncp_intdata);
@@ -644,6 +643,7 @@
 	ndis_unicode_to_ascii(key->nus_buf, key->nus_len, &keystr);
 
 	/* Decode the parameter into a string. */
+	bzero(val, sizeof(val));
 	*status = ndis_decode_parm(block, parm, val);
 	if (*status != NDIS_STATUS_SUCCESS) {
 		free(keystr, M_DEVBUF);
@@ -2484,9 +2484,8 @@
 }
 
 static void
-ndis_workfunc(ctx, pending)
+ndis_workfunc(ctx)
 	void			*ctx;
-	int			pending;
 {
 	ndis_work_item		*work;
 	__stdcall ndis_proc	workfunc;
@@ -2501,11 +2500,7 @@
 ndis_sched_workitem(work)
 	ndis_work_item		*work;
 {
-	struct task		*t;
-
-	t = (struct task *)&work->nwi_wraprsvd;
-	TASK_INIT(t, 0, ndis_workfunc, work);
-	taskqueue_enqueue(taskqueue_swi, t);
+	ndis_sched(ndis_workfunc, work, NDIS_TASKQUEUE);
 	return(NDIS_STATUS_SUCCESS);
 }
 

==== //depot/projects/netperf+sockets/sys/compat/ndis/subr_ntoskrnl.c#10 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.17 2004/01/15 21:31:48 wpaul Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.19 2004/01/19 19:57:00 wpaul Exp $");
 
 #include <sys/ctype.h>
 #include <sys/param.h>
@@ -75,7 +75,8 @@
 	ndis_ansi_string *, uint8_t);
 __stdcall static void *ntoskrnl_iobuildsynchfsdreq(uint32_t, void *,
 	void *, uint32_t, uint32_t *, void *, void *);
-__stdcall static uint32_t ntoskrnl_iofcalldriver(void *, void *);
+__stdcall static uint32_t ntoskrnl_iofcalldriver(/*void *, void * */ void);
+__stdcall static void ntoskrnl_iofcompletereq(/*void *, uint8_t*/ void);
 __stdcall static uint32_t ntoskrnl_waitforobj(void *, uint32_t,
 	uint32_t, uint8_t, void *);
 __stdcall static void ntoskrnl_initevent(void *, uint32_t, uint8_t);
@@ -129,6 +130,9 @@
 __stdcall static void ntoskrnl_free_ansi_string(ndis_ansi_string *);
 __stdcall static ndis_status ntoskrnl_unicode_to_int(ndis_unicode_string *,
 	uint32_t, uint32_t *);
+static int atoi (const char *);
+static long atol (const char *);
+__stdcall static uint8_t ntoskrnl_wdmver(uint8_t, uint8_t);
 __stdcall static void dummy(void);
 
 static struct mtx *ntoskrnl_interlock;
@@ -251,11 +255,25 @@
 }
 	
 __stdcall static uint32_t
-ntoskrnl_iofcalldriver(dobj, irp)
+ntoskrnl_iofcalldriver(/*dobj, irp*/)
+{
 	void			*dobj;
 	void			*irp;
+
+	__asm__ __volatile__ ("" : "=c" (dobj), "=d" (irp));
+
+	return(0);
+}
+
+__stdcall static void
+ntoskrnl_iofcompletereq(/*irp, prioboost*/)
 {
-	return(0);
+	void			*irp;
+	uint8_t			prioboost;
+
+	__asm__ __volatile__ ("" : "=c" (irp), "=d" (prioboost));
+
+	return;
 }
 
 __stdcall static uint32_t
@@ -805,6 +823,30 @@
 	return;
 }
 
+static int
+atoi(str)
+	const char		*str;
+{
+	return (int)strtol(str, (char **)NULL, 10);
+}
+
+static long
+atol(str)
+	const char		*str;
+{
+	return strtol(str, (char **)NULL, 10);
+}
+
+__stdcall static uint8_t
+ntoskrnl_wdmver(major, minor)
+	uint8_t			major;
+	uint8_t			minor;
+{
+	if (major == WDM_MAJOR && minor == WDM_MINOR_WINXP)
+		return(TRUE);
+	return(FALSE);
+}
+
 __stdcall static void
 dummy()
 {
@@ -825,6 +867,7 @@
 	{ "RtlFreeUnicodeString",	(FUNC)ntoskrnl_free_unicode_string },
 	{ "RtlUnicodeStringToInteger",	(FUNC)ntoskrnl_unicode_to_int },

>>> TRUNCATED FOR MAIL (1000 lines) <<<


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401232320.i0NNKMYW036736>