Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Jun 2004 21:38:06 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 55641 for review
Message-ID:  <200406232138.i5NLc6nD051109@repoman.freebsd.org>

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

Change 55641 by rwatson@rwatson_tislabs on 2004/06/23 21:37:33

	Integ netperf_socket, including TCP SACK support.

Affected files ...

.. //depot/projects/netperf_socket/sys/alpha/include/pmap.h#6 integrate
.. //depot/projects/netperf_socket/sys/amd64/amd64/pmap.c#17 integrate
.. //depot/projects/netperf_socket/sys/compat/linux/linux_util.c#3 integrate
.. //depot/projects/netperf_socket/sys/conf/files#29 integrate
.. //depot/projects/netperf_socket/sys/conf/files.i386#17 integrate
.. //depot/projects/netperf_socket/sys/conf/options#15 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi.c#26 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_pci.c#11 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_pcib.c#8 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_resource.c#7 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpivar.h#16 integrate
.. //depot/projects/netperf_socket/sys/dev/cp/if_cp.c#5 integrate
.. //depot/projects/netperf_socket/sys/dev/ctau/if_ct.c#6 integrate
.. //depot/projects/netperf_socket/sys/dev/cx/if_cx.c#9 integrate
.. //depot/projects/netperf_socket/sys/dev/pccbb/pccbb.c#11 integrate
.. //depot/projects/netperf_socket/sys/dev/uart/uart_tty.c#5 integrate
.. //depot/projects/netperf_socket/sys/dev/usb/ulpt.c#4 integrate
.. //depot/projects/netperf_socket/sys/fs/fifofs/fifo_vnops.c#10 integrate
.. //depot/projects/netperf_socket/sys/fs/portalfs/portal_vnops.c#6 integrate
.. //depot/projects/netperf_socket/sys/fs/udf/udf.h#3 integrate
.. //depot/projects/netperf_socket/sys/fs/udf/udf_vfsops.c#3 integrate
.. //depot/projects/netperf_socket/sys/fs/udf/udf_vnops.c#4 integrate
.. //depot/projects/netperf_socket/sys/geom/vinum/geom_vinum_share.c#2 integrate
.. //depot/projects/netperf_socket/sys/i386/conf/NOTES#20 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/bios.c#7 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/io_apic.c#4 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/mp_machdep.c#3 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/mptable.c#4 integrate
.. //depot/projects/netperf_socket/sys/i386/include/apicvar.h#3 integrate
.. //depot/projects/netperf_socket/sys/ia64/include/pmap.h#5 integrate
.. //depot/projects/netperf_socket/sys/kern/uipc_syscalls.c#20 integrate
.. //depot/projects/netperf_socket/sys/modules/ctau/Makefile#2 integrate
.. //depot/projects/netperf_socket/sys/modules/cx/Makefile#2 integrate
.. //depot/projects/netperf_socket/sys/netgraph/ng_bpf.c#3 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp.h#4 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_input.c#12 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_output.c#7 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_sack.c#1 branch
.. //depot/projects/netperf_socket/sys/netinet/tcp_seq.h#3 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_subr.c#10 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_syncache.c#9 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_timer.c#3 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_var.h#7 integrate
.. //depot/projects/netperf_socket/sys/netipsec/keysock.c#2 integrate
.. //depot/projects/netperf_socket/sys/sys/tty.h#7 integrate
.. //depot/projects/netperf_socket/sys/vm/swap_pager.c#5 integrate

Differences ...

==== //depot/projects/netperf_socket/sys/alpha/include/pmap.h#6 (text+ko) ====

@@ -39,7 +39,7 @@
  *	from: hp300: @(#)pmap.h	7.2 (Berkeley) 12/16/90
  *	from: @(#)pmap.h	7.4 (Berkeley) 5/12/91
  *	from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp
- * $FreeBSD: src/sys/alpha/include/pmap.h,v 1.30 2004/04/11 05:08:26 alc Exp $
+ * $FreeBSD: src/sys/alpha/include/pmap.h,v 1.31 2004/06/23 08:06:52 alc Exp $
  */
 
 #ifndef _MACHINE_PMAP_H_
@@ -178,11 +178,6 @@
 	LIST_ENTRY(pmap)	pm_list;	/* list of all pmaps. */
 };
 
-#define	pmap_page_is_mapped(m)	(!TAILQ_EMPTY(&(m)->md.pv_list))
-
-#define PM_FLAG_LOCKED	0x1
-#define PM_FLAG_WANTED	0x2
-
 typedef struct pmap	*pmap_t;
 
 #ifdef _KERNEL
@@ -210,6 +205,8 @@
 
 struct vmspace;
 
+#define	pmap_page_is_mapped(m)	(!TAILQ_EMPTY(&(m)->md.pv_list))
+
 vm_offset_t pmap_steal_memory(vm_size_t);
 void	pmap_bootstrap(vm_offset_t, u_int);
 void	pmap_kenter(vm_offset_t va, vm_offset_t pa);

==== //depot/projects/netperf_socket/sys/amd64/amd64/pmap.c#17 (text+ko) ====

@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.478 2004/06/20 20:57:05 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.479 2004/06/23 04:37:14 alc Exp $");
 
 /*
  *	Manages physical address maps.
@@ -801,18 +801,34 @@
 vm_page_t
 pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
 {
-	vm_paddr_t pa;
+	pd_entry_t pde, *pdep;
+	pt_entry_t pte;
 	vm_page_t m;
 
 	m = NULL;
-	mtx_lock(&Giant);
-	if ((pa = pmap_extract(pmap, va)) != 0) {
-		m = PHYS_TO_VM_PAGE(pa);
-		vm_page_lock_queues();
-		vm_page_hold(m);
-		vm_page_unlock_queues();
+	if (pmap == NULL)
+		return (m);
+	vm_page_lock_queues();
+	PMAP_LOCK(pmap);
+	pdep = pmap_pde(pmap, va);
+	if (pdep != NULL && (pde = *pdep)) {
+		if (pde & PG_PS) {
+			if ((pde & PG_RW) || (prot & VM_PROT_WRITE) == 0) {
+				m = PHYS_TO_VM_PAGE((pde & ~PDRMASK) |
+				    (va & PDRMASK));
+				vm_page_hold(m);
+			}
+		} else {
+			pte = *pmap_pte(pmap, va);
+			if ((pte & PG_V) &&
+			    ((pte & PG_RW) || (prot & VM_PROT_WRITE) == 0)) {
+				m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
+				vm_page_hold(m);
+			}
+		}
 	}
-	mtx_unlock(&Giant);
+	vm_page_unlock_queues();
+	PMAP_UNLOCK(pmap);
 	return (m);
 }
 

==== //depot/projects/netperf_socket/sys/compat/linux/linux_util.c#3 (text+ko) ====

@@ -30,13 +30,15 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/linux/linux_util.c,v 1.25 2004/06/22 04:22:34 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/linux/linux_util.c,v 1.26 2004/06/23 06:35:43 bde Exp $");
 
 #include <sys/param.h>
-#include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
 #include <sys/namei.h>
 #include <sys/proc.h>
-#include <sys/malloc.h>
+#include <sys/systm.h>
 #include <sys/vnode.h>
 
 #include <machine/stdarg.h>

==== //depot/projects/netperf_socket/sys/conf/files#29 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.907 2004/06/22 20:13:24 brooks Exp $
+# $FreeBSD: src/sys/conf/files,v 1.908 2004/06/23 21:04:36 ps Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -1465,6 +1465,7 @@
 netinet/tcp_hostcache.c	optional inet
 netinet/tcp_input.c	optional inet
 netinet/tcp_output.c	optional inet
+netinet/tcp_sack.c	optional inet
 netinet/tcp_subr.c	optional inet
 netinet/tcp_syncache.c	optional inet
 netinet/tcp_timer.c	optional inet

==== //depot/projects/netperf_socket/sys/conf/files.i386#17 (text+ko) ====

@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: src/sys/conf/files.i386,v 1.493 2004/05/26 07:43:40 bde Exp $
+# $FreeBSD: src/sys/conf/files.i386,v 1.494 2004/06/23 17:33:24 brooks Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -272,7 +272,7 @@
 i386/isa/elcr.c			standard
 i386/isa/elink.c		optional	ep
 i386/isa/elink.c		optional	ie
-i386/isa/if_el.c		count		el
+i386/isa/if_el.c		optional	el
 i386/isa/isa.c			optional	isa
 i386/isa/isa_dma.c		optional	isa
 i386/isa/mse.c			optional	mse

==== //depot/projects/netperf_socket/sys/conf/options#15 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/options,v 1.453 2004/06/13 17:29:06 mlaier Exp $
+# $FreeBSD: src/sys/conf/options,v 1.454 2004/06/23 21:04:37 ps Exp $
 #
 #        On the handling of kernel options
 #
@@ -354,6 +354,7 @@
 SLIP_IFF_OPTS		opt_slip.h
 TCPDEBUG
 TCP_SIGNATURE		opt_inet.h
+TCP_SACK_DEBUG		opt_tcp_sack.h 
 TCP_DROP_SYNFIN		opt_tcp_input.h
 XBONEHACK
 

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi.c#26 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.163 2004/06/16 09:46:35 phk Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.164 2004/06/23 17:21:02 jhb Exp $
  */
 
 #include "opt_acpi.h"
@@ -846,12 +846,12 @@
 acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
 {
+    ACPI_RESOURCE ares;
     struct acpi_device *ad = device_get_ivars(child);
     struct resource_list *rl = &ad->ad_rl;
     struct resource_list_entry *rle;
     struct resource *res;
     struct rman *rm;
-    int needactivate;
 
     /*
      * If this is an allocation of the "default" range for a given RID, and
@@ -870,41 +870,56 @@
     /* If we don't manage this address, pass the request up to the parent. */
     rle = acpi_sysres_find(type, start);
     if (rle == NULL) {
-	return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
-	    start, end, count, flags));
-    }
+	res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
+	    start, end, count, flags);
+    } else {
+
+	/* We only handle memory and IO resources through rman. */
+	switch (type) {
+	case SYS_RES_IOPORT:
+	    rm = &acpi_rman_io;
+	    break;
+	case SYS_RES_MEMORY:
+	    rm = &acpi_rman_mem;
+	    break;
+	default:
+	    panic("acpi_alloc_resource: invalid res type %d", type);
+	}
 
-    /* We only handle memory and IO resources through rman. */
-    switch (type) {
-    case SYS_RES_IOPORT:
-	rm = &acpi_rman_io;
-	break;
-    case SYS_RES_MEMORY:
-	rm = &acpi_rman_mem;
-	break;
-    default:
-	panic("acpi_alloc_resource: invalid res type %d", type);
-    }
+	/* If we do know it, allocate it from the local pool. */
+	res = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
+	    child);
+	if (res == NULL)
+	    return (NULL);
 
-    /* If we do know it, allocate it from the local pool. */
-    needactivate = flags & RF_ACTIVE;
-    flags &= ~RF_ACTIVE;
-    res = rman_reserve_resource(rm, start, end, count, flags, child);
-    if (res == NULL)
-	return (NULL);
+	/* Copy the bus tag from the pre-allocated resource. */
+	rman_set_bustag(res, rman_get_bustag(rle->res));
+	if (type == SYS_RES_IOPORT)
+	    rman_set_bushandle(res, res->r_start);
 
-    /* Copy the bus tag from the pre-allocated resource. */
-    rman_set_bustag(res, rman_get_bustag(rle->res));
-    if (type == SYS_RES_IOPORT)
-	rman_set_bushandle(res, res->r_start);
+	/* If requested, activate the resource using the parent's method. */
+	if (flags & RF_ACTIVE)
+	    if (bus_activate_resource(child, type, *rid, res) != 0) {
+		rman_release_resource(res);
+		return (NULL);
+	    }
+    }
 
-    /* If requested, activate the resource using the parent's method. */
-    if (needactivate)
-	if (bus_activate_resource(child, type, *rid, res) != 0) {
-	    rman_release_resource(res);
-	    return (NULL);
+    if (res != NULL && device_get_parent(child) == bus)
+	switch (type) {
+	case SYS_RES_IRQ:
+	    /*
+	     * Since bus_config_intr() takes immediate effect, we cannot
+	     * configure the interrupt associated with a device when we
+	     * parse the resources but have to defer it until a driver
+	     * actually allocates the interrupt via bus_alloc_resource().
+	     *
+	     * XXX: Should we handle the lookup failing?
+	     */
+	    if (ACPI_SUCCESS(acpi_lookup_irq_resource(child, *rid, res, &ares)))
+		acpi_config_intr(child, &ares);
+	    break;
 	}
-
     return (res);
 }
 

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_pci.c#11 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.18 2004/06/07 21:44:01 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.19 2004/06/23 15:08:40 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -56,18 +56,17 @@
 	ACPI_HANDLE		ap_handle;
 };
 
+static int	acpi_pci_attach(device_t dev);
+static int	acpi_pci_child_location_str_method(device_t cbdev,
+		    device_t child, char *buf, size_t buflen);
 static int	acpi_pci_probe(device_t dev);
-static int	acpi_pci_attach(device_t dev);
 static int	acpi_pci_read_ivar(device_t dev, device_t child, int which,
 		    uintptr_t *result);
-static int	acpi_pci_child_location_str_method(device_t cbdev,
-		    device_t child, char *buf, size_t buflen);
-
-
+static ACPI_STATUS acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level,
+		    void *context, void **status);
 static int	acpi_pci_set_powerstate_method(device_t dev, device_t child,
 		    int state);
-static ACPI_STATUS acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level,
-		    void *context, void **status);
+static void	acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child);
 
 static device_method_t acpi_pci_methods[] = {
 	/* Device interface */
@@ -205,6 +204,40 @@
 		return (0);
 }
 
+static void
+acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child)
+{
+	ACPI_STATUS status;
+	device_t child;
+
+	/*
+	 * Lookup and remove the unused device that acpi0 creates when it walks
+	 * the namespace creating devices.
+	 */
+	child = acpi_get_device(handle);
+	if (child != NULL) {
+		KASSERT(!device_is_alive(child), ("%s: deleting alive child %s",
+		    __func__, device_get_nameunit(child)));
+		KASSERT(device_get_parent(child) ==
+		    devclass_get_device(devclass_find("acpi"), 0),
+		    ("%s: child (%s)'s parent is not acpi0", __func__,
+		    acpi_name(handle)));
+		device_delete_child(device_get_parent(child), child);
+	}
+
+	/*
+	 * Update ACPI-CA to use the PCI enumerated device_t for this handle.
+	 */
+	status = AcpiDetachData(handle, acpi_fake_objhandler);
+	if (ACPI_FAILURE(status))
+		printf("WARNING: Unable to detach object data from %s - %s\n",
+		    acpi_name(handle), AcpiFormatException(status));
+	status = AcpiAttachData(handle, acpi_fake_objhandler, child);
+	if (ACPI_FAILURE(status))
+		printf("WARNING: Unable to attach object data to %s - %s\n",
+		    acpi_name(handle), AcpiFormatException(status));
+}
+
 static ACPI_STATUS
 acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level, void *context,
     void **status)
@@ -227,6 +260,7 @@
 		if (dinfo->ap_dinfo.cfg.func == func &&
 		    dinfo->ap_dinfo.cfg.slot == slot) {
 			dinfo->ap_handle = handle;
+			acpi_pci_update_device(handle, devlist[i]);
 			free(devlist, M_TEMP);
 			return_ACPI_STATUS (AE_OK);
 		}

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_pcib.c#8 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib.c,v 1.44 2004/06/07 17:36:22 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib.c,v 1.45 2004/06/23 17:21:02 jhb Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -121,6 +121,7 @@
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
     
+    crsres = NULL;
     buf.Pointer = NULL;
     crsbuf.Pointer = NULL;
     prsbuf.Pointer = NULL;
@@ -348,6 +349,7 @@
 
     /* XXX Data.Irq and Data.ExtendedIrq are implicitly structure-copied. */
     crsbuf.Pointer = NULL;
+    crsres = NULL;
     if (prsres->Id == ACPI_RSTYPE_IRQ) {
 	resbuf.Id = ACPI_RSTYPE_IRQ;
 	resbuf.Length = ACPI_SIZEOF_RESOURCE(ACPI_RESOURCE_IRQ);
@@ -378,6 +380,7 @@
 		      AcpiFormatException(status));
 	goto out;
     }
+    crsres = &resbuf;
     
     /* Return the interrupt we just routed. */
     device_printf(pcib, "slot %d INT%c routed to irq %d via %s\n", 
@@ -386,6 +389,8 @@
     interrupt = Interrupts[0];
 
 out:
+    if (PCI_INTERRUPT_VALID(interrupt) && crsres != NULL)
+	acpi_config_intr(dev, crsres);
     if (crsbuf.Pointer != NULL)
 	AcpiOsFree(crsbuf.Pointer);
     if (prsbuf.Pointer != NULL)

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_resource.c#7 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_resource.c,v 1.25 2004/06/13 22:52:30 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_resource.c,v 1.26 2004/06/23 17:21:02 jhb Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -46,6 +46,94 @@
 #define _COMPONENT	ACPI_BUS
 ACPI_MODULE_NAME("RESOURCE")
 
+struct lookup_irq_request {
+    ACPI_RESOURCE *acpi_res;
+    struct resource *res;
+    int		counter;
+    int		rid;
+    int		found;
+};
+
+static ACPI_STATUS
+acpi_lookup_irq_handler(ACPI_RESOURCE *res, void *context)
+{
+    struct lookup_irq_request *req;
+    u_int irqnum, irq;
+
+    switch (res->Id) {
+    case ACPI_RSTYPE_IRQ:
+    case ACPI_RSTYPE_EXT_IRQ:
+	if (res->Id == ACPI_RSTYPE_IRQ) {
+	    irqnum = res->Data.Irq.NumberOfInterrupts;
+	    irq = res->Data.Irq.Interrupts[0];
+	} else {
+	    irqnum = res->Data.ExtendedIrq.NumberOfInterrupts;
+	    irq = res->Data.ExtendedIrq.Interrupts[0];
+	}
+	if (irqnum != 1)
+	    break;
+	req = (struct lookup_irq_request *)context;
+	if (req->counter != req->rid) {
+	    req->counter++;
+	    break;
+	}
+	req->found = 1;
+	KASSERT(irq == rman_get_start(req->res),
+	    ("IRQ resources do not match"));
+	bcopy(res, req->acpi_res, sizeof(ACPI_RESOURCE));
+	return (AE_CTRL_TERMINATE);
+    }
+    return (AE_OK);
+}
+
+ACPI_STATUS
+acpi_lookup_irq_resource(device_t dev, int rid, struct resource *res,
+    ACPI_RESOURCE *acpi_res)
+{
+    struct lookup_irq_request req;
+    ACPI_STATUS status;
+
+    req.acpi_res = acpi_res;
+    req.res = res;
+    req.counter = 0;
+    req.rid = rid;
+    req.found = 0;
+    status = AcpiWalkResources(acpi_get_handle(dev), "_CRS",
+	acpi_lookup_irq_handler, &req);
+    if (ACPI_SUCCESS(status) && req.found == 0)
+	status = AE_NOT_FOUND;
+    return (status);
+}
+
+void
+acpi_config_intr(device_t dev, ACPI_RESOURCE *res)
+{
+    u_int irq;
+    int pol, trig;
+
+    switch (res->Id) {
+    case ACPI_RSTYPE_IRQ:
+	KASSERT(res->Data.Irq.NumberOfInterrupts == 1,
+	    ("%s: multiple interrupts", __func__));
+	irq = res->Data.Irq.Interrupts[0];
+	trig = res->Data.Irq.EdgeLevel;
+	pol = res->Data.Irq.ActiveHighLow;
+	break;
+    case ACPI_RSTYPE_EXT_IRQ:
+	KASSERT(res->Data.ExtendedIrq.NumberOfInterrupts == 1,
+	    ("%s: multiple interrupts", __func__));
+	irq = res->Data.ExtendedIrq.Interrupts[0];
+	trig = res->Data.ExtendedIrq.EdgeLevel;
+	pol = res->Data.ExtendedIrq.ActiveHighLow;
+	break;
+    default:
+	panic("%s: bad resource type %u", __func__, res->Id);
+    }
+    BUS_CONFIG_INTR(dev, irq, (trig == ACPI_EDGE_SENSITIVE) ?
+	INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL, (pol == ACPI_ACTIVE_HIGH) ?
+	INTR_POLARITY_HIGH : INTR_POLARITY_LOW);	
+}
+
 /*
  * Fetch a device's resources and associate them with the device.
  *
@@ -497,9 +585,6 @@
 	return;
 
     bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, *irq, 1);
-    BUS_CONFIG_INTR(dev, *irq, (trig == ACPI_EDGE_SENSITIVE) ?
-	INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL, (pol == ACPI_ACTIVE_HIGH) ?
-	INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
 }
 
 static void

==== //depot/projects/netperf_socket/sys/dev/acpica/acpivar.h#16 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.72 2004/06/16 09:46:35 phk Exp $
+ *	$FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.73 2004/06/23 17:21:02 jhb Exp $
  */
 
 #include "bus_if.h"
@@ -268,6 +268,10 @@
 };
 
 extern struct	acpi_parse_resource_set acpi_res_parse_set;
+
+void		acpi_config_intr(device_t dev, ACPI_RESOURCE *res);
+ACPI_STATUS	acpi_lookup_irq_resource(device_t dev, int rid,
+		    struct resource *res, ACPI_RESOURCE *acpi_res);
 ACPI_STATUS	acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
 		    struct acpi_parse_resource_set *set, void *arg);
 extern struct	rman acpi_rman_io, acpi_rman_mem;

==== //depot/projects/netperf_socket/sys/dev/cp/if_cp.c#5 (text+ko) ====

@@ -18,11 +18,11 @@
  * as long as this message is kept with the software, all derivative
  * works or modified versions.
  *
- * $Cronyx: if_cp.c,v 1.1.2.32 2004/02/26 17:56:39 rik Exp $
+ * Cronyx Id: if_cp.c,v 1.1.2.41 2004/06/23 17:09:13 rik Exp $
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cp/if_cp.c,v 1.6 2004/06/17 17:16:42 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cp/if_cp.c,v 1.8 2004/06/23 18:13:09 rik Exp $");
 
 #include <sys/param.h>
 
@@ -45,9 +45,7 @@
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/tty.h>
-#if __FreeBSD_version >= 400000
-#   include <sys/bus.h>
-#endif
+#include <sys/bus.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <net/if.h>
@@ -68,34 +66,18 @@
 #   endif
 #   include <netgraph/ng_message.h>
 #   include <netgraph/netgraph.h>
-#   if __FreeBSD_version >= 500000
-#       include <dev/cp/ng_cp.h>
-#   else
-#       include <netgraph/ng_cp.h>
-#   endif
+#   include <dev/cp/ng_cp.h>
 #else
 #   include <net/if_sppp.h>
 #   define PP_CISCO IFF_LINK2
-#   if __FreeBSD_version < 400000
-#       include <bpfilter.h>
-#       if NBPFILTER > 0
-#           include <net/bpf.h>
-#       endif
-#   else
-#       if __FreeBSD_version < 500000
-#           include <bpf.h>
-#       endif
-#       include <net/bpf.h>
-#       define NBPFILTER NBPF
-#endif
+#   if __FreeBSD_version < 500000
+#       include <bpf.h>
+#   endif
+#   include <net/bpf.h>
+#   define NBPFILTER NBPF
 #endif
-#if __FreeBSD_version >= 500000
 #include <dev/cx/machdep.h>
 #include <dev/cp/cpddk.h>
-#else
-#include <i386/isa/cronyx/machdep.h>
-#include <pci/cpddk.h>
-#endif
 #include <machine/cserial.h>
 #include <machine/resource.h>
 #include <machine/pmap.h>
@@ -112,7 +94,6 @@
 
 #define CDEV_MAJOR	134
 
-#if __FreeBSD_version >= 400000
 static	int cp_probe		__P((device_t));
 static	int cp_attach		__P((device_t));
 static	int cp_detach		__P((device_t));
@@ -126,27 +107,21 @@
 	{0, 0}
 };
 
-typedef	struct _bdrv_t {
-	cp_board_t	*board;
-	struct resource *cp_res;
-	struct resource *cp_irq;
-	void		*cp_intrhand;
-} bdrv_t;
-
-static	driver_t cp_driver = {
-	"cp",
-	cp_methods,
-	sizeof(bdrv_t),
-};
-
-static	devclass_t cp_devclass;
+typedef struct _cp_dma_mem_t {
+	unsigned long	phys;
+	void		*virt;
+	size_t		size;
+#if __FreeBSD_version >= 500000
+	bus_dma_tag_t	dmat;
+	bus_dmamap_t	mapp;
 #endif
+} cp_dma_mem_t;
 
 typedef struct _drv_t {
 	char name [8];
 	cp_chan_t *chan;
 	cp_board_t *board;
-	cp_buf_t buf;
+	cp_dma_mem_t dmamem;
 	int running;
 #ifdef NETGRAPH
 	char	nodename [NG_NODELEN+1];
@@ -160,11 +135,26 @@
 #else
 	struct sppp pp;
 #endif
-#if __FreeBSD_version >= 400000
 	struct cdev *devt;
-#endif
 } drv_t;
 
+typedef	struct _bdrv_t {
+	cp_board_t	*board;
+	struct resource *cp_res;
+	struct resource *cp_irq;
+	void		*cp_intrhand;
+	cp_dma_mem_t	dmamem;
+	drv_t		channel [NCHAN];
+} bdrv_t;
+
+static	driver_t cp_driver = {
+	"cp",
+	cp_methods,
+	sizeof(bdrv_t),
+};
+
+static	devclass_t cp_devclass;
+
 static void cp_receive (cp_chan_t *c, unsigned char *data, int len);
 static void cp_transmit (cp_chan_t *c, void *attachment, int len);
 static void cp_error (cp_chan_t *c, int data);
@@ -185,7 +175,6 @@
 
 static cp_board_t *adapter [NBRD];
 static drv_t *channel [NBRD*NCHAN];
-static cp_qbuf_t *queue [NBRD];
 static struct callout_handle led_timo [NBRD];
 static struct callout_handle timeout_handle;
 
@@ -227,14 +216,6 @@
 	return m;
 }
 
-#if __FreeBSD_version < 400000
-static const char *cp_probe (pcici_t tag, pcidi_t type)
-{
-	if (tag->vendor == cp_vendor_id && tag->device == cp_device_id)
-		return "Cronyx-Tau-PCI serial adapter";
-	return 0;
-}
-#else
 static int cp_probe (device_t dev)
 {
 	if ((pci_get_vendor (dev) == cp_vendor_id) &&
@@ -244,7 +225,6 @@
 	}
 	return ENXIO;
 }
-#endif
 
 static void cp_timeout (void *arg)
 {
@@ -300,12 +280,8 @@
 
 static void cp_intr (void *arg)
 {
-#if __FreeBSD_version < 400000
-	cp_board_t *b = arg;
-#else
 	bdrv_t *bd = arg;
 	cp_board_t *b = bd->board;
-#endif
 	int s = splimp ();
 	if (cp_destroy) {
 		splx (s);
@@ -324,49 +300,110 @@
 
 extern struct cdevsw cp_cdevsw;
 
+#if __FreeBSD_version >= 500000
+static void
+cp_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+	unsigned long *addr;
+
+	if (error)
+		return;
+
+	KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
+	addr = arg;
+	*addr = segs->ds_addr;
+}
+
+static int
+cp_bus_dma_mem_alloc (int bnum, int cnum, cp_dma_mem_t *dmem)
+{
+	int error;
+
+	error = bus_dma_tag_create (NULL, 16, 0, BUS_SPACE_MAXADDR_32BIT,
+		BUS_SPACE_MAXADDR, NULL, NULL, dmem->size, 1,
+		dmem->size, 0, NULL, NULL, &dmem->dmat);
+	if (error) {
+		if (cnum >= 0)	printf ("cp%d-%d: ", bnum, cnum);
+		else		printf ("cp%d: ", bnum);
+		printf ("couldn't allocate tag for dma memory\n");
+ 		return 0;
+	}
+	error = bus_dmamem_alloc (dmem->dmat, (void **)&dmem->virt,
+		BUS_DMA_NOWAIT | BUS_DMA_ZERO, &dmem->mapp);
+	if (error) {
+		if (cnum >= 0)	printf ("cp%d-%d: ", bnum, cnum);
+		else		printf ("cp%d: ", bnum);
+		printf ("couldn't allocate mem for dma memory\n");
+		bus_dma_tag_destroy (dmem->dmat);
+ 		return 0;
+	}
+	error = bus_dmamap_load (dmem->dmat, dmem->mapp, dmem->virt,
+		dmem->size, cp_bus_dmamap_addr, &dmem->phys, 0);
+	if (error) {
+		if (cnum >= 0)	printf ("cp%d-%d: ", bnum, cnum);
+		else		printf ("cp%d: ", bnum);
+		printf ("couldn't load mem map for dma memory\n");
+		bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+		bus_dma_tag_destroy (dmem->dmat);
+ 		return 0;
+	}
+	return 1;
+}
+
+static void
+cp_bus_dma_mem_free (cp_dma_mem_t *dmem)
+{
+	bus_dmamap_unload (dmem->dmat, dmem->mapp);
+	bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+	bus_dma_tag_destroy (dmem->dmat);
+}
+#else
+static int
+cp_bus_dma_mem_alloc (int bnum, int cnum, cp_dma_mem_t *dmem)
+{
+	dmem->virt = contigmalloc (dmem->size, M_DEVBUF, M_WAITOK,
+				   0x100000, 0xffffffff, 16, 0);
+	if (dmem->virt == NULL) {
+		if (cnum >= 0)	printf ("cp%d-%d: ", bnum, cnum);
+		else		printf ("cp%d: ", bnum);
+		printf ("couldn't allocate memory for dma memory\n", unit);
+ 		return 0;
+	}
+	dmem->phys = vtophys (dmem->virt);
+	return 1;
+}
+
+static void
+cp_bus_dma_mem_free (cp_dma_mem_t *dmem)
+{
+	contigfree (dmem->virt, dmem->size, M_DEVBUF);
+}
+#endif
+
 /*
  * Called if the probe succeeded.
  */
-#if __FreeBSD_version < 400000
-static void cp_attach (pcici_t tag, int unit)
-{
-	vm_offset_t pbase;
-#else
 static int cp_attach (device_t dev)
 {
 	bdrv_t *bd = device_get_softc (dev);
 	int unit = device_get_unit (dev);
+	unsigned short res;
+	vm_offset_t vbase;
 	int rid, error;
-#endif
-	vm_offset_t vbase;
-        cp_board_t *b;
+	cp_board_t *b;
 	cp_chan_t *c;
-        drv_t *d;
-	unsigned short res;
+	drv_t *d;
 	int s = splimp ();
 
 	b = malloc (sizeof(cp_board_t), M_DEVBUF, M_WAITOK);
 	if (!b) {
 		printf ("cp%d: couldn't allocate memory\n", unit);		
-#if __FreeBSD_version < 400000
-		splx (s);
-		return;
-#else
 		splx (s);
 		return (ENXIO);
-#endif
 	}
 	adapter[unit] = b;
 	bzero (b, sizeof(cp_board_t));
 
-#if __FreeBSD_version < 400000
-	if (! pci_map_mem (tag, PCIR_MAPS, &vbase, &pbase)) {
-		printf ("cp%d: cannot map memory\n", unit);
-		free (b, M_DEVBUF);
-		splx (s);
-		return;
-	}
-#else
 	bd->board = b;
 	b->sys = bd;
 	rid = PCIR_BAR(0);
@@ -379,40 +416,24 @@
 		return (ENXIO);
 	}
 	vbase = (vm_offset_t) rman_get_virtual (bd->cp_res);
-#endif
 
 	res = cp_init (b, unit, (u_char*) vbase);
 	if (res) {
 		printf ("cp%d: can't init, error code:%x\n", unit, res);
-#if __FreeBSD_version >= 400000
 		bus_release_resource (dev, SYS_RES_MEMORY, PCIR_BAR(0), bd->cp_res);
-#endif
 		free (b, M_DEVBUF);
 		splx (s);
-#if __FreeBSD_version >= 400000
  		return (ENXIO);
-#else
-		return;
-#endif
 	}
-	queue[unit] = contigmalloc (sizeof(cp_qbuf_t), M_DEVBUF, M_WAITOK,
-			0x100000, 0xffffffff, 16, 0);
-	if (queue[unit] == NULL) {
-		printf ("cp%d: allocate memory for qbuf_t\n", unit);
+
+	bd->dmamem.size = sizeof(cp_qbuf_t);
+	if (! cp_bus_dma_mem_alloc (unit, -1, &bd->dmamem)) {
 		free (b, M_DEVBUF);
 		splx (s);
-#if __FreeBSD_version >= 400000
  		return (ENXIO);
-#else
-		return;
-#endif
 	}
-	cp_reset (b, queue[unit], vtophys (queue[unit]));
+	cp_reset (b, bd->dmamem.virt, bd->dmamem.phys);
 
-#if __FreeBSD_version < 400000
-       	if (! pci_map_int (tag, cp_intr, b, &net_imask))
-		printf ("cp%d: cannot map interrupt\n", unit);
-#else
 	rid = 0;
 	bd->cp_irq = bus_alloc_resource (dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
 			RF_SHAREABLE | RF_ACTIVE);
@@ -435,20 +456,16 @@
 		splx (s);
 		return (ENXIO);
 	}
-#endif
 	printf ("cp%d: %s, clock %ld MHz\n", unit, b->name, b->osc / 1000000);
 
 	for (c=b->chan; c<b->chan+NCHAN; ++c) {
 		if (! c->type)
 			continue;
-		d = contigmalloc (sizeof(drv_t), M_DEVBUF, M_WAITOK,
-			0x100000, 0xffffffff, 16, 0);
-		if (d == NULL) {
-			printf ("cp%d-%d: cannot allocate memory for drv_t\n",
-			    unit, c->num);			
-		}
+		d = &bd->channel[c->num];
+		d->dmamem.size = sizeof(cp_buf_t);
+		if (! cp_bus_dma_mem_alloc (unit, c->num, &d->dmamem))
+			continue;
 		channel [b->num*NCHAN + c->num] = d;
-		bzero (d, sizeof(drv_t));
 		sprintf (d->name, "cp%d.%d", b->num, c->num);
 		d->board = b;
 		d->chan = c;
@@ -500,31 +517,24 @@
 		if_attach (&d->pp.pp_if);
 		d->pp.pp_tlf		= cp_tlf;
 		d->pp.pp_tls		= cp_tls;
-#if __FreeBSD_version >= 400000 || NBPFILTER > 0
 		/* If BPF is in the kernel, call the attach for it.

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



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