Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Aug 2007 19:31:57 GMT
From:      Maxim Zhuravlev <thioretic@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125450 for review
Message-ID:  <200708201931.l7KJVv9C082190@repoman.freebsd.org>

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

Change 125450 by thioretic@thioretic_freebox on 2007/08/20 19:31:36

	IFC

Affected files ...

.. //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/machdep.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/mptable_pci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/msi.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/nexus.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/trap.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/include/intr_machdep.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/amd64/pci/pci_bus.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/acpica/acpi_pcib_acpi.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/acpica/acpi_pcib_pci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_common.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_ctl_defs.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_mc5.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_t3_cpl.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_t3_hw.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_vsc7323.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_xgmac.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_adapter.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_include.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_ioctl.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_l2t.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_main.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_offload.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_offload.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_osdep.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/cxgb_sge.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/sys/mvec.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/t3b_protocol_sram-1.1.0.bin.gz.uu#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/t3b_tp_eeprom-1.1.0.bin.gz.uu#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/t3fw-4.1.0.bin.gz.uu#2 delete
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/t3fw-4.5.0.bin.gz.uu#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/ulp/toecore/toedev.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/digi/con.CX-IBM.h#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/digi/con.CX.h#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/digi/con.EPCX.h#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/digi/con.MBank.h#1 branch
.. //depot/projects/soc2007/thioretic_gidl2/dev/ipmi/ipmi_isa.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/nmdm/nmdm.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pci_pci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pci_private.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pcib_if.m#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pcib_private.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/pci/pcivar.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/sym/sym_hipd.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/dev/usb/ehci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/fs/smbfs/smbfs_smb.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/i386/machdep.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/i386/mptable_pci.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/i386/msi.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/i386/nexus.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/i386/trap.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/include/intr_machdep.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/include/proc.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/linux/linux_sysvec.c#3 integrate
.. //depot/projects/soc2007/thioretic_gidl2/i386/pci/pci_bus.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/kern/sysv_sem.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/kern/tty.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/modules/cxgb/Makefile#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/net/if_bridge.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/net/if_bridgevar.h#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/net/if_lagg.c#3 integrate
.. //depot/projects/soc2007/thioretic_gidl2/net/if_lagg.h#3 integrate
.. //depot/projects/soc2007/thioretic_gidl2/netgraph/ng_base.c#2 integrate
.. //depot/projects/soc2007/thioretic_gidl2/netgraph/ng_bpf.c#2 integrate

Differences ...

==== //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/machdep.c#2 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.638.2.11 2006/12/01 08:34:38 davidxu Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.638.2.12 2007/08/07 09:16:18 jkoshy Exp $");
 
 #include "opt_atalk.h"
 #include "opt_atpic.h"
@@ -1219,7 +1219,7 @@
 		setidt(x, &IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0);
 	setidt(IDT_DE, &IDTVEC(div),  SDT_SYSIGT, SEL_KPL, 0);
 	setidt(IDT_DB, &IDTVEC(dbg),  SDT_SYSIGT, SEL_KPL, 0);
-	setidt(IDT_NMI, &IDTVEC(nmi),  SDT_SYSIGT, SEL_KPL, 0);
+	setidt(IDT_NMI, &IDTVEC(nmi),  SDT_SYSIGT, SEL_KPL, 1);
  	setidt(IDT_BP, &IDTVEC(bpt),  SDT_SYSIGT, SEL_UPL, 0);
 	setidt(IDT_OF, &IDTVEC(ofl),  SDT_SYSIGT, SEL_KPL, 0);
 	setidt(IDT_BR, &IDTVEC(bnd),  SDT_SYSIGT, SEL_KPL, 0);

==== //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/mptable_pci.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/mptable_pci.c,v 1.2.8.3 2007/03/31 15:23:19 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/mptable_pci.c,v 1.2.8.4 2007/08/15 20:56:08 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,7 +72,7 @@
 	return (bus_generic_attach(dev));
 }
 
-/* Pass MSI alloc requests up to the nexus. */
+/* Pass MSI requests up to the nexus. */
 static int
 mptable_hostb_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
     int *irqs)
@@ -85,12 +85,22 @@
 }
 
 static int
-mptable_hostb_alloc_msix(device_t pcib, device_t dev, int index, int *irq)
+mptable_hostb_alloc_msix(device_t pcib, device_t dev, int *irq)
+{
+	device_t bus;
+
+	bus = device_get_parent(pcib);
+	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
+}
+
+static int
+mptable_hostb_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
+    uint32_t *data)
 {
 	device_t bus;
 
 	bus = device_get_parent(pcib);
-	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, index, irq));
+	return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
 }
 
 static device_method_t mptable_hostb_methods[] = {
@@ -120,8 +130,8 @@
 	DEVMETHOD(pcib_alloc_msi,	mptable_hostb_alloc_msi),
 	DEVMETHOD(pcib_release_msi,	pcib_release_msi),
 	DEVMETHOD(pcib_alloc_msix,	mptable_hostb_alloc_msix),
-	DEVMETHOD(pcib_remap_msix,	pcib_remap_msix),
 	DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+	DEVMETHOD(pcib_map_msi,		mptable_hostb_map_msi),
 
 	{ 0, 0 }
 };
@@ -177,8 +187,8 @@
 	DEVMETHOD(pcib_alloc_msi,	pcib_alloc_msi),
 	DEVMETHOD(pcib_release_msi,	pcib_release_msi),
 	DEVMETHOD(pcib_alloc_msix,	pcib_alloc_msix),
-	DEVMETHOD(pcib_remap_msix,	pcib_remap_msix),
 	DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+	DEVMETHOD(pcib_map_msi,		pcib_map_msi),
 
 	{0, 0}
 };

==== //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/msi.c#2 (text+ko) ====

@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/msi.c,v 1.4.2.1 2007/03/31 15:23:19 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/msi.c,v 1.4.2.3 2007/08/15 21:12:07 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -99,21 +99,20 @@
  * assigned an ID by the system; however, a group will use the ID from
  * the first message.
  *
- * For MSI-X, each message is isolated, and msi_index indicates the
- * index of this message in the device's MSI-X table.
+ * For MSI-X, each message is isolated.
  */
 struct msi_intsrc {
 	struct intsrc msi_intsrc;
 	device_t msi_dev;		/* Owning device. (g) */
 	struct msi_intsrc *msi_first;	/* First source in group. */
 	u_int msi_irq;			/* IRQ cookie. */
-	u_int msi_index;		/* Index of this message. */
 	u_int msi_msix;			/* MSI-X message. */
 	u_int msi_vector:8;		/* IDT vector. */
 	u_int msi_cpu:8;		/* Local APIC ID. (g) */
 	u_int msi_count:8;		/* Messages in this group. (g) */
 };
 
+static void	msi_create_source(void);
 static void	msi_enable_source(struct intsrc *isrc);
 static void	msi_disable_source(struct intsrc *isrc, int eoi);
 static void	msi_eoi_source(struct intsrc *isrc);
@@ -123,19 +122,14 @@
 static int	msi_config_intr(struct intsrc *isrc, enum intr_trigger trig,
 		    enum intr_polarity pol);
 static void	msi_assign_cpu(struct intsrc *isrc, u_int apic_id);
-static void	msix_enable_intr(struct intsrc *isrc);
-static int	msix_source_pending(struct intsrc *isrc);
-static void	msix_assign_cpu(struct intsrc *isrc, u_int apic_id);
 
 struct pic msi_pic = { msi_enable_source, msi_disable_source, msi_eoi_source,
 		       msi_enable_intr, msi_vector, msi_source_pending,
 		       NULL, NULL, msi_config_intr, msi_assign_cpu };
-struct pic msix_pic = { msi_enable_source, msi_disable_source, msi_eoi_source,
-			msix_enable_intr, msi_vector, msix_source_pending,
-			NULL, NULL, msi_config_intr, msix_assign_cpu };
 
 static int msi_enabled;
-static struct sx msi_sx;
+static int msi_last_irq;
+static struct mtx msi_lock;
 
 static void
 msi_enable_source(struct intsrc *isrc)
@@ -162,17 +156,6 @@
 {
 	struct msi_intsrc *msi = (struct msi_intsrc *)isrc;
 
-	/*
-	 * Since we can only enable the entire group at once, go ahead and
-	 * enable the messages when the first message is given a handler.
-	 * Note that we assume all devices will register a handler for the
-	 * first message.
-	 */
-	if (msi->msi_index == 0) {
-		mtx_lock_spin(&icu_lock);
-		pci_enable_msi(msi->msi_dev, INTEL_ADDR(msi), INTEL_DATA(msi));
-		mtx_unlock_spin(&icu_lock);
-	}
 	apic_enable_vector(msi->msi_vector);
 }
 
@@ -206,49 +189,11 @@
 
 	msi->msi_cpu = apic_id;
 	if (bootverbose)
-		printf("msi: Assigning MSI IRQ %d to local APIC %u\n",
-		    msi->msi_irq, msi->msi_cpu);
-	mtx_lock_spin(&icu_lock);
+		printf("msi: Assigning %s IRQ %d to local APIC %u\n",
+		    msi->msi_msix ? "MSI-X" : "MSI", msi->msi_irq,
+		    msi->msi_cpu);	
 	if (isrc->is_enabled)
-		pci_enable_msi(msi->msi_dev, INTEL_ADDR(msi), INTEL_DATA(msi));
-	mtx_unlock_spin(&icu_lock);
-}
-
-static void
-msix_enable_intr(struct intsrc *isrc)
-{
-	struct msi_intsrc *msi = (struct msi_intsrc *)isrc;
-
-	mtx_lock_spin(&icu_lock);
-	pci_enable_msix(msi->msi_dev, msi->msi_index, INTEL_ADDR(msi),
-	    INTEL_DATA(msi));
-	pci_unmask_msix(msi->msi_dev, msi->msi_index);
-	mtx_unlock_spin(&icu_lock);
-	apic_enable_vector(msi->msi_vector);
-}
-
-static int
-msix_source_pending(struct intsrc *isrc)
-{
-	struct msi_intsrc *msi = (struct msi_intsrc *)isrc;
-
-	return (pci_pending_msix(msi->msi_dev, msi->msi_index));
-}
-
-static void
-msix_assign_cpu(struct intsrc *isrc, u_int apic_id)
-{
-	struct msi_intsrc *msi = (struct msi_intsrc *)isrc;
-
-	msi->msi_cpu = apic_id;
-	if (bootverbose)
-		printf("msi: Assigning MSI-X IRQ %d to local APIC %u\n",
-		    msi->msi_irq, msi->msi_cpu);
-	mtx_lock_spin(&icu_lock);
-	if (isrc->is_enabled)
-		pci_enable_msix(msi->msi_dev, msi->msi_index, INTEL_ADDR(msi),
-		    INTEL_DATA(msi));
-	mtx_unlock_spin(&icu_lock);
+		pci_remap_msi_irq(msi->msi_dev, msi->msi_irq);
 }
 
 void
@@ -262,8 +207,29 @@
 
 	msi_enabled = 1;
 	intr_register_pic(&msi_pic);
-	intr_register_pic(&msix_pic);
-	sx_init(&msi_sx, "msi");
+	mtx_init(&msi_lock, "msi", NULL, MTX_DEF);
+}
+
+void
+msi_create_source(void)
+{
+	struct msi_intsrc *msi;
+	u_int irq;
+
+	mtx_lock(&msi_lock);
+	if (msi_last_irq >= NUM_MSI_INTS) {
+		mtx_unlock(&msi_lock);
+		return;
+	}
+	irq = msi_last_irq + FIRST_MSI_INT;
+	msi_last_irq++;
+	mtx_unlock(&msi_lock);
+
+	msi = malloc(sizeof(struct msi_intsrc), M_MSI, M_WAITOK | M_ZERO);	
+	msi->msi_intsrc.is_pic = &msi_pic;
+	msi->msi_irq = irq;
+	intr_register_source(&msi->msi_intsrc);
+	nexus_add_irq(irq);
 }
 
 /*
@@ -273,18 +239,16 @@
  * and *newcount being the number of new IRQ values added.
  */
 int
-msi_alloc(device_t dev, int count, int maxcount, int *irqs, int *newirq,
-    int *newcount)
+msi_alloc(device_t dev, int count, int maxcount, int *irqs)
 {
 	struct msi_intsrc *msi, *fsrc;
-	int cnt, i, j, vector;
+	int cnt, i, vector;
 
-	*newirq = 0;
-	*newcount = 0;
 	if (!msi_enabled)
 		return (ENXIO);
 
-	sx_xlock(&msi_sx);
+again:
+	mtx_lock(&msi_lock);
 
 	/* Try to find 'count' free IRQs. */
 	cnt = 0;
@@ -308,26 +272,17 @@
 	if (cnt < count) {
 		/* If we would exceed the max, give up. */
 		if (i + (count - cnt) > FIRST_MSI_INT + NUM_MSI_INTS) {
-			sx_xunlock(&msi_sx);
+			mtx_unlock(&msi_lock);
 			return (ENXIO);
 		}
+		mtx_unlock(&msi_lock);
 
-		/* We need count - cnt more sources starting at index 'cnt'. */
-		*newirq = cnt;
-		*newcount = count - cnt;
-		for (j = 0; j < *newcount; j++) {
-
-			/* Create a new MSI source. */
-			msi = malloc(sizeof(struct msi_intsrc), M_MSI,
-			    M_WAITOK | M_ZERO);
-			msi->msi_intsrc.is_pic = &msi_pic;
-			msi->msi_irq = i + j;
-			intr_register_source(&msi->msi_intsrc);
-
-			/* Add it to our array. */
-			irqs[cnt] = i + j;
+		/* We need count - cnt more sources. */
+		while (cnt < count) {
+			msi_create_source();
 			cnt++;
 		}
+		goto again;
 	}
 
 	/* Ok, we now have the IRQs allocated. */
@@ -336,7 +291,7 @@
 	/* Allocate 'count' IDT vectors. */
 	vector = apic_alloc_vectors(irqs, count, maxcount);
 	if (vector == 0) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (ENOSPC);
 	}
 
@@ -344,20 +299,18 @@
 	fsrc = (struct msi_intsrc *)intr_lookup_source(irqs[0]);
 	for (i = 0; i < count; i++) {
 		msi = (struct msi_intsrc *)intr_lookup_source(irqs[i]);
-		msi->msi_intsrc.is_pic = &msi_pic;
 		msi->msi_dev = dev;
 		msi->msi_vector = vector + i;
 		if (bootverbose)
 			printf("msi: routing MSI IRQ %d to vector %u\n",
 			    msi->msi_irq, msi->msi_vector);
-		msi->msi_index = i;
 		msi->msi_first = fsrc;
 
 		/* XXX: Somewhat gross. */
 		msi->msi_intsrc.is_enabled = 0;
 	}
 	fsrc->msi_count = count;
-	sx_xunlock(&msi_sx);
+	mtx_unlock(&msi_lock);
 
 	return (0);
 }
@@ -368,22 +321,22 @@
 	struct msi_intsrc *msi, *first;
 	int i;
 
-	sx_xlock(&msi_sx);
+	mtx_lock(&msi_lock);
 	first = (struct msi_intsrc *)intr_lookup_source(irqs[0]);
 	if (first == NULL) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (ENOENT);
 	}
 
 	/* Make sure this isn't an MSI-X message. */
 	if (first->msi_msix) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (EINVAL);
 	}
 
 	/* Make sure this message is allocated to a group. */
 	if (first->msi_first == NULL) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (ENXIO);
 	}
 
@@ -392,11 +345,9 @@
 	 * the entire group.
 	 */
 	if (first->msi_first != first || first->msi_count != count) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (EINVAL);
 	}
-	KASSERT(first->msi_index == 0, ("index mismatch"));
-
 	KASSERT(first->msi_dev != NULL, ("unowned group"));
 
 	/* Clear all the extra messages in the group. */
@@ -408,7 +359,6 @@
 		msi->msi_dev = NULL;
 		apic_free_vector(msi->msi_vector, msi->msi_irq);
 		msi->msi_vector = 0;
-		msi->msi_index = 0;
 	}
 
 	/* Clear out the first message. */
@@ -418,21 +368,58 @@
 	first->msi_vector = 0;
 	first->msi_count = 0;
 
-	sx_xunlock(&msi_sx);
+	mtx_unlock(&msi_lock);
+	return (0);
+}
+
+int
+msi_map(int irq, uint64_t *addr, uint32_t *data)
+{
+	struct msi_intsrc *msi;
+
+	mtx_lock(&msi_lock);
+	msi = (struct msi_intsrc *)intr_lookup_source(irq);
+	if (msi == NULL) {
+		mtx_unlock(&msi_lock);
+		return (ENOENT);
+	}
+
+	/* Make sure this message is allocated to a device. */
+	if (msi->msi_dev == NULL) {
+		mtx_unlock(&msi_lock);
+		return (ENXIO);
+	}
+
+	/*
+	 * If this message isn't an MSI-X message, make sure it's part
+	 * of a group, and switch to the first message in the
+	 * group.
+	 */
+	if (!msi->msi_msix) {
+		if (msi->msi_first == NULL) {
+			mtx_unlock(&msi_lock);
+			return (ENXIO);
+		}
+		msi = msi->msi_first;
+	}
+
+	*addr = INTEL_ADDR(msi);
+	*data = INTEL_DATA(msi);
+	mtx_unlock(&msi_lock);
 	return (0);
 }
 
 int
-msix_alloc(device_t dev, int index, int *irq, int *new)
+msix_alloc(device_t dev, int *irq)
 {
 	struct msi_intsrc *msi;
 	int i, vector;
 
-	*new = 0;
 	if (!msi_enabled)
 		return (ENXIO);
 
-	sx_xlock(&msi_sx);
+again:
+	mtx_lock(&msi_lock);
 
 	/* Find a free IRQ. */
 	for (i = FIRST_MSI_INT; i < FIRST_MSI_INT + NUM_MSI_INTS; i++) {
@@ -442,7 +429,7 @@
 		if (msi == NULL)
 			break;
 
-		/* If this is a free one, start or continue a run. */
+		/* Stop at the first free source. */
 		if (msi->msi_dev == NULL)
 			break;
 	}
@@ -451,17 +438,14 @@
 	if (msi == NULL) {
 		/* If we would exceed the max, give up. */
 		if (i + 1 > FIRST_MSI_INT + NUM_MSI_INTS) {
-			sx_xunlock(&msi_sx);
+			mtx_unlock(&msi_lock);
 			return (ENXIO);
 		}
+		mtx_unlock(&msi_lock);
 
 		/* Create a new source. */
-		*new = 1;
-		msi = malloc(sizeof(struct msi_intsrc), M_MSI,
-		    M_WAITOK | M_ZERO);
-		msi->msi_intsrc.is_pic = &msix_pic;
-		msi->msi_irq = i;
-		intr_register_source(&msi->msi_intsrc);
+		msi_create_source();
+		goto again;
 	}
 
 	/* Allocate an IDT vector. */
@@ -471,59 +455,33 @@
 		    vector);
 
 	/* Setup source. */
-	msi->msi_intsrc.is_pic = &msix_pic;
 	msi->msi_dev = dev;
 	msi->msi_vector = vector;
-	msi->msi_index = index;
 	msi->msi_msix = 1;
 
 	/* XXX: Somewhat gross. */
 	msi->msi_intsrc.is_enabled = 0;
-	sx_xunlock(&msi_sx);
+	mtx_unlock(&msi_lock);
 
 	*irq = i;
 	return (0);
 }
 
 int
-msix_remap(int index, int irq)
-{
-	struct msi_intsrc *msi;
-
-	sx_xlock(&msi_sx);
-	msi = (struct msi_intsrc *)intr_lookup_source(irq);
-	if (msi == NULL) {
-		sx_xunlock(&msi_sx);
-		return (ENOENT);
-	}
-
-	/* Make sure this is an MSI-X message. */
-	if (!msi->msi_msix) {
-		sx_xunlock(&msi_sx);
-		return (EINVAL);
-	}
-
-	KASSERT(msi->msi_dev != NULL, ("unowned message"));
-	msi->msi_index = index;
-	sx_xunlock(&msi_sx);
-	return (0);
-}
-
-int
 msix_release(int irq)
 {
 	struct msi_intsrc *msi;
 
-	sx_xlock(&msi_sx);
+	mtx_lock(&msi_lock);
 	msi = (struct msi_intsrc *)intr_lookup_source(irq);
 	if (msi == NULL) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (ENOENT);
 	}
 
 	/* Make sure this is an MSI-X message. */
 	if (!msi->msi_msix) {
-		sx_xunlock(&msi_sx);
+		mtx_unlock(&msi_lock);
 		return (EINVAL);
 	}
 
@@ -533,9 +491,8 @@
 	msi->msi_dev = NULL;
 	apic_free_vector(msi->msi_vector, msi->msi_irq);
 	msi->msi_vector = 0;
-	msi->msi_index = 0;
 	msi->msi_msix = 0;
 
-	sx_xunlock(&msi_sx);
+	mtx_unlock(&msi_lock);
 	return (0);
 }

==== //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/nexus.c#2 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/nexus.c,v 1.66.2.2 2007/03/31 15:23:19 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/nexus.c,v 1.66.2.4 2007/08/15 21:12:07 jhb Exp $");
 
 /*
  * This code implements a `root nexus' for Intel Architecture
@@ -105,9 +105,9 @@
 static void nexus_delete_resource(device_t, device_t, int, int);
 static	int nexus_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs);
 static	int nexus_release_msi(device_t pcib, device_t dev, int count, int *irqs);
-static	int nexus_alloc_msix(device_t pcib, device_t dev, int index, int *irq);
-static	int nexus_remap_msix(device_t pcib, device_t dev, int index, int irq);
+static	int nexus_alloc_msix(device_t pcib, device_t dev, int *irq);
 static	int nexus_release_msix(device_t pcib, device_t dev, int irq);
+static	int nexus_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data);
 
 static device_method_t nexus_methods[] = {
 	/* Device interface */
@@ -137,8 +137,8 @@
 	DEVMETHOD(pcib_alloc_msi,	nexus_alloc_msi),
 	DEVMETHOD(pcib_release_msi,	nexus_release_msi),
 	DEVMETHOD(pcib_alloc_msix,	nexus_alloc_msix),
-	DEVMETHOD(pcib_remap_msix,	nexus_remap_msix),
 	DEVMETHOD(pcib_release_msix,	nexus_release_msix),
+	DEVMETHOD(pcib_map_msi,		nexus_map_msi),
 
 	{ 0, 0 }
 };
@@ -519,22 +519,20 @@
 	resource_list_delete(rl, type, rid);
 }
 
-static int
-nexus_alloc_msix(device_t pcib, device_t dev, int index, int *irq)
+/* Called from the MSI code to add new IRQs to the IRQ rman. */
+void
+nexus_add_irq(u_long irq)
 {
-	int error, new;
 
-	error = msix_alloc(dev, index, irq, &new);
-	if (new)
-		rman_manage_region(&irq_rman, *irq, *irq);
-	return (error);
+	if (rman_manage_region(&irq_rman, irq, irq) != 0)
+		panic("%s: failed", __func__);
 }
 
 static int
-nexus_remap_msix(device_t pcib, device_t dev, int index, int irq)
+nexus_alloc_msix(device_t pcib, device_t dev, int *irq)
 {
 
-	return (msix_remap(index, irq));
+	return (msix_alloc(dev, irq));
 }
 
 static int
@@ -547,24 +545,22 @@
 static int
 nexus_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs)
 {
-	int error, i, newirq, newcount;
 
-	/* First alloc the messages. */
-	error = msi_alloc(dev, count, maxcount, irqs, &newirq, &newcount);
+	return (msi_alloc(dev, count, maxcount, irqs));
+}
 
-	/* Always add any new IRQs to the rman, even on failure. */
-	for (i = 0; i < newcount; i++)
-		rman_manage_region(&irq_rman, irqs[newirq + i],
-		    irqs[newirq + i]);
+static int
+nexus_release_msi(device_t pcib, device_t dev, int count, int *irqs)
+{
 
-	return (error);
+	return (msi_release(irqs, count));
 }
 
 static int
-nexus_release_msi(device_t pcib, device_t dev, int count, int *irqs)
+nexus_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data)
 {
 
-	return (msi_release(irqs, count));
+	return (msi_map(irq, addr, data));
 }
 
 #ifdef DEV_ISA

==== //depot/projects/soc2007/thioretic_gidl2/amd64/amd64/trap.c#2 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.289.2.5 2007/02/03 03:14:21 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.289.2.6 2007/08/14 19:42:51 jhb Exp $");
 
 /*
  * AMD64 Trap and System call handling
@@ -162,8 +162,8 @@
 {
 	struct thread *td = curthread;
 	struct proc *p = td->td_proc;
-	u_int sticks = 0;
-	int i = 0, ucode = 0, type, code;
+	u_int sticks = 0, type;
+	int i = 0, ucode = 0, code;
 
 	PCPU_LAZY_INC(cnt.v_trap);
 	type = frame.tf_trapno;
@@ -589,7 +589,8 @@
 	struct trapframe *frame;
 	vm_offset_t eva;
 {
-	int code, type, ss;
+	int code, ss;
+	u_int type;
 	long esp;
 	struct soft_segment_descriptor softseg;
 	char *msg;

==== //depot/projects/soc2007/thioretic_gidl2/amd64/include/intr_machdep.h#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/amd64/include/intr_machdep.h,v 1.5.2.6 2007/03/31 15:23:20 jhb Exp $
+ * $FreeBSD: src/sys/amd64/include/intr_machdep.h,v 1.5.2.8 2007/08/15 21:12:07 jhb Exp $
  */
 
 #ifndef __MACHINE_INTR_MACHDEP_H__
@@ -147,12 +147,12 @@
 void	intr_resume(void);
 void	intr_suspend(void);
 void	intrcnt_add(const char *name, u_long **countp);
-int	msi_alloc(device_t dev, int count, int maxcount, int *irqs, int *newirq,
-    int *newcount);
+void	nexus_add_irq(u_long irq);
+int	msi_alloc(device_t dev, int count, int maxcount, int *irqs);
 void	msi_init(void);
+int	msi_map(int irq, uint64_t *addr, uint32_t *data);
 int	msi_release(int *irqs, int count);
-int	msix_alloc(device_t dev, int index, int *irq, int *new);
-int	msix_remap(int index, int irq);
+int	msix_alloc(device_t dev, int *irq);
 int	msix_release(int irq);
 
 #endif	/* !LOCORE */

==== //depot/projects/soc2007/thioretic_gidl2/amd64/pci/pci_bus.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.113.2.3 2007/03/31 15:23:20 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.113.2.4 2007/08/15 20:56:09 jhb Exp $");
 
 #include "opt_cpu.h"
 
@@ -81,7 +81,7 @@
 	return (PCI_INVALID_IRQ);
 }
 
-/* Pass MSI alloc requests up to the nexus. */
+/* Pass MSI requests up to the nexus. */
 
 static int
 legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
@@ -95,12 +95,22 @@
 }
 
 static int
-legacy_pcib_alloc_msix(device_t pcib, device_t dev, int index, int *irq)
+legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
+{
+	device_t bus;
+
+	bus = device_get_parent(pcib);
+	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
+}
+
+static int
+legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
+    uint32_t *data)
 {
 	device_t bus;
 
 	bus = device_get_parent(pcib);
-	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, index, irq));
+	return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
 }
 
 static const char *
@@ -347,8 +357,8 @@
 	DEVMETHOD(pcib_alloc_msi,	legacy_pcib_alloc_msi),
 	DEVMETHOD(pcib_release_msi,	pcib_release_msi),
 	DEVMETHOD(pcib_alloc_msix,	legacy_pcib_alloc_msix),
-	DEVMETHOD(pcib_remap_msix,	pcib_remap_msix),
 	DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+	DEVMETHOD(pcib_map_msi,		legacy_pcib_map_msi),
 
 	{ 0, 0 }
 };

==== //depot/projects/soc2007/thioretic_gidl2/dev/acpica/acpi_pcib_acpi.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.47.2.4 2007/03/31 14:50:50 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.47.2.5 2007/08/15 20:56:09 jhb Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -76,8 +76,10 @@
 			    device_t dev, int pin);
 static int		acpi_pcib_alloc_msi(device_t pcib, device_t dev,
 			    int count, int maxcount, int *irqs);
+static int		acpi_pcib_map_msi(device_t pcib, device_t dev,
+			    int irq, uint64_t *addr, uint32_t *data);
 static int		acpi_pcib_alloc_msix(device_t pcib, device_t dev,
-			    int index, int *irq);
+			    int *irq);
 static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev,
 			    device_t child, int type, int *rid,
 			    u_long start, u_long end, u_long count,
@@ -110,8 +112,8 @@
     DEVMETHOD(pcib_alloc_msi,		acpi_pcib_alloc_msi),
     DEVMETHOD(pcib_release_msi,		pcib_release_msi),
     DEVMETHOD(pcib_alloc_msix,		acpi_pcib_alloc_msix),
-    DEVMETHOD(pcib_remap_msix,		pcib_remap_msix),
     DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+    DEVMETHOD(pcib_map_msi,		acpi_pcib_map_msi),
 
     {0, 0}
 };
@@ -323,12 +325,22 @@
 }
 
 static int
-acpi_pcib_alloc_msix(device_t pcib, device_t dev, int index, int *irq)
+acpi_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
+{
+	device_t bus;
+
+	bus = device_get_parent(pcib);
+	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
+}
+
+static int
+acpi_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
+    uint32_t *data)
 {
 	device_t bus;
 
 	bus = device_get_parent(pcib);
-	return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, index, irq));
+	return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
 }
 
 static u_long acpi_host_mem_start = 0x80000000;

==== //depot/projects/soc2007/thioretic_gidl2/dev/acpica/acpi_pcib_pci.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib_pci.c,v 1.12.2.3 2007/03/31 14:50:50 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pcib_pci.c,v 1.12.2.4 2007/08/15 20:56:09 jhb Exp $");
 
 #include "opt_acpi.h"
 
@@ -96,8 +96,8 @@
     DEVMETHOD(pcib_alloc_msi,		pcib_alloc_msi),
     DEVMETHOD(pcib_release_msi,		pcib_release_msi),
     DEVMETHOD(pcib_alloc_msix,		pcib_alloc_msix),
-    DEVMETHOD(pcib_remap_msix,		pcib_remap_msix),
     DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+    DEVMETHOD(pcib_map_msi,		pcib_map_msi),
 
     {0, 0}
 };

==== //depot/projects/soc2007/thioretic_gidl2/dev/cxgb/common/cxgb_common.h#2 (text+ko) ====

@@ -25,7 +25,7 @@
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.
 
-$FreeBSD: src/sys/dev/cxgb/common/cxgb_common.h,v 1.1.2.4 2007/06/17 23:52:16 kmacy Exp $
+$FreeBSD: src/sys/dev/cxgb/common/cxgb_common.h,v 1.1.2.5 2007/08/18 09:10:25 kmacy Exp $
 
 ***************************************************************************/
 #ifndef __CHELSIO_COMMON_H
@@ -38,8 +38,6 @@
 #endif
 
 enum {
-	MAX_NPORTS = 4,
-	TP_TMR_RES = 200,       /* TP timer resolution in usec */
 	MAX_FRAME_SIZE = 10240, /* max MAC frame size, includes header + FCS */
 	EEPROMSIZE     = 8192,  /* Serial EEPROM size */
 	RSS_TABLE_SIZE = 64,    /* size of RSS lookup and mapping tables */
@@ -48,6 +46,10 @@
 	NCCTRL_WIN     = 32,    /* # of congestion control windows */
 	NTX_SCHED      = 8,     /* # of HW Tx scheduling queues */
 	PROTO_SRAM_LINES = 128, /* size of protocol sram */
+	MAX_NPORTS     = 4,
+	TP_TMR_RES     = 200,
+	TP_SRAM_OFFSET = 4096,	/* TP SRAM content offset in eeprom */
+	TP_SRAM_LEN    = 2112,	/* TP SRAM content offset in eeprom */
 };
 
 #define MAX_RX_COALESCING_LEN 12288U
@@ -72,8 +74,8 @@
 
 enum {
 	TP_VERSION_MAJOR	= 1,
-	TP_VERSION_MINOR	= 0,
-	TP_VERSION_MICRO	= 44
+	TP_VERSION_MINOR	= 1,
+	TP_VERSION_MICRO	= 0
 };
 
 #define S_TP_VERSION_MAJOR		16
@@ -96,7 +98,7 @@
 
 enum {
 	FW_VERSION_MAJOR = 4,
-	FW_VERSION_MINOR = 1,
+	FW_VERSION_MINOR = 5,
 	FW_VERSION_MICRO = 0
 };
 
@@ -393,6 +395,7 @@
 	T3_REV_A  = 0,
 	T3_REV_B  = 2,
 	T3_REV_B2 = 3,
+	T3_REV_C  = 4,
 };
 
 struct trace_params {
@@ -467,6 +470,7 @@
 	unsigned int tx_xcnt;
 	u64 tx_mcnt;
 	unsigned int rx_xcnt;
+	unsigned int rx_ocnt;
 	u64 rx_mcnt;
 	unsigned int toggle_cnt;
 	unsigned int txen;
@@ -562,6 +566,9 @@
 /* Accumulate MAC statistics every 180 seconds.  For 1G we multiply by 10. */
 #define MAC_STATS_ACCUM_SECS 180
 
+/* The external MAC needs accumulation every 30 seconds */
+#define VSC_STATS_ACCUM_SECS 30
+
 #define XGM_REG(reg_addr, idx) \
 	((reg_addr) + (idx) * (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR))
 
@@ -656,9 +663,10 @@

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



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