Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jan 2012 09:58:40 +0000 (UTC)
From:      Grzegorz Bernacki <gber@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r229271 - in projects/armv6/sys: arm/conf boot/fdt/dts dev/mge
Message-ID:  <201201020958.q029weIU058383@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gber
Date: Mon Jan  2 09:58:39 2012
New Revision: 229271
URL: http://svn.freebsd.org/changeset/base/229271

Log:
  Import files needed to build ARMADA XP kernel.
  
  Obtained from:	Marvell, Semihalf

Added:
  projects/armv6/sys/arm/conf/ARMADAXP
Modified:
  projects/armv6/sys/boot/fdt/dts/db88f78160.dts
  projects/armv6/sys/dev/mge/if_mge.c
  projects/armv6/sys/dev/mge/if_mgevar.h

Added: projects/armv6/sys/arm/conf/ARMADAXP
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/armv6/sys/arm/conf/ARMADAXP	Mon Jan  2 09:58:39 2012	(r229271)
@@ -0,0 +1,102 @@
+#
+# Custom kernel for Marvell Armada XP
+#
+# $FreeBSD$
+#
+
+ident		MV-88F78XX0
+include		"../mv/armadaxp/std.mv78x60"
+
+options 	SOC_MV_ARMADAXP
+makeoptions	MODULES_OVERRIDE=""
+
+makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+makeoptions	WERROR="-Werror --save-temps"
+
+#options 	SCHED_ULE		#ULE scheduler
+options 	SCHED_4BSD		#4BSD scheduler
+options 	INET			#InterNETworking
+options 	INET6			#IPv6 communications protocols
+options 	FFS			#Berkeley Fast Filesystem
+options 	NFSCL			#Network Filesystem Client
+options 	NFSLOCKD		#Network Lock Manager
+options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+options 	BOOTP
+options 	BOOTP_NFSROOT
+options 	BOOTP_NFSV3
+options 	BOOTP_WIRED_TO=mge0
+
+options 	GEOM_PART_GPT
+options 	ROOTDEVNAME=\"ufs:/dev/da0p1\"
+
+options 	SYSVSHM			#SYSV-style shared memory
+options 	SYSVMSG			#SYSV-style message queues
+options 	SYSVSEM			#SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options 	MUTEX_NOINLINE
+options 	RWLOCK_NOINLINE
+options 	NO_FFS_SNAPSHOT
+options 	NO_SWAPPING
+
+options 	SMP
+
+# Debugging
+#options 	VERBOSE_SYSINIT
+options 	ALT_BREAK_TO_DEBUGGER
+options 	DDB
+options 	GDB
+#options 	DIAGNOSTIC
+#options 	INVARIANTS		#Enable calls of extra sanity checking
+#options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+options 	KDB
+options 	KDB_TRACE
+#options 	KTR
+#options 	KTR_VERBOSE=0
+#options 	KTR_ENTRIES=16384
+#options 	KTR_MASK=(KTR_SPARE2)
+#options 	KTR_COMPILE=KTR_ALL
+#options 	WITNESS			#Enable checks to detect deadlocks and cycles
+#options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+#options 	WITNESS_KDB
+
+# Pseudo devices
+device		random
+device		pty
+device		loop
+device		md
+
+# USB
+options 	USB_DEBUG		# enable debug msgs
+device		usb
+device		ehci
+device		umass
+device		scbus
+device		pass
+device		da
+
+# SATA
+device		ata
+device		atadisk
+#device		mvs
+
+# Serial ports
+device		uart
+
+# I2C (TWSI)
+device		iic
+device		iicbus
+
+#Network
+device		ether
+device		mge			# Marvell Gigabit Ethernet controller
+device		mii
+device		e1000phy
+device		bpf
+options		HZ=1000
+options		DEVICE_POLLING
+device		vlan
+
+#FDT
+options 	FDT
+options 	FDT_DTB_STATIC
+makeoptions	FDT_DTS_FILE=db88f78160.dts

Modified: projects/armv6/sys/boot/fdt/dts/db88f78160.dts
==============================================================================
--- projects/armv6/sys/boot/fdt/dts/db88f78160.dts	Mon Jan  2 09:56:40 2012	(r229270)
+++ projects/armv6/sys/boot/fdt/dts/db88f78160.dts	Mon Jan  2 09:58:39 2012	(r229271)
@@ -74,7 +74,7 @@
 			interrupt-controller;
 			#address-cells = <0>;
 			#interrupt-cells = <1>;
-			reg = <0x20a00 0x200>;
+			reg = <0x20a00 0x500 0x21000 0x800>;
 			compatible = "mrvl,mpic";
 		};
 
@@ -253,10 +253,11 @@
 			compatible = "mrvl,ge";
 			reg = <0x72000 0x2000>;
 			ranges = <0x0 0x72000 0x2000>;
-			local-mac-address = [ 00 01 01 07 84 60 ];
+			local-mac-address = [ 00 04 01 07 84 60 ];
 			interrupts = <67 68 122 >;
 			interrupt-parent = <&MPIC>;
 			phy-handle = <&phy0>;
+			has-neta;
 
 			mdio@0 {
 				#address-cells = <1>;

Modified: projects/armv6/sys/dev/mge/if_mge.c
==============================================================================
--- projects/armv6/sys/dev/mge/if_mge.c	Mon Jan  2 09:56:40 2012	(r229270)
+++ projects/armv6/sys/dev/mge/if_mge.c	Mon Jan  2 09:58:39 2012	(r229271)
@@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$");
 
 #include "miibus_if.h"
 
-/* PHY registers are in the address space of the first mge unit */
 static struct mge_softc *sc_mge0 = NULL;
 
 static int mge_probe(device_t dev);
@@ -107,7 +106,10 @@ static uint32_t mge_rx_ipg(uint32_t val,
 static void mge_ver_params(struct mge_softc *sc);
 
 static void mge_intrs_ctrl(struct mge_softc *sc, int enable);
+static void mge_intr_rxtx(void *arg);
 static void mge_intr_rx(void *arg);
+static void mge_intr_rx_check(struct mge_softc *sc, uint32_t int_cause,
+    uint32_t int_cause_ext);
 static int mge_intr_rx_locked(struct mge_softc *sc, int count);
 static void mge_intr_tx(void *arg);
 static void mge_intr_tx_locked(struct mge_softc *sc);
@@ -174,15 +176,14 @@ static struct resource_spec res_spec[] =
 	{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
 	{ SYS_RES_IRQ, 1, RF_ACTIVE | RF_SHAREABLE },
 	{ SYS_RES_IRQ, 2, RF_ACTIVE | RF_SHAREABLE },
-	{ SYS_RES_IRQ, 3, RF_ACTIVE | RF_SHAREABLE },
-	{ SYS_RES_IRQ, 4, RF_ACTIVE | RF_SHAREABLE },
 	{ -1, 0 }
 };
 
 static struct {
 	driver_intr_t *handler;
 	char * description;
-} mge_intrs[MGE_INTR_COUNT] = {
+} mge_intrs[MGE_INTR_COUNT + 1] = {
+	{ mge_intr_rxtx,"GbE aggregated interrupt" },
 	{ mge_intr_rx,	"GbE receive interrupt" },
 	{ mge_intr_tx,	"GbE transmit interrupt" },
 	{ mge_intr_misc,"GbE misc interrupt" },
@@ -261,8 +262,9 @@ mge_ver_params(struct mge_softc *sc)
 	uint32_t d, r;
 
 	soc_id(&d, &r);
-	if (d == MV_DEV_88F6281 || d == MV_DEV_MV78100 ||
-	    d == MV_DEV_MV78100_Z0) {
+	if (d == MV_DEV_88F6281 || d == MV_DEV_88F6781 ||
+	    d == MV_DEV_MV78100_Z0 ||
+	    (d & MV_DEV_FAMILY_MASK) == MV_DEV_DISCOVERY) {
 		sc->mge_ver = 2;
 		sc->mge_mtu = 0x4e8;
 		sc->mge_tfut_ipg_max = 0xFFFF;
@@ -279,6 +281,15 @@ mge_ver_params(struct mge_softc *sc)
 		sc->mge_tx_tok_cfg = 0x3FFFFFFF;
 		sc->mge_tx_tok_cnt = 0x3FFFFFFF;
 	}
+	if (d == MV_DEV_88RC8180)
+		sc->mge_intr_cnt = 1;
+	else
+		sc->mge_intr_cnt = 2;
+
+	if (d == MV_DEV_MV78160 || d == MV_DEV_MV78260 || d == MV_DEV_MV78460)
+		sc->mge_hw_csum = 0;
+	else
+		sc->mge_hw_csum = 1;
 }
 
 static void
@@ -443,7 +454,7 @@ mge_alloc_desc_dma(struct mge_softc *sc,
 
 	/* Allocate a busdma tag for mbufs. */
 	error = bus_dma_tag_create(NULL,	/* parent */
-	    8, 0,				/* alignment, boundary */
+	    1, 0,				/* alignment, boundary */
 	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
 	    BUS_SPACE_MAXADDR,			/* highaddr */
 	    NULL, NULL,				/* filtfunc, filtfuncarg */
@@ -685,9 +696,12 @@ mge_attach(device_t dev)
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST;
-	ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_MTU;
+	ifp->if_capabilities = IFCAP_VLAN_MTU;
+	if (sc->mge_hw_csum) {
+		ifp->if_capabilities |= IFCAP_HWCSUM;
+		ifp->if_hwassist = MGE_CHECKSUM_FEATURES;
+	}
 	ifp->if_capenable = ifp->if_capabilities;
-	ifp->if_hwassist = MGE_CHECKSUM_FEATURES;
 
 #ifdef DEVICE_POLLING
 	/* Advertise that polling is supported */
@@ -721,13 +735,15 @@ mge_attach(device_t dev)
 	MGE_WRITE(sc, MGE_REG_PHYDEV, miisc->mii_phy);
 
 	/* Attach interrupt handlers */
-	for (i = 0; i < 2; ++i) {
-		error = bus_setup_intr(dev, sc->res[1 + i],
-		    INTR_TYPE_NET | INTR_MPSAFE, NULL, *mge_intrs[i].handler,
-		    sc, &sc->ih_cookie[i]);
+	/* TODO: review flags, in part. mark RX as INTR_ENTROPY ? */
+	for (i = 1; i <= sc->mge_intr_cnt; ++i) {
+		error = bus_setup_intr(dev, sc->res[i],
+		    INTR_TYPE_NET | INTR_MPSAFE,
+		    NULL, *mge_intrs[(sc->mge_intr_cnt == 1 ? 0 : i)].handler,
+		    sc, &sc->ih_cookie[i - 1]);
 		if (error) {
 			device_printf(dev, "could not setup %s\n",
-			    mge_intrs[i].description);
+			    mge_intrs[(sc->mge_intr_cnt == 1 ? 0 : i)].description);
 			mge_detach(dev);
 			return (error);
 		}
@@ -752,14 +768,14 @@ mge_detach(device_t dev)
         callout_drain(&sc->wd_callout);
 
 	/* Stop and release all interrupts */
-	for (i = 0; i < 2; ++i) {
+	for (i = 0; i < sc->mge_intr_cnt; ++i) {
 		if (!sc->ih_cookie[i])
 			continue;
 
 		error = bus_teardown_intr(dev, sc->res[1 + i], sc->ih_cookie[i]);
 		if (error)
 			device_printf(dev, "could not release %s\n",
-			    mge_intrs[i].description);
+			    mge_intrs[(sc->mge_intr_cnt == 1 ? 0 : i + 1)].description);
 	}
 
 	/* Detach network interface */
@@ -987,6 +1003,41 @@ mge_init_locked(void *arg)
 }
 
 static void
+mge_intr_rxtx(void *arg)
+{
+	struct mge_softc *sc = arg;
+	uint32_t int_cause, int_cause_ext;
+
+	MGE_GLOBAL_LOCK(sc);
+
+#ifdef DEVICE_POLLING
+	if (sc->ifp->if_capenable & IFCAP_POLLING) {
+		MGE_GLOBAL_UNLOCK(sc);
+		return;
+	}
+#endif
+
+	/* Get interrupt cause */
+	int_cause = MGE_READ(sc, MGE_PORT_INT_CAUSE);
+	int_cause_ext = MGE_READ(sc, MGE_PORT_INT_CAUSE_EXT);
+
+	/* Check for Transmit interrupt */
+	if (int_cause_ext & (MGE_PORT_INT_EXT_TXBUF0 |
+	    MGE_PORT_INT_EXT_TXUR)) {
+		MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT, ~(int_cause_ext &
+		    (MGE_PORT_INT_EXT_TXBUF0 | MGE_PORT_INT_EXT_TXUR)));
+		mge_intr_tx_locked(sc);
+	}
+
+	MGE_TRANSMIT_UNLOCK(sc);
+
+	/* Check for Receive interrupt */
+	mge_intr_rx_check(sc, int_cause, int_cause_ext);
+
+	MGE_RECEIVE_UNLOCK(sc);
+}
+
+static void
 mge_intr_err(void *arg)
 {
 	struct mge_softc *sc = arg;
@@ -1024,11 +1075,20 @@ mge_intr_rx(void *arg) {
 	int_cause = MGE_READ(sc, MGE_PORT_INT_CAUSE);
 	int_cause_ext = MGE_READ(sc, MGE_PORT_INT_CAUSE_EXT);
 
+	mge_intr_rx_check(sc, int_cause, int_cause_ext);
+
+	MGE_RECEIVE_UNLOCK(sc);
+}
+
+static void
+mge_intr_rx_check(struct mge_softc *sc, uint32_t int_cause,
+    uint32_t int_cause_ext)
+{
 	/* Check for resource error */
 	if (int_cause & MGE_PORT_INT_RXERRQ0) {
 		mge_reinit_rx(sc);
 		MGE_WRITE(sc, MGE_PORT_INT_CAUSE,
-		    int_cause & ~MGE_PORT_INT_RXERRQ0);
+		    ~(int_cause & MGE_PORT_INT_RXERRQ0));
 	}
 
 	int_cause &= MGE_PORT_INT_RXQ0;
@@ -1039,11 +1099,8 @@ mge_intr_rx(void *arg) {
 		MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT, ~int_cause_ext);
 		mge_intr_rx_locked(sc, -1);
 	}
-
-	MGE_RECEIVE_UNLOCK(sc);
 }
 
-
 static int
 mge_intr_rx_locked(struct mge_softc *sc, int count)
 {
@@ -1134,8 +1191,8 @@ mge_intr_tx(void *arg)
 
 	/* Ack the interrupt */
 	int_cause_ext = MGE_READ(sc, MGE_PORT_INT_CAUSE_EXT);
-	MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT,
-	    int_cause_ext & ~MGE_PORT_INT_EXT_TXBUF0);
+	MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT, ~(int_cause_ext &
+	    (MGE_PORT_INT_EXT_TXBUF0 | MGE_PORT_INT_EXT_TXUR)));
 
 	mge_intr_tx_locked(sc);
 
@@ -1404,12 +1461,12 @@ mge_encap(struct mge_softc *sc, struct m
 		dw->mge_desc->byte_count = segs[seg].ds_len;
 		dw->mge_desc->buffer = segs[seg].ds_addr;
 		dw->buffer = m0;
-		dw->mge_desc->cmd_status = MGE_TX_LAST | MGE_TX_FIRST |
-		    MGE_TX_ETH_CRC | MGE_TX_EN_INT | MGE_TX_PADDING |
-		    MGE_DMA_OWNED;
-
+		dw->mge_desc->cmd_status = 0;
 		if (seg == 0)
 			mge_offload_setup_descriptor(sc, dw);
+		dw->mge_desc->cmd_status |= MGE_TX_LAST | MGE_TX_FIRST |
+		    MGE_TX_ETH_CRC | MGE_TX_EN_INT | MGE_TX_PADDING |
+		    MGE_DMA_OWNED;
 	}
 
 	bus_dmamap_sync(sc->mge_desc_dtag, dw->desc_dmap,

Modified: projects/armv6/sys/dev/mge/if_mgevar.h
==============================================================================
--- projects/armv6/sys/dev/mge/if_mgevar.h	Mon Jan  2 09:56:40 2012	(r229270)
+++ projects/armv6/sys/dev/mge/if_mgevar.h	Mon Jan  2 09:58:39 2012	(r229271)
@@ -103,6 +103,9 @@ struct mge_softc {
 	uint32_t	mge_tx_tok_cnt;
 	uint16_t	mge_mtu;
 	int		mge_ver;
+	int		mge_intr_cnt;
+	uint8_t		mge_hw_csum;
+
 };
 
 



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