Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 May 2011 21:05:17 -0500
From:      Erik Moe <ehmoeok@gmail.com>
To:        Oleksandr Tymoshenko <gonzo@bluezbox.com>
Cc:        freebsd-mips@freebsd.org
Subject:   Re: FreeBSD MIPS and RB133c
Message-ID:  <22FC61A7-D139-42EB-A04A-CD7DD8FA68B7@gmail.com>
In-Reply-To: <70891B7B-238D-4D7F-8475-58B77D0A7274@bluezbox.com>
References:  <AEDDDA7C-BCCF-49F7-82AD-B479230EA6F4@gmail.com>	<F8BC0A73-D14B-497B-A8AE-4C9737B667D4@gmail.com>	<42E1A1C3-654C-4A1F-8EDC-57EF2A52F5FE@gmail.com>	<4DC9DA05.7050901@freebsd.org>	<BC730DD0-BD9D-40E4-B57E-46503C8E9314@gmail.com>	<4DC9E4ED.8070203@freebsd.org> <5BF1630A-DC4C-4301-B27D-61004D238361@gmail.com> <4DCC857C.5050903@freebsd.org> <295FD17B-AED3-4468-8803-BCB78B4B06A1@gmail.com> <FC3F9B85-5BD3-42EE-9523-9733871457D9@bluezbox.com> <50EFCE6E-255B-4EA5-84CA-986D20413D17@gmail.com> <70891B7B-238D-4D7F-8475-58B77D0A7274@bluezbox.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail-23-786803332
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

Yes, I played with this some this weekend.  I don't really have the =
experience writing drivers for FreeBSD, but I think there was an issue =
with synchronization between the top half and the bottom half of the =
adm5120 switch driver.  I did a lot of experimentation, looked at other =
drivers for examples and I came up with a patch that gets the RB133C to =
boot the kernel multi-user and mount a root NFS filesystem.

RouterBOOT booter 2.18

RouterBoard 133C3

CPU frequency: 175 MHz
  Memory size:  16 MB

Press any key within 6 seconds to enter setup......
trying dhcp protocol... OK
resolved mac address 00:0C:29:29:27:66
Gateway: 192.168.11.1
transfer started ........................... transfer ok, time=3D5.52s
setting up elf image... OK
jumping to kernel code
entry: mips_init()
Cache info:
  picache_stride    =3D 4096
  picache_loopcount =3D 2
  pdcache_stride    =3D 4096
  pdcache_loopcount =3D 2
cpu0: MIPS Technologies processor v11.128
  MMU: Standard TLB, 16 entries
  L1 i-cache: 2 ways of 256 sets, 16 bytes per line
  L1 d-cache: 2 ways of 256 sets, 16 bytes per line
  Config1=3D0x1e994c8a<WatchRegs,EJTAG>
Physical memory chunk(s):
0x436000 - 0xffffff, 12361728 bytes (3018 pages)
Maxmem is 0x1000000
GDB: debug ports: uart
GDB: current port: uart
KDB: debugger backends: ddb gdb
KDB: current backend: ddb
Copyright (c) 1992-2011 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights =
reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.0-CURRENT #72 r221418M: Sun May 15 20:21:23 CDT 2011
    =
emoe@freebsd.localdomain:/usr/home/emoe/obj/mips/mips.mipsel/usr/home/emoe=
/svn/mips/sys/ADM5120.nfs mips
WARNING: WITNESS option enabled, expect reduced performance.
real memory  =3D 16777216 (16384K bytes)
Physical memory chunk(s):
0x004c2000 - 0x00f95fff, 11354112 bytes (2772 pages)
avail memory =3D 10993664 (10MB)
mem: <memory>
null: <null device, zero device>
nfslock: pseudo-device
nexus0: <MIPS32 root nexus>
clock0: <Generic MIPS32 ticker> on nexus0
Timecounter "MIPS32" frequency 175000000 Hz quality 800
Event timer "MIPS32" frequency 175000000 Hz quality 800
obio0 at mem 0-0x1ffffffe on nexus0
admsw0: <ADM5120 Switch Engine> on obio0
admsw0: ADM5120 Switch Engine, 6 ports
admsw0: base Ethernet address 00:0c:42:07:b2:4e
admsw0: Ethernet address: 00:0c:42:07:b2:4e
admsw1: Ethernet address: 00:0c:42:07:b2:4f
admsw2: Ethernet address: 00:0c:42:07:b2:50
admsw3: Ethernet address: 00:0c:42:07:b2:51
admsw4: Ethernet address: 00:0c:42:07:b2:52
admsw5: Ethernet address: 00:0c:42:07:b2:53
uart0: <adm5120_uart, channel A> on obio0
uart0: fast interrupt
uart0: console (115200,n,8,1)
Device configuration finished.
Timecounters tick every 10.000 msec
bootpc_init: wired to interface 'admsw0'
Sending DHCP Discover packet from interface admsw0 (00:0c:42:07:b2:4e)
Received DHCP Offer packet on admsw0 from 192.168.11.2 (accepted) (no =
root path)
Sending DHCP Request packet from interface admsw0 (00:0c:42:07:b2:4e)
Received DHCP Ack packet on admsw0 from 192.168.11.2 (accepted) (got =
root path)
admsw0 at 192.168.11.15 server 192.168.11.2 boot file boot/kernel/kernel
subnet mask 255.255.255.0 router 192.168.11.1 rootfs =
192.168.11.2:/usr/home/emoe/nfsroot=20
Adjusted interface admsw0
WARNING: WITNESS option enabled, expect reduced performance.
Trying to mount root from nfs: []...
NFS ROOT: 192.168.11.2:/usr/home/emoe/nfsroot
warning: no time-of-day clock registered, system time will not be set =
accurately
warning: no time-of-day clock registered, system time will not be set =
accurately
start_init: trying /sbin/init
Setting hostuuid: 1c57c506-1dd2-11b2-9a4c-000c4207b24e.
Setting hostid: 0xcb6fff12.
No suitable dump device was found.
Entropy harvesting:.
Starting file system checks:
mount_nfs: can't update /var/db/mounttab for =
192.168.11.2:/home/emoe/nfsroot
Mounting local file systems:.
/etc/rc: WARNING: $hostname is not set -- see rc.conf(5).
Starting Network: lo0 admsw0 admsw1 admsw2 admsw3 admsw4 admsw5.
lo0: flags=3D8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3D3<RXCSUM,TXCSUM>
        inet 127.0.0.1 netmask 0xff000000=20
admsw0: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
        ether 00:0c:42:07:b2:4e
        inet 192.168.11.15 netmask 0xffffff00 broadcast 192.168.11.255
        media: Ethernet autoselect (none)
        status: no carrier
admsw1: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:4f
        media: Ethernet autoselect (none)
        status: no carrier
admsw2: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:50
        media: Ethernet autoselect (10baseT/UTP)
        status: active
admsw3: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:51
        media: Ethernet autoselect (none)
        status: no carrier
admsw4: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:52
        media: Ethernet autoselect (none)
        status: no carrier
admsw5: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:53
        media: Ethernet autoselect (10baseT/UTP <full-duplex>)
        status: active
Starting devd.
Starting Network: admsw1.
admsw1: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:4f
        media: Ethernet autoselect (none)
        status: no carrier
Starting Network: admsw2.
admsw2: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:50
        media: Ethernet autoselect (10baseT/UTP)
        status: active
Starting Network: admsw3.
admsw3: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:51
        media: Ethernet autoselect (none)
        status: no carrier
Starting Network: admsw4.
admsw4: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:52
        media: Ethernet autoselect (none)
        status: no carrier
Starting Network: admsw5.
admsw5: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
        ether 00:0c:42:07:b2:53
        media: Ethernet autoselect (10baseT/UTP <full-duplex>)
        status: active
devd: cannot open pid file: Operation not supported
Mounting NFS file systems:.
Creating and/or trimming log files.
Starting syslogd.
syslogd: cannot open pid file: Operation not supported
/etc/rc: WARNING: Dump device does not exist.  Savecore not run.
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
Clearing /tmp (X related).
Updating motd:.
Jan  1 00:02:28  sm-mta[1535]: NOQUEUE: SYSERR(root): cannot =
flock(/var/run/sendmail.pid, fd=3D5, type=3D6, omode=3D40001, euid=3D0): =
Operation not supported
Starting cron.
cron: can't open or create /var/run/cron.pid: Operation not supported
/etc/rc: WARNING: failed to start cron
Jan  1 00:02:29  sm-msp-queue[1539]: A0102SMC001537: SYSERR(root): =
cannot flock(/var/spool/clientmqueue/sm-client.pid, fd=3D4, type=3D6, =
omode=3D40001, euid=3D25): Operation not supported
Jan  1 00:02:32  kernel: pid 1535 (sendmail), uid 0, was killed: out of =
swap space
Starting background file system checks in 60 seconds.

Thu Jan  1 00:02:38 UTC 1970

FreeBSD/mips (Amnesiac) (ttyu0)

login: root
Jan  1 00:09:39  login: ROOT LOGIN (root) ON ttyu0
FreeBSD 9.0-CURRENT (ADM5120.nfs) #72 r221418M: Sun May 15 20:21:23 CDT =
2011

Welcome to FreeBSD!

Before seeking technical support, please use the following resources:

o  Security advisories and updated errata information for all releases =
are
   at http://www.FreeBSD.org/releases/ - always consult the ERRATA =
section
   for your release first as it's updated frequently.

o  The Handbook and FAQ documents are at http://www.FreeBSD.org/ and,
   along with the mailing lists, can be searched by going to
   http://www.FreeBSD.org/search/.  If the doc distribution has
   been installed, they're also available formatted in /usr/share/doc.

If you still have a question or problem, please take the output of
`uname -a', along with any relevant error messages, and email it
as a question to the questions@FreeBSD.org mailing list.  If you are
unfamiliar with FreeBSD's directory layout, please refer to the hier(7)
manual page.  If you are not familiar with manual pages, type `man man'.

Edit /etc/motd to change this login announcement.

# ls
.cshrc          .login          .profile
# ls /dev
console         devctl          kmem            pci             =
ttyu0.init
ctty            fd              log             stderr          =
ttyu0.lock
cuau0           fido            mem             stdin           zero
cuau0.init      geom.ctl        nfslock         stdout
cuau0.lock      klog            null            ttyu0
# =20


--Apple-Mail-23-786803332
Content-Disposition: attachment;
	filename=admsw-hack.diff
Content-Type: application/octet-stream;
	name="admsw-hack.diff"
Content-Transfer-Encoding: 7bit

Index: if_admsw.c
===================================================================
--- if_admsw.c	(revision 221418)
+++ if_admsw.c	(working copy)
@@ -89,6 +89,7 @@
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
+#include <sys/taskqueue.h>
 #include <machine/bus.h>
 
 #include <net/ethernet.h>
@@ -113,12 +114,31 @@
 #include <mips/adm5120/if_admswreg.h>
 #include <mips/adm5120/if_admswvar.h>
 
-/* TODO: add locking */
-#define ADMSW_LOCK(sc) do {} while(0);
-#define ADMSW_UNLOCK(sc) do {} while(0);
+typedef enum {
+        ADMSW_DBG_MII    =       0x00000001,
+        ADMSW_DBG_INTR   =       0x00000002,
+        ADMSW_DBG_TX     =       0x00000004,
+        ADMSW_DBG_RX     =       0x00000008,
+        ADMSW_DBG_ERR    =       0x00000010,
+        ADMSW_DBG_RESET  =       0x00000020,
+} arge_debug_flags;
+ 
+#ifdef ADMSW_DEBUG
+#define ADMSWDEBUG(_sc, _m, ...)                                        \
+        do {                                                            \
+                if ((_m) & (_sc)->sc_debug)				\
+                        device_printf((_sc)->sc_dev, __VA_ARGS__);	\
+        } while (0)
+#else
+#define ADMSWDEBUG(_sc, _m, ...)
+#endif
 
+#define ADMSW_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
+#define ADMSW_UNLOCK(_sc)	mtx_unlock(&(_sc)->sc_mtx)
+#define ADMSW_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
+
 static uint8_t vlan_matrix[SW_DEVS] = {
-	(1 << 6) | (1 << 0),		/* CPU + port0 */
+	(1 << 6) |     0x3f,		/* CPU + all ports */
 	(1 << 6) | (1 << 1),		/* CPU + port1 */
 	(1 << 6) | (1 << 2),		/* CPU + port2 */
 	(1 << 6) | (1 << 3),		/* CPU + port3 */
@@ -128,6 +148,7 @@
 
 /* ifnet entry points */
 static void	admsw_start(struct ifnet *);
+static void	admsw_start_locked(struct ifnet *);
 static void	admsw_watchdog(void *);
 static int	admsw_ioctl(struct ifnet *, u_long, caddr_t);
 static void	admsw_init(void *);
@@ -145,7 +166,8 @@
 static int	admsw_mediachange(struct ifnet *);
 static void	admsw_mediastatus(struct ifnet *, struct ifmediareq *);
 
-static int	admsw_intr(void *);
+static int	admsw_intr_filter(void *);
+static void	admsw_int_task(void *, int pending);
 
 /* bus entry points */
 static int	admsw_probe(device_t dev);
@@ -386,6 +408,14 @@
 	device_printf(dev, "ADM5120 Switch Engine, %d ports\n", SW_DEVS);
 	sc->ndevs = 0;
 
+	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
+	    MTX_DEF);
+	TASK_INIT(&sc->sc_int_task, 0, admsw_int_task, sc);
+	sc->sc_tq = taskqueue_create_fast("admswtaskq", M_WAITOK,
+	    taskqueue_thread_enqueue, &sc->sc_tq);
+	taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq",
+	    device_get_nameunit(sc->sc_dev));
+
 	/* XXXMIPS: fix it */
 	enaddr[0] = 0x00;
 	enaddr[1] = 0x0C;
@@ -415,8 +445,9 @@
                 return (ENXIO);
         }
 
-	if ((error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 
-	    admsw_intr, NULL, sc, &sc->sc_ih)) != 0) {
+	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
+		admsw_intr_filter, NULL, sc, &sc->sc_ih);
+	if (error != 0) {
                 device_printf(dev, 
                     "WARNING: unable to register interrupt handler\n");
                 return (error);
@@ -559,8 +590,15 @@
 static int
 admsw_detach(device_t dev)
 {
+        struct admsw_softc *sc = (struct admsw_softc *) device_get_softc(dev);
 
+        KASSERT(mtx_initialized(&sc->sc_mtx),
+	    ("admsw mutex not initialized"));
+
 	printf("TODO: DETACH\n");
+
+        mtx_destroy(&sc->sc_mtx);
+
 	return (0);
 }
 
@@ -590,6 +628,23 @@
 static void
 admsw_start(struct ifnet *ifp)
 {
+        struct admsw_softc *sc;
+
+        sc = ifp->if_softc;
+
+        ADMSW_LOCK(sc);
+        admsw_start_locked(ifp);
+        ADMSW_UNLOCK(sc);
+}
+
+/*
+ * admsw_start_locked:
+ *
+ *	Start packet transmission on the interface.
+ */
+static void
+admsw_start_locked(struct ifnet *ifp)
+{
 	struct admsw_softc *sc = ifp->if_softc;
 	struct mbuf *m0, *m;
 	struct admsw_descsoft *ds;
@@ -599,6 +654,8 @@
 	int error, nexttx, len, i;
 	static int vlan = 0;
 
+	ADMSW_LOCK_ASSERT(sc);
+
 	/*
 	 * Loop through the send queues, setting up transmit descriptors
 	 * unitl we drain the queues, or use up all available transmit
@@ -614,9 +671,11 @@
 			if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) 
 			    == IFF_DRV_RUNNING) {
 				/* Grab a packet off the queue. */
-				IF_DEQUEUE(&ifp->if_snd, m0);
-				if (m0 != NULL)
-					break;
+				if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
+ 					IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
+					if (m0 != NULL)
+						break;
+				}
 			}
 			i++;
 			if (i == SW_DEVS)
@@ -717,7 +776,7 @@
 		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 		REG_WRITE(SEND_TRIG_REG, 1);
-		/* printf("send slot %d\n",nexttx); */
+		ADMSWDEBUG(sc, ADMSW_DBG_TX, "send slot %d\n", nexttx);
 
 		/*
 		 * Store a pointer to the packet so we can free it later.
@@ -779,9 +838,10 @@
 	ifp = sc->sc_ifnet[0];
 
 	/* Try to get more packets going. */
-	admsw_start(ifp);
+	/* admsw_start_locked(ifp); */
 }
 
+
 /*
  * admsw_ioctl:		[ifnet interface function]
  *
@@ -794,8 +854,6 @@
 	struct ifdrv *ifd;
 	int error, port;
 
-	ADMSW_LOCK(sc);
-
 	switch (cmd) {
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
@@ -825,7 +883,9 @@
 		} else {
 			error = copyin(ifd->ifd_data, vlan_matrix,
 			    sizeof(vlan_matrix));
+			ADMSW_LOCK(sc);
 			admsw_setvlan(sc, vlan_matrix);
+			ADMSW_UNLOCK(sc);
 		}
 		break;
 
@@ -843,43 +903,70 @@
 	}
 
 	/* Try to get more packets going. */
-	admsw_start(ifp);
+	/* admsw_start(ifp); */
 
-	ADMSW_UNLOCK(sc);
 	return (error);
 }
 
-
 /*
- * admsw_intr:
+ * admsw_intr_filter:
  *
- *	Interrupt service routine.
+ *	Interrupt filter routine.
  */
 static int
-admsw_intr(void *arg)
+admsw_intr_filter(void *arg)
 {
 	struct admsw_softc *sc = arg;
-	uint32_t pending;
+	uint32_t status;
 
-	pending = REG_READ(ADMSW_INT_ST);
-	REG_WRITE(ADMSW_INT_ST, pending);
+	status = REG_READ(ADMSW_INT_ST);
 
-	if (sc->ndevs == 0)
-		return (FILTER_STRAY);
+	ADMSWDEBUG(sc, ADMSW_DBG_INTR, "intr status = (%b)\n", status,
+		"\20\4RXLD\3RXHD\2SLD\1SHD");
 
-	if ((pending & ADMSW_INTR_RHD) != 0)
+	if (status & INT_MASK) {
+		REG_WRITE(ADMSW_INT_MASK, INT_MASK);
+		taskqueue_enqueue(sc->sc_tq, &sc->sc_int_task);
+		return(FILTER_HANDLED);
+	}
+
+	return (FILTER_STRAY);
+}
+
+/*
+ * admsw_int_task:
+ *
+ *	Interrupt task routine.
+ */
+static void
+admsw_int_task(void *arg, int pending)
+{
+	struct admsw_softc *sc = arg;
+	uint32_t status;
+
+	ADMSW_LOCK(sc);
+
+	status = REG_READ(ADMSW_INT_ST);
+	REG_WRITE(ADMSW_INT_ST, status);
+
+	if ((status & ADMSW_INTR_RHD) != 0)
 		admsw_rxintr(sc, 1);
 
-	if ((pending & ADMSW_INTR_RLD) != 0)
+	if ((status & ADMSW_INTR_RLD) != 0)
 		admsw_rxintr(sc, 0);
 
-	if ((pending & ADMSW_INTR_SHD) != 0)
+	if ((status & ADMSW_INTR_SHD) != 0)
 		admsw_txintr(sc, 1);
 
-	if ((pending & ADMSW_INTR_SLD) != 0)
+	if ((status & ADMSW_INTR_SLD) != 0)
 		admsw_txintr(sc, 0);
 
-	return (FILTER_HANDLED);
+	REG_WRITE(ADMSW_INT_MASK, REG_READ(ADMSW_INT_MASK) & 
+	    ~(ADMSW_INTR_SHD | ADMSW_INTR_SLD | 
+		ADMSW_INTR_RHD | ADMSW_INTR_RLD | 
+		ADMSW_INTR_HDF | ADMSW_INTR_LDF));
+
+	ADMSW_UNLOCK(sc);
 }
 
 /*
@@ -896,7 +983,10 @@
 	int i, vlan;
 	int gotone = 0;
 
-	/* printf("txintr: txdirty: %d, txfree: %d\n",sc->sc_txdirty, sc->sc_txfree); */
+	ADMSW_LOCK_ASSERT(sc);
+
+	ADMSWDEBUG(sc, ADMSW_DBG_TX, "txdirty: %d, txfree: %d\n",
+	    sc->sc_txdirty, sc->sc_txfree);
 	for (i = sc->sc_txdirty; sc->sc_txfree != ADMSW_NTXLDESC;
 	    i = ADMSW_NEXTTXL(i)) {
 
@@ -922,7 +1012,7 @@
 			panic("admsw_txintr: bad vlan\n");
 		ifp = sc->sc_ifnet[vlan];
 		gotone = 1;
-		/* printf("clear tx slot %d\n",i); */
+		ADMSWDEBUG(sc, ADMSW_DBG_TX, "clear tx slot %d\n",i);
 
 		ifp->if_opackets++;
 
@@ -937,7 +1027,7 @@
 		ifp = sc->sc_ifnet[0];
 
 		/* Try to queue more packets. */
-		admsw_start(ifp);
+		admsw_start_locked(ifp);
 
 		/*
 		 * If there are no more pending transmissions,
@@ -948,7 +1038,8 @@
 
 	}
 
-	/* printf("txintr end: txdirty: %d, txfree: %d\n",sc->sc_txdirty, sc->sc_txfree); */
+	ADMSWDEBUG(sc, ADMSW_DBG_TX, "end: txdirty: %d, txfree: %d\n",
+	    sc->sc_txdirty, sc->sc_txfree);
 }
 
 /*
@@ -965,7 +1056,7 @@
 	uint32_t stat;
 	int i, len, port, vlan;
 
-	/* printf("rxintr\n"); */
+	ADMSW_LOCK_ASSERT(sc);
 
 	if (high)
 		panic("admsw_rxintr: high priority packet\n");
@@ -1025,7 +1116,7 @@
 			break;
 		}
 
-		/* printf("process slot %d\n",i); */
+		ADMSWDEBUG(sc, ADMSW_DBG_RX, "process slot %d\n",i);
 
 		bus_dmamap_sync(sc->sc_bufs_dmat, ds->ds_dmamap,
 		    BUS_DMASYNC_POSTREAD);
@@ -1064,7 +1155,9 @@
 		BPF_MTAP(ifp, m);
 
 		/* Pass it on. */
+		ADMSW_UNLOCK(sc);
 		(*ifp->if_input)(ifp, m);
+		ADMSW_LOCK(sc);
 		ifp->if_ipackets++;
 	}
 

--Apple-Mail-23-786803332
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii




On May 12, 2011, at 10:47 PM, Oleksandr Tymoshenko wrote:

> This one looks like problem in IRQ handling - corrupted function =
pointer or=20
> something :( I need to review all code to refresh it in my memory. It =
was=20
> first MIPS platfrom I've been working on and I guess there are a lot =
of bugs.=20
>=20
>=20
> On 2011-05-12, at 8:06 PM, Erik Moe wrote:
>=20
>> I've been doing a little hacking of my own, trying to understand the =
issue.  I'm pretty sure what I'm doing is wrong, but I've actually =
gotten to the point where the kernel mounts the NFS root filesystem =
before i panics.=20
>>=20
>> --- if_admsw.c.orig	2011-05-12 13:16:43.000000000 -0500
>> +++ if_admsw.c	2011-05-12 13:18:04.000000000 -0500
>> @@ -118,7 +118,7 @@
>> #define ADMSW_UNLOCK(sc) do {} while(0);
>>=20
>> static uint8_t vlan_matrix[SW_DEVS] =3D {
>> -	(1 << 6) | (1 << 0),		/* CPU + port0 */
>> +	(1 << 6) |     0x3f,		/* CPU + all ports */
>> 	(1 << 6) | (1 << 1),		/* CPU + port1 */
>> 	(1 << 6) | (1 << 2),		/* CPU + port2 */
>> 	(1 << 6) | (1 << 3),		/* CPU + port3 */
>> @@ -779,7 +779,7 @@
>> 	ifp =3D sc->sc_ifnet[0];
>>=20
>> 	/* Try to get more packets going. */
>> -	admsw_start(ifp);
>> +	/* admsw_start(ifp); */
>> }
>>=20
>> /*
>> @@ -843,7 +843,7 @@
>> 	}
>>=20
>> 	/* Try to get more packets going. */
>> -	admsw_start(ifp);
>> +	/* admsw_start(ifp); */
>>=20
>> 	ADMSW_UNLOCK(sc);
>> 	return (error);
>> @@ -937,7 +937,7 @@
>> 		ifp =3D sc->sc_ifnet[0];
>>=20
>> 		/* Try to queue more packets. */
>> -		admsw_start(ifp);
>> +		/* admsw_start(ifp); */
>>=20
>> 		/*
>> 		 * If there are no more pending transmissions,
>>=20
>> RouterBOOT booter 2.18
>>=20
>> RouterBoard 133C3
>>=20
>> CPU frequency: 175 MHz
>> Memory size:  16 MB
>>=20
>> Press any key within 6 seconds to enter setup......
>> trying dhcp protocol... OK
>> resolved mac address 00:0C:29:29:27:66
>> Gateway: 192.168.11.1
>> transfer started ........................... transfer ok, time=3D5.52s
>> setting up elf image... OK
>> jumping to kernel code
>> entry: mips_init()
>> Cache info:
>> picache_stride    =3D 4096
>> picache_loopcount =3D 2
>> pdcache_stride    =3D 4096
>> pdcache_loopcount =3D 2
>> cpu0: MIPS Technologies processor v11.128
>> MMU: Standard TLB, 16 entries
>> L1 i-cache: 2 ways of 256 sets, 16 bytes per line
>> L1 d-cache: 2 ways of 256 sets, 16 bytes per line
>> Config1=3D0x1e994c8a<WatchRegs,EJTAG>
>> Physical memory chunk(s):
>> 0x2d6000 - 0xffffff, 13803520 bytes (3370 pages)
>> Maxmem is 0x1000000
>> GDB: debug ports: uart
>> GDB: current port: uart
>> KDB: debugger backends: ddb gdb
>> KDB: current backend: ddb
>> Copyright (c) 1992-2011 The FreeBSD Project.
>> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, =
1994
>>       The Regents of the University of California. All rights =
reserved.
>> FreeBSD is a registered trademark of The FreeBSD Foundation.
>> FreeBSD 9.0-CURRENT #40 r221418M: Thu May 12 13:20:24 CDT 2011
>>   =
emoe@freebsd.localdomain:/usr/home/emoe/obj/mips/mips.mipsel/usr/home/emoe=
/svn/mips/sys/ADM5120.nfs mips
>> real memory  =3D 16777216 (16384K bytes)
>> Physical memory chunk(s):
>> 0x00362000 - 0x00f8efff, 12767232 bytes (3117 pages)
>> avail memory =3D 12513280 (11MB)
>> mem: <memory>
>> null: <null device, zero device>
>> nfslock: pseudo-device
>> nexus0: <MIPS32 root nexus>
>> clock0: <Generic MIPS32 ticker> on nexus0
>> Timecounter "MIPS32" frequency 175000000 Hz quality 800
>> Event timer "MIPS32" frequency 175000000 Hz quality 800
>> obio0 at mem 0-0x1ffffffe on nexus0
>> admsw0: <ADM5120 Switch Engine> on obio0
>> admsw0: ADM5120 Switch Engine, 6 ports
>> admsw0: base Ethernet address 00:0c:42:07:b2:4e
>> admsw0: Ethernet address: 00:0c:42:07:b2:4e
>> admsw1: Ethernet address: 00:0c:42:07:b2:4f
>> admsw2: Ethernet address: 00:0c:42:07:b2:50
>> admsw3: Ethernet address: 00:0c:42:07:b2:51
>> admsw4: Ethernet address: 00:0c:42:07:b2:52
>> admsw5: Ethernet address: 00:0c:42:07:b2:53
>> uart0: <adm5120_uart, channel A> on obio0
>> uart0: fast interrupt
>> uart0: console (115200,n,8,1)
>> Device configuration finished.
>> Timecounters tick every 10.000 msec
>> bootpc_init: wired to interface 'admsw0'
>> Sending DHCP Discover packet from interface admsw0 =
(00:0c:42:07:b2:4e)
>> Received DHCP Offer packet on admsw0 from 192.168.11.2 (accepted) (no =
root path)
>> Sending DHCP Request packet from interface admsw0 (00:0c:42:07:b2:4e)
>> Received DHCP Ack packet on admsw0 from 192.168.11.2 (accepted) (got =
root path)
>> admsw0 at 192.168.11.15 server 192.168.11.2 boot file =
boot/kernel/kernel
>> subnet mask 255.255.255.0 router 192.168.11.1 rootfs =
192.168.11.2:/usr/home/emoe/nfsroot=20
>> Adjusted interface admsw0
>> Trying to mount root from nfs: []...
>> NFS ROOT: 192.168.11.2:/usr/home/emoe/nfsroot
>> warning: no time-of-day clock registered, system time will not be set =
accurately
>> warning: no time-of-day clock registered, system time will not be set =
accurately
>> start_init: trying /sbin/init
>> Setting hostuuid: 1c57c506-1dd2-11b2-9a4c-000c4207b24e.
>> Setting hostid: 0xcb6fff12.
>> No suitable dump device was found.
>> Entropy harvesting:.
>> Starting file system checks:
>> mount_nfs: can't update /var/db/mounttab for =
192.168.11.2:/home/emoe/nfsroot
>> Mounting local file systems:.
>> /etc/rc: WARNING: $hostname is not set -- see rc.conf(5).
>> Starting Network: lo0 admsw0 admsw1 admsw2 admsw3 admsw4 admsw5.
>> lo0: flags=3D8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
>>       options=3D3<RXCSUM,TXCSUM>
>>       inet 127.0.0.1 netmask 0xff000000=20
>> admsw0: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:4e
>>       inet 192.168.11.15 netmask 0xffffff00 broadcast 192.168.11.255
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> admsw1: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:4f
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> admsw2: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:50
>>       media: Ethernet autoselect (10baseT/UTP)
>>       status: active
>> admsw3: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:51
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> admsw4: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:52
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> admsw5: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:53
>>       media: Ethernet autoselect (10baseT/UTP <full-duplex>)
>>       status: active
>> Starting devd.
>> Starting Network: admsw1.
>> admsw1: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:4f
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> Starting Network: admsw2.
>> admsw2: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:50
>>       media: Ethernet autoselect (10baseT/UTP)
>>       status: active
>> Starting Network: admsw3.
>> admsw3: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:51
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> Starting Network: admsw4.
>> admsw4: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:52
>>       media: Ethernet autoselect (none)
>>       status: no carrier
>> Starting Network: admsw5.
>> admsw5: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
>>       ether 00:0c:42:07:b2:53
>>       media: Ethernet autoselect (10baseT/UTP <full-duplex>)
>>       status: active
>> devd: cannot open pid file: Operation not supported
>> panic: _mtx_lock_sleep: recursed on non-recursive mutex mbuf @ =
/usr/home/emoe/svn/mips/sys/vm/uma_core.c:2010
>>=20
>> KDB: enter: panic
>> [ thread pid 1053 tid 100029 ]
>> Stopped at      kdb_enter+0x4c: lui     at,0x802c
>> db> bt
>> Tracing pid 1053 tid 100029 td 0x8047e600
>> db_trace_thread+30 (?,?,?,?) ra 800030b0 sp c03e0ee0 sz 24
>> 80002f9c+114 (0,?,ffffffff,?) ra 8000266c sp c03e0ef8 sz 32
>> 800022e4+388 (?,?,?,?) ra 800027f0 sp c03e0f18 sz 168
>> db_command_loop+70 (?,?,?,?) ra 80004e34 sp c03e0fc0 sz 24
>> 80004d40+f4 (?,?,?,?) ra 80100a6c sp c03e0fd8 sz 424
>> kdb_trap+104 (?,?,?,?) ra 801fec20 sp c03e1180 sz 40
>> trap+b98 (?,?,?,?) ra 801f6c70 sp c03e11a8 sz 168
>> MipsKernGenException+134 (0,a,802e5fe4,109) ra 80100cf8 sp c03e1250 =
sz 200
>> kdb_enter+4c (?,?,?,?) ra 800c9c74 sp c03e1318 sz 24
>> panic+f4 (?,8023f064,8024dea0,7da) ra 800ba01c sp c03e1330 sz 40
>> _mtx_lock_sleep+68 (?,?,?,?) ra 800ba260 sp c03e1358 sz 32
>> _mtx_lock_flags+104 (?,?,?,?) ra 801d2fd0 sp c03e1378 sz 32
>> uma_zalloc_arg+104 (80ffa470,c03e1408,1,?) ra 80214c14 sp c03e1398 sz =
80
>> 80214b98+7c (?,?,?,?) ra 8021510c sp c03e13e8 sz 64
>> 80214e94+278 (?,?,?,?) ra 80215328 sp c03e1428 sz 56
>> 8021527c+ac (?,?,?,?) ra 800a24fc sp c03e1460 sz 40
>> intr_event_handle+98 (?,?,?,?) ra 802162e0 sp c03e1488 sz 48
>> 8021627c+64 (?,?,?,?) ra 800a24fc sp c03e14b8 sz 32
>> intr_event_handle+98 (?,?,?,?) ra 802180f4 sp c03e14d8 sz 48
>> cpu_intr+184 (c03e1558,?,?,?) ra 801f714c sp c03e1508 sz 56
>> MipsKernIntr+134 (80ffa460,0,80451000,9f5) ra 801d3c38 sp c03e1540 sz =
200
>> uma_dbg_free+1c (?,?,?,?) ra 801d2a78 sp c03e1608 sz 48
>> uma_zfree_arg+98 (?,?,?,?) ra 8012f428 sp c03e1638 sz 64
>> sbcompress+270 (?,?,?,?) ra 8012f750 sp c03e1678 sz 40
>> sbappendstream_locked+70 (?,?,?,?) ra 8012f7b0 sp c03e16a0 sz 32
>> sbappendstream+44 (?,?,?,?) ra 801b3f94 sp c03e16c0 sz 32
>> 801b3e58+13c (?,?,?,?) ra 80134348 sp c03e16e0 sz 56
>> sosend_generic+4a8 (?,0,?,?) ra 8013048c sp c03e1718 sz 104
>> sosend+34 (?,?,?,?) ra 801bf5cc sp c03e1780 sz 40
>> 801bf134+498 (?,?,6,80452300) ra 801be568 sp c03e17a8 sz 192
>> 801bdfb0+5b8 (805840e0,?,6,80452300) ra 800266d8 sp c03e1868 sz 104
>> newnfs_request+d94 (?,?,0,?) ra 8006060c sp c03e18d0 sz 184
>> nfscl_request+80 (?,?,?,?) ra 80049ba4 sp c03e1988 sz 56
>> nfsrpc_read+4fc (?,?,?,8047e600) ra 80059224 sp c03e19c0 sz 288
>> ncl_readrpc+38 (80484d20,?,?,?) ra 8006518c sp c03e1ae0 sz 232
>> ncl_getpages+310 (?,?,?,?) ra 80219b84 sp c03e1bc8 sz 112
>> VOP_GETPAGES_APV+d4 (?,?,?,?) ra 801f12c8 sp c03e1c38 sz 24
>> 801f1204+c4 (?,?,?,?) ra 801d622c sp c03e1c50 sz 80
>> vm_fault_hold+fb8 (8042a1e0,4059b000,1,0) ra 801d7220 sp c03e1ca0 sz =
280
>> vm_fault+14 (?,?,?,?) ra 801fe5a4 sp c03e1db8 sz 32
>> trap+51c (?,?,?,?) ra 801f6e6c sp c03e1dd8 sz 168
>> MipsUserGenException+10c (?,?,?,4059b670) ra 0 sp c03e1e80 sz 0
>> pid 1053
>> db>=20
>>=20
>>=20
>>=20
>>=20
>=20


--Apple-Mail-23-786803332--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?22FC61A7-D139-42EB-A04A-CD7DD8FA68B7>