svn commit: r207109 - user/jmallett/octeon/sys/mips/cavium/octe

Juli Mallett jmallett at FreeBSD.org
Fri Apr 23 10:10:27 UTC 2010


Author: jmallett
Date: Fri Apr 23 10:10:26 2010
New Revision: 207109
URL: http://svn.freebsd.org/changeset/base/207109

Log:
  Connect up the receive interrupt.

Added:
  user/jmallett/octeon/sys/mips/cavium/octe/octebusvar.h
Modified:
  user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c
  user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.h
  user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c
  user/jmallett/octeon/sys/mips/cavium/octe/octebus.c
  user/jmallett/octeon/sys/mips/cavium/octe/wrapper-cvmx-includes.h

Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c	Fri Apr 23 09:44:30 2010	(r207108)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c	Fri Apr 23 10:10:26 2010	(r207109)
@@ -35,6 +35,7 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/smp.h>
+#include <sys/taskqueue.h>
 
 #include <net/ethernet.h>
 #include <net/if.h>
@@ -44,18 +45,9 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 
 extern int pow_receive_group;
 extern struct ifnet *cvm_oct_device[];
-#if 0
-struct cvm_tasklet_wrapper
-{
-	struct tasklet_struct t;
-};// ____cacheline_aligned_in_smp;
 
-/* Aligning the tasklet_struct on cachline boundries seems to decrease
- * throughput even though in theory it would reduce contantion on the
- * cache lines containing the locks. */
-
-static struct cvm_tasklet_wrapper cvm_oct_tasklet[MAXCPU]; // __cacheline_aligned_in_smp;
-#endif
+static struct task cvm_oct_task;
+static struct taskqueue *cvm_oct_taskq;
 
 /**
  * Interrupt handler. The interrupt occurs whenever the POW
@@ -66,20 +58,15 @@ static struct cvm_tasklet_wrapper cvm_oc
  * @param regs
  * @return
  */
-int cvm_oct_do_interrupt(int cpl, void *dev_id)
+int cvm_oct_do_interrupt(void *dev_id)
 {
-#if 0
 	/* Acknowledge the interrupt */
 	if (INTERRUPT_LIMIT)
 		cvmx_write_csr(CVMX_POW_WQ_INT, 1<<pow_receive_group);
 	else
 		cvmx_write_csr(CVMX_POW_WQ_INT, 0x10001<<pow_receive_group);
-	preempt_disable();
-	tasklet_schedule(&cvm_oct_tasklet[smp_processor_id()].t);
-	preempt_enable();
-	return IRQ_HANDLED;
-#endif
-	panic("%s: not yet implemented.", __func__);
+	taskqueue_enqueue(cvm_oct_taskq, &cvm_oct_task);
+	return FILTER_HANDLED;
 }
 
 
@@ -94,9 +81,7 @@ int cvm_oct_do_interrupt(int cpl, void *
  */
 void cvm_oct_poll_controller(struct ifnet *ifp)
 {
-	preempt_disable();
-	tasklet_schedule(&cvm_oct_tasklet[smp_processor_id()].t);
-	preempt_enable();
+	taskqueue_enqueue(cvm_oct_taskq, &cvm_oct_task);
 }
 #endif
 
@@ -177,7 +162,7 @@ static inline int cvm_oct_check_rcv_erro
  *
  * @param unused
  */
-void cvm_oct_tasklet_rx(unsigned long unused)
+void cvm_oct_tasklet_rx(void *context, int pending)
 {
 	const int           coreid = cvmx_get_core_num();
 	uint64_t            old_group_mask;
@@ -440,21 +425,17 @@ void cvm_oct_tasklet_rx(unsigned long un
 
 void cvm_oct_rx_initialize(void)
 {
-#if 0
-	int i;
-	/* Initialize all of the tasklets */
-	for (i = 0; i < min(mp_ncpus, MAXCPU); i++)
-		tasklet_init(&cvm_oct_tasklet[i].t, cvm_oct_tasklet_rx, 0);
-#endif
+	TASK_INIT(&cvm_oct_task, 0, cvm_oct_tasklet_rx, NULL);
+
+	cvm_oct_taskq = taskqueue_create_fast("oct_rx", M_NOWAIT,
+					      taskqueue_thread_enqueue,
+					      &cvm_oct_taskq);
+	taskqueue_start_threads(&cvm_oct_taskq, min(mp_ncpus, MAXCPU),
+				PI_NET, "octe taskq");
 }
 
 void cvm_oct_rx_shutdown(void)
 {
-#if 0
-	int i;
-	/* Shutdown all of the tasklets */
-	for (i = 0; i < min(mp_ncpus, MAXCPU); i++)
-		tasklet_kill(&cvm_oct_tasklet[i].t);
-#endif
+	panic("%s: not yet implemented.", __func__);
 }
 

Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.h
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.h	Fri Apr 23 09:44:30 2010	(r207108)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.h	Fri Apr 23 10:10:26 2010	(r207109)
@@ -27,9 +27,9 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 
 *************************************************************************/
 
-int cvm_oct_do_interrupt(int cpl, void *dev_id);
+int cvm_oct_do_interrupt(void *dev_id);
 void cvm_oct_poll_controller(struct ifnet *ifp);
-void cvm_oct_tasklet_rx(unsigned long unused);
+void cvm_oct_tasklet_rx(void *context, int pending);
 
 void cvm_oct_rx_initialize(void);
 void cvm_oct_rx_shutdown(void);

Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c	Fri Apr 23 09:44:30 2010	(r207108)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c	Fri Apr 23 10:10:26 2010	(r207109)
@@ -32,6 +32,7 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include <sys/conf.h>
 #include <sys/endian.h>
 #include <sys/kernel.h>
+#include <sys/rman.h>
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/module.h>
@@ -44,6 +45,8 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include "wrapper-cvmx-includes.h"
 #include "ethernet-headers.h"
 
+#include "octebusvar.h"
+
 /*
  * XXX/juli
  * Convert 0444 to tunables, 0644 to sysctls.
@@ -204,11 +207,14 @@ static void cvm_do_timer(unsigned long a
 /**
  * Configure common hardware for all interfaces
  */
-static void cvm_oct_configure_common_hw(void)
+static void cvm_oct_configure_common_hw(device_t bus)
 {
-#if 0
-	int r;
-#endif
+	struct octebus_softc *sc;
+	int error;
+	int rid;
+
+        sc = device_get_softc(bus);
+
 	/* Setup the FPA */
 	cvmx_fpa_enable();
 	cvm_oct_mem_fill_fpa(CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE, num_packet_buffers);
@@ -223,10 +229,25 @@ static void cvm_oct_configure_common_hw(
 	if (!octeon_is_simulation())
 		cvmx_write_csr(CVMX_SMI_EN, 1);
 
-#if 0
 	/* Register an IRQ hander for to receive POW interrupts */
-	r = request_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group, cvm_oct_do_interrupt, IRQF_SHARED, "Ethernet", cvm_oct_device);
-#endif
+        rid = 0;
+        sc->sc_rx_irq = bus_alloc_resource(bus, SYS_RES_IRQ, &rid,
+					   CVMX_IRQ_WORKQ0 + pow_receive_group,
+					   CVMX_IRQ_WORKQ0 + pow_receive_group,
+					   1, RF_ACTIVE);
+        if (sc->sc_rx_irq == NULL) {
+                device_printf(bus, "could not allocate workq irq");
+		return;
+        }
+
+        error = bus_setup_intr(bus, sc->sc_rx_irq, INTR_TYPE_NET,
+			       cvm_oct_do_interrupt, NULL, cvm_oct_device,
+			       NULL);
+        if (error != 0) {
+                device_printf(bus, "could not setup workq irq");
+		return;
+        }
+
 
 #ifdef SMP
 	if (USE_MULTICORE_RECEIVE) {
@@ -330,7 +351,7 @@ int cvm_oct_init_module(device_t bus)
 	cvm_oct_proc_initialize();
 #endif
 	cvm_oct_rx_initialize();
-	cvm_oct_configure_common_hw();
+	cvm_oct_configure_common_hw(bus);
 
 	cvmx_helper_initialize_packet_io_global();
 

Modified: user/jmallett/octeon/sys/mips/cavium/octe/octebus.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/octebus.c	Fri Apr 23 09:44:30 2010	(r207108)
+++ user/jmallett/octeon/sys/mips/cavium/octe/octebus.c	Fri Apr 23 10:10:26 2010	(r207109)
@@ -46,6 +46,8 @@
 
 #include "ethernet-common.h"
 
+#include "octebusvar.h"
+
 static void		octebus_identify(driver_t *drv, device_t parent);
 static int		octebus_probe(device_t dev);
 static int		octebus_attach(device_t dev);
@@ -69,7 +71,7 @@ static device_method_t octebus_methods[]
 static driver_t octebus_driver = {
 	"octebus",
 	octebus_methods,
-	1,
+	sizeof (struct octebus_softc),
 };
 
 static devclass_t octebus_devclass;

Added: user/jmallett/octeon/sys/mips/cavium/octe/octebusvar.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/jmallett/octeon/sys/mips/cavium/octe/octebusvar.h	Fri Apr 23 10:10:26 2010	(r207109)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Juli Mallett <jmallett at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_CAVIUM_OCTE_OCTEBUSVAR_H_
+#define	_CAVIUM_OCTE_OCTEBUSVAR_H_
+
+struct octebus_softc {
+	struct resource *sc_rx_irq;
+};
+
+#endif /* !_CAVIUM_OCTE_OCTEBUSVAR_H_ */

Modified: user/jmallett/octeon/sys/mips/cavium/octe/wrapper-cvmx-includes.h
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/wrapper-cvmx-includes.h	Fri Apr 23 09:44:30 2010	(r207108)
+++ user/jmallett/octeon/sys/mips/cavium/octe/wrapper-cvmx-includes.h	Fri Apr 23 10:10:26 2010	(r207109)
@@ -43,5 +43,6 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include <contrib/octeon-sdk/cvmx-app-init.h>
 #include <contrib/octeon-sdk/cvmx-helper.h>
 #include <contrib/octeon-sdk/cvmx-helper-board.h>
+#include <contrib/octeon-sdk/cvmx-interrupt.h>
 
 #endif


More information about the svn-src-user mailing list