From owner-svn-src-projects@FreeBSD.ORG Mon Aug 10 01:50:00 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 263A3106564A; Mon, 10 Aug 2009 01:50:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15F468FC26; Mon, 10 Aug 2009 01:49:59 +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 n7A1nxxB084186; Mon, 10 Aug 2009 01:49:59 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7A1nxau084184; Mon, 10 Aug 2009 01:49:59 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <200908100149.n7A1nxau084184@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Mon, 10 Aug 2009 01:49:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196089 - projects/mips/sys/mips/include X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2009 01:50:00 -0000 Author: gonzo Date: Mon Aug 10 01:49:59 2009 New Revision: 196089 URL: http://svn.freebsd.org/changeset/base/196089 Log: - Make i/d cache size field 32-bit to prevent overflow Submited by: Neelkanth Natu Modified: projects/mips/sys/mips/include/cpuinfo.h Modified: projects/mips/sys/mips/include/cpuinfo.h ============================================================================== --- projects/mips/sys/mips/include/cpuinfo.h Sun Aug 9 18:39:23 2009 (r196088) +++ projects/mips/sys/mips/include/cpuinfo.h Mon Aug 10 01:49:59 2009 (r196089) @@ -57,11 +57,11 @@ struct mips_cpuinfo { u_int16_t tlb_nentries; u_int8_t icache_virtual; struct { - u_int8_t ic_size; + u_int32_t ic_size; u_int8_t ic_linesize; u_int8_t ic_nways; u_int16_t ic_nsets; - u_int8_t dc_size; + u_int32_t dc_size; u_int8_t dc_linesize; u_int8_t dc_nways; u_int16_t dc_nsets; From owner-svn-src-projects@FreeBSD.ORG Tue Aug 11 20:39:11 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 523CD106564A; Tue, 11 Aug 2009 20:39:11 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 41D1C8FC3A; Tue, 11 Aug 2009 20:39:11 +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 n7BKdBhM041156; Tue, 11 Aug 2009 20:39:11 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7BKdBqo041155; Tue, 11 Aug 2009 20:39:11 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <200908112039.n7BKdBqo041155@svn.freebsd.org> From: Craig Rodrigues Date: Tue, 11 Aug 2009 20:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196098 - projects/jbuild/usr.bin/jbuild/port X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2009 20:39:11 -0000 Author: rodrigc Date: Tue Aug 11 20:39:10 2009 New Revision: 196098 URL: http://svn.freebsd.org/changeset/base/196098 Log: Fixes to do-install target. Submitted by: alfred Modified: projects/jbuild/usr.bin/jbuild/port/Makefile Modified: projects/jbuild/usr.bin/jbuild/port/Makefile ============================================================================== --- projects/jbuild/usr.bin/jbuild/port/Makefile Tue Aug 11 16:53:08 2009 (r196097) +++ projects/jbuild/usr.bin/jbuild/port/Makefile Tue Aug 11 20:39:10 2009 (r196098) @@ -26,11 +26,17 @@ do-extract: cp Makefile.port ${WRKSRC}/Makefile do-install: - ( cd ${WRKSRC}/filemon; ${MAKE} install KMODDIR=/boot/modules) - ( cd ${WRKSRC}/jbuild; ${MAKE} install BINDIR=${PREFIX}/bin ) - ( cd ${WRKSRC}/jdirdep; ${MAKE} install BINDIR=${PREFIX}/bin ) + mkdir -p ${KMODDIR} + mkdir -p ${PREFIX}/bin + ${MAKE} -C ${WRKSRC}/filemon install KMODDIR=${KMODDIR} \ + BINOWN=${BINOWN} BINGRP=${BINGRP} + ${MAKE} -C ${WRKSRC}/jbuild install BINDIR=${PREFIX}/bin \ + BINOWN=${BINOWN} BINGRP=${BINGRP} + ${MAKE} -C ${WRKSRC}/jdirdep install BINDIR=${PREFIX}/bin \ + BINOWN=${BINOWN} BINGRP=${BINGRP} cp ${WRKSRC}/jdirdep/jcommit ${PREFIX}/bin cp ${WRKSRC}/jdirdep/jgetsrc ${PREFIX}/bin + mkdir -p ${MANPREFIX}/man/man1 ${INSTALL_MAN} ${WRKSRC}/jbuild/jbuild.1 ${MANPREFIX}/man/man1 do-clean: From owner-svn-src-projects@FreeBSD.ORG Tue Aug 11 21:37:21 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71FB1106564A; Tue, 11 Aug 2009 21:37:21 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 616AD8FC43; Tue, 11 Aug 2009 21:37:21 +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 n7BLbLU0042598; Tue, 11 Aug 2009 21:37:21 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7BLbL9Q042596; Tue, 11 Aug 2009 21:37:21 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <200908112137.n7BLbL9Q042596@svn.freebsd.org> From: Craig Rodrigues Date: Tue, 11 Aug 2009 21:37:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196103 - projects/jbuild/usr.bin/jbuild X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2009 21:37:21 -0000 Author: rodrigc Date: Tue Aug 11 21:37:21 2009 New Revision: 196103 URL: http://svn.freebsd.org/changeset/base/196103 Log: Remove mkdep(1) reference. Document .ERROR target. Modified: projects/jbuild/usr.bin/jbuild/jbuild.1 Modified: projects/jbuild/usr.bin/jbuild/jbuild.1 ============================================================================== --- projects/jbuild/usr.bin/jbuild/jbuild.1 Tue Aug 11 21:28:26 2009 (r196102) +++ projects/jbuild/usr.bin/jbuild/jbuild.1 Tue Aug 11 21:37:21 2009 (r196103) @@ -91,10 +91,6 @@ will be read for the main list of depend A different Buildfile or list of them can be supplied via the .Fl f option(s). -Finally, if the file -.Pa .depend -can be found in any of the aforesaid locations, it will also be read (see -.Xr mkdep 1 ) . .Pp The options are as follows: .Bl -tag -width Ds @@ -1309,6 +1305,11 @@ to the target's own name. .It Ic .END Any command lines attached to this target are executed after everything else is done. +.It Ic .ERROR +If +.Nm +executes a target which returns a non-zero status indicating failure, +any command lines attached to this target are executed. .It Ic .IGNORE Mark each of the sources with the .Ic .IGNORE @@ -1703,7 +1704,6 @@ Most of the more esoteric features of should probably be avoided for greater compatibility. .Sh SEE ALSO .Xr make 1 , -.Xr mkdep 1 , .Xr make.conf 5 .Rs .%T "PMake - A Tutorial" From owner-svn-src-projects@FreeBSD.ORG Tue Aug 11 22:26:10 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0C27106564A; Tue, 11 Aug 2009 22:26:10 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9DE088FC57; Tue, 11 Aug 2009 22:26:10 +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 n7BMQAVO043711; Tue, 11 Aug 2009 22:26:10 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7BMQAPU043709; Tue, 11 Aug 2009 22:26:10 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908112226.n7BMQAPU043709@svn.freebsd.org> From: Lawrence Stewart Date: Tue, 11 Aug 2009 22:26:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196107 - projects/tcp_ffcaia2008_8.x/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2009 22:26:11 -0000 Author: lstewart Date: Tue Aug 11 22:26:10 2009 New Revision: 196107 URL: http://svn.freebsd.org/changeset/base/196107 Log: Tweak the accounting math in my previous commit so that it actually calculates the correct values. The sack_hole_bytes variable should now be ready to use to influence SACK recovery behaviour. Sponsored by: FreeBSD Foundation Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c Tue Aug 11 22:09:43 2009 (r196106) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c Tue Aug 11 22:26:10 2009 (r196107) @@ -352,7 +352,7 @@ tcp_sackhole_remove(struct tcpcb *tp, st #endif */ if (TAILQ_EMPTY(&tp->snd_holes) && tp->sack_hole_bytes != 0) { - printf("tp->sack_hole_bytes is %d instead of 0", tp->sack_hole_bytes); + printf("conn (%p) tp->sack_hole_bytes is %d instead of 0\n", tp, tp->sack_hole_bytes); tp->sack_hole_bytes = 0; } } @@ -524,7 +524,7 @@ tcp_sack_doack(struct tcpcb *tp, struct /* Data acks at least the end of hole. */ if (SEQ_GEQ(sblkp->end, cur->end)) { /* Shrink hole: slide end of hole backward. */ - tp->sack_hole_bytes -= sblkp->start - cur->end; + tp->sack_hole_bytes -= cur->end - sblkp->start; cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, cur->end); } else { @@ -552,8 +552,6 @@ tcp_sack_doack(struct tcpcb *tp, struct * sblkp->end-sblkp->start */ tp->sack_hole_bytes -= cur->end - - sblkp->end - - sblkp->end + sblkp->start; cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, From owner-svn-src-projects@FreeBSD.ORG Thu Aug 13 13:17:50 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C094A106564A; Thu, 13 Aug 2009 13:17:50 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ADE208FC4D; Thu, 13 Aug 2009 13:17:50 +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 n7DDHoLt001761; Thu, 13 Aug 2009 13:17:50 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DDHoNE001757; Thu, 13 Aug 2009 13:17:50 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908131317.n7DDHoNE001757@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 13 Aug 2009 13:17:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196180 - in projects/tcp_ffcaia2008_8.x/sys: kern modules modules/alq sys X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 13:17:51 -0000 Author: lstewart Date: Thu Aug 13 13:17:50 2009 New Revision: 196180 URL: http://svn.freebsd.org/changeset/base/196180 Log: Import variable length ALQ(9) work from my user branch/SIFTR development repository. This is a prerequisite for importing SIFTR into the tree. This patch allows the ALQ(9) framework to be compiled as a kernel module. It also extends the KPI to support logging variable length messages by replacing the underlying storage with a circular byte based buffer and adding new alq_writen/alq_getn functions. Some additional minor structural work is required to remove the patch's current use of malloc in alq_getn. Sponsored by: FreeBSD Foundation Discussed with: jeff@, rwatson@ (quite some time ago now) Added: projects/tcp_ffcaia2008_8.x/sys/modules/alq/ Modified: projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c projects/tcp_ffcaia2008_8.x/sys/modules/Makefile projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Modified: projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c Thu Aug 13 12:28:30 2009 (r196179) +++ projects/tcp_ffcaia2008_8.x/sys/kern/kern_alq.c Thu Aug 13 13:17:50 2009 (r196180) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2002, Jeffrey Roberson + * Copyright (c) 2008-2009, Lawrence Stewart * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_mac.h" + #include #include #include @@ -43,20 +46,23 @@ __FBSDID("$FreeBSD$"); #include #include +#if (__FreeBSD_version >= 700000) #include +#endif /* Async. Logging Queue */ struct alq { int aq_entmax; /* Max entries */ int aq_entlen; /* Entry length */ + int aq_freebytes; /* Bytes available in buffer */ + int aq_buflen; /* Total length of our buffer */ char *aq_entbuf; /* Buffer for stored entries */ + int aq_writehead; + int aq_writetail; int aq_flags; /* Queue flags */ struct mtx aq_mtx; /* Queue lock */ struct vnode *aq_vp; /* Open vnode handle */ struct ucred *aq_cred; /* Credentials of the opening thread */ - struct ale *aq_first; /* First ent */ - struct ale *aq_entfree; /* First free ent */ - struct ale *aq_entvalid; /* First ent valid for writing */ LIST_ENTRY(alq) aq_act; /* List of active queues */ LIST_ENTRY(alq) aq_link; /* List of all queues */ }; @@ -69,6 +75,8 @@ struct alq { #define ALQ_LOCK(alq) mtx_lock_spin(&(alq)->aq_mtx) #define ALQ_UNLOCK(alq) mtx_unlock_spin(&(alq)->aq_mtx) +#define ALQ_HAS_PENDING_DATA(alq) ((alq)->aq_freebytes != (alq)->aq_buflen) + static MALLOC_DEFINE(M_ALD, "ALD", "ALD"); /* @@ -78,7 +86,6 @@ static struct mtx ald_mtx; static LIST_HEAD(, alq) ald_queues; static LIST_HEAD(, alq) ald_active; static int ald_shutingdown = 0; -struct thread *ald_thread; static struct proc *ald_proc; #define ALD_LOCK() mtx_lock(&ald_mtx) @@ -172,16 +179,25 @@ ald_daemon(void) int needwakeup; struct alq *alq; - ald_thread = FIRST_THREAD_IN_PROC(ald_proc); - EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL, SHUTDOWN_PRI_FIRST); ALD_LOCK(); for (;;) { - while ((alq = LIST_FIRST(&ald_active)) == NULL) + while ((alq = LIST_FIRST(&ald_active)) == NULL + && !ald_shutingdown) +#if (__FreeBSD_version >= 700000) + mtx_sleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0); +#else msleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0); +#endif + + /* Don't shutdown until all active alq's are flushed */ + if (ald_shutingdown && alq == NULL) { + ALD_UNLOCK(); + break; + } ALQ_LOCK(alq); ald_deactivate(alq); @@ -189,9 +205,18 @@ ald_daemon(void) needwakeup = alq_doio(alq); ALQ_UNLOCK(alq); if (needwakeup) - wakeup(alq); + wakeup_one(alq); ALD_LOCK(); } + +#if (__FreeBSD_version < 800000) +#if (__FreeBSD_version < 700000) + wakeup(ald_proc); +#endif + kthread_exit(0); +#else + kproc_exit(0); +#endif } static void @@ -200,14 +225,32 @@ ald_shutdown(void *arg, int howto) struct alq *alq; ALD_LOCK(); + + /* Ensure no new queues can be created */ ald_shutingdown = 1; + /* Shutdown all alqs prior to terminating the ald_daemon */ while ((alq = LIST_FIRST(&ald_queues)) != NULL) { LIST_REMOVE(alq, aq_link); ALD_UNLOCK(); alq_shutdown(alq); ALD_LOCK(); } + + /* At this point, all alqs are flushed and shutdown */ + + /* + * Wake ald_daemon so that it exits. It won't be able to do + * anything until we mtx_sleep because we hold the ald_mtx + */ + wakeup(&ald_active); + + /* Wait for ald_daemon to exit */ +#if (__FreeBSD_version >= 700000) + mtx_sleep(ald_proc, &ald_mtx, PWAIT, "aldslp", 0); +#else + msleep(ald_proc, &ald_mtx, PWAIT, "aldslp", 0); +#endif ALD_UNLOCK(); } @@ -219,15 +262,30 @@ alq_shutdown(struct alq *alq) /* Stop any new writers. */ alq->aq_flags |= AQ_SHUTDOWN; + /* + * If the alq isn't active but has unwritten data (possible if + * the ALQ_NOACTIVATE flag has been used), explicitly activate the + * alq here so that the pending data gets flushed by the ald_daemon. + */ + if (!(alq->aq_flags & AQ_ACTIVE) && + ALQ_HAS_PENDING_DATA(alq)) { + alq->aq_flags |= AQ_ACTIVE; + ALQ_UNLOCK(alq); + ALD_LOCK(); + ald_activate(alq); + ALD_UNLOCK(); + ALQ_LOCK(alq); + } + /* Drain IO */ - while (alq->aq_flags & (AQ_FLUSHING|AQ_ACTIVE)) { + while (alq->aq_flags & AQ_ACTIVE) { alq->aq_flags |= AQ_WANTED; msleep_spin(alq, &alq->aq_mtx, "aldclose", 0); } + ALQ_UNLOCK(alq); - vn_close(alq->aq_vp, FWRITE, alq->aq_cred, - curthread); + vn_close(alq->aq_vp, FWRITE, alq->aq_cred, curthread); crfree(alq->aq_cred); } @@ -242,46 +300,52 @@ alq_doio(struct alq *alq) struct vnode *vp; struct uio auio; struct iovec aiov[2]; - struct ale *ale; - struct ale *alstart; int totlen; int iov; int vfslocked; + KASSERT((ALQ_HAS_PENDING_DATA(alq)), + ("%s: queue emtpy!", __func__) + ); + vp = alq->aq_vp; td = curthread; totlen = 0; - iov = 0; - - alstart = ale = alq->aq_entvalid; - alq->aq_entvalid = NULL; + iov = 1; bzero(&aiov, sizeof(aiov)); bzero(&auio, sizeof(auio)); - do { - if (aiov[iov].iov_base == NULL) - aiov[iov].iov_base = ale->ae_data; - aiov[iov].iov_len += alq->aq_entlen; - totlen += alq->aq_entlen; - /* Check to see if we're wrapping the buffer */ - if (ale->ae_data + alq->aq_entlen != ale->ae_next->ae_data) - iov++; - ale->ae_flags &= ~AE_VALID; - ale = ale->ae_next; - } while (ale->ae_flags & AE_VALID); + /* Start the write from the location of our buffer tail pointer. */ + aiov[0].iov_base = alq->aq_entbuf + alq->aq_writetail; + + if (alq->aq_writetail < alq->aq_writehead) { + /* Buffer not wrapped */ + totlen = aiov[0].iov_len = alq->aq_writehead - alq->aq_writetail; + } else if (alq->aq_writehead == 0) { + /* Buffer not wrapped (special case to avoid an empty iov) */ + totlen = aiov[0].iov_len = alq->aq_buflen - alq->aq_writetail;; + } else { + /* + * Buffer wrapped, requires 2 aiov entries: + * - first is from writetail to end of buffer + * - second is from start of buffer to writehead + */ + aiov[0].iov_len = alq->aq_buflen - alq->aq_writetail; + iov++; + aiov[1].iov_base = alq->aq_entbuf; + aiov[1].iov_len = alq->aq_writehead; + totlen = aiov[0].iov_len + aiov[1].iov_len; + } alq->aq_flags |= AQ_FLUSHING; ALQ_UNLOCK(alq); - if (iov == 2 || aiov[iov].iov_base == NULL) - iov--; - auio.uio_iov = &aiov[0]; auio.uio_offset = 0; auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_WRITE; - auio.uio_iovcnt = iov + 1; + auio.uio_iovcnt = iov; auio.uio_resid = totlen; auio.uio_td = td; @@ -290,7 +354,12 @@ alq_doio(struct alq *alq) */ vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_start_write(vp, &mp, V_WAIT); +#if (__FreeBSD_version < 800000) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); +#else vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); +#endif + /* * XXX: VOP_WRITE error checks are ignored. */ @@ -298,15 +367,32 @@ alq_doio(struct alq *alq) if (mac_vnode_check_write(alq->aq_cred, NOCRED, vp) == 0) #endif VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, alq->aq_cred); +#if (__FreeBSD_version < 800000) + VOP_UNLOCK(vp, 0, td); +#else VOP_UNLOCK(vp, 0); +#endif vn_finished_write(mp); VFS_UNLOCK_GIANT(vfslocked); ALQ_LOCK(alq); alq->aq_flags &= ~AQ_FLUSHING; - if (alq->aq_entfree == NULL) - alq->aq_entfree = alstart; + /* Adjust writetail as required, taking into account wrapping. */ + alq->aq_writetail = (alq->aq_writetail + totlen) % alq->aq_buflen; + alq->aq_freebytes += totlen; + + /* + * If we just flushed the buffer completely, + * reset indexes to 0 to minimise buffer wraps. + * This is also required to ensure alq_getn() can't wedge itself. + */ + if (!ALQ_HAS_PENDING_DATA(alq)) + alq->aq_writehead = alq->aq_writetail = 0; + + KASSERT((alq->aq_writetail >= 0 && alq->aq_writetail < alq->aq_buflen), + ("%s: aq_writetail < 0 || aq_writetail >= aq_buflen", __func__) + ); if (alq->aq_flags & AQ_WANTED) { alq->aq_flags &= ~AQ_WANTED; @@ -337,13 +423,13 @@ alq_open(struct alq **alqp, const char * { struct thread *td; struct nameidata nd; - struct ale *ale; - struct ale *alp; struct alq *alq; - char *bufp; int flags; int error; - int i, vfslocked; + int vfslocked; + + KASSERT((size > 0), ("%s: size <= 0", __func__)); + KASSERT((count >= 0), ("%s: count < 0", __func__)); *alqp = NULL; td = curthread; @@ -351,42 +437,48 @@ alq_open(struct alq **alqp, const char * NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, file, td); flags = FWRITE | O_NOFOLLOW | O_CREAT; +#if (__FreeBSD_version < 700000) + error = vn_open_cred(&nd, &flags, cmode, cred, 0); +#elif (__FreeBSD_version < 800098) + error = vn_open_cred(&nd, &flags, cmode, cred, NULL); +#else error = vn_open_cred(&nd, &flags, cmode, 0, cred, NULL); +#endif if (error) return (error); vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); - /* We just unlock so we hold a reference */ + /* We just unlock so we hold a reference. */ +#if (__FreeBSD_version < 800000) + VOP_UNLOCK(nd.ni_vp, 0, td); +#else VOP_UNLOCK(nd.ni_vp, 0); +#endif VFS_UNLOCK_GIANT(vfslocked); alq = malloc(sizeof(*alq), M_ALD, M_WAITOK|M_ZERO); - alq->aq_entbuf = malloc(count * size, M_ALD, M_WAITOK|M_ZERO); - alq->aq_first = malloc(sizeof(*ale) * count, M_ALD, M_WAITOK|M_ZERO); alq->aq_vp = nd.ni_vp; alq->aq_cred = crhold(cred); - alq->aq_entmax = count; - alq->aq_entlen = size; - alq->aq_entfree = alq->aq_first; mtx_init(&alq->aq_mtx, "ALD Queue", NULL, MTX_SPIN|MTX_QUIET); - bufp = alq->aq_entbuf; - ale = alq->aq_first; - alp = NULL; - - /* Match up entries with buffers */ - for (i = 0; i < count; i++) { - if (alp) - alp->ae_next = ale; - ale->ae_data = bufp; - alp = ale; - ale++; - bufp += size; + if (count > 0) { + /* Fixed length messages. */ + alq->aq_buflen = size * count; + alq->aq_entmax = count; + alq->aq_entlen = size; + } else { + /* Variable length messages. */ + alq->aq_buflen = size; + alq->aq_entmax = 0; + alq->aq_entlen = 0; } - alp->ae_next = alq->aq_first; + alq->aq_freebytes = alq->aq_buflen; + alq->aq_entbuf = malloc(alq->aq_buflen, M_ALD, M_WAITOK|M_ZERO); + + alq->aq_writehead = alq->aq_writetail = 0; if ((error = ald_add(alq)) != 0) return (error); @@ -400,72 +492,240 @@ alq_open(struct alq **alqp, const char * * wait or return an error depending on the value of waitok. */ int -alq_write(struct alq *alq, void *data, int waitok) +alq_write(struct alq *alq, void *data, int flags) { - struct ale *ale; + /* Should only be called in fixed length message (legacy) mode. */ + KASSERT((alq->aq_entmax > 0 && alq->aq_entlen > 0), + ("%s: fixed length write on variable length queue", __func__) + ); + return (alq_writen(alq, data, alq->aq_entlen, flags)); +} + +int +alq_writen(struct alq *alq, void *data, int len, int flags) +{ + int activate = 0; + int copy = len; + + KASSERT((len > 0 && len <= alq->aq_buflen), + ("%s: len <= 0 || len > aq_buflen", __func__) + ); - if ((ale = alq_get(alq, waitok)) == NULL) + ALQ_LOCK(alq); + + /* + * If the message is larger than our underlying buffer or + * there is not enough free space in our underlying buffer + * to accept the message and the user can't wait, return. + */ + if ((len > alq->aq_buflen) || + ((flags & ALQ_NOWAIT) && (alq->aq_freebytes < len))) { + ALQ_UNLOCK(alq); return (EWOULDBLOCK); + } - bcopy(data, ale->ae_data, alq->aq_entlen); - alq_post(alq, ale); + /* + * ALQ_WAITOK or alq->aq_freebytes > len, either spin until + * we have enough free bytes (former) or skip (latter). + */ + while (alq->aq_freebytes < len && (alq->aq_flags & AQ_SHUTDOWN) == 0) { + alq->aq_flags |= AQ_WANTED; + msleep_spin(alq, &alq->aq_mtx, "alqwriten", 0); + } + + /* + * We need to serialise wakups to ensure records remain in order... + * Therefore, wakeup the next thread in the queue waiting for + * alq resources to be available. + * (technically this is only required if we actually entered the above + * while loop) + */ + wakeup_one(alq); + + /* Bail if we're shutting down. */ + if (alq->aq_flags & AQ_SHUTDOWN) { + ALQ_UNLOCK(alq); + return (EWOULDBLOCK); + } + + /* + * If we need to wrap the buffer to accommodate the write, + * we'll need 2 calls to bcopy. + */ + if ((alq->aq_buflen - alq->aq_writehead) < len) + copy = alq->aq_buflen - alq->aq_writehead; + + /* Copy message (or part thereof if wrap required) to the buffer. */ + bcopy(data, alq->aq_entbuf + alq->aq_writehead, copy); + alq->aq_writehead += copy; + + if (alq->aq_writehead >= alq->aq_buflen) { + KASSERT((alq->aq_writehead == alq->aq_buflen), + ("alq->aq_writehead (%d) > alq->aq_buflen (%d)", + alq->aq_writehead, + alq->aq_buflen) + ); + alq->aq_writehead = 0; + } + + if (copy != len) { + /* + * Wrap the buffer by copying the remainder of our message + * to the start of the buffer and resetting aq_writehead. + */ + bcopy(((uint8_t *)data)+copy, alq->aq_entbuf, len - copy); + alq->aq_writehead = len - copy; + } + + KASSERT((alq->aq_writehead >= 0 && alq->aq_writehead < alq->aq_buflen), + ("%s: aq_writehead < 0 || aq_writehead >= aq_buflen", __func__) + ); + + alq->aq_freebytes -= len; + + if (((alq->aq_flags & AQ_ACTIVE) == 0) && + ((flags & ALQ_NOACTIVATE) == 0)) { + alq->aq_flags |= AQ_ACTIVE; + activate = 1; + } + + ALQ_UNLOCK(alq); + + if (activate) { + ALD_LOCK(); + ald_activate(alq); + ALD_UNLOCK(); + } return (0); } struct ale * -alq_get(struct alq *alq, int waitok) +alq_get(struct alq *alq, int flags) +{ + /* Should only be called in fixed length message (legacy) mode. */ + KASSERT((alq->aq_entmax > 0 && alq->aq_entlen > 0), + ("%s: fixed length get on variable length queue", __func__) + ); + return (alq_getn(alq, alq->aq_entlen, flags)); +} + +struct ale * +alq_getn(struct alq *alq, int len, int flags) { struct ale *ale; - struct ale *aln; + int contigbytes; - ale = NULL; + KASSERT((len > 0 && len <= alq->aq_buflen), + ("%s: len <= 0 || len > alq->aq_buflen", __func__) + ); + + ale = malloc( sizeof(struct ale), + M_ALD, + (flags & ALQ_NOWAIT) ? M_NOWAIT : M_WAITOK + ); + + if (ale == NULL) + return (NULL); ALQ_LOCK(alq); - /* Loop until we get an entry or we're shutting down */ - while ((alq->aq_flags & AQ_SHUTDOWN) == 0 && - (ale = alq->aq_entfree) == NULL && - (waitok & ALQ_WAITOK)) { - alq->aq_flags |= AQ_WANTED; - msleep_spin(alq, &alq->aq_mtx, "alqget", 0); + /* + * Determine the number of free contiguous bytes. + * We ensure elsewhere that if aq_writehead == aq_writetail because + * the buffer is empty, they will both be set to 0 and therefore + * aq_freebytes == aq_buflen and is fully contiguous. + * If they are equal and the buffer is not empty, aq_freebytes will + * be 0 indicating the buffer is full. + */ + if (alq->aq_writehead <= alq->aq_writetail) + contigbytes = alq->aq_freebytes; + else + contigbytes = alq->aq_buflen - alq->aq_writehead; + + /* + * If the message is larger than our underlying buffer or + * there is not enough free contiguous space in our underlying buffer + * to accept the message and the user can't wait, return. + */ + if ((len > alq->aq_buflen) || + ((flags & ALQ_NOWAIT) && (contigbytes < len))) { + ALQ_UNLOCK(alq); + free(ale, M_ALD); + return (NULL); } - if (ale != NULL) { - aln = ale->ae_next; - if ((aln->ae_flags & AE_VALID) == 0) - alq->aq_entfree = aln; + /* + * ALQ_WAITOK or contigbytes >= len, + * either spin until we have enough free contiguous bytes (former) + * or skip (latter). + */ + while (contigbytes < len && (alq->aq_flags & AQ_SHUTDOWN) == 0) { + alq->aq_flags |= AQ_WANTED; + msleep_spin(alq, &alq->aq_mtx, "alqgetn", 0); + if (alq->aq_writehead <= alq->aq_writetail) + contigbytes = alq->aq_freebytes; else - alq->aq_entfree = NULL; - } else + contigbytes = alq->aq_buflen - alq->aq_writehead; + } + + /* + * We need to serialise wakups to ensure records remain in order. + * Therefore, wakeup the next thread in the queue waiting for + * alq resources to be available. + * (technically this is only required if we actually entered the above + * while loop) + */ + wakeup_one(alq); + + /* Bail if we're shutting down */ + if (alq->aq_flags & AQ_SHUTDOWN) { ALQ_UNLOCK(alq); + free(ale, M_ALD); + return (NULL); + } + /* + * If we are here, we have a contiguous number of bytes >= len + * available in our buffer starting at aq_writehead. + */ + ale->ae_data = alq->aq_entbuf + alq->aq_writehead; + ale->ae_datalen = len; + alq->aq_writehead += len; + alq->aq_freebytes -= len; + + /* Wrap aq_writehead if we've filled to the end of the buffer. */ + if (alq->aq_writehead == alq->aq_buflen) + alq->aq_writehead = 0; + + KASSERT((alq->aq_writehead >= 0 && alq->aq_writehead < alq->aq_buflen), + ("%s: aq_writehead < 0 || aq_writehead >= aq_buflen", __func__) + ); return (ale); } void -alq_post(struct alq *alq, struct ale *ale) +alq_post(struct alq *alq, struct ale *ale, int flags) { int activate; - ale->ae_flags |= AE_VALID; - - if (alq->aq_entvalid == NULL) - alq->aq_entvalid = ale; - - if ((alq->aq_flags & AQ_ACTIVE) == 0) { + if (((alq->aq_flags & AQ_ACTIVE) == 0) && + ((flags & ALQ_NOACTIVATE) == 0)) { alq->aq_flags |= AQ_ACTIVE; activate = 1; } else activate = 0; ALQ_UNLOCK(alq); + if (activate) { ALD_LOCK(); ald_activate(alq); ALD_UNLOCK(); } + + free(ale, M_ALD); } void @@ -475,16 +735,23 @@ alq_flush(struct alq *alq) ALD_LOCK(); ALQ_LOCK(alq); - if (alq->aq_flags & AQ_ACTIVE) { + + if (alq->aq_flags & AQ_ACTIVE) ald_deactivate(alq); - ALD_UNLOCK(); + + ALD_UNLOCK(); + + /* + * Pull the lever iff there is data to flush and we're + * not already in the middle of a flush operation. + */ + if (ALQ_HAS_PENDING_DATA(alq) && (alq->aq_flags & AQ_FLUSHING) == 0) needwakeup = alq_doio(alq); - } else - ALD_UNLOCK(); + ALQ_UNLOCK(alq); if (needwakeup) - wakeup(alq); + wakeup_one(alq); } /* @@ -506,7 +773,49 @@ alq_close(struct alq *alq) alq_shutdown(alq); mtx_destroy(&alq->aq_mtx); - free(alq->aq_first, M_ALD); free(alq->aq_entbuf, M_ALD); free(alq, M_ALD); } + +static int alq_load_handler(module_t mod, int what, void *arg) +{ + int ret = 0; + + switch(what) { + case MOD_LOAD: + case MOD_UNLOAD: + case MOD_SHUTDOWN: + break; + + case MOD_QUIESCE: + ALD_LOCK(); + /* only allow unload if there are no open queues */ + if (LIST_FIRST(&ald_queues) == NULL) { + ald_shutingdown = 1; + ALD_UNLOCK(); + ald_shutdown(NULL, 0); + mtx_destroy(&ald_mtx); + } else { + ALD_UNLOCK(); + ret = EBUSY; + } + break; + + default: + ret = EINVAL; + break; + } + + return (ret); +} + +/* basic module data */ +static moduledata_t alq_mod = +{ + "alq", + alq_load_handler, /* execution entry point for the module */ + NULL +}; + +DECLARE_MODULE(alq, alq_mod, SI_SUB_SMP, SI_ORDER_ANY); +MODULE_VERSION(alq, 1); Modified: projects/tcp_ffcaia2008_8.x/sys/modules/Makefile ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/modules/Makefile Thu Aug 13 12:28:30 2009 (r196179) +++ projects/tcp_ffcaia2008_8.x/sys/modules/Makefile Thu Aug 13 13:17:50 2009 (r196180) @@ -22,6 +22,7 @@ SUBDIR= ${_3dfx} \ ${_amdtemp} \ alc \ ale \ + alq \ amr \ ${_an} \ ${_aout} \ Modified: projects/tcp_ffcaia2008_8.x/sys/sys/alq.h ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Thu Aug 13 12:28:30 2009 (r196179) +++ projects/tcp_ffcaia2008_8.x/sys/sys/alq.h Thu Aug 13 13:17:50 2009 (r196180) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2002, Jeffrey Roberson + * Copyright (c) 2008-2009, Lawrence Stewart * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,7 +27,7 @@ * $FreeBSD$ * */ -#ifndef _SYS_ALQ_H_ +#ifndef _SYS_ALQ_H_ #define _SYS_ALQ_H_ /* @@ -41,17 +42,14 @@ extern struct thread *ald_thread; * Async. Logging Entry */ struct ale { - struct ale *ae_next; /* Next Entry */ char *ae_data; /* Entry buffer */ - int ae_flags; /* Entry flags */ + int ae_datalen; /* Length of buffer */ }; -#define AE_VALID 0x0001 /* Entry has valid data */ - - -/* waitok options */ +/* flags options */ #define ALQ_NOWAIT 0x0001 #define ALQ_WAITOK 0x0002 +#define ALQ_NOACTIVATE 0x0004 /* Suggested mode for file creation. */ #define ALQ_DEFAULT_CMODE 0600 @@ -64,7 +62,8 @@ struct ale { * file The filename to open for logging. * cred Credential to authorize open and I/O with. * cmode Creation mode for file, if new. - * size The size of each entry in the queue. + * size The size of each entry in the queue, or the size of the queue + * itself in bytes if count=0 (variable length queues). * count The number of items in the buffer, this should be large enough * to store items over the period of a disk write. * Returns: @@ -88,7 +87,8 @@ int alq_open(struct alq **, const char * * The system is shutting down. * 0 on success. */ -int alq_write(struct alq *alq, void *data, int waitok); +int alq_write(struct alq *alq, void *data, int flags); +int alq_writen(struct alq *alq, void *data, int len, int flags); /* * alq_flush: Flush the queue out to disk @@ -115,13 +115,14 @@ void alq_close(struct alq *alq); * * This leaves the queue locked until a subsequent alq_post. */ -struct ale *alq_get(struct alq *alq, int waitok); +struct ale *alq_get(struct alq *alq, int flags); +struct ale *alq_getn(struct alq *alq, int len, int flags); /* * alq_post: Schedule the ale retrieved by alq_get for writing. * alq The queue to post the entry to. * ale An asynch logging entry returned by alq_get. */ -void alq_post(struct alq *, struct ale *); +void alq_post(struct alq *alq, struct ale *ale, int flags); #endif /* _SYS_ALQ_H_ */ From owner-svn-src-projects@FreeBSD.ORG Thu Aug 13 14:46:33 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36579106566B; Thu, 13 Aug 2009 14:46:33 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 24CD08FC1F; Thu, 13 Aug 2009 14:46:33 +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 n7DEkXad003915; Thu, 13 Aug 2009 14:46:33 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DEkX93003913; Thu, 13 Aug 2009 14:46:33 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908131446.n7DEkX93003913@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 13 Aug 2009 14:46:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196183 - projects/tcp_ffcaia2008_8.x/sys/modules/alq X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 14:46:33 -0000 Author: lstewart Date: Thu Aug 13 14:46:32 2009 New Revision: 196183 URL: http://svn.freebsd.org/changeset/base/196183 Log: Forgot this in the previous ALQ import commit. Sponsored by: FreeBSD Foundation Added: projects/tcp_ffcaia2008_8.x/sys/modules/alq/Makefile Added: projects/tcp_ffcaia2008_8.x/sys/modules/alq/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/tcp_ffcaia2008_8.x/sys/modules/alq/Makefile Thu Aug 13 14:46:32 2009 (r196183) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.include + +.PATH: ${.CURDIR}/../../kern +KMOD= alq +SRCS= opt_mac.h vnode_if.h kern_alq.c + +.include From owner-svn-src-projects@FreeBSD.ORG Thu Aug 13 15:14:03 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3551A10656A5; Thu, 13 Aug 2009 15:14:03 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21F128FC1F; Thu, 13 Aug 2009 15:14:03 +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 n7DFE3eT004946; Thu, 13 Aug 2009 15:14:03 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DFE3wb004942; Thu, 13 Aug 2009 15:14:03 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908131514.n7DFE3wb004942@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 13 Aug 2009 15:14:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196191 - in projects/tcp_ffcaia2008_8.x/sys: modules modules/siftr netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 15:14:03 -0000 Author: lstewart Date: Thu Aug 13 15:14:02 2009 New Revision: 196191 URL: http://svn.freebsd.org/changeset/base/196191 Log: Initial wholesale import of the Statistical Information For TCP Research (SIFTR) v1.2.2 kernel module. SIFTR facilitates TCP related research, development and debugging by providing near real-time access to highly detailed kernel information from TCP endpoints. The tool can be used to gather data unobtrusively on running systems, making it a useful addition to the toolkits of system administrators, developers, and researchers alike. SIFTR was first released in 2007 by James Healy and Lawrence Stewart whilst working on the NewTCP research project at Swinburne University's Centre for Advanced Internet Architectures, Melbourne, Australia, which was made possible in part by a grant from the Cisco University Research Program Fund at Community Foundation Silicon Valley. More details are available at: http://caia.swin.edu.au/urp/newtcp/ Work on SIFTR v1.2.x was sponsored by the FreeBSD Foundation as part of the "Enhancing the FreeBSD TCP Implementation" project 2008-2009. More details are available at: http://www.freebsdfoundation.org/ http://caia.swin.edu.au/freebsd/etcp09/ Sponsored by: FreeBSD Foundation, Cisco Systems Added: projects/tcp_ffcaia2008_8.x/sys/modules/siftr/ projects/tcp_ffcaia2008_8.x/sys/modules/siftr/Makefile projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c Modified: projects/tcp_ffcaia2008_8.x/sys/modules/Makefile Modified: projects/tcp_ffcaia2008_8.x/sys/modules/Makefile ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/modules/Makefile Thu Aug 13 15:08:05 2009 (r196190) +++ projects/tcp_ffcaia2008_8.x/sys/modules/Makefile Thu Aug 13 15:14:02 2009 (r196191) @@ -243,6 +243,7 @@ SUBDIR= ${_3dfx} \ sdhci \ sem \ sf \ + siftr \ sis \ sk \ ${_smbfs} \ Added: projects/tcp_ffcaia2008_8.x/sys/modules/siftr/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/tcp_ffcaia2008_8.x/sys/modules/siftr/Makefile Thu Aug 13 15:14:02 2009 (r196191) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +.include + +.PATH: ${.CURDIR}/../../netinet +KMOD= siftr +SRCS= siftr.c + +# Uncomment to add IPv6 support +#CFLAGS+=-DSIFTR_IPV6 + +.include Added: projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c Thu Aug 13 15:14:02 2009 (r196191) @@ -0,0 +1,1786 @@ +/*- + * Copyright (c) 2007-2009, Centre for Advanced Internet Architectures + * Swinburne University of Technology, Melbourne, Australia + * (CRICOS number 00111D). + * + * All rights reserved. + * + * SIFTR was first released in 2007 by James Healy and Lawrence Stewart whilst + * working on the NewTCP research project at Swinburne University's Centre for + * Advanced Internet Architectures, Melbourne, Australia, which was made + * possible in part by a grant from the Cisco University Research Program Fund + * at Community Foundation Silicon Valley. More details are available at: + * http://caia.swin.edu.au/urp/newtcp/ + * + * Work on SIFTR v1.2.x was sponsored by the FreeBSD Foundation as part of + * the "Enhancing the FreeBSD TCP Implementation" project 2008-2009. + * More details are available at: + * http://www.freebsdfoundation.org/ + * http://caia.swin.edu.au/freebsd/etcp09/ + * + * Lawrence Stewart is currently the sole maintainer, and all contact regarding + * SIFTR should be directed to him via email: lastewart@swin.edu.au + * + * 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. + * 3. The names of the authors, the "Centre for Advanced Internet + * Architectures" and "Swinburne University of Technology" may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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. + */ + +/****************************************************** + * Statistical Information For TCP Research (SIFTR) + * + * A FreeBSD kernel module that adds very basic intrumentation to the + * TCP stack, allowing internal stats to be recorded to a log file + * during experimentation. + * + * Initial release date: June 2007 + * Most recent update: July 2009 + ******************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (__FreeBSD_version >= 800044) +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if (__FreeBSD_version >= 800044) +#include +#endif + +#ifdef SIFTR_IPV6 +#include +#include + +#if (__FreeBSD_version >= 800044) +#include +#endif + +#endif /* SIFTR_IPV6 */ + +#include + +#include "siftr_hash.h" + + +#define MODVERSION "1.2.2" +#define HOOK 0 +#define UNHOOK 1 + +#define SIFTR_EXPECTED_MAX_TCP_FLOWS 65536 + + +#define SYS_NAME "FreeBSD" +#define PACKET_TAG_SIFTR 100 +#define PACKET_COOKIE_SIFTR 21749576 +#define SIFTR_LOG_FILE_MODE 0644 + +/* + * log messages are less than MAX_LOG_MSG_LEN chars long, so divide + * SIFTR_ALQ_BUFLEN by MAX_LOG_MSG_LEN to get the approximate upper bound + * number of log messages that can be held in the ALQ buffer + */ +#define MAX_LOG_MSG_LEN 200 +#define SIFTR_ALQ_BUFLEN 200000 + + +#define SIFTR_DISABLE 0 +#define SIFTR_ENABLE 1 + + +/* + * 1 byte for IP version + * IPv4: src/dst IP (4+4) + src/dst port (2+2) = 12 bytes + * IPv6: src/dst IP (16+16) + src/dst port (2+2) = 36 bytes + */ +#ifdef SIFTR_IPV6 +#define FLOW_KEY_LEN 37 +#else +#define FLOW_KEY_LEN 13 +#endif + +#ifdef SIFTR_IPV6 +#define SIFTR_IPMODE 6 +#else +#define SIFTR_IPMODE 4 +#endif + +/* useful macros */ +#define CAST_PTR_INT(X) (*((int*)(X))) + +#define TOTAL_TCP_PKTS \ +( \ + siftr_num_inbound_tcp_pkts + \ + siftr_num_outbound_tcp_pkts \ +) + +#define TOTAL_SKIPPED_TCP_PKTS \ +( \ + siftr_num_inbound_skipped_pkts_malloc + \ + siftr_num_inbound_skipped_pkts_mtx + \ + siftr_num_outbound_skipped_pkts_malloc + \ + siftr_num_outbound_skipped_pkts_mtx + \ + siftr_num_inbound_skipped_pkts_tcb + \ + siftr_num_outbound_skipped_pkts_tcb + \ + siftr_num_inbound_skipped_pkts_icb + \ + siftr_num_outbound_skipped_pkts_icb \ +) + +#define UPPER_SHORT(X) (((X) & 0xFFFF0000) >> 16) +#define LOWER_SHORT(X) ((X) & 0x0000FFFF) + +#define FIRST_OCTET(X) (((X) & 0xFF000000) >> 24) +#define SECOND_OCTET(X) (((X) & 0x00FF0000) >> 16) +#define THIRD_OCTET(X) (((X) & 0x0000FF00) >> 8) +#define FOURTH_OCTET(X) ((X) & 0x000000FF) + +MALLOC_DECLARE(M_SIFTR); +MALLOC_DEFINE(M_SIFTR, "siftr", "dynamic memory used by SIFTR"); + +MALLOC_DECLARE(M_SIFTR_PKTNODE); +MALLOC_DEFINE(M_SIFTR_PKTNODE, "siftr_pktnode", "SIFTR pkt_node struct"); + +MALLOC_DECLARE(M_SIFTR_HASHNODE); +MALLOC_DEFINE(M_SIFTR_HASHNODE, "siftr_hashnode", "SIFTR flow_hash_node struct"); + +/* Struct that will make up links in the pkt manager queue */ +struct pkt_node { + /* timestamp of pkt as noted in the pfil hook */ + struct timeval tval; + /* direction pkt is travelling; either PFIL_IN or PFIL_OUT */ + uint8_t direction; + /* IP version pkt_node relates to; either INP_IPV4 or INP_IPV6 */ + uint8_t ipver; + /* hash of the pkt which triggered the log message */ + uint32_t hash; + /* local/foreign IP address */ +#ifdef SIFTR_IPV6 + uint32_t ip_laddr[4]; + uint32_t ip_faddr[4]; +#else + uint8_t ip_laddr[4]; + uint8_t ip_faddr[4]; +#endif + /* local TCP port */ + uint16_t tcp_localport; + /* foreign TCP port */ + uint16_t tcp_foreignport; + /* Congestion Window (bytes) */ + u_long snd_cwnd; + /* Sending Window (bytes) */ + u_long snd_wnd; + /* Receive Window (bytes) */ + u_long rcv_wnd; + /* Bandwidth Controlled Window (bytes) */ + u_long snd_bwnd; + /* Slow Start Threshold (bytes) */ + u_long snd_ssthresh; + /* Current state of the TCP FSM */ + int conn_state; + /* Max Segment Size (bytes) */ + u_int max_seg_size; + /* + * Smoothed RTT stored as found in the TCP control block + * in units of (TCP_RTT_SCALE*hz) + */ + int smoothed_rtt; + /* Is SACK enabled? */ + u_char sack_enabled; + /* Window scaling for snd window */ + u_char snd_scale; + /* Window scaling for recv window */ + u_char rcv_scale; + /* TCP control block flags */ + u_int flags; + /* Retransmit timeout length */ + int rxt_length; + /* Size of the TCP send buffer in bytes */ + u_int snd_buf_hiwater; + /* Current num bytes in the send socket buffer */ + u_int snd_buf_cc; + /* Size of the TCP receive buffer in bytes */ + u_int rcv_buf_hiwater; + /* Current num bytes in the receive socket buffer */ + u_int rcv_buf_cc; + /* Number of bytes inflight that we are waiting on ACKs for */ + u_int sent_inflight_bytes; + /* Link to next pkt_node in the list */ + STAILQ_ENTRY(pkt_node) nodes; +}; + +/* Struct that will be stored in the TCP flow hash table */ +struct flow_hash_node +{ + uint16_t counter; + uint8_t key[FLOW_KEY_LEN]; + LIST_ENTRY(flow_hash_node) nodes; +}; + +/* various runtime stats variables */ +static volatile uint32_t siftr_num_inbound_skipped_pkts_malloc = 0; +static volatile uint32_t siftr_num_inbound_skipped_pkts_mtx = 0; +static volatile uint32_t siftr_num_outbound_skipped_pkts_malloc = 0; +static volatile uint32_t siftr_num_outbound_skipped_pkts_mtx = 0; +static volatile uint32_t siftr_num_inbound_skipped_pkts_icb = 0; +static volatile uint32_t siftr_num_outbound_skipped_pkts_icb = 0; +static volatile uint32_t siftr_num_inbound_skipped_pkts_tcb = 0; +static volatile uint32_t siftr_num_outbound_skipped_pkts_tcb = 0; +static volatile uint32_t siftr_num_inbound_skipped_pkts_dejavu = 0; +static volatile uint32_t siftr_num_outbound_skipped_pkts_dejavu = 0; +static volatile uint32_t siftr_num_inbound_tcp_pkts = 0; +static volatile uint32_t siftr_num_outbound_tcp_pkts = 0; + +static volatile uint32_t siftr_exit_pkt_manager_thread = 0; +static uint8_t siftr_enabled = 0; +static uint32_t siftr_pkts_per_log = 1; +static char siftr_logfile[PATH_MAX] = "/var/log/siftr.log\0"; + +/* + * Controls whether we generate a hash for each packet that triggers + * a SIFTR log message. Should eventually be made accessible via sysctl. + */ +static uint8_t siftr_generate_hashes = 1; + +/* + * pfil.h defines PFIL_IN as 1 and PFIL_OUT as 2, + * which we use as an index into this array. + */ +static char direction[3] = {'\0', 'i','o'}; + + +static char *log_writer_msg_buf; +STAILQ_HEAD(pkthead, pkt_node) pkt_queue = STAILQ_HEAD_INITIALIZER(pkt_queue); + + +static u_long siftr_hashmask; +LIST_HEAD(listhead, flow_hash_node) *counter_hash; + +static int wait_for_pkt; + +static struct alq *siftr_alq = NULL; +static struct mtx siftr_pkt_queue_mtx; + +static struct mtx siftr_pkt_mgr_mtx; + + + +static struct thread *siftr_pkt_manager_thr = NULL; +#if (__FreeBSD_version < 800000) +static struct proc *siftr_pkt_manager_proc = NULL; +#endif + +#if (__FreeBSD_version >= 800044) +#define _siftrtcbinfo &V_tcbinfo +#else +#define _siftrtcbinfo &tcbinfo +#endif + + + +static void +siftr_process_pkt(struct pkt_node * pkt_node) +{ + char siftr_log_msg[MAX_LOG_MSG_LEN]; + uint8_t found_match = 0; + uint8_t key[FLOW_KEY_LEN]; + uint8_t key_offset = 1; + struct flow_hash_node *hash_node = NULL; + struct listhead *counter_list = NULL; + + /* + * Create the key that will be used to create a hash index + * into our hash table. + * Our key consists of ipversion,localip,localport,foreignip,foreignport + */ + key[0] = pkt_node->ipver; + memcpy( key + key_offset, + (void *)(&(pkt_node->ip_laddr)), + sizeof(pkt_node->ip_laddr) + ); + key_offset += sizeof(pkt_node->ip_laddr); + memcpy( key + key_offset, + (void *)(&(pkt_node->tcp_localport)), + sizeof(pkt_node->tcp_localport) + ); + key_offset += sizeof(pkt_node->tcp_localport); + memcpy( key + key_offset, + (void *)(&(pkt_node->ip_faddr)), + sizeof(pkt_node->ip_faddr) + ); + key_offset += sizeof(pkt_node->ip_faddr); + memcpy( key + key_offset, + (void *)(&(pkt_node->tcp_foreignport)), + sizeof(pkt_node->tcp_foreignport) + ); + + counter_list = (counter_hash + + (hash32_buf(key, sizeof(key), 0) & siftr_hashmask)); + + /* + * If the list is not empty i.e. the hash index has + * been used by another flow previously. + */ + if(LIST_FIRST(counter_list) != NULL) { + /* + * Loop through the hash nodes in the list. + * There should normally only be 1 hash node in the list, + * except if there have been collisions at the hash index + * computed by hash32_buf() + */ + LIST_FOREACH(hash_node, counter_list, nodes) { + /* + * Check if the key for the pkt we are currently + * processing is the same as the key stored in the + * hash node we are currently processing. + * If they are the same, then we've found the + * hash node that stores the counter for the flow + * the pkt belongs to + */ + if (memcmp(hash_node->key, key, sizeof(key)) == 0) { + found_match = 1; + break; + } + } + } + + /* If this flow hash hasn't been seen before or we have a collision */ + if (hash_node == NULL || !found_match) { + /* Create a new hash node to store the flow's counter */ + hash_node = malloc( sizeof(struct flow_hash_node), + M_SIFTR_HASHNODE, + M_WAITOK + ); + + if (hash_node != NULL) { + /* Initialise our new hash node list entry */ + hash_node->counter = 0; + memcpy(hash_node->key, key, sizeof(key)); + LIST_INSERT_HEAD(counter_list, hash_node, nodes); + } + else { + /* malloc failed */ + if (pkt_node->direction == PFIL_IN) + siftr_num_inbound_skipped_pkts_malloc++; + else + siftr_num_outbound_skipped_pkts_malloc++; + + return; + } + } + else if (siftr_pkts_per_log > 1) { + /* + * Taking the remainder of the counter divided + * by the current value of siftr_pkts_per_log + * and storing that in counter provides a neat + * way to modulate the frequency of log + * messages being written to the log file + */ + hash_node->counter = (hash_node->counter + 1) % + siftr_pkts_per_log; + + /* + * If we have not seen enough packets since the last time + * we wrote a log message for this connection, return + */ + if (hash_node->counter > 0) + return; + } + +#ifdef SIFTR_IPV6 + pkt_node->ip_laddr[3] = ntohl(pkt_node->ip_laddr[3]); + pkt_node->ip_faddr[3] = ntohl(pkt_node->ip_faddr[3]); + + if (pkt_node->ipver == INP_IPV6) { /* IPv6 packet */ + pkt_node->ip_laddr[0] = ntohl(pkt_node->ip_laddr[0]); + pkt_node->ip_laddr[1] = ntohl(pkt_node->ip_laddr[1]); + pkt_node->ip_laddr[2] = ntohl(pkt_node->ip_laddr[2]); + pkt_node->ip_faddr[0] = ntohl(pkt_node->ip_faddr[0]); + pkt_node->ip_faddr[1] = ntohl(pkt_node->ip_faddr[1]); + pkt_node->ip_faddr[2] = ntohl(pkt_node->ip_faddr[2]); + + /* Construct an IPv6 log message. */ + sprintf(siftr_log_msg, +#if (__FreeBSD_version >= 700000) + "%c,0x%08x,%zd.%06ld,%x:%x:%x:%x:%x:%x:%x:%x,%u,%x:%x:%x:%x:%x:%x:%x:%x,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", +#else + "%c,0x%08x,%ld.%06ld,%x:%x:%x:%x:%x:%x:%x:%x,%u,%x:%x:%x:%x:%x:%x:%x:%x,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", +#endif + direction[pkt_node->direction], + pkt_node->hash, + pkt_node->tval.tv_sec, + pkt_node->tval.tv_usec, + UPPER_SHORT(pkt_node->ip_laddr[0]), + LOWER_SHORT(pkt_node->ip_laddr[0]), + UPPER_SHORT(pkt_node->ip_laddr[1]), + LOWER_SHORT(pkt_node->ip_laddr[1]), + UPPER_SHORT(pkt_node->ip_laddr[2]), + LOWER_SHORT(pkt_node->ip_laddr[2]), + UPPER_SHORT(pkt_node->ip_laddr[3]), + LOWER_SHORT(pkt_node->ip_laddr[3]), + ntohs(pkt_node->tcp_localport), + UPPER_SHORT(pkt_node->ip_faddr[0]), + LOWER_SHORT(pkt_node->ip_faddr[0]), + UPPER_SHORT(pkt_node->ip_faddr[1]), + LOWER_SHORT(pkt_node->ip_faddr[1]), + UPPER_SHORT(pkt_node->ip_faddr[2]), + LOWER_SHORT(pkt_node->ip_faddr[2]), + UPPER_SHORT(pkt_node->ip_faddr[3]), + LOWER_SHORT(pkt_node->ip_faddr[3]), + ntohs(pkt_node->tcp_foreignport), + pkt_node->snd_ssthresh, + pkt_node->snd_cwnd, + pkt_node->snd_bwnd, + pkt_node->snd_wnd, + pkt_node->rcv_wnd, + pkt_node->snd_scale, + pkt_node->rcv_scale, + pkt_node->conn_state, + pkt_node->max_seg_size, + pkt_node->smoothed_rtt, + pkt_node->sack_enabled, + pkt_node->flags, + pkt_node->rxt_length, + pkt_node->snd_buf_hiwater, + pkt_node->snd_buf_cc, + pkt_node->rcv_buf_hiwater, + pkt_node->rcv_buf_cc, + pkt_node->sent_inflight_bytes + ); + } else { /* IPv4 packet */ + pkt_node->ip_laddr[0] = FIRST_OCTET(pkt_node->ip_laddr[3]); + pkt_node->ip_laddr[1] = SECOND_OCTET(pkt_node->ip_laddr[3]); + pkt_node->ip_laddr[2] = THIRD_OCTET(pkt_node->ip_laddr[3]); + pkt_node->ip_laddr[3] = FOURTH_OCTET(pkt_node->ip_laddr[3]); + pkt_node->ip_faddr[0] = FIRST_OCTET(pkt_node->ip_faddr[3]); + pkt_node->ip_faddr[1] = SECOND_OCTET(pkt_node->ip_faddr[3]); + pkt_node->ip_faddr[2] = THIRD_OCTET(pkt_node->ip_faddr[3]); + pkt_node->ip_faddr[3] = FOURTH_OCTET(pkt_node->ip_faddr[3]); +#endif /* SIFTR_IPV6 */ + + /* Construct an IPv4 log message. */ + sprintf(siftr_log_msg, +#if (__FreeBSD_version >= 700000) + "%c,0x%08x,%zd.%06ld,%u.%u.%u.%u,%u,%u.%u.%u.%u,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", +#else + "%c,0x%08x,%ld.%06ld,%u.%u.%u.%u,%u,%u.%u.%u.%u,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", +#endif + direction[pkt_node->direction], + pkt_node->hash, + pkt_node->tval.tv_sec, + pkt_node->tval.tv_usec, + pkt_node->ip_laddr[0], + pkt_node->ip_laddr[1], + pkt_node->ip_laddr[2], + pkt_node->ip_laddr[3], + ntohs(pkt_node->tcp_localport), + pkt_node->ip_faddr[0], + pkt_node->ip_faddr[1], + pkt_node->ip_faddr[2], + pkt_node->ip_faddr[3], + ntohs(pkt_node->tcp_foreignport), + pkt_node->snd_ssthresh, + pkt_node->snd_cwnd, + pkt_node->snd_bwnd, + pkt_node->snd_wnd, + pkt_node->rcv_wnd, + pkt_node->snd_scale, + pkt_node->rcv_scale, + pkt_node->conn_state, + pkt_node->max_seg_size, + pkt_node->smoothed_rtt, + pkt_node->sack_enabled, + pkt_node->flags, + pkt_node->rxt_length, + pkt_node->snd_buf_hiwater, + pkt_node->snd_buf_cc, + pkt_node->rcv_buf_hiwater, + pkt_node->rcv_buf_cc, + pkt_node->sent_inflight_bytes + ); +#ifdef SIFTR_IPV6 + } +#endif + + /* + * XXX: This could possibly be made more efficient by padding + * the log message to always be a fixed number of characters... + * We wouldn't need the call to strlen if we did this + */ + /* XXX: Should we use alq_getn/alq_post here to avoid the bcopy? */ + alq_writen(siftr_alq, siftr_log_msg, strlen(siftr_log_msg), ALQ_WAITOK); +} + + + + + + + +static void +siftr_pkt_manager_thread(void *arg) +{ + struct pkt_node *pkt_node, *pkt_node_temp; + STAILQ_HEAD(pkthead, pkt_node) tmp_pkt_queue = STAILQ_HEAD_INITIALIZER(tmp_pkt_queue); + uint8_t draining = 2; + + mtx_lock(&siftr_pkt_mgr_mtx); + + /* draining == 0 when queue has been flushed and it's safe to exit */ + while (draining) { + /* + * Sleep until we are signalled to wake because thread has + * been told to exit or until 1 tick has passed + */ + msleep(&wait_for_pkt, &siftr_pkt_mgr_mtx, PWAIT, "pktwait", 1); + + /* Gain exclusive access to the pkt_node queue */ + mtx_lock(&siftr_pkt_queue_mtx); + + /* + * Move pkt_queue to tmp_pkt_queue, which leaves + * pkt_queue empty and ready to receive more pkt_nodes + */ + STAILQ_CONCAT(&tmp_pkt_queue, &pkt_queue); + + /* + * We've finished making changes to the list. Unlock it + * so the pfil hooks can continue queuing pkt_nodes + */ + mtx_unlock(&siftr_pkt_queue_mtx); + + /* + * We can't hold a mutex whilst calling siftr_process_pkt + * because ALQ might sleep waiting for buffer space. + */ + mtx_unlock(&siftr_pkt_mgr_mtx); + + /* Flush all pkt_nodes to the log file */ + STAILQ_FOREACH_SAFE(pkt_node, + &tmp_pkt_queue, + nodes, + pkt_node_temp) { + siftr_process_pkt(pkt_node); + STAILQ_REMOVE_HEAD(&tmp_pkt_queue, nodes); + free(pkt_node, M_SIFTR_PKTNODE); + } + + KASSERT(STAILQ_EMPTY(&tmp_pkt_queue), + ("SIFTR tmp_pkt_queue not empty after flush") + ); + + mtx_lock(&siftr_pkt_mgr_mtx); + + /* + * If siftr_exit_pkt_manager_thread gets set during the window + * where we are draining the tmp_pkt_queue above, there might + * still be pkts in pkt_queue that need to be drained. + * Allow one further iteration to occur after + * siftr_exit_pkt_manager_thread has been set to ensure + * pkt_queue is completely empty before we kill the thread. + * + * siftr_exit_pkt_manager_thread is set only after the pfil + * hooks have been removed, so only 1 extra iteration + * is needed to drain the queue. + */ + if (siftr_exit_pkt_manager_thread) + draining--; + } + + mtx_unlock(&siftr_pkt_mgr_mtx); + +#if (__FreeBSD_version >= 800000) + /* calls wakeup on this thread's struct thread ptr */ + kthread_exit(); +#else +#if (__FreeBSD_version < 700000) + /* no wakeup given in 6.x so have to do it ourself */ + wakeup(siftr_pkt_manager_proc); +#endif + /* calls wakeup on this thread's struct proc ptr on 7.x */ + kthread_exit(0); +#endif +} + +static uint32_t +hash_pkt(struct mbuf *m, uint32_t offset) +{ + register uint32_t hash = 0; + + while ((m != NULL) && (offset > m->m_len)) { + /* + * The IP packet payload does not start in this mbuf, so + * need to figure out which mbuf it starts in and what offset + * into the mbuf's data region the payload starts at. + */ + offset -= m->m_len; + m = m->m_next; + } + + while (m != NULL) { + /* Ensure there is data in the mbuf */ + if ((m->m_len - offset) > 0) { + hash = hash32_buf( m->m_data + offset, + m->m_len - offset, + hash + ); + } + + m = m->m_next; + offset = 0; + } + + return hash; +} + +/* + * pfil hook that is called for each IPv4 packet making its way through the + * stack in either direction. + * The pfil subsystem holds a non-sleepable mutex somewhere when + * calling our hook function, so we can't sleep at all. + * It's very important to use the M_NOWAIT flag with all function calls + * that support it so that they won't sleep, otherwise you get a panic + */ +static int +siftr_chkpkt( void *arg, + struct mbuf **m, + struct ifnet *ifp, + int dir, + struct inpcb *inp +) +{ + register struct pkt_node *pkt_node = NULL; + register struct ip *ip = NULL; + register struct tcphdr *th = NULL; + register struct tcpcb *tp = NULL; + register unsigned int ip_hl = 0; + register uint8_t inp_locally_locked = 0; + + /* + * I don't think we need m_pullup here because both + * ip_input and ip_output seem to do the heavy lifting + */ + /* *m = m_pullup(*m, sizeof(struct ip)); + if (*m == NULL) + goto ret; */ + + /* Cram the mbuf into an ip packet struct */ + ip = mtod(*m, struct ip *); + + /* Only continue processing if the packet is TCP */ + if(ip->ip_p != IPPROTO_TCP) + goto ret; + + /* + * If a kernel subsystem reinjects packets into the stack, our pfil + * hook will be called multiple times for the same packet. + * Make sure we only process unique packets. + */ + if (m_tag_locate(*m, PACKET_COOKIE_SIFTR, PACKET_TAG_SIFTR, NULL) + != NULL) { + + if(dir == PFIL_IN) + siftr_num_inbound_skipped_pkts_dejavu++; + else + siftr_num_outbound_skipped_pkts_dejavu++; + + goto ret; + } + else { + struct m_tag *tag = m_tag_alloc( PACKET_COOKIE_SIFTR, + PACKET_TAG_SIFTR, + 0, + M_NOWAIT + ); + if (tag == NULL) { + if(dir == PFIL_IN) + siftr_num_inbound_skipped_pkts_malloc++; + else + siftr_num_outbound_skipped_pkts_malloc++; + + goto ret; + } + + m_tag_prepend(*m, tag); + } + + if(dir == PFIL_IN) + siftr_num_inbound_tcp_pkts++; + else + siftr_num_outbound_tcp_pkts++; + + /* + * Create a tcphdr struct starting at the correct offset + * in the IP packet. ip->ip_hl gives the ip header length + * in 4-byte words, so multiply it to get the size in bytes + */ + ip_hl = (ip->ip_hl << 2); + th = (struct tcphdr *)((caddr_t)ip + ip_hl); + + /* + * If the pfil hooks don't provide a pointer to the + * IP control block, we need to find it ourselves and lock it + */ + if (!inp) { + /* Find the corresponding inpcb for this pkt */ + + /* We need the tcbinfo lock */ +#if (__FreeBSD_version >= 700000) + INP_INFO_UNLOCK_ASSERT(_siftrtcbinfo); +#endif + INP_INFO_RLOCK(_siftrtcbinfo); + + if (dir == PFIL_IN) + inp = in_pcblookup_hash(_siftrtcbinfo, + ip->ip_src, + th->th_sport, + ip->ip_dst, + th->th_dport, + 0, + (*m)->m_pkthdr.rcvif + ); + else + inp = in_pcblookup_hash(_siftrtcbinfo, + ip->ip_dst, + th->th_dport, + ip->ip_src, + th->th_sport, + 0, + (*m)->m_pkthdr.rcvif + ); + + /* If we can't find the IP control block, bail */ + if (!inp) { + if(dir == PFIL_IN) + siftr_num_inbound_skipped_pkts_icb++; + else + siftr_num_outbound_skipped_pkts_icb++; + + INP_INFO_RUNLOCK(_siftrtcbinfo); + + goto ret; + } + + /* Acquire the inpcb lock */ + INP_UNLOCK_ASSERT(inp); +#if (__FreeBSD_version >= 701000) + INP_RLOCK(inp); +#else + INP_LOCK(inp); +#endif + INP_INFO_RUNLOCK(_siftrtcbinfo); + + inp_locally_locked = 1; + } + + INP_LOCK_ASSERT(inp); + + pkt_node = malloc(sizeof(struct pkt_node), M_SIFTR_PKTNODE, M_NOWAIT | M_ZERO); + + if (pkt_node == NULL) { + + if(dir == PFIL_IN) + siftr_num_inbound_skipped_pkts_malloc++; + else + siftr_num_outbound_skipped_pkts_malloc++; + + goto inp_unlock; + } + + /* Find the TCP control block that corresponds with this packet */ + tp = intotcpcb(inp); + + /* + * If we can't find the TCP control block (happens occasionaly for a + * packet sent during the shutdown phase of a TCP connection), + * or we're in the timewait state, bail + */ +#if (INP_TIMEWAIT == 0x8) + if (!tp || (inp->inp_vflag & INP_TIMEWAIT)) { +#else + if (!tp || (inp->inp_flags & INP_TIMEWAIT)) { +#endif + if(dir == PFIL_IN) + siftr_num_inbound_skipped_pkts_tcb++; + else + siftr_num_outbound_skipped_pkts_tcb++; + + free(pkt_node, M_SIFTR_PKTNODE); + goto inp_unlock; + } + + /* Fill in pkt_node data */ +#ifdef SIFTR_IPV6 + pkt_node->ip_laddr[3] = inp->inp_laddr.s_addr; + pkt_node->ip_faddr[3] = inp->inp_faddr.s_addr; +#else + *((uint32_t *)pkt_node->ip_laddr) = inp->inp_laddr.s_addr; + *((uint32_t *)pkt_node->ip_faddr) = inp->inp_faddr.s_addr; +#endif + pkt_node->ipver = INP_IPV4; + pkt_node->tcp_localport = inp->inp_lport; + pkt_node->tcp_foreignport = inp->inp_fport; + pkt_node->snd_cwnd = tp->snd_cwnd; + pkt_node->snd_wnd = tp->snd_wnd; + pkt_node->rcv_wnd = tp->rcv_wnd; + pkt_node->snd_bwnd = tp->snd_bwnd; + pkt_node->snd_ssthresh = tp->snd_ssthresh; + pkt_node->snd_scale = tp->snd_scale; + pkt_node->rcv_scale = tp->rcv_scale; + pkt_node->conn_state = tp->t_state; + pkt_node->max_seg_size = tp->t_maxseg; + pkt_node->smoothed_rtt = tp->t_srtt; +#if (__FreeBSD_version >= 700000) + pkt_node->sack_enabled = tp->t_flags & TF_SACK_PERMIT; +#else + pkt_node->sack_enabled = tp->sack_enable; +#endif + pkt_node->flags = tp->t_flags; + pkt_node->rxt_length = tp->t_rxtcur; + pkt_node->snd_buf_hiwater = inp->inp_socket->so_snd.sb_hiwat; + pkt_node->snd_buf_cc = inp->inp_socket->so_snd.sb_cc; + pkt_node->rcv_buf_hiwater = inp->inp_socket->so_rcv.sb_hiwat; + pkt_node->rcv_buf_cc = inp->inp_socket->so_rcv.sb_cc; + pkt_node->sent_inflight_bytes = tp->snd_max - tp->snd_una; + + /* We've finished accessing the tcb so release the lock */ + if (inp_locally_locked) +#if (__FreeBSD_version >= 701000) + INP_RUNLOCK(inp); +#else + INP_UNLOCK(inp); +#endif + + pkt_node->direction = dir; + + /* + * Significantly more accurate than using getmicrotime(), but slower! + * Gives true microsecond resolution at the expense of a hit to + * maximum pps throughput processing when SIFTR is loaded and enabled. + */ + microtime(&(pkt_node->tval)); + + if (siftr_generate_hashes) { + + if ((*m)->m_pkthdr.csum_flags & CSUM_TCP) { + /* + * For outbound packets, the TCP checksum isn't + * calculated yet. This is a problem for our packet + * hashing as the receiver will calc a different hash + * to ours if we don't include the correct TCP checksum + * in the bytes being hashed. To work around this + * problem, we manually calc the TCP checksum here in + * software. We unset the CSUM_TCP flag so the lower + * layers don't recalc it. + */ + (*m)->m_pkthdr.csum_flags &= ~CSUM_TCP; + + /* + * Calculate the TCP checksum in software and assign + * to correct TCP header field, which will follow the + * packet mbuf down the stack. The trick here is that + * tcp_output() sets th->th_sum to the checksum of the + * pseudo header for us already. Because of the nature + * of the checksumming algorithm, we can sum over the + * entire IP payload (i.e. TCP header and data), which + * will include the already calculated pseduo header + * checksum, thus giving us the complete TCP checksum. + * + * To put it in simple terms, if checksum(1,2,3,4)=10, + * then checksum(1,2,3,4,5) == checksum(10,5). + * This property is what allows us to "cheat" and + * checksum only the IP payload which has the TCP + * th_sum field populated with the pseudo header's + * checksum, and not need to futz around checksumming + * pseudo header bytes and TCP header/data in one hit. + * Refer to RFC 1071 for more info. + * + * NB: in_cksum_skip(struct mbuf *m, int len, int skip) + * in_cksum_skip 2nd argument is NOT the number of + * bytes to read from the mbuf at "skip" bytes offset + * from the start of the mbuf (very counter intuitive!). + * The number of bytes to read is calculated internally + * by the function as len-skip i.e. to sum over the IP + * payload (TCP header + data) bytes, it is INCORRECT + * to call the function like this: + * in_cksum_skip(at, ip->ip_len - offset, offset) + * Rather, it should be called like this: + * in_cksum_skip(at, ip->ip_len, offset) + * which means read "ip->ip_len - offset" bytes from + * the mbuf cluster "at" at offset "offset" bytes from + * the beginning of the "at" mbuf's data pointer. + */ + th->th_sum = in_cksum_skip(*m, ip->ip_len, ip_hl); + } + /* + printf("th->th_sum: 0x%04x\n\n", th->th_sum); + nanotime(&start); + */ + + /* + * XXX: Having to calculate the checksum in software and then + * hash over all bytes is really inefficient. Would be nice to + * find a way to create the hash and checksum in the same pass + * over the bytes. + */ + pkt_node->hash = hash_pkt(*m, ip_hl); + + /* + nanotime(&end); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@FreeBSD.ORG Thu Aug 13 16:08:35 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7804D1065673; Thu, 13 Aug 2009 16:08:35 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 667368FC4A; Thu, 13 Aug 2009 16:08:35 +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 n7DG8ZeX006313; Thu, 13 Aug 2009 16:08:35 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DG8ZVm006311; Thu, 13 Aug 2009 16:08:35 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908131608.n7DG8ZVm006311@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 13 Aug 2009 16:08:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196195 - projects/tcp_ffcaia2008_8.x/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 16:08:35 -0000 Author: lstewart Date: Thu Aug 13 16:08:35 2009 New Revision: 196195 URL: http://svn.freebsd.org/changeset/base/196195 Log: Remove a whole lot of cruft that was required to allow the SIFTR code to compile and run on FreeBSD 6, 7 and 8. Any MFC of SIFTR will require changes to the code that replicate the relevant chunks of what this commit removes. Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c Thu Aug 13 16:01:19 2009 (r196194) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/siftr.c Thu Aug 13 16:08:35 2009 (r196195) @@ -61,6 +61,7 @@ #include #include +#include #include #include #include @@ -74,9 +75,7 @@ #include #include #include -#if (__FreeBSD_version >= 800044) #include -#endif #include #include @@ -88,24 +87,13 @@ #include #include -#if (__FreeBSD_version >= 800044) -#include -#endif - #ifdef SIFTR_IPV6 #include #include - -#if (__FreeBSD_version >= 800044) -#include -#endif - #endif /* SIFTR_IPV6 */ #include -#include "siftr_hash.h" - #define MODVERSION "1.2.2" #define HOOK 0 @@ -309,15 +297,7 @@ static struct mtx siftr_pkt_mgr_mtx; static struct thread *siftr_pkt_manager_thr = NULL; -#if (__FreeBSD_version < 800000) -static struct proc *siftr_pkt_manager_proc = NULL; -#endif - -#if (__FreeBSD_version >= 800044) #define _siftrtcbinfo &V_tcbinfo -#else -#define _siftrtcbinfo &tcbinfo -#endif @@ -444,11 +424,7 @@ siftr_process_pkt(struct pkt_node * pkt_ /* Construct an IPv6 log message. */ sprintf(siftr_log_msg, -#if (__FreeBSD_version >= 700000) "%c,0x%08x,%zd.%06ld,%x:%x:%x:%x:%x:%x:%x:%x,%u,%x:%x:%x:%x:%x:%x:%x:%x,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", -#else - "%c,0x%08x,%ld.%06ld,%x:%x:%x:%x:%x:%x:%x:%x,%u,%x:%x:%x:%x:%x:%x:%x:%x,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", -#endif direction[pkt_node->direction], pkt_node->hash, pkt_node->tval.tv_sec, @@ -503,11 +479,7 @@ siftr_process_pkt(struct pkt_node * pkt_ /* Construct an IPv4 log message. */ sprintf(siftr_log_msg, -#if (__FreeBSD_version >= 700000) "%c,0x%08x,%zd.%06ld,%u.%u.%u.%u,%u,%u.%u.%u.%u,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", -#else - "%c,0x%08x,%ld.%06ld,%u.%u.%u.%u,%u,%u.%u.%u.%u,%u,%ld,%ld,%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u\n", -#endif direction[pkt_node->direction], pkt_node->hash, pkt_node->tval.tv_sec, @@ -632,17 +604,8 @@ siftr_pkt_manager_thread(void *arg) mtx_unlock(&siftr_pkt_mgr_mtx); -#if (__FreeBSD_version >= 800000) /* calls wakeup on this thread's struct thread ptr */ kthread_exit(); -#else -#if (__FreeBSD_version < 700000) - /* no wakeup given in 6.x so have to do it ourself */ - wakeup(siftr_pkt_manager_proc); -#endif - /* calls wakeup on this thread's struct proc ptr on 7.x */ - kthread_exit(0); -#endif } static uint32_t @@ -768,9 +731,7 @@ siftr_chkpkt( void *arg, /* Find the corresponding inpcb for this pkt */ /* We need the tcbinfo lock */ -#if (__FreeBSD_version >= 700000) INP_INFO_UNLOCK_ASSERT(_siftrtcbinfo); -#endif INP_INFO_RLOCK(_siftrtcbinfo); if (dir == PFIL_IN) @@ -806,11 +767,7 @@ siftr_chkpkt( void *arg, /* Acquire the inpcb lock */ INP_UNLOCK_ASSERT(inp); -#if (__FreeBSD_version >= 701000) INP_RLOCK(inp); -#else - INP_LOCK(inp); -#endif INP_INFO_RUNLOCK(_siftrtcbinfo); inp_locally_locked = 1; @@ -838,11 +795,7 @@ siftr_chkpkt( void *arg, * packet sent during the shutdown phase of a TCP connection), * or we're in the timewait state, bail */ -#if (INP_TIMEWAIT == 0x8) - if (!tp || (inp->inp_vflag & INP_TIMEWAIT)) { -#else if (!tp || (inp->inp_flags & INP_TIMEWAIT)) { -#endif if(dir == PFIL_IN) siftr_num_inbound_skipped_pkts_tcb++; else @@ -873,11 +826,7 @@ siftr_chkpkt( void *arg, pkt_node->conn_state = tp->t_state; pkt_node->max_seg_size = tp->t_maxseg; pkt_node->smoothed_rtt = tp->t_srtt; -#if (__FreeBSD_version >= 700000) pkt_node->sack_enabled = tp->t_flags & TF_SACK_PERMIT; -#else - pkt_node->sack_enabled = tp->sack_enable; -#endif pkt_node->flags = tp->t_flags; pkt_node->rxt_length = tp->t_rxtcur; pkt_node->snd_buf_hiwater = inp->inp_socket->so_snd.sb_hiwat; @@ -888,11 +837,7 @@ siftr_chkpkt( void *arg, /* We've finished accessing the tcb so release the lock */ if (inp_locally_locked) -#if (__FreeBSD_version >= 701000) INP_RUNLOCK(inp); -#else - INP_UNLOCK(inp); -#endif pkt_node->direction = dir; @@ -985,11 +930,7 @@ siftr_chkpkt( void *arg, inp_unlock: if (inp_locally_locked) -#if (__FreeBSD_version >= 701000) INP_RUNLOCK(inp); -#else - INP_UNLOCK(inp); -#endif ret: /* Returning 0 ensures pfil will not discard the pkt */ @@ -1091,9 +1032,7 @@ siftr_chkpkt6( void *arg, /* Find the the corresponding inpcb for this pkt */ /* We need the tcbinfo lock */ -#if (__FreeBSD_version >= 700000) INP_INFO_UNLOCK_ASSERT(_siftrtcbinfo); -#endif INP_INFO_RLOCK(_siftrtcbinfo); if (dir == PFIL_IN) @@ -1127,11 +1066,7 @@ siftr_chkpkt6( void *arg, } /* Acquire the inpcb lock */ -#if (__FreeBSD_version >= 701000) INP_RLOCK(inp); -#else - INP_LOCK(inp); -#endif INP_INFO_RUNLOCK(_siftrtcbinfo); inp_locally_locked = 1; } @@ -1156,11 +1091,7 @@ siftr_chkpkt6( void *arg, * packet sent during the shutdown phase of a TCP connection), * or we're in the timewait state, bail */ -#if (INP_TIMEWAIT == 0x8) - if (!tp || (inp->inp_vflag & INP_TIMEWAIT)) { -#else if (!tp || (inp->inp_flags & INP_TIMEWAIT)) { -#endif if(dir == PFIL_IN) siftr_num_inbound_skipped_pkts_tcb++; else @@ -1192,11 +1123,7 @@ siftr_chkpkt6( void *arg, pkt_node->conn_state = tp->t_state; pkt_node->max_seg_size = tp->t_maxseg; pkt_node->smoothed_rtt = tp->t_srtt; -#if (__FreeBSD_version >= 700000) pkt_node->sack_enabled = tp->t_flags & TF_SACK_PERMIT; -#else - pkt_node->sack_enabled = tp->sack_enable; -#endif pkt_node->flags = tp->t_flags; pkt_node->rxt_length = tp->t_rxtcur; pkt_node->snd_buf_hiwater = inp->inp_socket->so_snd.sb_hiwat; @@ -1207,11 +1134,7 @@ siftr_chkpkt6( void *arg, /* We've finished accessing the tcb so release the lock */ if (inp_locally_locked) -#if (__FreeBSD_version >= 701000) INP_RUNLOCK(inp); -#else - INP_UNLOCK(inp); -#endif pkt_node->direction = dir; @@ -1231,11 +1154,7 @@ siftr_chkpkt6( void *arg, inp_unlock6: if (inp_locally_locked) -#if (__FreeBSD_version >= 701000) INP_RUNLOCK(inp); -#else - INP_UNLOCK(inp); -#endif ret6: /* Returning 0 ensures pfil will not discard the pkt */ @@ -1363,7 +1282,6 @@ siftr_manage_ops(uint8_t action) siftr_exit_pkt_manager_thread = 0; -#if (__FreeBSD_version >= 800000) ret = kthread_add( &siftr_pkt_manager_thread, NULL, NULL, @@ -1372,27 +1290,13 @@ siftr_manage_ops(uint8_t action) 0, "siftr_pkt_manager_thr" ); -#else - ret = kthread_create( &siftr_pkt_manager_thread, - NULL, - &siftr_pkt_manager_proc, - RFNOWAIT, - 0, - "siftr_pkt_manager_thr" - ); - siftr_pkt_manager_thr = FIRST_THREAD_IN_PROC(siftr_pkt_manager_proc); -#endif siftr_pfil(HOOK); microtime(&tval); sbuf_printf(s, -#if (__FreeBSD_version >= 700000) "enable_time_secs=%zd\tenable_time_usecs=%06ld\tsiftrver=%s\thz=%u\ttcp_rtt_scale=%u\tsysname=%s\tsysver=%u\tipmode=%u\n", -#else - "enable_time_secs=%ld\tenable_time_usecs=%06ld\tsiftrver=%s\thz=%u\ttcp_rtt_scale=%u\tsysname=%s\tsysver=%u\tipmode=%u\n", -#endif tval.tv_sec, tval.tv_usec, MODVERSION, @@ -1430,22 +1334,12 @@ siftr_manage_ops(uint8_t action) wakeup(&wait_for_pkt); /* Wait for the pkt_manager thread to exit */ -#if (__FreeBSD_version >= 800000) msleep( siftr_pkt_manager_thr, &siftr_pkt_mgr_mtx, PWAIT, "thrwait", 0 ); -#else - msleep( siftr_pkt_manager_proc, - &siftr_pkt_mgr_mtx, - PWAIT, - "thrwait", - 0 - ); - siftr_pkt_manager_proc = NULL; -#endif siftr_pkt_manager_thr = NULL; mtx_unlock(&siftr_pkt_mgr_mtx); @@ -1453,11 +1347,7 @@ siftr_manage_ops(uint8_t action) microtime(&tval); sbuf_printf(s, -#if (__FreeBSD_version >= 700000) "disable_time_secs=%zd\tdisable_time_usecs=%06ld\tnum_inbound_tcp_pkts=%u\tnum_outbound_tcp_pkts=%u\ttotal_tcp_pkts=%u\tnum_inbound_skipped_pkts_malloc=%u\tnum_outbound_skipped_pkts_malloc=%u\tnum_inbound_skipped_pkts_mtx=%u\tnum_outbound_skipped_pkts_mtx=%u\tnum_inbound_skipped_pkts_tcb=%u\tnum_outbound_skipped_pkts_tcb=%u\tnum_inbound_skipped_pkts_icb=%u\tnum_outbound_skipped_pkts_icb=%u\ttotal_skipped_tcp_pkts=%u\tflow_list=", -#else - "disable_time_secs=%ld\tdisable_time_usecs=%06ld\tnum_inbound_tcp_pkts=%u\tnum_outbound_tcp_pkts=%u\ttotal_tcp_pkts=%u\tnum_inbound_skipped_pkts_malloc=%u\tnum_outbound_skipped_pkts_malloc=%u\tnum_inbound_skipped_pkts_mtx=%u\tnum_outbound_skipped_pkts_mtx=%u\tnum_inbound_skipped_pkts_tcb=%u\tnum_outbound_skipped_pkts_tcb=%u\tnum_inbound_skipped_pkts_icb=%u\tnum_outbound_skipped_pkts_icb=%u\ttotal_skipped_tcp_pkts=%u\tflow_list=", -#endif tval.tv_sec, tval.tv_usec, siftr_num_inbound_tcp_pkts, From owner-svn-src-projects@FreeBSD.ORG Thu Aug 13 19:47:14 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89381106564A; Thu, 13 Aug 2009 19:47:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 796268FC52; Thu, 13 Aug 2009 19:47:14 +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 n7DJlEsw011193; Thu, 13 Aug 2009 19:47:14 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DJlEo8011192; Thu, 13 Aug 2009 19:47:14 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908131947.n7DJlEo8011192@svn.freebsd.org> From: Warner Losh Date: Thu, 13 Aug 2009 19:47:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196199 - projects/mips/sys/mips/include X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 19:47:14 -0000 Author: imp Date: Thu Aug 13 19:47:13 2009 New Revision: 196199 URL: http://svn.freebsd.org/changeset/base/196199 Log: Use unsigned long instead of unsigned for the integer casts here. The former works for both ILP32 and LP64 programming models, while the latter fails LP64. # uintpr_t is better, but iirc, we can't pollute the name space to use it # I likely need to audit all my uintptr_t changes for that issue... Modified: projects/mips/sys/mips/include/param.h Modified: projects/mips/sys/mips/include/param.h ============================================================================== --- projects/mips/sys/mips/include/param.h Thu Aug 13 17:54:11 2009 (r196198) +++ projects/mips/sys/mips/include/param.h Thu Aug 13 19:47:13 2009 (r196199) @@ -152,10 +152,10 @@ /* * Conversion macros */ -#define mips_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) -#define mips_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) -#define mips_btop(x) ((unsigned)(x) >> PGSHIFT) -#define mips_ptob(x) ((unsigned)(x) << PGSHIFT) +#define mips_round_page(x) ((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1)) +#define mips_trunc_page(x) ((unsigned long)(x) & ~(NBPG-1)) +#define mips_btop(x) ((unsigned long)(x) >> PGSHIFT) +#define mips_ptob(x) ((unsigned long)(x) << PGSHIFT) #define round_page mips_round_page #define trunc_page mips_trunc_page #define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) From owner-svn-src-projects@FreeBSD.ORG Fri Aug 14 16:15:18 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0F5E106568F; Fri, 14 Aug 2009 16:15:18 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A078C8FC41; Fri, 14 Aug 2009 16:15:18 +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 n7EGFIeE041378; Fri, 14 Aug 2009 16:15:18 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7EGFI6i041376; Fri, 14 Aug 2009 16:15:18 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908141615.n7EGFI6i041376@svn.freebsd.org> From: Warner Losh Date: Fri, 14 Aug 2009 16:15:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196215 - projects/mips/sys/mips/include X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Aug 2009 16:15:18 -0000 Author: imp Date: Fri Aug 14 16:15:18 2009 New Revision: 196215 URL: http://svn.freebsd.org/changeset/base/196215 Log: (u_int) is the wrong type here. Use unsigned long instead, even though that's only less wrong... # This gets the kernel building again to the point it was at before # the last IFC for the OCTEON1 kernel config. Modified: projects/mips/sys/mips/include/param.h Modified: projects/mips/sys/mips/include/param.h ============================================================================== --- projects/mips/sys/mips/include/param.h Fri Aug 14 13:26:50 2009 (r196214) +++ projects/mips/sys/mips/include/param.h Fri Aug 14 16:15:18 2009 (r196215) @@ -83,7 +83,7 @@ * any desired pointer type. */ #define _ALIGNBYTES 7 -#define _ALIGN(p) (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) +#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) @@ -93,7 +93,7 @@ * This does not reflect the optimal alignment, just the possibility * (within reasonable limits). */ -#define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof (t) - 1)) == 0) +#define ALIGNED_POINTER(p, t) ((((unsigned long)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 01:03:14 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 446461065672; Sat, 15 Aug 2009 01:03:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19D648FC41; Sat, 15 Aug 2009 01:03:14 +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 n7F13Dgm053401; Sat, 15 Aug 2009 01:03:13 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F13Dd2053400; Sat, 15 Aug 2009 01:03:13 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908150103.n7F13Dd2053400@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 01:03:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196236 - in projects/mips/sys/mips: malta octeon1 sentry5 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 01:03:14 -0000 Author: imp Date: Sat Aug 15 01:03:13 2009 New Revision: 196236 URL: http://svn.freebsd.org/changeset/base/196236 Log: Fix style error replicated multiple times. Move to mips_bus_space_generic for octeon obio impl. Modified: projects/mips/sys/mips/malta/obio.c projects/mips/sys/mips/octeon1/obio.c projects/mips/sys/mips/sentry5/obio.c Modified: projects/mips/sys/mips/malta/obio.c ============================================================================== --- projects/mips/sys/mips/malta/obio.c Sat Aug 15 00:04:12 2009 (r196235) +++ projects/mips/sys/mips/malta/obio.c Sat Aug 15 01:03:13 2009 (r196236) @@ -63,20 +63,18 @@ int obio_attach(device_t); * A bit tricky and hackish. Since we need OBIO to rely * on PCI we make it pseudo-pci device. But there should * be only one such device, so we use this static flag - * to prevent false positives on every realPCI device probe. + * to prevent false positives on every real PCI device probe. */ static int have_one = 0; int obio_probe(device_t dev) { - if(!have_one) - { + if (!have_one) { have_one = 1; return 0; } - else - return (ENXIO); + return (ENXIO); } int Modified: projects/mips/sys/mips/octeon1/obio.c ============================================================================== --- projects/mips/sys/mips/octeon1/obio.c Sat Aug 15 00:04:12 2009 (r196235) +++ projects/mips/sys/mips/octeon1/obio.c Sat Aug 15 01:03:13 2009 (r196236) @@ -60,22 +60,19 @@ int obio_probe(device_t); int obio_attach(device_t); /* - * We need only one obio. - * Any other device hanging off of it, shouldn't cause multiple of - * these to be found. + * We need only one obio. Any other device hanging off of it, + * shouldn't cause multiple of these to be found. */ static int have_one = 0; int obio_probe(device_t dev) { - if(!have_one) - { + if (!have_one) { have_one = 1; return 0; } - else - return (ENXIO); + return (ENXIO); } int @@ -83,7 +80,7 @@ obio_attach(device_t dev) { struct obio_softc *sc = device_get_softc(dev); - sc->oba_st = MIPS_BUS_SPACE_IO; + sc->oba_st = mips_bus_space_generic; sc->oba_addr = OCTEON_UART0ADR; sc->oba_size = 0x10000; sc->oba_rman.rm_type = RMAN_ARRAY; Modified: projects/mips/sys/mips/sentry5/obio.c ============================================================================== --- projects/mips/sys/mips/sentry5/obio.c Sat Aug 15 00:04:12 2009 (r196235) +++ projects/mips/sys/mips/sentry5/obio.c Sat Aug 15 01:03:13 2009 (r196236) @@ -72,13 +72,11 @@ static int have_one = 0; int obio_probe(device_t dev) { - if(!have_one) - { + if (!have_one) { have_one = 1; return 0; } - else - return (ENXIO); + return (ENXIO); } int From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 02:03:42 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A02D106568C; Sat, 15 Aug 2009 02:03:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC0378FC4D; Sat, 15 Aug 2009 02:03:41 +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 n7F23fhc054633; Sat, 15 Aug 2009 02:03:41 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F23fZU054631; Sat, 15 Aug 2009 02:03:41 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908150203.n7F23fZU054631@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 02:03:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196237 - projects/mips/sys/mips/octeon1 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 02:03:42 -0000 Author: imp Date: Sat Aug 15 02:03:41 2009 New Revision: 196237 URL: http://svn.freebsd.org/changeset/base/196237 Log: Include Octeon specific registers since we mess with them here... Modified: projects/mips/sys/mips/octeon1/uart_dev_oct16550.c Modified: projects/mips/sys/mips/octeon1/uart_dev_oct16550.c ============================================================================== --- projects/mips/sys/mips/octeon1/uart_dev_oct16550.c Sat Aug 15 01:03:13 2009 (r196236) +++ projects/mips/sys/mips/octeon1/uart_dev_oct16550.c Sat Aug 15 02:03:41 2009 (r196237) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include "uart_if.h" From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 02:04:10 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F3CE10656A7; Sat, 15 Aug 2009 02:04:10 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D1838FC6B; Sat, 15 Aug 2009 02:04:10 +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 n7F24939054680; Sat, 15 Aug 2009 02:04:09 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F2497N054678; Sat, 15 Aug 2009 02:04:09 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908150204.n7F2497N054678@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 02:04:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196238 - projects/mips/sys/dev/ic X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 02:04:10 -0000 Author: imp Date: Sat Aug 15 02:04:09 2009 New Revision: 196238 URL: http://svn.freebsd.org/changeset/base/196238 Log: Add a couple of extra defines needed by the octeon uart. Not sure this is the right place... Modified: projects/mips/sys/dev/ic/ns16550.h Modified: projects/mips/sys/dev/ic/ns16550.h ============================================================================== --- projects/mips/sys/dev/ic/ns16550.h Sat Aug 15 02:03:41 2009 (r196237) +++ projects/mips/sys/dev/ic/ns16550.h Sat Aug 15 02:04:09 2009 (r196238) @@ -52,6 +52,7 @@ #define REG_IIR com_iir #define IIR_IMASK 0xf #define IIR_RXTOUT 0xc +#define IIR_BUSY 0x7 #define IIR_RLS 0x6 #define IIR_RXRDY 0x4 #define IIR_TXRDY 0x2 @@ -181,6 +182,10 @@ #define com_xoff1 6 /* XOFF 1 character (R/W) */ #define com_xoff2 7 /* XOFF 2 character (R/W) */ +#define com_usr 39 /* Octeon 16750/16550 Uart Status Reg */ +#define REG_USR com_usr +#define USR_TXFIFO_NOTFULL 2 /* Uart TX FIFO Not full */ + /* 16950 register #1. Access enabled by ACR[7]. Also requires !LCR[7]. */ #define com_asr 1 /* additional status register (R[0-7]/W[0-1]) */ From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 04:27:57 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC752106568B; Sat, 15 Aug 2009 04:27:57 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAB948FC41; Sat, 15 Aug 2009 04:27:57 +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 n7F4RvPU057823; Sat, 15 Aug 2009 04:27:57 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F4RviE057821; Sat, 15 Aug 2009 04:27:57 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908150427.n7F4RviE057821@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 04:27:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196239 - projects/mips/sys/conf X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 04:27:57 -0000 Author: imp Date: Sat Aug 15 04:27:57 2009 New Revision: 196239 URL: http://svn.freebsd.org/changeset/base/196239 Log: New script to produce mips64 ELF64 binaries. Added: projects/mips/sys/conf/ldscript.mips.mips64 Added: projects/mips/sys/conf/ldscript.mips.mips64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/mips/sys/conf/ldscript.mips.mips64 Sat Aug 15 04:27:57 2009 (r196239) @@ -0,0 +1,303 @@ +/*- + * Copyright (c) 2001, 2004, 2008, Juniper Networks, Inc. + * 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. + * 3. Neither the name of the Juniper Networks, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS 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 JUNIPER NETWORKS 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. + * + * JNPR: ldscript.mips,v 1.3 2006/10/11 06:12:04 + * $FreeBSD: projects/mips/sys/conf/ldscript.mips 191079 2009-04-14 22:53:22Z gonzo $ + */ + +OUTPUT_FORMAT("elf64-tradbigmips", "elf64-tradbigmips", + "elf64-tradlittlemips") + +OUTPUT_ARCH(mips) +ENTRY(_start) +SEARCH_DIR(/usr/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; +PROVIDE (_DYNAMIC = 0); +*/ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = KERNLOADADDR + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t.*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t.*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r.*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r.*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d.*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d.*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.sdata : + { + *(.rel.sdata) + *(.rel.sdata.*) + *(.rel.gnu.linkonce.s.*) + } + .rela.sdata : + { + *(.rela.sdata) + *(.rela.sdata.*) + *(.rela.gnu.linkonce.s.*) + } + .rel.sbss : + { + *(.rel.sbss) + *(.rel.sbss.*) + *(.rel.gnu.linkonce.sb.*) + } + .rela.sbss : + { + *(.rela.sbss) + *(.rela.sbss.*) + *(.rel.gnu.linkonce.sb.*) + } + .rel.sdata2 : + { + *(.rel.sdata2) + *(.rel.sdata2.*) + *(.rel.gnu.linkonce.s2.*) + } + .rela.sdata2 : + { + *(.rela.sdata2) + *(.rela.sdata2.*) + *(.rela.gnu.linkonce.s2.*) + } + .rel.sbss2 : + { + *(.rel.sbss2) + *(.rel.sbss2.*) + *(.rel.gnu.linkonce.sb2.*) + } + .rela.sbss2 : + { + *(.rela.sbss2) + *(.rela.sbss2.*) + *(.rela.gnu.linkonce.sb2.*) + } + .rel.bss : + { + *(.rel.bss) + *(.rel.bss.*) + *(.rel.gnu.linkonce.b.*) + } + .rela.bss : + { + *(.rela.bss) + *(.rela.bss.*) + *(.rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0x1000000 + .text : + { + *(.trap) + *(.text) + *(.text.*) + *(.stub) + /* .gnu.warning sections are handled specially by elf64.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t.*) + } =0x1000000 + .fini : + { + KEEP (*(.fini)) + } =0x1000000 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .reginfo : { *(.reginfo) } + .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } + .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } + . = ALIGN(0x2000) + (. & (0x2000 - 1)); + .data : + { + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + .eh_frame : { KEEP (*(.eh_frame)) } + .gcc_except_table : { *(.gcc_except_table) } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .plt : { *(.plt) } + _gp = ALIGN(16) + 0x7ff0; + .got : { *(.got.plt) *(.got) } + .dynamic : { *(.dynamic) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : + { + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .sbss : + { + PROVIDE (__sbss_start = .); + PROVIDE (___sbss_start = .); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + PROVIDE (__sbss_end = .); + PROVIDE (___sbss_end = .); + } + .bss : + { + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(64 / 8); + } + . = ALIGN(64 / 8); + _end = .; + PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* These must appear regardless of . */ +} From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 04:29:18 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E93C5106564A; Sat, 15 Aug 2009 04:29:18 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D93928FC16; Sat, 15 Aug 2009 04:29:18 +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 n7F4TIK0057880; Sat, 15 Aug 2009 04:29:18 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F4TId2057878; Sat, 15 Aug 2009 04:29:18 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908150429.n7F4TId2057878@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 04:29:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196240 - projects/mips/sys/mips/conf X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 04:29:19 -0000 Author: imp Date: Sat Aug 15 04:29:18 2009 New Revision: 196240 URL: http://svn.freebsd.org/changeset/base/196240 Log: Use new ldscript.mips.mips64 Also, declare this to be a 64-bit target. We get to the final link now and die in the linker script.. Modified: projects/mips/sys/mips/conf/OCTEON1 Modified: projects/mips/sys/mips/conf/OCTEON1 ============================================================================== --- projects/mips/sys/mips/conf/OCTEON1 Sat Aug 15 04:27:57 2009 (r196239) +++ projects/mips/sys/mips/conf/OCTEON1 Sat Aug 15 04:29:18 2009 (r196240) @@ -22,10 +22,12 @@ cpu CPU_MIPS4KC ident OCTEON1 makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" +makeoptions LDSCRIPT_NAME= ldscript.mips.mips64 # Don't build any modules yet. makeoptions MODULES_OVERRIDE="" makeoptions TARGET_BIG_ENDIAN=defined +makeoptions TARGET_64BIT=defined options KERNVIRTADDR=0x80100000 include "../octeon1/std.octeon1" From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 08:39:55 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DD4E106568B; Sat, 15 Aug 2009 08:39:55 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 42B1E8FC52; Sat, 15 Aug 2009 08:39:55 +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 n7F8dtt1062613; Sat, 15 Aug 2009 08:39:55 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7F8dtXR062612; Sat, 15 Aug 2009 08:39:55 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <200908150839.n7F8dtXR062612@svn.freebsd.org> From: Peter Holm Date: Sat, 15 Aug 2009 08:39:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196241 - projects/stress2/misc X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 08:39:55 -0000 Author: pho Date: Sat Aug 15 08:39:54 2009 New Revision: 196241 URL: http://svn.freebsd.org/changeset/base/196241 Log: Added a test scenario for when a UFS node is truncated to the zero length, which could cause kernel memory exhaustion. Fixed in r196206. Added: projects/stress2/misc/truncate.sh (contents, props changed) Added: projects/stress2/misc/truncate.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/stress2/misc/truncate.sh Sat Aug 15 08:39:54 2009 (r196241) @@ -0,0 +1,95 @@ +#!/bin/sh + +# +# Copyright (c) 2009 Peter Holm +# 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$ +# + +# Test high water mark for freeblks + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > truncate.c +cc -o truncate -Wall -O2 truncate.c +rm -f truncate.c +[ -d $RUNDIR ] || mkdir -p $RUNDIR +cd $RUNDIR + +/tmp/truncate + +rm -f /tmp/truncate +exit 0 +EOF +#include +#include +#include +#include +#include +#include + +#define SIZ 512 +char buf[SIZ]; + +void +test(void) +{ + int fd[10], i, j; + char name[128]; + + for (j = 0; j < 10; j++) { + sprintf(name, "%05d.%05d", getpid(), j); + if ((fd[j] = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666)) == -1) + err(1, name); + unlink(name); + } + + for (i = 0; i < 100000; i++) { + for (j = 0; j < 10; j++) { + if (write(fd[j], buf, 2) != 2) + err(1, "write"); + if (ftruncate(fd[j], 0) == -1) + err(1, "ftruncate"); + } + } + + exit(0); +} +int +main(int argc, char **argv) +{ + int i, status; + + for (i = 0; i < 20; i++) { + if (fork() == 0) + test(); + } + for (i = 0; i < 20; i++) + wait(&status); + + return (0); +} From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 19:43:16 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 45E8E106568C; Sat, 15 Aug 2009 19:43:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 363E28FC4B; Sat, 15 Aug 2009 19:43:16 +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 n7FJhGqL084630; Sat, 15 Aug 2009 19:43:16 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FJhGvg084628; Sat, 15 Aug 2009 19:43:16 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908151943.n7FJhGvg084628@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 19:43:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196258 - projects/mips/sys/conf X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 19:43:16 -0000 Author: imp Date: Sat Aug 15 19:43:15 2009 New Revision: 196258 URL: http://svn.freebsd.org/changeset/base/196258 Log: Pick an arbitrary address to load the kernel at. 1MB seems as good as any other. Modified: projects/mips/sys/conf/ldscript.mips.mips64 Modified: projects/mips/sys/conf/ldscript.mips.mips64 ============================================================================== --- projects/mips/sys/conf/ldscript.mips.mips64 Sat Aug 15 18:56:56 2009 (r196257) +++ projects/mips/sys/conf/ldscript.mips.mips64 Sat Aug 15 19:43:15 2009 (r196258) @@ -43,7 +43,7 @@ PROVIDE (_DYNAMIC = 0); SECTIONS { /* Read-only sections, merged into text segment: */ - . = KERNLOADADDR + SIZEOF_HEADERS; + . = 0x80100000 + SIZEOF_HEADERS; .interp : { *(.interp) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 19:48:14 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7EA3106568C; Sat, 15 Aug 2009 19:48:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D85918FC5A; Sat, 15 Aug 2009 19:48:14 +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 n7FJmEQQ084901; Sat, 15 Aug 2009 19:48:14 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FJmEVD084899; Sat, 15 Aug 2009 19:48:14 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908151948.n7FJmEVD084899@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 19:48:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196259 - projects/mips/sys/mips/octeon1 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 19:48:15 -0000 Author: imp Date: Sat Aug 15 19:48:14 2009 New Revision: 196259 URL: http://svn.freebsd.org/changeset/base/196259 Log: The UART device infrasturcture wants these defined. Define them just like we do in Malta. We may want to look at consolidating things because *ALL* mips will *ALWAYS* be memory mapped. The only wrinkle is that the tag may need to be a custom one (see endian issues with the Atheros port for one example). Modified: projects/mips/sys/mips/octeon1/uart_cpu_octeonusart.c Modified: projects/mips/sys/mips/octeon1/uart_cpu_octeonusart.c ============================================================================== --- projects/mips/sys/mips/octeon1/uart_cpu_octeonusart.c Sat Aug 15 19:43:15 2009 (r196258) +++ projects/mips/sys/mips/octeon1/uart_cpu_octeonusart.c Sat Aug 15 19:48:14 2009 (r196259) @@ -50,6 +50,9 @@ __FBSDID("$FreeBSD$"); #include +bus_space_tag_t uart_bus_space_io; +bus_space_tag_t uart_bus_space_mem; + extern struct uart_class uart_oct16550_class; extern struct uart_ops octeon_usart_ops; extern struct bus_space octeon_bs_tag; @@ -80,5 +83,8 @@ uart_cpu_getdev(int devtype, struct uart di->bas.bsh = OCTEON_UART0ADR; uart_getenv(devtype, di, class); + + uart_bus_space_io = NULL; + uart_bus_space_mem = mips_bus_space_generic; return (0); } From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 21:42:05 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42DF0106568B; Sat, 15 Aug 2009 21:42:05 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 326598FC41; Sat, 15 Aug 2009 21:42:05 +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 n7FLg5FT089738; Sat, 15 Aug 2009 21:42:05 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FLg5Ut089736; Sat, 15 Aug 2009 21:42:05 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908152142.n7FLg5Ut089736@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 21:42:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196262 - projects/mips/sys/mips/octeon1 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 21:42:05 -0000 Author: imp Date: Sat Aug 15 21:42:04 2009 New Revision: 196262 URL: http://svn.freebsd.org/changeset/base/196262 Log: First cut at a platform_start. It is likely wrong, but it is better than nothing :) Modified: projects/mips/sys/mips/octeon1/octeon_machdep.c Modified: projects/mips/sys/mips/octeon1/octeon_machdep.c ============================================================================== --- projects/mips/sys/mips/octeon1/octeon_machdep.c Sat Aug 15 21:37:16 2009 (r196261) +++ projects/mips/sys/mips/octeon1/octeon_machdep.c Sat Aug 15 21:42:04 2009 (r196262) @@ -29,20 +29,57 @@ __FBSDID("$FreeBSD$"); #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include #include #include #include #include -#include +#include +#include +#include +#include #include +#include +#include +#include #if defined(__mips_n64) - #define MAX_APP_DESC_ADDR 0xffffffffafffffff +#define MAX_APP_DESC_ADDR 0xffffffffafffffff #else - #define MAX_APP_DESC_ADDR 0xafffffff +#define MAX_APP_DESC_ADDR 0xafffffff #endif +extern int *edata; +extern int *end; + /* * Perform a board-level soft-reset. @@ -625,16 +662,79 @@ void ciu_enable_interrupts (int core_num octeon_set_interrupts(cpu_status_bits); } +void +platform_start(__register_t a0, __register_t a1, + __register_t a2 __unused, __register_t a3 __unused) +{ + uint64_t platform_counter_freq; + vm_offset_t kernend; + int argc = a0; + char **argv = (char **)a1; + int i, mem; + + /* clear the BSS and SBSS segments */ + kernend = round_page((vm_offset_t)&end); + memset(&edata, 0, kernend - (vm_offset_t)(&edata)); -extern void mips_platform_init(void); - -void mips_platform_init (void) -{ octeon_ciu_reset(); octeon_uart_write_string(0, "\nPlatform Starting"); -} - +/* From here on down likely is bogus */ + /* + * Looking for mem=XXM argument + */ + mem = 0; /* Just something to start with */ + for (i=0; i < argc; i++) { + if (strncmp(argv[i], "mem=", 4) == 0) { + mem = strtol(argv[i] + 4, NULL, 0); + break; + } + } + + bootverbose = 1; + if (mem > 0) + realmem = btoc(mem << 20); + else + realmem = btoc(32 << 20); + + for (i = 0; i < 10; i++) { + phys_avail[i] = 0; + } + + /* phys_avail regions are in bytes */ + phys_avail[0] = MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); + phys_avail[1] = ctob(realmem); + + physmem = realmem; + + /* + * ns8250 uart code uses DELAY so ticker should be inititalized + * before cninit. And tick_init_params refers to hz, so * init_param1 + * should be called first. + */ + init_param1(); + /* TODO: parse argc,argv */ + platform_counter_freq = 330000000UL; /* XXX: from idt */ + mips_timer_init_params(platform_counter_freq, 1); + cninit(); + /* Panic here, after cninit */ + if (mem == 0) + panic("No mem=XX parameter in arguments"); + + printf("cmd line: "); + for (i=0; i < argc; i++) + printf("%s ", argv[i]); + printf("\n"); + + init_param2(physmem); + mips_cpu_init(); + pmap_bootstrap(); + mips_proc0_init(); + mutex_init(); +#ifdef DDB + kdb_init(); +#endif +} /* **************************************************************************************** From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 22:45:46 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA125106568B; Sat, 15 Aug 2009 22:45:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C0B378FC57; Sat, 15 Aug 2009 22:45:46 +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 n7FMjk9D092345; Sat, 15 Aug 2009 22:45:46 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FMjk0t092343; Sat, 15 Aug 2009 22:45:46 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908152245.n7FMjk0t092343@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 22:45:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196264 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 22:45:47 -0000 Author: imp Date: Sat Aug 15 22:45:46 2009 New Revision: 196264 URL: http://svn.freebsd.org/changeset/base/196264 Log: (1) Some CPUs have a range to map I/O cyces on the pci bus. So allow them to work by allowding the nexus to assign ports. (2) Remove some Octeon junk that shouldn't be necessary. Submitted by: neel@ (#1) for SB1 port. Modified: projects/mips/sys/mips/mips/nexus.c Modified: projects/mips/sys/mips/mips/nexus.c ============================================================================== --- projects/mips/sys/mips/mips/nexus.c Sat Aug 15 22:26:26 2009 (r196263) +++ projects/mips/sys/mips/mips/nexus.c Sat Aug 15 22:45:46 2009 (r196264) @@ -77,6 +77,7 @@ struct nexus_device { static struct rman irq_rman; static struct rman mem_rman; +static struct rman port_rman; static struct resource * nexus_alloc_resource(device_t, device_t, int, int *, u_long, @@ -160,6 +161,21 @@ nexus_probe(device_t dev) panic("%s: mem_rman", __func__); } + /* + * MIPS has no concept of the x86 I/O address space but some cpus + * provide a memory mapped window to access the PCI I/O BARs. + */ + port_rman.rm_start = 0; +#ifdef PCI_IOSPACE_SIZE + port_rman.rm_end = PCI_IOSPACE_SIZE - 1; +#endif + port_rman.rm_type = RMAN_ARRAY; + port_rman.rm_descr = "I/O ports"; + if (rman_init(&port_rman) != 0 || + rman_manage_region(&port_rman, 0, port_rman.rm_end) != 0) + panic("%s: port_rman", __func__); + + return (0); } @@ -225,6 +241,7 @@ nexus_print_all_resources(device_t dev) retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx"); retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); + retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); return (retval); } @@ -345,6 +362,9 @@ nexus_alloc_resource(device_t bus, devic case SYS_RES_MEMORY: rm = &mem_rman; break; + case SYS_RES_IOPORT: + rm = &port_rman; + break; default: printf("%s: unknown resource type %d\n", __func__, type); return (0); @@ -374,9 +394,6 @@ static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { -#ifdef TARGET_OCTEON - uint64_t temp; -#endif /* * If this is a memory resource, track the direct mapping * in the uncached MIPS KSEG1 segment. @@ -394,13 +411,7 @@ nexus_activate_resource(device_t bus, de rman_set_virtual(r, vaddr); rman_set_bustag(r, mips_bus_space_generic); -#ifdef TARGET_OCTEON - temp = 0x0000000000000000; - temp |= (uint32_t)vaddr; - rman_set_bushandle(r, (bus_space_handle_t)temp); -#else rman_set_bushandle(r, (bus_space_handle_t)vaddr); -#endif } return (rman_activate_resource(r)); @@ -481,6 +492,12 @@ static int nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + vm_offset_t va; + + if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { + va = (vm_offset_t)rman_get_virtual(r); + pmap_unmapdev(va, rman_get_size(r)); + } return (rman_deactivate_resource(r)); } From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 22:48:10 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3DF71065698; Sat, 15 Aug 2009 22:48:09 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E360F8FC69; Sat, 15 Aug 2009 22:48:09 +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 n7FMm94V092432; Sat, 15 Aug 2009 22:48:09 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FMm94E092430; Sat, 15 Aug 2009 22:48:09 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908152248.n7FMm94E092430@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 22:48:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196265 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 22:48:10 -0000 Author: imp Date: Sat Aug 15 22:48:09 2009 New Revision: 196265 URL: http://svn.freebsd.org/changeset/base/196265 Log: Various 32/64-bit confusion cleanups. Modified: projects/mips/sys/mips/mips/trap.c Modified: projects/mips/sys/mips/mips/trap.c ============================================================================== --- projects/mips/sys/mips/mips/trap.c Sat Aug 15 22:45:46 2009 (r196264) +++ projects/mips/sys/mips/mips/trap.c Sat Aug 15 22:48:09 2009 (r196265) @@ -98,7 +98,6 @@ __FBSDID("$FreeBSD$"); #ifdef TRAP_DEBUG int trap_debug = 1; - #endif extern unsigned onfault_table[]; @@ -251,7 +250,7 @@ extern void MipsSwitchFPState(struct thr extern void MipsFPTrap(u_int, u_int, u_int); u_int trap(struct trapframe *); -u_int MipsEmulateBranch(struct trapframe *, int, int, u_int); +u_int MipsEmulateBranch(struct trapframe *, uintptr_t, int, uintptr_t); #define KERNLAND(x) ((int)(x) < 0) #define DELAYBRANCH(x) ((int)(x) < 0) @@ -260,7 +259,6 @@ u_int MipsEmulateBranch(struct trapframe * kdbpeekD(addr) - skip one word starting at 'addr', then read the second word */ #define kdbpeekD(addr) kdbpeek(((int *)(addr)) + 1) -int rrs_debug = 0; /* * MIPS load/store access type @@ -305,8 +303,7 @@ extern char *syscallnames[]; * p->p_addr->u_pcb.pcb_onfault is set, otherwise, return old pc. */ u_int -trap(trapframe) - struct trapframe *trapframe; +trap(struct trapframe *trapframe) { int type, usermode; int i = 0; @@ -848,7 +845,7 @@ dofault: case T_BREAK + T_USER: { - unsigned int va, instr; + uintptr_t va, instr; /* compute address of break instruction */ va = trapframe->pc; @@ -881,13 +878,13 @@ dofault: case T_IWATCH + T_USER: case T_DWATCH + T_USER: { - unsigned int va; + uintptr_t va; /* compute address of trapped instruction */ va = trapframe->pc; if (DELAYBRANCH(trapframe->cause)) va += sizeof(int); - printf("watch exception @ 0x%x\n", va); + printf("watch exception @ %p\n", (void *)va); i = SIGTRAP; addr = va; break; @@ -895,7 +892,7 @@ dofault: case T_TRAP + T_USER: { - unsigned int va, instr; + uintptr_t va, instr; struct trapframe *locr0 = td->td_frame; /* compute address of trap instruction */ @@ -1090,26 +1087,26 @@ trapDump(char *msg) * Return the resulting PC as if the branch was executed. */ u_int -MipsEmulateBranch(struct trapframe *framePtr, int instPC, int fpcCSR, - u_int instptr) +MipsEmulateBranch(struct trapframe *framePtr, uintptr_t instPC, int fpcCSR, + uintptr_t instptr) { InstFmt inst; register_t *regsPtr = (register_t *) framePtr; - unsigned retAddr = 0; + uintptr_t retAddr = 0; int condition; #define GetBranchDest(InstPtr, inst) \ - ((unsigned)InstPtr + 4 + ((short)inst.IType.imm << 2)) + (InstPtr + 4 + ((short)inst.IType.imm << 2)) if (instptr) { if (instptr < MIPS_KSEG0_START) - inst.word = fuword((void *)instptr); + inst.word = fuword32((void *)instptr); else inst = *(InstFmt *) instptr; } else { if ((vm_offset_t)instPC < MIPS_KSEG0_START) - inst.word = fuword((void *)instPC); + inst.word = fuword32((void *)instPC); else inst = *(InstFmt *) instPC; } @@ -1249,7 +1246,7 @@ MipsEmulateBranch(struct trapframe *fram */ #define MIPS_END_OF_FUNCTION(ins) ((ins) == 0x03e00008) /* forward */ -char *fn_name(unsigned addr); +static char *fn_name(uintptr_t addr); /* * Print a stack backtrace. @@ -1264,7 +1261,7 @@ void stacktrace_subr(struct trapframe *regs, int (*printfn) (const char *,...)) { InstFmt i; - unsigned a0, a1, a2, a3, pc, sp, fp, ra, va, subr; + uintptr_t a0, a1, a2, a3, pc, sp, fp, ra, va, subr; unsigned instr, mask; unsigned int frames = 0; int more, stksize; @@ -1291,6 +1288,7 @@ loop: goto finish; /* XXX */ } /* check for bad SP: could foul up next frame */ + /*XXX MIPS64 bad: this hard-coded SP is lame */ if (sp & 3 || sp < 0x80000000) { (*printfn) ("SP 0x%x: not in kernel\n", sp); ra = 0; @@ -1300,7 +1298,7 @@ loop: #define Between(x, y, z) \ ( ((x) <= (y)) && ((y) < (z)) ) #define pcBetween(a,b) \ - Between((unsigned)a, pc, (unsigned)b) + Between((uintptr_t)a, pc, (uintptr_t)b) /* * Check for current PC in exception handler code that don't have a @@ -1308,30 +1306,31 @@ loop: * on relative ordering of functions in exception.S, swtch.S. */ if (pcBetween(MipsKernGenException, MipsUserGenException)) - subr = (unsigned)MipsKernGenException; + subr = (uintptr_t)MipsKernGenException; else if (pcBetween(MipsUserGenException, MipsKernIntr)) - subr = (unsigned)MipsUserGenException; + subr = (uintptr_t)MipsUserGenException; else if (pcBetween(MipsKernIntr, MipsUserIntr)) - subr = (unsigned)MipsKernIntr; + subr = (uintptr_t)MipsKernIntr; else if (pcBetween(MipsUserIntr, MipsTLBInvalidException)) - subr = (unsigned)MipsUserIntr; + subr = (uintptr_t)MipsUserIntr; else if (pcBetween(MipsTLBInvalidException, MipsKernTLBInvalidException)) - subr = (unsigned)MipsTLBInvalidException; + subr = (uintptr_t)MipsTLBInvalidException; else if (pcBetween(MipsKernTLBInvalidException, MipsUserTLBInvalidException)) - subr = (unsigned)MipsKernTLBInvalidException; + subr = (uintptr_t)MipsKernTLBInvalidException; else if (pcBetween(MipsUserTLBInvalidException, MipsTLBMissException)) - subr = (unsigned)MipsUserTLBInvalidException; + subr = (uintptr_t)MipsUserTLBInvalidException; else if (pcBetween(cpu_switch, MipsSwitchFPState)) - subr = (unsigned)cpu_switch; + subr = (uintptr_t)cpu_switch; else if (pcBetween(_locore, _locoreEnd)) { - subr = (unsigned)_locore; + subr = (uintptr_t)_locore; ra = 0; goto done; } /* check for bad PC */ - if (pc & 3 || pc < (unsigned)0x80000000 || pc >= (unsigned)edata) { + /*XXX MIPS64 bad: These hard coded constants are lame */ + if (pc & 3 || pc < (uintptr_t)0x80000000 || pc >= (uintptr_t)edata) { (*printfn) ("PC 0x%x: not in kernel\n", pc); ra = 0; goto done; @@ -1535,8 +1534,8 @@ static struct { /* * Map a function address to a string name, if known; or a hex string. */ -char * -fn_name(unsigned addr) +static char * +fn_name(uintptr_t addr) { static char buf[17]; int i = 0; @@ -1557,7 +1556,7 @@ fn_name(unsigned addr) for (i = 0; names[i].name; i++) if (names[i].addr == (void *)addr) return (names[i].name); - sprintf(buf, "%x", addr); + sprintf(buf, "%jx", (uintmax_t)addr); return (buf); } From owner-svn-src-projects@FreeBSD.ORG Sat Aug 15 22:51:11 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC3FE106568C; Sat, 15 Aug 2009 22:51:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC3FA8FC4D; Sat, 15 Aug 2009 22:51:11 +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 n7FMpBPu092529; Sat, 15 Aug 2009 22:51:11 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7FMpBJQ092527; Sat, 15 Aug 2009 22:51:11 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200908152251.n7FMpBJQ092527@svn.freebsd.org> From: Warner Losh Date: Sat, 15 Aug 2009 22:51:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196266 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2009 22:51:11 -0000 Author: imp Date: Sat Aug 15 22:51:11 2009 New Revision: 196266 URL: http://svn.freebsd.org/changeset/base/196266 Log: (1) Fix a few 32/64-bit bugs. (2) Also, always allocate 2 pages for the stack to optimize TLB usage. Submitted by: neel@ (2) Modified: projects/mips/sys/mips/mips/machdep.c Modified: projects/mips/sys/mips/mips/machdep.c ============================================================================== --- projects/mips/sys/mips/mips/machdep.c Sat Aug 15 22:48:09 2009 (r196265) +++ projects/mips/sys/mips/mips/machdep.c Sat Aug 15 22:51:11 2009 (r196266) @@ -104,6 +104,7 @@ SYSCTL_STRING(_hw, HW_MODEL, model, CTLF int cold = 1; long realmem = 0; +long Maxmem = 0; int cpu_clock = MIPS_DEFAULT_HZ; SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD, &cpu_clock, 0, "CPU instruction clock rate"); @@ -170,11 +171,13 @@ cpu_startup(void *dummy) printf("Physical memory chunk(s):\n"); for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) { - int size1 = phys_avail[indx + 1] - phys_avail[indx]; + uintptr_t size1 = phys_avail[indx + 1] - phys_avail[indx]; - printf("0x%08x - 0x%08x, %u bytes (%u pages)\n", - phys_avail[indx], phys_avail[indx + 1] - 1, size1, - size1 / PAGE_SIZE); + printf("0x%08llx - 0x%08llx, %llu bytes (%llu pages)\n", + (unsigned long long)phys_avail[indx], + (unsigned long long)phys_avail[indx + 1] - 1, + (unsigned long long)size1, + (unsigned long long)size1 / PAGE_SIZE); } } @@ -255,10 +258,7 @@ mips_proc0_init(void) proc_linkup(&proc0, &thread0); thread0.td_kstack = kstack0; thread0.td_kstack_pages = KSTACK_PAGES - 1; - if (thread0.td_kstack & (1 << PAGE_SHIFT)) - thread0.td_md.md_realstack = thread0.td_kstack + PAGE_SIZE; - else - thread0.td_md.md_realstack = thread0.td_kstack; + thread0.td_md.md_realstack = roundup2(thread0.td_kstack, PAGE_SIZE * 2); /* Initialize pcpu info of cpu-zero */ #ifdef SMP pcpu_init(&__pcpu[0], 0, sizeof(struct pcpu));