From owner-svn-src-user@FreeBSD.ORG  Fri Apr 23 00:11:39 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9A75B106566C;
	Fri, 23 Apr 2010 00:11:38 +0000 (UTC)
	(envelope-from jmallett@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7EC908FC0A;
	Fri, 23 Apr 2010 00:11:38 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3N0Bch2033693;
	Fri, 23 Apr 2010 00:11:38 GMT
	(envelope-from jmallett@svn.freebsd.org)
Received: (from jmallett@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3N0Bcac033690;
	Fri, 23 Apr 2010 00:11:38 GMT
	(envelope-from jmallett@svn.freebsd.org)
Message-Id: <201004230011.o3N0Bcac033690@svn.freebsd.org>
From: Juli Mallett <jmallett@FreeBSD.org>
Date: Fri, 23 Apr 2010 00:11:38 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r207084 - user/jmallett/octeon/sys/mips/cavium/octe
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 23 Apr 2010 00:11:39 -0000

Author: jmallett
Date: Fri Apr 23 00:11:38 2010
New Revision: 207084
URL: http://svn.freebsd.org/changeset/base/207084

Log:
  Fix some SMP stuff.

Modified:
  user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c
  user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c

Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c	Thu Apr 22 23:58:07 2010	(r207083)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-rx.c	Fri Apr 23 00:11:38 2010	(r207084)
@@ -34,6 +34,7 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include <sys/kernel.h>
 #include <sys/mbuf.h>
 #include <sys/socket.h>
+#include <sys/smp.h>
 
 #include <net/ethernet.h>
 #include <net/if.h>
@@ -53,7 +54,7 @@ struct cvm_tasklet_wrapper
  * throughput even though in theory it would reduce contantion on the
  * cache lines containing the locks. */
 
-static struct cvm_tasklet_wrapper cvm_oct_tasklet[NR_CPUS]; // __cacheline_aligned_in_smp;
+static struct cvm_tasklet_wrapper cvm_oct_tasklet[MAXCPU]; // __cacheline_aligned_in_smp;
 #endif
 
 /**
@@ -442,7 +443,7 @@ void cvm_oct_rx_initialize(void)
 #if 0
 	int i;
 	/* Initialize all of the tasklets */
-	for (i = 0; i < NR_CPUS; i++)
+	for (i = 0; i < min(mp_ncpus, MAXCPU); i++)
 		tasklet_init(&cvm_oct_tasklet[i].t, cvm_oct_tasklet_rx, 0);
 #endif
 }
@@ -452,7 +453,7 @@ void cvm_oct_rx_shutdown(void)
 #if 0
 	int i;
 	/* Shutdown all of the tasklets */
-	for (i = 0; i < NR_CPUS; i++)
+	for (i = 0; i < min(mp_ncpus, MAXCPU); i++)
 		tasklet_kill(&cvm_oct_tasklet[i].t);
 #endif
 }

Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c	Thu Apr 22 23:58:07 2010	(r207083)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c	Fri Apr 23 00:11:38 2010	(r207084)
@@ -35,6 +35,7 @@ AND WITH ALL FAULTS AND CAVIUM  NETWORKS
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/module.h>
+#include <sys/smp.h>
 
 #include <net/ethernet.h>
 #include <net/if.h>
@@ -241,24 +242,20 @@ static void cvm_oct_configure_common_hw(
 
 #ifdef SMP
 	if (USE_MULTICORE_RECEIVE) {
-#if 0
-		preempt_disable();
+		critical_enter();
 		{
 			int cpu;
-			for (cpu = 0; cpu < NR_CPUS; cpu++) {
-				if (cpu_online(cpu) &&
-				   (cpu != smp_processor_id())) {
+			for (cpu = 0; cpu < mp_maxid; cpu++) {
+				if (!CPU_ABSENT(cpu) &&
+				   (cpu != PCPU_GET(cpuid))) {
 					cvmx_ciu_intx0_t en;
-					en.u64 = cvmx_read_csr(CVMX_CIU_INTX_EN0(cpu_logical_map(cpu)*2));
+					en.u64 = cvmx_read_csr(CVMX_CIU_INTX_EN0(cpu*2));
 					en.s.workq |= (1<<pow_receive_group);
-					cvmx_write_csr(CVMX_CIU_INTX_EN0(cpu_logical_map(cpu)*2), en.u64);
+					cvmx_write_csr(CVMX_CIU_INTX_EN0(cpu*2), en.u64);
 				}
 			}
 		}
-		preempt_enable();
-#else
-		panic("%s: need to implement CPU enumeration.", __func__);
-#endif
+		critical_exit();
 	}
 #endif
 }