From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 00:37:00 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FE421065670; Sun, 31 Oct 2010 00:37:00 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DBD88FC0A; Sun, 31 Oct 2010 00:37:00 +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 o9V0b01J033999; Sun, 31 Oct 2010 00:37:00 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V0b0N9033997; Sun, 31 Oct 2010 00:37:00 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201010310037.o9V0b0N9033997@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 31 Oct 2010 00:37:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214578 - stable/8/usr.sbin/rtadvd X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 00:37:00 -0000 Author: bz Date: Sun Oct 31 00:37:00 2010 New Revision: 214578 URL: http://svn.freebsd.org/changeset/base/214578 Log: MFC r214447: Correct a typo. Modified: stable/8/usr.sbin/rtadvd/rtadvd.conf.5 Directory Properties: stable/8/usr.sbin/rtadvd/ (props changed) Modified: stable/8/usr.sbin/rtadvd/rtadvd.conf.5 ============================================================================== --- stable/8/usr.sbin/rtadvd/rtadvd.conf.5 Sun Oct 31 00:35:18 2010 (r214577) +++ stable/8/usr.sbin/rtadvd/rtadvd.conf.5 Sun Oct 31 00:37:00 2010 (r214578) @@ -109,7 +109,7 @@ The default value is 64. (str or num) A 8-bit flags field in router advertisement message header. This field can be specified either as a case-sensitive string or as an integer. -A sting consists of characters each of which corresponds to a +A string consists of characters each of which corresponds to a particular flag bit(s). An integer should be the logical OR of all enabled bits. Bit 7 From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 00:51:23 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 139BB106566B; Sun, 31 Oct 2010 00:51:23 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F39C18FC17; Sun, 31 Oct 2010 00:51:22 +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 o9V0pMQh034611; Sun, 31 Oct 2010 00:51:22 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V0pM7n034607; Sun, 31 Oct 2010 00:51:22 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201010310051.o9V0pM7n034607@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 31 Oct 2010 00:51:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214579 - in stable/8/sys: conf net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 00:51:23 -0000 Author: bz Date: Sun Oct 31 00:51:22 2010 New Revision: 214579 URL: http://svn.freebsd.org/changeset/base/214579 Log: MFC r214333: Factor out DDB commands from r204145, r204279 into if_debug.c for further enhancements (1). Switch to a standard 2-clause BSD license for this (2). Unfortunately we have to un-static the ifindex_table for this but do not publicly export it. Suggested by: rwatson (1) a while back. Approved by: thompsa (2) for the change from r204279. Added: stable/8/sys/net/if_debug.c - copied unchanged from r214333, head/sys/net/if_debug.c Modified: stable/8/sys/conf/files stable/8/sys/net/if.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Sun Oct 31 00:37:00 2010 (r214578) +++ stable/8/sys/conf/files Sun Oct 31 00:51:22 2010 (r214579) @@ -2326,6 +2326,7 @@ net/if_atmsubr.c optional atm net/if_bridge.c optional bridge inet | if_bridge inet net/if_clone.c standard net/if_dead.c standard +net/if_debug.c optional ddb net/if_disc.c optional disc net/if_edsc.c optional edsc net/if_ef.c optional ef Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Sun Oct 31 00:37:00 2010 (r214578) +++ stable/8/sys/net/if.c Sun Oct 31 00:51:22 2010 (r214579) @@ -33,7 +33,6 @@ #include "opt_compat.h" #include "opt_inet6.h" #include "opt_inet.h" -#include "opt_ddb.h" #include #include @@ -62,10 +61,6 @@ #include #include -#ifdef DDB -#include -#endif - #include #include #include @@ -186,7 +181,7 @@ VNET_DEFINE(struct ifgrouphead, ifg_head static VNET_DEFINE(int, if_indexlim) = 8; /* Table of ifnet by index. */ -static VNET_DEFINE(struct ifindex_entry *, ifindex_table); +VNET_DEFINE(struct ifindex_entry *, ifindex_table); #define V_if_indexlim VNET(if_indexlim) #define V_ifindex_table VNET(ifindex_table) @@ -3416,78 +3411,3 @@ if_deregister_com_alloc(u_char type) if_com_alloc[type] = NULL; if_com_free[type] = NULL; } - -#ifdef DDB -static void -if_show_ifnet(struct ifnet *ifp) -{ - - if (ifp == NULL) - return; - db_printf("%s:\n", ifp->if_xname); -#define IF_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, ifp->e); - IF_DB_PRINTF("%s", if_dname); - IF_DB_PRINTF("%d", if_dunit); - IF_DB_PRINTF("%s", if_description); - IF_DB_PRINTF("%u", if_index); - IF_DB_PRINTF("%u", if_refcount); - IF_DB_PRINTF("%p", if_softc); - IF_DB_PRINTF("%p", if_l2com); - IF_DB_PRINTF("%p", if_vnet); - IF_DB_PRINTF("%p", if_home_vnet); - IF_DB_PRINTF("%p", if_addr); - IF_DB_PRINTF("%p", if_llsoftc); - IF_DB_PRINTF("%p", if_label); - IF_DB_PRINTF("%u", if_pcount); - IF_DB_PRINTF("0x%08x", if_flags); - IF_DB_PRINTF("0x%08x", if_drv_flags); - IF_DB_PRINTF("0x%08x", if_capabilities); - IF_DB_PRINTF("0x%08x", if_capenable); - IF_DB_PRINTF("%p", if_snd.ifq_head); - IF_DB_PRINTF("%p", if_snd.ifq_tail); - IF_DB_PRINTF("%d", if_snd.ifq_len); - IF_DB_PRINTF("%d", if_snd.ifq_maxlen); - IF_DB_PRINTF("%d", if_snd.ifq_drops); - IF_DB_PRINTF("%p", if_snd.ifq_drv_head); - IF_DB_PRINTF("%p", if_snd.ifq_drv_tail); - IF_DB_PRINTF("%d", if_snd.ifq_drv_len); - IF_DB_PRINTF("%d", if_snd.ifq_drv_maxlen); - IF_DB_PRINTF("%d", if_snd.altq_type); - IF_DB_PRINTF("%x", if_snd.altq_flags); -#undef IF_DB_PRINTF -} - -DB_SHOW_COMMAND(ifnet, db_show_ifnet) -{ - - if (!have_addr) { - db_printf("usage: show ifnet \n"); - return; - } - - if_show_ifnet((struct ifnet *)addr); -} - -DB_SHOW_ALL_COMMAND(ifnets, db_show_all_ifnets) -{ - VNET_ITERATOR_DECL(vnet_iter); - struct ifnet *ifp; - u_short idx; - - VNET_FOREACH(vnet_iter) { - CURVNET_SET_QUIET(vnet_iter); -#ifdef VIMAGE - db_printf("vnet=%p\n", curvnet); -#endif - for (idx = 1; idx <= V_if_index; idx++) { - ifp = V_ifindex_table[idx].ife_ifnet; - if (ifp == NULL) - continue; - db_printf( "%20s ifp=%p\n", ifp->if_xname, ifp); - if (db_pager_quit) - break; - } - CURVNET_RESTORE(); - } -} -#endif Copied: stable/8/sys/net/if_debug.c (from r214333, head/sys/net/if_debug.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/net/if_debug.c Sun Oct 31 00:51:22 2010 (r214579, copy of r214333, head/sys/net/if_debug.c) @@ -0,0 +1,125 @@ +/*- + * Copyright (c) 2010 Bjoern A. Zeeb + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" + +#include +#include +#include + +#ifdef DDB +#include +#endif + +#include +#include +#include +#include + +#ifdef DDB +struct ifindex_entry { + struct ifnet *ife_ifnet; +}; +VNET_DECLARE(struct ifindex_entry *, ifindex_table); +#define V_ifindex_table VNET(ifindex_table) + +static void +if_show_ifnet(struct ifnet *ifp) +{ + + if (ifp == NULL) + return; + db_printf("%s:\n", ifp->if_xname); +#define IF_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, ifp->e); + IF_DB_PRINTF("%s", if_dname); + IF_DB_PRINTF("%d", if_dunit); + IF_DB_PRINTF("%s", if_description); + IF_DB_PRINTF("%u", if_index); + IF_DB_PRINTF("%u", if_refcount); + IF_DB_PRINTF("%d", if_index_reserved); + IF_DB_PRINTF("%p", if_softc); + IF_DB_PRINTF("%p", if_l2com); + IF_DB_PRINTF("%p", if_vnet); + IF_DB_PRINTF("%p", if_home_vnet); + IF_DB_PRINTF("%p", if_addr); + IF_DB_PRINTF("%p", if_llsoftc); + IF_DB_PRINTF("%p", if_label); + IF_DB_PRINTF("%u", if_pcount); + IF_DB_PRINTF("0x%08x", if_flags); + IF_DB_PRINTF("0x%08x", if_drv_flags); + IF_DB_PRINTF("0x%08x", if_capabilities); + IF_DB_PRINTF("0x%08x", if_capenable); + IF_DB_PRINTF("%p", if_snd.ifq_head); + IF_DB_PRINTF("%p", if_snd.ifq_tail); + IF_DB_PRINTF("%d", if_snd.ifq_len); + IF_DB_PRINTF("%d", if_snd.ifq_maxlen); + IF_DB_PRINTF("%d", if_snd.ifq_drops); + IF_DB_PRINTF("%p", if_snd.ifq_drv_head); + IF_DB_PRINTF("%p", if_snd.ifq_drv_tail); + IF_DB_PRINTF("%d", if_snd.ifq_drv_len); + IF_DB_PRINTF("%d", if_snd.ifq_drv_maxlen); + IF_DB_PRINTF("%d", if_snd.altq_type); + IF_DB_PRINTF("%x", if_snd.altq_flags); +#undef IF_DB_PRINTF +} + +DB_SHOW_COMMAND(ifnet, db_show_ifnet) +{ + + if (!have_addr) { + db_printf("usage: show ifnet \n"); + return; + } + + if_show_ifnet((struct ifnet *)addr); +} + +DB_SHOW_ALL_COMMAND(ifnets, db_show_all_ifnets) +{ + VNET_ITERATOR_DECL(vnet_iter); + struct ifnet *ifp; + u_short idx; + + VNET_FOREACH(vnet_iter) { + CURVNET_SET_QUIET(vnet_iter); +#ifdef VIMAGE + db_printf("vnet=%p\n", curvnet); +#endif + for (idx = 1; idx <= V_if_index; idx++) { + ifp = V_ifindex_table[idx].ife_ifnet; + if (ifp == NULL) + continue; + db_printf( "%20s ifp=%p\n", ifp->if_xname, ifp); + if (db_pager_quit) + break; + } + CURVNET_RESTORE(); + } +} +#endif From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 07:57:06 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32CE5106564A; Sun, 31 Oct 2010 07:57:06 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20C298FC0C; Sun, 31 Oct 2010 07:57:06 +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 o9V7v67J057270; Sun, 31 Oct 2010 07:57:06 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V7v6Z0057268; Sun, 31 Oct 2010 07:57:06 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310757.o9V7v6Z0057268@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 07:57:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214588 - stable/8/sys/pc98/cbus X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 07:57:06 -0000 Author: nyan Date: Sun Oct 31 07:57:05 2010 New Revision: 214588 URL: http://svn.freebsd.org/changeset/base/214588 Log: MFC: revision 208563 Reduce diffs against syscons_isa.c. No functional changes. Modified: stable/8/sys/pc98/cbus/syscons_cbus.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/cbus/syscons_cbus.c ============================================================================== --- stable/8/sys/pc98/cbus/syscons_cbus.c Sun Oct 31 07:09:58 2010 (r214587) +++ stable/8/sys/pc98/cbus/syscons_cbus.c Sun Oct 31 07:57:05 2010 (r214588) @@ -22,10 +22,11 @@ * 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$ */ +#include +__FBSDID("$FreeBSD$"); + #include "opt_syscons.h" #include @@ -47,7 +48,7 @@ static devclass_t sc_devclass; -static sc_softc_t main_softc; +static sc_softc_t main_softc; #ifdef SC_NO_SUSPEND_VTYSWITCH static int sc_no_suspend_vtswitch = 1; #else @@ -55,31 +56,34 @@ static int sc_no_suspend_vtswitch = 0; #endif static int sc_cur_scr; -TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", (int *)&sc_no_suspend_vtswitch); +TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); SYSCTL_DECL(_hw_syscons); SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, - &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); + &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); static void -scidentify (driver_t *driver, device_t parent) +scidentify(driver_t *driver, device_t parent) { + BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "sc", 0); } static int scprobe(device_t dev) { + /* No pnp support */ if (isa_get_vendorid(dev)) return (ENXIO); device_set_desc(dev, "System console"); - return sc_probe_unit(device_get_unit(dev), device_get_flags(dev)); + return (sc_probe_unit(device_get_unit(dev), device_get_flags(dev))); } static int scattach(device_t dev) { + return sc_attach_unit(device_get_unit(dev), device_get_flags(dev)); } @@ -127,7 +131,8 @@ scresume(device_t dev) int sc_max_unit(void) { - return devclass_get_maxunit(sc_devclass); + + return (devclass_get_maxunit(sc_devclass)); } sc_softc_t @@ -136,52 +141,52 @@ sc_softc_t sc_softc_t *sc; if (unit < 0) - return NULL; - if (flags & SC_KERNEL_CONSOLE) { + return (NULL); + if ((flags & SC_KERNEL_CONSOLE) != 0) { /* FIXME: clear if it is wired to another unit! */ sc = &main_softc; } else { - sc = (sc_softc_t *)device_get_softc(devclass_get_device(sc_devclass, unit)); + sc = device_get_softc(devclass_get_device(sc_devclass, unit)); if (sc == NULL) - return NULL; + return (NULL); } sc->unit = unit; - if (!(sc->flags & SC_INIT_DONE)) { + if ((sc->flags & SC_INIT_DONE) == 0) { sc->keyboard = -1; sc->adapter = -1; sc->mouse_char = SC_MOUSE_CHAR; } - return sc; + return (sc); } sc_softc_t *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd) { sc_softc_t *sc; - int units; int i; + int units; sc = &main_softc; - if (((adp == NULL) || (adp == sc->adp)) - && ((kbd == NULL) || (kbd == sc->kbd))) - return sc; + if ((adp == NULL || adp == sc->adp) && + (kbd == NULL || kbd == sc->kbd)) + return (sc); units = devclass_get_maxunit(sc_devclass); for (i = 0; i < units; ++i) { - sc = (sc_softc_t *)device_get_softc(devclass_get_device(sc_devclass, i)); + sc = device_get_softc(devclass_get_device(sc_devclass, i)); if (sc == NULL) continue; - if (((adp == NULL) || (adp == sc->adp)) - && ((kbd == NULL) || (kbd == sc->kbd))) - return sc; + if ((adp == NULL || adp == sc->adp) && + (kbd == NULL || kbd == sc->kbd)) + return (sc); } - return NULL; + return (NULL); } int sc_get_cons_priority(int *unit, int *flags) { const char *at; - int u, f; + int f, u; *unit = -1; for (u = 0; u < 16; u++) { @@ -207,7 +212,7 @@ sc_get_cons_priority(int *unit, int *fla *unit = 0; *flags = 0; } - return CN_INTERNAL; + return (CN_INTERNAL); } void @@ -225,12 +230,12 @@ sc_tone(int herz) if (herz) { if (timer_spkr_acquire()) - return EBUSY; + return (EBUSY); timer_spkr_setfreq(herz); - } else { + } else timer_spkr_release(); - } - return 0; + + return (0); } static device_method_t sc_methods[] = { From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 08:02:48 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 159231065698; Sun, 31 Oct 2010 08:02:48 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 03DC48FC08; Sun, 31 Oct 2010 08:02:48 +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 o9V82lhK058544; Sun, 31 Oct 2010 08:02:47 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V82lBO058542; Sun, 31 Oct 2010 08:02:47 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310802.o9V82lBO058542@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 08:02:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214589 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 08:02:48 -0000 Author: nyan Date: Sun Oct 31 08:02:47 2010 New Revision: 214589 URL: http://svn.freebsd.org/changeset/base/214589 Log: MFC: revision 208632 Clarify a potential issue in get_fpcontext() use. Modified: stable/8/sys/pc98/pc98/machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 07:57:05 2010 (r214588) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:02:47 2010 (r214589) @@ -561,6 +561,13 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sf.sf_uc.uc_mcontext.mc_gs = rgs(); bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs)); sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */ + + /* + * The get_fpcontext() call must be placed before assignments + * to mc_fsbase and mc_gsbase due to the alignment-override + * code in get_fpcontext() that possibly clobbers 12 bytes of + * mcontext after mc_fpstate. + */ get_fpcontext(td, &sf.sf_uc.uc_mcontext); fpstate_drop(td); /* @@ -2453,6 +2460,13 @@ get_mcontext(struct thread *td, mcontext mcp->mc_esp = tp->tf_esp; mcp->mc_ss = tp->tf_ss; mcp->mc_len = sizeof(*mcp); + + /* + * The get_fpcontext() call must be placed before assignments + * to mc_fsbase and mc_gsbase due to the alignment-override + * code in get_fpcontext() that possibly clobbers 12 bytes of + * mcontext after mc_fpstate. + */ get_fpcontext(td, mcp); sdp = &td->td_pcb->pcb_fsd; mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase; From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 08:08:18 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F04461065670; Sun, 31 Oct 2010 08:08:18 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE7558FC08; Sun, 31 Oct 2010 08:08: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 o9V88IFp059743; Sun, 31 Oct 2010 08:08:18 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V88Ich059741; Sun, 31 Oct 2010 08:08:18 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310808.o9V88Ich059741@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 08:08:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214590 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 08:08:19 -0000 Author: nyan Date: Sun Oct 31 08:08:18 2010 New Revision: 214590 URL: http://svn.freebsd.org/changeset/base/214590 Log: MFC: revision 208634 Reduce diffs against i386. Modified: stable/8/sys/pc98/pc98/machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:02:47 2010 (r214589) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:08:18 2010 (r214590) @@ -213,6 +213,8 @@ static void cpu_startup(dummy) void *dummy; { + uintmax_t memsize; + /* * Good {morning,afternoon,evening,night}. */ @@ -222,9 +224,14 @@ cpu_startup(dummy) #ifdef PERFMON perfmon_init(); #endif - printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem), - ptoa((uintmax_t)Maxmem) / 1048576); realmem = Maxmem; + + /* + * Display physical memory. + */ + memsize = ptoa((uintmax_t)Maxmem); + printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20); + /* * Display any holes after the first chunk of extended memory. */ @@ -255,7 +262,6 @@ cpu_startup(dummy) */ bufinit(); vm_pager_bufferinit(); - cpu_setregs(); } @@ -1024,8 +1030,8 @@ sigreturn(td, uap) else td->td_sigstk.ss_flags &= ~SS_ONSTACK; #endif - kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); + kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); return (EJUSTRETURN); } @@ -1296,10 +1302,11 @@ SYSCTL_ULONG(_machdep, OID_AUTO, guessed */ int _default_ldt; + union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ +union descriptor ldt[NLDT]; /* local descriptor table */ static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ -union descriptor ldt[NLDT]; /* local descriptor table */ struct region_descriptor r_gdt, r_idt; /* table descriptors */ struct mtx dt_lock; /* lock for GDT and LDT */ @@ -1655,7 +1662,8 @@ getmemsize(int first) int i, off, physmap_idx, pa_indx, da_indx; int pg_n; u_long physmem_tunable; - u_int extmem, under16; + u_int extmem; + u_int under16; vm_paddr_t pa, physmap[PHYSMAP_SIZE]; pt_entry_t *pte; quad_t dcons_addr, dcons_size; @@ -1680,7 +1688,7 @@ getmemsize(int first) /* * Perform "base memory" related probes & setup */ - under16 = pc98_getmemsize(&basemem, &extmem); + under16 = pc98_getmemsize(&basemem, &extmem); if (basemem > 640) { printf("Preposterous BIOS basemem of %uK, truncating to 640K\n", basemem); @@ -1912,7 +1920,7 @@ do_next: } *pte = 0; invltlb(); - + /* * XXX * The last chunk must contain at least one page plus the message @@ -1942,9 +1950,8 @@ init386(first) int first; { struct gate_descriptor *gdp; - int gsel_tss, metadata_missing, x; + int gsel_tss, metadata_missing, x, pa; struct pcpu *pc; - int pa; thread0.td_kstack = proc0kstack; thread0.td_pcb = (struct pcb *) @@ -2005,7 +2012,6 @@ init386(first) pmap_kenter(pa + KERNBASE, pa); dpcpu_init((void *)(first + KERNBASE), 0); first += DPCPU_SIZE; - PCPU_SET(prvspace, pc); PCPU_SET(curthread, &thread0); PCPU_SET(curpcb, thread0.td_pcb); From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 08:14:52 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D909F106564A; Sun, 31 Oct 2010 08:14:52 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C6C958FC08; Sun, 31 Oct 2010 08:14:52 +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 o9V8EqGG061155; Sun, 31 Oct 2010 08:14:52 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V8Eqs6061152; Sun, 31 Oct 2010 08:14:52 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310814.o9V8Eqs6061152@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 08:14:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214591 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 08:14:53 -0000 Author: nyan Date: Sun Oct 31 08:14:52 2010 New Revision: 214591 URL: http://svn.freebsd.org/changeset/base/214591 Log: MFC: revision 208638 - Add an integer argument to idle to indicate how likely we are to wake from idle over the next tick. - Add a new MD routine, cpu_wake_idle() to wakeup idle threads who are suspended in cpu specific states. This function can fail and cause the scheduler to fall back to another mechanism (ipi). - Implement support for mwait in cpu_idle() on i386/amd64 machines that support it. mwait is a higher performance way to synchronize cpus as compared to hlt & ipis. - Allow selecting the idle routine by name via sysctl machdep.idle. This replaces machdep.cpu_idle_hlt. Only idle routines supported by the current machine are permitted. Modified: stable/8/sys/pc98/pc98/machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:08:18 2010 (r214590) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:14:52 2010 (r214591) @@ -1104,6 +1104,7 @@ cpu_est_clockrate(int cpu_id, uint64_t * return (0); } + /* * Shutdown the CPU as much as possible */ @@ -1114,70 +1115,177 @@ cpu_halt(void) __asm__ ("hlt"); } -/* - * Hook to idle the CPU when possible. In the SMP case we default to - * off because a halted cpu will not currently pick up a new thread in the - * run queue until the next timer tick. If turned on this will result in - * approximately a 4.2% loss in real time performance in buildworld tests - * (but improves user and sys times oddly enough), and saves approximately - * 5% in power consumption on an idle machine (tests w/2xCPU 1.1GHz P3). - * - * XXX we need to have a cpu mask of idle cpus and generate an IPI or - * otherwise generate some sort of interrupt to wake up cpus sitting in HLT. - * Then we can have our cake and eat it too. - * - * XXX I'm turning it on for SMP as well by default for now. It seems to - * help lock contention somewhat, and this is critical for HTT. -Peter - */ -static int cpu_idle_hlt = 1; -TUNABLE_INT("machdep.cpu_idle_hlt", &cpu_idle_hlt); -SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW, - &cpu_idle_hlt, 0, "Idle loop HLT enable"); - static void -cpu_idle_default(void) +cpu_idle_hlt(int busy) { /* - * we must absolutely guarentee that hlt is the - * absolute next instruction after sti or we - * introduce a timing window. + * we must absolutely guarentee that hlt is the next instruction + * after sti or we introduce a timing window. */ - __asm __volatile("sti; hlt"); + disable_intr(); + if (sched_runnable()) + enable_intr(); + else + __asm __volatile("sti; hlt"); } -/* - * Note that we have to be careful here to avoid a race between checking - * sched_runnable() and actually halting. If we don't do this, we may waste - * the time between calling hlt and the next interrupt even though there - * is a runnable process. - */ +static void +cpu_idle_spin(int busy) +{ + return; +} + +void (*cpu_idle_fn)(int) = cpu_idle_hlt; + void cpu_idle(int busy) { - -#ifdef SMP +#if defined(SMP) if (mp_grab_cpu_hlt()) return; #endif + cpu_idle_fn(busy); +} + +/* + * mwait cpu power states. Lower 4 bits are sub-states. + */ +#define MWAIT_C0 0xf0 +#define MWAIT_C1 0x00 +#define MWAIT_C2 0x10 +#define MWAIT_C3 0x20 +#define MWAIT_C4 0x30 + +#define MWAIT_DISABLED 0x0 +#define MWAIT_WOKEN 0x1 +#define MWAIT_WAITING 0x2 + +static void +cpu_idle_mwait(int busy) +{ + int *mwait; - if (cpu_idle_hlt) { - disable_intr(); - if (sched_runnable()) - enable_intr(); - else - (*cpu_idle_hook)(); + mwait = (int *)PCPU_PTR(monitorbuf); + *mwait = MWAIT_WAITING; + if (sched_runnable()) + return; + cpu_monitor(mwait, 0, 0); + if (*mwait == MWAIT_WAITING) + cpu_mwait(0, MWAIT_C1); +} + +static void +cpu_idle_mwait_hlt(int busy) +{ + int *mwait; + + mwait = (int *)PCPU_PTR(monitorbuf); + if (busy == 0) { + *mwait = MWAIT_DISABLED; + cpu_idle_hlt(busy); + return; } + *mwait = MWAIT_WAITING; + if (sched_runnable()) + return; + cpu_monitor(mwait, 0, 0); + if (*mwait == MWAIT_WAITING) + cpu_mwait(0, MWAIT_C1); } int cpu_idle_wakeup(int cpu) { + struct pcpu *pcpu; + int *mwait; - return (0); + if (cpu_idle_fn == cpu_idle_spin) + return (1); + if (cpu_idle_fn != cpu_idle_mwait && cpu_idle_fn != cpu_idle_mwait_hlt) + return (0); + pcpu = pcpu_find(cpu); + mwait = (int *)pcpu->pc_monitorbuf; + /* + * This doesn't need to be atomic since missing the race will + * simply result in unnecessary IPIs. + */ + if (cpu_idle_fn == cpu_idle_mwait_hlt && *mwait == MWAIT_DISABLED) + return (0); + *mwait = MWAIT_WOKEN; + + return (1); +} + +/* + * Ordered by speed/power consumption. + */ +struct { + void *id_fn; + char *id_name; +} idle_tbl[] = { + { cpu_idle_spin, "spin" }, + { cpu_idle_mwait, "mwait" }, + { cpu_idle_mwait_hlt, "mwait_hlt" }, + { cpu_idle_hlt, "hlt" }, + { NULL, NULL } +}; + +static int +idle_sysctl_available(SYSCTL_HANDLER_ARGS) +{ + char *avail, *p; + int error; + int i; + + avail = malloc(256, M_TEMP, M_WAITOK); + p = avail; + for (i = 0; idle_tbl[i].id_name != NULL; i++) { + if (strstr(idle_tbl[i].id_name, "mwait") && + (cpu_feature2 & CPUID2_MON) == 0) + continue; + p += sprintf(p, "%s, ", idle_tbl[i].id_name); + } + error = sysctl_handle_string(oidp, avail, 0, req); + free(avail, M_TEMP); + return (error); } -/* Other subsystems (e.g., ACPI) can hook this later. */ -void (*cpu_idle_hook)(void) = cpu_idle_default; +static int +idle_sysctl(SYSCTL_HANDLER_ARGS) +{ + char buf[16]; + int error; + char *p; + int i; + + p = "unknown"; + for (i = 0; idle_tbl[i].id_name != NULL; i++) { + if (idle_tbl[i].id_fn == cpu_idle_fn) { + p = idle_tbl[i].id_name; + break; + } + } + strncpy(buf, p, sizeof(buf)); + error = sysctl_handle_string(oidp, buf, sizeof(buf), req); + if (error != 0 || req->newptr == NULL) + return (error); + for (i = 0; idle_tbl[i].id_name != NULL; i++) { + if (strstr(idle_tbl[i].id_name, "mwait") && + (cpu_feature2 & CPUID2_MON) == 0) + continue; + if (strcmp(idle_tbl[i].id_name, buf)) + continue; + cpu_idle_fn = idle_tbl[i].id_fn; + return (0); + } + return (EINVAL); +} + +SYSCTL_PROC(_machdep, OID_AUTO, idle_available, CTLTYPE_STRING | CTLFLAG_RD, + 0, 0, idle_sysctl_available, "A", "list of available idle functions"); + +SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, + idle_sysctl, "A", "currently selected idle function"); /* * Reset registers to default values on exec. From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 08:18:24 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DF77106564A; Sun, 31 Oct 2010 08:18:24 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C8258FC0A; Sun, 31 Oct 2010 08:18:24 +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 o9V8IN1E061956; Sun, 31 Oct 2010 08:18:23 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V8INmD061954; Sun, 31 Oct 2010 08:18:23 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310818.o9V8INmD061954@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 08:18:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214592 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 08:18:24 -0000 Author: nyan Date: Sun Oct 31 08:18:23 2010 New Revision: 214592 URL: http://svn.freebsd.org/changeset/base/214592 Log: MFC: revision 208639 Use SEL_KPL macro. Modified: stable/8/sys/pc98/pc98/machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:14:52 2010 (r214591) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:18:23 2010 (r214592) @@ -1439,7 +1439,7 @@ struct soft_segment_descriptor gdt_segs[ { .ssd_base = 0x0, .ssd_limit = 0x0, .ssd_type = 0, - .ssd_dpl = 0, + .ssd_dpl = SEL_KPL, .ssd_p = 0, .ssd_xx = 0, .ssd_xx1 = 0, .ssd_def32 = 0, @@ -1448,7 +1448,7 @@ struct soft_segment_descriptor gdt_segs[ { .ssd_base = 0x0, .ssd_limit = 0xfffff, .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, + .ssd_dpl = SEL_KPL, .ssd_p = 1, .ssd_xx = 0, .ssd_xx1 = 0, .ssd_def32 = 1, @@ -1475,7 +1475,7 @@ struct soft_segment_descriptor gdt_segs[ { .ssd_base = 0x0, .ssd_limit = 0xfffff, .ssd_type = SDT_MEMERA, - .ssd_dpl = 0, + .ssd_dpl = SEL_KPL, .ssd_p = 1, .ssd_xx = 0, .ssd_xx1 = 0, .ssd_def32 = 1, @@ -1484,7 +1484,7 @@ struct soft_segment_descriptor gdt_segs[ { .ssd_base = 0x0, .ssd_limit = 0xfffff, .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, + .ssd_dpl = SEL_KPL, .ssd_p = 1, .ssd_xx = 0, .ssd_xx1 = 0, .ssd_def32 = 1, @@ -1511,7 +1511,7 @@ struct soft_segment_descriptor gdt_segs[ { .ssd_base = 0x400, .ssd_limit = 0xfffff, .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, + .ssd_dpl = SEL_KPL, .ssd_p = 1, .ssd_xx = 0, .ssd_xx1 = 0, .ssd_def32 = 1, From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 08:39:42 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5055106564A; Sun, 31 Oct 2010 08:39:42 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 931AC8FC16; Sun, 31 Oct 2010 08:39:42 +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 o9V8dgo6066501; Sun, 31 Oct 2010 08:39:42 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V8dg4C066499; Sun, 31 Oct 2010 08:39:42 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310839.o9V8dg4C066499@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 08:39:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214593 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 08:39:42 -0000 Author: nyan Date: Sun Oct 31 08:39:42 2010 New Revision: 214593 URL: http://svn.freebsd.org/changeset/base/214593 Log: MFC: revision 214258 Rewrite the i386 memory probe: - Move the base memory setup into a new basemem_setup() routine. The mergeinfo is already recorded accidentally in the previous commit. Modified: stable/8/sys/pc98/pc98/machdep.c Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:18:23 2010 (r214592) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:39:42 2010 (r214593) @@ -1751,52 +1751,13 @@ sdtossd(sd, ssd) ssd->ssd_gran = sd->sd_gran; } -/* - * Populate the (physmap) array with base/bound pairs describing the - * available physical memory in the system, then test this memory and - * build the phys_avail array describing the actually-available memory. - * - * If we cannot accurately determine the physical memory map, then use - * value from the 0xE801 call, and failing that, the RTC. - * - * Total memory size may be set by the kernel environment variable - * hw.physmem or the compile-time define MAXMEM. - * - * XXX first should be vm_paddr_t. - */ static void -getmemsize(int first) +basemem_setup(void) { - int i, off, physmap_idx, pa_indx, da_indx; - int pg_n; - u_long physmem_tunable; - u_int extmem; - u_int under16; - vm_paddr_t pa, physmap[PHYSMAP_SIZE]; + vm_paddr_t pa; pt_entry_t *pte; - quad_t dcons_addr, dcons_size; - - bzero(physmap, sizeof(physmap)); - - /* XXX - some of EPSON machines can't use PG_N */ - pg_n = PG_N; - if (pc98_machine_type & M_EPSON_PC98) { - switch (epson_machine_id) { -#ifdef WB_CACHE - default: -#endif - case EPSON_PC486_HX: - case EPSON_PC486_HG: - case EPSON_PC486_HA: - pg_n = 0; - break; - } - } + int i; - /* - * Perform "base memory" related probes & setup - */ - under16 = pc98_getmemsize(&basemem, &extmem); if (basemem > 640) { printf("Preposterous BIOS basemem of %uK, truncating to 640K\n", basemem); @@ -1828,12 +1789,62 @@ getmemsize(int first) pmap_kenter(KERNBASE + pa, pa); /* - * if basemem != 640, map pages r/w into vm86 page table so - * that the bios can scribble on it. + * Map pages between basemem and ISA_HOLE_START, if any, r/w into + * the vm86 page table so that vm86 can scribble on them using + * the vm86 map too. XXX: why 2 ways for this and only 1 way for + * page 0, at least as initialized here? */ pte = (pt_entry_t *)vm86paddr; for (i = basemem / 4; i < 160; i++) pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U; +} + +/* + * Populate the (physmap) array with base/bound pairs describing the + * available physical memory in the system, then test this memory and + * build the phys_avail array describing the actually-available memory. + * + * If we cannot accurately determine the physical memory map, then use + * value from the 0xE801 call, and failing that, the RTC. + * + * Total memory size may be set by the kernel environment variable + * hw.physmem or the compile-time define MAXMEM. + * + * XXX first should be vm_paddr_t. + */ +static void +getmemsize(int first) +{ + int off, physmap_idx, pa_indx, da_indx; + u_long physmem_tunable; + vm_paddr_t physmap[PHYSMAP_SIZE]; + pt_entry_t *pte; + quad_t dcons_addr, dcons_size; + int i; + int pg_n; + u_int extmem; + u_int under16; + vm_paddr_t pa; + + bzero(physmap, sizeof(physmap)); + + /* XXX - some of EPSON machines can't use PG_N */ + pg_n = PG_N; + if (pc98_machine_type & M_EPSON_PC98) { + switch (epson_machine_id) { +#ifdef WB_CACHE + default: +#endif + case EPSON_PC486_HX: + case EPSON_PC486_HG: + case EPSON_PC486_HA: + pg_n = 0; + break; + } + } + + under16 = pc98_getmemsize(&basemem, &extmem); + basemem_setup(); physmap[0] = 0; physmap[1] = basemem * 1024; From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 09:05:05 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D1C0106564A; Sun, 31 Oct 2010 09:05:05 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B9E18FC14; Sun, 31 Oct 2010 09:05: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 o9V954mF072022; Sun, 31 Oct 2010 09:05:04 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V954Ok072019; Sun, 31 Oct 2010 09:05:04 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <201010310905.o9V954Ok072019@svn.freebsd.org> From: Takahashi Yoshihiro Date: Sun, 31 Oct 2010 09:05:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214595 - stable/8/sys/pc98/pc98 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 09:05:05 -0000 Author: nyan Date: Sun Oct 31 09:05:04 2010 New Revision: 214595 URL: http://svn.freebsd.org/changeset/base/214595 Log: MFC: revision 207355 - Change printf() calls to uprintf() for sigreturn(). - Normalize the messages to include both pid and thread name. Modified: stable/8/sys/pc98/pc98/machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/pc98/pc98/machdep.c ============================================================================== --- stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 08:50:31 2010 (r214594) +++ stable/8/sys/pc98/pc98/machdep.c Sun Oct 31 09:05:04 2010 (r214595) @@ -885,7 +885,8 @@ freebsd4_sigreturn(td, uap) * one less debugger trap, so allowing it is fairly harmless. */ if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - printf("freebsd4_sigreturn: eflags = 0x%x\n", eflags); + uprintf("pid %d (%s): freebsd4_sigreturn eflags = 0x%x\n", + td->td_proc->p_pid, td->td_name, eflags); return (EINVAL); } @@ -896,7 +897,8 @@ freebsd4_sigreturn(td, uap) */ cs = ucp->uc_mcontext.mc_cs; if (!CS_SECURE(cs)) { - printf("freebsd4_sigreturn: cs = 0x%x\n", cs); + uprintf("pid %d (%s): freebsd4_sigreturn cs = 0x%x\n", + td->td_proc->p_pid, td->td_name, cs); ksiginfo_init_trap(&ksi); ksi.ksi_signo = SIGBUS; ksi.ksi_code = BUS_OBJERR; @@ -997,7 +999,8 @@ sigreturn(td, uap) * one less debugger trap, so allowing it is fairly harmless. */ if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - printf("sigreturn: eflags = 0x%x\n", eflags); + uprintf("pid %d (%s): sigreturn eflags = 0x%x\n", + td->td_proc->p_pid, td->td_name, eflags); return (EINVAL); } @@ -1008,7 +1011,8 @@ sigreturn(td, uap) */ cs = ucp->uc_mcontext.mc_cs; if (!CS_SECURE(cs)) { - printf("sigreturn: cs = 0x%x\n", cs); + uprintf("pid %d (%s): sigreturn cs = 0x%x\n", + td->td_proc->p_pid, td->td_name, cs); ksiginfo_init_trap(&ksi); ksi.ksi_signo = SIGBUS; ksi.ksi_code = BUS_OBJERR; From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 12:05:38 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FC3910656A3; Sun, 31 Oct 2010 12:05:38 +0000 (UTC) (envelope-from bcr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13FF28FC14; Sun, 31 Oct 2010 12:05:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9VC5be4086869; Sun, 31 Oct 2010 12:05:37 GMT (envelope-from bcr@svn.freebsd.org) Received: (from bcr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9VC5bvi086867; Sun, 31 Oct 2010 12:05:37 GMT (envelope-from bcr@svn.freebsd.org) Message-Id: <201010311205.o9VC5bvi086867@svn.freebsd.org> From: Benedict Reuschling Date: Sun, 31 Oct 2010 12:05:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214598 - stable/8/share/man/man5 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 12:05:38 -0000 Author: bcr (doc committer) Date: Sun Oct 31 12:05:37 2010 New Revision: 214598 URL: http://svn.freebsd.org/changeset/base/214598 Log: MFC r214387: Add some missing documentation to the man page: - FILES section ref: ~/nsmb.conf - use of password in examples section - use of simple encryption for password in examples section PR: docs/132311 Submitted by: David Horn (dhorn2000 at gmail dot com) Patch corrected by: trhodes Approved by: trhodes Modified: stable/8/share/man/man5/nsmb.conf.5 Directory Properties: stable/8/share/man/man5/ (props changed) Modified: stable/8/share/man/man5/nsmb.conf.5 ============================================================================== --- stable/8/share/man/man5/nsmb.conf.5 Sun Oct 31 11:44:41 2010 (r214597) +++ stable/8/share/man/man5/nsmb.conf.5 Sun Oct 31 12:05:37 2010 (r214598) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 30, 2003 +.Dd October 19, 2010 .Dt NSMB.CONF 5 .Os .Sh NAME @@ -87,7 +87,7 @@ Possible keywords may include: .It Va nbns Ta "+ + - -" Ta "address of NetBIOS name server (WINS)" .It Va nbscope Ta "+ + - -" Ta "NetBIOS scope" .It Va nbtimeout Ta "+ + - -" Ta "timeout for NetBIOS name servers" -.It Va password Ta "- - + +" Ta "plain text password used to access the given share" +.It Va password Ta "- - + +" Ta "plain text or simple encrypted password used to access the given share" .It Va retry_count Ta "+ + - -" Ta "number of retries before connection is marked as broken" .It Va timeout Ta "+ + - -" Ta "SMB request timeout" .It Va workgroup Ta "+ + + +" Ta "workgroup name" @@ -96,6 +96,9 @@ Possible keywords may include: .Bl -tag -width ".Pa /etc/nsmb.conf" .It Pa /etc/nsmb.conf The default remote mount-point configuration file. +.Pa "~/nsmb.conf" +.It Pa ~/nsmb.conf +The user specific remote mount-point configuration file. .El .Sh EXAMPLES What follows is a sample configuration file which may, @@ -108,6 +111,9 @@ workgroup=SALES [FSERVER] charsets=koi8-r:cp866 addr=fserv.example.com +# User specific data for FSERVER +[FSERVER:MYUSER] +password=$$16144562c293a0314e6e1 .Ed .Pp All lines which begin with the @@ -124,6 +130,18 @@ required when Cyrillic characters are no The hostname value, .Dq Li fserv.example.com , is also assigned in this section. +.Dq Li FSERVER:USER , +defines the user settings and is useful for saving the password used +during a specific connection. +The password may be plaintext or obfuscated using simple encryption. +The simple encrypted password starts with the `$$1' symbols. +Warning: the encryption function is very weak and intended only to hide +clear text passwords. +If the use of simple encryption is desired, the following command may be +used on a password: +.Bd -literal -offset indent +smbutil crypt +.Ed .Sh COMPATIBILITY At the time of this writing, the .Tn IPX From owner-svn-src-stable-8@FreeBSD.ORG Sun Oct 31 16:54:50 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C61D21065693; Sun, 31 Oct 2010 16:54:50 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4B558FC17; Sun, 31 Oct 2010 16:54: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 o9VGso9q097009; Sun, 31 Oct 2010 16:54:50 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9VGsoCQ097007; Sun, 31 Oct 2010 16:54:50 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201010311654.o9VGsoCQ097007@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 31 Oct 2010 16:54:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214602 - stable/8/sys/net X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 16:54:50 -0000 Author: bz Date: Sun Oct 31 16:54:50 2010 New Revision: 214602 URL: http://svn.freebsd.org/changeset/base/214602 Log: Correct a merge issue from r214554, where the field had been deprecated and reserved in HEAD but is still there in 8. Reported by: dhw Modified: stable/8/sys/net/if_debug.c Modified: stable/8/sys/net/if_debug.c ============================================================================== --- stable/8/sys/net/if_debug.c Sun Oct 31 15:07:09 2010 (r214601) +++ stable/8/sys/net/if_debug.c Sun Oct 31 16:54:50 2010 (r214602) @@ -62,7 +62,7 @@ if_show_ifnet(struct ifnet *ifp) IF_DB_PRINTF("%s", if_description); IF_DB_PRINTF("%u", if_index); IF_DB_PRINTF("%u", if_refcount); - IF_DB_PRINTF("%d", if_index_reserved); + IF_DB_PRINTF("%u", if_timer); IF_DB_PRINTF("%p", if_softc); IF_DB_PRINTF("%p", if_l2com); IF_DB_PRINTF("%p", if_vnet); From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 01:03:05 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81717106564A; Mon, 1 Nov 2010 01:03:05 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6D5A88FC08; Mon, 1 Nov 2010 01:03: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 oA11354v017072; Mon, 1 Nov 2010 01:03:05 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA1135Ga017056; Mon, 1 Nov 2010 01:03:05 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011010103.oA1135Ga017056@svn.freebsd.org> From: Rick Macklem Date: Mon, 1 Nov 2010 01:03:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214612 - in stable/8/sys: fs/nfsclient nfs nfsclient nlm X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 01:03:05 -0000 Author: rmacklem Date: Mon Nov 1 01:03:05 2010 New Revision: 214612 URL: http://svn.freebsd.org/changeset/base/214612 Log: MFC: r214048, r214053 Modify the NFS clients and the NLM so that the NLM can be used by both clients. Since the NLM uses various fields of the nfsmount structure, those fields were extracted and put in a separate nfs_mountcommon structure stored in sys/nfs/nfs_mountcommon.h. This structure also has a function pointer for a function that extracts the required information from the mount point and nfs vnode for that particular client. Also, fix the type of the 3rd argument for this function. Added: stable/8/sys/nfs/nfs_mountcommon.h - copied, changed from r214048, head/sys/nfs/nfs_mountcommon.h Modified: stable/8/sys/fs/nfsclient/nfs_clnode.c stable/8/sys/fs/nfsclient/nfs_clvfsops.c stable/8/sys/fs/nfsclient/nfs_clvnops.c stable/8/sys/fs/nfsclient/nfsmount.h stable/8/sys/nfs/nfs_lock.c stable/8/sys/nfs/nfs_lock.h stable/8/sys/nfsclient/nfs_node.c stable/8/sys/nfsclient/nfs_vfsops.c stable/8/sys/nfsclient/nfs_vnops.c stable/8/sys/nfsclient/nfsmount.h stable/8/sys/nfsclient/nfsnode.h stable/8/sys/nlm/nlm_advlock.c stable/8/sys/nlm/nlm_prot_impl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clnode.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/fs/nfsclient/nfs_clnode.c Mon Nov 1 01:03:05 2010 (r214612) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -53,12 +54,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include + extern struct vop_vector newnfs_vnodeops; extern struct buf_ops buf_ops_newnfs; MALLOC_DECLARE(M_NEWNFSREQ); uma_zone_t newnfsnode_zone; -vop_reclaim_t *ncl_reclaim_p = NULL; void ncl_nhinit(void) @@ -238,8 +240,8 @@ ncl_reclaim(struct vop_reclaim_args *ap) * If the NLM is running, give it a chance to abort pending * locks. */ - if (ncl_reclaim_p) - ncl_reclaim_p(ap); + if (nfs_reclaim_p != NULL) + nfs_reclaim_p(ap); /* * Destroy the vm object and flush associated pages. Modified: stable/8/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clvfsops.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/fs/nfsclient/nfs_clvfsops.c Mon Nov 1 01:03:05 2010 (r214612) @@ -96,10 +96,13 @@ SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELA static void nfs_sec_name(char *, int *); static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp, - struct nfs_args *argp, struct ucred *, struct thread *); + struct nfs_args *argp, const char *, struct ucred *, + struct thread *); static int mountnfs(struct nfs_args *, struct mount *, struct sockaddr *, char *, u_char *, u_char *, u_char *, struct vnode **, struct ucred *, struct thread *, int); +static void nfs_getnlminfo(struct vnode *, uint8_t *, size_t *, + struct sockaddr_storage *, int *, off_t *); static vfs_mount_t nfs_mount; static vfs_cmount_t nfs_cmount; static vfs_unmount_t nfs_unmount; @@ -518,10 +521,11 @@ nfs_sec_name(char *sec, int *flagsp) static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp, - struct ucred *cred, struct thread *td) + const char *hostname, struct ucred *cred, struct thread *td) { int s; int adjsock; + char *p; s = splnet(); @@ -659,6 +663,14 @@ nfs_decode_args(struct mount *mp, struct nmp->nm_sotype = argp->sotype; nmp->nm_soproto = argp->proto; } + + if (hostname != NULL) { + strlcpy(nmp->nm_hostname, hostname, + sizeof(nmp->nm_hostname)); + p = strchr(nmp->nm_hostname, ':'); + if (p != NULL) + *p = '\0'; + } } static const char *nfs_opts[] = { "from", @@ -933,7 +945,7 @@ nfs_mount(struct mount *mp) NFSMNT_INTEGRITY | NFSMNT_PRIVACY | NFSMNT_NOLOCKD /*|NFSMNT_XLATECOOKIE*/)); - nfs_decode_args(mp, nmp, &args, td->td_ucred, td); + nfs_decode_args(mp, nmp, &args, NULL, td->td_ucred, td); goto out; } @@ -1110,13 +1122,14 @@ mountnfs(struct nfs_args *argp, struct m nmp->nm_sockreq.nr_cred = crhold(cred); mtx_init(&nmp->nm_sockreq.nr_mtx, "nfssock", NULL, MTX_DEF); mp->mnt_data = nmp; + nmp->nm_getinfo = nfs_getnlminfo; } vfs_getnewfsid(mp); nmp->nm_mountp = mp; mtx_init(&nmp->nm_mtx, "NFSmount lock", NULL, MTX_DEF | MTX_DUPOK); nmp->nm_negnametimeo = negnametimeo; - nfs_decode_args(mp, nmp, argp, cred, td); + nfs_decode_args(mp, nmp, argp, hst, cred, td); /* * V2 can only handle 32 bit filesizes. A 4GB-1 limit may be too @@ -1447,3 +1460,26 @@ nfs_sysctl(struct mount *mp, fsctlop_t o return (0); } +/* + * Extract the information needed by the nlm from the nfs vnode. + */ +static void +nfs_getnlminfo(struct vnode *vp, uint8_t *fhp, size_t *fhlenp, + struct sockaddr_storage *sp, int *is_v3p, off_t *sizep) +{ + struct nfsmount *nmp; + struct nfsnode *np = VTONFS(vp); + + nmp = VFSTONFS(vp->v_mount); + if (fhlenp != NULL) + *fhlenp = (size_t)np->n_fhp->nfh_len; + if (fhp != NULL) + bcopy(np->n_fhp->nfh_fh, fhp, np->n_fhp->nfh_len); + if (sp != NULL) + bcopy(nmp->nm_nam, sp, min(nmp->nm_nam->sa_len, sizeof(*sp))); + if (is_v3p != NULL) + *is_v3p = NFS_ISV3(vp); + if (sizep != NULL) + *sizep = np->n_size; +} + Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clvnops.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/fs/nfsclient/nfs_clvnops.c Mon Nov 1 01:03:05 2010 (r214612) @@ -84,7 +84,6 @@ __FBSDID("$FreeBSD$"); extern struct nfsstats newnfsstats; MALLOC_DECLARE(M_NEWNFSREQ); -vop_advlock_t *ncl_advlock_p = NULL; /* * Ifdef for FreeBSD-current merged buffer cache. It is unfortunate that these @@ -2937,8 +2936,8 @@ nfs_advlock(struct vop_advlock_args *ap) VOP_UNLOCK(vp, 0); error = lf_advlock(ap, &(vp->v_lockf), size); } else { - if (ncl_advlock_p) - error = ncl_advlock_p(ap); + if (nfs_advlock_p != NULL) + error = nfs_advlock_p(ap); else { VOP_UNLOCK(vp, 0); error = ENOLCK; Modified: stable/8/sys/fs/nfsclient/nfsmount.h ============================================================================== --- stable/8/sys/fs/nfsclient/nfsmount.h Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/fs/nfsclient/nfsmount.h Mon Nov 1 01:03:05 2010 (r214612) @@ -35,22 +35,19 @@ #ifndef _NFSCLIENT_NFSMOUNT_H_ #define _NFSCLIENT_NFSMOUNT_H_ +#include + /* * Mount structure. * One allocated on every NFS mount. * Holds NFS specific information for mount. */ struct nfsmount { - struct mtx nm_mtx; - int nm_flag; /* Flags for soft/hard... */ - int nm_state; /* Internal state flags */ - struct mount *nm_mountp; /* Vfs structure for this filesystem */ + struct nfsmount_common nm_com; /* Common fields for nlm */ int nm_numgrps; /* Max. size of groupslist */ u_char nm_fh[NFSX_FHMAX]; /* File handle of root dir */ int nm_fhsize; /* Size of root file handle */ struct nfssockreq nm_sockreq; /* Socket Info */ - int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */ - int nm_retry; /* Max retries */ int nm_timeouts; /* Request timeouts */ int nm_rsize; /* Max size of read rpc */ int nm_wsize; /* Max size of write rpc */ @@ -89,6 +86,14 @@ struct nfsmount { #define nm_soproto nm_sockreq.nr_soproto #define nm_client nm_sockreq.nr_client #define nm_krbname nm_name +#define nm_mtx nm_com.nmcom_mtx +#define nm_flag nm_com.nmcom_flag +#define nm_state nm_com.nmcom_state +#define nm_mountp nm_com.nmcom_mountp +#define nm_timeo nm_com.nmcom_timeo +#define nm_retry nm_com.nmcom_retry +#define nm_hostname nm_com.nmcom_hostname +#define nm_getinfo nm_com.nmcom_getinfo #define NFSMNT_DIRPATH(m) (&((m)->nm_name[(m)->nm_krbnamelen + 1])) #define NFSMNT_SRVKRBNAME(m) \ Modified: stable/8/sys/nfs/nfs_lock.c ============================================================================== --- stable/8/sys/nfs/nfs_lock.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfs/nfs_lock.c Mon Nov 1 01:03:05 2010 (r214612) @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$"); extern void (*nlminfo_release_p)(struct proc *p); +vop_advlock_t *nfs_advlock_p = nfs_dolock; +vop_reclaim_t *nfs_reclaim_p = NULL; + MALLOC_DEFINE(M_NFSLOCK, "nfsclient_lock", "NFS lock request"); MALLOC_DEFINE(M_NLMINFO, "nfsclient_nlminfo", "NFS lock process structure"); @@ -236,20 +239,19 @@ nfs_dolock(struct vop_advlock_args *ap) int error; struct flock *fl; struct proc *p; + struct nfsmount *nmp; td = curthread; p = td->td_proc; vp = ap->a_vp; fl = ap->a_fl; + nmp = VFSTONFS(vp->v_mount); ASSERT_VOP_LOCKED(vp, "nfs_dolock"); - bcopy(VFSTONFS(vp->v_mount)->nm_nam, &msg.lm_addr, - min(sizeof msg.lm_addr, VFSTONFS(vp->v_mount)->nm_nam->sa_len)); - msg.lm_fh_len = NFS_ISV3(vp) ? VTONFS(vp)->n_fhsize : NFSX_V2FH; - bcopy(VTONFS(vp)->n_fhp, msg.lm_fh, msg.lm_fh_len); - msg.lm_nfsv3 = NFS_ISV3(vp); + nmp->nm_getinfo(vp, msg.lm_fh, &msg.lm_fh_len, &msg.lm_addr, + &msg.lm_nfsv3, NULL); VOP_UNLOCK(vp, 0); /* Modified: stable/8/sys/nfs/nfs_lock.h ============================================================================== --- stable/8/sys/nfs/nfs_lock.h Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfs/nfs_lock.h Mon Nov 1 01:03:05 2010 (r214612) @@ -87,4 +87,6 @@ struct lockd_ans { #ifdef _KERNEL int nfs_dolock(struct vop_advlock_args *ap); +extern vop_advlock_t *nfs_advlock_p; +extern vop_reclaim_t *nfs_reclaim_p; #endif Copied and modified: stable/8/sys/nfs/nfs_mountcommon.h (from r214048, head/sys/nfs/nfs_mountcommon.h) ============================================================================== --- head/sys/nfs/nfs_mountcommon.h Tue Oct 19 00:20:00 2010 (r214048, copy source) +++ stable/8/sys/nfs/nfs_mountcommon.h Mon Nov 1 01:03:05 2010 (r214612) @@ -34,7 +34,7 @@ * used by the nlm. It includes a function pointer that provides * a mechanism for getting the client specific info for an nfs vnode. */ -typedef void nfs_getinfofromvp_ftype(struct vnode *, uint8_t *, int *, +typedef void nfs_getinfofromvp_ftype(struct vnode *, uint8_t *, size_t *, struct sockaddr_storage *, int *, off_t *); struct nfsmount_common { Modified: stable/8/sys/nfsclient/nfs_node.c ============================================================================== --- stable/8/sys/nfsclient/nfs_node.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfsclient/nfs_node.c Mon Nov 1 01:03:05 2010 (r214612) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include Modified: stable/8/sys/nfsclient/nfs_vfsops.c ============================================================================== --- stable/8/sys/nfsclient/nfs_vfsops.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfsclient/nfs_vfsops.c Mon Nov 1 01:03:05 2010 (r214612) @@ -115,6 +115,8 @@ static void nfs_decode_args(struct mount static int mountnfs(struct nfs_args *, struct mount *, struct sockaddr *, char *, struct vnode **, struct ucred *cred, int); +static void nfs_getnlminfo(struct vnode *, uint8_t *, size_t *, + struct sockaddr_storage *, int *, off_t *); static vfs_mount_t nfs_mount; static vfs_cmount_t nfs_cmount; static vfs_unmount_t nfs_unmount; @@ -1202,6 +1204,7 @@ mountnfs(struct nfs_args *argp, struct m bzero((caddr_t)nmp, sizeof (struct nfsmount)); TAILQ_INIT(&nmp->nm_bufq); mp->mnt_data = nmp; + nmp->nm_getinfo = nfs_getnlminfo; } vfs_getnewfsid(mp); nmp->nm_mountp = mp; @@ -1490,3 +1493,27 @@ nfs_sysctl(struct mount *mp, fsctlop_t o } return (0); } + +/* + * Extract the information needed by the nlm from the nfs vnode. + */ +static void +nfs_getnlminfo(struct vnode *vp, uint8_t *fhp, size_t *fhlenp, + struct sockaddr_storage *sp, int *is_v3p, off_t *sizep) +{ + struct nfsmount *nmp; + struct nfsnode *np = VTONFS(vp); + + nmp = VFSTONFS(vp->v_mount); + if (fhlenp != NULL) + *fhlenp = (size_t)np->n_fhsize; + if (fhp != NULL) + bcopy(np->n_fhp, fhp, np->n_fhsize); + if (sp != NULL) + bcopy(nmp->nm_nam, sp, min(nmp->nm_nam->sa_len, sizeof(*sp))); + if (is_v3p != NULL) + *is_v3p = NFS_ISV3(vp); + if (sizep != NULL) + *sizep = np->n_size; +} + Modified: stable/8/sys/nfsclient/nfs_vnops.c ============================================================================== --- stable/8/sys/nfsclient/nfs_vnops.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfsclient/nfs_vnops.c Mon Nov 1 01:03:05 2010 (r214612) @@ -215,8 +215,6 @@ struct mtx nfs_iod_mtx; enum nfsiod_state nfs_iodwant[NFS_MAXASYNCDAEMON]; struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; int nfs_numasync = 0; -vop_advlock_t *nfs_advlock_p = nfs_dolock; -vop_reclaim_t *nfs_reclaim_p = NULL; #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) SYSCTL_DECL(_vfs_nfs); Modified: stable/8/sys/nfsclient/nfsmount.h ============================================================================== --- stable/8/sys/nfsclient/nfsmount.h Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfsclient/nfsmount.h Mon Nov 1 01:03:05 2010 (r214612) @@ -36,6 +36,10 @@ #ifndef _NFSCLIENT_NFSMOUNT_H_ #define _NFSCLIENT_NFSMOUNT_H_ +#include + +#include + #include #include #include @@ -47,10 +51,7 @@ * Holds NFS specific information for mount. */ struct nfsmount { - struct mtx nm_mtx; - int nm_flag; /* Flags for soft/hard... */ - int nm_state; /* Internal state flags */ - struct mount *nm_mountp; /* Vfs structure for this filesystem */ + struct nfsmount_common nm_com; /* Common fields for nlm */ int nm_numgrps; /* Max. size of groupslist */ u_char nm_fh[NFSX_V4FH]; /* File handle of root dir */ int nm_fhsize; /* Size of root file handle */ @@ -58,8 +59,6 @@ struct nfsmount { int nm_soproto; /* and protocol */ int nm_soflags; /* pr_flags for socket protocol */ struct sockaddr *nm_nam; /* Addr of server */ - int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */ - int nm_retry; /* Max retries */ int nm_deadthresh; /* Threshold of timeouts-->dead server*/ int nm_rsize; /* Max size of read rpc */ int nm_wsize; /* Max size of write rpc */ @@ -79,7 +78,6 @@ struct nfsmount { struct nfs_rpcops *nm_rpcops; int nm_tprintf_initial_delay; /* initial delay */ int nm_tprintf_delay; /* interval for messages */ - char nm_hostname[MNAMELEN]; /* server's name */ int nm_secflavor; /* auth flavor to use for rpc */ struct __rpc_client *nm_client; struct rpc_timers nm_timers[NFS_MAX_TIMER]; /* RTT Timers for rpcs */ @@ -94,6 +92,15 @@ struct nfsmount { time_t nm_last_renewal; }; +#define nm_mtx nm_com.nmcom_mtx +#define nm_flag nm_com.nmcom_flag +#define nm_state nm_com.nmcom_state +#define nm_mountp nm_com.nmcom_mountp +#define nm_timeo nm_com.nmcom_timeo +#define nm_retry nm_com.nmcom_retry +#define nm_hostname nm_com.nmcom_hostname +#define nm_getinfo nm_com.nmcom_getinfo + #if defined(_KERNEL) /* * Convert mount ptr to nfsmount ptr. Modified: stable/8/sys/nfsclient/nfsnode.h ============================================================================== --- stable/8/sys/nfsclient/nfsnode.h Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nfsclient/nfsnode.h Mon Nov 1 01:03:05 2010 (r214612) @@ -200,9 +200,6 @@ extern struct vop_vector nfs_fifoops; extern struct vop_vector nfs_vnodeops; extern struct buf_ops buf_ops_nfs; -extern vop_advlock_t *nfs_advlock_p; -extern vop_reclaim_t *nfs_reclaim_p; - /* * Prototypes for NFS vnode operations */ Modified: stable/8/sys/nlm/nlm_advlock.c ============================================================================== --- stable/8/sys/nlm/nlm_advlock.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nlm/nlm_advlock.c Mon Nov 1 01:03:05 2010 (r214612) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -47,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -196,7 +196,6 @@ nlm_advlock_internal(struct vnode *vp, v { struct thread *td = curthread; struct nfsmount *nmp; - struct nfsnode *np; off_t size; size_t fhlen; union nfsfh fh; @@ -214,6 +213,7 @@ nlm_advlock_internal(struct vnode *vp, v struct nlm_file_svid *ns; int svid; int error; + int is_v3; ASSERT_VOP_LOCKED(vp, "nlm_advlock_1"); @@ -225,18 +225,13 @@ nlm_advlock_internal(struct vnode *vp, v if (op == F_SETLK || op == F_UNLCK) nfs_vinvalbuf(vp, V_SAVE, td, 1); - np = VTONFS(vp); nmp = VFSTONFS(vp->v_mount); - size = np->n_size; - sa = nmp->nm_nam; - memcpy(&ss, sa, sa->sa_len); - sa = (struct sockaddr *) &ss; strcpy(servername, nmp->nm_hostname); - fhlen = np->n_fhsize; - memcpy(&fh.fh_bytes, np->n_fhp, fhlen); + nmp->nm_getinfo(vp, fh.fh_bytes, &fhlen, &ss, &is_v3, &size); + sa = (struct sockaddr *) &ss; timo.tv_sec = nmp->nm_timeo / NFS_HZ; timo.tv_usec = (nmp->nm_timeo % NFS_HZ) * (1000000 / NFS_HZ); - if (NFS_ISV3(vp)) + if (is_v3 != 0) vers = NLM_VERS4; else vers = NLM_VERS; Modified: stable/8/sys/nlm/nlm_prot_impl.c ============================================================================== --- stable/8/sys/nlm/nlm_prot_impl.c Mon Nov 1 00:42:25 2010 (r214611) +++ stable/8/sys/nlm/nlm_prot_impl.c Mon Nov 1 01:03:05 2010 (r214612) @@ -54,8 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include #include #include @@ -2311,4 +2310,5 @@ DECLARE_MODULE(nfslockd, nfslockd_mod, S /* So that loader and kldload(2) can find us, wherever we are.. */ MODULE_DEPEND(nfslockd, krpc, 1, 1, 1); MODULE_DEPEND(nfslockd, nfs, 1, 1, 1); +MODULE_DEPEND(nfslockd, nfslock, 1, 1, 1); MODULE_VERSION(nfslockd, 1); From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 01:55:15 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92D57106564A; Mon, 1 Nov 2010 01:55:15 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 806EC8FC17; Mon, 1 Nov 2010 01:55:15 +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 oA11tF4P019950; Mon, 1 Nov 2010 01:55:15 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA11tF4G019948; Mon, 1 Nov 2010 01:55:15 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011010155.oA11tF4G019948@svn.freebsd.org> From: Rick Macklem Date: Mon, 1 Nov 2010 01:55:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214614 - stable/8/sys/fs/nfsserver X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 01:55:15 -0000 Author: rmacklem Date: Mon Nov 1 01:55:15 2010 New Revision: 214614 URL: http://svn.freebsd.org/changeset/base/214614 Log: MFC: r214149 Modify the experimental NFS server in a manner analagous to r214049 for the regular NFS server, so that it will not do a VOP_LOOKUP() of ".." when at the root of a file system when performing a ReaddirPlus RPC. Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- stable/8/sys/fs/nfsserver/nfs_nfsdport.c Mon Nov 1 01:51:47 2010 (r214613) +++ stable/8/sys/fs/nfsserver/nfs_nfsdport.c Mon Nov 1 01:55:15 2010 (r214614) @@ -1933,7 +1933,15 @@ again: vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - r = VOP_LOOKUP(vp, &nvp, &cn); + if ((vp->v_vflag & VV_ROOT) != 0 + && (cn.cn_flags & ISDOTDOT) + != 0) { + vref(vp); + nvp = vp; + r = 0; + } else + r = VOP_LOOKUP(vp, &nvp, + &cn); } } if (!r) { From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 02:21:36 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B4F1106566B; Mon, 1 Nov 2010 02:21:36 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E5DA8FC08; Mon, 1 Nov 2010 02:21:36 +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 oA12Lalj021092; Mon, 1 Nov 2010 02:21:36 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA12Laot021088; Mon, 1 Nov 2010 02:21:36 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011010221.oA12Laot021088@svn.freebsd.org> From: Rick Macklem Date: Mon, 1 Nov 2010 02:21:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214616 - in stable/8/sys/fs: nfs nfsserver X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 02:21:36 -0000 Author: rmacklem Date: Mon Nov 1 02:21:35 2010 New Revision: 214616 URL: http://svn.freebsd.org/changeset/base/214616 Log: MFC: r214224 Modify the file handle hash function in the experimental NFS server so that it will work better for non-UFS file systems. The new function simply sums the bytes of the fh_fid field of fhandle_t. Modified: stable/8/sys/fs/nfs/nfs_var.h stable/8/sys/fs/nfs/nfsdport.h stable/8/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfs/nfs_var.h ============================================================================== --- stable/8/sys/fs/nfs/nfs_var.h Mon Nov 1 02:20:18 2010 (r214615) +++ stable/8/sys/fs/nfs/nfs_var.h Mon Nov 1 02:21:35 2010 (r214616) @@ -578,6 +578,7 @@ void nfsvno_unlockvfs(mount_t); int nfsvno_lockvfs(mount_t); int nfsrv_v4rootexport(void *, struct ucred *, NFSPROC_T *); int nfsvno_testexp(struct nfsrv_descript *, struct nfsexstuff *); +int nfsrv_hashfh(fhandle_t *); /* nfs_commonkrpc.c */ int newnfs_nmcancelreqs(struct nfsmount *); Modified: stable/8/sys/fs/nfs/nfsdport.h ============================================================================== --- stable/8/sys/fs/nfs/nfsdport.h Mon Nov 1 02:20:18 2010 (r214615) +++ stable/8/sys/fs/nfs/nfsdport.h Mon Nov 1 02:21:35 2010 (r214616) @@ -73,7 +73,7 @@ struct nfsexstuff { bcmp(&(f1)->fh_fid, &(f2)->fh_fid, sizeof(struct fid)) == 0) #define NFSLOCKHASH(f) \ - (&nfslockhash[(*((u_int32_t *)((f)->fh_fid.fid_data))) % NFSLOCKHASHSIZE]) + (&nfslockhash[nfsrv_hashfh(f) % NFSLOCKHASHSIZE]) #define NFSFPVNODE(f) ((struct vnode *)((f)->f_data)) #define NFSFPCRED(f) ((f)->f_cred) Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- stable/8/sys/fs/nfsserver/nfs_nfsdport.c Mon Nov 1 02:20:18 2010 (r214615) +++ stable/8/sys/fs/nfsserver/nfs_nfsdport.c Mon Nov 1 02:21:35 2010 (r214616) @@ -3087,6 +3087,21 @@ nfsvno_testexp(struct nfsrv_descript *nd return (1); } +/* + * Calculate a hash value for the fid in a file handle. + */ +int +nfsrv_hashfh(fhandle_t *fhp) +{ + int hashval = 0, i; + uint8_t *cp; + + cp = (uint8_t *)&fhp->fh_fid; + for (i = 0; i < sizeof(struct fid); i++) + hashval += *cp++; + return (hashval); +} + extern int (*nfsd_call_nfsd)(struct thread *, struct nfssvc_args *); /* From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 06:17:03 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DBBA106566C; Mon, 1 Nov 2010 06:17:03 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B9D78FC16; Mon, 1 Nov 2010 06:17: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 oA16H3em035200; Mon, 1 Nov 2010 06:17:03 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA16H3ko035198; Mon, 1 Nov 2010 06:17:03 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201011010617.oA16H3ko035198@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 1 Nov 2010 06:17:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214618 - stable/8/sbin/mksnap_ffs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 06:17:03 -0000 Author: jh Date: Mon Nov 1 06:17:02 2010 New Revision: 214618 URL: http://svn.freebsd.org/changeset/base/214618 Log: MFC r213668: - Print the nmount(2) provided error message only when it is set. - Ensure that the error message is NUL-terminated before printing it. PR: bin/147482 Modified: stable/8/sbin/mksnap_ffs/mksnap_ffs.c Directory Properties: stable/8/sbin/mksnap_ffs/ (props changed) Modified: stable/8/sbin/mksnap_ffs/mksnap_ffs.c ============================================================================== --- stable/8/sbin/mksnap_ffs/mksnap_ffs.c Mon Nov 1 02:22:48 2010 (r214617) +++ stable/8/sbin/mksnap_ffs/mksnap_ffs.c Mon Nov 1 06:17:02 2010 (r214618) @@ -121,8 +121,12 @@ main(int argc, char **argv) build_iovec(&iov, &iovlen, "update", NULL, 0); build_iovec(&iov, &iovlen, "snapshot", NULL, 0); - if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) - err(1, "Cannot create snapshot %s: %s", snapname, errmsg); + *errmsg = '\0'; + if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) { + errmsg[sizeof(errmsg) - 1] = '\0'; + err(1, "Cannot create snapshot %s%s%s", snapname, + *errmsg != '\0' ? ": " : "", errmsg); + } if ((fd = open(snapname, O_RDONLY)) < 0) err(1, "Cannot open %s", snapname); if (fstat(fd, &stbuf) != 0) From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 06:19:44 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7D37106564A; Mon, 1 Nov 2010 06:19:44 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 93D768FC15; Mon, 1 Nov 2010 06:19:44 +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 oA16JiIB035525; Mon, 1 Nov 2010 06:19:44 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA16Ji7x035523; Mon, 1 Nov 2010 06:19:44 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201011010619.oA16Ji7x035523@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 1 Nov 2010 06:19:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214619 - stable/8/sbin/mount_nfs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 06:19:44 -0000 Author: jh Date: Mon Nov 1 06:19:44 2010 New Revision: 214619 URL: http://svn.freebsd.org/changeset/base/214619 Log: MFC r214419: Correct a typo. PR: 151321 Modified: stable/8/sbin/mount_nfs/mount_nfs.c Directory Properties: stable/8/sbin/mount_nfs/ (props changed) Modified: stable/8/sbin/mount_nfs/mount_nfs.c ============================================================================== --- stable/8/sbin/mount_nfs/mount_nfs.c Mon Nov 1 06:17:02 2010 (r214618) +++ stable/8/sbin/mount_nfs/mount_nfs.c Mon Nov 1 06:19:44 2010 (r214619) @@ -177,7 +177,7 @@ main(int argc, char *argv[]) mountmode = V3; break; case 'a': - printf("-a deprecated, use -o readhead=\n"); + printf("-a deprecated, use -o readahead=\n"); build_iovec(&iov, &iovlen, "readahead", optarg, (size_t)-1); break; case 'b': From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 08:12:28 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C628E106567A; Mon, 1 Nov 2010 08:12:28 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B44148FC12; Mon, 1 Nov 2010 08:12:28 +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 oA18CSqu049958; Mon, 1 Nov 2010 08:12:28 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA18CS3J049956; Mon, 1 Nov 2010 08:12:28 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201011010812.oA18CS3J049956@svn.freebsd.org> From: Andriy Gapon Date: Mon, 1 Nov 2010 08:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214620 - stable/8/sys/amd64/include X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 08:12:28 -0000 Author: avg Date: Mon Nov 1 08:12:28 2010 New Revision: 214620 URL: http://svn.freebsd.org/changeset/base/214620 Log: MFC r212784: amd64: reduce VM_KMEM_SIZE_SCALE to 1 allowing kernel to use more memory Modified: stable/8/sys/amd64/include/vmparam.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/amd64/include/vmparam.h ============================================================================== --- stable/8/sys/amd64/include/vmparam.h Mon Nov 1 06:19:44 2010 (r214619) +++ stable/8/sys/amd64/include/vmparam.h Mon Nov 1 08:12:28 2010 (r214620) @@ -194,7 +194,7 @@ * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE -#define VM_KMEM_SIZE_SCALE (3) +#define VM_KMEM_SIZE_SCALE (1) #endif /* From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 08:20:14 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9387106566B; Mon, 1 Nov 2010 08:20:14 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D67A98FC0A; Mon, 1 Nov 2010 08:20: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 oA18KEo9050502; Mon, 1 Nov 2010 08:20:14 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA18KEas050499; Mon, 1 Nov 2010 08:20:14 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201011010820.oA18KEas050499@svn.freebsd.org> From: Andriy Gapon Date: Mon, 1 Nov 2010 08:20:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214621 - in stable/8/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 08:20:15 -0000 Author: avg Date: Mon Nov 1 08:20:14 2010 New Revision: 214621 URL: http://svn.freebsd.org/changeset/base/214621 Log: MFC r213323: i386 and amd64 mp_machdep: improve topology detection for Intel CPUs Modified: stable/8/sys/amd64/amd64/mp_machdep.c stable/8/sys/i386/i386/mp_machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/mp_machdep.c Mon Nov 1 08:12:28 2010 (r214620) +++ stable/8/sys/amd64/amd64/mp_machdep.c Mon Nov 1 08:20:14 2010 (r214621) @@ -118,7 +118,6 @@ extern inthand_t IDTVEC(fast_syscall), I * Local data and functions. */ -static u_int logical_cpus; static volatile cpumask_t ipi_nmi_pending; /* used to hold the AP's until we are ready to release them */ @@ -144,8 +143,8 @@ int apic_cpuids[MAX_APIC_ID + 1]; static volatile u_int cpu_ipi_pending[MAXCPU]; static u_int boot_address; -static int cpu_logical; -static int cpu_cores; +static int cpu_logical; /* logical cpus per core */ +static int cpu_cores; /* cores per package */ static void assign_cpu_ids(void); static void set_interrupt_apic_ids(void); @@ -154,7 +153,7 @@ static int start_ap(int apic_id); static void release_aps(void *dummy); static int hlt_logical_cpus; -static u_int hyperthreading_cpus; +static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ static cpumask_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; static struct sysctl_ctx_list logical_cpu_clist; @@ -168,24 +167,105 @@ mem_range_AP_init(void) } static void +topo_probe_amd(void) +{ + + /* AMD processors do not support HTT. */ + cpu_cores = (amd_feature2 & AMDID2_CMP) != 0 ? + (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1; + cpu_logical = 1; +} + +/* + * Round up to the next power of two, if necessary, and then + * take log2. + * Returns -1 if argument is zero. + */ +static __inline int +mask_width(u_int x) +{ + + return (fls(x << (1 - powerof2(x))) - 1); +} + +static void +topo_probe_0x4(void) +{ + u_int p[4]; + int pkg_id_bits; + int core_id_bits; + int max_cores; + int max_logical; + int id; + + /* Both zero and one here mean one logical processor per package. */ + max_logical = (cpu_feature & CPUID_HTT) != 0 ? + (cpu_procinfo & CPUID_HTT_CORES) >> 16 : 1; + if (max_logical <= 1) + return; + + /* + * Because of uniformity assumption we examine only + * those logical processors that belong to the same + * package as BSP. Further, we count number of + * logical processors that belong to the same core + * as BSP thus deducing number of threads per core. + */ + cpuid_count(0x04, 0, p); + max_cores = ((p[0] >> 26) & 0x3f) + 1; + core_id_bits = mask_width(max_logical/max_cores); + if (core_id_bits < 0) + return; + pkg_id_bits = core_id_bits + mask_width(max_cores); + + for (id = 0; id <= MAX_APIC_ID; id++) { + /* Check logical CPU availability. */ + if (!cpu_info[id].cpu_present || cpu_info[id].cpu_disabled) + continue; + /* Check if logical CPU has the same package ID. */ + if ((id >> pkg_id_bits) != (boot_cpu_id >> pkg_id_bits)) + continue; + cpu_cores++; + /* Check if logical CPU has the same package and core IDs. */ + if ((id >> core_id_bits) == (boot_cpu_id >> core_id_bits)) + cpu_logical++; + } + + cpu_cores /= cpu_logical; + hyperthreading_cpus = cpu_logical; +} + +static void topo_probe_0xb(void) { - int logical; - int p[4]; + u_int p[4]; int bits; - int type; int cnt; int i; + int logical; + int type; int x; - /* We only support two levels for now. */ + /* We only support three levels for now. */ for (i = 0; i < 3; i++) { - cpuid_count(0x0B, i, p); + cpuid_count(0x0b, i, p); + + /* Fall back if CPU leaf 11 doesn't really exist. */ + if (i == 0 && p[1] == 0) { + topo_probe_0x4(); + return; + } + bits = p[0] & 0x1f; logical = p[1] &= 0xffff; type = (p[2] >> 8) & 0xff; if (type == 0 || logical == 0) break; + /* + * Because of uniformity assumption we examine only + * those logical processors that belong to the same + * package as BSP. + */ for (cnt = 0, x = 0; x <= MAX_APIC_ID; x++) { if (!cpu_info[x].cpu_present || cpu_info[x].cpu_disabled) @@ -203,76 +283,16 @@ topo_probe_0xb(void) cpu_cores /= cpu_logical; } -static void -topo_probe_0x4(void) -{ - u_int threads_per_cache, p[4]; - u_int htt, cmp; - int i; - - htt = cmp = 1; - /* - * If this CPU supports HTT or CMP then mention the - * number of physical/logical cores it contains. - */ - if (cpu_feature & CPUID_HTT) - htt = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - if (cpu_vendor_id == CPU_VENDOR_AMD && (amd_feature2 & AMDID2_CMP)) - cmp = (cpu_procinfo2 & AMDID_CMP_CORES) + 1; - else if (cpu_vendor_id == CPU_VENDOR_INTEL && (cpu_high >= 4)) { - cpuid_count(4, 0, p); - if ((p[0] & 0x1f) != 0) - cmp = ((p[0] >> 26) & 0x3f) + 1; - } - cpu_cores = cmp; - cpu_logical = htt / cmp; - - /* Setup the initial logical CPUs info. */ - if (cpu_feature & CPUID_HTT) - logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - - /* - * Work out if hyperthreading is *really* enabled. This - * is made really ugly by the fact that processors lie: Dual - * core processors claim to be hyperthreaded even when they're - * not, presumably because they want to be treated the same - * way as HTT with respect to per-cpu software licensing. - * At the time of writing (May 12, 2005) the only hyperthreaded - * cpus are from Intel, and Intel's dual-core processors can be - * identified via the "deterministic cache parameters" cpuid - * calls. - */ - /* - * First determine if this is an Intel processor which claims - * to have hyperthreading support. - */ - if ((cpu_feature & CPUID_HTT) && cpu_vendor_id == CPU_VENDOR_INTEL) { - /* - * If the "deterministic cache parameters" cpuid calls - * are available, use them. - */ - if (cpu_high >= 4) { - /* Ask the processor about the L1 cache. */ - for (i = 0; i < 1; i++) { - cpuid_count(4, i, p); - threads_per_cache = ((p[0] & 0x3ffc000) >> 14) + 1; - if (hyperthreading_cpus < threads_per_cache) - hyperthreading_cpus = threads_per_cache; - if ((p[0] & 0x1f) == 0) - break; - } - } - - /* - * If the deterministic cache parameters are not - * available, or if no caches were reported to exist, - * just accept what the HTT flag indicated. - */ - if (hyperthreading_cpus == 0) - hyperthreading_cpus = logical_cpus; - } -} - +/* + * Both topology discovery code and code that consumes topology + * information assume top-down uniformity of the topology. + * That is, all physical packages must be identical and each + * core in a package must have the same number of threads. + * Topology information is queried only on BSP, on which this + * code runs and for which it can query CPUID information. + * Then topology is extrapolated on all packages using the + * uniformity assumption. + */ static void topo_probe(void) { @@ -281,13 +301,31 @@ topo_probe(void) if (cpu_topo_probed) return; - logical_cpus = logical_cpus_mask = 0; - if (cpu_high >= 0xb) - topo_probe_0xb(); - else if (cpu_high) - topo_probe_0x4(); + logical_cpus_mask = 0; + if (cpu_vendor_id == CPU_VENDOR_AMD) + topo_probe_amd(); + else if (cpu_vendor_id == CPU_VENDOR_INTEL) { + /* + * See Intel(R) 64 Architecture Processor + * Topology Enumeration article for details. + * + * Note that 0x1 <= cpu_high < 4 case should be + * compatible with topo_probe_0x4() logic when + * CPUID.1:EBX[23:16] > 0 (cpu_cores will be 1) + * or it should trigger the fallback otherwise. + */ + if (cpu_high >= 0xb) + topo_probe_0xb(); + else if (cpu_high >= 0x1) + topo_probe_0x4(); + } + + /* + * Fallback: assume each logical CPU is in separate + * physical package. That is, no multi-core, no SMT. + */ if (cpu_cores == 0) - cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1; + cpu_cores = 1; if (cpu_logical == 0) cpu_logical = 1; cpu_topo_probed = 1; @@ -667,7 +705,8 @@ init_secondary(void) printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); /* Determine if we are a logical CPU. */ - if (logical_cpus > 1 && PCPU_GET(apic_id) % logical_cpus != 0) + /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ + if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) logical_cpus_mask |= PCPU_GET(cpumask); /* Determine if we are a hyperthread. */ Modified: stable/8/sys/i386/i386/mp_machdep.c ============================================================================== --- stable/8/sys/i386/i386/mp_machdep.c Mon Nov 1 08:12:28 2010 (r214620) +++ stable/8/sys/i386/i386/mp_machdep.c Mon Nov 1 08:20:14 2010 (r214621) @@ -172,7 +172,6 @@ u_long *ipi_lazypmap_counts[MAXCPU]; * Local data and functions. */ -static u_int logical_cpus; static volatile cpumask_t ipi_nmi_pending; /* used to hold the AP's until we are ready to release them */ @@ -198,8 +197,8 @@ int apic_cpuids[MAX_APIC_ID + 1]; static volatile u_int cpu_ipi_pending[MAXCPU]; static u_int boot_address; -static int cpu_logical; -static int cpu_cores; +static int cpu_logical; /* logical cpus per core */ +static int cpu_cores; /* cores per package */ static void assign_cpu_ids(void); static void install_ap_tramp(void); @@ -209,7 +208,7 @@ static int start_ap(int apic_id); static void release_aps(void *dummy); static int hlt_logical_cpus; -static u_int hyperthreading_cpus; +static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ static cpumask_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; static struct sysctl_ctx_list logical_cpu_clist; @@ -222,24 +221,105 @@ mem_range_AP_init(void) } static void +topo_probe_amd(void) +{ + + /* AMD processors do not support HTT. */ + cpu_cores = (amd_feature2 & AMDID2_CMP) != 0 ? + (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1; + cpu_logical = 1; +} + +/* + * Round up to the next power of two, if necessary, and then + * take log2. + * Returns -1 if argument is zero. + */ +static __inline int +mask_width(u_int x) +{ + + return (fls(x << (1 - powerof2(x))) - 1); +} + +static void +topo_probe_0x4(void) +{ + u_int p[4]; + int pkg_id_bits; + int core_id_bits; + int max_cores; + int max_logical; + int id; + + /* Both zero and one here mean one logical processor per package. */ + max_logical = (cpu_feature & CPUID_HTT) != 0 ? + (cpu_procinfo & CPUID_HTT_CORES) >> 16 : 1; + if (max_logical <= 1) + return; + + /* + * Because of uniformity assumption we examine only + * those logical processors that belong to the same + * package as BSP. Further, we count number of + * logical processors that belong to the same core + * as BSP thus deducing number of threads per core. + */ + cpuid_count(0x04, 0, p); + max_cores = ((p[0] >> 26) & 0x3f) + 1; + core_id_bits = mask_width(max_logical/max_cores); + if (core_id_bits < 0) + return; + pkg_id_bits = core_id_bits + mask_width(max_cores); + + for (id = 0; id <= MAX_APIC_ID; id++) { + /* Check logical CPU availability. */ + if (!cpu_info[id].cpu_present || cpu_info[id].cpu_disabled) + continue; + /* Check if logical CPU has the same package ID. */ + if ((id >> pkg_id_bits) != (boot_cpu_id >> pkg_id_bits)) + continue; + cpu_cores++; + /* Check if logical CPU has the same package and core IDs. */ + if ((id >> core_id_bits) == (boot_cpu_id >> core_id_bits)) + cpu_logical++; + } + + cpu_cores /= cpu_logical; + hyperthreading_cpus = cpu_logical; +} + +static void topo_probe_0xb(void) { - int logical; - int p[4]; + u_int p[4]; int bits; - int type; int cnt; int i; + int logical; + int type; int x; - /* We only support two levels for now. */ + /* We only support three levels for now. */ for (i = 0; i < 3; i++) { - cpuid_count(0x0B, i, p); + cpuid_count(0x0b, i, p); + + /* Fall back if CPU leaf 11 doesn't really exist. */ + if (i == 0 && p[1] == 0) { + topo_probe_0x4(); + return; + } + bits = p[0] & 0x1f; logical = p[1] &= 0xffff; type = (p[2] >> 8) & 0xff; if (type == 0 || logical == 0) break; + /* + * Because of uniformity assumption we examine only + * those logical processors that belong to the same + * package as BSP. + */ for (cnt = 0, x = 0; x <= MAX_APIC_ID; x++) { if (!cpu_info[x].cpu_present || cpu_info[x].cpu_disabled) @@ -257,76 +337,16 @@ topo_probe_0xb(void) cpu_cores /= cpu_logical; } -static void -topo_probe_0x4(void) -{ - u_int threads_per_cache, p[4]; - u_int htt, cmp; - int i; - - htt = cmp = 1; - /* - * If this CPU supports HTT or CMP then mention the - * number of physical/logical cores it contains. - */ - if (cpu_feature & CPUID_HTT) - htt = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - if (cpu_vendor_id == CPU_VENDOR_AMD && (amd_feature2 & AMDID2_CMP)) - cmp = (cpu_procinfo2 & AMDID_CMP_CORES) + 1; - else if (cpu_vendor_id == CPU_VENDOR_INTEL && (cpu_high >= 4)) { - cpuid_count(4, 0, p); - if ((p[0] & 0x1f) != 0) - cmp = ((p[0] >> 26) & 0x3f) + 1; - } - cpu_cores = cmp; - cpu_logical = htt / cmp; - - /* Setup the initial logical CPUs info. */ - if (cpu_feature & CPUID_HTT) - logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - - /* - * Work out if hyperthreading is *really* enabled. This - * is made really ugly by the fact that processors lie: Dual - * core processors claim to be hyperthreaded even when they're - * not, presumably because they want to be treated the same - * way as HTT with respect to per-cpu software licensing. - * At the time of writing (May 12, 2005) the only hyperthreaded - * cpus are from Intel, and Intel's dual-core processors can be - * identified via the "deterministic cache parameters" cpuid - * calls. - */ - /* - * First determine if this is an Intel processor which claims - * to have hyperthreading support. - */ - if ((cpu_feature & CPUID_HTT) && cpu_vendor_id == CPU_VENDOR_INTEL) { - /* - * If the "deterministic cache parameters" cpuid calls - * are available, use them. - */ - if (cpu_high >= 4) { - /* Ask the processor about the L1 cache. */ - for (i = 0; i < 1; i++) { - cpuid_count(4, i, p); - threads_per_cache = ((p[0] & 0x3ffc000) >> 14) + 1; - if (hyperthreading_cpus < threads_per_cache) - hyperthreading_cpus = threads_per_cache; - if ((p[0] & 0x1f) == 0) - break; - } - } - - /* - * If the deterministic cache parameters are not - * available, or if no caches were reported to exist, - * just accept what the HTT flag indicated. - */ - if (hyperthreading_cpus == 0) - hyperthreading_cpus = logical_cpus; - } -} - +/* + * Both topology discovery code and code that consumes topology + * information assume top-down uniformity of the topology. + * That is, all physical packages must be identical and each + * core in a package must have the same number of threads. + * Topology information is queried only on BSP, on which this + * code runs and for which it can query CPUID information. + * Then topology is extrapolated on all packages using the + * uniformity assumption. + */ static void topo_probe(void) { @@ -335,13 +355,31 @@ topo_probe(void) if (cpu_topo_probed) return; - logical_cpus = logical_cpus_mask = 0; - if (cpu_high >= 0xb) - topo_probe_0xb(); - else if (cpu_high) - topo_probe_0x4(); + logical_cpus_mask = 0; + if (cpu_vendor_id == CPU_VENDOR_AMD) + topo_probe_amd(); + else if (cpu_vendor_id == CPU_VENDOR_INTEL) { + /* + * See Intel(R) 64 Architecture Processor + * Topology Enumeration article for details. + * + * Note that 0x1 <= cpu_high < 4 case should be + * compatible with topo_probe_0x4() logic when + * CPUID.1:EBX[23:16] > 0 (cpu_cores will be 1) + * or it should trigger the fallback otherwise. + */ + if (cpu_high >= 0xb) + topo_probe_0xb(); + else if (cpu_high >= 0x1) + topo_probe_0x4(); + } + + /* + * Fallback: assume each logical CPU is in separate + * physical package. That is, no multi-core, no SMT. + */ if (cpu_cores == 0) - cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1; + cpu_cores = 1; if (cpu_logical == 0) cpu_logical = 1; cpu_topo_probed = 1; @@ -705,7 +743,8 @@ init_secondary(void) printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); /* Determine if we are a logical CPU. */ - if (logical_cpus > 1 && PCPU_GET(apic_id) % logical_cpus != 0) + /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ + if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) logical_cpus_mask |= PCPU_GET(cpumask); /* Determine if we are a hyperthread. */ From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 11:38:04 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 783ED1065670; Mon, 1 Nov 2010 11:38:04 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 65B598FC0C; Mon, 1 Nov 2010 11:38:04 +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 oA1Bc4XU061103; Mon, 1 Nov 2010 11:38:04 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA1Bc4rR061101; Mon, 1 Nov 2010 11:38:04 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201011011138.oA1Bc4rR061101@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 1 Nov 2010 11:38:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214624 - stable/8/lib/libc/posix1e X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 11:38:04 -0000 Author: trasz Date: Mon Nov 1 11:38:04 2010 New Revision: 214624 URL: http://svn.freebsd.org/changeset/base/214624 Log: MFC r212376: Add minor optimization. It's less strict than its kernel counterpart due to upcoming ACL changes required by the new ZFS. MFC r212379: Fix previous commit. Modified: stable/8/lib/libc/posix1e/acl_strip.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/posix1e/acl_strip.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_strip.c Mon Nov 1 10:42:14 2010 (r214623) +++ stable/8/lib/libc/posix1e/acl_strip.c Mon Nov 1 11:38:04 2010 (r214624) @@ -176,6 +176,15 @@ acl_is_trivial_np(const acl_t aclp, int case ACL_BRAND_NFS4: /* + * If the ACL has more than canonical six entries, + * it's non trivial by definition. + */ + if (aclp->ats_acl.acl_cnt > 6) { + *trivialp = 0; + return (0); + } + + /* * Calculate trivial ACL - using acl_strip_np - and compare * with the original. */ From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 15:36:48 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50718106566C; Mon, 1 Nov 2010 15:36:48 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C8468FC14; Mon, 1 Nov 2010 15:36:48 +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 oA1Famwk069805; Mon, 1 Nov 2010 15:36:48 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA1FamsX069801; Mon, 1 Nov 2010 15:36:48 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201011011536.oA1FamsX069801@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 1 Nov 2010 15:36:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214626 - in stable/8: lib/libc/posix1e sys/kern sys/sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 15:36:48 -0000 Author: trasz Date: Mon Nov 1 15:36:47 2010 New Revision: 214626 URL: http://svn.freebsd.org/changeset/base/214626 Log: MFC r212906: First step at adopting FreeBSD to support PSARC/2010/029. This makes acl_is_trivial_np(3) properly recognize the new trivial ACLs. From the user point of view, that means "ls -l" no longer shows plus signs for all the files when running ZFS v28. Modified: stable/8/lib/libc/posix1e/acl_strip.c stable/8/sys/kern/subr_acl_nfs4.c stable/8/sys/sys/acl.h Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/lib/libc/posix1e/acl_strip.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_strip.c Mon Nov 1 15:18:57 2010 (r214625) +++ stable/8/lib/libc/posix1e/acl_strip.c Mon Nov 1 15:36:47 2010 (r214626) @@ -31,19 +31,21 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "acl_support.h" /* - * These two routines from sys/kern/subr_acl_nfs4.c are used by both kernel + * These three routines from sys/kern/subr_acl_nfs4.c are used by both kernel * and libc. */ +void acl_nfs4_trivial_from_mode(struct acl *aclp, mode_t mode); void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode, int file_owner_id); void acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *aclp); static acl_t -_nfs4_acl_strip_np(const acl_t aclp, int recalculate_mask) +_nfs4_acl_strip_np(const acl_t aclp, int canonical_six) { acl_t newacl; mode_t mode = 0; @@ -57,7 +59,10 @@ _nfs4_acl_strip_np(const acl_t aclp, int _acl_brand_as(newacl, ACL_BRAND_NFS4); acl_nfs4_sync_mode_from_acl(&mode, &(aclp->ats_acl)); - acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1); + if (canonical_six) + acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1); + else + acl_nfs4_trivial_from_mode(&(newacl->ats_acl), mode); return (newacl); } @@ -136,7 +141,7 @@ acl_strip_np(const acl_t aclp, int recal { switch (_acl_brand(aclp)) { case ACL_BRAND_NFS4: - return (_nfs4_acl_strip_np(aclp, recalculate_mask)); + return (_nfs4_acl_strip_np(aclp, 1)); case ACL_BRAND_POSIX: return (_posix1e_acl_strip_np(aclp, recalculate_mask)); @@ -185,10 +190,25 @@ acl_is_trivial_np(const acl_t aclp, int } /* - * Calculate trivial ACL - using acl_strip_np - and compare + * Calculate trivial ACL - using acl_strip_np(3) - and compare * with the original. */ - tmpacl = acl_strip_np(aclp, 0); + tmpacl = _nfs4_acl_strip_np(aclp, 0); + if (tmpacl == NULL) + return (-1); + + differs = _acl_differs(aclp, tmpacl); + acl_free(tmpacl); + + if (differs == 0) { + *trivialp = 1; + return (0); + } + + /* + * Try again with an old-style, "canonical six" trivial ACL. + */ + tmpacl = _nfs4_acl_strip_np(aclp, 1); if (tmpacl == NULL) return (-1); Modified: stable/8/sys/kern/subr_acl_nfs4.c ============================================================================== --- stable/8/sys/kern/subr_acl_nfs4.c Mon Nov 1 15:18:57 2010 (r214625) +++ stable/8/sys/kern/subr_acl_nfs4.c Mon Nov 1 15:36:47 2010 (r214626) @@ -323,6 +323,83 @@ _acl_duplicate_entry(struct acl *aclp, i return (&(aclp->acl_entry[entry_index + 1])); } +/* + * Calculate trivial ACL in a manner compatible with PSARC/2010/029. + * Note that this results in an ACL different from (but semantically + * equal to) the "canonical six" trivial ACL computed using algorithm + * described in draft-ietf-nfsv4-minorversion1-03.txt, 3.16.6.2. + */ +void +acl_nfs4_trivial_from_mode(struct acl *aclp, mode_t mode) +{ + acl_perm_t user_allow_first = 0, user_deny = 0, group_deny = 0; + acl_perm_t user_allow, group_allow, everyone_allow; + + KASSERT(aclp->acl_cnt == 0, ("aclp->acl_cnt == 0")); + + user_allow = group_allow = everyone_allow = ACL_READ_ACL | + ACL_READ_ATTRIBUTES | ACL_READ_NAMED_ATTRS | ACL_SYNCHRONIZE; + user_allow |= ACL_WRITE_ACL | ACL_WRITE_OWNER | ACL_WRITE_ATTRIBUTES | + ACL_WRITE_NAMED_ATTRS; + + if (mode & S_IRUSR) + user_allow |= ACL_READ_DATA; + if (mode & S_IWUSR) + user_allow |= (ACL_WRITE_DATA | ACL_APPEND_DATA); + if (mode & S_IXUSR) + user_allow |= ACL_EXECUTE; + + if (mode & S_IRGRP) + group_allow |= ACL_READ_DATA; + if (mode & S_IWGRP) + group_allow |= (ACL_WRITE_DATA | ACL_APPEND_DATA); + if (mode & S_IXGRP) + group_allow |= ACL_EXECUTE; + + if (mode & S_IROTH) + everyone_allow |= ACL_READ_DATA; + if (mode & S_IWOTH) + everyone_allow |= (ACL_WRITE_DATA | ACL_APPEND_DATA); + if (mode & S_IXOTH) + everyone_allow |= ACL_EXECUTE; + + user_deny = ((group_allow | everyone_allow) & ~user_allow); + group_deny = everyone_allow & ~group_allow; + user_allow_first = group_deny & ~user_deny; + +#if 1 + /* + * This is a workaround for what looks like a bug in ZFS - trivial + * ACL for mode 0077 should look like this: + * + * owner@:rwxp----------:------:deny + * owner@:------aARWcCos:------:allow + * group@:rwxp--a-R-c--s:------:allow + * everyone@:rwxp--a-R-c--s:------:allow + * + * Instead, ZFS makes it like this: + * + * owner@:rwx-----------:------:deny + * owner@:------aARWcCos:------:allow + * group@:rwxp--a-R-c--s:------:allow + * everyone@:rwxp--a-R-c--s:------:allow + */ + user_allow_first &= ~ACL_APPEND_DATA; + user_deny &= ~ACL_APPEND_DATA; + group_deny &= ~ACL_APPEND_DATA; +#endif + + if (user_allow_first != 0) + _acl_append(aclp, ACL_USER_OBJ, user_allow_first, ACL_ENTRY_TYPE_ALLOW); + if (user_deny != 0) + _acl_append(aclp, ACL_USER_OBJ, user_deny, ACL_ENTRY_TYPE_DENY); + if (group_deny != 0) + _acl_append(aclp, ACL_GROUP_OBJ, group_deny, ACL_ENTRY_TYPE_DENY); + _acl_append(aclp, ACL_USER_OBJ, user_allow, ACL_ENTRY_TYPE_ALLOW); + _acl_append(aclp, ACL_GROUP_OBJ, group_allow, ACL_ENTRY_TYPE_ALLOW); + _acl_append(aclp, ACL_EVERYONE, everyone_allow, ACL_ENTRY_TYPE_ALLOW); +} + void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode, int file_owner_id) { Modified: stable/8/sys/sys/acl.h ============================================================================== --- stable/8/sys/sys/acl.h Mon Nov 1 15:18:57 2010 (r214625) +++ stable/8/sys/sys/acl.h Mon Nov 1 15:36:47 2010 (r214626) @@ -285,6 +285,8 @@ mode_t acl_posix1e_newfilemode(mode_t struct acl *acl_alloc(int flags); void acl_free(struct acl *aclp); +void acl_nfs4_trivial_from_mode(struct acl *aclp, + mode_t mode); void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode, int file_owner_id); void acl_nfs4_sync_mode_from_acl(mode_t *mode, From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 15:43:43 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28C22106566B; Mon, 1 Nov 2010 15:43:43 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 162478FC23; Mon, 1 Nov 2010 15:43:43 +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 oA1Fhg4R070236; Mon, 1 Nov 2010 15:43:42 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA1FhgHV070234; Mon, 1 Nov 2010 15:43:42 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201011011543.oA1FhgHV070234@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 1 Nov 2010 15:43:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214627 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 15:43:43 -0000 Author: trasz Date: Mon Nov 1 15:43:42 2010 New Revision: 214627 URL: http://svn.freebsd.org/changeset/base/214627 Log: MFC r214245: Remove workaround for ZFS bug; fix was committed to the //depot/user/pjd/zfs/... branch some time ago. Modified: stable/8/sys/kern/subr_acl_nfs4.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/kern/subr_acl_nfs4.c ============================================================================== --- stable/8/sys/kern/subr_acl_nfs4.c Mon Nov 1 15:36:47 2010 (r214626) +++ stable/8/sys/kern/subr_acl_nfs4.c Mon Nov 1 15:43:42 2010 (r214627) @@ -367,28 +367,6 @@ acl_nfs4_trivial_from_mode(struct acl *a group_deny = everyone_allow & ~group_allow; user_allow_first = group_deny & ~user_deny; -#if 1 - /* - * This is a workaround for what looks like a bug in ZFS - trivial - * ACL for mode 0077 should look like this: - * - * owner@:rwxp----------:------:deny - * owner@:------aARWcCos:------:allow - * group@:rwxp--a-R-c--s:------:allow - * everyone@:rwxp--a-R-c--s:------:allow - * - * Instead, ZFS makes it like this: - * - * owner@:rwx-----------:------:deny - * owner@:------aARWcCos:------:allow - * group@:rwxp--a-R-c--s:------:allow - * everyone@:rwxp--a-R-c--s:------:allow - */ - user_allow_first &= ~ACL_APPEND_DATA; - user_deny &= ~ACL_APPEND_DATA; - group_deny &= ~ACL_APPEND_DATA; -#endif - if (user_allow_first != 0) _acl_append(aclp, ACL_USER_OBJ, user_allow_first, ACL_ENTRY_TYPE_ALLOW); if (user_deny != 0) From owner-svn-src-stable-8@FreeBSD.ORG Mon Nov 1 19:05:38 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A78AA106564A; Mon, 1 Nov 2010 19:05:38 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A81E8FC08; Mon, 1 Nov 2010 19:05:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA1J5cd9083203; Mon, 1 Nov 2010 19:05:38 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA1J5ccU083201; Mon, 1 Nov 2010 19:05:38 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201011011905.oA1J5ccU083201@svn.freebsd.org> From: Bernhard Schmidt Date: Mon, 1 Nov 2010 19:05:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214633 - stable/8/sys/dev/iwi X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Nov 2010 19:05:38 -0000 Author: bschmidt Date: Mon Nov 1 19:05:38 2010 New Revision: 214633 URL: http://svn.freebsd.org/changeset/base/214633 Log: MFC r214160,214162,214236 r214236 & r214160: The firmware does pad notifications to an even number of bytes (at least the association notification), the included information though always contains an elem block with an odd number of bytes. We handle the last byte as if it might contain a whole elem block, this of course is not true as one byte is not enough to hold a block, we therefore discard the complete frame. The solution here is to subtract one from the actual notification length, this is also what the Linux driver does. With this change the frame ends exactly where the last elem block ends. r214262: The firmware always sets bit 14 and 15, to get the real associd we need to clear those bits. Modified: stable/8/sys/dev/iwi/if_iwi.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/iwi/if_iwi.c ============================================================================== --- stable/8/sys/dev/iwi/if_iwi.c Mon Nov 1 19:04:16 2010 (r214632) +++ stable/8/sys/dev/iwi/if_iwi.c Mon Nov 1 19:05:38 2010 (r214633) @@ -1368,7 +1368,7 @@ iwi_checkforqos(struct ieee80211vap *vap ni = vap->iv_bss; ni->ni_capinfo = capinfo; - ni->ni_associd = associd; + ni->ni_associd = associd & 0x3fff; if (wme != NULL) ni->ni_flags |= IEEE80211_NODE_QOS; else @@ -1483,7 +1483,7 @@ iwi_notification_intr(struct iwi_softc * IWI_STATE_END(sc, IWI_FW_ASSOCIATING); iwi_checkforqos(vap, (const struct ieee80211_frame *)(assoc+1), - le16toh(notif->len) - sizeof(*assoc)); + le16toh(notif->len) - sizeof(*assoc) - 1); ieee80211_new_state(vap, IEEE80211_S_RUN, -1); break; case IWI_ASSOC_INIT: From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 07:56:20 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0A0D106566B; Tue, 2 Nov 2010 07:56:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BD30F8FC0C; Tue, 2 Nov 2010 07:56:20 +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 oA27uK9M027308; Tue, 2 Nov 2010 07:56:20 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA27uKgk027306; Tue, 2 Nov 2010 07:56:20 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201011020756.oA27uKgk027306@svn.freebsd.org> From: Andriy Gapon Date: Tue, 2 Nov 2010 07:56:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214662 - stable/8/sys/dev/acpica X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 07:56:20 -0000 Author: avg Date: Tue Nov 2 07:56:20 2010 New Revision: 214662 URL: http://svn.freebsd.org/changeset/base/214662 Log: MFC r213737: acpi_ec: changes in communication with hardware Modified: stable/8/sys/dev/acpica/acpi_ec.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/acpica/acpi_ec.c ============================================================================== --- stable/8/sys/dev/acpica/acpi_ec.c Tue Nov 2 07:49:21 2010 (r214661) +++ stable/8/sys/dev/acpica/acpi_ec.c Tue Nov 2 07:56:20 2010 (r214662) @@ -153,7 +153,7 @@ struct acpi_ec_softc { int ec_glkhandle; int ec_burstactive; int ec_sci_pend; - u_int ec_gencount; + volatile u_int ec_gencount; int ec_suspending; }; @@ -165,7 +165,7 @@ struct acpi_ec_softc { #define EC_LOCK_TIMEOUT 1000 /* Default delay in microseconds between each run of the status polling loop. */ -#define EC_POLL_DELAY 5 +#define EC_POLL_DELAY 50 /* Total time in ms spent waiting for a response from EC. */ #define EC_TIMEOUT 750 @@ -600,12 +600,32 @@ acpi_ec_write_method(device_t dev, u_int return (0); } +static ACPI_STATUS +EcCheckStatus(struct acpi_ec_softc *sc, const char *msg, EC_EVENT event) +{ + ACPI_STATUS status; + EC_STATUS ec_status; + + status = AE_NO_HARDWARE_RESPONSE; + ec_status = EC_GET_CSR(sc); + if (sc->ec_burstactive && !(ec_status & EC_FLAG_BURST_MODE)) { + CTR1(KTR_ACPI, "ec burst disabled in waitevent (%s)", msg); + sc->ec_burstactive = FALSE; + } + if (EVENT_READY(event, ec_status)) { + CTR2(KTR_ACPI, "ec %s wait ready, status %#x", msg, ec_status); + status = AE_OK; + } + return (status); +} + static void EcGpeQueryHandler(void *Context) { struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context; UINT8 Data; ACPI_STATUS Status; + int retry; char qxx[5]; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -626,7 +646,16 @@ EcGpeQueryHandler(void *Context) * that may arise from running the query from causing another query * to be queued, we clear the pending flag only after running it. */ - Status = EcCommand(sc, EC_COMMAND_QUERY); + for (retry = 0; retry < 2; retry++) { + Status = EcCommand(sc, EC_COMMAND_QUERY); + if (ACPI_SUCCESS(Status)) + break; + if (EcCheckStatus(sc, "retr_check", + EC_EVENT_INPUT_BUFFER_EMPTY) == AE_OK) + continue; + else + break; + } sc->ec_sci_pend = FALSE; if (ACPI_FAILURE(Status)) { EcUnlock(sc); @@ -679,7 +708,7 @@ EcGpeHandler(void *Context) * address and then data values.) */ atomic_add_int(&sc->ec_gencount, 1); - wakeup(&sc->ec_gencount); + wakeup(&sc); /* * If the EC_SCI bit of the status register is set, queue a query handler. @@ -790,68 +819,27 @@ EcSpaceHandler(UINT32 Function, ACPI_PHY } static ACPI_STATUS -EcCheckStatus(struct acpi_ec_softc *sc, const char *msg, EC_EVENT event) -{ - ACPI_STATUS status; - EC_STATUS ec_status; - - status = AE_NO_HARDWARE_RESPONSE; - ec_status = EC_GET_CSR(sc); - if (sc->ec_burstactive && !(ec_status & EC_FLAG_BURST_MODE)) { - CTR1(KTR_ACPI, "ec burst disabled in waitevent (%s)", msg); - sc->ec_burstactive = FALSE; - } - if (EVENT_READY(event, ec_status)) { - CTR2(KTR_ACPI, "ec %s wait ready, status %#x", msg, ec_status); - status = AE_OK; - } - return (status); -} - -static ACPI_STATUS EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event, u_int gen_count) { + static int no_intr = 0; ACPI_STATUS Status; - int count, i, slp_ival; + int count, i, need_poll, slp_ival; ACPI_SERIAL_ASSERT(ec); Status = AE_NO_HARDWARE_RESPONSE; - int need_poll = cold || rebooting || ec_polled_mode || sc->ec_suspending; - /* - * The main CPU should be much faster than the EC. So the status should - * be "not ready" when we start waiting. But if the main CPU is really - * slow, it's possible we see the current "ready" response. Since that - * can't be distinguished from the previous response in polled mode, - * this is a potential issue. We really should have interrupts enabled - * during boot so there is no ambiguity in polled mode. - * - * If this occurs, we add an additional delay before actually entering - * the status checking loop, hopefully to allow the EC to go to work - * and produce a non-stale status. - */ - if (need_poll) { - static int once; - - if (EcCheckStatus(sc, "pre-check", Event) == AE_OK) { - if (!once) { - device_printf(sc->ec_dev, - "warning: EC done before starting event wait\n"); - once = 1; - } - AcpiOsStall(10); - } - } + need_poll = cold || rebooting || ec_polled_mode || sc->ec_suspending; /* Wait for event by polling or GPE (interrupt). */ if (need_poll) { count = (ec_timeout * 1000) / EC_POLL_DELAY; if (count == 0) count = 1; + DELAY(10); for (i = 0; i < count; i++) { Status = EcCheckStatus(sc, "poll", Event); if (Status == AE_OK) break; - AcpiOsStall(EC_POLL_DELAY); + DELAY(EC_POLL_DELAY); } } else { slp_ival = hz / 1000; @@ -870,34 +858,37 @@ EcWaitEvent(struct acpi_ec_softc *sc, EC * EC query). */ for (i = 0; i < count; i++) { - if (gen_count != sc->ec_gencount) { - /* - * Record new generation count. It's possible the GPE was - * just to notify us that a query is needed and we need to - * wait for a second GPE to signal the completion of the - * event we are actually waiting for. - */ - gen_count = sc->ec_gencount; - Status = EcCheckStatus(sc, "sleep", Event); - if (Status == AE_OK) - break; + if (gen_count == sc->ec_gencount) + tsleep(&sc, 0, "ecgpe", slp_ival); + /* + * Record new generation count. It's possible the GPE was + * just to notify us that a query is needed and we need to + * wait for a second GPE to signal the completion of the + * event we are actually waiting for. + */ + Status = EcCheckStatus(sc, "sleep", Event); + if (Status == AE_OK) { + if (gen_count == sc->ec_gencount) + no_intr++; + else + no_intr = 0; + break; } - tsleep(&sc->ec_gencount, PZERO, "ecgpe", slp_ival); + gen_count = sc->ec_gencount; } /* * We finished waiting for the GPE and it never arrived. Try to * read the register once and trust whatever value we got. This is - * the best we can do at this point. Then, force polled mode on - * since this system doesn't appear to generate GPEs. + * the best we can do at this point. */ - if (Status != AE_OK) { + if (Status != AE_OK) Status = EcCheckStatus(sc, "sleep_end", Event); - device_printf(sc->ec_dev, - "wait timed out (%sresponse), forcing polled mode\n", - Status == AE_OK ? "" : "no "); - ec_polled_mode = TRUE; - } + } + if (!need_poll && no_intr > 10) { + device_printf(sc->ec_dev, + "not getting interrupts, switched to polled mode\n"); + ec_polled_mode = 1; } if (Status != AE_OK) CTR0(KTR_ACPI, "error: ec wait timed out"); @@ -934,6 +925,14 @@ EcCommand(struct acpi_ec_softc *sc, EC_C return (AE_BAD_PARAMETER); } + /* + * Ensure empty input buffer before issuing command. + * Use generation count of zero to force a quick check. + */ + status = EcWaitEvent(sc, EC_EVENT_INPUT_BUFFER_EMPTY, 0); + if (ACPI_FAILURE(status)) + return (status); + /* Run the command and wait for the chosen event. */ CTR1(KTR_ACPI, "ec running command %#x", cmd); gen_count = sc->ec_gencount; @@ -956,24 +955,31 @@ EcRead(struct acpi_ec_softc *sc, UINT8 A { ACPI_STATUS status; u_int gen_count; + int retry; ACPI_SERIAL_ASSERT(ec); CTR1(KTR_ACPI, "ec read from %#x", Address); - status = EcCommand(sc, EC_COMMAND_READ); - if (ACPI_FAILURE(status)) - return (status); + for (retry = 0; retry < 2; retry++) { + status = EcCommand(sc, EC_COMMAND_READ); + if (ACPI_FAILURE(status)) + return (status); - gen_count = sc->ec_gencount; - EC_SET_DATA(sc, Address); - status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL, gen_count); - if (ACPI_FAILURE(status)) { - device_printf(sc->ec_dev, "EcRead: failed waiting to get data\n"); - return (status); + gen_count = sc->ec_gencount; + EC_SET_DATA(sc, Address); + status = EcWaitEvent(sc, EC_EVENT_OUTPUT_BUFFER_FULL, gen_count); + if (ACPI_FAILURE(status)) { + if (EcCheckStatus(sc, "retr_check", + EC_EVENT_INPUT_BUFFER_EMPTY) == AE_OK) + continue; + else + break; + } + *Data = EC_GET_DATA(sc); + return (AE_OK); } - *Data = EC_GET_DATA(sc); - - return (AE_OK); + device_printf(sc->ec_dev, "EcRead: failed waiting to get data\n"); + return (status); } static ACPI_STATUS @@ -993,7 +999,7 @@ EcWrite(struct acpi_ec_softc *sc, UINT8 EC_SET_DATA(sc, Address); status = EcWaitEvent(sc, EC_EVENT_INPUT_BUFFER_EMPTY, gen_count); if (ACPI_FAILURE(status)) { - device_printf(sc->ec_dev, "EcRead: failed waiting for sent address\n"); + device_printf(sc->ec_dev, "EcWrite: failed waiting for sent address\n"); return (status); } From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:01:08 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCC2F1065670; Tue, 2 Nov 2010 09:01:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA13E8FC08; Tue, 2 Nov 2010 09:01:08 +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 oA29182p031010; Tue, 2 Nov 2010 09:01:08 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2918g9031007; Tue, 2 Nov 2010 09:01:08 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020901.oA2918g9031007@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:01:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214664 - in stable/8/sys/dev: ahci siis X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:01:08 -0000 Author: mav Date: Tue Nov 2 09:01:08 2010 New Revision: 214664 URL: http://svn.freebsd.org/changeset/base/214664 Log: MFC r214325: Add missing mtx_destroy() on channel attach failure. Modified: stable/8/sys/dev/ahci/ahci.c stable/8/sys/dev/siis/siis.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ahci/ahci.c ============================================================================== --- stable/8/sys/dev/ahci/ahci.c Tue Nov 2 08:08:37 2010 (r214663) +++ stable/8/sys/dev/ahci/ahci.c Tue Nov 2 09:01:08 2010 (r214664) @@ -963,6 +963,7 @@ err1: err0: bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); mtx_unlock(&ch->mtx); + mtx_destroy(&ch->mtx); return (error); } Modified: stable/8/sys/dev/siis/siis.c ============================================================================== --- stable/8/sys/dev/siis/siis.c Tue Nov 2 08:08:37 2010 (r214663) +++ stable/8/sys/dev/siis/siis.c Tue Nov 2 09:01:08 2010 (r214664) @@ -527,6 +527,7 @@ err1: err0: bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem); mtx_unlock(&ch->mtx); + mtx_destroy(&ch->mtx); return (error); } From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:04:19 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FC7E106566C; Tue, 2 Nov 2010 09:04:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B9F08FC16; Tue, 2 Nov 2010 09:04:19 +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 oA294Jb4031328; Tue, 2 Nov 2010 09:04:19 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA294JWh031324; Tue, 2 Nov 2010 09:04:19 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020904.oA294JWh031324@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:04:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214665 - stable/8/sys/dev/mvs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:04:19 -0000 Author: mav Date: Tue Nov 2 09:04:18 2010 New Revision: 214665 URL: http://svn.freebsd.org/changeset/base/214665 Log: MFC r214099: Some mvs(4) style cleanup: - remove commented debugging code; - wrap long lines. Modified: stable/8/sys/dev/mvs/mvs.c stable/8/sys/dev/mvs/mvs_pci.c stable/8/sys/dev/mvs/mvs_soc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/mvs/mvs.c ============================================================================== --- stable/8/sys/dev/mvs/mvs.c Tue Nov 2 09:01:08 2010 (r214664) +++ stable/8/sys/dev/mvs/mvs.c Tue Nov 2 09:04:18 2010 (r214665) @@ -56,7 +56,8 @@ static int mvs_ch_deinit(device_t dev); static int mvs_ch_suspend(device_t dev); static int mvs_ch_resume(device_t dev); static void mvs_dmainit(device_t dev); -static void mvs_dmasetupc_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error); +static void mvs_dmasetupc_cb(void *xsc, + bus_dma_segment_t *segs, int nsegs, int error); static void mvs_dmafini(device_t dev); static void mvs_slotsalloc(device_t dev); static void mvs_slotsfree(device_t dev); @@ -78,7 +79,8 @@ static void mvs_crbq_intr(device_t dev); static void mvs_begin_transaction(device_t dev, union ccb *ccb); static void mvs_legacy_execute_transaction(struct mvs_slot *slot); static void mvs_timeout(struct mvs_slot *slot); -static void mvs_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error); +static void mvs_dmasetprd(void *arg, + bus_dma_segment_t *segs, int nsegs, int error); static void mvs_requeue_frozen(device_t dev); static void mvs_execute_transaction(struct mvs_slot *slot); static void mvs_end_transaction(struct mvs_slot *slot, enum mvs_err_type et); @@ -313,9 +315,11 @@ mvs_dmainit(device_t dev) if (bus_dmamem_alloc(ch->dma.workrq_tag, (void **)&ch->dma.workrq, 0, &ch->dma.workrq_map)) goto error; - if (bus_dmamap_load(ch->dma.workrq_tag, ch->dma.workrq_map, ch->dma.workrq, - MVS_WORKRQ_SIZE, mvs_dmasetupc_cb, &dcba, 0) || dcba.error) { - bus_dmamem_free(ch->dma.workrq_tag, ch->dma.workrq, ch->dma.workrq_map); + if (bus_dmamap_load(ch->dma.workrq_tag, ch->dma.workrq_map, + ch->dma.workrq, MVS_WORKRQ_SIZE, mvs_dmasetupc_cb, &dcba, 0) || + dcba.error) { + bus_dmamem_free(ch->dma.workrq_tag, + ch->dma.workrq, ch->dma.workrq_map); goto error; } ch->dma.workrq_bus = dcba.maddr; @@ -328,9 +332,11 @@ mvs_dmainit(device_t dev) if (bus_dmamem_alloc(ch->dma.workrp_tag, (void **)&ch->dma.workrp, 0, &ch->dma.workrp_map)) goto error; - if (bus_dmamap_load(ch->dma.workrp_tag, ch->dma.workrp_map, ch->dma.workrp, - MVS_WORKRP_SIZE, mvs_dmasetupc_cb, &dcba, 0) || dcba.error) { - bus_dmamem_free(ch->dma.workrp_tag, ch->dma.workrp, ch->dma.workrp_map); + if (bus_dmamap_load(ch->dma.workrp_tag, ch->dma.workrp_map, + ch->dma.workrp, MVS_WORKRP_SIZE, mvs_dmasetupc_cb, &dcba, 0) || + dcba.error) { + bus_dmamem_free(ch->dma.workrp_tag, + ch->dma.workrp, ch->dma.workrp_map); goto error; } ch->dma.workrp_bus = dcba.maddr; @@ -370,7 +376,8 @@ mvs_dmafini(device_t dev) } if (ch->dma.workrp_bus) { bus_dmamap_unload(ch->dma.workrp_tag, ch->dma.workrp_map); - bus_dmamem_free(ch->dma.workrp_tag, ch->dma.workrp, ch->dma.workrp_map); + bus_dmamem_free(ch->dma.workrp_tag, + ch->dma.workrp, ch->dma.workrp_map); ch->dma.workrp_bus = 0; ch->dma.workrp_map = NULL; ch->dma.workrp = NULL; @@ -381,7 +388,8 @@ mvs_dmafini(device_t dev) } if (ch->dma.workrq_bus) { bus_dmamap_unload(ch->dma.workrq_tag, ch->dma.workrq_map); - bus_dmamem_free(ch->dma.workrq_tag, ch->dma.workrq, ch->dma.workrq_map); + bus_dmamem_free(ch->dma.workrq_tag, + ch->dma.workrq, ch->dma.workrq_map); ch->dma.workrq_bus = 0; ch->dma.workrq_map = NULL; ch->dma.workrq = NULL; @@ -443,14 +451,16 @@ mvs_setup_edma_queues(device_t dev) ATA_OUTL(ch->r_mem, EDMA_REQQBAH, work >> 32); ATA_OUTL(ch->r_mem, EDMA_REQQIP, work & 0xffffffff); ATA_OUTL(ch->r_mem, EDMA_REQQOP, work & 0xffffffff); - bus_dmamap_sync(ch->dma.workrq_tag, ch->dma.workrq_map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(ch->dma.workrq_tag, ch->dma.workrq_map, + BUS_DMASYNC_PREWRITE); /* Reponses queue. */ bzero(ch->dma.workrp, 256); work = ch->dma.workrp_bus; ATA_OUTL(ch->r_mem, EDMA_RESQBAH, work >> 32); ATA_OUTL(ch->r_mem, EDMA_RESQIP, work & 0xffffffff); ATA_OUTL(ch->r_mem, EDMA_RESQOP, work & 0xffffffff); - bus_dmamap_sync(ch->dma.workrp_tag, ch->dma.workrp_map, BUS_DMASYNC_PREREAD); + bus_dmamap_sync(ch->dma.workrp_tag, ch->dma.workrp_map, + BUS_DMASYNC_PREREAD); ch->out_idx = 0; ch->in_idx = 0; } @@ -677,20 +687,15 @@ mvs_ch_intr(void *data) int i, ccs, port = -1, selfdis = 0; int edma = (ch->numtslots != 0 || ch->numdslots != 0); -//device_printf(dev, "irq cause %02x EDMA %d IEC %08x\n", -// arg->cause, edma, ATA_INL(ch->r_mem, EDMA_IEC)); /* New item in response queue. */ if ((arg->cause & 2) && edma) mvs_crbq_intr(dev); /* Some error or special event. */ if (arg->cause & 1) { iec = ATA_INL(ch->r_mem, EDMA_IEC); -//device_printf(dev, "irq cause %02x EDMA %d IEC %08x\n", -// arg->cause, edma, iec); if (iec & EDMA_IE_SERRINT) { serr = ATA_INL(ch->r_mem, SATA_SE); ATA_OUTL(ch->r_mem, SATA_SE, serr); -//device_printf(dev, "SERR %08x\n", serr); } /* EDMA self-disabled due to error. */ if (iec & EDMA_IE_ESELFDIS) @@ -705,7 +710,6 @@ mvs_ch_intr(void *data) fisic = SATA_FISC_FISWAIT4HOSTRDYEN_B1; else /* For Gen-IIe - read FIS interrupt cause. */ fisic = ATA_INL(ch->r_mem, SATA_FISIC); -//device_printf(dev, "FISIC %08x\n", fisic); } if (selfdis) ch->curr_mode = MVS_EDMA_UNKNOWN; @@ -744,7 +748,6 @@ mvs_ch_intr(void *data) } } } -//device_printf(dev, "err slot %d port %d\n", ccs, port); mvs_requeue_frozen(dev); for (i = 0; i < MVS_MAX_SLOTS; i++) { /* XXX: reqests in loading state. */ @@ -770,7 +773,8 @@ mvs_ch_intr(void *data) ch->fatalerr = 1; } } else if (iec & 0xfc1e9000) { - if (ch->numtslots == 0 && i != ccs && port != -2) + if (ch->numtslots == 0 && + i != ccs && port != -2) et = MVS_ERR_INNOCENT; else et = MVS_ERR_SATA; @@ -822,8 +826,6 @@ mvs_legacy_intr(device_t dev) /* Clear interrupt and get status. */ status = mvs_getstatus(dev, 1); -// device_printf(dev, "Legacy intr status %02x\n", -// status); if (slot->state < MVS_SLOT_RUNNING) return; port = ccb->ccb_h.target_id & 0x0f; @@ -866,7 +868,8 @@ mvs_legacy_intr(device_t dev) /* If data write command - put them */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { if (mvs_wait(dev, ATA_S_DRQ, ATA_S_BUSY, 1000) < 0) { - device_printf(dev, "timeout waiting for write DRQ\n"); + device_printf(dev, + "timeout waiting for write DRQ\n"); et = MVS_ERR_TIMEOUT; goto end_finished; } @@ -889,19 +892,18 @@ mvs_legacy_intr(device_t dev) ATA_OUTL(ch->r_mem, DMA_C, 0); goto end_finished; } else { /* ATAPI PIO */ - length = ATA_INB(ch->r_mem,ATA_CYL_LSB) | (ATA_INB(ch->r_mem,ATA_CYL_MSB) << 8); + length = ATA_INB(ch->r_mem,ATA_CYL_LSB) | + (ATA_INB(ch->r_mem,ATA_CYL_MSB) << 8); ireason = ATA_INB(ch->r_mem,ATA_IREASON); -//device_printf(dev, "status %02x, ireason %02x, length %d\n", status, ireason, length); switch ((ireason & (ATA_I_CMD | ATA_I_IN)) | (status & ATA_S_DRQ)) { case ATAPI_P_CMDOUT: -device_printf(dev, "ATAPI CMDOUT\n"); + device_printf(dev, "ATAPI CMDOUT\n"); /* Return wait for interrupt */ return; case ATAPI_P_WRITE: -//device_printf(dev, "ATAPI WRITE\n"); if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { device_printf(dev, "trying to write on read buffer\n"); et = MVS_ERR_TFE; @@ -919,7 +921,6 @@ device_printf(dev, "ATAPI CMDOUT\n"); return; case ATAPI_P_READ: -//device_printf(dev, "ATAPI READ\n"); if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { device_printf(dev, "trying to read on write buffer\n"); et = MVS_ERR_TFE; @@ -936,7 +937,6 @@ device_printf(dev, "ATAPI CMDOUT\n"); return; case ATAPI_P_DONEDRQ: -device_printf(dev, "ATAPI DONEDRQ\n"); device_printf(dev, "WARNING - DONEDRQ non conformant device\n"); if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { @@ -957,13 +957,13 @@ device_printf(dev, "ATAPI DONEDRQ\n"); case ATAPI_P_ABORT: case ATAPI_P_DONE: -//device_printf(dev, "ATAPI ABORT/DONE\n"); if (status & (ATA_S_ERROR | ATA_S_DWF)) et = MVS_ERR_TFE; goto end_finished; default: - device_printf(dev, "unknown transfer phase (status %02x, ireason %02x)\n", + device_printf(dev, "unknown transfer phase" + " (status %02x, ireason %02x)\n", status, ireason); et = MVS_ERR_TFE; } @@ -1265,8 +1265,6 @@ mvs_legacy_execute_transaction(struct mv ch->rslots |= (1 << slot->slot); ATA_OUTB(ch->r_mem, SATA_SATAICTL, port << SATA_SATAICTL_PMPTX_SHIFT); if (ccb->ccb_h.func_code == XPT_ATA_IO) { -// device_printf(dev, "%d Legacy command %02x size %d\n", -// port, ccb->ataio.cmd.command, ccb->ataio.dxfer_len); mvs_tfd_write(dev, ccb); /* Device reset doesn't interrupt. */ if (ccb->ataio.cmd.command == ATA_DEVICE_RESET) { @@ -1286,7 +1284,8 @@ mvs_legacy_execute_transaction(struct mv /* If data write command - output the data */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { if (mvs_wait(dev, ATA_S_DRQ, ATA_S_BUSY, 1000) < 0) { - device_printf(dev, "timeout waiting for write DRQ\n"); + device_printf(dev, + "timeout waiting for write DRQ\n"); mvs_end_transaction(slot, MVS_ERR_TIMEOUT); return; } @@ -1295,9 +1294,6 @@ mvs_legacy_execute_transaction(struct mv ch->transfersize / 2); } } else { -// device_printf(dev, "%d ATAPI command %02x size %d dma %d\n", -// port, ccb->csio.cdb_io.cdb_bytes[0], ccb->csio.dxfer_len, -// ch->basic_dma); ch->donecount = 0; ch->transfersize = min(ccb->csio.dxfer_len, ch->curr[port].bytecount); @@ -1330,7 +1326,8 @@ mvs_legacy_execute_transaction(struct mv DELAY(20); } if (timeout <= 0) { - device_printf(dev, "timeout waiting for ATAPI command ready\n"); + device_printf(dev, + "timeout waiting for ATAPI command ready\n"); mvs_end_transaction(slot, MVS_ERR_TIMEOUT); return; } @@ -1370,8 +1367,6 @@ mvs_execute_transaction(struct mvs_slot int port = ccb->ccb_h.target_id & 0x0f; int i; -// device_printf(dev, "%d EDMA command %02x size %d slot %d tag %d\n", -// port, ccb->ataio.cmd.command, ccb->ataio.dxfer_len, slot->slot, slot->tag); /* Get address of the prepared EPRD */ eprd = ch->dma.workrq_bus + MVS_EPRD_OFFSET + (MVS_EPRD_SIZE * slot->slot); /* Prepare CRQB. Gen IIe uses different CRQB format. */ @@ -1553,7 +1548,6 @@ mvs_end_transaction(struct mvs_slot *slo union ccb *ccb = slot->ccb; int lastto; -//device_printf(dev, "cmd done status %d\n", et); bus_dmamap_sync(ch->dma.workrq_tag, ch->dma.workrq_map, BUS_DMASYNC_POSTWRITE); /* Read result registers to the result struct @@ -1791,7 +1785,8 @@ mvs_process_read_log(device_t dev, union if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) device_printf(dev, "Error while READ LOG EXT\n"); else if ((data[0] & 0x80) == 0) { - device_printf(dev, "Non-queued command error in READ LOG EXT\n"); + device_printf(dev, + "Non-queued command error in READ LOG EXT\n"); } for (i = 0; i < MVS_MAX_SLOTS; i++) { if (!ch->hold[i]) Modified: stable/8/sys/dev/mvs/mvs_pci.c ============================================================================== --- stable/8/sys/dev/mvs/mvs_pci.c Tue Nov 2 09:01:08 2010 (r214664) +++ stable/8/sys/dev/mvs/mvs_pci.c Tue Nov 2 09:04:18 2010 (r214665) @@ -339,7 +339,6 @@ mvs_intr(void *data) u_int32_t ic, aic; ic = ATA_INL(ctlr->r_mem, CHIP_MIC); -//device_printf(ctlr->dev, "irq MIC:%08x\n", ic); if (ctlr->msi) { /* We have to to mask MSI during processing. */ mtx_lock(&ctlr->mtx); Modified: stable/8/sys/dev/mvs/mvs_soc.c ============================================================================== --- stable/8/sys/dev/mvs/mvs_soc.c Tue Nov 2 09:01:08 2010 (r214664) +++ stable/8/sys/dev/mvs/mvs_soc.c Tue Nov 2 09:04:18 2010 (r214665) @@ -295,7 +295,6 @@ mvs_intr(void *data) u_int32_t ic, aic; ic = ATA_INL(ctlr->r_mem, CHIP_SOC_MIC); -//device_printf(ctlr->dev, "irq MIC:%08x\n", ic); if ((ic & IC_HC0) == 0) return; /* Acknowledge interrupts of this HC. */ From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:05:40 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4584106566B; Tue, 2 Nov 2010 09:05:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A19828FC12; Tue, 2 Nov 2010 09:05:40 +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 oA295ePW031505; Tue, 2 Nov 2010 09:05:40 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA295ear031503; Tue, 2 Nov 2010 09:05:40 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020905.oA295ear031503@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:05:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214666 - stable/8/sys/dev/mvs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:05:40 -0000 Author: mav Date: Tue Nov 2 09:05:40 2010 New Revision: 214666 URL: http://svn.freebsd.org/changeset/base/214666 Log: MFC r214102: Workaround strange situation when EDMA_RESQIP register returns zero instead of proper value. It caused bunch of "EMPTY CRPB" messages and potentially may cause premature requests completion, which could cause data corruption. For most cases it seems enough to just reread register to get proper value. To protect against worse cases - erase processed queue entries with impossible values and ignore them if problem still happen. Modified: stable/8/sys/dev/mvs/mvs.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/mvs/mvs.c ============================================================================== --- stable/8/sys/dev/mvs/mvs.c Tue Nov 2 09:04:18 2010 (r214665) +++ stable/8/sys/dev/mvs/mvs.c Tue Nov 2 09:05:40 2010 (r214666) @@ -454,7 +454,7 @@ mvs_setup_edma_queues(device_t dev) bus_dmamap_sync(ch->dma.workrq_tag, ch->dma.workrq_map, BUS_DMASYNC_PREWRITE); /* Reponses queue. */ - bzero(ch->dma.workrp, 256); + memset(ch->dma.workrp, 0xff, MVS_WORKRP_SIZE); work = ch->dma.workrp_bus; ATA_OUTL(ch->r_mem, EDMA_RESQBAH, work >> 32); ATA_OUTL(ch->r_mem, EDMA_RESQIP, work & 0xffffffff); @@ -979,38 +979,54 @@ mvs_crbq_intr(device_t dev) struct mvs_channel *ch = device_get_softc(dev); struct mvs_crpb *crpb; union ccb *ccb; - int in_idx, cin_idx, slot; + int in_idx, fin_idx, cin_idx, slot; + uint32_t val; uint16_t flags; - in_idx = (ATA_INL(ch->r_mem, EDMA_RESQIP) & EDMA_RESQP_ERPQP_MASK) >> + val = ATA_INL(ch->r_mem, EDMA_RESQIP); + if (val == 0) + val = ATA_INL(ch->r_mem, EDMA_RESQIP); + in_idx = (val & EDMA_RESQP_ERPQP_MASK) >> EDMA_RESQP_ERPQP_SHIFT; bus_dmamap_sync(ch->dma.workrp_tag, ch->dma.workrp_map, BUS_DMASYNC_POSTREAD); - cin_idx = ch->in_idx; + fin_idx = cin_idx = ch->in_idx; ch->in_idx = in_idx; while (in_idx != cin_idx) { crpb = (struct mvs_crpb *) - (ch->dma.workrp + MVS_CRPB_OFFSET + (MVS_CRPB_SIZE * cin_idx)); + (ch->dma.workrp + MVS_CRPB_OFFSET + + (MVS_CRPB_SIZE * cin_idx)); slot = le16toh(crpb->id) & MVS_CRPB_TAG_MASK; flags = le16toh(crpb->rspflg); -//device_printf(dev, "CRPB %d %d %04x\n", cin_idx, slot, flags); /* * Handle only successfull completions here. * Errors will be handled by main intr handler. */ - if (ch->numtslots != 0 || (flags & EDMA_IE_EDEVERR) == 0) { -if ((flags >> 8) & ATA_S_ERROR) -device_printf(dev, "ERROR STATUS CRPB %d %d %04x\n", cin_idx, slot, flags); + if (crpb->id == 0xffff && crpb->rspflg == 0xffff) { + device_printf(dev, "Unfilled CRPB " + "%d (%d->%d) tag %d flags %04x rs %08x\n", + cin_idx, fin_idx, in_idx, slot, flags, ch->rslots); + } else if (ch->numtslots != 0 || + (flags & EDMA_IE_EDEVERR) == 0) { + crpb->id = 0xffff; + crpb->rspflg = 0xffff; if (ch->slot[slot].state >= MVS_SLOT_RUNNING) { ccb = ch->slot[slot].ccb; - ccb->ataio.res.status = (flags & MVS_CRPB_ATASTS_MASK) >> + ccb->ataio.res.status = + (flags & MVS_CRPB_ATASTS_MASK) >> MVS_CRPB_ATASTS_SHIFT; mvs_end_transaction(&ch->slot[slot], MVS_ERR_NONE); - } else -device_printf(dev, "EMPTY CRPB %d (->%d) %d %04x\n", cin_idx, in_idx, slot, flags); - } else -device_printf(dev, "ERROR FLAGS CRPB %d %d %04x\n", cin_idx, slot, flags); - + } else { + device_printf(dev, "Unused tag in CRPB " + "%d (%d->%d) tag %d flags %04x rs %08x\n", + cin_idx, fin_idx, in_idx, slot, flags, + ch->rslots); + } + } else { + device_printf(dev, + "CRPB with error %d tag %d flags %04x\n", + cin_idx, slot, flags); + } cin_idx = (cin_idx + 1) & (MVS_MAX_SLOTS - 1); } bus_dmamap_sync(ch->dma.workrp_tag, ch->dma.workrp_map, From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:13:14 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 482371065714; Tue, 2 Nov 2010 09:13:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 354D18FC08; Tue, 2 Nov 2010 09:13: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 oA29DEiO032154; Tue, 2 Nov 2010 09:13:14 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA29DE5H032152; Tue, 2 Nov 2010 09:13:14 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020913.oA29DE5H032152@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:13:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214667 - stable/8/sys/dev/ata/chipsets X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:13:14 -0000 Author: mav Date: Tue Nov 2 09:13:13 2010 New Revision: 214667 URL: http://svn.freebsd.org/changeset/base/214667 Log: MFC r213047 by jchandra: Add missing byteswap, works on big endian systems now (tested on Netlogic XLS MIPS processor). Modified: stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/chipsets/ata-siliconimage.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Tue Nov 2 09:05:40 2010 (r214666) +++ stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Tue Nov 2 09:13:13 2010 (r214667) @@ -649,7 +649,7 @@ ata_siiprb_end_transaction(struct ata_re /* update progress */ if (!(request->status & ATA_S_ERROR) && !(request->flags & ATA_R_TIMEOUT)) { if (request->flags & ATA_R_READ) - request->donecount = prb->transfer_count; + request->donecount = le32toh(prb->transfer_count); else request->donecount = request->bytecount; } From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:14:04 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F2001065672; Tue, 2 Nov 2010 09:14:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8CC298FC20; Tue, 2 Nov 2010 09:14:04 +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 oA29E4fR032264; Tue, 2 Nov 2010 09:14:04 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA29E4O6032262; Tue, 2 Nov 2010 09:14:04 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020914.oA29E4O6032262@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214668 - stable/8/sys/dev/ata/chipsets X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:14:04 -0000 Author: mav Date: Tue Nov 2 09:14:04 2010 New Revision: 214668 URL: http://svn.freebsd.org/changeset/base/214668 Log: MFC r213092: Add missing le32toh(), same as recently done in ata-siliconimage.c. Modified: stable/8/sys/dev/ata/chipsets/ata-ahci.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/chipsets/ata-ahci.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-ahci.c Tue Nov 2 09:13:13 2010 (r214667) +++ stable/8/sys/dev/ata/chipsets/ata-ahci.c Tue Nov 2 09:14:04 2010 (r214668) @@ -563,7 +563,7 @@ ata_ahci_end_transaction(struct ata_requ /* record how much data we actually moved */ clp = (struct ata_ahci_cmd_list *) (ch->dma.work + ATA_AHCI_CL_OFFSET); - request->donecount = clp->bytecount; + request->donecount = le32toh(clp->bytecount); /* release SG list etc */ ch->dma.unload(request); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:15:28 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28FDC106564A; Tue, 2 Nov 2010 09:15:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 165E28FC17; Tue, 2 Nov 2010 09:15:28 +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 oA29FRYL032384; Tue, 2 Nov 2010 09:15:27 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA29FR4g032382; Tue, 2 Nov 2010 09:15:27 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020915.oA29FR4g032382@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:15:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214669 - stable/8/sys/dev/ata/chipsets X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:15:28 -0000 Author: mav Date: Tue Nov 2 09:15:27 2010 New Revision: 214669 URL: http://svn.freebsd.org/changeset/base/214669 Log: MFC r213301: Revert r132291. Restore setting PIO/WDMA timings for VIA UDMA133 controllers. Linux disables only AST register writing there, but no all timings. Modified: stable/8/sys/dev/ata/chipsets/ata-via.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/chipsets/ata-via.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-via.c Tue Nov 2 09:14:04 2010 (r214668) +++ stable/8/sys/dev/ata/chipsets/ata-via.c Tue Nov 2 09:15:27 2010 (r214669) @@ -352,8 +352,7 @@ ata_via_old_setmode(device_t dev, int ta piomode = mode; } /* Set WDMA/PIO timings */ - if (ctlr->chip->cfg1 != VIA133) - pci_write_config(parent, reg - 0x08,timings[ata_mode2idx(piomode)], 1); + pci_write_config(parent, reg - 0x08,timings[ata_mode2idx(piomode)], 1); return (mode); } From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 09:26:12 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89082106566B; Tue, 2 Nov 2010 09:26:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 748388FC14; Tue, 2 Nov 2010 09:26:12 +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 oA29QCVJ032819; Tue, 2 Nov 2010 09:26:12 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA29QCGh032806; Tue, 2 Nov 2010 09:26:12 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201011020926.oA29QCGh032806@svn.freebsd.org> From: Alexander Motin Date: Tue, 2 Nov 2010 09:26:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214671 - in stable/8/sys: arm/mv dev/ata dev/ata/chipsets X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:26:12 -0000 Author: mav Date: Tue Nov 2 09:26:12 2010 New Revision: 214671 URL: http://svn.freebsd.org/changeset/base/214671 Log: MFC r214016: Set of legacy mode SATA enchancements: - Implement proper combined mode decoding for Intel controllers to properly identify SATA and PATA channels and associate ATA channels with SATA ports. This fixes wrong reporting and in some cases hard resets to wrong SATA ports. - Improve SATA registers support to handle hot-plug events and potentially interface errors. For ICH5/6300ESB chipsets these registers accessible via PCI config space. For later ones they may be accessible via PCI BAR(5). - For controllers not generating interrupts on hot-plug events, implement periodic status polling. Use it to detect hot-plug on Intel and VIA controllers. Same probably could also be used for Serverworks and SIS. Modified: stable/8/sys/arm/mv/mv_sata.c stable/8/sys/dev/ata/ata-all.c stable/8/sys/dev/ata/ata-all.h stable/8/sys/dev/ata/ata-pci.c stable/8/sys/dev/ata/ata-sata.c stable/8/sys/dev/ata/chipsets/ata-ahci.c stable/8/sys/dev/ata/chipsets/ata-intel.c stable/8/sys/dev/ata/chipsets/ata-marvell.c stable/8/sys/dev/ata/chipsets/ata-nvidia.c stable/8/sys/dev/ata/chipsets/ata-promise.c stable/8/sys/dev/ata/chipsets/ata-siliconimage.c stable/8/sys/dev/ata/chipsets/ata-via.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/arm/mv/mv_sata.c ============================================================================== --- stable/8/sys/arm/mv/mv_sata.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/arm/mv/mv_sata.c Tue Nov 2 09:26:12 2010 (r214671) @@ -709,7 +709,7 @@ sata_channel_status(device_t dev) if ((icr & SATA_ICR_DEV(ch->unit)) || iecr) { /* Disable EDMA before accessing SATA registers */ sata_edma_ctrl(dev, 0); - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); /* Ack device and error interrupt */ SATA_OUTL(sc, SATA_ICR, ~SATA_ICR_DEV(ch->unit)); Modified: stable/8/sys/dev/ata/ata-all.c ============================================================================== --- stable/8/sys/dev/ata/ata-all.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/ata-all.c Tue Nov 2 09:26:12 2010 (r214671) @@ -82,6 +82,7 @@ static void bswap(int8_t *, int); static void btrim(int8_t *, int); static void bpack(int8_t *, int8_t *, int); static void ata_interrupt_locked(void *data); +static void ata_periodic_poll(void *data); /* global vars */ MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer"); @@ -172,6 +173,7 @@ ata_attach(device_t dev) ch->curr[i] = ch->user[i]; } #endif + callout_init(&ch->poll_callout, 1); /* reset the controller HW, the channel and device(s) */ while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit) @@ -199,6 +201,8 @@ ata_attach(device_t dev) device_printf(dev, "unable to setup interrupt\n"); return error; } + if (ch->flags & ATA_PERIODIC_POLL) + callout_reset(&ch->poll_callout, hz, ata_periodic_poll, ch); #ifndef ATA_CAM /* probe and attach devices on this channel unless we are in early boot */ @@ -245,6 +249,8 @@ err2: err1: bus_release_resource(dev, SYS_RES_IRQ, rid, ch->r_irq); mtx_unlock(&ch->state_mtx); + if (ch->flags & ATA_PERIODIC_POLL) + callout_drain(&ch->poll_callout); return (error); #endif } @@ -266,6 +272,8 @@ ata_detach(device_t dev) mtx_lock(&ch->state_mtx); ch->state |= ATA_STALL_QUEUE; mtx_unlock(&ch->state_mtx); + if (ch->flags & ATA_PERIODIC_POLL) + callout_drain(&ch->poll_callout); #ifndef ATA_CAM /* detach & delete all children */ @@ -453,6 +461,8 @@ ata_suspend(device_t dev) if (!dev || !(ch = device_get_softc(dev))) return ENXIO; + if (ch->flags & ATA_PERIODIC_POLL) + callout_drain(&ch->poll_callout); #ifdef ATA_CAM mtx_lock(&ch->state_mtx); xpt_freeze_simq(ch->sim, 1); @@ -497,6 +507,8 @@ ata_resume(device_t dev) /* kick off requests on the queue */ ata_start(dev); #endif + if (ch->flags & ATA_PERIODIC_POLL) + callout_reset(&ch->poll_callout, hz, ata_periodic_poll, ch); return error; } @@ -563,6 +575,15 @@ ata_interrupt_locked(void *data) #endif } +static void +ata_periodic_poll(void *data) +{ + struct ata_channel *ch = (struct ata_channel *)data; + + callout_reset(&ch->poll_callout, hz, ata_periodic_poll, ch); + ata_interrupt(ch); +} + void ata_print_cable(device_t dev, u_int8_t *who) { Modified: stable/8/sys/dev/ata/ata-all.h ============================================================================== --- stable/8/sys/dev/ata/ata-all.h Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/ata-all.h Tue Nov 2 09:26:12 2010 (r214671) @@ -114,13 +114,6 @@ #define ATA_SS_IPM_PARTIAL 0x00000200 #define ATA_SS_IPM_SLUMBER 0x00000600 -#define ATA_SS_CONWELL_MASK \ - (ATA_SS_DET_MASK|ATA_SS_SPD_MASK|ATA_SS_IPM_MASK) -#define ATA_SS_CONWELL_GEN1 \ - (ATA_SS_DET_PHY_ONLINE|ATA_SS_SPD_GEN1|ATA_SS_IPM_ACTIVE) -#define ATA_SS_CONWELL_GEN2 \ - (ATA_SS_DET_PHY_ONLINE|ATA_SS_SPD_GEN2|ATA_SS_IPM_ACTIVE) - #define ATA_SERROR 14 #define ATA_SE_DATA_CORRECTED 0x00000001 #define ATA_SE_COMM_CORRECTED 0x00000002 @@ -567,6 +560,7 @@ struct ata_channel { #define ATA_DMA_BEFORE_CMD 0x100 #define ATA_KNOWN_PRESENCE 0x200 #define ATA_STATUS_IS_LONG 0x400 +#define ATA_PERIODIC_POLL 0x800 int pm_level; /* power management level */ int devices; /* what is present */ @@ -593,6 +587,7 @@ struct ata_channel { struct ata_cam_device user[16]; /* User-specified settings */ struct ata_cam_device curr[16]; /* Current settings */ #endif + struct callout poll_callout; /* Periodic status poll. */ }; /* disk bay/enclosure related */ @@ -666,7 +661,7 @@ void ata_dmainit(device_t); void ata_dmafini(device_t dev); /* ata-sata.c: */ -void ata_sata_phy_check_events(device_t dev); +void ata_sata_phy_check_events(device_t dev, int port); int ata_sata_scr_read(struct ata_channel *ch, int port, int reg, uint32_t *val); int ata_sata_scr_write(struct ata_channel *ch, int port, int reg, uint32_t val); int ata_sata_phy_reset(device_t dev, int port, int quick); Modified: stable/8/sys/dev/ata/ata-pci.c ============================================================================== --- stable/8/sys/dev/ata/ata-pci.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/ata-pci.c Tue Nov 2 09:26:12 2010 (r214671) @@ -615,6 +615,7 @@ ata_pcichannel_attach(device_t dev) return (0); ch->attached = 1; + ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); resource_int_value(device_get_name(dev), Modified: stable/8/sys/dev/ata/ata-sata.c ============================================================================== --- stable/8/sys/dev/ata/ata-sata.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/ata-sata.c Tue Nov 2 09:26:12 2010 (r214671) @@ -48,20 +48,23 @@ __FBSDID("$FreeBSD$"); #include void -ata_sata_phy_check_events(device_t dev) +ata_sata_phy_check_events(device_t dev, int port) { struct ata_channel *ch = device_get_softc(dev); - u_int32_t error = ATA_IDX_INL(ch, ATA_SERROR); + u_int32_t error, status; - /* clear error bits/interrupt */ - ATA_IDX_OUTL(ch, ATA_SERROR, error); + ata_sata_scr_read(ch, port, ATA_SERROR, &error); + /* Clear set error bits/interrupt. */ + if (error) + ata_sata_scr_write(ch, port, ATA_SERROR, error); /* if we have a connection event deal with it */ if ((error & ATA_SE_PHY_CHANGED) && (ch->pm_level == 0)) { if (bootverbose) { - u_int32_t status = ATA_IDX_INL(ch, ATA_SSTATUS); - if (((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1) || - ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2)) { + ata_sata_scr_read(ch, port, ATA_SSTATUS, &status); + if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && + ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && + ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) { device_printf(dev, "CONNECT requested\n"); } else device_printf(dev, "DISCONNECT requested\n"); @@ -73,69 +76,51 @@ ata_sata_phy_check_events(device_t dev) int ata_sata_scr_read(struct ata_channel *ch, int port, int reg, uint32_t *val) { - int r; - if (port < 0) { + if (ch->hw.pm_read != NULL) + return (ch->hw.pm_read(ch->dev, port, reg, val)); + if (ch->r_io[reg].res) { *val = ATA_IDX_INL(ch, reg); return (0); - } else { - switch (reg) { - case ATA_SSTATUS: - r = 0; - break; - case ATA_SERROR: - r = 1; - break; - case ATA_SCONTROL: - r = 2; - break; - default: - return (EINVAL); - } - return (ch->hw.pm_read(ch->dev, port, r, val)); } + return (-1); } int ata_sata_scr_write(struct ata_channel *ch, int port, int reg, uint32_t val) { - int r; - if (port < 0) { + if (ch->hw.pm_write != NULL) + return (ch->hw.pm_write(ch->dev, port, reg, val)); + if (ch->r_io[reg].res) { ATA_IDX_OUTL(ch, reg, val); return (0); - } else { - switch (reg) { - case ATA_SERROR: - r = 1; - break; - case ATA_SCONTROL: - r = 2; - break; - default: - return (EINVAL); - } - return (ch->hw.pm_write(ch->dev, port, r, val)); } + return (-1); } static int -ata_sata_connect(struct ata_channel *ch, int port) +ata_sata_connect(struct ata_channel *ch, int port, int quick) { u_int32_t status; - int timeout; + int timeout, t; /* wait up to 1 second for "connect well" */ - for (timeout = 0; timeout < 100 ; timeout++) { + timeout = (quick == 2) ? 0 : 100; + t = 0; + while (1) { if (ata_sata_scr_read(ch, port, ATA_SSTATUS, &status)) return (0); - if ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1 || - (status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2) + if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && + ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && + ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) + break; + if (++t > timeout) break; ata_udelay(10000); } - if (timeout >= 100) { - if (bootverbose) { + if (bootverbose) { + if (t > timeout) { if (port < 0) { device_printf(ch->dev, "SATA connect timeout status=%08x\n", status); @@ -143,23 +128,19 @@ ata_sata_connect(struct ata_channel *ch, device_printf(ch->dev, "p%d: SATA connect timeout status=%08x\n", port, status); } - } - return 0; - } - if (bootverbose) { - if (port < 0) { + } else if (port < 0) { device_printf(ch->dev, "SATA connect time=%dms status=%08x\n", - timeout * 10, status); + t * 10, status); } else { device_printf(ch->dev, "p%d: SATA connect time=%dms status=%08x\n", - port, timeout * 10, status); + port, t * 10, status); } } /* clear SATA error register */ ata_sata_scr_write(ch, port, ATA_SERROR, 0xffffffff); - return 1; + return ((t > timeout) ? 0 : 1); } int @@ -173,7 +154,7 @@ ata_sata_phy_reset(device_t dev, int por if (ata_sata_scr_read(ch, port, ATA_SCONTROL, &val)) return (0); if ((val & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE) - return ata_sata_connect(ch, port); + return ata_sata_connect(ch, port, quick); } if (bootverbose) { @@ -203,7 +184,7 @@ ata_sata_phy_reset(device_t dev, int por if (ata_sata_scr_read(ch, port, ATA_SCONTROL, &val)) return (0); if ((val & ATA_SC_DET_MASK) == 0) - return ata_sata_connect(ch, port); + return ata_sata_connect(ch, port, 0); } } return 0; Modified: stable/8/sys/dev/ata/chipsets/ata-ahci.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-ahci.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-ahci.c Tue Nov 2 09:26:12 2010 (r214671) @@ -403,7 +403,7 @@ ata_ahci_status(device_t dev) /* do we have any PHY events ? */ if (istatus & (ATA_AHCI_P_IX_PRC | ATA_AHCI_P_IX_PC)) - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); /* do we have a potentially hanging engine to take care of? */ /* XXX SOS what todo on NCQ */ @@ -623,6 +623,25 @@ ata_ahci_pm_read(device_t dev, int port, (struct ata_ahci_cmd_tab *)(ch->dma.work + ATA_AHCI_CT_OFFSET); u_int8_t *fis = ch->dma.work + ATA_AHCI_FB_OFFSET + 0x40; + if (port < 0) { + *result = ATA_IDX_INL(ch, reg); + return (0); + } + if (port < ATA_PM) { + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + } bzero(ctp->cfis, 64); ctp->cfis[0] = 0x27; /* host to device */ ctp->cfis[1] = 0x8f; /* command FIS to PM port */ @@ -649,6 +668,25 @@ ata_ahci_pm_write(device_t dev, int port (struct ata_ahci_cmd_tab *)(ch->dma.work + ATA_AHCI_CT_OFFSET); int offset = ch->unit << 7; + if (port < 0) { + ATA_IDX_OUTL(ch, reg, value); + return (0); + } + if (port < ATA_PM) { + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + } bzero(ctp->cfis, 64); ctp->cfis[0] = 0x27; /* host to device */ ctp->cfis[1] = 0x8f; /* command FIS to PM port */ Modified: stable/8/sys/dev/ata/chipsets/ata-intel.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-intel.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-intel.c Tue Nov 2 09:26:12 2010 (r214671) @@ -59,6 +59,15 @@ static int ata_intel_old_setmode(device_ static int ata_intel_new_setmode(device_t dev, int target, int mode); static int ata_intel_sch_setmode(device_t dev, int target, int mode); static int ata_intel_sata_getrev(device_t dev, int target); +static int ata_intel_sata_status(device_t dev); +static int ata_intel_sata_cscr_read(device_t dev, int port, + int reg, u_int32_t *result); +static int ata_intel_sata_sidpr_read(device_t dev, int port, + int reg, u_int32_t *result); +static int ata_intel_sata_cscr_write(device_t dev, int port, + int reg, u_int32_t result); +static int ata_intel_sata_sidpr_write(device_t dev, int port, + int reg, u_int32_t result); static int ata_intel_31244_ch_attach(device_t dev); static int ata_intel_31244_ch_detach(device_t dev); static int ata_intel_31244_status(device_t dev); @@ -67,7 +76,9 @@ static void ata_intel_31244_reset(device /* misc defines */ #define INTEL_AHCI 1 - +#define INTEL_ICH5 2 +#define INTEL_6CH 4 +#define INTEL_6CH2 8 /* * Intel chipset support functions @@ -92,74 +103,74 @@ ata_intel_probe(device_t dev) { ATA_I82801DB, 0, 0, 2, ATA_UDMA5, "ICH4" }, { ATA_I82801DB_1, 0, 0, 2, ATA_UDMA5, "ICH4" }, { ATA_I82801EB, 0, 0, 2, ATA_UDMA5, "ICH5" }, - { ATA_I82801EB_S1, 0, 0, 2, ATA_SA150, "ICH5" }, - { ATA_I82801EB_R1, 0, 0, 2, ATA_SA150, "ICH5" }, + { ATA_I82801EB_S1, 0, INTEL_ICH5, 2, ATA_SA150, "ICH5" }, + { ATA_I82801EB_R1, 0, INTEL_ICH5, 2, ATA_SA150, "ICH5" }, { ATA_I6300ESB, 0, 0, 2, ATA_UDMA5, "6300ESB" }, - { ATA_I6300ESB_S1, 0, 0, 2, ATA_SA150, "6300ESB" }, - { ATA_I6300ESB_R1, 0, 0, 2, ATA_SA150, "6300ESB" }, + { ATA_I6300ESB_S1, 0, INTEL_ICH5, 2, ATA_SA150, "6300ESB" }, + { ATA_I6300ESB_R1, 0, INTEL_ICH5, 2, ATA_SA150, "6300ESB" }, { ATA_I82801FB, 0, 0, 2, ATA_UDMA5, "ICH6" }, { ATA_I82801FB_S1, 0, INTEL_AHCI, 0, ATA_SA150, "ICH6" }, { ATA_I82801FB_R1, 0, INTEL_AHCI, 0, ATA_SA150, "ICH6" }, { ATA_I82801FBM, 0, INTEL_AHCI, 0, ATA_SA150, "ICH6M" }, { ATA_I82801GB, 0, 0, 1, ATA_UDMA5, "ICH7" }, - { ATA_I82801GB_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH7" }, - { ATA_I82801GB_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH7" }, + { ATA_I82801GB_S1, 0, 0, 0, ATA_SA300, "ICH7" }, + { ATA_I82801GB_R1, 0, 0, 0, ATA_SA300, "ICH7" }, { ATA_I82801GB_AH, 0, INTEL_AHCI, 0, ATA_SA300, "ICH7" }, - { ATA_I82801GBM_S1, 0, INTEL_AHCI, 0, ATA_SA150, "ICH7M" }, - { ATA_I82801GBM_R1, 0, INTEL_AHCI, 0, ATA_SA150, "ICH7M" }, + { ATA_I82801GBM_S1, 0, 0, 0, ATA_SA150, "ICH7M" }, + { ATA_I82801GBM_R1, 0, 0, 0, ATA_SA150, "ICH7M" }, { ATA_I82801GBM_AH, 0, INTEL_AHCI, 0, ATA_SA150, "ICH7M" }, { ATA_I63XXESB2, 0, 0, 1, ATA_UDMA5, "63XXESB2" }, - { ATA_I63XXESB2_S1, 0, INTEL_AHCI, 0, ATA_SA300, "63XXESB2" }, + { ATA_I63XXESB2_S1, 0, 0, 0, ATA_SA300, "63XXESB2" }, { ATA_I63XXESB2_S2, 0, INTEL_AHCI, 0, ATA_SA300, "63XXESB2" }, { ATA_I63XXESB2_R1, 0, INTEL_AHCI, 0, ATA_SA300, "63XXESB2" }, { ATA_I63XXESB2_R2, 0, INTEL_AHCI, 0, ATA_SA300, "63XXESB2" }, - { ATA_I82801HB_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8" }, - { ATA_I82801HB_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8" }, + { ATA_I82801HB_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH8" }, + { ATA_I82801HB_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH8" }, { ATA_I82801HB_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8" }, { ATA_I82801HB_AH4, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8" }, { ATA_I82801HB_AH6, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8" }, { ATA_I82801HBM, 0, 0, 1, ATA_UDMA5, "ICH8M" }, - { ATA_I82801HBM_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8M" }, + { ATA_I82801HBM_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH8M" }, { ATA_I82801HBM_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8M" }, { ATA_I82801HBM_S3, 0, INTEL_AHCI, 0, ATA_SA300, "ICH8M" }, - { ATA_I82801IB_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, - { ATA_I82801IB_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, + { ATA_I82801IB_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH9" }, + { ATA_I82801IB_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH9" }, { ATA_I82801IB_AH2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, { ATA_I82801IB_AH4, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, { ATA_I82801IB_AH6, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, { ATA_I82801IB_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH9" }, - { ATA_I82801JIB_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, + { ATA_I82801JIB_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH10" }, { ATA_I82801JIB_AH, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, { ATA_I82801JIB_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_I82801JIB_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_I82801JD_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, + { ATA_I82801JIB_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH10" }, + { ATA_I82801JD_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH10" }, { ATA_I82801JD_AH, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, { ATA_I82801JD_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_I82801JD_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_I82801JI_S1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, + { ATA_I82801JD_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH10" }, + { ATA_I82801JI_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH10" }, { ATA_I82801JI_AH, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, { ATA_I82801JI_R1, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_I82801JI_S2, 0, INTEL_AHCI, 0, ATA_SA300, "ICH10" }, - { ATA_5Series_S1, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S2, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_I82801JI_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH10" }, + { ATA_5Series_S1, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_5Series_S2, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_AH1, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_AH2, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_R1, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S3, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S4, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_5Series_S3, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_5Series_S4, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_AH3, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_R2, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S5, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S6, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_5Series_S5, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_5Series_S6, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, { ATA_5Series_AH4, 0, INTEL_AHCI, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_CPT_S1, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, - { ATA_CPT_S2, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, + { ATA_CPT_S1, 0, INTEL_6CH, 0, ATA_SA300, "Cougar Point" }, + { ATA_CPT_S2, 0, INTEL_6CH, 0, ATA_SA300, "Cougar Point" }, { ATA_CPT_AH1, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, { ATA_CPT_AH2, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, { ATA_CPT_R1, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, { ATA_CPT_R2, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, - { ATA_CPT_S3, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, - { ATA_CPT_S4, 0, INTEL_AHCI, 0, ATA_SA300, "Cougar Point" }, + { ATA_CPT_S3, 0, INTEL_6CH2, 0, ATA_SA300, "Cougar Point" }, + { ATA_CPT_S4, 0, INTEL_6CH2, 0, ATA_SA300, "Cougar Point" }, { ATA_I31244, 0, 0, 2, ATA_SA150, "31244" }, { ATA_ISCH, 0, 0, 1, ATA_UDMA5, "SCH" }, { 0, 0, 0, 0, 0, 0}}; @@ -183,6 +194,8 @@ ata_intel_chipinit(device_t dev) if (ata_setup_interrupt(dev, ata_generic_intr)) return ENXIO; + ctlr->chipset_data = NULL; + /* good old PIIX needs special treatment (not implemented) */ if (ctlr->chip->chipid == ATA_I82371FB) { ctlr->setmode = ata_intel_old_setmode; @@ -233,7 +246,7 @@ ata_intel_chipinit(device_t dev) * if we have AHCI capability and AHCI or RAID mode enabled * in BIOS we try for AHCI mode */ - if ((ctlr->chip->cfg1 == INTEL_AHCI) && + if ((ctlr->chip->cfg1 & INTEL_AHCI) && (pci_read_config(dev, 0x90, 1) & 0xc0) && (ata_ahci_chipinit(dev) != ENXIO)) return 0; @@ -242,7 +255,8 @@ ata_intel_chipinit(device_t dev) ctlr->r_type2 = SYS_RES_IOPORT; ctlr->r_rid2 = PCIR_BAR(5); if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2, - &ctlr->r_rid2, RF_ACTIVE))) + &ctlr->r_rid2, RF_ACTIVE)) + || (ctlr->chip->cfg1 & INTEL_ICH5)) ctlr->getrev = ata_intel_sata_getrev; ctlr->setmode = ata_sata_setmode; } @@ -252,63 +266,142 @@ ata_intel_chipinit(device_t dev) static int ata_intel_ch_attach(device_t dev) { - struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); - struct ata_channel *ch = device_get_softc(dev); - - /* setup the usual register normal pci style */ - if (ata_pci_ch_attach(dev)) - return ENXIO; - - /* if r_res2 is valid it points to SATA interface registers */ - if (ctlr->r_res2) { - ch->r_io[ATA_IDX_ADDR].res = ctlr->r_res2; - ch->r_io[ATA_IDX_ADDR].offset = 0x00; - ch->r_io[ATA_IDX_DATA].res = ctlr->r_res2; - ch->r_io[ATA_IDX_DATA].offset = 0x04; - } + struct ata_pci_controller *ctlr; + struct ata_channel *ch; + u_char *smap; + u_int map; + + /* setup the usual register normal pci style */ + if (ata_pci_ch_attach(dev)) + return (ENXIO); + + ctlr = device_get_softc(device_get_parent(dev)); + ch = device_get_softc(dev); + + /* if r_res2 is valid it points to SATA interface registers */ + if (ctlr->r_res2) { + ch->r_io[ATA_IDX_ADDR].res = ctlr->r_res2; + ch->r_io[ATA_IDX_ADDR].offset = 0x00; + ch->r_io[ATA_IDX_DATA].res = ctlr->r_res2; + ch->r_io[ATA_IDX_DATA].offset = 0x04; + } - ch->flags |= ATA_ALWAYS_DMASTAT; - if (ctlr->chip->max_dma >= ATA_SA150) { - if (ctlr->chip->cfg1 == 0 && - (pci_read_config(device_get_parent(dev), 0x90, 1) & 0x04) == 0) - ch->flags |= ATA_NO_SLAVE; - ch->flags |= ATA_SATA; - } else if (ctlr->chip->chipid != ATA_ISCH) - ch->flags |= ATA_CHECKS_CABLE; - return 0; + ch->flags |= ATA_ALWAYS_DMASTAT; + if (ctlr->chip->max_dma >= ATA_SA150) { + smap = (u_char *)&ctlr->chipset_data + ch->unit * 2; + map = pci_read_config(device_get_parent(dev), 0x90, 1); + if (ctlr->chip->cfg1 & INTEL_ICH5) { + map &= 0x07; + if ((map & 0x04) == 0) { + ch->flags |= ATA_SATA; + ch->flags |= ATA_NO_SLAVE; + smap[0] = (map & 0x01) ^ ch->unit; + smap[1] = 0; + } else if ((map & 0x02) == 0 && ch->unit == 0) { + ch->flags |= ATA_SATA; + smap[0] = (map & 0x01) ? 1 : 0; + smap[1] = (map & 0x01) ? 0 : 1; + } else if ((map & 0x02) != 0 && ch->unit == 1) { + ch->flags |= ATA_SATA; + smap[0] = (map & 0x01) ? 1 : 0; + smap[1] = (map & 0x01) ? 0 : 1; + } + } else if (ctlr->chip->cfg1 & INTEL_6CH2) { + ch->flags |= ATA_SATA; + ch->flags |= ATA_NO_SLAVE; + smap[0] = (ch->unit == 0) ? 4 : 5; + smap[1] = 0; + } else { + map &= 0x03; + if (map == 0x00) { + ch->flags |= ATA_SATA; + smap[ch->unit] = (ch->unit == 0) ? 0x20 : 0x31; + smap[0] = (ch->unit == 0) ? 0 : 1; + smap[1] = (ch->unit == 0) ? 2 : 3; + } else if (map == 0x02 && ch->unit == 0) { + ch->flags |= ATA_SATA; + smap[0] = 0; + smap[1] = 2; + } else if (map == 0x01 && ch->unit == 1) { + ch->flags |= ATA_SATA; + smap[0] = 1; + smap[1] = 3; + } + } + if (ch->flags & ATA_SATA) { + if ((ctlr->chip->cfg1 & INTEL_ICH5)) { + ch->flags |= ATA_PERIODIC_POLL; + ch->hw.status = ata_intel_sata_status; + ch->hw.pm_read = ata_intel_sata_cscr_read; + ch->hw.pm_write = ata_intel_sata_cscr_write; + } else if (ctlr->r_res2) { + ch->flags |= ATA_PERIODIC_POLL; + ch->hw.status = ata_intel_sata_status; + ch->hw.pm_read = ata_intel_sata_sidpr_read; + ch->hw.pm_write = ata_intel_sata_sidpr_write; + } + if (ch->hw.pm_write != NULL) { + ata_sata_scr_write(ch, 0, + ATA_SERROR, 0xffffffff); + if ((ch->flags & ATA_NO_SLAVE) == 0) { + ata_sata_scr_write(ch, 1, + ATA_SERROR, 0xffffffff); + } + } + } else + ctlr->setmode = ata_intel_new_setmode; + } else if (ctlr->chip->chipid != ATA_ISCH) + ch->flags |= ATA_CHECKS_CABLE; + return (0); } static void ata_intel_reset(device_t dev) { - device_t parent = device_get_parent(dev); - struct ata_pci_controller *ctlr = device_get_softc(parent); - struct ata_channel *ch = device_get_softc(dev); - int mask, timeout; + device_t parent = device_get_parent(dev); + struct ata_pci_controller *ctlr = device_get_softc(parent); + struct ata_channel *ch = device_get_softc(dev); + int mask, pmask, timeout, devs; + u_char *smap; - /* ICH6 & ICH7 in compat mode has 4 SATA ports as master/slave on 2 ch's */ - if (ctlr->chip->cfg1) { - mask = (0x0005 << ch->unit); - } - else { - /* ICH5 in compat mode has SATA ports as master/slave on 1 channel */ - if (pci_read_config(parent, 0x90, 1) & 0x04) - mask = 0x0003; + /* In combined mode, skip SATA stuff for PATA channel. */ + if ((ch->flags & ATA_SATA) == 0) + return (ata_generic_reset(dev)); + + /* Do hard-reset on respective SATA ports. */ + smap = (u_char *)&ctlr->chipset_data + ch->unit * 2; + mask = 1 << smap[0]; + if ((ch->flags & ATA_NO_SLAVE) == 0) + mask |= (1 << smap[1]); + pci_write_config(parent, 0x92, + pci_read_config(parent, 0x92, 2) & ~mask, 2); + DELAY(10); + pci_write_config(parent, 0x92, + pci_read_config(parent, 0x92, 2) | mask, 2); + + /* Wait up to 1 sec for "connect well". */ + if (ctlr->chip->cfg1 & (INTEL_6CH | INTEL_6CH2)) + pmask = mask << 8; else - mask = (0x0001 << ch->unit); - } - pci_write_config(parent, 0x92, pci_read_config(parent, 0x92, 2) & ~mask, 2); - DELAY(10); - pci_write_config(parent, 0x92, pci_read_config(parent, 0x92, 2) | mask, 2); - - /* wait up to 1 sec for "connect well" */ - for (timeout = 0; timeout < 100 ; timeout++) { - if (((pci_read_config(parent, 0x92, 2) & (mask << 4)) == (mask << 4)) && - (ATA_IDX_INB(ch, ATA_STATUS) != 0xff)) - break; - ata_udelay(10000); - } - ata_generic_reset(dev); + pmask = mask << 4; + for (timeout = 0; timeout < 100 ; timeout++) { + if (((pci_read_config(parent, 0x92, 2) & pmask) == pmask) && + (ATA_IDX_INB(ch, ATA_STATUS) != 0xff)) + break; + ata_udelay(10000); + } + + /* If any device found, do soft-reset. */ + if (ch->hw.pm_read != NULL) { + devs = ata_sata_phy_reset(dev, 0, 2); + if ((ch->flags & ATA_NO_SLAVE) == 0) + devs += ata_sata_phy_reset(dev, 1, 2); + } else + devs = 1; + if (devs) + ata_generic_reset(dev); + else + ch->devices = 0; } static int @@ -339,6 +432,10 @@ ata_intel_new_setmode(device_t dev, int u_int8_t timings[] = { 0x00, 0x00, 0x10, 0x21, 0x23, 0x00, 0x21, 0x23 }; u_int8_t utimings[] = { 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02 }; + /* In combined mode, skip PATA stuff for SATA channel. */ + if (ch->flags & ATA_SATA) + return (ata_sata_setmode(dev, target, mode)); + mode = min(mode, ctlr->chip->max_dma); if (ata_dma_check_80pin && mode > ATA_UDMA2 && !(reg54 & (0x10 << devno))) { @@ -421,12 +518,145 @@ static int ata_intel_sata_getrev(device_t dev, int target) { struct ata_channel *ch = device_get_softc(dev); - int devno = (ch->unit << 1) + target; + uint32_t status; + + if (ata_sata_scr_read(ch, target, ATA_SSTATUS, &status) == 0) + return ((status & 0x0f0) >> 4); + return (0xff); +} + +static int +ata_intel_sata_status(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + ata_sata_phy_check_events(dev, 0); + if ((ch->flags & ATA_NO_SLAVE) == 0) + ata_sata_phy_check_events(dev, 1); - /* set ATA_SSTATUS register offset */ - ATA_IDX_OUTL(ch, ATA_IDX_ADDR, devno * 0x100); - /* query SATA STATUS for the speed */ - return ((ATA_IDX_INL(ch, ATA_IDX_DATA) & 0x0f0) >> 4); + return ata_pci_status(dev); +} + +static int +ata_intel_sata_cscr_read(device_t dev, int port, int reg, u_int32_t *result) +{ + struct ata_pci_controller *ctlr; + struct ata_channel *ch; + device_t parent; + u_char *smap; + + parent = device_get_parent(dev); + ctlr = device_get_softc(parent); + ch = device_get_softc(dev); + smap = (u_char *)&ctlr->chipset_data + ch->unit * 2; + port = (port == 1) ? 1 : 0; + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + pci_write_config(parent, 0xa0, + 0x50 + smap[port] * 0x10 + reg * 4, 4); + *result = pci_read_config(parent, 0xa4, 4); + return (0); +} + +static int +ata_intel_sata_sidpr_read(device_t dev, int port, int reg, u_int32_t *result) +{ + struct ata_pci_controller *ctlr; + struct ata_channel *ch; + device_t parent; + + parent = device_get_parent(dev); + ctlr = device_get_softc(parent); + ch = device_get_softc(dev); + port = (port == 1) ? 1 : 0; + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SCONTROL: + reg = 1; + break; + case ATA_SERROR: + reg = 2; + break; + default: + return (EINVAL); + } + ATA_IDX_OUTL(ch, ATA_IDX_ADDR, ((ch->unit * 2 + port) << 8) + reg); + *result = ATA_IDX_INL(ch, ATA_IDX_DATA); + return (0); +} + +static int +ata_intel_sata_cscr_write(device_t dev, int port, int reg, u_int32_t value) +{ + struct ata_pci_controller *ctlr; + struct ata_channel *ch; + device_t parent; + u_char *smap; + + parent = device_get_parent(dev); + ctlr = device_get_softc(parent); + ch = device_get_softc(dev); + smap = (u_char *)&ctlr->chipset_data + ch->unit * 2; + port = (port == 1) ? 1 : 0; + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + pci_write_config(parent, 0xa0, + 0x50 + smap[port] * 0x10 + reg * 4, 4); + pci_write_config(parent, 0xa4, value, 4); + return (0); +} + +static int +ata_intel_sata_sidpr_write(device_t dev, int port, int reg, u_int32_t value) +{ + struct ata_pci_controller *ctlr; + struct ata_channel *ch; + device_t parent; + + parent = device_get_parent(dev); + ctlr = device_get_softc(parent); + ch = device_get_softc(dev); + port = (port == 1) ? 1 : 0; + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SCONTROL: + reg = 1; + break; + case ATA_SERROR: + reg = 2; + break; + default: + return (EINVAL); + } + ATA_IDX_OUTL(ch, ATA_IDX_ADDR, ((ch->unit * 2 + port) << 8) + reg); + ATA_IDX_OUTL(ch, ATA_IDX_DATA, value); + return (0); } static int @@ -492,7 +722,7 @@ static int ata_intel_31244_status(device_t dev) { /* do we have any PHY events ? */ - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); /* any drive action to take care of ? */ return ata_pci_status(dev); Modified: stable/8/sys/dev/ata/chipsets/ata-marvell.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-marvell.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-marvell.c Tue Nov 2 09:26:12 2010 (r214671) @@ -374,7 +374,7 @@ ata_marvell_edma_status(device_t dev) ATA_OUTL(ctlr->r_res1, 0x02008 + ATA_MV_EDMA_BASE(ch), 0x0); /* do we have any PHY events ? */ - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); } /* do we have any device action ? */ Modified: stable/8/sys/dev/ata/chipsets/ata-nvidia.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-nvidia.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-nvidia.c Tue Nov 2 09:26:12 2010 (r214671) @@ -281,7 +281,7 @@ ata_nvidia_status(device_t dev) /* do we have any PHY events ? */ if (istatus & (0x0c << shift)) - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); /* clear interrupt(s) */ if (ctlr->chip->cfg1 & NVQ) Modified: stable/8/sys/dev/ata/chipsets/ata-promise.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-promise.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-promise.c Tue Nov 2 09:26:12 2010 (r214671) @@ -830,6 +830,25 @@ ata_promise_mio_pm_read(device_t dev, in struct ata_channel *ch = device_get_softc(dev); int timeout = 0; + if (port < 0) { + *result = ATA_IDX_INL(ch, reg); + return (0); + } + if (port < ATA_PM) { + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + } /* set portmultiplier port */ ATA_OUTB(ctlr->r_res2, 0x4e8 + (ch->unit << 8), 0x0f); @@ -862,6 +881,25 @@ ata_promise_mio_pm_write(device_t dev, i struct ata_channel *ch = device_get_softc(dev); int timeout = 0; + if (port < 0) { + ATA_IDX_OUTL(ch, reg, value); + return (0); + } + if (port < ATA_PM) { + switch (reg) { + case ATA_SSTATUS: + reg = 0; + break; + case ATA_SERROR: + reg = 1; + break; + case ATA_SCONTROL: + reg = 2; + break; + default: + return (EINVAL); + } + } /* set portmultiplier port */ ATA_OUTB(ctlr->r_res2, 0x4e8 + (ch->unit << 8), 0x0f); Modified: stable/8/sys/dev/ata/chipsets/ata-siliconimage.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Tue Nov 2 09:16:41 2010 (r214670) +++ stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Tue Nov 2 09:26:12 2010 (r214671) @@ -354,7 +354,7 @@ ata_sii_status(device_t dev) /* do we have any PHY events ? */ if (ctlr->chip->max_dma >= ATA_SA150 && (ATA_INL(ctlr->r_res2, 0x10 + offset0) & 0x00000010)) - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); if (ATA_INL(ctlr->r_res2, 0xa0 + offset1) & 0x00000800) return ata_pci_status(dev); @@ -510,7 +510,7 @@ ata_siiprb_status(device_t dev) u_int32_t istatus = ATA_INL(ctlr->r_res2, 0x1008 + offset); /* do we have any PHY events ? */ - ata_sata_phy_check_events(dev); + ata_sata_phy_check_events(dev, -1); /* clear interrupt(s) */ ATA_OUTL(ctlr->r_res2, 0x1008 + offset, istatus); @@ -700,6 +700,25 @@ ata_siiprb_pm_read(device_t dev, int por struct ata_siiprb_command *prb = (struct ata_siiprb_command *)ch->dma.work; int offset = ch->unit * 0x2000; + if (port < 0) { + *result = ATA_IDX_INL(ch, reg); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 20:06:46 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDADC1065672; Tue, 2 Nov 2010 20:06:46 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D9EE58FC12; Tue, 2 Nov 2010 20:06: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 oA2K6kP1082092; Tue, 2 Nov 2010 20:06:46 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2K6k4s082087; Tue, 2 Nov 2010 20:06:46 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201011022006.oA2K6k4s082087@svn.freebsd.org> From: Marius Strobl Date: Tue, 2 Nov 2010 20:06:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214684 - in stable/8/sys: dev/mii modules/mii X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 20:06:47 -0000 Author: marius Date: Tue Nov 2 20:06:46 2010 New Revision: 214684 URL: http://svn.freebsd.org/changeset/base/214684 Log: MFC: r213878 Add a NetBSD-compatible mii_attach(), which is intended to eventually replace mii_phy_probe() altogether. Compared to the latter the advantages of mii_attach() are: - intended to be called multiple times in order to attach PHYs in multiple passes (f.e. in order to only use sub-ranges of the 0 to MII_NPHY - 1 range) - being able to pass along the capability mask from the NIC to the PHY drivers - being able to specify at which address (phyloc) to probe for a PHY (instead of always probing at all addresses from 0 to MII_NPHY - 1) - being able to specify which PHY instance (offloc) to attach - being able to pass along MIIF_* flags from the NIC to the PHY drivers (f.e. as required to indicated to the PHY drivers that flow control is supported by the NIC driver, which actually is the motivation for this change). While at it, I used the opportunity to get rid of some hacks in mii(4) like miibus_probe() generally doing work besides sheer probing and the "EVIL HACK" (which will vanish entirely along with mii_phy_probe()) by passing the struct ifnet pointer via an argument of mii_attach() as well as to fix some resource leaks in mii(4) in case something fails. Commits which will update the PHY drivers to honor the MII flags passed down from the NIC drivers and take advantage of mii_attach() to get rid of certain types of hacks in NIC and PHY drivers as well as a conversion of the remaining uses of mii_phy_probe() will follow shortly. Reviewed by: jhb, yongari Obtained from: NetBSD (partially) Modified: stable/8/sys/dev/mii/mii.c stable/8/sys/dev/mii/mii.h stable/8/sys/dev/mii/miivar.h stable/8/sys/modules/mii/Makefile Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/mii/mii.c ============================================================================== --- stable/8/sys/dev/mii/mii.c Tue Nov 2 19:33:45 2010 (r214683) +++ stable/8/sys/dev/mii/mii.c Tue Nov 2 20:06:46 2010 (r214684) @@ -58,6 +58,8 @@ MODULE_VERSION(miibus, 1); #include "miibus_if.h" static int miibus_print_child(device_t dev, device_t child); +static int miibus_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); static int miibus_child_location_str(device_t bus, device_t child, char *buf, size_t buflen); static int miibus_child_pnpinfo_str(device_t bus, device_t child, char *buf, @@ -77,6 +79,7 @@ static device_method_t miibus_methods[] /* bus interface */ DEVMETHOD(bus_print_child, miibus_print_child), + DEVMETHOD(bus_read_ivar, miibus_read_ivar), DEVMETHOD(bus_driver_added, bus_generic_driver_added), DEVMETHOD(bus_child_pnpinfo_str, miibus_child_pnpinfo_str), DEVMETHOD(bus_child_location_str, miibus_child_location_str), @@ -100,87 +103,52 @@ driver_t miibus_driver = { }; struct miibus_ivars { + struct ifnet *ifp; ifm_change_cb_t ifmedia_upd; ifm_stat_cb_t ifmedia_sts; + int mii_flags; }; -/* - * Helper function used by network interface drivers, attaches PHYs - * to the network interface driver parent. - */ int miibus_probe(device_t dev) { - struct mii_attach_args ma, *args; - struct mii_data *mii; - device_t child = NULL, parent; - int bmsr, capmask = 0xFFFFFFFF; - - mii = device_get_softc(dev); - parent = device_get_parent(dev); - LIST_INIT(&mii->mii_phys); - - for (ma.mii_phyno = 0; ma.mii_phyno < MII_NPHY; ma.mii_phyno++) { - /* - * Check to see if there is a PHY at this address. Note, - * many braindead PHYs report 0/0 in their ID registers, - * so we test for media in the BMSR. - */ - bmsr = MIIBUS_READREG(parent, ma.mii_phyno, MII_BMSR); - if (bmsr == 0 || bmsr == 0xffff || - (bmsr & (BMSR_EXTSTAT | BMSR_MEDIAMASK)) == 0) { - /* Assume no PHY at this address. */ - continue; - } - - /* - * Extract the IDs. Braindead PHYs will be handled by - * the `ukphy' driver, as we have no ID information to - * match on. - */ - ma.mii_id1 = MIIBUS_READREG(parent, ma.mii_phyno, - MII_PHYIDR1); - ma.mii_id2 = MIIBUS_READREG(parent, ma.mii_phyno, - MII_PHYIDR2); - - ma.mii_data = mii; - ma.mii_capmask = capmask; - - args = malloc(sizeof(struct mii_attach_args), - M_DEVBUF, M_NOWAIT); - bcopy((char *)&ma, (char *)args, sizeof(ma)); - child = device_add_child(dev, NULL, -1); - device_set_ivars(child, args); - } - - if (child == NULL) - return (ENXIO); device_set_desc(dev, "MII bus"); - return (0); + return (BUS_PROBE_SPECIFIC); } int miibus_attach(device_t dev) { struct miibus_ivars *ivars; + struct mii_attach_args *ma; struct mii_data *mii; + device_t *children; + int i, nchildren; mii = device_get_softc(dev); - /* - * Note that each NIC's softc must start with an ifnet pointer. - * XXX: EVIL HACK! - */ - mii->mii_ifp = *(struct ifnet**)device_get_softc(device_get_parent(dev)); - mii->mii_ifp->if_capabilities |= IFCAP_LINKSTATE; - mii->mii_ifp->if_capenable |= IFCAP_LINKSTATE; + nchildren = 0; + if (device_get_children(dev, &children, &nchildren) == 0) { + for (i = 0; i < nchildren; i++) { + ma = device_get_ivars(children[i]); + ma->mii_data = mii; + } + free(children, M_TEMP); + } + if (nchildren == 0) { + device_printf(dev, "cannot get children"); + return (ENXIO); + } ivars = device_get_ivars(dev); ifmedia_init(&mii->mii_media, IFM_IMASK, ivars->ifmedia_upd, ivars->ifmedia_sts); - bus_generic_attach(dev); + mii->mii_ifp = ivars->ifp; + mii->mii_ifp->if_capabilities |= IFCAP_LINKSTATE; + mii->mii_ifp->if_capenable |= IFCAP_LINKSTATE; + LIST_INIT(&mii->mii_phys); - return (0); + return (bus_generic_attach(dev)); } int @@ -211,7 +179,28 @@ miibus_print_child(device_t dev, device_ } static int -miibus_child_pnpinfo_str(device_t bus, device_t child, char *buf, +miibus_read_ivar(device_t dev, device_t child __unused, int which, + uintptr_t *result) +{ + struct miibus_ivars *ivars; + + /* + * NB: this uses the instance variables of the miibus rather than + * its PHY children. + */ + ivars = device_get_ivars(dev); + switch (which) { + case MIIBUS_IVAR_FLAGS: + *result = ivars->mii_flags; + break; + default: + return (ENOENT); + } + return (0); +} + +static int +miibus_child_pnpinfo_str(device_t bus __unused, device_t child, char *buf, size_t buflen) { struct mii_attach_args *ma; @@ -224,7 +213,7 @@ miibus_child_pnpinfo_str(device_t bus, d } static int -miibus_child_location_str(device_t bus, device_t child, char *buf, +miibus_child_location_str(device_t bus __unused, device_t child, char *buf, size_t buflen) { struct mii_attach_args *ma; @@ -318,40 +307,177 @@ miibus_mediainit(device_t dev) ifmedia_set(&mii->mii_media, media); } +/* + * Helper function used by network interface drivers, attaches the miibus and + * the PHYs to the network interface driver parent. + */ int -mii_phy_probe(device_t dev, device_t *child, ifm_change_cb_t ifmedia_upd, - ifm_stat_cb_t ifmedia_sts) -{ - struct miibus_ivars *ivars; - int bmsr, i; +mii_attach(device_t dev, device_t *miibus, struct ifnet *ifp, + ifm_change_cb_t ifmedia_upd, ifm_stat_cb_t ifmedia_sts, int capmask, + int phyloc, int offloc, int flags) +{ + struct miibus_ivars *ivars; + struct mii_attach_args ma, *args; + device_t *children, phy; + int bmsr, first, i, nchildren, offset, phymax, phymin, rv; + + if (phyloc != MII_PHY_ANY && offloc != MII_OFFSET_ANY) { + printf("%s: phyloc and offloc specified", __func__); + return (EINVAL); + } - ivars = malloc(sizeof(*ivars), M_DEVBUF, M_NOWAIT); - if (ivars == NULL) - return (ENOMEM); - ivars->ifmedia_upd = ifmedia_upd; - ivars->ifmedia_sts = ifmedia_sts; - *child = device_add_child(dev, "miibus", -1); - device_set_ivars(*child, ivars); - - for (i = 0; i < MII_NPHY; i++) { - bmsr = MIIBUS_READREG(dev, i, MII_BMSR); - if (bmsr == 0 || bmsr == 0xffff || - (bmsr & (BMSR_EXTSTAT | BMSR_MEDIAMASK)) == 0) { - /* Assume no PHY at this address. */ - continue; - } else - break; + if (offloc != MII_OFFSET_ANY && (offloc < 0 || offloc >= MII_NPHY)) { + printf("%s: ivalid offloc %d", __func__, offloc); + return (EINVAL); } - if (i == MII_NPHY) { - device_delete_child(dev, *child); - *child = NULL; - return (ENXIO); + if (phyloc == MII_PHY_ANY) { + phymin = 0; + phymax = MII_NPHY - 1; + } else { + if (phyloc < 0 || phyloc >= MII_NPHY) { + printf("%s: ivalid phyloc %d", __func__, phyloc); + return (EINVAL); + } + phymin = phymax = phyloc; } - bus_generic_attach(dev); + first = 0; + if (*miibus == NULL) { + first = 1; + ivars = malloc(sizeof(*ivars), M_DEVBUF, M_NOWAIT); + if (ivars == NULL) + return (ENOMEM); + ivars->ifp = ifp; + ivars->ifmedia_upd = ifmedia_upd; + ivars->ifmedia_sts = ifmedia_sts; + ivars->mii_flags = flags; + *miibus = device_add_child(dev, "miibus", -1); + if (*miibus == NULL) { + rv = ENXIO; + goto fail; + } + device_set_ivars(*miibus, ivars); + } else { + ivars = device_get_ivars(*miibus); + if (ivars->ifp != ifp || ivars->ifmedia_upd != ifmedia_upd || + ivars->ifmedia_sts != ifmedia_sts || + ivars->mii_flags != flags) { + printf("%s: non-matching invariant", __func__); + return (EINVAL); + } + /* + * Assignment of the attach arguments mii_data for the first + * pass is done in miibus_attach(), i.e. once the miibus softc + * has been allocated. + */ + ma.mii_data = device_get_softc(*miibus); + } + + ma.mii_capmask = capmask; + + phy = NULL; + offset = 0; + for (ma.mii_phyno = phymin; ma.mii_phyno <= phymax; ma.mii_phyno++) { + /* + * Make sure we haven't already configured a PHY at this + * address. This allows mii_attach() to be called + * multiple times. + */ + if (device_get_children(*miibus, &children, &nchildren) == 0) { + for (i = 0; i < nchildren; i++) { + args = device_get_ivars(children[i]); + if (args->mii_phyno == ma.mii_phyno) { + /* + * Yes, there is already something + * configured at this address. + */ + free(children, M_TEMP); + goto skip; + } + } + free(children, M_TEMP); + } + + /* + * Check to see if there is a PHY at this address. Note, + * many braindead PHYs report 0/0 in their ID registers, + * so we test for media in the BMSR. + */ + bmsr = MIIBUS_READREG(dev, ma.mii_phyno, MII_BMSR); + if (bmsr == 0 || bmsr == 0xffff || + (bmsr & (BMSR_EXTSTAT | BMSR_MEDIAMASK)) == 0) { + /* Assume no PHY at this address. */ + continue; + } + + /* + * There is a PHY at this address. If we were given an + * `offset' locator, skip this PHY if it doesn't match. + */ + if (offloc != MII_OFFSET_ANY && offloc != offset) + goto skip; + + /* + * Extract the IDs. Braindead PHYs will be handled by + * the `ukphy' driver, as we have no ID information to + * match on. + */ + ma.mii_id1 = MIIBUS_READREG(dev, ma.mii_phyno, MII_PHYIDR1); + ma.mii_id2 = MIIBUS_READREG(dev, ma.mii_phyno, MII_PHYIDR2); + + args = malloc(sizeof(struct mii_attach_args), M_DEVBUF, + M_NOWAIT); + if (args == NULL) + goto skip; + bcopy((char *)&ma, (char *)args, sizeof(ma)); + phy = device_add_child(*miibus, NULL, -1); + if (phy == NULL) { + free(args, M_DEVBUF); + goto skip; + } + device_set_ivars(phy, args); + skip: + offset++; + } + + if (first != 0) { + if (phy == NULL) { + rv = ENXIO; + goto fail; + } + rv = bus_generic_attach(dev); + if (rv != 0) + goto fail; + } + rv = bus_generic_attach(*miibus); + if (rv != 0) + goto fail; return (0); + + fail: + if (*miibus != NULL) + device_delete_child(dev, *miibus); + free(ivars, M_DEVBUF); + if (first != 0) + *miibus = NULL; + return (rv); +} + +int +mii_phy_probe(device_t dev, device_t *child, ifm_change_cb_t ifmedia_upd, + ifm_stat_cb_t ifmedia_sts) +{ + struct ifnet *ifp; + + /* + * Note that each NIC's softc must start with an ifnet pointer. + * XXX: EVIL HACK! + */ + ifp = *(struct ifnet **)device_get_softc(dev); + return (mii_attach(dev, child, ifp, ifmedia_upd, ifmedia_sts, + BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0)); } /* Modified: stable/8/sys/dev/mii/mii.h ============================================================================== --- stable/8/sys/dev/mii/mii.h Tue Nov 2 19:33:45 2010 (r214683) +++ stable/8/sys/dev/mii/mii.h Tue Nov 2 20:06:46 2010 (r214684) @@ -1,5 +1,5 @@ /* $NetBSD: mii.h,v 1.9 2001/05/31 03:07:14 thorpej Exp $ */ - + /*- * Copyright (c) 1997 Manuel Bouyer. All rights reserved. * @@ -47,7 +47,7 @@ #define MII_COMMAND_WRITE 0x01 #define MII_COMMAND_ACK 0x02 -#define MII_BMCR 0x00 /* Basic mode control register (rw) */ +#define MII_BMCR 0x00 /* Basic mode control register (rw) */ #define BMCR_RESET 0x8000 /* reset */ #define BMCR_LOOP 0x4000 /* loopback */ #define BMCR_SPEED0 0x2000 /* speed selection (LSB) */ @@ -82,6 +82,8 @@ #define BMSR_JABBER 0x0002 /* Jabber detected */ #define BMSR_EXTCAP 0x0001 /* Extended capability */ +#define BMSR_DEFCAPMASK 0xffffffff + /* * Note that the EXTSTAT bit indicates that there is extended status * info available in register 15, but 802.3 section 22.2.4.3 also Modified: stable/8/sys/dev/mii/miivar.h ============================================================================== --- stable/8/sys/dev/mii/miivar.h Tue Nov 2 19:33:45 2010 (r214683) +++ stable/8/sys/dev/mii/miivar.h Tue Nov 2 20:06:46 2010 (r214684) @@ -102,7 +102,7 @@ typedef int (*mii_downcall_t)(struct mii */ struct mii_softc { device_t mii_dev; /* generic device glue */ - + LIST_ENTRY(mii_softc) mii_list; /* entry on parent's PHY list */ int mii_phy; /* our MII address */ @@ -122,16 +122,22 @@ struct mii_softc { typedef struct mii_softc mii_softc_t; /* mii_flags */ -#define MIIF_INITDONE 0x0001 /* has been initialized (mii_data) */ -#define MIIF_NOISOLATE 0x0002 /* do not isolate the PHY */ -#define MIIF_NOLOOP 0x0004 /* no loopback capability */ -#define MIIF_AUTOTSLEEP 0x0010 /* use tsleep(), not callout() */ -#define MIIF_HAVEFIBER 0x0020 /* from parent: has fiber interface */ -#define MIIF_HAVE_GTCR 0x0040 /* has 100base-T2/1000base-T CR */ -#define MIIF_IS_1000X 0x0080 /* is a 1000BASE-X device */ -#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */ -#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */ -#define MIIF_FORCEANEG 0x0400 /* force auto-negotiation */ +#define MIIF_INITDONE 0x00000001 /* has been initialized (mii_data) */ +#define MIIF_NOISOLATE 0x00000002 /* do not isolate the PHY */ +#define MIIF_NOLOOP 0x00000004 /* no loopback capability */ +#define MIIF_AUTOTSLEEP 0x00000010 /* use tsleep(), not callout() */ +#define MIIF_HAVEFIBER 0x00000020 /* from parent: has fiber interface */ +#define MIIF_HAVE_GTCR 0x00000040 /* has 100base-T2/1000base-T CR */ +#define MIIF_IS_1000X 0x00000080 /* is a 1000BASE-X device */ +#define MIIF_DOPAUSE 0x00000100 /* advertise PAUSE capability */ +#define MIIF_IS_HPNA 0x00000200 /* is a HomePNA device */ +#define MIIF_FORCEANEG 0x00000400 /* force auto-negotiation */ +#define MIIF_MACPRIV0 0x01000000 /* private to the MAC driver */ +#define MIIF_MACPRIV1 0x02000000 /* private to the MAC driver */ +#define MIIF_MACPRIV2 0x04000000 /* private to the MAC driver */ +#define MIIF_PHYPRIV0 0x10000000 /* private to the PHY driver */ +#define MIIF_PHYPRIV1 0x20000000 /* private to the PHY driver */ +#define MIIF_PHYPRIV2 0x40000000 /* private to the PHY driver */ /* Default mii_anegticks values */ #define MII_ANEGTICKS 5 @@ -140,6 +146,14 @@ typedef struct mii_softc mii_softc_t; #define MIIF_INHERIT_MASK (MIIF_NOISOLATE|MIIF_NOLOOP|MIIF_AUTOTSLEEP) /* + * Special `locators' passed to mii_attach(). If one of these is not + * an `any' value, we look for *that* PHY and configure it. If both + * are not `any', that is an error, and mii_attach() will panic. + */ +#define MII_OFFSET_ANY -1 +#define MII_PHY_ANY -1 + +/* * Used to attach a PHY to a parent. */ struct mii_attach_args { @@ -192,6 +206,18 @@ struct mii_media { #define PHY_WRITE(p, r, v) \ MIIBUS_WRITEREG((p)->mii_dev, (p)->mii_phy, (r), (v)) +enum miibus_device_ivars { + MIIBUS_IVAR_FLAGS +}; + +/* + * Simplified accessors for miibus + */ +#define MIIBUS_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(miibus, var, MIIBUS, ivar, type) + +MIIBUS_ACCESSOR(flags, FLAGS, int) + extern devclass_t miibus_devclass; extern driver_t miibus_driver; @@ -199,6 +225,8 @@ int miibus_probe(device_t); int miibus_attach(device_t); int miibus_detach(device_t); +int mii_attach(device_t, device_t *, struct ifnet *, ifm_change_cb_t, + ifm_stat_cb_t, int, int, int, int); int mii_anar(int); void mii_down(struct mii_data *); int mii_mediachg(struct mii_data *); Modified: stable/8/sys/modules/mii/Makefile ============================================================================== --- stable/8/sys/modules/mii/Makefile Tue Nov 2 19:33:45 2010 (r214683) +++ stable/8/sys/modules/mii/Makefile Tue Nov 2 20:06:46 2010 (r214684) @@ -12,7 +12,8 @@ SRCS+= rgephy.c rlphy.c ruephy.c tdkphy. SRCS+= ukphy_subr.c SRCS+= xmphy.c -EXPORT_SYMS= mii_mediachg \ +EXPORT_SYMS= mii_attach \ + mii_mediachg \ mii_phy_probe \ mii_phy_reset \ mii_pollstat \ From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 21:01:15 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DB2F106566B; Tue, 2 Nov 2010 21:01:15 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7AB6E8FC12; Tue, 2 Nov 2010 21:01:15 +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 oA2L1Fvx087557; Tue, 2 Nov 2010 21:01:15 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2L1F1a087554; Tue, 2 Nov 2010 21:01:15 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201011022101.oA2L1F1a087554@svn.freebsd.org> From: Marius Strobl Date: Tue, 2 Nov 2010 21:01:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214687 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 21:01:15 -0000 Author: marius Date: Tue Nov 2 21:01:15 2010 New Revision: 214687 URL: http://svn.freebsd.org/changeset/base/214687 Log: MFC: r201430 Fix card/device names, no functional change The ADMtek AN985 is the cardbus variant of ADMtek AN983 The Netgear FA511 is just a relabled ADMtek AN985 PR: kern/50574 Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Tue Nov 2 20:16:41 2010 (r214686) +++ stable/8/sys/dev/dc/if_dc.c Tue Nov 2 21:01:15 2010 (r214687) @@ -43,8 +43,9 @@ __FBSDID("$FreeBSD$"); * ASIX Electronics AX88140A (www.asix.com.tw) * ASIX Electronics AX88141 (www.asix.com.tw) * ADMtek AL981 (www.admtek.com.tw) - * ADMtek AN985 (www.admtek.com.tw) - * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek AN985 + * ADMtek AN983 (www.admtek.com.tw) + * ADMtek cardbus AN985 (www.admtek.com.tw) + * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek cardbus AN985 * Davicom DM9100, DM9102, DM9102A (www.davicom8.com) * Accton EN1217 (www.accton.com) * Xircom X3201 (www.xircom.com) @@ -161,14 +162,14 @@ static const struct dc_type dc_devs[] = "Davicom DM9102 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AL981), 0, "ADMtek AL981 10/100BaseTX" }, + { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983), 0, + "ADMtek AN983 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985), 0, - "ADMtek AN985 10/100BaseTX" }, + "ADMtek AN985 cardBus 10/100BaseTX or clone" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511), 0, "ADMtek ADM9511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513), 0, "ADMtek ADM9513 10/100BaseTX" }, - { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_FA511), 0, - "Netgear FA511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ASIX, DC_DEVICEID_AX88140A), DC_REVISION_88141, "ASIX AX88141 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ASIX, DC_DEVICEID_AX88140A), 0, @@ -778,10 +779,10 @@ dc_miibus_readreg(device_t dev, int phy, bzero(&frame, sizeof(frame)); /* - * Note: both the AL981 and AN985 have internal PHYs, + * Note: both the AL981 and AN983 have internal PHYs, * however the AL981 provides direct access to the PHY - * registers while the AN985 uses a serial MII interface. - * The AN985's MII interface is also buggy in that you + * registers while the AN983 uses a serial MII interface. + * The AN983's MII interface is also buggy in that you * can read from any MII address (0 to 31), but only address 1 * behaves normally. To deal with both cases, we pretend * that the PHY is at MII address 1. @@ -1895,11 +1896,11 @@ dc_attach(device_t dev) sc->dc_pmode = DC_PMODE_MII; dc_read_srom(sc, sc->dc_romwidth); break; + case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513): case DC_DEVID(DC_VENDORID_DLINK, DC_DEVICEID_DRP32TXD): - case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_FA511): case DC_DEVID(DC_VENDORID_ABOCOM, DC_DEVICEID_FE2500): case DC_DEVID(DC_VENDORID_ABOCOM, DC_DEVICEID_FE2500MX): case DC_DEVID(DC_VENDORID_ACCTON, DC_DEVICEID_EN2242): @@ -1910,7 +1911,7 @@ dc_attach(device_t dev) case DC_DEVID(DC_VENDORID_MICROSOFT, DC_DEVICEID_MSMN130): case DC_DEVID(DC_VENDORID_LINKSYS, DC_DEVICEID_PCMPC200_AB08): case DC_DEVID(DC_VENDORID_LINKSYS, DC_DEVICEID_PCMPC200_AB09): - sc->dc_type = DC_TYPE_AN985; + sc->dc_type = DC_TYPE_AN983; sc->dc_flags |= DC_64BIT_HASH; sc->dc_flags |= DC_TX_USE_TX_INTR; sc->dc_flags |= DC_TX_ADMTEK_WAR; @@ -2057,7 +2058,7 @@ dc_attach(device_t dev) dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0); break; case DC_TYPE_AL981: - case DC_TYPE_AN985: + case DC_TYPE_AN983: reg = CSR_READ_4(sc, DC_AL_PAR0); mac = (uint8_t *)&eaddr[0]; mac[0] = (reg >> 0) & 0xff; Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Tue Nov 2 20:16:41 2010 (r214686) +++ stable/8/sys/dev/dc/if_dcreg.h Tue Nov 2 21:01:15 2010 (r214687) @@ -72,7 +72,7 @@ #define DC_TYPE_21143 0x4 /* Intel 21143 */ #define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ #define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ -#define DC_TYPE_AN985 0x7 /* ADMtek AN985 Centaur */ +#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ #define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ #define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ #define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ @@ -86,12 +86,12 @@ #define DC_IS_ADMTEK(x) \ (x->dc_type == DC_TYPE_AL981 || \ - x->dc_type == DC_TYPE_AN985) + x->dc_type == DC_TYPE_AN983) #define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) #define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) #define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) -#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN985) +#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) #define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) #define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) #define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) @@ -543,8 +543,8 @@ struct dc_mii_frame { */ /* - * ADMtek specific registers and constants for the AL981 and AN985. - * The AN985 doesn't use the magic PHY registers. + * ADMtek specific registers and constants for the AL981 and AN983. + * The AN983 doesn't use the magic PHY registers. */ #define DC_AL_CR 0x88 /* command register */ #define DC_AL_PAR0 0xA4 /* station address */ @@ -890,8 +890,8 @@ struct dc_softc { * ADMtek device IDs. */ #define DC_DEVICEID_AL981 0x0981 -#define DC_DEVICEID_AN985 0x0985 -#define DC_DEVICEID_FA511 0x1985 +#define DC_DEVICEID_AN983 0x0985 +#define DC_DEVICEID_AN985 0x1985 #define DC_DEVICEID_ADM9511 0x9511 #define DC_DEVICEID_ADM9513 0x9513 From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:12:06 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5A26106566C; Tue, 2 Nov 2010 22:12:06 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2D898FC1C; Tue, 2 Nov 2010 22:12:06 +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 oA2MC67S092452; Tue, 2 Nov 2010 22:12:06 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MC6tR092450; Tue, 2 Nov 2010 22:12:06 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201011022212.oA2MC6tR092450@svn.freebsd.org> From: Marius Strobl Date: Tue, 2 Nov 2010 22:12:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214690 - stable/8/sys/boot/sparc64/loader X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:12:06 -0000 Author: marius Date: Tue Nov 2 22:12:06 2010 New Revision: 214690 URL: http://svn.freebsd.org/changeset/base/214690 Log: MFC: r214526 Partially revert r203829 (MFC'ed to stable/7 in r205920); as it turns out what the PowerPC OFW loader did was incorrect as further down the road cons_probe() calls malloc() so the former can't be called before init_heap() has succeed. Instead just exit to the firmware in case init_heap() fails like OF_init() does when hitting a problem as we're then likely running in a very broken environment where hardly anything can be trusted to work. Modified: stable/8/sys/boot/sparc64/loader/main.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/8/sys/boot/sparc64/loader/main.c Tue Nov 2 22:06:23 2010 (r214689) +++ stable/8/sys/boot/sparc64/loader/main.c Tue Nov 2 22:12:06 2010 (r214690) @@ -811,15 +811,15 @@ main(int (*openfirm)(void *)) archsw.arch_autoload = sparc64_autoload; archsw.arch_maphint = sparc64_maphint; + if (init_heap() == (vm_offset_t)-1) + OF_exit(); + setheap((void *)heapva, (void *)(heapva + HEAPSZ)); + /* * Probe for a console. */ cons_probe(); - if (init_heap() == (vm_offset_t)-1) - panic("%s: can't claim heap", __func__); - setheap((void *)heapva, (void *)(heapva + HEAPSZ)); - if ((root = OF_peer(0)) == -1) panic("%s: can't get root phandle", __func__); OF_getprop(root, "compatible", compatible, sizeof(compatible)); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:30:19 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0B8210656C0; Tue, 2 Nov 2010 22:30:19 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9DC638FC2F; Tue, 2 Nov 2010 22:30:19 +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 oA2MUJab093506; Tue, 2 Nov 2010 22:30:19 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MUJnc093504; Tue, 2 Nov 2010 22:30:19 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201011022230.oA2MUJnc093504@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 2 Nov 2010 22:30:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214693 - stable/8/sys/nfsserver X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:30:19 -0000 Author: pjd Date: Tue Nov 2 22:30:19 2010 New Revision: 214693 URL: http://svn.freebsd.org/changeset/base/214693 Log: MFC r211854: - When VFS_VGET() is not supported, switch to VOP_LOOKUP(). - We are fine by only share-locking the vnode. - Remove assertion that doesn't hold for ZFS where we cross mount points boundaries by going into .zfs/snapshot//. Reviewed by: rmacklem Reminded by: kib Modified: stable/8/sys/nfsserver/nfs_serv.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/nfsserver/nfs_serv.c ============================================================================== --- stable/8/sys/nfsserver/nfs_serv.c Tue Nov 2 22:13:08 2010 (r214692) +++ stable/8/sys/nfsserver/nfs_serv.c Tue Nov 2 22:30:19 2010 (r214693) @@ -3041,7 +3041,8 @@ nfsrv_readdirplus(struct nfsrv_descript u_quad_t off, toff, verf; u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */ int v3 = (nfsd->nd_flag & ND_NFSV3); - int vfslocked; + int usevget = 1, vfslocked; + struct componentname cn; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); vfslocked = 0; @@ -3186,28 +3187,6 @@ again: goto again; } - /* - * Probe one of the directory entries to see if the filesystem - * supports VGET. - */ - error = VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp); - if (error) { - if (error == EOPNOTSUPP) - error = NFSERR_NOTSUPP; - else - error = NFSERR_SERVERFAULT; - vrele(vp); - vp = NULL; - free((caddr_t)cookies, M_TEMP); - free((caddr_t)rbuf, M_TEMP); - nfsm_reply(NFSX_V3POSTOPATTR); - nfsm_srvpostop_attr(getret, &at); - error = 0; - goto nfsmout; - } - vput(nvp); - nvp = NULL; - dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); @@ -3224,23 +3203,49 @@ again: nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; - /* - * For readdir_and_lookup get the vnode using - * the file number. - */ - if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, - &nvp)) - goto invalid; + if (usevget) { + /* + * For readdir_and_lookup get the vnode using + * the file number. + */ + error = VFS_VGET(vp->v_mount, dp->d_fileno, + LK_SHARED, &nvp); + if (error != 0 && error != EOPNOTSUPP) { + error = 0; + goto invalid; + } else if (error == EOPNOTSUPP) { + /* + * VFS_VGET() not supported? + * Let's switch to VOP_LOOKUP(). + */ + error = 0; + usevget = 0; + cn.cn_nameiop = LOOKUP; + cn.cn_flags = ISLASTCN | NOFOLLOW | \ + LOCKSHARED | LOCKLEAF | MPSAFE; + cn.cn_lkflags = LK_SHARED | LK_RETRY; + cn.cn_cred = cred; + cn.cn_thread = curthread; + } + } + if (!usevget) { + cn.cn_nameptr = dp->d_name; + cn.cn_namelen = dp->d_namlen; + if (dp->d_namlen == 2 && + dp->d_name[0] == '.' && + dp->d_name[1] == '.') { + cn.cn_flags |= ISDOTDOT; + } else { + cn.cn_flags &= ~ISDOTDOT; + } + if (!VOP_ISLOCKED(vp)) + vn_lock(vp, LK_SHARED | LK_RETRY); + if (VOP_LOOKUP(vp, &nvp, &cn) != 0) + goto invalid; + } + bzero((caddr_t)nfhp, NFSX_V3FH); - nfhp->fh_fsid = - nvp->v_mount->mnt_stat.f_fsid; - /* - * XXXRW: Assert the mountpoints are the same so that - * we know that acquiring Giant based on the - * directory is the right thing for the child. - */ - KASSERT(nvp->v_mount == vp->v_mount, - ("nfsrv_readdirplus: nvp mount != vp mount")); + nfhp->fh_fsid = nvp->v_mount->mnt_stat.f_fsid; if (VOP_VPTOFH(nvp, &nfhp->fh_fid)) { vput(nvp); nvp = NULL; @@ -3336,7 +3341,10 @@ invalid: cookiep++; ncookies--; } - vrele(vp); + if (!usevget && VOP_ISLOCKED(vp)) + vput(vp); + else + vrele(vp); vp = NULL; nfsm_clget; *tl = nfsrv_nfs_false; From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:44:51 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0061106567A; Tue, 2 Nov 2010 22:44:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BCF218FC14; Tue, 2 Nov 2010 22:44:51 +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 oA2Mip0D094340; Tue, 2 Nov 2010 22:44:51 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MipSg094337; Tue, 2 Nov 2010 22:44:51 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022244.oA2MipSg094337@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 22:44:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214694 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:44:51 -0000 Author: yongari Date: Tue Nov 2 22:44:51 2010 New Revision: 214694 URL: http://svn.freebsd.org/changeset/base/214694 Log: MFC r213081,213225,213280: r213081: Always show asic/chip revision in device attach phase. There are too many bge(4) controllers there and model name does not necessarily match asic/chip revision. Relying on VPD string made it hard to identify exact asic/chip revision so the first step to debug bge(4) was getting exact asic/chip information with verbose boot which may not be available on production server. r213255: Set the number of RX frames to receive after RX MBUF low watermark has reached. This reduced number of dropped frames when flow-control is enabled. Previously it dropped incoming frames once RX MBUF low watermark has reached. The value used in MAC RX MBUF low watermark is greater than or equal to 4 so receiving two more RX frames should not be a problem. Obtained from: OpenBSD r213280: After r207391, brgphy(4) passes resolved flow-control settings to parent driver. Use that information to configure flow-control. One drawback is there is no way to disable flow-control as we still don't have proper way to not advertise RX/TX pause capability to link partner. But I don't think it would cause severe problems and users can selectively disable flow-control in switch port. Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 22:30:19 2010 (r214693) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 22:44:51 2010 (r214694) @@ -882,10 +882,21 @@ bge_miibus_statchg(device_t dev) else BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_MII); - if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) + if (IFM_OPTIONS(mii->mii_media_active & IFM_FDX) != 0) { BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); - else + if (IFM_OPTIONS(mii->mii_media_active) & IFM_FLAG1) + BGE_SETBIT(sc, BGE_TX_MODE, BGE_TXMODE_FLOWCTL_ENABLE); + else + BGE_CLRBIT(sc, BGE_TX_MODE, BGE_TXMODE_FLOWCTL_ENABLE); + if (IFM_OPTIONS(mii->mii_media_active) & IFM_FLAG0) + BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_FLOWCTL_ENABLE); + else + BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_FLOWCTL_ENABLE); + } else { BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); + BGE_CLRBIT(sc, BGE_TX_MODE, BGE_TXMODE_FLOWCTL_ENABLE); + BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_FLOWCTL_ENABLE); + } } /* @@ -2644,12 +2655,11 @@ bge_attach(device_t dev) goto fail; } - if (bootverbose) - device_printf(dev, - "CHIP ID 0x%08x; ASIC REV 0x%02x; CHIP REV 0x%02x; %s\n", - sc->bge_chipid, sc->bge_asicrev, sc->bge_chiprev, - (sc->bge_flags & BGE_FLAG_PCIX) ? "PCI-X" : - ((sc->bge_flags & BGE_FLAG_PCIE) ? "PCI-E" : "PCI")); + device_printf(dev, + "CHIP ID 0x%08x; ASIC REV 0x%02x; CHIP REV 0x%02x; %s\n", + sc->bge_chipid, sc->bge_asicrev, sc->bge_chiprev, + (sc->bge_flags & BGE_FLAG_PCIX) ? "PCI-X" : + ((sc->bge_flags & BGE_FLAG_PCIE) ? "PCI-E" : "PCI")); BGE_LOCK_INIT(sc, device_get_nameunit(dev)); @@ -4223,6 +4233,14 @@ bge_init_locked(struct bge_softc *sc) /* Turn on receiver. */ BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); + /* + * Set the number of good frames to receive after RX MBUF + * Low Watermark has been reached. After the RX MAC receives + * this number of frames, it will drop subsequent incoming + * frames until the MBUF High Watermark is reached. + */ + CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); + /* Tell firmware we're alive. */ BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP); Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 22:30:19 2010 (r214693) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 22:44:51 2010 (r214694) @@ -632,6 +632,7 @@ #define BGE_RX_BD_RULES_CTL15 0x04F8 #define BGE_RX_BD_RULES_MASKVAL15 0x04FC #define BGE_RX_RULES_CFG 0x0500 +#define BGE_MAX_RX_FRAME_LOWAT 0x0504 #define BGE_SERDES_CFG 0x0590 #define BGE_SERDES_STS 0x0594 #define BGE_SGDIG_CFG 0x05B0 From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:48:19 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B8171065672; Tue, 2 Nov 2010 22:48:19 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 587E58FC21; Tue, 2 Nov 2010 22:48:19 +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 oA2MmIuP094631; Tue, 2 Nov 2010 22:48:18 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MmIet094629; Tue, 2 Nov 2010 22:48:18 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201011022248.oA2MmIet094629@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 2 Nov 2010 22:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214695 - stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:48:19 -0000 Author: pjd Date: Tue Nov 2 22:48:18 2010 New Revision: 214695 URL: http://svn.freebsd.org/changeset/base/214695 Log: MFC r211855: Update comment now that I finally committed r211854. Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Nov 2 22:44:51 2010 (r214694) +++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Tue Nov 2 22:48:18 2010 (r214695) @@ -1555,15 +1555,9 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int fla int err; /* - * XXXPJD: zfs_zget() can't operate on virtual entires like .zfs/ or - * .zfs/snapshot/ directories, so for now just return EOPNOTSUPP. - * This will make NFS to fall back to using READDIR instead of - * READDIRPLUS. - * Also snapshots are stored in AVL tree, but based on their names, - * not inode numbers, so it will be very inefficient to iterate - * over all snapshots to find the right one. - * Note that OpenSolaris READDIRPLUS implementation does LOOKUP on - * d_name, and not VGET on d_fileno as we do. + * zfs_zget() can't operate on virtual entires like .zfs/ or + * .zfs/snapshot/ directories, that's why we return EOPNOTSUPP. + * This will make NFS to switch to LOOKUP instead of using VGET. */ if (ino == ZFSCTL_INO_ROOT || ino == ZFSCTL_INO_SNAPDIR) return (EOPNOTSUPP); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:49:20 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD119106564A; Tue, 2 Nov 2010 22:49:20 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B9B748FC22; Tue, 2 Nov 2010 22:49:20 +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 oA2MnKUU094769; Tue, 2 Nov 2010 22:49:20 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MnKad094760; Tue, 2 Nov 2010 22:49:20 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201011022249.oA2MnKad094760@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 2 Nov 2010 22:49:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214697 - stable/8/sbin/hastd X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:49:20 -0000 Author: pjd Date: Tue Nov 2 22:49:20 2010 New Revision: 214697 URL: http://svn.freebsd.org/changeset/base/214697 Log: MFC r214119,r214273,r214274,r214275,r214276,r214282,r214283,r214284,r214692: r214119: Use closefrom(2) instead of close(2) in a loop. r214273: Load geom_gate.ko module after parsing arguments. r214274: Plug memory leaks. Found with: valgrind r214275: Plug memory leak. r214276: Simplify code a bit. r214282: Move all NV defines into nv.c, they are not used externally thus there is no need to make then visible from outside. r214283: Implement nv_exists() function that returns true if argument of the given name exists. r214284: Before this change on first connect between primary and secondary we initialize all the data. This is huge waste of time and resources if there were no writes yet, as there is no real data to synchronize. Optimize this by sending "virgin" argument to secondary, which gives it a hint that synchronization is not needed. In the common case (where noth nodes are configured at the same time) instead of synchronizing everything, we don't synchronize at all. r214692: Send packets to remote node only via the send thread to avoid possible races - in this case a keepalive packet was send from wrong thread which lead to connection dropping, because of corrupted packet. Fix it by sending keepalive packets directly from the send thread. As a bonus we now send keepalive packets only when connection is idle. Submitted by: Mikolaj Golub Modified: stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hooks.c stable/8/sbin/hastd/nv.c stable/8/sbin/hastd/nv.h stable/8/sbin/hastd/parse.y stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/secondary.c stable/8/sbin/hastd/synch.h Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/hastd.c Tue Nov 2 22:49:20 2010 (r214697) @@ -701,8 +701,6 @@ main(int argc, char *argv[]) int debuglevel; sigset_t mask; - g_gate_load(); - foreground = false; debuglevel = 0; pidfile = HASTD_PIDFILE; @@ -736,6 +734,8 @@ main(int argc, char *argv[]) pjdlog_debug_set(debuglevel); + g_gate_load(); + pfh = pidfile_open(pidfile, 0600, &otherpid); if (pfh == NULL) { if (errno == EEXIST) { Modified: stable/8/sbin/hastd/hooks.c ============================================================================== --- stable/8/sbin/hastd/hooks.c Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/hooks.c Tue Nov 2 22:49:20 2010 (r214697) @@ -88,32 +88,19 @@ static void hook_free(struct hookproc *h static void descriptors(void) { - long maxfd; int fd; /* - * Close all descriptors. + * Close all (or almost all) descriptors. */ - maxfd = sysconf(_SC_OPEN_MAX); - if (maxfd < 0) { - pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed"); - maxfd = 1024; - } - for (fd = 0; fd <= maxfd; fd++) { - switch (fd) { - case STDIN_FILENO: - case STDOUT_FILENO: - case STDERR_FILENO: - if (pjdlog_mode_get() == PJDLOG_MODE_STD) - break; - /* FALLTHROUGH */ - default: - close(fd); - break; - } - } - if (pjdlog_mode_get() == PJDLOG_MODE_STD) + if (pjdlog_mode_get() == PJDLOG_MODE_STD) { + closefrom(MAX(MAX(STDIN_FILENO, STDOUT_FILENO), + STDERR_FILENO) + 1); return; + } + + closefrom(0); + /* * Redirect stdin, stdout and stderr to /dev/null. */ Modified: stable/8/sbin/hastd/nv.c ============================================================================== --- stable/8/sbin/hastd/nv.c Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/nv.c Tue Nov 2 22:49:20 2010 (r214697) @@ -46,6 +46,35 @@ __FBSDID("$FreeBSD$"); #include #include +#define NV_TYPE_NONE 0 + +#define NV_TYPE_INT8 1 +#define NV_TYPE_UINT8 2 +#define NV_TYPE_INT16 3 +#define NV_TYPE_UINT16 4 +#define NV_TYPE_INT32 5 +#define NV_TYPE_UINT32 6 +#define NV_TYPE_INT64 7 +#define NV_TYPE_UINT64 8 +#define NV_TYPE_INT8_ARRAY 9 +#define NV_TYPE_UINT8_ARRAY 10 +#define NV_TYPE_INT16_ARRAY 11 +#define NV_TYPE_UINT16_ARRAY 12 +#define NV_TYPE_INT32_ARRAY 13 +#define NV_TYPE_UINT32_ARRAY 14 +#define NV_TYPE_INT64_ARRAY 15 +#define NV_TYPE_UINT64_ARRAY 16 +#define NV_TYPE_STRING 17 + +#define NV_TYPE_MASK 0x7f +#define NV_TYPE_FIRST NV_TYPE_INT8 +#define NV_TYPE_LAST NV_TYPE_STRING + +#define NV_ORDER_NETWORK 0x00 +#define NV_ORDER_HOST 0x80 + +#define NV_ORDER_MASK 0x80 + #define NV_MAGIC 0xaea1e struct nv { int nv_magic; @@ -534,6 +563,29 @@ nv_get_string(struct nv *nv, const char return (str); } +bool +nv_exists(struct nv *nv, const char *namefmt, ...) +{ + struct nvhdr *nvh; + va_list nameap; + int snverror, serrno; + + if (nv == NULL) + return (false); + + serrno = errno; + snverror = nv->nv_error; + + va_start(nameap, namefmt); + nvh = nv_find(nv, NV_TYPE_NONE, namefmt, nameap); + va_end(nameap); + + errno = serrno; + nv->nv_error = snverror; + + return (nvh != NULL); +} + /* * Dump content of the nv structure. */ @@ -770,7 +822,8 @@ nv_find(struct nv *nv, int type, const c assert(size >= NVH_SIZE(nvh)); nv_swap(nvh, true); if (strcmp(nvh->nvh_name, name) == 0) { - if ((nvh->nvh_type & NV_TYPE_MASK) != type) { + if (type != NV_TYPE_NONE && + (nvh->nvh_type & NV_TYPE_MASK) != type) { errno = EINVAL; if (nv->nv_error == 0) nv->nv_error = EINVAL; Modified: stable/8/sbin/hastd/nv.h ============================================================================== --- stable/8/sbin/hastd/nv.h Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/nv.h Tue Nov 2 22:49:20 2010 (r214697) @@ -41,33 +41,6 @@ #include -#define NV_TYPE_INT8 1 -#define NV_TYPE_UINT8 2 -#define NV_TYPE_INT16 3 -#define NV_TYPE_UINT16 4 -#define NV_TYPE_INT32 5 -#define NV_TYPE_UINT32 6 -#define NV_TYPE_INT64 7 -#define NV_TYPE_UINT64 8 -#define NV_TYPE_INT8_ARRAY 9 -#define NV_TYPE_UINT8_ARRAY 10 -#define NV_TYPE_INT16_ARRAY 11 -#define NV_TYPE_UINT16_ARRAY 12 -#define NV_TYPE_INT32_ARRAY 13 -#define NV_TYPE_UINT32_ARRAY 14 -#define NV_TYPE_INT64_ARRAY 15 -#define NV_TYPE_UINT64_ARRAY 16 -#define NV_TYPE_STRING 17 - -#define NV_TYPE_MASK 0x7f -#define NV_TYPE_FIRST NV_TYPE_INT8 -#define NV_TYPE_LAST NV_TYPE_STRING - -#define NV_ORDER_NETWORK 0x00 -#define NV_ORDER_HOST 0x80 - -#define NV_ORDER_MASK 0x80 - struct nv; struct nv *nv_alloc(void); @@ -153,6 +126,7 @@ const uint64_t *nv_get_uint64_array(stru const char *nv_get_string(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); +bool nv_exists(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); void nv_dump(struct nv *nv); #endif /* !_NV_H_ */ Modified: stable/8/sbin/hastd/parse.y ============================================================================== --- stable/8/sbin/hastd/parse.y Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/parse.y Tue Nov 2 22:49:20 2010 (r214697) @@ -264,6 +264,7 @@ control_statement: CONTROL STR sizeof(depth0_control)) >= sizeof(depth0_control)) { pjdlog_error("control argument is too long."); + free($2); return (1); } break; @@ -274,12 +275,14 @@ control_statement: CONTROL STR sizeof(lconfig->hc_controladdr)) >= sizeof(lconfig->hc_controladdr)) { pjdlog_error("control argument is too long."); + free($2); return (1); } break; default: assert(!"control at wrong depth level"); } + free($2); } ; @@ -291,6 +294,7 @@ listen_statement: LISTEN STR sizeof(depth0_listen)) >= sizeof(depth0_listen)) { pjdlog_error("listen argument is too long."); + free($2); return (1); } break; @@ -301,12 +305,14 @@ listen_statement: LISTEN STR sizeof(lconfig->hc_listenaddr)) >= sizeof(lconfig->hc_listenaddr)) { pjdlog_error("listen argument is too long."); + free($2); return (1); } break; default: assert(!"listen at wrong depth level"); } + free($2); } ; @@ -357,6 +363,7 @@ exec_statement: EXEC STR if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >= sizeof(depth0_exec)) { pjdlog_error("Exec path is too long."); + free($2); return (1); } break; @@ -367,12 +374,14 @@ exec_statement: EXEC STR sizeof(curres->hr_exec)) >= sizeof(curres->hr_exec)) { pjdlog_error("Exec path is too long."); + free($2); return (1); } break; default: assert(!"exec at wrong depth level"); } + free($2); } ; @@ -386,6 +395,7 @@ node_start: STR { switch (isitme($1)) { case -1: + free($1); return (1); case 0: break; @@ -395,6 +405,7 @@ node_start: STR default: assert(!"invalid isitme() return value"); } + free($1); } ; @@ -482,14 +493,17 @@ resource_start: STR curres = calloc(1, sizeof(*curres)); if (curres == NULL) { pjdlog_error("Unable to allocate memory for resource."); + free($1); return (1); } if (strlcpy(curres->hr_name, $1, sizeof(curres->hr_name)) >= sizeof(curres->hr_name)) { pjdlog_error("Resource name is too long."); + free($1); return (1); } + free($1); curres->hr_role = HAST_ROLE_INIT; curres->hr_previous_role = HAST_ROLE_INIT; curres->hr_replication = -1; @@ -530,6 +544,7 @@ name_statement: NAME STR sizeof(depth1_provname)) >= sizeof(depth1_provname)) { pjdlog_error("name argument is too long."); + free($2); return (1); } break; @@ -541,12 +556,14 @@ name_statement: NAME STR sizeof(curres->hr_provname)) >= sizeof(curres->hr_provname)) { pjdlog_error("name argument is too long."); + free($2); return (1); } break; default: assert(!"name at wrong depth level"); } + free($2); } ; @@ -558,6 +575,7 @@ local_statement: LOCAL STR sizeof(depth1_localpath)) >= sizeof(depth1_localpath)) { pjdlog_error("local argument is too long."); + free($2); return (1); } break; @@ -569,12 +587,14 @@ local_statement: LOCAL STR sizeof(curres->hr_localpath)) >= sizeof(curres->hr_localpath)) { pjdlog_error("local argument is too long."); + free($2); return (1); } break; default: assert(!"local at wrong depth level"); } + free($2); } ; @@ -589,6 +609,7 @@ resource_node_start: STR if (curres != NULL) { switch (isitme($1)) { case -1: + free($1); return (1); case 0: break; @@ -599,6 +620,7 @@ resource_node_start: STR assert(!"invalid isitme() return value"); } } + free($1); } ; @@ -624,8 +646,10 @@ remote_statement: REMOTE STR sizeof(curres->hr_remoteaddr)) >= sizeof(curres->hr_remoteaddr)) { pjdlog_error("remote argument is too long."); + free($2); return (1); } } + free($2); } ; Modified: stable/8/sbin/hastd/primary.c ============================================================================== --- stable/8/sbin/hastd/primary.c Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/primary.c Tue Nov 2 22:49:20 2010 (r214697) @@ -180,14 +180,21 @@ static pthread_mutex_t metadata_lock; if (_wakeup) \ cv_signal(&hio_##name##_list_cond); \ } while (0) -#define QUEUE_TAKE1(hio, name, ncomp) do { \ +#define QUEUE_TAKE1(hio, name, ncomp, timeout) do { \ + bool _last; \ + \ mtx_lock(&hio_##name##_list_lock[(ncomp)]); \ - while (((hio) = TAILQ_FIRST(&hio_##name##_list[(ncomp)])) == NULL) { \ - cv_wait(&hio_##name##_list_cond[(ncomp)], \ - &hio_##name##_list_lock[(ncomp)]); \ + _last = false; \ + while (((hio) = TAILQ_FIRST(&hio_##name##_list[(ncomp)])) == NULL && !_last) { \ + cv_timedwait(&hio_##name##_list_cond[(ncomp)], \ + &hio_##name##_list_lock[(ncomp)], (timeout)); \ + if ((timeout) != 0) \ + _last = true; \ + } \ + if (hio != NULL) { \ + TAILQ_REMOVE(&hio_##name##_list[(ncomp)], (hio), \ + hio_next[(ncomp)]); \ } \ - TAILQ_REMOVE(&hio_##name##_list[(ncomp)], (hio), \ - hio_next[(ncomp)]); \ mtx_unlock(&hio_##name##_list_lock[(ncomp)]); \ } while (0) #define QUEUE_TAKE2(hio, name) do { \ @@ -417,6 +424,24 @@ init_environment(struct hast_resource *r } } +static bool +init_resuid(struct hast_resource *res) +{ + + mtx_lock(&metadata_lock); + if (res->hr_resuid != 0) { + mtx_unlock(&metadata_lock); + return (false); + } else { + /* Initialize unique resource identifier. */ + arc4random_buf(&res->hr_resuid, sizeof(res->hr_resuid)); + mtx_unlock(&metadata_lock); + if (metadata_write(res) < 0) + exit(EX_NOINPUT); + return (true); + } +} + static void init_local(struct hast_resource *res) { @@ -452,10 +477,12 @@ init_local(struct hast_resource *res) if (res->hr_resuid != 0) return; /* - * We're using provider for the first time, so we have to generate - * resource unique identifier and initialize local and remote counts. + * We're using provider for the first time. Initialize local and remote + * counters. We don't initialize resuid here, as we want to do it just + * in time. The reason for this is that we want to inform secondary + * that there were no writes yet, so there is no need to synchronize + * anything. */ - arc4random_buf(&res->hr_resuid, sizeof(res->hr_resuid)); res->hr_primary_localcnt = 1; res->hr_primary_remotecnt = 0; if (metadata_write(res) < 0) @@ -566,6 +593,19 @@ init_remote(struct hast_resource *res, s nv_add_string(nvout, res->hr_name, "resource"); nv_add_uint8_array(nvout, res->hr_token, sizeof(res->hr_token), "token"); + if (res->hr_resuid == 0) { + /* + * The resuid field was not yet initialized. + * Because we do synchronization inside init_resuid(), it is + * possible that someone already initialized it, the function + * will return false then, but if we successfully initialized + * it, we will get true. True means that there were no writes + * to this resource yet and we want to inform secondary that + * synchronization is not needed by sending "virgin" argument. + */ + if (init_resuid(res)) + nv_add_int8(nvout, 1, "virgin"); + } nv_add_uint64(nvout, res->hr_resuid, "resuid"); nv_add_uint64(nvout, res->hr_primary_localcnt, "localcnt"); nv_add_uint64(nvout, res->hr_primary_remotecnt, "remotecnt"); @@ -646,6 +686,7 @@ init_remote(struct hast_resource *res, s */ (void)hast_activemap_flush(res); } + nv_free(nvin); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; @@ -1005,6 +1046,10 @@ ggate_recv_thread(void *arg) QUEUE_INSERT1(hio, send, ncomp); break; case BIO_WRITE: + if (res->hr_resuid == 0) { + /* This is first write, initialize resuid. */ + (void)init_resuid(res); + } for (;;) { mtx_lock(&range_lock); if (rangelock_islocked(range_sync, @@ -1074,7 +1119,7 @@ local_send_thread(void *arg) for (;;) { pjdlog_debug(2, "local_send: Taking request."); - QUEUE_TAKE1(hio, send, ncomp); + QUEUE_TAKE1(hio, send, ncomp, 0); pjdlog_debug(2, "local_send: (%p) Got request.", hio); ggio = &hio->hio_ggio; switch (ggio->gctl_cmd) { @@ -1138,6 +1183,38 @@ local_send_thread(void *arg) return (NULL); } +static void +keepalive_send(struct hast_resource *res, unsigned int ncomp) +{ + struct nv *nv; + + if (!ISCONNECTED(res, ncomp)) + return; + + assert(res->hr_remotein != NULL); + assert(res->hr_remoteout != NULL); + + nv = nv_alloc(); + nv_add_uint8(nv, HIO_KEEPALIVE, "cmd"); + if (nv_error(nv) != 0) { + nv_free(nv); + pjdlog_debug(1, + "keepalive_send: Unable to prepare header to send."); + return; + } + if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) { + pjdlog_common(LOG_DEBUG, 1, errno, + "keepalive_send: Unable to send request"); + nv_free(nv); + rw_unlock(&hio_remote_lock[ncomp]); + remote_close(res, ncomp); + rw_rlock(&hio_remote_lock[ncomp]); + return; + } + nv_free(nv); + pjdlog_debug(2, "keepalive_send: Request sent."); +} + /* * Thread sends request to secondary node. */ @@ -1146,6 +1223,7 @@ remote_send_thread(void *arg) { struct hast_resource *res = arg; struct g_gate_ctl_io *ggio; + time_t lastcheck, now; struct hio *hio; struct nv *nv; unsigned int ncomp; @@ -1156,10 +1234,19 @@ remote_send_thread(void *arg) /* Remote component is 1 for now. */ ncomp = 1; + lastcheck = time(NULL); for (;;) { pjdlog_debug(2, "remote_send: Taking request."); - QUEUE_TAKE1(hio, send, ncomp); + QUEUE_TAKE1(hio, send, ncomp, RETRY_SLEEP); + if (hio == NULL) { + now = time(NULL); + if (lastcheck + RETRY_SLEEP <= now) { + keepalive_send(res, ncomp); + lastcheck = now; + } + continue; + } pjdlog_debug(2, "remote_send: (%p) Got request.", hio); ggio = &hio->hio_ggio; switch (ggio->gctl_cmd) { @@ -1845,32 +1932,6 @@ failed: } static void -keepalive_send(struct hast_resource *res, unsigned int ncomp) -{ - struct nv *nv; - - nv = nv_alloc(); - nv_add_uint8(nv, HIO_KEEPALIVE, "cmd"); - if (nv_error(nv) != 0) { - nv_free(nv); - pjdlog_debug(1, - "keepalive_send: Unable to prepare header to send."); - return; - } - if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) { - pjdlog_common(LOG_DEBUG, 1, errno, - "keepalive_send: Unable to send request"); - nv_free(nv); - rw_unlock(&hio_remote_lock[ncomp]); - remote_close(res, ncomp); - rw_rlock(&hio_remote_lock[ncomp]); - return; - } - nv_free(nv); - pjdlog_debug(2, "keepalive_send: Request sent."); -} - -static void guard_one(struct hast_resource *res, unsigned int ncomp) { struct proto_conn *in, *out; @@ -1888,12 +1949,6 @@ guard_one(struct hast_resource *res, uns if (ISCONNECTED(res, ncomp)) { assert(res->hr_remotein != NULL); assert(res->hr_remoteout != NULL); - keepalive_send(res, ncomp); - } - - if (ISCONNECTED(res, ncomp)) { - assert(res->hr_remotein != NULL); - assert(res->hr_remoteout != NULL); rw_unlock(&hio_remote_lock[ncomp]); pjdlog_debug(2, "remote_guard: Connection to %s is ok.", res->hr_remoteaddr); Modified: stable/8/sbin/hastd/secondary.c ============================================================================== --- stable/8/sbin/hastd/secondary.c Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/secondary.c Tue Nov 2 22:49:20 2010 (r214697) @@ -243,13 +243,22 @@ init_remote(struct hast_resource *res, s */ if (res->hr_resuid == 0) { /* - * Provider is used for the first time. Initialize everything. + * Provider is used for the first time. If primary node done no + * writes yet as well (we will find "virgin" argument) then + * there is no need to synchronize anything. If primary node + * done any writes already we have to synchronize everything. */ assert(res->hr_secondary_localcnt == 0); res->hr_resuid = resuid; if (metadata_write(res) < 0) exit(EX_NOINPUT); - memset(map, 0xff, mapsize); + if (nv_exists(nvin, "virgin")) { + free(map); + map = NULL; + mapsize = 0; + } else { + memset(map, 0xff, mapsize); + } nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); } else if ( /* Is primary is out-of-date? */ @@ -318,11 +327,11 @@ init_remote(struct hast_resource *res, s (uintmax_t)res->hr_secondary_remotecnt); } if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) { - pjdlog_errno(LOG_WARNING, "Unable to send activemap to %s", + pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s", res->hr_remoteaddr); - nv_free(nvout); - exit(EX_TEMPFAIL); } + if (map != NULL) + free(map); nv_free(nvout); if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { Modified: stable/8/sbin/hastd/synch.h ============================================================================== --- stable/8/sbin/hastd/synch.h Tue Nov 2 22:48:52 2010 (r214696) +++ stable/8/sbin/hastd/synch.h Tue Nov 2 22:49:20 2010 (r214697) @@ -140,6 +140,8 @@ cv_init(pthread_cond_t *cv) assert(error == 0); error = pthread_cond_init(cv, &attr); assert(error == 0); + error = pthread_condattr_destroy(&attr); + assert(error == 0); } static __inline void cv_wait(pthread_cond_t *cv, pthread_mutex_t *lock) From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 22:57:20 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79A781065670; Tue, 2 Nov 2010 22:57:20 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 657CC8FC0C; Tue, 2 Nov 2010 22:57:20 +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 oA2MvKbr095422; Tue, 2 Nov 2010 22:57:20 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2MvKg9095419; Tue, 2 Nov 2010 22:57:20 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022257.oA2MvKg9095419@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 22:57:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214698 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:57:20 -0000 Author: yongari Date: Tue Nov 2 22:57:20 2010 New Revision: 214698 URL: http://svn.freebsd.org/changeset/base/214698 Log: MFC r213283,213410: r213283: Implement hardware MAC statistics for BCM5705 or newer Broadcom controllers. bge(4) exported MAC statistics on controllers that maintain the statistics in the NIC's internal memory. Newer controllers require register access to fetch these values. These counters provide useful information to diagnose driver issues. r213410: Consistently use ifHCOutOctets/ifHCInOctets instead of Octets as these names are used in data sheet. Also use UnicastPkts, MulticastPkts and BroadcastPkts instead of UcastPkts, McastPkts and BcastPkts to clarify its meaning. Suggested by: bde Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 22:49:20 2010 (r214697) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 22:57:20 2010 (r214698) @@ -371,6 +371,7 @@ static int bge_rxeof(struct bge_softc *, static void bge_asf_driver_up (struct bge_softc *); static void bge_tick(void *); +static void bge_stats_clear_regs(struct bge_softc *); static void bge_stats_update(struct bge_softc *); static void bge_stats_update_regs(struct bge_softc *); static struct mbuf *bge_setup_tso(struct bge_softc *, struct mbuf *, @@ -453,6 +454,10 @@ static int bge_sysctl_reg_read(SYSCTL_HA static int bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS); #endif static void bge_add_sysctls(struct bge_softc *); +static void bge_add_sysctl_stats_regs(struct bge_softc *, + struct sysctl_ctx_list *, struct sysctl_oid_list *); +static void bge_add_sysctl_stats(struct bge_softc *, struct sysctl_ctx_list *, + struct sysctl_oid_list *); static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS); static device_method_t bge_methods[] = { @@ -3730,15 +3735,127 @@ static void bge_stats_update_regs(struct bge_softc *sc) { struct ifnet *ifp; + struct bge_mac_stats *stats; ifp = sc->bge_ifp; + stats = &sc->bge_mac_stats; - ifp->if_collisions += CSR_READ_4(sc, BGE_MAC_STATS + - offsetof(struct bge_mac_stats_regs, etherStatsCollisions)); + stats->ifHCOutOctets += + CSR_READ_4(sc, BGE_TX_MAC_STATS_OCTETS); + stats->etherStatsCollisions += + CSR_READ_4(sc, BGE_TX_MAC_STATS_COLLS); + stats->outXonSent += + CSR_READ_4(sc, BGE_TX_MAC_STATS_XON_SENT); + stats->outXoffSent += + CSR_READ_4(sc, BGE_TX_MAC_STATS_XOFF_SENT); + stats->dot3StatsInternalMacTransmitErrors += + CSR_READ_4(sc, BGE_TX_MAC_STATS_ERRORS); + stats->dot3StatsSingleCollisionFrames += + CSR_READ_4(sc, BGE_TX_MAC_STATS_SINGLE_COLL); + stats->dot3StatsMultipleCollisionFrames += + CSR_READ_4(sc, BGE_TX_MAC_STATS_MULTI_COLL); + stats->dot3StatsDeferredTransmissions += + CSR_READ_4(sc, BGE_TX_MAC_STATS_DEFERRED); + stats->dot3StatsExcessiveCollisions += + CSR_READ_4(sc, BGE_TX_MAC_STATS_EXCESS_COLL); + stats->dot3StatsLateCollisions += + CSR_READ_4(sc, BGE_TX_MAC_STATS_LATE_COLL); + stats->ifHCOutUcastPkts += + CSR_READ_4(sc, BGE_TX_MAC_STATS_UCAST); + stats->ifHCOutMulticastPkts += + CSR_READ_4(sc, BGE_TX_MAC_STATS_MCAST); + stats->ifHCOutBroadcastPkts += + CSR_READ_4(sc, BGE_TX_MAC_STATS_BCAST); + + stats->ifHCInOctets += + CSR_READ_4(sc, BGE_RX_MAC_STATS_OCTESTS); + stats->etherStatsFragments += + CSR_READ_4(sc, BGE_RX_MAC_STATS_FRAGMENTS); + stats->ifHCInUcastPkts += + CSR_READ_4(sc, BGE_RX_MAC_STATS_UCAST); + stats->ifHCInMulticastPkts += + CSR_READ_4(sc, BGE_RX_MAC_STATS_MCAST); + stats->ifHCInBroadcastPkts += + CSR_READ_4(sc, BGE_RX_MAC_STATS_BCAST); + stats->dot3StatsFCSErrors += + CSR_READ_4(sc, BGE_RX_MAC_STATS_FCS_ERRORS); + stats->dot3StatsAlignmentErrors += + CSR_READ_4(sc, BGE_RX_MAC_STATS_ALGIN_ERRORS); + stats->xonPauseFramesReceived += + CSR_READ_4(sc, BGE_RX_MAC_STATS_XON_RCVD); + stats->xoffPauseFramesReceived += + CSR_READ_4(sc, BGE_RX_MAC_STATS_XOFF_RCVD); + stats->macControlFramesReceived += + CSR_READ_4(sc, BGE_RX_MAC_STATS_CTRL_RCVD); + stats->xoffStateEntered += + CSR_READ_4(sc, BGE_RX_MAC_STATS_XOFF_ENTERED); + stats->dot3StatsFramesTooLong += + CSR_READ_4(sc, BGE_RX_MAC_STATS_FRAME_TOO_LONG); + stats->etherStatsJabbers += + CSR_READ_4(sc, BGE_RX_MAC_STATS_JABBERS); + stats->etherStatsUndersizePkts += + CSR_READ_4(sc, BGE_RX_MAC_STATS_UNDERSIZE); + + stats->FramesDroppedDueToFilters += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_FILTDROP); + stats->DmaWriteQueueFull += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_DMA_WRQ_FULL); + stats->DmaWriteHighPriQueueFull += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_DMA_HPWRQ_FULL); + stats->NoMoreRxBDs += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS); + stats->InputDiscards += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); + stats->InputErrors += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS); + stats->RecvThresholdHit += + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_RXTHRESH_HIT); + + ifp->if_collisions = (u_long)stats->etherStatsCollisions; + ifp->if_ierrors = (u_long)(stats->NoMoreRxBDs + stats->InputDiscards + + stats->InputErrors); +} + +static void +bge_stats_clear_regs(struct bge_softc *sc) +{ - ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS); - ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); - ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS); + CSR_READ_4(sc, BGE_TX_MAC_STATS_OCTETS); + CSR_READ_4(sc, BGE_TX_MAC_STATS_COLLS); + CSR_READ_4(sc, BGE_TX_MAC_STATS_XON_SENT); + CSR_READ_4(sc, BGE_TX_MAC_STATS_XOFF_SENT); + CSR_READ_4(sc, BGE_TX_MAC_STATS_ERRORS); + CSR_READ_4(sc, BGE_TX_MAC_STATS_SINGLE_COLL); + CSR_READ_4(sc, BGE_TX_MAC_STATS_MULTI_COLL); + CSR_READ_4(sc, BGE_TX_MAC_STATS_DEFERRED); + CSR_READ_4(sc, BGE_TX_MAC_STATS_EXCESS_COLL); + CSR_READ_4(sc, BGE_TX_MAC_STATS_LATE_COLL); + CSR_READ_4(sc, BGE_TX_MAC_STATS_UCAST); + CSR_READ_4(sc, BGE_TX_MAC_STATS_MCAST); + CSR_READ_4(sc, BGE_TX_MAC_STATS_BCAST); + + CSR_READ_4(sc, BGE_RX_MAC_STATS_OCTESTS); + CSR_READ_4(sc, BGE_RX_MAC_STATS_FRAGMENTS); + CSR_READ_4(sc, BGE_RX_MAC_STATS_UCAST); + CSR_READ_4(sc, BGE_RX_MAC_STATS_MCAST); + CSR_READ_4(sc, BGE_RX_MAC_STATS_BCAST); + CSR_READ_4(sc, BGE_RX_MAC_STATS_FCS_ERRORS); + CSR_READ_4(sc, BGE_RX_MAC_STATS_ALGIN_ERRORS); + CSR_READ_4(sc, BGE_RX_MAC_STATS_XON_RCVD); + CSR_READ_4(sc, BGE_RX_MAC_STATS_XOFF_RCVD); + CSR_READ_4(sc, BGE_RX_MAC_STATS_CTRL_RCVD); + CSR_READ_4(sc, BGE_RX_MAC_STATS_XOFF_ENTERED); + CSR_READ_4(sc, BGE_RX_MAC_STATS_FRAME_TOO_LONG); + CSR_READ_4(sc, BGE_RX_MAC_STATS_JABBERS); + CSR_READ_4(sc, BGE_RX_MAC_STATS_UNDERSIZE); + + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_FILTDROP); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_DMA_WRQ_FULL); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_DMA_HPWRQ_FULL); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS); + CSR_READ_4(sc, BGE_RXLP_LOCSTAT_RXTHRESH_HIT); } static void @@ -4241,6 +4358,10 @@ bge_init_locked(struct bge_softc *sc) */ CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); + /* Clear MAC statistics. */ + if (BGE_IS_5705_PLUS(sc)) + bge_stats_clear_regs(sc); + /* Tell firmware we're alive. */ BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP); @@ -4642,6 +4763,9 @@ bge_stop(struct bge_softc *sc) BGE_CLRBIT(sc, BGE_BMAN_MODE, BGE_BMANMODE_ENABLE); BGE_CLRBIT(sc, BGE_MARB_MODE, BGE_MARBMODE_ENABLE); } + /* Update MAC statistics. */ + if (BGE_IS_5705_PLUS(sc)) + bge_stats_update_regs(sc); bge_reset(sc); bge_sig_legacy(sc, BGE_RESET_STOP); @@ -4840,17 +4964,11 @@ bge_link_upd(struct bge_softc *sc) BGE_MACSTAT_LINK_CHANGED); } -#define BGE_SYSCTL_STAT(sc, ctx, desc, parent, node, oid) \ - SYSCTL_ADD_PROC(ctx, parent, OID_AUTO, oid, CTLTYPE_UINT|CTLFLAG_RD, \ - sc, offsetof(struct bge_stats, node), bge_sysctl_stats, "IU", \ - desc) - static void bge_add_sysctls(struct bge_softc *sc) { struct sysctl_ctx_list *ctx; - struct sysctl_oid_list *children, *schildren; - struct sysctl_oid *tree; + struct sysctl_oid_list *children; char tn[32]; int unit; @@ -4912,9 +5030,24 @@ bge_add_sysctls(struct bge_softc *sc) "generate UDP checksum value 0"); if (BGE_IS_5705_PLUS(sc)) - return; + bge_add_sysctl_stats_regs(sc, ctx, children); + else + bge_add_sysctl_stats(sc, ctx, children); +} + +#define BGE_SYSCTL_STAT(sc, ctx, desc, parent, node, oid) \ + SYSCTL_ADD_PROC(ctx, parent, OID_AUTO, oid, CTLTYPE_UINT|CTLFLAG_RD, \ + sc, offsetof(struct bge_stats, node), bge_sysctl_stats, "IU", \ + desc) - tree = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "stats", CTLFLAG_RD, +static void +bge_add_sysctl_stats(struct bge_softc *sc, struct sysctl_ctx_list *ctx, + struct sysctl_oid_list *parent) +{ + struct sysctl_oid *tree; + struct sysctl_oid_list *children, *schildren; + + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "stats", CTLFLAG_RD, NULL, "BGE Statistics"); schildren = children = SYSCTL_CHILDREN(tree); BGE_SYSCTL_STAT(sc, ctx, "Frames Dropped Due To Filters", @@ -4953,11 +5086,11 @@ bge_add_sysctls(struct bge_softc *sc) NULL, "BGE RX Statistics"); children = SYSCTL_CHILDREN(tree); BGE_SYSCTL_STAT(sc, ctx, "Inbound Octets", - children, rxstats.ifHCInOctets, "Octets"); + children, rxstats.ifHCInOctets, "ifHCInOctets"); BGE_SYSCTL_STAT(sc, ctx, "Fragments", children, rxstats.etherStatsFragments, "Fragments"); BGE_SYSCTL_STAT(sc, ctx, "Inbound Unicast Packets", - children, rxstats.ifHCInUcastPkts, "UcastPkts"); + children, rxstats.ifHCInUcastPkts, "UnicastPkts"); BGE_SYSCTL_STAT(sc, ctx, "Inbound Multicast Packets", children, rxstats.ifHCInMulticastPkts, "MulticastPkts"); BGE_SYSCTL_STAT(sc, ctx, "FCS Errors", @@ -4989,7 +5122,7 @@ bge_add_sysctls(struct bge_softc *sc) NULL, "BGE TX Statistics"); children = SYSCTL_CHILDREN(tree); BGE_SYSCTL_STAT(sc, ctx, "Outbound Octets", - children, txstats.ifHCOutOctets, "Octets"); + children, txstats.ifHCOutOctets, "ifHCOutOctets"); BGE_SYSCTL_STAT(sc, ctx, "TX Collisions", children, txstats.etherStatsCollisions, "Collisions"); BGE_SYSCTL_STAT(sc, ctx, "XON Sent", @@ -5017,7 +5150,7 @@ bge_add_sysctls(struct bge_softc *sc) children, txstats.dot3StatsLateCollisions, "LateCollisions"); BGE_SYSCTL_STAT(sc, ctx, "Outbound Unicast Packets", - children, txstats.ifHCOutUcastPkts, "UcastPkts"); + children, txstats.ifHCOutUcastPkts, "UnicastPkts"); BGE_SYSCTL_STAT(sc, ctx, "Outbound Multicast Packets", children, txstats.ifHCOutMulticastPkts, "MulticastPkts"); BGE_SYSCTL_STAT(sc, ctx, "Outbound Broadcast Packets", @@ -5031,6 +5164,106 @@ bge_add_sysctls(struct bge_softc *sc) children, txstats.ifOutErrors, "Errors"); } +#undef BGE_SYSCTL_STAT + +#define BGE_SYSCTL_STAT_ADD64(c, h, n, p, d) \ + SYSCTL_ADD_QUAD(c, h, OID_AUTO, n, CTLFLAG_RD, p, d) + +static void +bge_add_sysctl_stats_regs(struct bge_softc *sc, struct sysctl_ctx_list *ctx, + struct sysctl_oid_list *parent) +{ + struct sysctl_oid *tree; + struct sysctl_oid_list *child, *schild; + struct bge_mac_stats *stats; + + stats = &sc->bge_mac_stats; + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "stats", CTLFLAG_RD, + NULL, "BGE Statistics"); + schild = child = SYSCTL_CHILDREN(tree); + BGE_SYSCTL_STAT_ADD64(ctx, child, "FramesDroppedDueToFilters", + &stats->FramesDroppedDueToFilters, "Frames Dropped Due to Filters"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "DmaWriteQueueFull", + &stats->DmaWriteQueueFull, "NIC DMA Write Queue Full"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "DmaWriteHighPriQueueFull", + &stats->DmaWriteHighPriQueueFull, + "NIC DMA Write High Priority Queue Full"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "NoMoreRxBDs", + &stats->NoMoreRxBDs, "NIC No More RX Buffer Descriptors"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "InputDiscards", + &stats->InputDiscards, "Discarded Input Frames"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "InputErrors", + &stats->InputErrors, "Input Errors"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "RecvThresholdHit", + &stats->RecvThresholdHit, "NIC Recv Threshold Hit"); + + tree = SYSCTL_ADD_NODE(ctx, schild, OID_AUTO, "rx", CTLFLAG_RD, + NULL, "BGE RX Statistics"); + child = SYSCTL_CHILDREN(tree); + BGE_SYSCTL_STAT_ADD64(ctx, child, "ifHCInOctets", + &stats->ifHCInOctets, "Inbound Octets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "Fragments", + &stats->etherStatsFragments, "Fragments"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "UnicastPkts", + &stats->ifHCInUcastPkts, "Inbound Unicast Packets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "MulticastPkts", + &stats->ifHCInMulticastPkts, "Inbound Multicast Packets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "BroadcastPkts", + &stats->ifHCInBroadcastPkts, "Inbound Broadcast Packets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "FCSErrors", + &stats->dot3StatsFCSErrors, "FCS Errors"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "AlignmentErrors", + &stats->dot3StatsAlignmentErrors, "Alignment Errors"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "xonPauseFramesReceived", + &stats->xonPauseFramesReceived, "XON Pause Frames Received"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "xoffPauseFramesReceived", + &stats->xoffPauseFramesReceived, "XOFF Pause Frames Received"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "ControlFramesReceived", + &stats->macControlFramesReceived, "MAC Control Frames Received"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "xoffStateEntered", + &stats->xoffStateEntered, "XOFF State Entered"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "FramesTooLong", + &stats->dot3StatsFramesTooLong, "Frames Too Long"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "Jabbers", + &stats->etherStatsJabbers, "Jabbers"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "UndersizePkts", + &stats->etherStatsUndersizePkts, "Undersized Packets"); + + tree = SYSCTL_ADD_NODE(ctx, schild, OID_AUTO, "tx", CTLFLAG_RD, + NULL, "BGE TX Statistics"); + child = SYSCTL_CHILDREN(tree); + BGE_SYSCTL_STAT_ADD64(ctx, child, "ifHCOutOctets", + &stats->ifHCOutOctets, "Outbound Octets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "Collisions", + &stats->etherStatsCollisions, "TX Collisions"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "XonSent", + &stats->outXonSent, "XON Sent"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "XoffSent", + &stats->outXoffSent, "XOFF Sent"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "InternalMacTransmitErrors", + &stats->dot3StatsInternalMacTransmitErrors, + "Internal MAC TX Errors"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "SingleCollisionFrames", + &stats->dot3StatsSingleCollisionFrames, "Single Collision Frames"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "MultipleCollisionFrames", + &stats->dot3StatsMultipleCollisionFrames, + "Multiple Collision Frames"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "DeferredTransmissions", + &stats->dot3StatsDeferredTransmissions, "Deferred Transmissions"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "ExcessiveCollisions", + &stats->dot3StatsExcessiveCollisions, "Excessive Collisions"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "LateCollisions", + &stats->dot3StatsLateCollisions, "Late Collisions"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "UnicastPkts", + &stats->ifHCOutUcastPkts, "Outbound Unicast Packets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "MulticastPkts", + &stats->ifHCOutMulticastPkts, "Outbound Multicast Packets"); + BGE_SYSCTL_STAT_ADD64(ctx, child, "BroadcastPkts", + &stats->ifHCOutBroadcastPkts, "Outbound Broadcast Packets"); +} + +#undef BGE_SYSCTL_STAT_ADD64 + static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS) { Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 22:49:20 2010 (r214697) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 22:57:20 2010 (r214698) @@ -637,7 +637,53 @@ #define BGE_SERDES_STS 0x0594 #define BGE_SGDIG_CFG 0x05B0 #define BGE_SGDIG_STS 0x05B4 -#define BGE_MAC_STATS 0x0800 +#define BGE_TX_MAC_STATS_OCTETS 0x0800 +#define BGE_TX_MAC_STATS_RESERVE_0 0x0804 +#define BGE_TX_MAC_STATS_COLLS 0x0808 +#define BGE_TX_MAC_STATS_XON_SENT 0x080C +#define BGE_TX_MAC_STATS_XOFF_SENT 0x0810 +#define BGE_TX_MAC_STATS_RESERVE_1 0x0814 +#define BGE_TX_MAC_STATS_ERRORS 0x0818 +#define BGE_TX_MAC_STATS_SINGLE_COLL 0x081C +#define BGE_TX_MAC_STATS_MULTI_COLL 0x0820 +#define BGE_TX_MAC_STATS_DEFERRED 0x0824 +#define BGE_TX_MAC_STATS_RESERVE_2 0x0828 +#define BGE_TX_MAC_STATS_EXCESS_COLL 0x082C +#define BGE_TX_MAC_STATS_LATE_COLL 0x0830 +#define BGE_TX_MAC_STATS_RESERVE_3 0x0834 +#define BGE_TX_MAC_STATS_RESERVE_4 0x0838 +#define BGE_TX_MAC_STATS_RESERVE_5 0x083C +#define BGE_TX_MAC_STATS_RESERVE_6 0x0840 +#define BGE_TX_MAC_STATS_RESERVE_7 0x0844 +#define BGE_TX_MAC_STATS_RESERVE_8 0x0848 +#define BGE_TX_MAC_STATS_RESERVE_9 0x084C +#define BGE_TX_MAC_STATS_RESERVE_10 0x0850 +#define BGE_TX_MAC_STATS_RESERVE_11 0x0854 +#define BGE_TX_MAC_STATS_RESERVE_12 0x0858 +#define BGE_TX_MAC_STATS_RESERVE_13 0x085C +#define BGE_TX_MAC_STATS_RESERVE_14 0x0860 +#define BGE_TX_MAC_STATS_RESERVE_15 0x0864 +#define BGE_TX_MAC_STATS_RESERVE_16 0x0868 +#define BGE_TX_MAC_STATS_UCAST 0x086C +#define BGE_TX_MAC_STATS_MCAST 0x0870 +#define BGE_TX_MAC_STATS_BCAST 0x0874 +#define BGE_TX_MAC_STATS_RESERVE_17 0x0878 +#define BGE_TX_MAC_STATS_RESERVE_18 0x087C +#define BGE_RX_MAC_STATS_OCTESTS 0x0880 +#define BGE_RX_MAC_STATS_RESERVE_0 0x0884 +#define BGE_RX_MAC_STATS_FRAGMENTS 0x0888 +#define BGE_RX_MAC_STATS_UCAST 0x088C +#define BGE_RX_MAC_STATS_MCAST 0x0890 +#define BGE_RX_MAC_STATS_BCAST 0x0894 +#define BGE_RX_MAC_STATS_FCS_ERRORS 0x0898 +#define BGE_RX_MAC_STATS_ALGIN_ERRORS 0x089C +#define BGE_RX_MAC_STATS_XON_RCVD 0x08A0 +#define BGE_RX_MAC_STATS_XOFF_RCVD 0x08A4 +#define BGE_RX_MAC_STATS_CTRL_RCVD 0x08A8 +#define BGE_RX_MAC_STATS_XOFF_ENTERED 0x08AC +#define BGE_RX_MAC_STATS_FRAME_TOO_LONG 0x08B0 +#define BGE_RX_MAC_STATS_JABBERS 0x08B4 +#define BGE_RX_MAC_STATS_UNDERSIZE 0x08B8 /* Ethernet MAC Mode register */ #define BGE_MACMODE_RESET 0x00000001 @@ -2349,40 +2395,50 @@ struct bge_tx_mac_stats { }; /* Stats counters access through registers */ -struct bge_mac_stats_regs { - uint32_t ifHCOutOctets; - uint32_t Reserved0; - uint32_t etherStatsCollisions; - uint32_t outXonSent; - uint32_t outXoffSent; - uint32_t Reserved1; - uint32_t dot3StatsInternalMacTransmitErrors; - uint32_t dot3StatsSingleCollisionFrames; - uint32_t dot3StatsMultipleCollisionFrames; - uint32_t dot3StatsDeferredTransmissions; - uint32_t Reserved2; - uint32_t dot3StatsExcessiveCollisions; - uint32_t dot3StatsLateCollisions; - uint32_t Reserved3[14]; - uint32_t ifHCOutUcastPkts; - uint32_t ifHCOutMulticastPkts; - uint32_t ifHCOutBroadcastPkts; - uint32_t Reserved4[2]; - uint32_t ifHCInOctets; - uint32_t Reserved5; - uint32_t etherStatsFragments; - uint32_t ifHCInUcastPkts; - uint32_t ifHCInMulticastPkts; - uint32_t ifHCInBroadcastPkts; - uint32_t dot3StatsFCSErrors; - uint32_t dot3StatsAlignmentErrors; - uint32_t xonPauseFramesReceived; - uint32_t xoffPauseFramesReceived; - uint32_t macControlFramesReceived; - uint32_t xoffStateEntered; - uint32_t dot3StatsFramesTooLong; - uint32_t etherStatsJabbers; - uint32_t etherStatsUndersizePkts; +struct bge_mac_stats { + /* TX MAC statistics */ + uint64_t ifHCOutOctets; + uint64_t Reserved0; + uint64_t etherStatsCollisions; + uint64_t outXonSent; + uint64_t outXoffSent; + uint64_t Reserved1; + uint64_t dot3StatsInternalMacTransmitErrors; + uint64_t dot3StatsSingleCollisionFrames; + uint64_t dot3StatsMultipleCollisionFrames; + uint64_t dot3StatsDeferredTransmissions; + uint64_t Reserved2; + uint64_t dot3StatsExcessiveCollisions; + uint64_t dot3StatsLateCollisions; + uint64_t Reserved3[14]; + uint64_t ifHCOutUcastPkts; + uint64_t ifHCOutMulticastPkts; + uint64_t ifHCOutBroadcastPkts; + uint64_t Reserved4[2]; + /* RX MAC statistics */ + uint64_t ifHCInOctets; + uint64_t Reserved5; + uint64_t etherStatsFragments; + uint64_t ifHCInUcastPkts; + uint64_t ifHCInMulticastPkts; + uint64_t ifHCInBroadcastPkts; + uint64_t dot3StatsFCSErrors; + uint64_t dot3StatsAlignmentErrors; + uint64_t xonPauseFramesReceived; + uint64_t xoffPauseFramesReceived; + uint64_t macControlFramesReceived; + uint64_t xoffStateEntered; + uint64_t dot3StatsFramesTooLong; + uint64_t etherStatsJabbers; + uint64_t etherStatsUndersizePkts; + /* Receive List Placement control */ + uint64_t FramesDroppedDueToFilters; + uint64_t DmaWriteQueueFull; + uint64_t DmaWriteHighPriQueueFull; + uint64_t NoMoreRxBDs; + uint64_t InputDiscards; + uint64_t InputErrors; + uint64_t RecvThresholdHit; }; struct bge_stats { @@ -2660,6 +2716,7 @@ struct bge_softc { #ifdef DEVICE_POLLING int rxcycles; #endif /* DEVICE_POLLING */ + struct bge_mac_stats bge_mac_stats; struct task bge_intr_task; struct taskqueue *bge_tq; }; From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:04:24 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51522106566B; Tue, 2 Nov 2010 23:04:24 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3EB5E8FC0C; Tue, 2 Nov 2010 23:04:24 +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 oA2N4OWb096209; Tue, 2 Nov 2010 23:04:24 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2N4Oef096206; Tue, 2 Nov 2010 23:04:24 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022304.oA2N4Oef096206@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:04:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214700 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:04:24 -0000 Author: yongari Date: Tue Nov 2 23:04:23 2010 New Revision: 214700 URL: http://svn.freebsd.org/changeset/base/214700 Log: MFC r213316,213333-213334: r213316: Fix IFCAP_TXCSUM/IFCAP_RXCSUM handling. Previously bge(4) used IFCAP_HWCSUM to know which capability should be changed such that disabling RX checksun offloading resulted in disabling TX checksum offloading. r213333: Allow write DMA to request larger DMA burst size to get better performance on BCM5785. Obtained from: OpenBSD r213334: Remove extra semicolon. Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 22:59:45 2010 (r214699) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:04:23 2010 (r214700) @@ -1052,7 +1052,7 @@ bge_init_rx_ring_std(struct bge_softc *s if ((error = bge_newbuf_std(sc, i)) != 0) return (error); BGE_INC(sc->bge_std, BGE_STD_RX_RING_CNT); - }; + } bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag, sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_PREWRITE); @@ -1095,7 +1095,7 @@ bge_init_rx_ring_jumbo(struct bge_softc if ((error = bge_newbuf_jumbo(sc, i)) != 0) return (error); BGE_INC(sc->bge_jumbo, BGE_JUMBO_RX_RING_CNT); - }; + } bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag, sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_PREWRITE); @@ -1834,6 +1834,10 @@ bge_blockinit(struct bge_softc *sc) if (BGE_IS_5755_PLUS(sc)) val |= BGE_WDMAMODE_STATUS_TAG_FIX; + /* Request larger DMA burst size to get better performance. */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5785) + val |= BGE_WDMAMODE_BURST_ALL_DATA; + /* Turn on write DMA state machine */ CSR_WRITE_4(sc, BGE_WDMA_MODE, val); DELAY(40); @@ -4632,15 +4636,19 @@ bge_ioctl(struct ifnet *ifp, u_long comm } } #endif - if (mask & IFCAP_HWCSUM) { - ifp->if_capenable ^= IFCAP_HWCSUM; - if (IFCAP_HWCSUM & ifp->if_capenable && - IFCAP_HWCSUM & ifp->if_capabilities) + if ((mask & IFCAP_TXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_TXCSUM) != 0) { + ifp->if_capenable ^= IFCAP_TXCSUM; + if ((ifp->if_capenable & IFCAP_TXCSUM) != 0) ifp->if_hwassist |= sc->bge_csum_features; else ifp->if_hwassist &= ~sc->bge_csum_features; } + if ((mask & IFCAP_RXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_RXCSUM) != 0) + ifp->if_capenable ^= IFCAP_RXCSUM; + if ((mask & IFCAP_TSO4) != 0 && (ifp->if_capabilities & IFCAP_TSO4) != 0) { ifp->if_capenable ^= IFCAP_TSO4; Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 22:59:45 2010 (r214699) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:04:23 2010 (r214700) @@ -1481,6 +1481,7 @@ #define BGE_WDMAMODE_LOCREAD_TOOBIG 0x00000200 #define BGE_WDMAMODE_ALL_ATTNS 0x000003FC #define BGE_WDMAMODE_STATUS_TAG_FIX 0x20000000 +#define BGE_WDMAMODE_BURST_ALL_DATA 0xC0000000 /* Write DMA status register */ #define BGE_WDMASTAT_PCI_TGT_ABRT_ATTN 0x00000004 From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:23:49 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BC2E106564A; Tue, 2 Nov 2010 23:23:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 489538FC0C; Tue, 2 Nov 2010 23:23:49 +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 oA2NNnP3097924; Tue, 2 Nov 2010 23:23:49 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2NNnEe097920; Tue, 2 Nov 2010 23:23:49 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022323.oA2NNnEe097920@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:23:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214702 - in stable/8/sys/dev: bge mii X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:23:49 -0000 Author: yongari Date: Tue Nov 2 23:23:48 2010 New Revision: 214702 URL: http://svn.freebsd.org/changeset/base/214702 Log: MFC r213411,213464-213465,213468: r213411: Enable fix for read DMA FIFO overruns on controllers that have this fix. Note, we still need workaround for controllers that lacks this fix and it needs more work in RX BD updating. Submitted by: davidch r213464: Separate common flags into controller specific and PHY related flags. There should be no functional changes. This change will make it easy to add more quirk/flags in future. Reviewed by: davidch r213465: Rearrange code a bit to correctly set PHY flags. This change make it easy to add more newer ASICs. Obtained from: OpenBSD r213468: Fix bge(4) build breakage when BGE_REGISTER_DEBUG is defined. Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h stable/8/sys/dev/mii/brgphy.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:07:38 2010 (r214701) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:23:48 2010 (r214702) @@ -1858,6 +1858,19 @@ bge_blockinit(struct bge_softc *sc) sc->bge_asicrev == BGE_ASICREV_BCM57780) val |= BGE_RDMAMODE_TSO6_ENABLE; } + if (sc->bge_asicrev == BGE_ASICREV_BCM5761 || + sc->bge_asicrev == BGE_ASICREV_BCM5784 || + sc->bge_asicrev == BGE_ASICREV_BCM5785 || + sc->bge_asicrev == BGE_ASICREV_BCM57780) { + /* + * Enable fix for read DMA FIFO overruns. + * The fix is to limit the number of RX BDs + * the hardware would fetch at a fime. + */ + CSR_WRITE_4(sc, BGE_RDMA_RSRVCTRL, + CSR_READ_4(sc, BGE_RDMA_RSRVCTRL) | + BGE_RDMA_RSRVCTRL_FIFO_OFLW_FIX); + } CSR_WRITE_4(sc, BGE_RDMA_MODE, val); DELAY(40); @@ -2497,7 +2510,7 @@ bge_attach(device_t dev) sc->bge_asicrev != BGE_ASICREV_BCM5906 && sc->bge_chipid != BGE_CHIPID_BCM5705_A0 && sc->bge_chipid != BGE_CHIPID_BCM5705_A1) - sc->bge_flags |= BGE_FLAG_WIRESPEED; + sc->bge_phy_flags |= BGE_PHY_WIRESPEED; if (bge_has_eaddr(sc)) sc->bge_flags |= BGE_FLAG_EADDR; @@ -2534,30 +2547,32 @@ bge_attach(device_t dev) break; } - /* Set various bug flags. */ + /* Set various PHY bug flags. */ if (sc->bge_chipid == BGE_CHIPID_BCM5701_A0 || sc->bge_chipid == BGE_CHIPID_BCM5701_B0) - sc->bge_flags |= BGE_FLAG_CRC_BUG; + sc->bge_phy_flags |= BGE_PHY_CRC_BUG; if (sc->bge_chiprev == BGE_CHIPREV_5703_AX || sc->bge_chiprev == BGE_CHIPREV_5704_AX) - sc->bge_flags |= BGE_FLAG_ADC_BUG; + sc->bge_phy_flags |= BGE_PHY_ADC_BUG; if (sc->bge_chipid == BGE_CHIPID_BCM5704_A0) - sc->bge_flags |= BGE_FLAG_5704_A0_BUG; + sc->bge_phy_flags |= BGE_PHY_5704_A0_BUG; if (pci_get_subvendor(dev) == DELL_VENDORID) - sc->bge_flags |= BGE_FLAG_NO_3LED; - if (pci_get_device(dev) == BCOM_DEVICEID_BCM5755M) - sc->bge_flags |= BGE_FLAG_ADJUST_TRIM; - if (BGE_IS_5705_PLUS(sc) && - !(sc->bge_flags & BGE_FLAG_ADJUST_TRIM)) { + sc->bge_phy_flags |= BGE_PHY_NO_3LED; + if ((BGE_IS_5705_PLUS(sc)) && + sc->bge_asicrev != BGE_ASICREV_BCM5906 && + sc->bge_asicrev != BGE_ASICREV_BCM5785 && + sc->bge_asicrev != BGE_ASICREV_BCM57780) { if (sc->bge_asicrev == BGE_ASICREV_BCM5755 || sc->bge_asicrev == BGE_ASICREV_BCM5761 || sc->bge_asicrev == BGE_ASICREV_BCM5784 || sc->bge_asicrev == BGE_ASICREV_BCM5787) { if (pci_get_device(dev) != BCOM_DEVICEID_BCM5722 && pci_get_device(dev) != BCOM_DEVICEID_BCM5756) - sc->bge_flags |= BGE_FLAG_JITTER_BUG; - } else if (sc->bge_asicrev != BGE_ASICREV_BCM5906) - sc->bge_flags |= BGE_FLAG_BER_BUG; + sc->bge_phy_flags |= BGE_PHY_JITTER_BUG; + if (pci_get_device(dev) == BCOM_DEVICEID_BCM5755M) + sc->bge_phy_flags |= BGE_PHY_ADJUST_TRIM; + } else + sc->bge_phy_flags |= BGE_PHY_BER_BUG; } /* @@ -5342,7 +5357,7 @@ bge_sysctl_debug_info(SYSCTL_HANDLER_ARG printf(" - PCI-X Bus\n"); if (sc->bge_flags & BGE_FLAG_PCIE) printf(" - PCI Express Bus\n"); - if (sc->bge_flags & BGE_FLAG_NO_3LED) + if (sc->bge_phy_flags & BGE_PHY_NO_3LED) printf(" - No 3 LEDs\n"); if (sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) printf(" - RX Alignment Bug\n"); Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:07:38 2010 (r214701) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:23:48 2010 (r214702) @@ -1431,6 +1431,7 @@ */ #define BGE_RDMA_MODE 0x4800 #define BGE_RDMA_STATUS 0x4804 +#define BGE_RDMA_RSRVCTRL 0x4900 /* Read DMA mode register */ #define BGE_RDMAMODE_RESET 0x00000001 @@ -1462,6 +1463,9 @@ #define BGE_RDMASTAT_PCI_FIFOOREAD_ATTN 0x00000100 #define BGE_RDMASTAT_LOCWRITE_TOOBIG 0x00000200 +/* Read DMA Reserved Control register */ +#define BGE_RDMA_RSRVCTRL_FIFO_OFLW_FIX 0x00000004 + /* * Write DMA control registers */ @@ -2659,29 +2663,30 @@ struct bge_softc { uint32_t bge_flags; #define BGE_FLAG_TBI 0x00000001 #define BGE_FLAG_JUMBO 0x00000002 -#define BGE_FLAG_WIRESPEED 0x00000004 #define BGE_FLAG_EADDR 0x00000008 #define BGE_FLAG_MII_SERDES 0x00000010 #define BGE_FLAG_MSI 0x00000100 #define BGE_FLAG_PCIX 0x00000200 #define BGE_FLAG_PCIE 0x00000400 #define BGE_FLAG_TSO 0x00000800 -#define BGE_FLAG_5700_FAMILY 0x00001000 -#define BGE_FLAG_5705_PLUS 0x00002000 -#define BGE_FLAG_5714_FAMILY 0x00004000 -#define BGE_FLAG_575X_PLUS 0x00008000 -#define BGE_FLAG_5755_PLUS 0x00010000 -#define BGE_FLAG_40BIT_BUG 0x00020000 -#define BGE_FLAG_4G_BNDRY_BUG 0x00040000 -#define BGE_FLAG_RX_ALIGNBUG 0x00100000 -#define BGE_FLAG_NO_3LED 0x00200000 -#define BGE_FLAG_ADC_BUG 0x00400000 -#define BGE_FLAG_5704_A0_BUG 0x00800000 -#define BGE_FLAG_JITTER_BUG 0x01000000 -#define BGE_FLAG_BER_BUG 0x02000000 -#define BGE_FLAG_ADJUST_TRIM 0x04000000 -#define BGE_FLAG_CRC_BUG 0x08000000 -#define BGE_FLAG_5788 0x20000000 +#define BGE_FLAG_5700_FAMILY 0x00010000 +#define BGE_FLAG_5705_PLUS 0x00020000 +#define BGE_FLAG_5714_FAMILY 0x00040000 +#define BGE_FLAG_575X_PLUS 0x00080000 +#define BGE_FLAG_5755_PLUS 0x00100000 +#define BGE_FLAG_5788 0x00200000 +#define BGE_FLAG_40BIT_BUG 0x01000000 +#define BGE_FLAG_4G_BNDRY_BUG 0x02000000 +#define BGE_FLAG_RX_ALIGNBUG 0x04000000 + uint32_t bge_phy_flags; +#define BGE_PHY_WIRESPEED 0x00000001 +#define BGE_PHY_ADC_BUG 0x00000002 +#define BGE_PHY_5704_A0_BUG 0x00000004 +#define BGE_PHY_JITTER_BUG 0x00000008 +#define BGE_PHY_BER_BUG 0x00000010 +#define BGE_PHY_ADJUST_TRIM 0x00000020 +#define BGE_PHY_CRC_BUG 0x00000040 +#define BGE_PHY_NO_3LED 0x00000080 uint32_t bge_chipid; uint32_t bge_asicrev; uint32_t bge_chiprev; Modified: stable/8/sys/dev/mii/brgphy.c ============================================================================== --- stable/8/sys/dev/mii/brgphy.c Tue Nov 2 23:07:38 2010 (r214701) +++ stable/8/sys/dev/mii/brgphy.c Tue Nov 2 23:23:48 2010 (r214702) @@ -1025,26 +1025,26 @@ brgphy_reset(struct mii_softc *sc) /* Handle any bge (NetXtreme/NetLink) workarounds. */ if (bge_sc) { /* Fix up various bugs */ - if (bge_sc->bge_flags & BGE_FLAG_5704_A0_BUG) + if (bge_sc->bge_phy_flags & BGE_PHY_5704_A0_BUG) brgphy_fixup_5704_a0_bug(sc); - if (bge_sc->bge_flags & BGE_FLAG_ADC_BUG) + if (bge_sc->bge_phy_flags & BGE_PHY_ADC_BUG) brgphy_fixup_adc_bug(sc); - if (bge_sc->bge_flags & BGE_FLAG_ADJUST_TRIM) + if (bge_sc->bge_phy_flags & BGE_PHY_ADJUST_TRIM) brgphy_fixup_adjust_trim(sc); - if (bge_sc->bge_flags & BGE_FLAG_BER_BUG) + if (bge_sc->bge_phy_flags & BGE_PHY_BER_BUG) brgphy_fixup_ber_bug(sc); - if (bge_sc->bge_flags & BGE_FLAG_CRC_BUG) + if (bge_sc->bge_phy_flags & BGE_PHY_CRC_BUG) brgphy_fixup_crc_bug(sc); - if (bge_sc->bge_flags & BGE_FLAG_JITTER_BUG) + if (bge_sc->bge_phy_flags & BGE_PHY_JITTER_BUG) brgphy_fixup_jitter_bug(sc); brgphy_jumbo_settings(sc, ifp->if_mtu); - if (bge_sc->bge_flags & BGE_FLAG_WIRESPEED) + if (bge_sc->bge_phy_flags & BGE_PHY_WIRESPEED) brgphy_ethernet_wirespeed(sc); /* Enable Link LED on Dell boxes */ - if (bge_sc->bge_flags & BGE_FLAG_NO_3LED) { + if (bge_sc->bge_phy_flags & BGE_PHY_NO_3LED) { PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL) & ~BRGPHY_PHY_EXTCTL_3_LED); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:35:08 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9B0C106566B; Tue, 2 Nov 2010 23:35:08 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D62CE8FC14; Tue, 2 Nov 2010 23:35:08 +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 oA2NZ8Qd098377; Tue, 2 Nov 2010 23:35:08 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2NZ84K098374; Tue, 2 Nov 2010 23:35:08 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022335.oA2NZ84K098374@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:35:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214704 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:35:09 -0000 Author: yongari Date: Tue Nov 2 23:35:08 2010 New Revision: 214704 URL: http://svn.freebsd.org/changeset/base/214704 Log: MFC r213485,213710,213812: r213485: Overhaul MII register access routine and remove unnecessary BGE_MI_MODE register accesses. Previously bge(4) used to read BGE_MI_MODE register to detect whether it needs to disable autopolling feature or not. Because we don't touch autopolling in other part of driver there is no reason to read BGE_MI_MODE register given that we know default value in advance. In order to achieve the goal, check whether the controller has CPMU(Central Power Mangement Unit) capability. If controller has CPMU feature, use 500KHz MII management interface(mdio/mdc) frequency regardless core clock frequency. Otherwise use default MII clock. While I'm here, add CPMU register definition. In bge_miibus_readreg(), rearrange code a bit and remove goto statement. In bge_miibus_writereg(), make sure to restore autopolling even if MII write failed. The delay time inserted after accessing BGE_MI_MODE register increased from 40us to 80us. The default PHY address is now stored in softc. All PHYs supported by bge(4) currently uses PHY address 1 but it will be changed when we add newer controllers. This change will make it easier to change default PHY address depending on PHY models. Submitted by: davidch r213710: Remove one last reference of BGE_MI_MODE register for auto polling. Previously bge(4) always enabled auto polling for non-BGE_FLAG_TBI controllers. With this change, auto polling is not used anymore so polling through mii(4) was introduced. Reviewed by: davidch r213812: Fix a regression introduced in r213710. r213710 removed the use of auto polling such that it made all controllers obtain link status information from the state of the LNKRDY input signal. Broadcom recommends disabling auto polling such that driver should rely on PHY interrupts for link status change indications. Unfortunately it seems some controllers(BCM5703, BCM5704 and BCM5705) have PHY related issues so Linux took other approach to workaround it. bge(4) didn't follow that and it used to enable auto polling to workaround it. Restore this old behavior for BCM5700 family controllers and BCM5705 to use auto polling. For BCM5700 and BCM5701, it seems it does not need to enable auto polling but I restored it for safety. Special thanks to marius who tried lots of patches with patience. Reported by: marius Tested by: marius Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:26:07 2010 (r214703) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:35:08 2010 (r214704) @@ -768,38 +768,34 @@ static int bge_miibus_readreg(device_t dev, int phy, int reg) { struct bge_softc *sc; - uint32_t val, autopoll; + uint32_t val; int i; sc = device_get_softc(dev); - /* - * Broadcom's own driver always assumes the internal - * PHY is at GMII address 1. On some chips, the PHY responds - * to accesses at all addresses, which could cause us to - * bogusly attach the PHY 32 times at probe type. Always - * restricting the lookup to address 1 is simpler than - * trying to figure out which chips revisions should be - * special-cased. - */ - if (phy != 1) + /* Prevent the probe from finding incorrect devices. */ + if (phy != sc->bge_phy_addr) return (0); - /* Reading with autopolling on may trigger PCI errors */ - autopoll = CSR_READ_4(sc, BGE_MI_MODE); - if (autopoll & BGE_MIMODE_AUTOPOLL) { - BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); - DELAY(40); + /* Clear the autopoll bit if set, otherwise may trigger PCI errors. */ + if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) { + CSR_WRITE_4(sc, BGE_MI_MODE, + sc->bge_mi_mode & ~BGE_MIMODE_AUTOPOLL); + DELAY(80); } CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_READ | BGE_MICOMM_BUSY | BGE_MIPHY(phy) | BGE_MIREG(reg)); + /* Poll for the PHY register access to complete. */ for (i = 0; i < BGE_TIMEOUT; i++) { DELAY(10); val = CSR_READ_4(sc, BGE_MI_COMM); - if (!(val & BGE_MICOMM_BUSY)) + if ((val & BGE_MICOMM_BUSY) == 0) { + DELAY(5); + val = CSR_READ_4(sc, BGE_MI_COMM); break; + } } if (i == BGE_TIMEOUT) { @@ -807,16 +803,12 @@ bge_miibus_readreg(device_t dev, int phy "PHY read timed out (phy %d, reg %d, val 0x%08x)\n", phy, reg, val); val = 0; - goto done; } - DELAY(5); - val = CSR_READ_4(sc, BGE_MI_COMM); - -done: - if (autopoll & BGE_MIMODE_AUTOPOLL) { - BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); - DELAY(40); + /* Restore the autopoll bit if necessary. */ + if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) { + CSR_WRITE_4(sc, BGE_MI_MODE, sc->bge_mi_mode); + DELAY(80); } if (val & BGE_MICOMM_READFAIL) @@ -829,7 +821,6 @@ static int bge_miibus_writereg(device_t dev, int phy, int reg, int val) { struct bge_softc *sc; - uint32_t autopoll; int i; sc = device_get_softc(dev); @@ -838,11 +829,11 @@ bge_miibus_writereg(device_t dev, int ph (reg == BRGPHY_MII_1000CTL || reg == BRGPHY_MII_AUXCTL)) return (0); - /* Reading with autopolling on may trigger PCI errors */ - autopoll = CSR_READ_4(sc, BGE_MI_MODE); - if (autopoll & BGE_MIMODE_AUTOPOLL) { - BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); - DELAY(40); + /* Clear the autopoll bit if set, otherwise may trigger PCI errors. */ + if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) { + CSR_WRITE_4(sc, BGE_MI_MODE, + sc->bge_mi_mode & ~BGE_MIMODE_AUTOPOLL); + DELAY(80); } CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_WRITE | BGE_MICOMM_BUSY | @@ -857,17 +848,16 @@ bge_miibus_writereg(device_t dev, int ph } } - if (i == BGE_TIMEOUT) { + /* Restore the autopoll bit if necessary. */ + if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) { + CSR_WRITE_4(sc, BGE_MI_MODE, sc->bge_mi_mode); + DELAY(80); + } + + if (i == BGE_TIMEOUT) device_printf(sc->bge_dev, "PHY write timed out (phy %d, reg %d, val %d)\n", phy, reg, val); - return (0); - } - - if (autopoll & BGE_MIMODE_AUTOPOLL) { - BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); - DELAY(40); - } return (0); } @@ -1918,11 +1908,17 @@ bge_blockinit(struct bge_softc *sc) BGE_MACSTAT_LINK_CHANGED); CSR_WRITE_4(sc, BGE_MI_STS, 0); - /* Enable PHY auto polling (for MII/GMII only) */ + /* + * Enable attention when the link has changed state for + * devices that use auto polling. + */ if (sc->bge_flags & BGE_FLAG_TBI) { CSR_WRITE_4(sc, BGE_MI_STS, BGE_MISTS_LINK); } else { - BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL | (10 << 16)); + if (sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) { + CSR_WRITE_4(sc, BGE_MI_MODE, sc->bge_mi_mode); + DELAY(80); + } if (sc->bge_asicrev == BGE_ASICREV_BCM5700 && sc->bge_chipid != BGE_CHIPID_BCM5700_B2) CSR_WRITE_4(sc, BGE_MAC_EVT_ENB, @@ -2502,6 +2498,9 @@ bge_attach(device_t dev) sc->bge_asicrev = BGE_ASICREV(sc->bge_chipid); sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid); + /* Set default PHY address. */ + sc->bge_phy_addr = 1; + /* * Don't enable Ethernet@WireSpeed for the 5700, 5906, or the * 5705 A0 and A1 chips. @@ -2575,6 +2574,20 @@ bge_attach(device_t dev) sc->bge_phy_flags |= BGE_PHY_BER_BUG; } + /* Identify the chips that use an CPMU. */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5784 || + sc->bge_asicrev == BGE_ASICREV_BCM5761 || + sc->bge_asicrev == BGE_ASICREV_BCM5785 || + sc->bge_asicrev == BGE_ASICREV_BCM57780) + sc->bge_flags |= BGE_FLAG_CPMU_PRESENT; + if ((sc->bge_flags & BGE_FLAG_CPMU_PRESENT) != 0) + sc->bge_mi_mode = BGE_MIMODE_500KHZ_CONST; + else + sc->bge_mi_mode = BGE_MIMODE_BASE; + /* Enable auto polling for BCM570[0-5]. */ + if (BGE_IS_5700_FAMILY(sc) || sc->bge_asicrev == BGE_ASICREV_BCM5705) + sc->bge_mi_mode |= BGE_MIMODE_AUTOPOLL; + /* * All controllers that are not 5755 or higher have 4GB * boundary DMA bug. @@ -4948,7 +4961,7 @@ bge_link_upd(struct bge_softc *sc) if_printf(sc->bge_ifp, "link DOWN\n"); if_link_state_change(sc->bge_ifp, LINK_STATE_DOWN); } - } else if (CSR_READ_4(sc, BGE_MI_MODE) & BGE_MIMODE_AUTOPOLL) { + } else if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) { /* * Some broken BCM chips have BGE_STATFLAG_LINKSTATE_CHANGED bit * in status word always set. Workaround this bug by reading @@ -4976,9 +4989,17 @@ bge_link_upd(struct bge_softc *sc) } } else { /* - * Discard link events for MII/GMII controllers - * if MI auto-polling is disabled. + * For controllers that call mii_tick, we have to poll + * link status. */ + mii = device_get_softc(sc->bge_miibus); + mii_pollstat(mii); + if (!sc->bge_link && mii->mii_media_status & IFM_ACTIVE && + IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { + bge_miibus_statchg(sc->bge_dev); + sc->bge_link = 1; + } else + sc->bge_link = 0; } /* Clear the attention. */ Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:26:07 2010 (r214703) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:35:08 2010 (r214704) @@ -863,9 +863,12 @@ #define BGE_MISTS_LINK 0x00000001 #define BGE_MISTS_10MBPS 0x00000002 +#define BGE_MIMODE_CLK_10MHZ 0x00000001 #define BGE_MIMODE_SHORTPREAMBLE 0x00000002 #define BGE_MIMODE_AUTOPOLL 0x00000010 #define BGE_MIMODE_CLKCNT 0x001F0000 +#define BGE_MIMODE_500KHZ_CONST 0x00008000 +#define BGE_MIMODE_BASE 0x000C0000 /* @@ -1221,6 +1224,51 @@ /* Receive List Selector Status register */ #define BGE_RXLSSTAT_ERROR 0x00000004 +#define BGE_CPMU_CTRL 0x3600 +#define BGE_CPMU_LSPD_10MB_CLK 0x3604 +#define BGE_CPMU_LSPD_1000MB_CLK 0x360C +#define BGE_CPMU_LNK_AWARE_PWRMD 0x3610 +#define BGE_CPMU_HST_ACC 0x361C +#define BGE_CPMU_CLCK_STAT 0x3630 +#define BGE_CPMU_MUTEX_REQ 0x365C +#define BGE_CPMU_MUTEX_GNT 0x3660 +#define BGE_CPMU_PHY_STRAP 0x3664 + +/* Central Power Management Unit (CPMU) register */ +#define BGE_CPMU_CTRL_LINK_IDLE_MODE 0x00000200 +#define BGE_CPMU_CTRL_LINK_AWARE_MODE 0x00000400 +#define BGE_CPMU_CTRL_LINK_SPEED_MODE 0x00004000 +#define BGE_CPMU_CTRL_GPHY_10MB_RXONLY 0x00010000 + +/* Link Speed 10MB/No Link Power Mode Clock Policy register */ +#define BGE_CPMU_LSPD_10MB_MACCLK_MASK 0x001F0000 +#define BGE_CPMU_LSPD_10MB_MACCLK_6_25 0x00130000 + +/* Link Speed 1000MB Power Mode Clock Policy register */ +#define BGE_CPMU_LSPD_1000MB_MACCLK_62_5 0x00000000 +#define BGE_CPMU_LSPD_1000MB_MACCLK_12_5 0x00110000 +#define BGE_CPMU_LSPD_1000MB_MACCLK_MASK 0x001F0000 + +/* Link Aware Power Mode Clock Policy register */ +#define BGE_CPMU_LNK_AWARE_MACCLK_MASK 0x001F0000 +#define BGE_CPMU_LNK_AWARE_MACCLK_6_25 0x00130000 + +#define BGE_CPMU_HST_ACC_MACCLK_MASK 0x001F0000 +#define BGE_CPMU_HST_ACC_MACCLK_6_25 0x00130000 + +/* CPMU Clock Status register */ +#define BGE_CPMU_CLCK_STAT_MAC_CLCK_MASK 0x001F0000 +#define BGE_CPMU_CLCK_STAT_MAC_CLCK_62_5 0x00000000 +#define BGE_CPMU_CLCK_STAT_MAC_CLCK_12_5 0x00110000 +#define BGE_CPMU_CLCK_STAT_MAC_CLCK_6_25 0x00130000 + +/* CPMU Mutex Request register */ +#define BGE_CPMU_MUTEX_REQ_DRIVER 0x00001000 +#define BGE_CPMU_MUTEX_GNT_DRIVER 0x00001000 + +/* CPMU GPHY Strap register */ +#define BGE_CPMU_PHY_STRAP_IS_SERDES 0x00000020 + /* * Mbuf Cluster Free registers (has nothing to do with BSD mbufs) */ @@ -2665,6 +2713,7 @@ struct bge_softc { #define BGE_FLAG_JUMBO 0x00000002 #define BGE_FLAG_EADDR 0x00000008 #define BGE_FLAG_MII_SERDES 0x00000010 +#define BGE_FLAG_CPMU_PRESENT 0x00000020 #define BGE_FLAG_MSI 0x00000100 #define BGE_FLAG_PCIX 0x00000200 #define BGE_FLAG_PCIE 0x00000400 @@ -2707,7 +2756,9 @@ struct bge_softc { uint32_t bge_rx_max_coal_bds; uint32_t bge_tx_max_coal_bds; uint32_t bge_tx_buf_ratio; + uint32_t bge_mi_mode; int bge_if_flags; + int bge_phy_addr; int bge_txcnt; int bge_link; /* link state */ int bge_link_evt; /* pending link event */ From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:41:43 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A51751065695; Tue, 2 Nov 2010 23:41:43 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 914438FC17; Tue, 2 Nov 2010 23:41:43 +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 oA2NfhaD098656; Tue, 2 Nov 2010 23:41:43 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2NfhCI098654; Tue, 2 Nov 2010 23:41:43 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022341.oA2NfhCI098654@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:41:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214706 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:41:43 -0000 Author: yongari Date: Tue Nov 2 23:41:43 2010 New Revision: 214706 URL: http://svn.freebsd.org/changeset/base/214706 Log: MFC r213495,213742: r213495: Add more comments to rings supported by the controller. Different versions of controller support different number of ring control blocks such that adjust code a bit to access known number of send/receive ring control blocks. Previously bge(4) blindly accessed 16 send/receive RCBs. Also move initializing standard receive producer ring producer index, jumbo receive producer ring producer index and mini receive producer ring producer index to the end of each receive producer ring initialization. Do not assume mini receive producer ring is available only when controller has jumbo frame capability, instead explicitly check ASIC version BCM5700 to disable mini receive producer ring. Additionally always enable send ring 0 regardless of controller versions. Previously bge(4) didn't enable send ring 0 if controller is BGE_IS_5705_PLUS. Becase bge(4) need 1 send ring to send frames at least, I have no idea how it would have worked so far. Submitted by: davidch r213742: Fix a regression introduced in r213495. r213495 disabled mini receive producer ring only for BCM5700. It was believed that BCM5700 with external SSRAM is the only controller that supports mini ring but it seems all BCM570[0-4] requires to disable mini receive producer ring. Otherwise, it caused unexpected RX DMA error or watchdog timeouts. Reported by: marius, Steve Kargl troutmask dot apl dot washington dot edu> Tested by: marius, Steve Kargl troutmask dot apl dot washington dot edu> Modified: stable/8/sys/dev/bge/if_bge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:36:54 2010 (r214705) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:41:43 2010 (r214706) @@ -1092,9 +1092,10 @@ bge_init_rx_ring_jumbo(struct bge_softc sc->bge_jumbo = 0; + /* Enable the jumbo receive producer ring. */ rcb = &sc->bge_ldata.bge_info.bge_jumbo_rx_rcb; - rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, - BGE_RCB_FLAG_USE_EXT_RX_BD); + rcb->bge_maxlen_flags = + BGE_RCB_MAXLEN_FLAGS(0, BGE_RCB_FLAG_USE_EXT_RX_BD); CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags); bge_writembx(sc, BGE_MBX_RX_JUMBO_PROD_LO, BGE_JUMBO_RX_RING_CNT - 1); @@ -1473,7 +1474,7 @@ bge_blockinit(struct bge_softc *sc) bus_size_t vrcb; bge_hostaddr taddr; uint32_t val; - int i; + int i, limit; /* * Initialize the memory window pointer register so that @@ -1553,7 +1554,38 @@ bge_blockinit(struct bge_softc *sc) return (ENXIO); } - /* Initialize the standard RX ring control block */ + /* + * Summary of rings supported by the controller: + * + * Standard Receive Producer Ring + * - This ring is used to feed receive buffers for "standard" + * sized frames (typically 1536 bytes) to the controller. + * + * Jumbo Receive Producer Ring + * - This ring is used to feed receive buffers for jumbo sized + * frames (i.e. anything bigger than the "standard" frames) + * to the controller. + * + * Mini Receive Producer Ring + * - This ring is used to feed receive buffers for "mini" + * sized frames to the controller. + * - This feature required external memory for the controller + * but was never used in a production system. Should always + * be disabled. + * + * Receive Return Ring + * - After the controller has placed an incoming frame into a + * receive buffer that buffer is moved into a receive return + * ring. The driver is then responsible to passing the + * buffer up to the stack. Many versions of the controller + * support multiple RR rings. + * + * Send Ring + * - This ring is used for outgoing frames. Many versions of + * the controller support multiple send rings. + */ + + /* Initialize the standard receive producer ring control block. */ rcb = &sc->bge_ldata.bge_info.bge_std_rx_rcb; rcb->bge_hostaddr.bge_addr_lo = BGE_ADDR_LO(sc->bge_ldata.bge_rx_std_ring_paddr); @@ -1561,28 +1593,45 @@ bge_blockinit(struct bge_softc *sc) BGE_ADDR_HI(sc->bge_ldata.bge_rx_std_ring_paddr); bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag, sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_PREREAD); - if (BGE_IS_5705_PLUS(sc)) + if (BGE_IS_5705_PLUS(sc)) { + /* + * Bits 31-16: Programmable ring size (512, 256, 128, 64, 32) + * Bits 15-2 : Reserved (should be 0) + * Bit 1 : 1 = Ring Disabled, 0 = Ring Enabled + * Bit 0 : Reserved + */ rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(512, 0); - else + } else { + /* + * Ring size is always XXX entries + * Bits 31-16: Maximum RX frame size + * Bits 15-2 : Reserved (should be 0) + * Bit 1 : 1 = Ring Disabled, 0 = Ring Enabled + * Bit 0 : Reserved + */ rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(BGE_MAX_FRAMELEN, 0); + } rcb->bge_nicaddr = BGE_STD_RX_RINGS; + /* Write the standard receive producer ring control block. */ CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_HI, rcb->bge_hostaddr.bge_addr_hi); CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_LO, rcb->bge_hostaddr.bge_addr_lo); - CSR_WRITE_4(sc, BGE_RX_STD_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags); CSR_WRITE_4(sc, BGE_RX_STD_RCB_NICADDR, rcb->bge_nicaddr); + /* Reset the standard receive producer ring producer index. */ + bge_writembx(sc, BGE_MBX_RX_STD_PROD_LO, 0); + /* - * Initialize the jumbo RX ring control block - * We set the 'ring disabled' bit in the flags - * field until we're actually ready to start + * Initialize the jumbo RX producer ring control + * block. We set the 'ring disabled' bit in the + * flags field until we're actually ready to start * using this ring (i.e. once we set the MTU * high enough to require it). */ if (BGE_IS_JUMBO_CAPABLE(sc)) { rcb = &sc->bge_ldata.bge_info.bge_jumbo_rx_rcb; - + /* Get the jumbo receive producer ring RCB parameters. */ rcb->bge_hostaddr.bge_addr_lo = BGE_ADDR_LO(sc->bge_ldata.bge_rx_jumbo_ring_paddr); rcb->bge_hostaddr.bge_addr_hi = @@ -1597,20 +1646,31 @@ bge_blockinit(struct bge_softc *sc) rcb->bge_hostaddr.bge_addr_hi); CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_HADDR_LO, rcb->bge_hostaddr.bge_addr_lo); - + /* Program the jumbo receive producer ring RCB parameters. */ CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags); CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_NICADDR, rcb->bge_nicaddr); + /* Reset the jumbo receive producer ring producer index. */ + bge_writembx(sc, BGE_MBX_RX_JUMBO_PROD_LO, 0); + } - /* Set up dummy disabled mini ring RCB */ + /* Disable the mini receive producer ring RCB. */ + if (BGE_IS_5700_FAMILY(sc)) { rcb = &sc->bge_ldata.bge_info.bge_mini_rx_rcb; rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, BGE_RCB_FLAG_RING_DISABLED); CSR_WRITE_4(sc, BGE_RX_MINI_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags); + /* Reset the mini receive producer ring producer index. */ + bge_writembx(sc, BGE_MBX_RX_MINI_PROD_LO, 0); } /* + * The BD ring replenish thresholds control how often the + * hardware fetches new BD's from the producer rings in host + * memory. Setting the value too low on a busy system can + * starve the hardware and recue the throughpout. + * * Set the BD ring replentish thresholds. The recommended * values are 1/8th the number of descriptors allocated to * each ring. @@ -1632,61 +1692,67 @@ bge_blockinit(struct bge_softc *sc) BGE_JUMBO_RX_RING_CNT/8); /* - * Disable all unused send rings by setting the 'ring disabled' - * bit in the flags field of all the TX send ring control blocks. - * These are located in NIC memory. - */ + * Disable all send rings by setting the 'ring disabled' bit + * in the flags field of all the TX send ring control blocks, + * located in NIC memory. + */ + if (!BGE_IS_5705_PLUS(sc)) + /* 5700 to 5704 had 16 send rings. */ + limit = BGE_TX_RINGS_EXTSSRAM_MAX; + else + limit = 1; vrcb = BGE_MEMWIN_START + BGE_SEND_RING_RCB; - for (i = 0; i < BGE_TX_RINGS_EXTSSRAM_MAX; i++) { + for (i = 0; i < limit; i++) { RCB_WRITE_4(sc, vrcb, bge_maxlen_flags, BGE_RCB_MAXLEN_FLAGS(0, BGE_RCB_FLAG_RING_DISABLED)); RCB_WRITE_4(sc, vrcb, bge_nicaddr, 0); vrcb += sizeof(struct bge_rcb); } - /* Configure TX RCB 0 (we use only the first ring) */ + /* Configure send ring RCB 0 (we use only the first ring) */ vrcb = BGE_MEMWIN_START + BGE_SEND_RING_RCB; BGE_HOSTADDR(taddr, sc->bge_ldata.bge_tx_ring_paddr); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_hi, taddr.bge_addr_hi); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo); RCB_WRITE_4(sc, vrcb, bge_nicaddr, BGE_NIC_TXRING_ADDR(0, BGE_TX_RING_CNT)); - if (!(BGE_IS_5705_PLUS(sc))) - RCB_WRITE_4(sc, vrcb, bge_maxlen_flags, - BGE_RCB_MAXLEN_FLAGS(BGE_TX_RING_CNT, 0)); + RCB_WRITE_4(sc, vrcb, bge_maxlen_flags, + BGE_RCB_MAXLEN_FLAGS(BGE_TX_RING_CNT, 0)); - /* Disable all unused RX return rings */ + /* + * Disable all receive return rings by setting the + * 'ring diabled' bit in the flags field of all the receive + * return ring control blocks, located in NIC memory. + */ + if (!BGE_IS_5705_PLUS(sc)) + limit = BGE_RX_RINGS_MAX; + else if (sc->bge_asicrev == BGE_ASICREV_BCM5755) + limit = 4; + else + limit = 1; + /* Disable all receive return rings. */ vrcb = BGE_MEMWIN_START + BGE_RX_RETURN_RING_RCB; - for (i = 0; i < BGE_RX_RINGS_MAX; i++) { + for (i = 0; i < limit; i++) { RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_hi, 0); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_lo, 0); RCB_WRITE_4(sc, vrcb, bge_maxlen_flags, - BGE_RCB_MAXLEN_FLAGS(sc->bge_return_ring_cnt, - BGE_RCB_FLAG_RING_DISABLED)); + BGE_RCB_FLAG_RING_DISABLED); RCB_WRITE_4(sc, vrcb, bge_nicaddr, 0); bge_writembx(sc, BGE_MBX_RX_CONS0_LO + (i * (sizeof(uint64_t))), 0); vrcb += sizeof(struct bge_rcb); } - /* Initialize RX ring indexes */ - bge_writembx(sc, BGE_MBX_RX_STD_PROD_LO, 0); - if (BGE_IS_JUMBO_CAPABLE(sc)) - bge_writembx(sc, BGE_MBX_RX_JUMBO_PROD_LO, 0); - if (sc->bge_asicrev == BGE_ASICREV_BCM5700) - bge_writembx(sc, BGE_MBX_RX_MINI_PROD_LO, 0); - /* - * Set up RX return ring 0 - * Note that the NIC address for RX return rings is 0x00000000. - * The return rings live entirely within the host, so the - * nicaddr field in the RCB isn't used. + * Set up receive return ring 0. Note that the NIC address + * for RX return rings is 0x0. The return rings live entirely + * within the host, so the nicaddr field in the RCB isn't used. */ vrcb = BGE_MEMWIN_START + BGE_RX_RETURN_RING_RCB; BGE_HOSTADDR(taddr, sc->bge_ldata.bge_rx_return_ring_paddr); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_hi, taddr.bge_addr_hi); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo); - RCB_WRITE_4(sc, vrcb, bge_nicaddr, 0x00000000); + RCB_WRITE_4(sc, vrcb, bge_nicaddr, 0); RCB_WRITE_4(sc, vrcb, bge_maxlen_flags, BGE_RCB_MAXLEN_FLAGS(sc->bge_return_ring_cnt, 0)); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:48:08 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B01851065673; Tue, 2 Nov 2010 23:48:08 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D7D98FC16; Tue, 2 Nov 2010 23:48:08 +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 oA2Nm8N9099062; Tue, 2 Nov 2010 23:48:08 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2Nm8hf099060; Tue, 2 Nov 2010 23:48:08 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022348.oA2Nm8hf099060@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:48:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214710 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:48:08 -0000 Author: yongari Date: Tue Nov 2 23:48:08 2010 New Revision: 214710 URL: http://svn.freebsd.org/changeset/base/214710 Log: MFC r213522,213587,213711: r213522: Fix a long standing bug which regarded some revisions of controller as 5788. This caused BGE_MISC_LOCAL_CTL register is used to generate link state change interrupt for non-5788 controllers. The interrupt handler may or may not detect link state attention as status block wouldn't be updated when an interrupt was generated with BGE_MISC_LOCAL_CTL register. All controllers except 5700 and 5788 should use host coalescing mode register to trigger an interrupt. r213587: Do not blindly UP the interface when interface's MTU is changed. If driver is not running there is no need to up the interface. While I'm here hold driver lock before modifying MTU as it is referenced in RX handler. r213711: The IFF_DRV_RUNNING flag is set at the end of bge_init_locked. But before setting the flag, interrupt was already enabled such that interrupt handler could be run before setting IFF_DRV_RUNNING flag. This can lose initial link state change interrupt which in turn make bge(4) think that it still does not have valid link. Fix this race by protecting the taskqueue with a driver lock. While I'm here move reenabling interrupt code after handling of link state chage. Reviewed by: davidch Modified: stable/8/sys/dev/bge/if_bge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:44:29 2010 (r214709) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:48:08 2010 (r214710) @@ -2665,14 +2665,12 @@ bge_attach(device_t dev) if (BGE_IS_5755_PLUS(sc) == 0) sc->bge_flags |= BGE_FLAG_4G_BNDRY_BUG; - /* - * We could possibly check for BCOM_DEVICEID_BCM5788 in bge_probe() - * but I do not know the DEVICEID for the 5788M. - */ - misccfg = CSR_READ_4(sc, BGE_MISC_CFG) & BGE_MISCCFG_BOARD_ID; - if (misccfg == BGE_MISCCFG_BOARD_ID_5788 || - misccfg == BGE_MISCCFG_BOARD_ID_5788M) - sc->bge_flags |= BGE_FLAG_5788; + if (sc->bge_asicrev == BGE_ASICREV_BCM5705) { + misccfg = CSR_READ_4(sc, BGE_MISC_CFG) & BGE_MISCCFG_BOARD_ID; + if (misccfg == BGE_MISCCFG_BOARD_ID_5788 || + misccfg == BGE_MISCCFG_BOARD_ID_5788M) + sc->bge_flags |= BGE_FLAG_5788; + } /* * Some controllers seem to require a special firmware to use @@ -3638,8 +3636,11 @@ bge_intr_task(void *arg, int pending) sc = (struct bge_softc *)arg; ifp = sc->bge_ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + BGE_LOCK(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + BGE_UNLOCK(sc); return; + } /* Get updated status block. */ bus_dmamap_sync(sc->bge_cdata.bge_status_tag, @@ -3654,26 +3655,27 @@ bge_intr_task(void *arg, int pending) bus_dmamap_sync(sc->bge_cdata.bge_status_tag, sc->bge_cdata.bge_status_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + if ((status & BGE_STATFLAG_LINKSTATE_CHANGED) != 0) + bge_link_upd(sc); + /* Let controller work. */ bge_writembx(sc, BGE_MBX_IRQ0_LO, 0); - if ((status & BGE_STATFLAG_LINKSTATE_CHANGED) != 0) { - BGE_LOCK(sc); - bge_link_upd(sc); - BGE_UNLOCK(sc); - } - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING && + sc->bge_rx_saved_considx != rx_prod) { /* Check RX return ring producer/consumer. */ + BGE_UNLOCK(sc); bge_rxeof(sc, rx_prod, 0); + BGE_LOCK(sc); } if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - BGE_LOCK(sc); /* Check TX ring producer/consumer. */ bge_txeof(sc, tx_cons); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) bge_start_locked(ifp); - BGE_UNLOCK(sc); } + BGE_UNLOCK(sc); } static void @@ -4644,6 +4646,7 @@ bge_ioctl(struct ifnet *ifp, u_long comm switch (command) { case SIOCSIFMTU: + BGE_LOCK(sc); if (ifr->ifr_mtu < ETHERMIN || ((BGE_IS_JUMBO_CAPABLE(sc)) && ifr->ifr_mtu > BGE_JUMBO_MTU) || @@ -4652,9 +4655,12 @@ bge_ioctl(struct ifnet *ifp, u_long comm error = EINVAL; else if (ifp->if_mtu != ifr->ifr_mtu) { ifp->if_mtu = ifr->ifr_mtu; - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - bge_init(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + bge_init_locked(sc); + } } + BGE_UNLOCK(sc); break; case SIOCSIFFLAGS: BGE_LOCK(sc); From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 2 23:55:00 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 026B5106564A; Tue, 2 Nov 2010 23:55:00 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E41808FC16; Tue, 2 Nov 2010 23:54: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 oA2Nsx3D099368; Tue, 2 Nov 2010 23:54:59 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2NsxF7099365; Tue, 2 Nov 2010 23:54:59 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011022354.oA2NsxF7099365@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 2 Nov 2010 23:54:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214712 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 23:55:00 -0000 Author: yongari Date: Tue Nov 2 23:54:59 2010 New Revision: 214712 URL: http://svn.freebsd.org/changeset/base/214712 Log: MFC r213747,213808,214216: r213747: Protect bge(4) from accessing invalid NIC internal memory regions on BCM5906. Tested by: Buganini < buganini <> gmail dot com > r213808: Add more checks for resolved link speed in bge_miibus_statchg(). Link UP state could be reported first before actual completion of auto-negotiation. This change makes bge(4) reprogram BGE_MAC_MODE, BGE_TX_MODE and BGE_RX_MODE register only after controller got a valid link. r214216: Enable TX MAC state machine lockup fix for both BCM5755 or higher and BCM5906. Publicly available data sheet just says it may happen due to corrupted TxMbuf. Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:49:48 2010 (r214711) +++ stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:54:59 2010 (r214712) @@ -550,6 +550,10 @@ bge_readmem_ind(struct bge_softc *sc, in device_t dev; uint32_t val; + if (sc->bge_asicrev == BGE_ASICREV_BCM5906 && + off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4) + return (0); + dev = sc->bge_dev; pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); @@ -563,6 +567,10 @@ bge_writemem_ind(struct bge_softc *sc, i { device_t dev; + if (sc->bge_asicrev == BGE_ASICREV_BCM5906 && + off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4) + return; + dev = sc->bge_dev; pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); @@ -870,6 +878,29 @@ bge_miibus_statchg(device_t dev) sc = device_get_softc(dev); mii = device_get_softc(sc->bge_miibus); + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->bge_link = 1; + break; + case IFM_1000_T: + case IFM_1000_SX: + case IFM_2500_SX: + if (sc->bge_asicrev != BGE_ASICREV_BCM5906) + sc->bge_link = 1; + else + sc->bge_link = 0; + break; + default: + sc->bge_link = 0; + break; + } + } else + sc->bge_link = 0; + if (sc->bge_link == 0) + return; BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE); if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T || IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX) @@ -4339,6 +4370,7 @@ bge_init_locked(struct bge_softc *sc) { struct ifnet *ifp; uint16_t *m; + uint32_t mode; BGE_LOCK_ASSERT(sc); @@ -4444,8 +4476,12 @@ bge_init_locked(struct bge_softc *sc) /* Init TX ring. */ bge_init_tx_ring(sc); + /* Enable TX MAC state machine lockup fix. */ + mode = CSR_READ_4(sc, BGE_TX_MODE); + if (BGE_IS_5755_PLUS(sc) || sc->bge_asicrev == BGE_ASICREV_BCM5906) + mode |= BGE_TXMODE_MBUF_LOCKUP_FIX; /* Turn on transmitter. */ - BGE_SETBIT(sc, BGE_TX_MODE, BGE_TXMODE_ENABLE); + CSR_WRITE_4(sc, BGE_TX_MODE, mode | BGE_TXMODE_ENABLE); /* Turn on receiver. */ BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); @@ -5066,12 +5102,7 @@ bge_link_upd(struct bge_softc *sc) */ mii = device_get_softc(sc->bge_miibus); mii_pollstat(mii); - if (!sc->bge_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - bge_miibus_statchg(sc->bge_dev); - sc->bge_link = 1; - } else - sc->bge_link = 0; + bge_miibus_statchg(sc->bge_dev); } /* Clear the attention. */ Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:49:48 2010 (r214711) +++ stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:54:59 2010 (r214712) @@ -765,6 +765,7 @@ #define BGE_TXMODE_FLOWCTL_ENABLE 0x00000010 #define BGE_TXMODE_BIGBACKOFF_ENABLE 0x00000020 #define BGE_TXMODE_LONGPAUSE_ENABLE 0x00000040 +#define BGE_TXMODE_MBUF_LOCKUP_FIX 0x00000100 /* Transmit MAC status register */ #define BGE_TXSTAT_RX_XOFFED 0x00000001 From owner-svn-src-stable-8@FreeBSD.ORG Wed Nov 3 00:03:26 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D7631106564A; Wed, 3 Nov 2010 00:03:26 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C4A9F8FC0A; Wed, 3 Nov 2010 00:03:26 +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 oA303QTZ099794; Wed, 3 Nov 2010 00:03:26 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA303QGS099791; Wed, 3 Nov 2010 00:03:26 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011030003.oA303QGS099791@svn.freebsd.org> From: Pyun YongHyeon Date: Wed, 3 Nov 2010 00:03:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214714 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 00:03:27 -0000 Author: yongari Date: Wed Nov 3 00:03:26 2010 New Revision: 214714 URL: http://svn.freebsd.org/changeset/base/214714 Log: MFC r214087,214219,214251,214292: r214087: Add workaround for BCM5906 controller silicon bug. If device receive two back-to-back send BDs with less than or equal to 8 total bytes then the device may hang. The two back-to-back send BDs must be in the same frame for this failure to occur. Thanks to davidch for detailed errata information. Reviewed by: davidch r214219: Add workaround for BCM5906 A1 controller silicon bug. When auto-negotiation results in half-duplex operation, excess collision on the ethernet link may cause internal chip delays that may result in subsequent valid frames being dropped due to insufficient receive buffer resources. The workaround is to choose de-pipeline method as a flow control decision for SDI. De-pipeline method allows only 1 data in TxMbuf at a time such that a request to RDMA from SDI is made only when TxMbuf is empty. Thanks for david for providing detailed errata information. r214251: Apply the same workaround for SDI flow control used on BCM5906 A1 to BCM6906 A0/A2. This should fix a long standing BCM5906 A2 lockup issues. Data sheet explicitly mentions BCM5906 A0, A1 and A2 use de-pipelined mode on these revisions. Special thanks to Buganini who tried all combinations of experimental patches for more than 10 days. Tested by: Buganini gmail dot com > r214292: Use bge_chipid to compare controller ids. r214251 incorrectly used bge_chiprev. Reported by: Buganini gmail dot com > Modified: stable/8/sys/dev/bge/if_bge.c stable/8/sys/dev/bge/if_bgereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Tue Nov 2 23:56:35 2010 (r214713) +++ stable/8/sys/dev/bge/if_bge.c Wed Nov 3 00:03:26 2010 (r214714) @@ -374,6 +374,7 @@ static void bge_tick(void *); static void bge_stats_clear_regs(struct bge_softc *); static void bge_stats_update(struct bge_softc *); static void bge_stats_update_regs(struct bge_softc *); +static struct mbuf *bge_check_short_dma(struct mbuf *); static struct mbuf *bge_setup_tso(struct bge_softc *, struct mbuf *, uint16_t *); static int bge_encap(struct bge_softc *, struct mbuf **, uint32_t *); @@ -1696,6 +1697,14 @@ bge_blockinit(struct bge_softc *sc) bge_writembx(sc, BGE_MBX_RX_MINI_PROD_LO, 0); } + /* Choose de-pipeline mode for BCM5906 A0, A1 and A2. */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5906) { + if (sc->bge_chipid == BGE_CHIPID_BCM5906_A0 || + sc->bge_chipid == BGE_CHIPID_BCM5906_A1 || + sc->bge_chipid == BGE_CHIPID_BCM5906_A2) + CSR_WRITE_4(sc, BGE_ISO_PKT_TX, + (CSR_READ_4(sc, BGE_ISO_PKT_TX) & ~3) | 2); + } /* * The BD ring replenish thresholds control how often the * hardware fetches new BD's from the producer rings in host @@ -2637,6 +2646,8 @@ bge_attach(device_t dev) case BGE_ASICREV_BCM5752: case BGE_ASICREV_BCM5906: sc->bge_flags |= BGE_FLAG_575X_PLUS; + if (sc->bge_asicrev == BGE_ASICREV_BCM5906) + sc->bge_flags |= BGE_FLAG_SHORT_DMA_BUG; /* FALLTHROUGH */ case BGE_ASICREV_BCM5705: sc->bge_flags |= BGE_FLAG_5705_PLUS; @@ -4064,6 +4075,39 @@ bge_cksum_pad(struct mbuf *m) } static struct mbuf * +bge_check_short_dma(struct mbuf *m) +{ + struct mbuf *n; + int found; + + /* + * If device receive two back-to-back send BDs with less than + * or equal to 8 total bytes then the device may hang. The two + * back-to-back send BDs must in the same frame for this failure + * to occur. Scan mbuf chains and see whether two back-to-back + * send BDs are there. If this is the case, allocate new mbuf + * and copy the frame to workaround the silicon bug. + */ + for (n = m, found = 0; n != NULL; n = n->m_next) { + if (n->m_len < 8) { + found++; + if (found > 1) + break; + continue; + } + found = 0; + } + + if (found > 1) { + n = m_defrag(m, M_DONTWAIT); + if (n == NULL) + m_freem(m); + } else + n = m; + return (n); +} + +static struct mbuf * bge_setup_tso(struct bge_softc *sc, struct mbuf *m, uint16_t *mss) { struct ip *ip; @@ -4136,6 +4180,13 @@ bge_encap(struct bge_softc *sc, struct m csum_flags = 0; mss = 0; vlan_tag = 0; + if ((sc->bge_flags & BGE_FLAG_SHORT_DMA_BUG) != 0 && + m->m_next != NULL) { + *m_head = bge_check_short_dma(m); + if (*m_head == NULL) + return (ENOBUFS); + m = *m_head; + } if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { *m_head = m = bge_setup_tso(sc, m, &mss); if (*m_head == NULL) Modified: stable/8/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/8/sys/dev/bge/if_bgereg.h Tue Nov 2 23:56:35 2010 (r214713) +++ stable/8/sys/dev/bge/if_bgereg.h Wed Nov 3 00:03:26 2010 (r214714) @@ -306,6 +306,7 @@ #define BGE_CHIPID_BCM5787_A0 0xb000 #define BGE_CHIPID_BCM5787_A1 0xb001 #define BGE_CHIPID_BCM5787_A2 0xb002 +#define BGE_CHIPID_BCM5906_A0 0xc000 #define BGE_CHIPID_BCM5906_A1 0xc001 #define BGE_CHIPID_BCM5906_A2 0xc002 #define BGE_CHIPID_BCM57780_A0 0x57780000 @@ -880,6 +881,7 @@ #define BGE_SDI_STATS_CTL 0x0C08 #define BGE_SDI_STATS_ENABLE_MASK 0x0C0C #define BGE_SDI_STATS_INCREMENT_MASK 0x0C10 +#define BGE_ISO_PKT_TX 0x0C20 #define BGE_LOCSTATS_COS0 0x0C80 #define BGE_LOCSTATS_COS1 0x0C84 #define BGE_LOCSTATS_COS2 0x0C88 @@ -2728,6 +2730,7 @@ struct bge_softc { #define BGE_FLAG_40BIT_BUG 0x01000000 #define BGE_FLAG_4G_BNDRY_BUG 0x02000000 #define BGE_FLAG_RX_ALIGNBUG 0x04000000 +#define BGE_FLAG_SHORT_DMA_BUG 0x08000000 uint32_t bge_phy_flags; #define BGE_PHY_WIRESPEED 0x00000001 #define BGE_PHY_ADC_BUG 0x00000002 From owner-svn-src-stable-8@FreeBSD.ORG Wed Nov 3 01:24:33 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 755B310657B9; Wed, 3 Nov 2010 01:24:33 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48A888FC18; Wed, 3 Nov 2010 01:24: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 oA31OX9M002400; Wed, 3 Nov 2010 01:24:33 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA31OXX5002398; Wed, 3 Nov 2010 01:24:33 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011030124.oA31OXX5002398@svn.freebsd.org> From: Pyun YongHyeon Date: Wed, 3 Nov 2010 01:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214717 - stable/8/sys/dev/fxp X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 01:24:33 -0000 Author: yongari Date: Wed Nov 3 01:24:33 2010 New Revision: 214717 URL: http://svn.freebsd.org/changeset/base/214717 Log: MFC r214302: Add TSO support over VLAN for i82550/i82551. Controller requires VLAN hardware tagging to make TSO work over VLAN. So if VLAN hardware tagging is disabled explicitly clear TSO over VLAN. While I'm here allow disabling VLAN TX checksum offloading. Tested by: Liudas < liudasb <> centras dot lt > Modified: stable/8/sys/dev/fxp/if_fxp.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/8/sys/dev/fxp/if_fxp.c Wed Nov 3 01:24:26 2010 (r214716) +++ stable/8/sys/dev/fxp/if_fxp.c Wed Nov 3 01:24:33 2010 (r214717) @@ -858,9 +858,9 @@ fxp_attach(device_t dev) ifp->if_capenable |= IFCAP_VLAN_MTU; /* the hw bits already set */ if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) { ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | - IFCAP_VLAN_HWCSUM; + IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO; ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | - IFCAP_VLAN_HWCSUM; + IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO; } /* @@ -2862,10 +2862,19 @@ fxp_ioctl(struct ifnet *ifp, u_long comm if (ifp->if_flags & IFF_UP) reinit++; } + if ((mask & IFCAP_VLAN_HWCSUM) != 0 && + (ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0) + ifp->if_capenable ^= IFCAP_VLAN_HWCSUM; + if ((mask & IFCAP_VLAN_HWTSO) != 0 && + (ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0) + ifp->if_capenable ^= IFCAP_VLAN_HWTSO; if ((mask & IFCAP_VLAN_HWTAGGING) != 0 && (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) { ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; - reinit++; + if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0) + ifp->if_capenable &= + ~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM); + reinit++; } if (reinit > 0 && ifp->if_flags & IFF_UP) fxp_init_body(sc); From owner-svn-src-stable-8@FreeBSD.ORG Wed Nov 3 01:28:09 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5C24106566B; Wed, 3 Nov 2010 01:28:09 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B8D818FC15; Wed, 3 Nov 2010 01:28: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 oA31S9XU002633; Wed, 3 Nov 2010 01:28:09 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA31S9dk002631; Wed, 3 Nov 2010 01:28:09 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011030128.oA31S9dk002631@svn.freebsd.org> From: Pyun YongHyeon Date: Wed, 3 Nov 2010 01:28:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214720 - stable/8/share/man/man4 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 01:28:10 -0000 Author: yongari Date: Wed Nov 3 01:28:09 2010 New Revision: 214720 URL: http://svn.freebsd.org/changeset/base/214720 Log: MFC r214432: Use shorten model name and add RTL8168, RTL8111 to the list of supported device. re(4) had been supported all variants of RTL8168, RTL8111 and RTL810x. I think this change will cover all controllers supported by re(4). Modified: stable/8/share/man/man4/re.4 Directory Properties: stable/8/share/man/man4/ (props changed) Modified: stable/8/share/man/man4/re.4 ============================================================================== --- stable/8/share/man/man4/re.4 Wed Nov 3 01:26:41 2010 (r214719) +++ stable/8/share/man/man4/re.4 Wed Nov 3 01:28:09 2010 (r214720) @@ -30,12 +30,12 @@ .\" .\" $FreeBSD$ .\" -.Dd February 9, 2009 +.Dd October 27, 2010 .Dt RE 4 .Os .Sh NAME .Nm re -.Nd "RealTek 8139C+/8169/816xS/811xS/8101E PCI/PCIe Ethernet adapter driver" +.Nd "RealTek 8139C+/8169/816xS/811xS/8168/810xE/8111 PCI/PCIe Ethernet adapter driver" .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -55,13 +55,13 @@ if_re_load="YES" The .Nm driver provides support for various NICs based on the RealTek RTL8139C+, -RTL8169, RTL8169S, RTL8110S, RTL8168S, RTL8111S and RTL8101E PCI and +RTL8169, RTL816xS, RTL811xS, RTL8168, RTL810xE and RTL8111 PCI and PCIe Ethernet controllers. .Pp -NICs based on the 8139C+ and 8101E are capable of 10 and 100Mbps speeds +NICs based on the 8139C+ and 810xE are capable of 10 and 100Mbps speeds over CAT5 cable. -NICs based on the 8169, 816xS and 811xS are capable of 10, 100 and -1000Mbps operation. +NICs based on the 8169, 816xS, 811xS, 8168 and 8111 are capable of 10, 100 +and 1000Mbps operation. .Pp All NICs supported by the .Nm @@ -72,8 +72,8 @@ capable of TCP large send (TCP segmentat .Pp The 8139C+ is a single-chip solution combining both a 10/100 MAC and PHY. The 8169 is a 10/100/1000 MAC only, requiring a GMII or TBI external PHY. -The 8169S and 8110S are single-chip devices containing both a 10/100/1000 -MAC and 10/100/1000 copper PHY. +The 816xS, 811xS, 8168 and 8111 are single-chip devices containing both a +10/100/1000 MAC and 10/100/1000 copper PHY. Standalone 10/100/1000 cards are available in both 32-bit PCI and 64-bit PCI models. The 8110S is designed for @@ -144,8 +144,8 @@ For more information on configuring this .Sh HARDWARE The .Nm -driver supports RealTek RTL8139C+, RTL8169, RTL816xS, RTL811xS, -and RTL8101E based Fast Ethernet and Gigabit Ethernet adapters including: +driver supports RealTek RTL8139C+, RTL8169, RTL816xS, RTL811xS, RTL8168, +RTL810xE and RTL8111 based Fast Ethernet and Gigabit Ethernet adapters including: .Pp .Bl -bullet -compact .It From owner-svn-src-stable-8@FreeBSD.ORG Wed Nov 3 01:32:39 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F0CA1065670; Wed, 3 Nov 2010 01:32:39 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 521978FC1D; Wed, 3 Nov 2010 01:32:39 +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 oA31Wd6x002916; Wed, 3 Nov 2010 01:32:39 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA31WdeD002914; Wed, 3 Nov 2010 01:32:39 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201011030132.oA31WdeD002914@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 3 Nov 2010 01:32:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214723 - stable/8/share/zoneinfo X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 01:32:39 -0000 Author: edwin Date: Wed Nov 3 01:32:39 2010 New Revision: 214723 URL: http://svn.freebsd.org/changeset/base/214723 Log: MFC of r214722, tzdata2010o: - Fiji goes into DST three weeks earlier in 2011. Modified: stable/8/share/zoneinfo/australasia Directory Properties: stable/8/share/zoneinfo/ (props changed) Modified: stable/8/share/zoneinfo/australasia ============================================================================== --- stable/8/share/zoneinfo/australasia Wed Nov 3 01:30:56 2010 (r214722) +++ stable/8/share/zoneinfo/australasia Wed Nov 3 01:32:39 2010 (r214723) @@ -1,5 +1,5 @@ #
-# @(#)australasia	8.18
+# @(#)australasia	8.20
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -284,13 +284,26 @@ Zone	Indian/Cocos	6:27:40	-	LMT	1900
 # http://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html
 # 
 
+# From Alexander Krivenyshev (2010-10-24):
+# According to Radio Fiji and Fiji Times online, Fiji will end DST 3 
+# weeks earlier than expected - on March 6, 2011, not March 27, 2011...
+# Here is confirmation from Government of the Republic of the Fiji Islands, 
+# Ministry of Information (fiji.gov.fj) web site:
+# 
+# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=2608:daylight-savings&catid=71:press-releases&Itemid=155
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_fiji04.html
+# 
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Fiji	1998	1999	-	Nov	Sun>=1	2:00	1:00	S
 Rule	Fiji	1999	2000	-	Feb	lastSun	3:00	0	-
 Rule	Fiji	2009	only	-	Nov	29	2:00	1:00	S
 Rule	Fiji	2010	only	-	Mar	lastSun	3:00	0	-
 Rule	Fiji	2010	only	-	Oct	24	2:00	1:00	S
-Rule	Fiji	2011	only	-	Mar	lastSun 3:00	0	-
+Rule	Fiji	2011	only	-	Mar	Sun>=1	3:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fiji	11:53:40 -	LMT	1915 Oct 26	# Suva
 			12:00	Fiji	FJ%sT	# Fiji Time
@@ -487,11 +500,21 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 # http://www.parliament.gov.ws/documents/acts/Daylight%20Saving%20Act%20%202009%20%28English%29%20-%20Final%207-7-091.pdf
 # 
 
+# From Raymond Hughes (2010-10-07):
+# Please see
+# 
+# http://www.mcil.gov.ws
+# ,
+# the Ministry of Commerce, Industry and Labour (sideframe) "Last Sunday
+# September 2010 (26/09/10) - adjust clocks forward from 12:00 midnight
+# to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks
+# backwards from 1:00am to 12:00am"
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
 			-11:00	-	WST	2010 Sep 26
-			-11:00	1:00	WSDT	2011 Apr 3
+			-11:00	1:00	WSDT	2011 Apr 3 1:00
 			-11:00	-	WST
 
 # Solomon Is

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 08:34:01 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2B747106564A;
	Wed,  3 Nov 2010 08:34:01 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F2C7A8FC18;
	Wed,  3 Nov 2010 08:34:00 +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 oA38Y0RA013031;
	Wed, 3 Nov 2010 08:34:00 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA38Y0IC013029;
	Wed, 3 Nov 2010 08:34:00 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011030834.oA38Y0IC013029@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 08:34:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214727 - stable/8/sys/nfsserver
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 08:34:01 -0000

Author: kib
Date: Wed Nov  3 08:34:00 2010
New Revision: 214727
URL: http://svn.freebsd.org/changeset/base/214727

Log:
  MFC r214049:
  When readdirplus() is handled on the exported filesystem that does
  not support VFS_VGET, like msdosfs, do not call VOP_LOOKUP() for
  dotdot on the root directory. Our filesystems expect that VFS handles
  dotdot lookups on root on its own.

Modified:
  stable/8/sys/nfsserver/nfs_serv.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/nfsserver/nfs_serv.c
==============================================================================
--- stable/8/sys/nfsserver/nfs_serv.c	Wed Nov  3 07:51:33 2010	(r214726)
+++ stable/8/sys/nfsserver/nfs_serv.c	Wed Nov  3 08:34:00 2010	(r214727)
@@ -3036,7 +3036,7 @@ nfsrv_readdirplus(struct nfsrv_descript 
 	struct iovec iv;
 	struct vattr va, at, *vap = &va;
 	struct nfs_fattr *fp;
-	int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1;
+	int len, nlen, rem, xfer, tsiz, i, error = 0, error1, getret = 1;
 	int siz, cnt, fullsiz, eofflag, rdonly, dirlen, ncookies;
 	u_quad_t off, toff, verf;
 	u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
@@ -3240,24 +3240,25 @@ again:
 				}
 				if (!VOP_ISLOCKED(vp))
 					vn_lock(vp, LK_SHARED | LK_RETRY);
-				if (VOP_LOOKUP(vp, &nvp, &cn) != 0)
+				if ((vp->v_vflag & VV_ROOT) != 0 &&
+				    (cn.cn_flags & ISDOTDOT) != 0) {
+					vref(vp);
+					nvp = vp;
+				} else if (VOP_LOOKUP(vp, &nvp, &cn) != 0)
 					goto invalid;
 			}
 
 			bzero((caddr_t)nfhp, NFSX_V3FH);
 			nfhp->fh_fsid = nvp->v_mount->mnt_stat.f_fsid;
-			if (VOP_VPTOFH(nvp, &nfhp->fh_fid)) {
+			if ((error1 = VOP_VPTOFH(nvp, &nfhp->fh_fid)) == 0)
+				error1 = VOP_GETATTR(nvp, vap, cred);
+			if (vp == nvp)
+				vunref(nvp);
+			else
 				vput(nvp);
-				nvp = NULL;
-				goto invalid;
-			}
-			if (VOP_GETATTR(nvp, vap, cred)) {
-				vput(nvp);
-				nvp = NULL;
-				goto invalid;
-			}
-			vput(nvp);
 			nvp = NULL;
+			if (error1 != 0)
+				goto invalid;
 
 			/*
 			 * If either the dircount or maxcount will be

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 10:10:34 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 920F01065670;
	Wed,  3 Nov 2010 10:10:34 +0000 (UTC)
	(envelope-from edwin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7F7EE8FC15;
	Wed,  3 Nov 2010 10:10:34 +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 oA3AAYck015350;
	Wed, 3 Nov 2010 10:10:34 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3AAYjl015348;
	Wed, 3 Nov 2010 10:10:34 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201011031010.oA3AAYjl015348@svn.freebsd.org>
From: Edwin Groothuis 
Date: Wed, 3 Nov 2010 10:10:34 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214729 - stable/8/usr.bin/uudecode
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 10:10:34 -0000

Author: edwin
Date: Wed Nov  3 10:10:34 2010
New Revision: 214729
URL: http://svn.freebsd.org/changeset/base/214729

Log:
  MFC of r214002, r214010
  
  - Stylify of uudecode(1)
    Part of PR bin/124739.
  
  - "b64decode -r" did not handle arbitary breaks in base64 encoded
    data. White space should be accepted anywhere in a base64 encoded
    stream, not just after every chunk (4 characters).
  
    Test-scenario:
  
    VmVsb2NpdHkgUmV3YXJkcw==
  
    and
  
    VmVsb2NpdHkgUmV3YXJkcw
    ==
  
    should both produce "Velocity Rewards"
  
  PR:		bin/124739
  Submitted by:	Mark Andrews 

Modified:
  stable/8/usr.bin/uudecode/uudecode.c
Directory Properties:
  stable/8/usr.bin/uudecode/   (props changed)

Modified: stable/8/usr.bin/uudecode/uudecode.c
==============================================================================
--- stable/8/usr.bin/uudecode/uudecode.c	Wed Nov  3 09:23:08 2010	(r214728)
+++ stable/8/usr.bin/uudecode/uudecode.c	Wed Nov  3 10:10:34 2010	(r214729)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -87,7 +88,7 @@ main(int argc, char *argv[])
 		base64 = 1;
 
 	while ((ch = getopt(argc, argv, "cimo:prs")) != -1) {
-		switch(ch) {
+		switch (ch) {
 		case 'c':
 			if (oflag || rflag)
 				usage();
@@ -125,10 +126,10 @@ main(int argc, char *argv[])
 			usage();
 		}
 	}
-        argc -= optind;
-        argv += optind;
+	argc -= optind;
+	argv += optind;
 
-	if (*argv) {
+	if (*argv != NULL) {
 		rval = 0;
 		do {
 			infp = fopen(infile = *argv, "r");
@@ -184,7 +185,7 @@ decode2(void)
 	void *handle;
 	struct passwd *pw;
 	struct stat st;
-	char buf[MAXPATHLEN+1];
+	char buf[MAXPATHLEN + 1];
 
 	base64 = 0;
 	/* search for header line */
@@ -259,7 +260,7 @@ decode2(void)
 	if (pflag || strcmp(outfile, "/dev/stdout") == 0)
 		outfp = stdout;
 	else {
-		flags = O_WRONLY|O_CREAT|O_EXCL;
+		flags = O_WRONLY | O_CREAT | O_EXCL;
 		if (lstat(outfile, &st) == 0) {
 			if (iflag) {
 				warnc(EEXIST, "%s: %s", infile, outfile);
@@ -305,6 +306,7 @@ decode2(void)
 static int
 getline(char *buf, size_t size)
 {
+
 	if (fgets(buf, size, infp) != NULL)
 		return (2);
 	if (rflag)
@@ -341,17 +343,19 @@ uu_decode(void)
 	/* for each input line */
 	for (;;) {
 		switch (getline(buf, sizeof(buf))) {
-		case 0: return (0);
-		case 1: return (1);
+		case 0:
+			return (0);
+		case 1:
+			return (1);
 		}
 
-#define	DEC(c)	(((c) - ' ') & 077)		/* single character decode */
-#define IS_DEC(c) ( (((c) - ' ') >= 0) && (((c) - ' ') <= 077 + 1) )
+#define	DEC(c)		(((c) - ' ') & 077)	/* single character decode */
+#define IS_DEC(c)	 ( (((c) - ' ') >= 0) && (((c) - ' ') <= 077 + 1) )
 
 #define OUT_OF_RANGE do {						\
 	warnx("%s: %s: character out of range: [%d-%d]",		\
 	    infile, outfile, 1 + ' ', 077 + ' ' + 1);			\
-        return (1);							\
+	return (1);							\
 } while (0)
 
 		/*
@@ -364,8 +368,8 @@ uu_decode(void)
 		for (++p; i > 0; p += 4, i -= 3)
 			if (i >= 3) {
 				if (!(IS_DEC(*p) && IS_DEC(*(p + 1)) &&
-				     IS_DEC(*(p + 2)) && IS_DEC(*(p + 3))))
-                                	OUT_OF_RANGE;
+				    IS_DEC(*(p + 2)) && IS_DEC(*(p + 3))))
+					OUT_OF_RANGE;
 
 				ch = DEC(p[0]) << 2 | DEC(p[1]) >> 4;
 				putc(ch, outfp);
@@ -373,8 +377,7 @@ uu_decode(void)
 				putc(ch, outfp);
 				ch = DEC(p[2]) << 6 | DEC(p[3]);
 				putc(ch, outfp);
-			}
-			else {
+			} else {
 				if (i >= 1) {
 					if (!(IS_DEC(*p) && IS_DEC(*(p + 1))))
 	                                	OUT_OF_RANGE;
@@ -383,56 +386,85 @@ uu_decode(void)
 				}
 				if (i >= 2) {
 					if (!(IS_DEC(*(p + 1)) &&
-						IS_DEC(*(p + 2))))
-		                                OUT_OF_RANGE;
+					    IS_DEC(*(p + 2))))
+						OUT_OF_RANGE;
 
 					ch = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
 					putc(ch, outfp);
 				}
 				if (i >= 3) {
 					if (!(IS_DEC(*(p + 2)) &&
-						IS_DEC(*(p + 3))))
-		                                OUT_OF_RANGE;
+					    IS_DEC(*(p + 3))))
+						OUT_OF_RANGE;
 					ch = DEC(p[2]) << 6 | DEC(p[3]);
 					putc(ch, outfp);
 				}
 			}
 	}
 	switch (getline(buf, sizeof(buf))) {
-	case 0:  return (0);
-	case 1:  return (1);
-	default: return (checkend(buf, "end", "no \"end\" line"));
+	case 0:
+		return (0);
+	case 1:
+		return (1);
+	default:
+		return (checkend(buf, "end", "no \"end\" line"));
 	}
 }
 
 static int
 base64_decode(void)
 {
-	int n;
-	char inbuf[MAXPATHLEN+1];
+	int n, count, count4;
+	char inbuf[MAXPATHLEN + 1], *p;
 	unsigned char outbuf[MAXPATHLEN * 4];
+	char leftover[MAXPATHLEN + 1];
 
+	leftover[0] = '\0';
 	for (;;) {
-		switch (getline(inbuf, sizeof(inbuf))) {
-		case 0: return (0);
-		case 1: return (1);
+		strcpy(inbuf, leftover);
+		switch (getline(inbuf + strlen(inbuf),
+		    sizeof(inbuf) - strlen(inbuf))) {
+		case 0:
+			return (0);
+		case 1:
+			return (1);
 		}
+
+		count = 0;
+		count4 = -1;
+		p = inbuf;
+		while (*p != '\0') {
+			/*
+			 * Base64 encoded strings have the following
+			 * characters in them: A-Z, a-z, 0-9 and +, / and =
+			 */
+			if (isalnum(*p) || *p == '+' || *p == '/' || *p == '=')
+				count++;
+			if (count % 4 == 0)
+				count4 = p - inbuf;
+			p++;
+		}
+
+		strcpy(leftover, inbuf + count4 + 1);
+		inbuf[count4 + 1] = 0;
+
 		n = b64_pton(inbuf, outbuf, sizeof(outbuf));
+
 		if (n < 0)
 			break;
 		fwrite(outbuf, 1, n, outfp);
 	}
-	return (checkend(inbuf, "====",
-		    "error decoding base64 input stream"));
+	return (checkend(inbuf, "====", "error decoding base64 input stream"));
 }
 
 static void
 usage(void)
 {
+
 	(void)fprintf(stderr,
-"usage: uudecode [-cimprs] [file ...]\n"
-"       uudecode [-i] -o output_file [file]\n"
-"       b64decode [-cimprs] [file ...]\n"
-"       b64decode [-i] -o output_file [file]\n");
+	    "usage: uudecode [-cimprs] [file ...]\n"
+	    "       uudecode [-i] -o output_file [file]\n"
+	    "       b64decode [-cimprs] [file ...]\n"
+	    "       b64decode [-i] -o output_file [file]\n");
 	exit(1);
 }

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 10:23:06 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 933CF106564A;
	Wed,  3 Nov 2010 10:23:06 +0000 (UTC) (envelope-from ed@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 816518FC17;
	Wed,  3 Nov 2010 10:23:06 +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 oA3AN6Z7015785;
	Wed, 3 Nov 2010 10:23:06 GMT (envelope-from ed@svn.freebsd.org)
Received: (from ed@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3AN6AY015783;
	Wed, 3 Nov 2010 10:23:06 GMT (envelope-from ed@svn.freebsd.org)
Message-Id: <201011031023.oA3AN6AY015783@svn.freebsd.org>
From: Ed Schouten 
Date: Wed, 3 Nov 2010 10:23:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214731 - stable/8/usr.bin/truss
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 10:23:06 -0000

Author: ed
Date: Wed Nov  3 10:23:06 2010
New Revision: 214731
URL: http://svn.freebsd.org/changeset/base/214731

Log:
  MFC r214105:
  
    Remove setpgid() call before executing child process.
  
    Using a separate process group here is bad, since (for example) job
    control in the TTY layer prevents interaction with the TTY, causing the
    child process to hang.

Modified:
  stable/8/usr.bin/truss/setup.c
Directory Properties:
  stable/8/usr.bin/truss/   (props changed)

Modified: stable/8/usr.bin/truss/setup.c
==============================================================================
--- stable/8/usr.bin/truss/setup.c	Wed Nov  3 10:12:13 2010	(r214730)
+++ stable/8/usr.bin/truss/setup.c	Wed Nov  3 10:23:06 2010	(r214731)
@@ -78,7 +78,6 @@ setup_and_wait(char *command[])
 	}
 	if (pid == 0) {	/* Child */
 		ptrace(PT_TRACE_ME, 0, 0, 0);
-		setpgid (0, 0); 
 		execvp(command[0], command);
 		err(1, "execvp %s", command[0]);
 	}

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 15:24:26 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4CEE61065672;
	Wed,  3 Nov 2010 15:24:26 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3AAE98FC19;
	Wed,  3 Nov 2010 15:24:26 +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 oA3FOQJF024819;
	Wed, 3 Nov 2010 15:24:26 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FOQu1024817;
	Wed, 3 Nov 2010 15:24:26 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201011031524.oA3FOQu1024817@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Wed, 3 Nov 2010 15:24:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214741 - stable/8/sys/powerpc/aim
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 15:24:26 -0000

Author: nwhitehorn
Date: Wed Nov  3 15:24:25 2010
New Revision: 214741
URL: http://svn.freebsd.org/changeset/base/214741

Log:
  MFC r214601:
  Add some missing parentheses so that moea_bat_mapped() actually works.
  
  Submitted by:	alc

Modified:
  stable/8/sys/powerpc/aim/mmu_oea.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- stable/8/sys/powerpc/aim/mmu_oea.c	Wed Nov  3 15:22:09 2010	(r214740)
+++ stable/8/sys/powerpc/aim/mmu_oea.c	Wed Nov  3 15:24:25 2010	(r214741)
@@ -2381,7 +2381,7 @@ moea_bat_mapped(int idx, vm_offset_t pa,
 	/*
 	 * Return immediately if not a valid mapping
 	 */
-	if (!battable[idx].batu & BAT_Vs)
+	if (!(battable[idx].batu & BAT_Vs))
 		return (EINVAL);
 
 	/*

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 15:25:30 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B09741065679;
	Wed,  3 Nov 2010 15:25:30 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9D6AC8FC12;
	Wed,  3 Nov 2010 15:25:30 +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 oA3FPUcf024902;
	Wed, 3 Nov 2010 15:25:30 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FPUuX024894;
	Wed, 3 Nov 2010 15:25:30 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011031525.oA3FPUuX024894@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 3 Nov 2010 15:25:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214742 - stable/8/usr.sbin/mfiutil
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 15:25:30 -0000

Author: jhb
Date: Wed Nov  3 15:25:30 2010
New Revision: 214742
URL: http://svn.freebsd.org/changeset/base/214742

Log:
  MFC 213672,213674,214396:
  - Report subcommand handler errors in mfiutil so that tools that
    invoke the utilities can robustly report errors.
  - Fix compile with -DDEBUG by using the correct mfi_pd_ref union definition
    in mfireg.h.
  - Save errno values before calling warn(3) so that errors are correctly
    reported.
  - Use powerof2() from  rather than a copy and paste version.

Modified:
  stable/8/usr.sbin/mfiutil/mfi_config.c
  stable/8/usr.sbin/mfiutil/mfi_drive.c
  stable/8/usr.sbin/mfiutil/mfi_evt.c
  stable/8/usr.sbin/mfiutil/mfi_flash.c
  stable/8/usr.sbin/mfiutil/mfi_patrol.c
  stable/8/usr.sbin/mfiutil/mfi_show.c
  stable/8/usr.sbin/mfiutil/mfi_volume.c
  stable/8/usr.sbin/mfiutil/mfiutil.c
Directory Properties:
  stable/8/usr.sbin/mfiutil/   (props changed)
  stable/8/usr.sbin/mfiutil/mfiutil.8   (props changed)

Modified: stable/8/usr.sbin/mfiutil/mfi_config.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_config.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_config.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -29,12 +29,12 @@
  * $FreeBSD$
  */
 
-#include 
+#include 
 #ifdef DEBUG
 #include 
 #endif
-#include 
 #include 
+#include 
 #include 
 #ifdef DEBUG
 #include 
@@ -52,8 +52,6 @@ static void	dump_config(int fd, struct m
 static int	add_spare(int ac, char **av);
 static int	remove_spare(int ac, char **av);
 
-#define powerof2(x)    ((((x)-1)&(x))==0)
-
 static long
 dehumanize(const char *value)
 {
@@ -151,13 +149,14 @@ static int
 clear_config(int ac, char **av)
 {
 	struct mfi_ld_list list;
-	int ch, fd;
+	int ch, error, fd;
 	u_int i;
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (!mfi_reconfig_supported()) {
@@ -167,8 +166,9 @@ clear_config(int ac, char **av)
 	}
 
 	if (mfi_ld_get_list(fd, &list, NULL) < 0) {
+		error = errno;
 		warn("Failed to get volume list");
-		return (errno);
+		return (error);
 	}
 
 	for (i = 0; i < list.ld_count; i++) {
@@ -189,8 +189,9 @@ clear_config(int ac, char **av)
 	}
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_CLEAR, NULL, 0, NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to clear configuration");
-		return (errno);
+		return (error);
 	}
 
 	printf("mfi%d: Configuration cleared\n", mfi_unit);
@@ -335,8 +336,9 @@ parse_array(int fd, int raid_type, char 
 			return (error);
 
 		if (mfi_pd_get_info(fd, device_id, pinfo, NULL) < 0) {
+			error = errno;
 			warn("Failed to fetch drive info for drive %s", cp);
-			return (errno);
+			return (error);
 		}
 
 		if (pinfo->fw_state != MFI_PD_STATE_UNCONFIGURED_GOOD) {
@@ -548,8 +550,9 @@ create_volume(int ac, char **av)
 	
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (!mfi_reconfig_supported()) {
@@ -660,8 +663,9 @@ create_volume(int ac, char **av)
 	 * array and volume identifiers.
 	 */
 	if (mfi_config_read(fd, &config) < 0) {
+		error = errno;
 		warn("Failed to read configuration");
-		return (errno);
+		return (error);
 	}
 	p = (char *)config->array;
 	state.array_ref = 0xffff;
@@ -745,14 +749,14 @@ create_volume(int ac, char **av)
 #ifdef DEBUG
 	if (dump)
 		dump_config(fd, config);
-	else
 #endif
 
 	/* Send the new config to the controller. */
 	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_ADD, config, config_size,
 	    NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to add volume");
-		return (errno);
+		return (error);
 	}
 
 	/* Clean up. */
@@ -774,7 +778,7 @@ static int
 delete_volume(int ac, char **av)
 {
 	struct mfi_ld_info info;
-	int fd;
+	int error, fd;
 	uint8_t target_id, mbox[4];
 
 	/*
@@ -799,8 +803,9 @@ delete_volume(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (!mfi_reconfig_supported()) {
@@ -810,13 +815,15 @@ delete_volume(int ac, char **av)
 	}
 
 	if (mfi_lookup_volume(fd, av[1], &target_id) < 0) {
+		error = errno;
 		warn("Invalid volume %s", av[1]);
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_ld_get_info(fd, target_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to get info for volume %d", target_id);
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_volume_busy(fd, target_id)) {
@@ -828,8 +835,9 @@ delete_volume(int ac, char **av)
 	mbox_store_ldref(mbox, &info.ld_config.properties.ld);
 	if (mfi_dcmd_command(fd, MFI_DCMD_LD_DELETE, NULL, 0, mbox,
 	    sizeof(mbox), NULL) < 0) {
+		error = errno;
 		warn("Failed to delete volume");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -858,8 +866,9 @@ add_spare(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -867,8 +876,9 @@ add_spare(int ac, char **av)
 		return (error);
 
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch drive info");
-		return (errno);
+		return (error);
 	}
 
 	if (info.fw_state != MFI_PD_STATE_UNCONFIGURED_GOOD) {
@@ -878,14 +888,16 @@ add_spare(int ac, char **av)
 
 	if (ac > 2) {
 		if (mfi_lookup_volume(fd, av[2], &target_id) < 0) {
+			error = errno;
 			warn("Invalid volume %s", av[2]);
-			return (errno);
+			return (error);
 		}
 	}
 
 	if (mfi_config_read(fd, &config) < 0) {
+		error = errno;
 		warn("Failed to read configuration");
-		return (errno);
+		return (error);
 	}
 
 	spare = malloc(sizeof(struct mfi_spare) + sizeof(uint16_t) *
@@ -939,8 +951,9 @@ add_spare(int ac, char **av)
 	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_MAKE_SPARE, spare,
 	    sizeof(struct mfi_spare) + sizeof(uint16_t) * spare->array_count,
 	    NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to assign spare");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -964,8 +977,9 @@ remove_spare(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -974,8 +988,9 @@ remove_spare(int ac, char **av)
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 
 	if (info.fw_state != MFI_PD_STATE_HOT_SPARE) {
@@ -986,8 +1001,9 @@ remove_spare(int ac, char **av)
 	mbox_store_pdref(mbox, &info.ref);
 	if (mfi_dcmd_command(fd, MFI_DCMD_CFG_REMOVE_SPARE, NULL, 0, mbox,
 	    sizeof(mbox), NULL) < 0) {
+		error = errno;
 		warn("Failed to delete spare");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -1024,7 +1040,7 @@ dump_config(int fd, struct mfi_config_da
 		    ar->num_drives);
 		printf("      size = %ju\n", (uintmax_t)ar->size);
 		for (j = 0; j < ar->num_drives; j++) {
-			device_id = ar->pd[j].ref.device_id;
+			device_id = ar->pd[j].ref.v.device_id;
 			if (device_id == 0xffff)
 				printf("        drive MISSING\n");
 			else {
@@ -1080,7 +1096,7 @@ dump_config(int fd, struct mfi_config_da
 		sp = (struct mfi_spare *)p;
 		printf("    %s spare %u ",
 		    sp->spare_type & MFI_SPARE_DEDICATED ? "dedicated" :
-		    "global", sp->ref.device_id);
+		    "global", sp->ref.v.device_id);
 		printf("%s", mfi_pdstate(MFI_PD_STATE_HOT_SPARE));
 		printf(" backs:\n");
 		for (j = 0; j < sp->array_count; j++)
@@ -1093,7 +1109,7 @@ static int
 debug_config(int ac, char **av)
 {
 	struct mfi_config_data *config;
-	int fd;
+	int error, fd;
 
 	if (ac != 1) {
 		warnx("debug: extra arguments");
@@ -1102,14 +1118,16 @@ debug_config(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	/* Get the config from the controller. */
 	if (mfi_config_read(fd, &config) < 0) {
+		error = errno;
 		warn("Failed to get config");
-		return (errno);
+		return (error);
 	}
 
 	/* Dump out the configuration. */
@@ -1127,7 +1145,7 @@ dump(int ac, char **av)
 	struct mfi_config_data *config;
 	char buf[64];
 	size_t len;
-	int fd;
+	int error, fd;
 
 	if (ac != 1) {
 		warnx("dump: extra arguments");
@@ -1136,23 +1154,26 @@ dump(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	/* Get the stashed copy of the last dcmd from the driver. */
 	snprintf(buf, sizeof(buf), "dev.mfi.%d.debug_command", mfi_unit);
 	if (sysctlbyname(buf, NULL, &len, NULL, 0) < 0) {
+		error = errno;
 		warn("Failed to read debug command");
-		if (errno == ENOENT)
-			errno = EOPNOTSUPP;
-		return (errno);
+		if (error == ENOENT)
+			error = EOPNOTSUPP;
+		return (error);
 	}
 
 	config = malloc(len);
 	if (sysctlbyname(buf, config, &len, NULL, 0) < 0) {
+		error = errno;
 		warn("Failed to read debug command");
-		return (errno);
+		return (error);
 	}
 	dump_config(fd, config);
 	free(config);

Modified: stable/8/usr.sbin/mfiutil/mfi_drive.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_drive.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_drive.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -79,10 +79,11 @@ int
 mfi_lookup_drive(int fd, char *drive, uint16_t *device_id)
 {
 	struct mfi_pd_list *list;
-	uint8_t encl, slot;
 	long val;
+	int error;
 	u_int i;
 	char *cp;
+	uint8_t encl, slot;
 
 	/* Look for a raw device id first. */
 	val = strtol(drive, &cp, 0);
@@ -118,8 +119,9 @@ mfi_lookup_drive(int fd, char *drive, ui
 		slot = val;
 
 		if (mfi_pd_get_list(fd, &list, NULL) < 0) {
+			error = errno;
 			warn("Failed to fetch drive list");
-			return (errno);
+			return (error);
 		}
 
 		for (i = 0; i < list->count; i++) {
@@ -302,8 +304,9 @@ drive_set_state(char *drive, uint16_t ne
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, drive, &device_id);
@@ -312,8 +315,9 @@ drive_set_state(char *drive, uint16_t ne
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 
 	/* Try to change the state. */
@@ -327,9 +331,10 @@ drive_set_state(char *drive, uint16_t ne
 	mbox[5] = new_state >> 8;
 	if (mfi_dcmd_command(fd, MFI_DCMD_PD_STATE_SET, NULL, 0, mbox, 6,
 	    NULL) < 0) {
+		error = errno;
 		warn("Failed to set drive %u to %s", device_id,
 		    mfi_pdstate(new_state));
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -395,8 +400,9 @@ start_rebuild(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -405,13 +411,14 @@ start_rebuild(int ac, char **av)
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 
 	/* Check the state, must be REBUILD. */
 	if (info.fw_state != MFI_PD_STATE_REBUILD) {
-		warn("Drive %d is not in the REBUILD state", device_id);
+		warnx("Drive %d is not in the REBUILD state", device_id);
 		return (EINVAL);
 	}
 
@@ -419,8 +426,9 @@ start_rebuild(int ac, char **av)
 	mbox_store_pdref(&mbox[0], &info.ref);
 	if (mfi_dcmd_command(fd, MFI_DCMD_PD_REBUILD_START, NULL, 0, mbox, 4,
 	    NULL) < 0) {
+		error = errno;
 		warn("Failed to start rebuild on drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 	close(fd);
 
@@ -444,8 +452,9 @@ abort_rebuild(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -454,8 +463,9 @@ abort_rebuild(int ac, char **av)
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 
 	/* Check the state, must be REBUILD. */
@@ -468,8 +478,9 @@ abort_rebuild(int ac, char **av)
 	mbox_store_pdref(&mbox[0], &info.ref);
 	if (mfi_dcmd_command(fd, MFI_DCMD_PD_REBUILD_ABORT, NULL, 0, mbox, 4,
 	    NULL) < 0) {
+		error = errno;
 		warn("Failed to abort rebuild on drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 	close(fd);
 
@@ -492,8 +503,9 @@ drive_progress(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -502,8 +514,9 @@ drive_progress(int ac, char **av)
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 	close(fd);
 
@@ -551,8 +564,9 @@ drive_clear(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -561,16 +575,18 @@ drive_clear(int ac, char **av)
 
 	/* Get the info for this drive. */
 	if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to fetch info for drive %u", device_id);
-		return (errno);
+		return (error);
 	}
 
 	mbox_store_pdref(&mbox[0], &info.ref);
 	if (mfi_dcmd_command(fd, opcode, NULL, 0, mbox, 4, NULL) < 0) {
+		error = errno;
 		warn("Failed to %s clear on drive %u",
 		    opcode == MFI_DCMD_PD_CLEAR_START ? "start" : "stop",
 		    device_id);
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -604,8 +620,9 @@ drive_locate(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	error = mfi_lookup_drive(fd, av[1], &device_id);
@@ -617,10 +634,11 @@ drive_locate(int ac, char **av)
 	mbox[2] = 0;
 	mbox[3] = 0;
 	if (mfi_dcmd_command(fd, opcode, NULL, 0, mbox, 4, NULL) < 0) {
+		error = errno;
 		warn("Failed to %s locate on drive %u",
 		    opcode == MFI_DCMD_PD_LOCATE_START ? "start" : "stop",
 		    device_id);
-		return (errno);
+		return (error);
 	}
 	close(fd);
 

Modified: stable/8/usr.sbin/mfiutil/mfi_evt.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_evt.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_evt.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -32,7 +32,6 @@
 #include 
 #include 
 #include 
-//#include 
 #include 
 #include 
 #include 
@@ -67,7 +66,7 @@ static int
 show_logstate(int ac, char **av)
 {
 	struct mfi_evt_log_state info;
-	int fd;
+	int error, fd;
 
 	if (ac != 1) {
 		warnx("show logstate: extra arguments");
@@ -76,13 +75,15 @@ show_logstate(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_event_get_info(fd, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to get event log info");
-		return (errno);
+		return (error);
 	}
 
 	printf("mfi%d Event Log Sequence Numbers:\n", mfi_unit);
@@ -536,18 +537,20 @@ show_events(int ac, char **av)
 	ssize_t size;
 	uint32_t seq, start, stop;
 	uint8_t status;
-	int ch, fd, num_events, verbose;
+	int ch, error, fd, num_events, verbose;
 	u_int i;
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_event_get_info(fd, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to get event log info");
-		return (errno);
+		return (error);
 	}
 
 	/* Default settings. */
@@ -565,14 +568,16 @@ show_events(int ac, char **av)
 		switch (ch) {
 		case 'c':
 			if (parse_class(optarg, &filter.members.class) < 0) {
+				error = errno;
 				warn("Error parsing event class");
-				return (errno);
+				return (error);
 			}
 			break;
 		case 'l':
 			if (parse_locale(optarg, &filter.members.locale) < 0) {
+				error = errno;
 				warn("Error parsing event locale");
-				return (errno);
+				return (error);
 			}
 			break;
 		case 'n':
@@ -608,20 +613,23 @@ show_events(int ac, char **av)
 		return (EINVAL);
 	}
 	if (ac > 0 && parse_seq(&info, av[0], &start) < 0) {
+		error = errno;
 		warn("Error parsing starting sequence number");
-		return (errno);
+		return (error);
 	}
 	if (ac > 1 && parse_seq(&info, av[1], &stop) < 0) {
+		error = errno;
 		warn("Error parsing ending sequence number");
-		return (errno);
+		return (error);
 	}
 
 	list = malloc(size);
 	for (seq = start;;) {
 		if (mfi_get_events(fd, list, num_events, filter, seq,
 		    &status) < 0) {
+			error = errno;
 			warn("Failed to fetch events");
-			return (errno);
+			return (error);
 		}
 		if (status == MFI_STAT_NOT_FOUND) {
 			if (seq == start)

Modified: stable/8/usr.sbin/mfiutil/mfi_flash.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_flash.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_flash.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -72,16 +72,18 @@ display_firmware(struct mfi_info_compone
 	    fw_time_width, comp->build_time);
 }
 
-static void
+static int
 display_pending_firmware(int fd)
 {
 	struct mfi_ctrl_info info;
 	struct mfi_info_component header;
+	int error;
 	u_int i;
 
 	if (mfi_ctrl_get_info(fd, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to get controller info");
-		return;
+		return (error);
 	}
 
 	printf("mfi%d Pending Firmware Images:\n", mfi_unit);
@@ -97,6 +99,8 @@ display_pending_firmware(int fd)
 	display_firmware(&header);
 	for (i = 0; i < info.pending_image_component_count; i++)
 		display_firmware(&info.pending_image_component[i]);
+
+	return (0);
 }
 
 static void
@@ -117,7 +121,7 @@ flash_adapter(int ac, char **av)
 	size_t nread;
 	char *buf;
 	struct stat sb;
-	int fd, flash;
+	int error, fd, flash;
 	uint8_t mbox[4], status;
 
 	if (ac != 2) {
@@ -127,13 +131,15 @@ flash_adapter(int ac, char **av)
 
 	flash = open(av[1], O_RDONLY);
 	if (flash < 0) {
+		error = errno;
 		warn("flash: Failed to open %s", av[1]);
-		return (errno);
+		return (error);
 	}
 
 	if (fstat(flash, &sb) < 0) {
+		error = errno;
 		warn("fstat(%s)", av[1]);
-		return (errno);
+		return (error);
 	}
 	if (sb.st_size % 1024 != 0 || sb.st_size > 0x7fffffff) {
 		warnx("Invalid flash file size");
@@ -142,8 +148,9 @@ flash_adapter(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	/* First, ask the firmware to allocate space for the flash file. */
@@ -190,10 +197,10 @@ flash_adapter(int ac, char **av)
 		return (ENXIO);
 	}
 	printf("finished\n");
-	display_pending_firmware(fd);
+	error = display_pending_firmware(fd);
 
 	close(fd);
 
-	return (0);
+	return (error);
 }
 MFI_COMMAND(top, flash, flash_adapter);

Modified: stable/8/usr.sbin/mfiutil/mfi_patrol.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_patrol.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_patrol.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -62,11 +62,13 @@ mfi_get_time(int fd, uint32_t *at)
 static int
 patrol_get_props(int fd, struct mfi_pr_properties *prop)
 {
+	int error;
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_PR_GET_PROPERTIES, prop,
 	    sizeof(*prop), NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to get patrol read properties");
-		return (-1);
+		return (error);
 	}
 	return (0);
 }
@@ -81,19 +83,21 @@ show_patrol(int ac, char **av)
 	char label[16];
 	time_t now;
 	uint32_t at;
-	int fd;
+	int error, fd;
 	u_int i;
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	time(&now);
 	mfi_get_time(fd, &at);
-	if (patrol_get_props(fd, &prop) < 0)
-		return (errno);
+	error = patrol_get_props(fd, &prop);
+	if (error)
+		return (error);
 	printf("Operation Mode: ");
 	switch (prop.op_mode) {
 	case MFI_PR_OPMODE_AUTO:
@@ -122,8 +126,9 @@ show_patrol(int ac, char **av)
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_PR_GET_STATUS, &status,
 	    sizeof(status), NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to get patrol read properties");
-		return (errno);
+		return (error);
 	}
 	printf("Runs Completed: %u\n", status.num_iteration);
 	printf("Current State: ");
@@ -146,8 +151,9 @@ show_patrol(int ac, char **av)
 	}
 	if (status.state == MFI_PR_STATE_ACTIVE) {
 		if (mfi_pd_get_list(fd, &list, NULL) < 0) {
+			error = errno;
 			warn("Failed to get drive list");
-			return (errno);
+			return (error);
 		}
 
 		for (i = 0; i < list->count; i++) {
@@ -156,9 +162,10 @@ show_patrol(int ac, char **av)
 
 			if (mfi_pd_get_info(fd, list->addr[i].device_id, &info,
 			    NULL) < 0) {
+				error = errno;
 				warn("Failed to fetch info for drive %u",
 				    list->addr[i].device_id);
-				return (errno);
+				return (error);
 			}
 			if (info.prog_info.active & MFI_PD_PROGRESS_PATROL) {
 				snprintf(label, sizeof(label), "    Drive %u",
@@ -178,18 +185,20 @@ MFI_COMMAND(show, patrol, show_patrol);
 static int
 start_patrol(int ac, char **av)
 {
-	int fd;
+	int error, fd;
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_PR_START, NULL, 0, NULL, 0, NULL) <
 	    0) {
+		error = errno;
 		warn("Failed to start patrol read");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -201,18 +210,20 @@ MFI_COMMAND(start, patrol, start_patrol)
 static int
 stop_patrol(int ac, char **av)
 {
-	int fd;
+	int error, fd;
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_PR_STOP, NULL, 0, NULL, 0, NULL) <
 	    0) {
+		error = errno;
 		warn("Failed to stop patrol read");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);
@@ -227,10 +238,10 @@ patrol_config(int ac, char **av)
 	struct mfi_pr_properties prop;
 	long val;
 	time_t now;
+	int error, fd;
 	uint32_t at, next_exec, exec_freq;
 	char *cp;
 	uint8_t op_mode;
-	int fd;
 
 	exec_freq = 0;	/* GCC too stupid */
 	next_exec = 0;
@@ -272,12 +283,14 @@ patrol_config(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
-	if (patrol_get_props(fd, &prop) < 0)
-		return (errno);
+	error = patrol_get_props(fd, &prop);
+	if (error)
+		return (error);
 	prop.op_mode = op_mode;
 	if (op_mode == MFI_PR_OPMODE_AUTO) {
 		if (ac > 2)
@@ -294,8 +307,9 @@ patrol_config(int ac, char **av)
 	}
 	if (mfi_dcmd_command(fd, MFI_DCMD_PR_SET_PROPERTIES, &prop,
 	    sizeof(prop), NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to set patrol read properties");
-		return (errno);
+		return (error);
 	}
 
 	close(fd);

Modified: stable/8/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_show.c	Wed Nov  3 15:24:25 2010	(r214741)
+++ stable/8/usr.sbin/mfiutil/mfi_show.c	Wed Nov  3 15:25:30 2010	(r214742)
@@ -54,7 +54,7 @@ show_adapter(int ac, char **av)
 {
 	struct mfi_ctrl_info info;
 	char stripe[5];
-	int fd, comma;
+	int error, fd, comma;
 
 	if (ac != 1) {
 		warnx("show adapter: extra arguments");
@@ -63,13 +63,15 @@ show_adapter(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_ctrl_get_info(fd, &info, NULL) < 0) {
+		error = errno;
 		warn("Failed to get controller info");
-		return (errno);
+		return (error);
 	}
 	printf("mfi%d Adapter:\n", mfi_unit);
 	printf("    Product Name: %.80s\n", info.product_name);
@@ -137,7 +139,7 @@ show_battery(int ac, char **av)
 	struct mfi_bbu_capacity_info cap;
 	struct mfi_bbu_design_info design;
 	uint8_t status;
-	int fd;
+	int error, fd;
 
 	if (ac != 1) {
 		warnx("show battery: extra arguments");
@@ -146,8 +148,9 @@ show_battery(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_BBU_GET_CAPACITY_INFO, &cap,
@@ -156,14 +159,16 @@ show_battery(int ac, char **av)
 			printf("mfi%d: No battery present\n", mfi_unit);
 			return (0);
 		}
+		error = errno;
 		warn("Failed to get capacity info");
-		return (errno);
+		return (error);
 	}
 
 	if (mfi_dcmd_command(fd, MFI_DCMD_BBU_GET_DESIGN_INFO, &design,
 	    sizeof(design), NULL, 0, NULL) < 0) {
+		error = errno;
 		warn("Failed to get design info");
-		return (errno);
+		return (error);
 	}
 
 	printf("mfi%d: Battery State:\n", mfi_unit);
@@ -242,7 +247,7 @@ show_config(int ac, char **av)
 	struct mfi_pd_info pinfo;
 	uint16_t device_id;
 	char *p;
-	int fd, i, j;
+	int error, fd, i, j;
 
 	if (ac != 1) {
 		warnx("show config: extra arguments");
@@ -251,14 +256,16 @@ show_config(int ac, char **av)
 
 	fd = mfi_open(mfi_unit);
 	if (fd < 0) {
+		error = errno;
 		warn("mfi_open");
-		return (errno);
+		return (error);
 	}
 
 	/* Get the config from the controller. */
 	if (mfi_config_read(fd, &config) < 0) {
+		error = errno;
 		warn("Failed to get config");
-		return (errno);
+		return (error);
 	}
 
 	/* Dump out the configuration. */
@@ -337,8 +344,8 @@ show_volumes(int ac, char **av)
 {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 15:31:11 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 68DED1065675;
	Wed,  3 Nov 2010 15:31:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 357F28FC0C;
	Wed,  3 Nov 2010 15:31: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 oA3FVBm3025169;
	Wed, 3 Nov 2010 15:31:11 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FVBaQ025168;
	Wed, 3 Nov 2010 15:31:11 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011031531.oA3FVBaQ025168@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 3 Nov 2010 15:31:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214744 - in stable: 7/usr.sbin/mfiutil
	8/usr.sbin/mfiutil
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 15:31:11 -0000

Author: jhb
Date: Wed Nov  3 15:31:10 2010
New Revision: 214744
URL: http://svn.freebsd.org/changeset/base/214744

Log:
  Trim unneeded mergeinfo from a file.

Modified:
Directory Properties:
  stable/8/usr.sbin/mfiutil/mfiutil.8   (props changed)

Changes in other areas also in this revision:
Modified:
Directory Properties:
  stable/7/usr.sbin/mfiutil/mfiutil.8   (props changed)

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 15:31:37 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7AB2D106580C;
	Wed,  3 Nov 2010 15:31:37 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5E53A8FC14;
	Wed,  3 Nov 2010 15:31:37 +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 oA3FVbEv025215;
	Wed, 3 Nov 2010 15:31:37 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FVbTV025211;
	Wed, 3 Nov 2010 15:31:37 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201011031531.oA3FVbTV025211@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Wed, 3 Nov 2010 15:31:37 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214745 - in stable/8/sys/dev: pci usb/controller
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 15:31:37 -0000

Author: nwhitehorn
Date: Wed Nov  3 15:31:37 2010
New Revision: 214745
URL: http://svn.freebsd.org/changeset/base/214745

Log:
  MFC r214349:
  The EHCI_CAPLENGTH and EHCI_HCIVERSION registers are actually sub-registers
  within the first 4 bytes of the EHCI memory space. For controllers that
  use big-endian MMIO, reading them with 1- and 2-byte reads would then
  return the wrong values. Instead, read the combined register with a
  4-byte read and mask out the interesting quantities.
  
  Requested by:	marius

Modified:
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/usb/controller/ehci.c
  stable/8/sys/dev/usb/controller/ehcireg.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Wed Nov  3 15:31:10 2010	(r214744)
+++ stable/8/sys/dev/pci/pci.c	Wed Nov  3 15:31:37 2010	(r214745)
@@ -2729,7 +2729,7 @@ ehci_early_takeover(device_t self)
 				    "SMM does not respond\n");
 		}
 		/* Disable interrupts */
-		offs = bus_read_1(res, EHCI_CAPLENGTH);
+		offs = EHCI_CAPLENGTH(bus_read_4(res, EHCI_CAPLEN_HCIVERSION));
 		bus_write_4(res, offs + EHCI_USBINTR, 0);
 	}
 	bus_release_resource(self, SYS_RES_MEMORY, rid, res);

Modified: stable/8/sys/dev/usb/controller/ehci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/ehci.c	Wed Nov  3 15:31:10 2010	(r214744)
+++ stable/8/sys/dev/usb/controller/ehci.c	Wed Nov  3 15:31:37 2010	(r214745)
@@ -268,9 +268,9 @@ ehci_init(ehci_softc_t *sc)
 	}
 #endif
 
-	sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
+	sc->sc_offs = EHCI_CAPLENGTH(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
 
-	version = EREAD2(sc, EHCI_HCIVERSION);
+	version = EHCI_HCIVERSION(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
 	device_printf(sc->sc_bus.bdev, "EHCI version %x.%x\n",
 	    version >> 8, version & 0xff);
 

Modified: stable/8/sys/dev/usb/controller/ehcireg.h
==============================================================================
--- stable/8/sys/dev/usb/controller/ehcireg.h	Wed Nov  3 15:31:10 2010	(r214744)
+++ stable/8/sys/dev/usb/controller/ehcireg.h	Wed Nov  3 15:31:37 2010	(r214745)
@@ -61,9 +61,13 @@
 #define	EHCI_LEGSUP_USBLEGCTLSTS	0x04
 
 /* EHCI capability registers */
-#define	EHCI_CAPLENGTH		0x00	/* RO Capability register length field */
-/* reserved			0x01 */
-#define	EHCI_HCIVERSION		0x02	/* RO Interface version number */
+#define	EHCI_CAPLEN_HCIVERSION	0x00	/* RO Capability register length
+					 * (least-significant byte) and 
+					 * interface version number (two
+					 * most significant)
+					 */
+#define EHCI_CAPLENGTH(x)	((x) & 0xff)
+#define EHCI_HCIVERSION(x)	(((x) >> 16) & 0xffff)
 #define	EHCI_HCSPARAMS		0x04	/* RO Structural parameters */
 #define	EHCI_HCS_DEBUGPORT(x)	(((x) >> 20) & 0xf)
 #define	EHCI_HCS_P_INDICATOR(x) ((x) & 0x10000)

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 15:54:51 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 48500106564A;
	Wed,  3 Nov 2010 15:54:51 +0000 (UTC)
	(envelope-from jamie@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 365A98FC0C;
	Wed,  3 Nov 2010 15:54:51 +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 oA3FspLX025844;
	Wed, 3 Nov 2010 15:54:51 GMT (envelope-from jamie@svn.freebsd.org)
Received: (from jamie@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FspiO025842;
	Wed, 3 Nov 2010 15:54:51 GMT (envelope-from jamie@svn.freebsd.org)
Message-Id: <201011031554.oA3FspiO025842@svn.freebsd.org>
From: Jamie Gritton 
Date: Wed, 3 Nov 2010 15:54:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214747 - stable/8/lib/libjail
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 15:54:51 -0000

Author: jamie
Date: Wed Nov  3 15:54:50 2010
New Revision: 214747
URL: http://svn.freebsd.org/changeset/base/214747

Log:
  MFC 214434:
  
    Find a jail's type as part of jailparam_init rather than waiting until
    it's absolutely necessary.

Modified:
  stable/8/lib/libjail/jail.c
Directory Properties:
  stable/8/lib/libjail/   (props changed)

Modified: stable/8/lib/libjail/jail.c
==============================================================================
--- stable/8/lib/libjail/jail.c	Wed Nov  3 15:38:52 2010	(r214746)
+++ stable/8/lib/libjail/jail.c	Wed Nov  3 15:54:50 2010	(r214747)
@@ -250,10 +250,6 @@ jailparam_all(struct jailparam **jpp)
 		}
 		if (jailparam_init(jp + njp, buf + sizeof(SJPARAM)) < 0)
 			goto error;
-		if (jailparam_type(jp + njp) < 0) {
-			njp++;
-			goto error;
-		}
 		mib1[1] = 2;
 	}
 	jp = realloc(jp, njp * sizeof(*jp));
@@ -279,6 +275,10 @@ jailparam_init(struct jailparam *jp, con
 		strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
 		return (-1);
 	}
+	if (jailparam_type(jp) < 0) {
+		jailparam_free(jp, 1);
+		return (-1);
+	}
 	return (0);
 }
 
@@ -293,8 +293,6 @@ jailparam_import(struct jailparam *jp, c
 	const char *avalue;
 	int i, nval, fw;
 
-	if (!jp->jp_ctltype && jailparam_type(jp) < 0)
-		return (-1);
 	if (value == NULL)
 		return (0);
 	if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) {
@@ -563,8 +561,6 @@ jailparam_get(struct jailparam *jp, unsi
 	jp_lastjid = jp_jid = jp_name = NULL;
 	arrays = 0;
 	for (ai = j = 0; j < njp; j++) {
-		if (!jp[j].jp_ctltype && jailparam_type(jp + j) < 0)
-			return (-1);
 		if (!strcmp(jp[j].jp_name, "lastjid"))
 			jp_lastjid = jp + j;
 		else if (!strcmp(jp[j].jp_name, "jid"))
@@ -725,8 +721,6 @@ jailparam_export(struct jailparam *jp)
 	int i, nval, ival;
 	char valbuf[INET6_ADDRSTRLEN];
 
-	if (!jp->jp_ctltype && jailparam_type(jp) < 0)
-		return (NULL);
 	if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) {
 		value = strdup(jp->jp_value);
 		if (value == NULL)

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:21:12 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C796A1065673;
	Wed,  3 Nov 2010 21:21:12 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B1F7C8FC08;
	Wed,  3 Nov 2010 21:21:12 +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 oA3LLCjh033741;
	Wed, 3 Nov 2010 21:21:12 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3LLCVH033720;
	Wed, 3 Nov 2010 21:21:12 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032121.oA3LLCVH033720@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:21:12 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214755 - in stable/8/sys: amd64/amd64 amd64/conf
	amd64/ia32 amd64/include amd64/linux32 arm/arm
	cddl/dev/systrace compat/ia32 compat/svr4 conf i386/conf
	i386/i386 i386/ibcs2 i386/inclu...
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:21:13 -0000

Author: kib
Date: Wed Nov  3 21:21:12 2010
New Revision: 214755
URL: http://svn.freebsd.org/changeset/base/214755

Log:
  MFC r208453:
  Reorganize syscall entry and leave handling.
  Implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and
  PL_FLAG_EXEC.
  
  The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are
  changed to use syscallenter()/syscallret(). MIPS and arm are not
  converted and use the mostly unchanged syscall() implementation.
  
  MFC r208514:
  Change ia64' struct syscall_args definition so that args is a pointer to
  the arguments array instead of array itself.
  
  MFC r208566:
  Allow to use syscallname(9) outside subr_trap.c.
  
  MFC r209258 (by rpaulo):
  Make DTrace syscall provider work again by including opt_kdtrace.h here.
  
  MFC r209313:
  Only enable kdtrace hook in the LINT on the architectures that implement it.
  
  MFC r209697:
  Obey sv_syscallnames bounds in syscallname().
  
  NOTE: The KBI of the struct sysentvec is changed, new required members
  sv_set_syscall_retval, sv_fetch_syscall_args and sv_syscallnames are
  added. The sv_prepsyscall field is now ignored. Third-party modules
  using the struct sysentvec must be modified and recompiled, we believe
  that only ABI emulators are affected. No such out-of-tree modules are
  known. In-tree modules that are affected by the change were converted
  to depend on exact version of the kernel, see r214421.

Modified:
  stable/8/sys/amd64/amd64/elf_machdep.c
  stable/8/sys/amd64/amd64/trap.c
  stable/8/sys/amd64/conf/NOTES
  stable/8/sys/amd64/ia32/ia32_syscall.c
  stable/8/sys/amd64/include/proc.h
  stable/8/sys/amd64/linux32/linux32_sysvec.c
  stable/8/sys/arm/arm/elf_machdep.c
  stable/8/sys/arm/arm/trap.c
  stable/8/sys/cddl/dev/systrace/systrace.c
  stable/8/sys/compat/ia32/ia32_sysvec.c
  stable/8/sys/compat/ia32/ia32_util.h
  stable/8/sys/compat/svr4/svr4_sysvec.c
  stable/8/sys/conf/NOTES
  stable/8/sys/conf/files
  stable/8/sys/i386/conf/NOTES
  stable/8/sys/i386/i386/elf_machdep.c
  stable/8/sys/i386/i386/trap.c
  stable/8/sys/i386/ibcs2/ibcs2_sysvec.c
  stable/8/sys/i386/include/proc.h
  stable/8/sys/i386/linux/linux_sysvec.c
  stable/8/sys/ia64/ia32/ia32_trap.c
  stable/8/sys/ia64/ia64/elf_machdep.c
  stable/8/sys/ia64/ia64/trap.c
  stable/8/sys/ia64/include/proc.h
  stable/8/sys/kern/imgact_aout.c
  stable/8/sys/kern/init_main.c
  stable/8/sys/kern/kern_exec.c
  stable/8/sys/kern/kern_sig.c
  stable/8/sys/kern/subr_trap.c
  stable/8/sys/kern/sys_process.c
  stable/8/sys/mips/mips/elf64_machdep.c
  stable/8/sys/mips/mips/elf_machdep.c
  stable/8/sys/mips/mips/trap.c
  stable/8/sys/powerpc/aim/trap.c
  stable/8/sys/powerpc/booke/trap.c
  stable/8/sys/powerpc/include/proc.h
  stable/8/sys/powerpc/powerpc/elf_machdep.c
  stable/8/sys/sparc64/include/proc.h
  stable/8/sys/sparc64/sparc64/elf_machdep.c
  stable/8/sys/sparc64/sparc64/trap.c
  stable/8/sys/sun4v/include/proc.h
  stable/8/sys/sun4v/sun4v/trap.c
  stable/8/sys/sys/proc.h
  stable/8/sys/sys/ptrace.h
  stable/8/sys/sys/sysent.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- stable/8/sys/amd64/amd64/elf_machdep.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/amd64/elf_machdep.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,7 +75,10 @@ struct sysentvec elf64_freebsd_sysvec = 
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_FREEBSD | SV_LP64
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
+	.sv_syscallnames = syscallnames,
 };
 
 static Elf64_Brandinfo freebsd_brand_info = {

Modified: stable/8/sys/amd64/amd64/trap.c
==============================================================================
--- stable/8/sys/amd64/amd64/trap.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/amd64/trap.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -76,7 +76,6 @@ __FBSDID("$FreeBSD$");
 #ifdef HWPMC_HOOKS
 #include 
 #endif
-#include 
 
 #include 
 #include 
@@ -170,8 +169,6 @@ static int prot_fault_translation = 0;
 SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
 	&prot_fault_translation, 0, "Select signal to deliver on protection fault");
 
-extern char *syscallnames[];
-
 /*
  * Exception, fault, and trap interface to the FreeBSD kernel.
  * This common code is called from assembly language IDT gate entry
@@ -804,19 +801,12 @@ dblfault_handler(struct trapframe *frame
 	panic("double fault");
 }
 
-struct syscall_args {
-	u_int code;
-	struct sysent *callp;
-	register_t args[8];
-	register_t *argp;
-	int narg;
-};
-
-static int
-fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+int
+cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
 {
 	struct proc *p;
 	struct trapframe *frame;
+	register_t *argp;
 	caddr_t params;
 	int reg, regcnt, error;
 
@@ -828,15 +818,10 @@ fetch_syscall_args(struct thread *td, st
 	params = (caddr_t)frame->tf_rsp + sizeof(register_t);
 	sa->code = frame->tf_rax;
 
-	if (p->p_sysent->sv_prepsyscall) {
-		(*p->p_sysent->sv_prepsyscall)(frame, (int *)sa->args,
-		    &sa->code, ¶ms);
-	} else {
-		if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
-			sa->code = frame->tf_rdi;
-			reg++;
-			regcnt--;
-		}
+	if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
+		sa->code = frame->tf_rdi;
+		reg++;
+		regcnt--;
 	}
  	if (p->p_sysent->sv_mask)
  		sa->code &= p->p_sysent->sv_mask;
@@ -850,24 +835,20 @@ fetch_syscall_args(struct thread *td, st
 	KASSERT(sa->narg <= sizeof(sa->args) / sizeof(sa->args[0]),
 	    ("Too many syscall arguments!"));
 	error = 0;
-	sa->argp = &frame->tf_rdi;
-	sa->argp += reg;
-	bcopy(sa->argp, sa->args, sizeof(sa->args[0]) * regcnt);
+	argp = &frame->tf_rdi;
+	argp += reg;
+	bcopy(argp, sa->args, sizeof(sa->args[0]) * regcnt);
 	if (sa->narg > regcnt) {
 		KASSERT(params != NULL, ("copyin args with no params!"));
 		error = copyin(params, &sa->args[regcnt],
 	    	    (sa->narg - regcnt) * sizeof(sa->args[0]));
 	}
-	sa->argp = &sa->args[0];
 
-	/*
-	 * This may result in two records if debugger modified
-	 * registers or memory during sleep at stop/ptrace point.
-	 */
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSCALL))
-		ktrsyscall(sa->code, sa->narg, sa->argp);
-#endif
+	if (error == 0) {
+		td->td_retval[0] = 0;
+		td->td_retval[1] = frame->tf_rdx;
+	}
+
 	return (error);
 }
 
@@ -880,87 +861,22 @@ void
 syscall(struct trapframe *frame)
 {
 	struct thread *td;
-	struct proc *p;
 	struct syscall_args sa;
 	register_t orig_tf_rflags;
 	int error;
 	ksiginfo_t ksi;
 
-	PCPU_INC(cnt.v_syscall);
-	td = curthread;
-	p = td->td_proc;
-	td->td_syscalls++;
-
 #ifdef DIAGNOSTIC
 	if (ISPL(frame->tf_cs) != SEL_UPL) {
 		panic("syscall");
 		/* NOT REACHED */
 	}
 #endif
-
-	td->td_pticks = 0;
-	td->td_frame = frame;
-	if (td->td_ucred != p->p_ucred) 
-		cred_update_thread(td);
 	orig_tf_rflags = frame->tf_rflags;
-	if (p->p_flag & P_TRACED) {
-		PROC_LOCK(p);
-		td->td_dbgflags &= ~TDB_USERWR;
-		PROC_UNLOCK(p);
-	}
-	error = fetch_syscall_args(td, &sa);
-
-	CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_name, sa.code);
-
-	if (error == 0) {
-		td->td_retval[0] = 0;
-		td->td_retval[1] = frame->tf_rdx;
-
-		STOPEVENT(p, S_SCE, sa.narg);
-		PTRACESTOP_SC(p, td, S_PT_SCE);
-		if (td->td_dbgflags & TDB_USERWR) {
-			/*
-			 * Reread syscall number and arguments if
-			 * debugger modified registers or memory.
-			 */
-			error = fetch_syscall_args(td, &sa);
-			if (error != 0)
-				goto retval;
-			td->td_retval[1] = frame->tf_rdx;
-		}
-
-#ifdef KDTRACE_HOOKS
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'entry', process the probe.
-		 */
-		if (systrace_probe_func != NULL && sa.callp->sy_entry != 0)
-			(*systrace_probe_func)(sa.callp->sy_entry, sa.code,
-			    sa.callp, sa.args);
-#endif
-
-		AUDIT_SYSCALL_ENTER(sa.code, td);
-		error = (*sa.callp->sy_call)(td, sa.argp);
-		AUDIT_SYSCALL_EXIT(error, td);
-
-		/* Save the latest error return value. */
-		td->td_errno = error;
+	td = curthread;
+	td->td_frame = frame;
 
-#ifdef KDTRACE_HOOKS
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'return', process the probe.
-		 */
-		if (systrace_probe_func != NULL && sa.callp->sy_return != 0)
-			(*systrace_probe_func)(sa.callp->sy_return, sa.code,
-			    sa.callp, sa.args);
-#endif
-	}
- retval:
-	cpu_set_syscall_retval(td, error);
+	error = syscallenter(td, &sa);
 
 	/*
 	 * Traced syscall.
@@ -974,40 +890,5 @@ syscall(struct trapframe *frame)
 		trapsignal(td, &ksi);
 	}
 
-	/*
-	 * Check for misbehavior.
-	 */
-	WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???");
-	KASSERT(td->td_critnest == 0,
-	    ("System call %s returning in a critical section",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???"));
-	KASSERT(td->td_locks == 0,
-	    ("System call %s returning with %d locks held",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???", td->td_locks));
-
-	/*
-	 * Handle reschedule and other end-of-syscall issues
-	 */
-	userret(td, frame);
-
-	CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_name, sa.code);
-
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSRET))
-		ktrsysret(sa.code, error, td->td_retval[0]);
-#endif
-
-	/*
-	 * This works because errno is findable through the
-	 * register set.  If we ever support an emulation where this
-	 * is not the case, this code will need to be revisited.
-	 */
-	STOPEVENT(p, S_SCX, sa.code);
-
-	PTRACESTOP_SC(p, td, S_PT_SCX);
+	syscallret(td, error, &sa);
 }

Modified: stable/8/sys/amd64/conf/NOTES
==============================================================================
--- stable/8/sys/amd64/conf/NOTES	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/conf/NOTES	Wed Nov  3 21:21:12 2010	(r214755)
@@ -11,6 +11,12 @@
 # We want LINT to cover profiling as well.
 profile         2
 
+#
+# Enable the kernel DTrace hooks which are required to load the DTrace
+# kernel modules.
+#
+options 	KDTRACE_HOOKS
+
 
 #####################################################################
 # SMP OPTIONS:

Modified: stable/8/sys/amd64/ia32/ia32_syscall.c
==============================================================================
--- stable/8/sys/amd64/ia32/ia32_syscall.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/ia32/ia32_syscall.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -81,62 +82,54 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #define	IDTVEC(name)	__CONCAT(X,name)
 
 extern inthand_t IDTVEC(int0x80_syscall), IDTVEC(rsvd);
-extern const char *freebsd32_syscallnames[];
 
 void ia32_syscall(struct trapframe *frame);	/* Called from asm code */
 
-struct ia32_syscall_args {
-	u_int code;
-	caddr_t params;
-	struct sysent *callp;
-	u_int64_t args64[8];
-	int narg;
-};
+void
+ia32_set_syscall_retval(struct thread *td, int error)
+{
 
-static int
-fetch_ia32_syscall_args(struct thread *td, struct ia32_syscall_args *sa)
+	cpu_set_syscall_retval(td, error);
+}
+
+int
+ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
 {
 	struct proc *p;
 	struct trapframe *frame;
+	caddr_t params;
 	u_int32_t args[8];
 	int error, i;
 
 	p = td->td_proc;
 	frame = td->td_frame;
 
-	sa->params = (caddr_t)frame->tf_rsp + sizeof(u_int32_t);
+	params = (caddr_t)frame->tf_rsp + sizeof(u_int32_t);
 	sa->code = frame->tf_rax;
 
-	if (p->p_sysent->sv_prepsyscall) {
+	/*
+	 * Need to check if this is a 32 bit or 64 bit syscall.
+	 */
+	if (sa->code == SYS_syscall) {
 		/*
-		 * The prep code is MP aware.
+		 * Code is first argument, followed by actual args.
 		 */
-		(*p->p_sysent->sv_prepsyscall)(frame, args, &sa->code,
-		    &sa->params);
-	} else {
+		sa->code = fuword32(params);
+		params += sizeof(int);
+	} else if (sa->code == SYS___syscall) {
 		/*
-		 * Need to check if this is a 32 bit or 64 bit syscall.
-		 * fuword is MP aware.
+		 * Like syscall, but code is a quad, so as to maintain
+		 * quad alignment for the rest of the arguments.
+		 * We use a 32-bit fetch in case params is not
+		 * aligned.
 		 */
-		if (sa->code == SYS_syscall) {
-			/*
-			 * Code is first argument, followed by actual args.
-			 */
-			sa->code = fuword32(sa->params);
-			sa->params += sizeof(int);
-		} else if (sa->code == SYS___syscall) {
-			/*
-			 * Like syscall, but code is a quad, so as to maintain
-			 * quad alignment for the rest of the arguments.
-			 * We use a 32-bit fetch in case params is not
-			 * aligned.
-			 */
-			sa->code = fuword32(sa->params);
-			sa->params += sizeof(quad_t);
-		}
+		sa->code = fuword32(params);
+		params += sizeof(quad_t);
 	}
  	if (p->p_sysent->sv_mask)
  		sa->code &= p->p_sysent->sv_mask;
@@ -146,19 +139,19 @@ fetch_ia32_syscall_args(struct thread *t
  		sa->callp = &p->p_sysent->sv_table[sa->code];
 	sa->narg = sa->callp->sy_narg;
 
-	if (sa->params != NULL && sa->narg != 0)
-		error = copyin(sa->params, (caddr_t)args,
+	if (params != NULL && sa->narg != 0)
+		error = copyin(params, (caddr_t)args,
 		    (u_int)(sa->narg * sizeof(int)));
 	else
 		error = 0;
 
 	for (i = 0; i < sa->narg; i++)
-		sa->args64[i] = args[i];
+		sa->args[i] = args[i];
 
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSCALL))
-		ktrsyscall(sa->code, sa->narg, sa->args64);
-#endif
+	if (error == 0) {
+		td->td_retval[0] = 0;
+		td->td_retval[1] = frame->tf_rdx;
+	}
 
 	return (error);
 }
@@ -167,58 +160,16 @@ void
 ia32_syscall(struct trapframe *frame)
 {
 	struct thread *td;
-	struct proc *p;
-	struct ia32_syscall_args sa;
+	struct syscall_args sa;
 	register_t orig_tf_rflags;
 	int error;
 	ksiginfo_t ksi;
 
-	PCPU_INC(cnt.v_syscall);
+	orig_tf_rflags = frame->tf_rflags;
 	td = curthread;
-	p = td->td_proc;
-	td->td_syscalls++;
-
-	td->td_pticks = 0;
 	td->td_frame = frame;
-	if (td->td_ucred != p->p_ucred) 
-		cred_update_thread(td);
-	orig_tf_rflags = frame->tf_rflags;
-	if (p->p_flag & P_TRACED) {
-		PROC_LOCK(p);
-		td->td_dbgflags &= ~TDB_USERWR;
-		PROC_UNLOCK(p);
-	}
-	error = fetch_ia32_syscall_args(td, &sa);
-
-	CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_name, sa.code);
-
-	if (error == 0) {
-		td->td_retval[0] = 0;
-		td->td_retval[1] = frame->tf_rdx;
 
-		STOPEVENT(p, S_SCE, sa.narg);
-		PTRACESTOP_SC(p, td, S_PT_SCE);
-		if (td->td_dbgflags & TDB_USERWR) {
-			/*
-			 * Reread syscall number and arguments if
-			 * debugger modified registers or memory.
-			 */
-			error = fetch_ia32_syscall_args(td, &sa);
-			if (error != 0)
-				goto retval;
-			td->td_retval[1] = frame->tf_rdx;
-		}
-
-		AUDIT_SYSCALL_ENTER(sa.code, td);
-		error = (*sa.callp->sy_call)(td, sa.args64);
-		AUDIT_SYSCALL_EXIT(error, td);
-
-		/* Save the latest error return value. */
-		td->td_errno = error;
-	}
- retval:
-	cpu_set_syscall_retval(td, error);
+	error = syscallenter(td, &sa);
 
 	/*
 	 * Traced syscall.
@@ -232,44 +183,9 @@ ia32_syscall(struct trapframe *frame)
 		trapsignal(td, &ksi);
 	}
 
-	/*
-	 * Check for misbehavior.
-	 */
-	WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     freebsd32_syscallnames[sa.code] : "???");
-	KASSERT(td->td_critnest == 0,
-	    ("System call %s returning in a critical section",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     freebsd32_syscallnames[sa.code] : "???"));
-	KASSERT(td->td_locks == 0,
-	    ("System call %s returning with %d locks held",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     freebsd32_syscallnames[sa.code] : "???", td->td_locks));
-
-	/*
-	 * Handle reschedule and other end-of-syscall issues
-	 */
-	userret(td, frame);
-
-	CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_proc->p_comm, sa.code);
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSRET))
-		ktrsysret(sa.code, error, td->td_retval[0]);
-#endif
-
-	/*
-	 * This works because errno is findable through the
-	 * register set.  If we ever support an emulation where this
-	 * is not the case, this code will need to be revisited.
-	 */
-	STOPEVENT(p, S_SCX, sa.code);
- 
-	PTRACESTOP_SC(p, td, S_PT_SCX);
+	syscallret(td, error, &sa);
 }
 
-
 static void
 ia32_syscall_enable(void *dummy)
 {

Modified: stable/8/sys/amd64/include/proc.h
==============================================================================
--- stable/8/sys/amd64/include/proc.h	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/include/proc.h	Wed Nov  3 21:21:12 2010	(r214755)
@@ -79,6 +79,14 @@ int amd64_set_ldt_data(struct thread *td
 extern struct mtx dt_lock;
 extern int max_ldt_segment;
 
+struct syscall_args {
+	u_int code;
+	struct sysent *callp;
+	register_t args[8];
+	int narg;
+};
+#define	HAVE_SYSCALL_ARGS_DEF 1
+
 #endif  /* _KERNEL */
 
 #endif /* !_MACHINE_PROC_H_ */

Modified: stable/8/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- stable/8/sys/amd64/linux32/linux32_sysvec.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/amd64/linux32/linux32_sysvec.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -121,8 +121,6 @@ SET_DECLARE(linux_device_handler_set, st
 static int	elf_linux_fixup(register_t **stack_base,
 		    struct image_params *iparams);
 static register_t *linux_copyout_strings(struct image_params *imgp);
-static void	linux_prepsyscall(struct trapframe *tf, int *args, u_int *code,
-		    caddr_t *params);
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void	exec_linux_setregs(struct thread *td, u_long entry,
 				   u_long stack, u_long ps_strings);
@@ -764,19 +762,33 @@ linux_rt_sigreturn(struct thread *td, st
 	return (EJUSTRETURN);
 }
 
-/*
- * MPSAFE
- */
-static void
-linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params)
+static int
+linux32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
 {
-	args[0] = tf->tf_rbx;
-	args[1] = tf->tf_rcx;
-	args[2] = tf->tf_rdx;
-	args[3] = tf->tf_rsi;
-	args[4] = tf->tf_rdi;
-	args[5] = tf->tf_rbp;	/* Unconfirmed */
-	*params = NULL;		/* no copyin */
+	struct proc *p;
+	struct trapframe *frame;
+
+	p = td->td_proc;
+	frame = td->td_frame;
+
+	sa->args[0] = frame->tf_rbx;
+	sa->args[1] = frame->tf_rcx;
+	sa->args[2] = frame->tf_rdx;
+	sa->args[3] = frame->tf_rsi;
+	sa->args[4] = frame->tf_rdi;
+	sa->args[5] = frame->tf_rbp;	/* Unconfirmed */
+	sa->code = frame->tf_rax;
+
+	if (sa->code >= p->p_sysent->sv_size)
+		sa->callp = &p->p_sysent->sv_table[0];
+	else
+		sa->callp = &p->p_sysent->sv_table[sa->code];
+	sa->narg = sa->callp->sy_narg;
+
+	td->td_retval[0] = 0;
+	td->td_retval[1] = frame->tf_rdx;
+
+	return (0);
 }
 
 /*
@@ -1043,7 +1055,7 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_sendsig	= linux_sendsig,
 	.sv_sigcode	= linux_sigcode,
 	.sv_szsigcode	= &linux_szsigcode,
-	.sv_prepsyscall	= linux_prepsyscall,
+	.sv_prepsyscall	= NULL,
 	.sv_name	= "Linux ELF32",
 	.sv_coredump	= elf32_coredump,
 	.sv_imgact_try	= exec_linux_imgact_try,
@@ -1058,7 +1070,10 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_setregs	= exec_linux_setregs,
 	.sv_fixlimit	= linux32_fixlimit,
 	.sv_maxssiz	= &linux32_maxssiz,
-	.sv_flags	= SV_ABI_LINUX | SV_ILP32 | SV_IA32
+	.sv_flags	= SV_ABI_LINUX | SV_ILP32 | SV_IA32,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = linux32_fetch_syscall_args,
+	.sv_syscallnames = NULL,
 };
 
 static char GNU_ABI_VENDOR[] = "GNU";

Modified: stable/8/sys/arm/arm/elf_machdep.c
==============================================================================
--- stable/8/sys/arm/arm/elf_machdep.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/arm/arm/elf_machdep.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,7 +74,10 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32
+	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = NULL, /* XXXKIB */
+	.sv_syscallnames = syscallnames,
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: stable/8/sys/arm/arm/trap.c
==============================================================================
--- stable/8/sys/arm/arm/trap.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/arm/arm/trap.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -130,7 +130,6 @@ void undefinedinstruction(trapframe_t *)
 #include 
  
 extern char fusubailout[];
-extern char *syscallnames[];
 
 #ifdef DEBUG
 int last_fault_code;	/* For the benefit of pmap_fault_fixup() */

Modified: stable/8/sys/cddl/dev/systrace/systrace.c
==============================================================================
--- stable/8/sys/cddl/dev/systrace/systrace.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/cddl/dev/systrace/systrace.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -77,7 +77,6 @@ extern struct sysent linux_sysent[];
  */
 #include 
 #include 
-extern const char	*syscallnames[];
 #define	DEVNAME		"dtrace/systrace"
 #define	PROVNAME	"syscall"
 #define	MAXSYSCALL	SYS_MAXSYSCALL

Modified: stable/8/sys/compat/ia32/ia32_sysvec.c
==============================================================================
--- stable/8/sys/compat/ia32/ia32_sysvec.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/compat/ia32/ia32_sysvec.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -93,6 +93,8 @@ CTASSERT(sizeof(struct ia32_ucontext4) =
 CTASSERT(sizeof(struct ia32_sigframe4) == 408);
 #endif
 
+extern const char *freebsd32_syscallnames[];
+
 static void ia32_fixlimit(struct rlimit *rl, int which);
 
 SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode");
@@ -135,7 +137,10 @@ struct sysentvec ia32_freebsd_sysvec = {
 	.sv_setregs	= ia32_setregs,
 	.sv_fixlimit	= ia32_fixlimit,
 	.sv_maxssiz	= &ia32_maxssiz,
-	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32
+	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32,
+	.sv_set_syscall_retval = ia32_set_syscall_retval,
+	.sv_fetch_syscall_args = ia32_fetch_syscall_args,
+	.sv_syscallnames = freebsd32_syscallnames,
 };
 
 

Modified: stable/8/sys/compat/ia32/ia32_util.h
==============================================================================
--- stable/8/sys/compat/ia32/ia32_util.h	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/compat/ia32/ia32_util.h	Wed Nov  3 21:21:12 2010	(r214755)
@@ -47,3 +47,7 @@
 #define	IA32_MAXDSIZ	(512*1024*1024)		/* 512MB */
 #define	IA32_MAXSSIZ	(64*1024*1024)		/* 64MB */
 #define IA32_MAXVMEM	0			/* Unlimited */
+
+struct syscall_args;
+int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa);
+void ia32_set_syscall_retval(struct thread *, int);

Modified: stable/8/sys/compat/svr4/svr4_sysvec.c
==============================================================================
--- stable/8/sys/compat/svr4/svr4_sysvec.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/compat/svr4/svr4_sysvec.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -191,7 +191,10 @@ struct sysentvec svr4_sysvec = {
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz     = NULL,
-	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32
+	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
+	.sv_syscallnames = NULL,
 };
 
 const char      svr4_emul_path[] = "/compat/svr4";

Modified: stable/8/sys/conf/NOTES
==============================================================================
--- stable/8/sys/conf/NOTES	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/conf/NOTES	Wed Nov  3 21:21:12 2010	(r214755)
@@ -363,12 +363,6 @@ options 	DDB_NUMSYM
 options 	GDB
 
 #
-# Enable the kernel DTrace hooks which are required to load the DTrace
-# kernel modules.
-#
-options 	KDTRACE_HOOKS
-
-#
 # SYSCTL_DEBUG enables a 'sysctl' debug tree that can be used to dump the
 # contents of the registered sysctl nodes on the console.  It is disabled by
 # default because it generates excessively verbose console output that can

Modified: stable/8/sys/conf/files
==============================================================================
--- stable/8/sys/conf/files	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/conf/files	Wed Nov  3 21:21:12 2010	(r214755)
@@ -2171,7 +2171,7 @@ kern/sys_generic.c		standard
 kern/sys_pipe.c			standard
 kern/sys_process.c		standard
 kern/sys_socket.c		standard
-kern/syscalls.c			optional witness | invariants | kdtrace_hooks
+kern/syscalls.c			standard
 kern/sysv_ipc.c			standard
 kern/sysv_msg.c			optional sysvmsg
 kern/sysv_sem.c			optional sysvsem

Modified: stable/8/sys/i386/conf/NOTES
==============================================================================
--- stable/8/sys/i386/conf/NOTES	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/i386/conf/NOTES	Wed Nov  3 21:21:12 2010	(r214755)
@@ -11,6 +11,12 @@
 # We want LINT to cover profiling as well.
 profile         2
 
+#
+# Enable the kernel DTrace hooks which are required to load the DTrace
+# kernel modules.
+#
+options 	KDTRACE_HOOKS
+
 
 #####################################################################
 # SMP OPTIONS:

Modified: stable/8/sys/i386/i386/elf_machdep.c
==============================================================================
--- stable/8/sys/i386/i386/elf_machdep.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/i386/i386/elf_machdep.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,7 +74,10 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32
+	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
+	.sv_syscallnames = syscallnames,
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: stable/8/sys/i386/i386/trap.c
==============================================================================
--- stable/8/sys/i386/i386/trap.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/i386/i386/trap.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -184,8 +184,6 @@ static int prot_fault_translation = 0;
 SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
 	&prot_fault_translation, 0, "Select signal to deliver on protection fault");
 
-extern char *syscallnames[];
-
 /*
  * Exception, fault, and trap interface to the FreeBSD kernel.
  * This common code is called from assembly language IDT gate entry
@@ -971,16 +969,8 @@ dblfault_handler()
 	panic("double fault");
 }
 
-struct syscall_args {
-	u_int code;
-	struct sysent *callp;
-	int args[8];
-	register_t *argp;
-	int narg;
-};
-
-static int
-fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+int
+cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
 {
 	struct proc *p;
 	struct trapframe *frame;
@@ -993,27 +983,22 @@ fetch_syscall_args(struct thread *td, st
 	params = (caddr_t)frame->tf_esp + sizeof(int);
 	sa->code = frame->tf_eax;
 
-	if (p->p_sysent->sv_prepsyscall) {
-		(*p->p_sysent->sv_prepsyscall)(frame, sa->args, &sa->code,
-		    ¶ms);
-	} else {
+	/*
+	 * Need to check if this is a 32 bit or 64 bit syscall.
+	 */
+	if (sa->code == SYS_syscall) {
 		/*
-		 * Need to check if this is a 32 bit or 64 bit syscall.
+		 * Code is first argument, followed by actual args.
 		 */
-		if (sa->code == SYS_syscall) {
-			/*
-			 * Code is first argument, followed by actual args.
-			 */
-			sa->code = fuword(params);
-			params += sizeof(int);
-		} else if (sa->code == SYS___syscall) {
-			/*
-			 * Like syscall, but code is a quad, so as to maintain
-			 * quad alignment for the rest of the arguments.
-			 */
-			sa->code = fuword(params);
-			params += sizeof(quad_t);
-		}
+		sa->code = fuword(params);
+		params += sizeof(int);
+	} else if (sa->code == SYS___syscall) {
+		/*
+		 * Like syscall, but code is a quad, so as to maintain
+		 * quad alignment for the rest of the arguments.
+		 */
+		sa->code = fuword(params);
+		params += sizeof(quad_t);
 	}
 
  	if (p->p_sysent->sv_mask)
@@ -1029,11 +1014,12 @@ fetch_syscall_args(struct thread *td, st
 		    (u_int)(sa->narg * sizeof(int)));
 	else
 		error = 0;
+
+	if (error == 0) {
+		td->td_retval[0] = 0;
+		td->td_retval[1] = frame->tf_edx;
+	}
 		
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSCALL))
-		ktrsyscall(sa->code, sa->narg, sa->args);
-#endif
 	return (error);
 }
 
@@ -1046,87 +1032,23 @@ void
 syscall(struct trapframe *frame)
 {
 	struct thread *td;
-	struct proc *p;
 	struct syscall_args sa;
 	register_t orig_tf_eflags;
 	int error;
 	ksiginfo_t ksi;
 
-	PCPU_INC(cnt.v_syscall);
-	td = curthread;
-	p = td->td_proc;
-	td->td_syscalls++;
-
 #ifdef DIAGNOSTIC
 	if (ISPL(frame->tf_cs) != SEL_UPL) {
 		panic("syscall");
 		/* NOT REACHED */
 	}
 #endif
-
-	td->td_pticks = 0;
-	td->td_frame = frame;
-	if (td->td_ucred != p->p_ucred) 
-		cred_update_thread(td);
 	orig_tf_eflags = frame->tf_eflags;
-	if (p->p_flag & P_TRACED) {
-		PROC_LOCK(p);
-		td->td_dbgflags &= ~TDB_USERWR;
-		PROC_UNLOCK(p);
-	}
-	error = fetch_syscall_args(td, &sa);
-
-	CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_name, sa.code);
-
-	if (error == 0) {
-		td->td_retval[0] = 0;
-		td->td_retval[1] = frame->tf_edx;
-
-		STOPEVENT(p, S_SCE, sa.narg);
-		PTRACESTOP_SC(p, td, S_PT_SCE);
-		if (td->td_dbgflags & TDB_USERWR) {
-			/*
-			 * Reread syscall number and arguments if
-			 * debugger modified registers or memory.
-			 */
-			error = fetch_syscall_args(td, &sa);
-			if (error != 0)
-				goto retval;
-			td->td_retval[1] = frame->tf_edx;
-		}
-
-#ifdef KDTRACE_HOOKS
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'entry', process the probe.
-		 */
-		if (systrace_probe_func != NULL && sa.callp->sy_entry != 0)
-			(*systrace_probe_func)(sa.callp->sy_entry, sa.code,
-			    sa.callp, sa.args);
-#endif
 
-		AUDIT_SYSCALL_ENTER(sa.code, td);
-		error = (*sa.callp->sy_call)(td, sa.args);
-		AUDIT_SYSCALL_EXIT(error, td);
+	td = curthread;
+	td->td_frame = frame;
 
-		/* Save the latest error return value. */
-		td->td_errno = error;
-
-#ifdef KDTRACE_HOOKS
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'return', process the probe.
-		 */
-		if (systrace_probe_func != NULL && sa.callp->sy_return != 0)
-			(*systrace_probe_func)(sa.callp->sy_return, sa.code,
-			    sa.callp, sa.args);
-#endif
-	}
- retval:
-	cpu_set_syscall_retval(td, error);
+	error = syscallenter(td, &sa);
 
 	/*
 	 * Traced syscall.
@@ -1140,41 +1062,5 @@ syscall(struct trapframe *frame)
 		trapsignal(td, &ksi);
 	}
 
-	/*
-	 * Check for misbehavior.
-	 */
-	WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???");
-	KASSERT(td->td_critnest == 0,
-	    ("System call %s returning in a critical section",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???"));
-	KASSERT(td->td_locks == 0,
-	    ("System call %s returning with %d locks held",
-	    (sa.code >= 0 && sa.code < SYS_MAXSYSCALL) ?
-	     syscallnames[sa.code] : "???", td->td_locks));
-
-	/*
-	 * Handle reschedule and other end-of-syscall issues
-	 */
-	userret(td, frame);
-
-	CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
-	    td->td_proc->p_pid, td->td_name, sa.code);
-
-#ifdef KTRACE
-	if (KTRPOINT(td, KTR_SYSRET))
-		ktrsysret(sa.code, error, td->td_retval[0]);
-#endif
-
-	/*
-	 * This works because errno is findable through the
-	 * register set.  If we ever support an emulation where this
-	 * is not the case, this code will need to be revisited.
-	 */
-	STOPEVENT(p, S_SCX, sa.code);
-
-	PTRACESTOP_SC(p, td, S_PT_SCX);
+	syscallret(td, error, &sa);
 }
-

Modified: stable/8/sys/i386/ibcs2/ibcs2_sysvec.c
==============================================================================
--- stable/8/sys/i386/ibcs2/ibcs2_sysvec.c	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/i386/ibcs2/ibcs2_sysvec.c	Wed Nov  3 21:21:12 2010	(r214755)
@@ -86,7 +86,10 @@ struct sysentvec ibcs2_svr3_sysvec = {
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32
+	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32,
+	.sv_set_syscall_retval = cpu_set_syscall_retval,
+	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
+	.sv_syscallnames = NULL,
 };
 
 static int

Modified: stable/8/sys/i386/include/proc.h
==============================================================================
--- stable/8/sys/i386/include/proc.h	Wed Nov  3 21:10:12 2010	(r214754)
+++ stable/8/sys/i386/include/proc.h	Wed Nov  3 21:21:12 2010	(r214755)
@@ -77,6 +77,14 @@ void	user_ldt_deref(struct proc_ldt *pld
 
 extern struct mtx dt_lock;
 
+struct syscall_args {
+	u_int code;
+	struct sysent *callp;
+	register_t args[8];
+	int narg;
+};
+#define	HAVE_SYSCALL_ARGS_DEF 1
+
 #endif	/* _KERNEL */
 
 #endif /* !_MACHINE_PROC_H_ */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:24:21 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CEF47106566B;
	Wed,  3 Nov 2010 21:24:21 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BCF198FC15;
	Wed,  3 Nov 2010 21:24: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 oA3LOLUq033874;
	Wed, 3 Nov 2010 21:24:21 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3LOLJ7033869;
	Wed, 3 Nov 2010 21:24:21 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032124.oA3LOLJ7033869@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:24:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214756 - in stable/8/sys: kern sys
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:24:21 -0000

Author: kib
Date: Wed Nov  3 21:24:21 2010
New Revision: 214756
URL: http://svn.freebsd.org/changeset/base/214756

Log:
  MFC r209688:
  Extend ptrace(PT_LWPINFO) to report siginfo for the signal that caused
  debugee stop.

Modified:
  stable/8/sys/kern/kern_sig.c
  stable/8/sys/kern/sys_process.c
  stable/8/sys/sys/proc.h
  stable/8/sys/sys/ptrace.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/kern_sig.c
==============================================================================
--- stable/8/sys/kern/kern_sig.c	Wed Nov  3 21:21:12 2010	(r214755)
+++ stable/8/sys/kern/kern_sig.c	Wed Nov  3 21:24:21 2010	(r214756)
@@ -2517,7 +2517,6 @@ issignal(struct thread *td, int stop_all
 	struct sigacts *ps;
 	struct sigqueue *queue;
 	sigset_t sigpending;
-	ksiginfo_t ksi;
 	int sig, prop, newsig;
 
 	p = td->td_proc;
@@ -2560,10 +2559,10 @@ issignal(struct thread *td, int stop_all
 			 * be thrown away.
 			 */
 			queue = &td->td_sigqueue;
-			ksi.ksi_signo = 0;
-			if (sigqueue_get(queue, sig, &ksi) == 0) {
+			td->td_dbgksi.ksi_signo = 0;
+			if (sigqueue_get(queue, sig, &td->td_dbgksi) == 0) {
 				queue = &p->p_sigqueue;
-				sigqueue_get(queue, sig, &ksi);
+				sigqueue_get(queue, sig, &td->td_dbgksi);
 			}
 
 			mtx_unlock(&ps->ps_mtx);
@@ -2590,13 +2589,13 @@ issignal(struct thread *td, int stop_all
 					continue;
 				signotify(td);
 			} else {
-				if (ksi.ksi_signo != 0) {
-					ksi.ksi_flags |= KSI_HEAD;
+				if (td->td_dbgksi.ksi_signo != 0) {
+					td->td_dbgksi.ksi_flags |= KSI_HEAD;
 					if (sigqueue_add(&td->td_sigqueue, sig,
-					    &ksi) != 0)
-						ksi.ksi_signo = 0;
+					    &td->td_dbgksi) != 0)
+						td->td_dbgksi.ksi_signo = 0;
 				}
-				if (ksi.ksi_signo == 0)
+				if (td->td_dbgksi.ksi_signo == 0)
 					sigqueue_add(&td->td_sigqueue, sig,
 					    NULL);
 			}

Modified: stable/8/sys/kern/sys_process.c
==============================================================================
--- stable/8/sys/kern/sys_process.c	Wed Nov  3 21:21:12 2010	(r214755)
+++ stable/8/sys/kern/sys_process.c	Wed Nov  3 21:24:21 2010	(r214756)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef COMPAT_FREEBSD32
 #include 
+#include 
 
 struct ptrace_io_desc32 {
 	int		piod_op;
@@ -84,6 +85,15 @@ struct ptrace_vm_entry32 {
 	uint32_t	pve_path;
 };
 
+struct ptrace_lwpinfo32 {
+	lwpid_t	pl_lwpid;	/* LWP described. */
+	int	pl_event;	/* Event that stopped the LWP. */
+	int	pl_flags;	/* LWP flags. */
+	sigset_t	pl_sigmask;	/* LWP signal mask */
+	sigset_t	pl_siglist;	/* LWP pending signal */
+	struct siginfo32 pl_siginfo;	/* siginfo for signal */
+};
+
 #endif
 
 /*
@@ -495,6 +505,19 @@ ptrace_vm_entry32(struct thread *td, str
 	pve32->pve_pathlen = pve.pve_pathlen;
 	return (error);
 }
+
+static void
+ptrace_lwpinfo_to32(const struct ptrace_lwpinfo *pl,
+    struct ptrace_lwpinfo32 *pl32)
+{
+
+	pl32->pl_lwpid = pl->pl_lwpid;
+	pl32->pl_event = pl->pl_event;
+	pl32->pl_flags = pl->pl_flags;
+	pl32->pl_sigmask = pl->pl_sigmask;
+	pl32->pl_siglist = pl->pl_siglist;
+	siginfo_to_siginfo32(&pl->pl_siginfo, &pl32->pl_siginfo);
+}
 #endif /* COMPAT_FREEBSD32 */
 
 /*
@@ -549,6 +572,7 @@ ptrace(struct thread *td, struct ptrace_
 		struct fpreg32 fpreg32;
 		struct reg32 reg32;
 		struct ptrace_io_desc32 piod32;
+		struct ptrace_lwpinfo32 pl32;
 		struct ptrace_vm_entry32 pve32;
 #endif
 	} r;
@@ -659,6 +683,8 @@ kern_ptrace(struct thread *td, int req, 
 #ifdef COMPAT_FREEBSD32
 	int wrap32 = 0, safe = 0;
 	struct ptrace_io_desc32 *piod32 = NULL;
+	struct ptrace_lwpinfo32 *pl32 = NULL;
+	struct ptrace_lwpinfo plr;
 #endif
 
 	curp = td->td_proc;
@@ -1100,15 +1126,44 @@ kern_ptrace(struct thread *td, int req, 
 		break;
 
 	case PT_LWPINFO:
-		if (data <= 0 || data > sizeof(*pl)) {
+		if (data <= 0 ||
+#ifdef COMPAT_FREEBSD32
+		    (!wrap32 && data > sizeof(*pl)) ||
+		    (wrap32 && data > sizeof(*pl32))) {
+#else
+		    data > sizeof(*pl)) {
+#endif
 			error = EINVAL;
 			break;
 		}
+#ifdef COMPAT_FREEBSD32
+		if (wrap32) {
+			pl = &plr;
+			pl32 = addr;
+		} else
+#endif
 		pl = addr;
 		pl->pl_lwpid = td2->td_tid;
-		if (td2->td_dbgflags & TDB_XSIG)
-			pl->pl_event = PL_EVENT_SIGNAL;
 		pl->pl_flags = 0;
+		if (td2->td_dbgflags & TDB_XSIG) {
+			pl->pl_event = PL_EVENT_SIGNAL;
+			if (td2->td_dbgksi.ksi_signo != 0 &&
+#ifdef COMPAT_FREEBSD32
+			    ((!wrap32 && data >= offsetof(struct ptrace_lwpinfo,
+			    pl_siginfo) + sizeof(pl->pl_siginfo)) ||
+			    (wrap32 && data >= offsetof(struct ptrace_lwpinfo32,
+			    pl_siginfo) + sizeof(struct siginfo32)))
+#else
+			    data >= offsetof(struct ptrace_lwpinfo, pl_siginfo)
+			    + sizeof(pl->pl_siginfo)
+#endif
+			){
+				pl->pl_flags |= PL_FLAG_SI;
+				pl->pl_siginfo = td2->td_dbgksi.ksi_info;
+			}
+		}
+		if ((pl->pl_flags & PL_FLAG_SI) == 0)
+			bzero(&pl->pl_siginfo, sizeof(pl->pl_siginfo));
 		if (td2->td_dbgflags & TDB_SCE)
 			pl->pl_flags |= PL_FLAG_SCE;
 		else if (td2->td_dbgflags & TDB_SCX)
@@ -1117,6 +1172,10 @@ kern_ptrace(struct thread *td, int req, 
 			pl->pl_flags |= PL_FLAG_EXEC;
 		pl->pl_sigmask = td2->td_sigmask;
 		pl->pl_siglist = td2->td_siglist;
+#ifdef COMPAT_FREEBSD32
+		if (wrap32)
+			ptrace_lwpinfo_to32(pl, pl32);
+#endif
 		break;
 
 	case PT_GETNUMLWPS:

Modified: stable/8/sys/sys/proc.h
==============================================================================
--- stable/8/sys/sys/proc.h	Wed Nov  3 21:21:12 2010	(r214755)
+++ stable/8/sys/sys/proc.h	Wed Nov  3 21:24:21 2010	(r214756)
@@ -257,6 +257,7 @@ struct thread {
 	char		td_name[MAXCOMLEN + 1];	/* (*) Thread name. */
 	struct file	*td_fpop;	/* (k) file referencing cdev under op */
 	int		td_dbgflags;	/* (c) Userland debugger flags */
+	struct ksiginfo td_dbgksi;	/* (c) ksi reflected to debugger. */
 	int		td_ng_outbound;	/* (k) Thread entered ng from above. */
 	struct osd	td_osd;		/* (k) Object specific data. */
 #define	td_endzero td_base_pri

Modified: stable/8/sys/sys/ptrace.h
==============================================================================
--- stable/8/sys/sys/ptrace.h	Wed Nov  3 21:21:12 2010	(r214755)
+++ stable/8/sys/sys/ptrace.h	Wed Nov  3 21:24:21 2010	(r214756)
@@ -33,7 +33,7 @@
 #ifndef	_SYS_PTRACE_H_
 #define	_SYS_PTRACE_H_
 
-#include 
+#include 
 #include 
 
 #define	PT_TRACE_ME	0	/* child declares it's being traced */
@@ -102,8 +102,10 @@ struct ptrace_lwpinfo {
 #define	PL_FLAG_SCE	0x04	/* syscall enter point */
 #define	PL_FLAG_SCX	0x08	/* syscall leave point */
 #define	PL_FLAG_EXEC	0x10	/* exec(2) succeeded */
+#define	PL_FLAG_SI	0x20	/* siginfo is valid */
 	sigset_t	pl_sigmask;	/* LWP signal mask */
 	sigset_t	pl_siglist;	/* LWP pending signal */
+	struct __siginfo pl_siginfo;	/* siginfo for signal */
 };
 
 /* Argument structure for PT_VM_ENTRY. */

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:31:04 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5F5ED106566B;
	Wed,  3 Nov 2010 21:31:04 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 444908FC16;
	Wed,  3 Nov 2010 21:31:04 +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 oA3LV4EM034080;
	Wed, 3 Nov 2010 21:31:04 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3LV4Lb034078;
	Wed, 3 Nov 2010 21:31:04 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032131.oA3LV4Lb034078@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:31:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214757 - stable/8/lib/libc/sys
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:31:04 -0000

Author: kib
Date: Wed Nov  3 21:31:03 2010
New Revision: 214757
URL: http://svn.freebsd.org/changeset/base/214757

Log:
  MFC r208513:
  Improve the documentation for PT_LWPINFO. Note that some features are
  not implemented on MIPS and ARM.

Modified:
  stable/8/lib/libc/sys/ptrace.2
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/locale/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/sys/   (props changed)

Modified: stable/8/lib/libc/sys/ptrace.2
==============================================================================
--- stable/8/lib/libc/sys/ptrace.2	Wed Nov  3 21:24:21 2010	(r214756)
+++ stable/8/lib/libc/sys/ptrace.2	Wed Nov  3 21:31:03 2010	(r214757)
@@ -2,7 +2,7 @@
 .\"	$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
 .\"
 .\" This file is in the public domain.
-.Dd February 11, 2010
+.Dd May 24, 2010
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -289,8 +289,11 @@ argument specifies a pointer to a
 which is defined as follows:
 .Bd -literal
 struct ptrace_lwpinfo {
-	lwpid_t pl_lwpid;	/* LWP described. */
-	int	pl_event;	/* Event received. */
+	lwpid_t pl_lwpid;
+	int	pl_event;
+	int	pl_flags;
+	sigset_t pl_sigmask;
+	sigset_t pl_siglist;
 };
 .Ed
 .Pp
@@ -298,6 +301,51 @@ The
 .Fa data
 argument is to be set to the size of the structure known to the caller.
 This allows the structure to grow without affecting older programs.
+.Pp
+The fields in the
+.Vt "struct ptrace_lwpinfo"
+have the following meaning:
+.Bl -tag -width indent -compact
+.It pl_lwpid
+LWP id of the thread
+.It pl_event
+Event that caused the stop.
+Currently defined events are
+.Bl -tag -width indent -compact
+.It PL_EVENT_NONE
+No reason given
+.It PL_EVENT_SIGNAL
+Thread stopped due to the pending signal
+.El
+.It pl_flags
+Flags that specify additional details about observed stop.
+Currently defined flags are:
+.Bl -tag -width indent -compact
+.It PL_FLAG_SCE
+The thread stopped due to system call entry, right after the kernel is entered.
+The debugger may examine syscall arguments that are stored in memory and
+registers according to the ABI of the current process, and modify them,
+if needed.
+.It PL_FLAG_SCX
+The thread is stopped immediately before syscall is returning to the usermode.
+The debugger may examine system call return values in the ABI-defined registers
+and/or memory.
+.It PL_FLAG_EXEC
+When
+.Dv PL_FLAG_SCX
+is set, this flag may be additionally specified to inform that the
+program being executed by debuggee process has been changed by succesful
+execution of a system call from the
+.Fn execve 2
+family.
+.El
+.It pl_sigmask
+The current signal mask of the LWP
+.It pl_siglist
+The current pending set of signals for the LWP. Note that signals that
+are delivered to the process would not appear on an LWP siglist until
+the thread is selected for delivery.
+.El
 .It PT_GETNUMLWPS
 This request returns the number of kernel threads associated with the
 traced process.
@@ -501,3 +549,10 @@ The
 .Fn ptrace
 function appeared in
 .At v7 .
+.Sh BUGS
+The
+.Dv PL_FLAG_SCE ,
+.Dv PL_FLAG_SCX
+and
+.Dv PL_FLAG_EXEC
+are not implemented for MIPS and ARM architectures.

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:32:31 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9BA0E1065695;
	Wed,  3 Nov 2010 21:32:31 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8A8C38FC25;
	Wed,  3 Nov 2010 21:32:31 +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 oA3LWVAL034153;
	Wed, 3 Nov 2010 21:32:31 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3LWVDq034151;
	Wed, 3 Nov 2010 21:32:31 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032132.oA3LWVDq034151@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:32:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214758 - stable/8/lib/libc/sys
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:32:31 -0000

Author: kib
Date: Wed Nov  3 21:32:31 2010
New Revision: 214758
URL: http://svn.freebsd.org/changeset/base/214758

Log:
  MFC r209873:
  Document pl_siginfo and PT_FLAG_SI for PT_LWPINFO.

Modified:
  stable/8/lib/libc/sys/ptrace.2
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/locale/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/sys/   (props changed)

Modified: stable/8/lib/libc/sys/ptrace.2
==============================================================================
--- stable/8/lib/libc/sys/ptrace.2	Wed Nov  3 21:31:03 2010	(r214757)
+++ stable/8/lib/libc/sys/ptrace.2	Wed Nov  3 21:32:31 2010	(r214758)
@@ -2,7 +2,7 @@
 .\"	$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
 .\"
 .\" This file is in the public domain.
-.Dd May 24, 2010
+.Dd July 10, 2010
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -294,6 +294,7 @@ struct ptrace_lwpinfo {
 	int	pl_flags;
 	sigset_t pl_sigmask;
 	sigset_t pl_siglist;
+	siginfo_t pl_siginfo;
 };
 .Ed
 .Pp
@@ -338,13 +339,28 @@ program being executed by debuggee proce
 execution of a system call from the
 .Fn execve 2
 family.
+.It PL_FLAG_SI
+Indicates that
+.Va pl_siginfo
+member of
+.Vt "struct ptrace_lwpinfo"
+contains valid information.
 .El
 .It pl_sigmask
 The current signal mask of the LWP
 .It pl_siglist
-The current pending set of signals for the LWP. Note that signals that
-are delivered to the process would not appear on an LWP siglist until
-the thread is selected for delivery.
+The current pending set of signals for the LWP.
+Note that signals that are delivered to the process would not appear
+on an LWP siglist until the thread is selected for delivery.
+.It pl_siginfo
+The siginfo that accompanies the signal pending.
+Only valid for
+.Dv PL_EVENT_SIGNAL
+kind of stop, when
+.Va pl_flags
+has
+.Dv PL_FLAG_SI
+set.
 .El
 .It PT_GETNUMLWPS
 This request returns the number of kernel threads associated with the

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:39:12 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 305F01065675;
	Wed,  3 Nov 2010 21:39:12 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1E60E8FC1B;
	Wed,  3 Nov 2010 21:39:12 +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 oA3LdCcw034364;
	Wed, 3 Nov 2010 21:39:12 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3LdBSX034357;
	Wed, 3 Nov 2010 21:39:11 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032139.oA3LdBSX034357@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:39:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214759 - stable/8/lib/libthread_db
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:39:12 -0000

Author: kib
Date: Wed Nov  3 21:39:11 2010
New Revision: 214759
URL: http://svn.freebsd.org/changeset/base/214759

Log:
  MFC r209689:
  Extend the td_thrinfo_t to include siginfo for the signal that stopped
  the target.

Modified:
  stable/8/lib/libthread_db/Symbol.map
  stable/8/lib/libthread_db/libpthread_db.c
  stable/8/lib/libthread_db/libthr_db.c
  stable/8/lib/libthread_db/thread_db.c
  stable/8/lib/libthread_db/thread_db.h
  stable/8/lib/libthread_db/thread_db_int.h
Directory Properties:
  stable/8/lib/libthread_db/   (props changed)

Modified: stable/8/lib/libthread_db/Symbol.map
==============================================================================
--- stable/8/lib/libthread_db/Symbol.map	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/Symbol.map	Wed Nov  3 21:39:11 2010	(r214759)
@@ -19,7 +19,6 @@ FBSD_1.0 {
 	td_thr_dbsuspend;
 	td_thr_event_enable;
 	td_thr_event_getmsg;
-	td_thr_get_info;
 	td_thr_getfpregs;
 	td_thr_getgregs;
 #if defined(i386)
@@ -33,3 +32,7 @@ FBSD_1.0 {
 	td_thr_tls_get_addr;
 	td_thr_validate;
 };
+
+FBSD_1.2 {
+	td_thr_get_info;
+};

Modified: stable/8/lib/libthread_db/libpthread_db.c
==============================================================================
--- stable/8/lib/libthread_db/libpthread_db.c	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/libpthread_db.c	Wed Nov  3 21:39:11 2010	(r214759)
@@ -570,7 +570,7 @@ pt_thr_validate(const td_thrhandle_t *th
 }
 
 static td_err_e
-pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
+pt_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info)
 {
 	const td_thragent_t *ta = th->th_ta;
 	struct ptrace_lwpinfo linfo;
@@ -659,6 +659,16 @@ pt_thr_get_info(const td_thrhandle_t *th
 	return (0);
 }
 
+static td_err_e
+pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
+{
+	td_err_e e;
+
+	e = pt_thr_old_get_info(th, (td_old_thrinfo_t *)info);
+	bzero(&info->ti_siginfo, sizeof(info->ti_siginfo));
+	return (e);
+}
+
 #ifdef __i386__
 static td_err_e
 pt_thr_getxmmregs(const td_thrhandle_t *th, char *fxsave)
@@ -1114,6 +1124,7 @@ struct ta_ops libpthread_db_ops = {
 	.to_thr_dbsuspend	= pt_thr_dbsuspend,
 	.to_thr_event_enable	= pt_thr_event_enable,
 	.to_thr_event_getmsg	= pt_thr_event_getmsg,
+	.to_thr_old_get_info	= pt_thr_old_get_info,
 	.to_thr_get_info	= pt_thr_get_info,
 	.to_thr_getfpregs	= pt_thr_getfpregs,
 	.to_thr_getgregs	= pt_thr_getgregs,

Modified: stable/8/lib/libthread_db/libthr_db.c
==============================================================================
--- stable/8/lib/libthread_db/libthr_db.c	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/libthr_db.c	Wed Nov  3 21:39:11 2010	(r214759)
@@ -453,7 +453,7 @@ pt_thr_validate(const td_thrhandle_t *th
 }
 
 static td_err_e
-pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
+pt_thr_get_info_common(const td_thrhandle_t *th, td_thrinfo_t *info, int old)
 {
 	const td_thragent_t *ta = th->th_ta;
 	struct ptrace_lwpinfo linfo;
@@ -489,6 +489,13 @@ pt_thr_get_info(const td_thrhandle_t *th
 	if (ret == PS_OK) {
 		info->ti_sigmask = linfo.pl_sigmask;
 		info->ti_pending = linfo.pl_siglist;
+		if (!old) {
+			if ((linfo.pl_flags & PL_FLAG_SI) != 0)
+				info->ti_siginfo = linfo.pl_siginfo;
+			else
+				bzero(&info->ti_siginfo,
+				    sizeof(info->ti_siginfo));
+		}
 	} else
 		return (ret);
 	if (state == ta->thread_state_running)
@@ -501,6 +508,20 @@ pt_thr_get_info(const td_thrhandle_t *th
 	return (0);
 }
 
+static td_err_e
+pt_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info)
+{
+
+	return (pt_thr_get_info_common(th, (td_thrinfo_t *)info, 1));
+}
+
+static td_err_e
+pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
+{
+
+	return (pt_thr_get_info_common(th, info, 0));
+}
+
 #ifdef __i386__
 static td_err_e
 pt_thr_getxmmregs(const td_thrhandle_t *th, char *fxsave)
@@ -761,6 +782,7 @@ struct ta_ops libthr_db_ops = {
 	.to_thr_dbsuspend	= pt_thr_dbsuspend,
 	.to_thr_event_enable	= pt_thr_event_enable,
 	.to_thr_event_getmsg	= pt_thr_event_getmsg,
+	.to_thr_old_get_info	= pt_thr_old_get_info,
 	.to_thr_get_info	= pt_thr_get_info,
 	.to_thr_getfpregs	= pt_thr_getfpregs,
 	.to_thr_getgregs	= pt_thr_getgregs,

Modified: stable/8/lib/libthread_db/thread_db.c
==============================================================================
--- stable/8/lib/libthread_db/thread_db.c	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/thread_db.c	Wed Nov  3 21:39:11 2010	(r214759)
@@ -176,6 +176,14 @@ td_thr_event_getmsg(const td_thrhandle_t
 }
 
 td_err_e
+td_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info)
+{
+	const td_thragent_t *ta = th->th_ta;
+	return (ta->ta_ops->to_thr_old_get_info(th, info));
+}
+__sym_compat(td_thr_get_info, td_thr_old_get_info, FBSD_1.0);
+
+td_err_e
 td_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
 {
 	const td_thragent_t *ta = th->th_ta;

Modified: stable/8/lib/libthread_db/thread_db.h
==============================================================================
--- stable/8/lib/libthread_db/thread_db.h	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/thread_db.h	Wed Nov  3 21:39:11 2010	(r214759)
@@ -191,6 +191,7 @@ typedef struct {
 	psaddr_t	ti_startfunc;
 	psaddr_t	ti_stkbase;
 	size_t		ti_stksize;
+	siginfo_t	ti_siginfo;
 } td_thrinfo_t;
 
 /*

Modified: stable/8/lib/libthread_db/thread_db_int.h
==============================================================================
--- stable/8/lib/libthread_db/thread_db_int.h	Wed Nov  3 21:32:31 2010	(r214758)
+++ stable/8/lib/libthread_db/thread_db_int.h	Wed Nov  3 21:39:11 2010	(r214759)
@@ -32,6 +32,25 @@
 #include 
 #include 
 
+typedef struct {
+	const td_thragent_t *ti_ta_p;
+	thread_t	ti_tid;
+	psaddr_t	ti_thread;
+	td_thr_state_e	ti_state;
+	td_thr_type_e	ti_type;
+	td_thr_events_t	ti_events;
+	int		ti_pri;
+	lwpid_t		ti_lid;
+	char		ti_db_suspended;
+	char		ti_traceme;
+	sigset_t	ti_sigmask;
+	sigset_t	ti_pending;
+	psaddr_t	ti_tls;
+	psaddr_t	ti_startfunc;
+	psaddr_t	ti_stkbase;
+	size_t		ti_stksize;
+} td_old_thrinfo_t;
+
 #define	TD_THRAGENT_FIELDS			\
 	struct ta_ops		*ta_ops;	\
 	TAILQ_ENTRY(td_thragent) ta_next;	\
@@ -65,6 +84,8 @@ struct ta_ops {
 	td_err_e (*to_thr_event_enable)(const td_thrhandle_t *, int);
 	td_err_e (*to_thr_event_getmsg)(const td_thrhandle_t *,
 	    td_event_msg_t *);
+	td_err_e (*to_thr_old_get_info)(const td_thrhandle_t *,
+	    td_old_thrinfo_t *);
 	td_err_e (*to_thr_get_info)(const td_thrhandle_t *, td_thrinfo_t *);
 	td_err_e (*to_thr_getfpregs)(const td_thrhandle_t *, prfpregset_t *);
 	td_err_e (*to_thr_getgregs)(const td_thrhandle_t *, prgregset_t);
@@ -103,4 +124,6 @@ int thr_pwrite_int(const struct td_thrag
 int thr_pwrite_long(const struct td_thragent *, psaddr_t, uint64_t);
 int thr_pwrite_ptr(const struct td_thragent *, psaddr_t, psaddr_t);
 
+td_err_e td_thr_old_get_info(const td_thrhandle_t *th, td_old_thrinfo_t *info);
+
 #endif /* _THREAD_DB_INT_H_ */

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:40:58 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 101A81065672;
	Wed,  3 Nov 2010 21:40:58 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D88578FC13;
	Wed,  3 Nov 2010 21:40: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 oA3LevZL034461;
	Wed, 3 Nov 2010 21:40:57 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3Levi9034459;
	Wed, 3 Nov 2010 21:40:57 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032140.oA3Levi9034459@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:40:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214760 - stable/8/gnu/usr.bin/gdb/libgdb
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:40:58 -0000

Author: kib
Date: Wed Nov  3 21:40:57 2010
New Revision: 214760
URL: http://svn.freebsd.org/changeset/base/214760

Log:
  MFC r209690:
  For "thread signal" command, print some information from siginfo when
  available.

Modified:
  stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c
Directory Properties:
  stable/8/gnu/usr.bin/gdb/   (props changed)
  stable/8/gnu/usr.bin/gdb/kgdb/   (props changed)

Modified: stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c
==============================================================================
--- stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c	Wed Nov  3 21:39:11 2010	(r214759)
+++ stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c	Wed Nov  3 21:40:57 2010	(r214760)
@@ -1299,6 +1299,7 @@ fbsd_thread_signal_cmd (char *exp, int f
   td_thrhandle_t th;
   td_thrinfo_t ti;
   td_err_e err;
+  const char *code;
 
   if (!fbsd_thread_active || !IS_THREAD(inferior_ptid))
     return;
@@ -1315,6 +1316,42 @@ fbsd_thread_signal_cmd (char *exp, int f
   fbsd_print_sigset(&ti.ti_sigmask);
   printf_filtered("signal pending:\n");
   fbsd_print_sigset(&ti.ti_pending);
+  if (ti.ti_siginfo.si_signo != 0) {
+   printf_filtered("si_signo %d si_errno %d", ti.ti_siginfo.si_signo,
+     ti.ti_siginfo.si_errno);
+   if (ti.ti_siginfo.si_errno != 0)
+    printf_filtered(" (%s)", strerror(ti.ti_siginfo.si_errno));
+   printf_filtered("\n");
+   switch (ti.ti_siginfo.si_code) {
+   case SI_NOINFO:
+	code = "NOINFO";
+	break;
+    case SI_USER:
+	code = "USER";
+	break;
+    case SI_QUEUE:
+	code = "QUEUE";
+	break;
+    case SI_TIMER:
+	code = "TIMER";
+	break;
+    case SI_ASYNCIO:
+	code = "ASYNCIO";
+	break;
+    case SI_MESGQ:
+	code = "MESGQ";
+	break;
+    case SI_KERNEL:
+	code = "KERNEL";
+	break;
+    default:
+	code = "UNKNOWN";
+	break;
+    }
+    printf_filtered("si_code %s si_pid %d si_uid %d si_status %x si_addr %p\n",
+      code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, ti.ti_siginfo.si_status,
+      ti.ti_siginfo.si_addr);
+  }
 }
 
 static int

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 21:51:05 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B1D08106566B;
	Wed,  3 Nov 2010 21:51:05 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A05298FC15;
	Wed,  3 Nov 2010 21:51: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 oA3Lp5Di034823;
	Wed, 3 Nov 2010 21:51:05 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3Lp5K1034821;
	Wed, 3 Nov 2010 21:51:05 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201011032151.oA3Lp5K1034821@svn.freebsd.org>
From: Konstantin Belousov 
Date: Wed, 3 Nov 2010 21:51:05 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214762 - stable/8/sys/sys
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 21:51:05 -0000

Author: kib
Date: Wed Nov  3 21:51:05 2010
New Revision: 214762
URL: http://svn.freebsd.org/changeset/base/214762

Log:
  Bump __FreeBSD_version for struct sysentvec changes in r214755.

Modified:
  stable/8/sys/sys/param.h

Modified: stable/8/sys/sys/param.h
==============================================================================
--- stable/8/sys/sys/param.h	Wed Nov  3 21:50:49 2010	(r214761)
+++ stable/8/sys/sys/param.h	Wed Nov  3 21:51:05 2010	(r214762)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 801500	/* Master, propagated to newvers */
+#define __FreeBSD_version 801501	/* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include 

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Nov  3 22:17:42 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E45B31065670;
	Wed,  3 Nov 2010 22:17:42 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BA5F08FC14;
	Wed,  3 Nov 2010 22:17:42 +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 oA3MHgba035546;
	Wed, 3 Nov 2010 22:17:42 GMT (envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3MHgVB035543;
	Wed, 3 Nov 2010 22:17:42 GMT (envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201011032217.oA3MHgVB035543@svn.freebsd.org>
From: Rick Macklem 
Date: Wed, 3 Nov 2010 22:17:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214763 - in stable/8/sys/fs: nfs nfsserver
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Wed, 03 Nov 2010 22:17:43 -0000

Author: rmacklem
Date: Wed Nov  3 22:17:42 2010
New Revision: 214763
URL: http://svn.freebsd.org/changeset/base/214763

Log:
  MFC: r214255
  Modify the experimental NFSv4 server's file handle hash function
  to use the generic hash32_buf() function. Although adding the
  bytes seemed sufficient for UFS and ZFS, since most of the bytes
  are the same for file handles on the same volume, this might not
  be sufficient for other file systems. Use of a generic function
  also seems preferable to one specific to NFSv4.

Modified:
  stable/8/sys/fs/nfs/nfs_var.h
  stable/8/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/fs/nfs/nfs_var.h
==============================================================================
--- stable/8/sys/fs/nfs/nfs_var.h	Wed Nov  3 21:51:05 2010	(r214762)
+++ stable/8/sys/fs/nfs/nfs_var.h	Wed Nov  3 22:17:42 2010	(r214763)
@@ -578,7 +578,7 @@ void nfsvno_unlockvfs(mount_t);
 int nfsvno_lockvfs(mount_t);
 int nfsrv_v4rootexport(void *, struct ucred *, NFSPROC_T *);
 int nfsvno_testexp(struct nfsrv_descript *, struct nfsexstuff *);
-int nfsrv_hashfh(fhandle_t *);
+uint32_t nfsrv_hashfh(fhandle_t *);
 
 /* nfs_commonkrpc.c */
 int newnfs_nmcancelreqs(struct nfsmount *);

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdport.c	Wed Nov  3 21:51:05 2010	(r214762)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdport.c	Wed Nov  3 22:17:42 2010	(r214763)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3090,15 +3091,12 @@ nfsvno_testexp(struct nfsrv_descript *nd
 /*
  * Calculate a hash value for the fid in a file handle.
  */
-int
+uint32_t
 nfsrv_hashfh(fhandle_t *fhp)
 {
-	int hashval = 0, i;
-	uint8_t *cp;
+	uint32_t hashval;
 
-	cp = (uint8_t *)&fhp->fh_fid;
-	for (i = 0; i < sizeof(struct fid); i++)
-		hashval += *cp++;
+	hashval = hash32_buf(&fhp->fh_fid, sizeof(struct fid), 0);
 	return (hashval);
 }
 

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 10:53:51 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F377C106564A;
	Thu,  4 Nov 2010 10:53:50 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E03EC8FC0C;
	Thu,  4 Nov 2010 10:53: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 oA4AroNj057697;
	Thu, 4 Nov 2010 10:53:50 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4AroW0057692;
	Thu, 4 Nov 2010 10:53:50 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201011041053.oA4AroW0057692@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Thu, 4 Nov 2010 10:53:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214779 - in stable/8/usr.bin: lex yacc
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 10:53:51 -0000

Author: uqs
Date: Thu Nov  4 10:53:50 2010
New Revision: 214779
URL: http://svn.freebsd.org/changeset/base/214779

Log:
  MFC r200626,201289,213764,214272, syncing yacc and flex to -CURRENT
  
  r200626:
  remove external reference to not (or at least no longer) existing variable 'myname'
  
  r201289:
  Let both yacc and lex generate code that passes -Wold-style-definition.
  
  Both these tools emit code where several functions have no `void'
  keyword placed in the arugment list when the function has no arguments.
  
  r213764:
  Don't define the input() function ifdef YY_NO_INPUT.
  This was previously done for the input() function.
  
  r214272:
  flex: add missing ifdef magic to create/hide prototypes
  This unbreaks build for some software with higher WARNS flags.

Modified:
  stable/8/usr.bin/lex/flex.skl
  stable/8/usr.bin/lex/initscan.c
  stable/8/usr.bin/yacc/defs.h
  stable/8/usr.bin/yacc/skeleton.c
Directory Properties:
  stable/8/usr.bin/lex/   (props changed)
  stable/8/usr.bin/yacc/   (props changed)

Modified: stable/8/usr.bin/lex/flex.skl
==============================================================================
--- stable/8/usr.bin/lex/flex.skl	Thu Nov  4 10:47:19 2010	(r214778)
+++ stable/8/usr.bin/lex/flex.skl	Thu Nov  4 10:53:50 2010	(r214779)
@@ -747,7 +747,11 @@ void yyFlexLexer::LexerOutput( const cha
  */
 
 %-
+#ifdef YY_USE_PROTOS
+static int yy_get_next_buffer(void)
+#else
 static int yy_get_next_buffer()
+#endif
 %+
 int yyFlexLexer::yy_get_next_buffer()
 %*
@@ -883,7 +887,11 @@ int yyFlexLexer::yy_get_next_buffer()
 /* yy_get_previous_state - get the state just before the EOB char was reached */
 
 %-
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_get_previous_state(void)
+#else
 static yy_state_type yy_get_previous_state()
+#endif
 %+
 yy_state_type yyFlexLexer::yy_get_previous_state()
 %*
@@ -979,11 +987,16 @@ void yyFlexLexer::yyunput( int c, char* 
 
 
 %-
+#ifndef YY_NO_INPUT
 #ifdef __cplusplus
 static int yyinput()
 #else
+#ifdef YY_USE_PROTOS
+static int input(void)
+#else
 static int input()
 #endif
+#endif
 %+
 int yyFlexLexer::yyinput()
 %*
@@ -1054,6 +1067,9 @@ int yyFlexLexer::yyinput()
 
 	return c;
 	}
+%-
+#endif	/* ifndef YY_NO_INPUT */
+%*
 
 
 %-
@@ -1402,7 +1418,11 @@ void yyFlexLexer::yy_push_state( int new
 
 #ifndef YY_NO_POP_STATE
 %-
+#ifdef YY_USE_PROTOS
+static void yy_pop_state(void)
+#else
 static void yy_pop_state()
+#endif
 %+
 void yyFlexLexer::yy_pop_state()
 %*
@@ -1417,7 +1437,11 @@ void yyFlexLexer::yy_pop_state()
 
 #ifndef YY_NO_TOP_STATE
 %-
+#ifdef YY_USE_PROTOS
+static int yy_top_state(void)
+#else
 static int yy_top_state()
+#endif
 %+
 int yyFlexLexer::yy_top_state()
 %*

Modified: stable/8/usr.bin/lex/initscan.c
==============================================================================
--- stable/8/usr.bin/lex/initscan.c	Thu Nov  4 10:47:19 2010	(r214778)
+++ stable/8/usr.bin/lex/initscan.c	Thu Nov  4 10:53:50 2010	(r214779)
@@ -2894,7 +2894,7 @@ case YY_STATE_EOF(LINEDIR):
  *	EOB_ACT_END_OF_FILE - end of file
  */
 
-static int yy_get_next_buffer()
+static int yy_get_next_buffer(void)
 	{
 	char *dest = yy_current_buffer->yy_ch_buf;
 	char *source = yytext_ptr;
@@ -3026,7 +3026,7 @@ static int yy_get_next_buffer()
 
 /* yy_get_previous_state - get the state just before the EOB char was reached */
 
-static yy_state_type yy_get_previous_state()
+static yy_state_type yy_get_previous_state(void)
 	{
 	yy_state_type yy_current_state;
 	char *yy_cp;
@@ -3138,7 +3138,7 @@ char *yy_bp;
 #ifdef __cplusplus
 static int yyinput()
 #else
-static int input()
+static int input(void)
 #endif
 	{
 	int c;

Modified: stable/8/usr.bin/yacc/defs.h
==============================================================================
--- stable/8/usr.bin/yacc/defs.h	Thu Nov  4 10:47:19 2010	(r214778)
+++ stable/8/usr.bin/yacc/defs.h	Thu Nov  4 10:53:50 2010	(r214779)
@@ -220,7 +220,6 @@ extern char tflag;
 extern char vflag;
 extern const char *symbol_prefix;
 
-extern char *myname;
 extern char *cptr;
 extern char *line;
 extern int lineno;

Modified: stable/8/usr.bin/yacc/skeleton.c
==============================================================================
--- stable/8/usr.bin/yacc/skeleton.c	Thu Nov  4 10:47:19 2010	(r214778)
+++ stable/8/usr.bin/yacc/skeleton.c	Thu Nov  4 10:53:50 2010	(r214779)
@@ -140,7 +140,11 @@ const char *header[] =
 const char *body[] =
 {
     "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
+    "#if defined(__cplusplus) || __STDC__",
+    "static int yygrowstack(void)",
+    "#else",
     "static int yygrowstack()",
+    "#endif",
     "{",
     "    int newsize, i;",
     "    short *newss;",

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 12:33:08 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 544EC106566B;
	Thu,  4 Nov 2010 12:33:08 +0000 (UTC) (envelope-from uqs@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 41AF88FC19;
	Thu,  4 Nov 2010 12:33:08 +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 oA4CX8lr060060;
	Thu, 4 Nov 2010 12:33:08 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4CX86u060057;
	Thu, 4 Nov 2010 12:33:08 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201011041233.oA4CX86u060057@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Thu, 4 Nov 2010 12:33:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214780 - stable/8/usr.sbin/rtadvd
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 12:33:08 -0000

Author: uqs
Date: Thu Nov  4 12:33:07 2010
New Revision: 214780
URL: http://svn.freebsd.org/changeset/base/214780

Log:
  MFC r208028,214491: Sync manpages to -CURRENT
  
  r208028:
  mdoc: move remaining sections into consistent order
  
  r214491:
  Fix another "string" typo.

Modified:
  stable/8/usr.sbin/rtadvd/rtadvd.8
  stable/8/usr.sbin/rtadvd/rtadvd.conf.5
Directory Properties:
  stable/8/usr.sbin/rtadvd/   (props changed)

Modified: stable/8/usr.sbin/rtadvd/rtadvd.8
==============================================================================
--- stable/8/usr.sbin/rtadvd/rtadvd.8	Thu Nov  4 10:53:50 2010	(r214779)
+++ stable/8/usr.sbin/rtadvd/rtadvd.8	Thu Nov  4 12:33:07 2010	(r214780)
@@ -162,8 +162,6 @@ In this case,
 will transmit router advertisement with router lifetime 0
 to all the interfaces
 .Pq in accordance with RFC2461 6.2.5 .
-.Sh EXIT STATUS
-.Ex -std
 .Sh FILES
 .Bl -tag -width Pa -compact
 .It Pa /etc/rtadvd.conf
@@ -176,6 +174,8 @@ The file in which
 .Nm
 dumps its internal state.
 .El
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr rtadvd.conf 5 ,
 .Xr rtsol 8

Modified: stable/8/usr.sbin/rtadvd/rtadvd.conf.5
==============================================================================
--- stable/8/usr.sbin/rtadvd/rtadvd.conf.5	Thu Nov  4 10:53:50 2010	(r214779)
+++ stable/8/usr.sbin/rtadvd/rtadvd.conf.5	Thu Nov  4 12:33:07 2010	(r214780)
@@ -201,7 +201,7 @@ The default value is 64.
 (str or num) A 8-bit flags field in prefix information option.
 This field can be specified either as a case-sensitive string or as an
 integer.
-A sting consists of characters each of which corresponds to a
+A string consists of characters each of which corresponds to a
 particular flag bit(s).
 An integer should be the logical OR of all enabled bits.
 Bit 7

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 17:06:55 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 53C3A106564A;
	Thu,  4 Nov 2010 17:06:55 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 415AA8FC12;
	Thu,  4 Nov 2010 17:06: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 oA4H6tNd066335;
	Thu, 4 Nov 2010 17:06:55 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4H6t1d066331;
	Thu, 4 Nov 2010 17:06:55 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011041706.oA4H6t1d066331@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 4 Nov 2010 17:06:55 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214784 - in stable/8/sys: conf x86 x86/pci
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 17:06:55 -0000

Author: jhb
Date: Thu Nov  4 17:06:54 2010
New Revision: 214784
URL: http://svn.freebsd.org/changeset/base/214784

Log:
  MFC 211820,211821,212292:
  Intel QPI chipsets actually provide extra "non-core" PCI buses that
  provide PCI devices for various hardware such as memory controllers,
  etc.  for each socket.  These PCI buses are not enumerated via ACPI
  however.  Add qpi(4) psuedo bus and Host-PCI bridge drivers to
  enumerate these buses.  Currently the driver uses the CPU ID to
  determine the bridges' presence.

Added:
  stable/8/sys/x86/
  stable/8/sys/x86/pci/
     - copied from r211820, head/sys/x86/pci/
Modified:
  stable/8/sys/conf/files.amd64
  stable/8/sys/conf/files.i386
  stable/8/sys/x86/pci/qpi.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/conf/files.amd64
==============================================================================
--- stable/8/sys/conf/files.amd64	Thu Nov  4 17:01:21 2010	(r214783)
+++ stable/8/sys/conf/files.amd64	Thu Nov  4 17:06:54 2010	(r214784)
@@ -313,3 +313,7 @@ libkern/memset.c		standard
 #
 compat/x86bios/x86bios.c	optional x86bios | atkbd | dpms | vesa
 contrib/x86emu/x86emu.c		optional x86bios | atkbd | dpms | vesa
+#
+# x86 shared code between IA32, AMD64 and PC98 architectures
+#
+x86/pci/qpi.c			standard

Modified: stable/8/sys/conf/files.i386
==============================================================================
--- stable/8/sys/conf/files.i386	Thu Nov  4 17:01:21 2010	(r214783)
+++ stable/8/sys/conf/files.i386	Thu Nov  4 17:06:54 2010	(r214784)
@@ -388,3 +388,7 @@ i386/xbox/pic16l.s		optional xbox
 #
 compat/x86bios/x86bios.c	optional x86bios | atkbd | dpms | vesa
 contrib/x86emu/x86emu.c		optional x86bios | atkbd | dpms | vesa
+#
+# x86 shared code between IA32, AMD64 and PC98 architectures
+#
+x86/pci/qpi.c			standard

Modified: stable/8/sys/x86/pci/qpi.c
==============================================================================
--- head/sys/x86/pci/qpi.c	Wed Aug 25 19:12:05 2010	(r211820)
+++ stable/8/sys/x86/pci/qpi.c	Thu Nov  4 17:06:54 2010	(r214784)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include "pcib_if.h"
@@ -62,7 +63,8 @@ qpi_identify(driver_t *driver, device_t 
 {
 
         /* Check CPUID to ensure this is an i7 CPU of some sort. */
-        if (!(cpu_vendor_id == CPU_VENDOR_INTEL && CPUID_TO_FAMILY(cpu_id) &&
+        if (!(cpu_vendor_id == CPU_VENDOR_INTEL &&
+	    CPUID_TO_FAMILY(cpu_id) == 0x6 &&
 	    (CPUID_TO_MODEL(cpu_id) == 0x1a || CPUID_TO_MODEL(cpu_id) == 0x2c)))
                 return;
 
@@ -83,31 +85,62 @@ qpi_probe(device_t dev)
 	return (BUS_PROBE_SPECIFIC);
 }
 
+/*
+ * Look for a PCI bus with the specified bus address.  If one is found,
+ * add a pcib device and return 0.  Otherwise, return an error code.
+ */
 static int
-qpi_attach(device_t dev)
+qpi_probe_pcib(device_t dev, int bus)
 {
 	struct qpi_device *qdev;
 	device_t child;
+	uint32_t devid;
 
 	/*
-	 * Add two Host-PCI bridge devices, one for PCI bus 254 and
-	 * one for PCI bus 255.
+	 * If a PCI bus already exists for this bus number, then
+	 * fail.
 	 */
-	child = BUS_ADD_CHILD(dev, 0, "pcib", -1);
-	if (child == NULL)
-		panic("%s: failed to add pci bus 254",
-		    device_get_nameunit(dev));
-	qdev = malloc(sizeof(struct qpi_device), M_QPI, M_WAITOK);
-	qdev->qd_pcibus = 254;
-	device_set_ivars(child, qdev);
+	if (pci_find_bsf(bus, 0, 0) != NULL)
+		return (EEXIST);
+
+	/*
+	 * Attempt to read the device id for device 0, function 0 on
+	 * the bus.  A value of 0xffffffff means that the bus is not
+	 * present.
+	 */
+	devid = pci_cfgregread(bus, 0, 0, PCIR_DEVVENDOR, 4);
+	if (devid == 0xffffffff)
+		return (ENOENT);
+
+	if ((devid & 0xffff) != 0x8086) {
+		device_printf(dev,
+		    "Device at pci%d.0.0 has non-Intel vendor 0x%x\n", bus,
+		    devid & 0xffff);
+		return (ENXIO);
+	}
 
 	child = BUS_ADD_CHILD(dev, 0, "pcib", -1);
 	if (child == NULL)
-		panic("%s: failed to add pci bus 255",
-		    device_get_nameunit(dev));
+		panic("%s: failed to add pci bus %d", device_get_nameunit(dev),
+		    bus);
 	qdev = malloc(sizeof(struct qpi_device), M_QPI, M_WAITOK);
-	qdev->qd_pcibus = 255;
+	qdev->qd_pcibus = bus;
 	device_set_ivars(child, qdev);
+	return (0);
+}
+
+static int
+qpi_attach(device_t dev)
+{
+	int bus;
+
+	/*
+	 * Each processor socket has a dedicated PCI bus counting down from
+	 * 255.  We keep probing buses until one fails.
+	 */
+	for (bus = 255;; bus--)
+		if (qpi_probe_pcib(dev, bus) != 0)
+			break;
 
 	return (bus_generic_attach(dev));
 }

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 17:12:29 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C687A106566B;
	Thu,  4 Nov 2010 17:12:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9A55D8FC20;
	Thu,  4 Nov 2010 17:12:29 +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 oA4HCTTo066557;
	Thu, 4 Nov 2010 17:12:29 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4HCTHw066555;
	Thu, 4 Nov 2010 17:12:29 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011041712.oA4HCTHw066555@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 4 Nov 2010 17:12:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214786 - stable/8/sys/dev/pci
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 17:12:29 -0000

Author: jhb
Date: Thu Nov  4 17:12:29 2010
New Revision: 214786
URL: http://svn.freebsd.org/changeset/base/214786

Log:
  MFC 214203:
  - Add a new PCI quirk to whitelist an old chipset that doesn't support
    PCI-express or PCI-X capabilities if we are running in a virtual machine.
  - Whitelist the Intel 82440 chipset used by QEMU.

Modified:
  stable/8/sys/dev/pci/pci.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Thu Nov  4 17:07:13 2010	(r214785)
+++ stable/8/sys/dev/pci/pci.c	Thu Nov  4 17:12:29 2010	(r214786)
@@ -184,6 +184,7 @@ struct pci_quirk {
 	int	type;
 #define	PCI_QUIRK_MAP_REG	1 /* PCI map register in weird place */
 #define	PCI_QUIRK_DISABLE_MSI	2 /* MSI/MSI-X doesn't work */
+#define	PCI_QUIRK_ENABLE_MSI_VM	3 /* Older chipset in VM where MSI works */
 	int	arg1;
 	int	arg2;
 };
@@ -220,6 +221,12 @@ struct pci_quirk pci_quirks[] = {
 	 */
 	{ 0x74501022, PCI_QUIRK_DISABLE_MSI,	0,	0 },
 
+	/*
+	 * Some virtualization environments emulate an older chipset
+	 * but support MSI just fine.  QEMU uses the Intel 82440.
+	 */
+	{ 0x12378086, PCI_QUIRK_ENABLE_MSI_VM,	0,	0 },
+
 	{ 0 }
 };
 
@@ -1803,6 +1810,23 @@ pci_msi_device_blacklisted(device_t dev)
 }
 
 /*
+ * Returns true if a specified chipset supports MSI when it is
+ * emulated hardware in a virtual machine.
+ */
+static int
+pci_msi_vm_chipset(device_t dev)
+{
+	struct pci_quirk *q;
+
+	for (q = &pci_quirks[0]; q->devid; q++) {
+		if (q->devid == pci_get_devid(dev) &&
+		    q->type == PCI_QUIRK_ENABLE_MSI_VM)
+			return (1);
+	}
+	return (0);
+}
+
+/*
  * Determine if MSI is blacklisted globally on this sytem.  Currently,
  * we just check for blacklisted chipsets as represented by the
  * host-PCI bridge at device 0:0:0.  In the future, it may become
@@ -1818,8 +1842,14 @@ pci_msi_blacklisted(void)
 		return (0);
 
 	/* Blacklist all non-PCI-express and non-PCI-X chipsets. */
-	if (!(pcie_chipset || pcix_chipset))
+	if (!(pcie_chipset || pcix_chipset)) {
+		if (vm_guest != VM_GUEST_NO) {
+			dev = pci_find_bsf(0, 0, 0);
+			if (dev != NULL)
+				return (pci_msi_vm_chipset(dev) == 0);
+		}
 		return (1);
+	}
 
 	dev = pci_find_bsf(0, 0, 0);
 	if (dev != NULL)

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 17:19:16 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AC38E106564A;
	Thu,  4 Nov 2010 17:19:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9A5228FC0C;
	Thu,  4 Nov 2010 17:19: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 oA4HJGnU066775;
	Thu, 4 Nov 2010 17:19:16 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4HJGaU066772;
	Thu, 4 Nov 2010 17:19:16 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011041719.oA4HJGaU066772@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 4 Nov 2010 17:19:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214788 - in stable/8/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 17:19:16 -0000

Author: jhb
Date: Thu Nov  4 17:19:16 2010
New Revision: 214788
URL: http://svn.freebsd.org/changeset/base/214788

Log:
  MFC 214448:
  Use 'PCPU_GET(apic_id)' to determine the BSP's APIC ID on a UP machine
  when routing interrupts instead of cpu_apic_ids[0] since cpu_apic_ids[]
  is only populated for multiple-CPU machines.  This also matches what the
  code does when SMP is not enabled.

Modified:
  stable/8/sys/amd64/amd64/intr_machdep.c
  stable/8/sys/i386/i386/intr_machdep.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/amd64/amd64/intr_machdep.c
==============================================================================
--- stable/8/sys/amd64/amd64/intr_machdep.c	Thu Nov  4 17:13:30 2010	(r214787)
+++ stable/8/sys/amd64/amd64/intr_machdep.c	Thu Nov  4 17:19:16 2010	(r214788)
@@ -458,7 +458,7 @@ intr_next_cpu(void)
 
 	/* Leave all interrupts on the BSP during boot. */
 	if (!assign_cpu)
-		return (cpu_apic_ids[0]);
+		return (PCPU_GET(apic_id));
 
 	mtx_lock_spin(&icu_lock);
 	apic_id = cpu_apic_ids[current_cpu];

Modified: stable/8/sys/i386/i386/intr_machdep.c
==============================================================================
--- stable/8/sys/i386/i386/intr_machdep.c	Thu Nov  4 17:13:30 2010	(r214787)
+++ stable/8/sys/i386/i386/intr_machdep.c	Thu Nov  4 17:19:16 2010	(r214788)
@@ -424,7 +424,7 @@ intr_next_cpu(void)
 
 	/* Leave all interrupts on the BSP during boot. */
 	if (!assign_cpu)
-		return (cpu_apic_ids[0]);
+		return (PCPU_GET(apic_id));
 
 	mtx_lock_spin(&icu_lock);
 	apic_id = cpu_apic_ids[current_cpu];

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 17:22:49 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E5F65106564A;
	Thu,  4 Nov 2010 17:22:49 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D44AC8FC12;
	Thu,  4 Nov 2010 17:22:49 +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 oA4HMnwP066916;
	Thu, 4 Nov 2010 17:22:49 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4HMn77066914;
	Thu, 4 Nov 2010 17:22:49 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011041722.oA4HMn77066914@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 4 Nov 2010 17:22:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214789 - stable/8/sys/kern
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 17:22:50 -0000

Author: jhb
Date: Thu Nov  4 17:22:49 2010
New Revision: 214789
URL: http://svn.freebsd.org/changeset/base/214789

Log:
  MFC 214449:
  Set bootverbose directly in mi_startup() rather than via a SYSINIT.  This
  ensures 'bootverbose' is in a valid state for all SYSINITs.

Modified:
  stable/8/sys/kern/init_main.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/init_main.c
==============================================================================
--- stable/8/sys/kern/init_main.c	Thu Nov  4 17:19:16 2010	(r214788)
+++ stable/8/sys/kern/init_main.c	Thu Nov  4 17:22:49 2010	(r214789)
@@ -178,6 +178,9 @@ mi_startup(void)
 	int verbose;
 #endif
 
+	if (boothowto & RB_VERBOSE)
+		bootverbose++;
+
 	if (sysinit == NULL) {
 		sysinit = SET_BEGIN(sysinit_set);
 		sysinit_end = SET_LIMIT(sysinit_set);
@@ -325,15 +328,6 @@ SYSINIT(diagwarn2, SI_SUB_RUN_SCHEDULER,
     print_caddr_t, diag_warn);
 #endif
 
-static void
-set_boot_verbose(void *data __unused)
-{
-
-	if (boothowto & RB_VERBOSE)
-		bootverbose++;
-}
-SYSINIT(boot_verbose, SI_SUB_TUNABLES, SI_ORDER_ANY, set_boot_verbose, NULL);
-
 static int
 null_fetch_syscall_args(struct thread *td __unused,
     struct syscall_args *sa __unused)

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 17:25:31 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 63686106566B;
	Thu,  4 Nov 2010 17:25:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5194D8FC16;
	Thu,  4 Nov 2010 17:25:31 +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 oA4HPVR6067096;
	Thu, 4 Nov 2010 17:25:31 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4HPVtQ067094;
	Thu, 4 Nov 2010 17:25:31 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201011041725.oA4HPVtQ067094@svn.freebsd.org>
From: John Baldwin 
Date: Thu, 4 Nov 2010 17:25:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214791 - stable/8/usr.bin/kdump
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 17:25:31 -0000

Author: jhb
Date: Thu Nov  4 17:25:31 2010
New Revision: 214791
URL: http://svn.freebsd.org/changeset/base/214791

Log:
  MFC 214625: Correct the abbreviations for general I/O and signal traces.

Modified:
  stable/8/usr.bin/kdump/kdump.1
Directory Properties:
  stable/8/usr.bin/kdump/   (props changed)

Modified: stable/8/usr.bin/kdump/kdump.1
==============================================================================
--- stable/8/usr.bin/kdump/kdump.1	Thu Nov  4 17:23:06 2010	(r214790)
+++ stable/8/usr.bin/kdump/kdump.1	Thu Nov  4 17:25:31 2010	(r214791)
@@ -162,13 +162,13 @@ Seven bytes were written by the
 system call, so 7 is the return value.
 .Pp
 The possible operations are:
-.Bl -column -offset indent ".Li GENIO" ".No data from user process"
+.Bl -column -offset indent ".Li CALL" ".No data from user process"
 .It Sy Name Ta Sy Operation Ta Sy Fourth field
 .It Li CALL Ta enter syscall Ta syscall name and arguments
 .It Li RET Ta return from syscall Ta syscall name and return value
 .It Li NAMI Ta file name lookup Ta path to file
-.It Li GENIO Ta general I/O Ta fd, read/write, number of bytes
-.It Li SIG Ta signal Ta signal name, handler, mask, code
+.It Li GIO Ta general I/O Ta fd, read/write, number of bytes
+.It Li PSIG Ta signal Ta signal name, handler, mask, code
 .It Li CSW Ta context switch Ta stop/resume user/kernel
 .It Li USER Ta data from user process Ta the data
 .It Li STRU Ta various syscalls Ta structure

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 21:47:28 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7DAD01065672;
	Thu,  4 Nov 2010 21:47:28 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 50BD98FC1E;
	Thu,  4 Nov 2010 21:47:28 +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 oA4LlSRJ074062;
	Thu, 4 Nov 2010 21:47:28 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4LlSqp074059;
	Thu, 4 Nov 2010 21:47:28 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201011042147.oA4LlSqp074059@svn.freebsd.org>
From: Doug Barton 
Date: Thu, 4 Nov 2010 21:47:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214810 - in stable/8/lib/bind: . isc/isc
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 21:47:28 -0000

Author: dougb
Date: Thu Nov  4 21:47:28 2010
New Revision: 214810
URL: http://svn.freebsd.org/changeset/base/214810

Log:
  MFC 214585:
  
  Prep for the 9.6-ESV-R2 update

Modified:
  stable/8/lib/bind/config.h
  stable/8/lib/bind/isc/isc/platform.h
Directory Properties:
  stable/8/lib/bind/   (props changed)

Modified: stable/8/lib/bind/config.h
==============================================================================
--- stable/8/lib/bind/config.h	Thu Nov  4 21:06:36 2010	(r214809)
+++ stable/8/lib/bind/config.h	Thu Nov  4 21:47:28 2010	(r214810)
@@ -147,6 +147,9 @@ int sigwait(const unsigned int *set, int
 /* Define if threads need PTHREAD_SCOPE_SYSTEM */
 /* #undef NEED_PTHREAD_SCOPE_SYSTEM */
 
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
 /* Define if recvmsg() does not meet all of the BSD socket API specifications.
    */
 /* #undef BROKEN_RECVMSG */
@@ -306,6 +309,9 @@ int sigwait(const unsigned int *set, int
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME ""
 
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
 /* Define to the version of this package. */
 #define PACKAGE_VERSION ""
 
@@ -327,11 +333,15 @@ int sigwait(const unsigned int *set, int
 /* #undef WITH_IDN */
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-#elif ! defined __LITTLE_ENDIAN__
-/* # undef WORDS_BIGENDIAN */
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* #  undef WORDS_BIGENDIAN */
+# endif
 #endif
 
 /* Define to empty if `const' does not conform to ANSI C. */

Modified: stable/8/lib/bind/isc/isc/platform.h
==============================================================================
--- stable/8/lib/bind/isc/isc/platform.h	Thu Nov  4 21:06:36 2010	(r214809)
+++ stable/8/lib/bind/isc/isc/platform.h	Thu Nov  4 21:47:28 2010	(r214810)
@@ -252,7 +252,14 @@
  * If the "xaddq" operation (64bit xadd) is available on this architecture,
  * ISC_PLATFORM_HAVEXADDQ will be defined.
  */
+/*
+ * FreeBSD local modification, preserve this over upgrades
+ */
+#ifdef __amd64__
+#define ISC_PLATFORM_HAVEXADDQ 1
+#else
 #undef ISC_PLATFORM_HAVEXADDQ
+#endif
 
 /*
  * If the "atomic swap" operation is available on this architecture,

From owner-svn-src-stable-8@FreeBSD.ORG  Thu Nov  4 21:48:40 2010
Return-Path: 
Delivered-To: svn-src-stable-8@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 23B8C1065673;
	Thu,  4 Nov 2010 21:48:40 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D5D58FC08;
	Thu,  4 Nov 2010 21:48:40 +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 oA4LmdrN074154;
	Thu, 4 Nov 2010 21:48:39 GMT (envelope-from dougb@svn.freebsd.org)
Received: (from dougb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4Lmdjt074118;
	Thu, 4 Nov 2010 21:48:39 GMT (envelope-from dougb@svn.freebsd.org)
Message-Id: <201011042148.oA4Lmdjt074118@svn.freebsd.org>
From: Doug Barton 
Date: Thu, 4 Nov 2010 21:48:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r214811 - in stable/8/contrib/bind9: . bin/dnssec
	bin/named bin/named/include/named bin/nsupdate doc/arm
	lib/dns lib/dns/include/dns lib/isc lib/isc/include/isc
	lib/lwres/man
X-BeenThere: svn-src-stable-8@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for only the 8-stable src tree
	
List-Unsubscribe: , 
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: , 
	
X-List-Received-Date: Thu, 04 Nov 2010 21:48:40 -0000

Author: dougb
Date: Thu Nov  4 21:48:39 2010
New Revision: 214811
URL: http://svn.freebsd.org/changeset/base/214811

Log:
  Update to 9.6-ESV-R2, the latest from ISC.
  
  This version contains bug fixes that are relevant to any
  caching/resolving name server; as well as DNSSEC-related
  fixes.

Modified:
  stable/8/contrib/bind9/CHANGES
  stable/8/contrib/bind9/README
  stable/8/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html
  stable/8/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html
  stable/8/contrib/bind9/bin/dnssec/dnssec-keygen.html
  stable/8/contrib/bind9/bin/dnssec/dnssec-signzone.html
  stable/8/contrib/bind9/bin/named/include/named/globals.h
  stable/8/contrib/bind9/bin/named/main.c
  stable/8/contrib/bind9/bin/named/query.c
  stable/8/contrib/bind9/bin/named/server.c
  stable/8/contrib/bind9/bin/nsupdate/nsupdate.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM-book.xml
  stable/8/contrib/bind9/doc/arm/Bv9ARM.ch06.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM.ch07.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM.ch08.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM.ch09.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM.html
  stable/8/contrib/bind9/doc/arm/Bv9ARM.pdf
  stable/8/contrib/bind9/doc/arm/isc-logo.eps
  stable/8/contrib/bind9/doc/arm/isc-logo.pdf
  stable/8/contrib/bind9/doc/arm/man.dig.html
  stable/8/contrib/bind9/doc/arm/man.dnssec-dsfromkey.html
  stable/8/contrib/bind9/doc/arm/man.dnssec-keyfromlabel.html
  stable/8/contrib/bind9/doc/arm/man.dnssec-keygen.html
  stable/8/contrib/bind9/doc/arm/man.dnssec-signzone.html
  stable/8/contrib/bind9/doc/arm/man.host.html
  stable/8/contrib/bind9/doc/arm/man.named-checkconf.html
  stable/8/contrib/bind9/doc/arm/man.named-checkzone.html
  stable/8/contrib/bind9/doc/arm/man.named.html
  stable/8/contrib/bind9/doc/arm/man.nsupdate.html
  stable/8/contrib/bind9/doc/arm/man.rndc-confgen.html
  stable/8/contrib/bind9/doc/arm/man.rndc.conf.html
  stable/8/contrib/bind9/doc/arm/man.rndc.html
  stable/8/contrib/bind9/lib/dns/adb.c
  stable/8/contrib/bind9/lib/dns/api
  stable/8/contrib/bind9/lib/dns/include/dns/diff.h
  stable/8/contrib/bind9/lib/dns/include/dns/ncache.h
  stable/8/contrib/bind9/lib/dns/include/dns/rdataset.h
  stable/8/contrib/bind9/lib/dns/include/dns/resolver.h
  stable/8/contrib/bind9/lib/dns/include/dns/result.h
  stable/8/contrib/bind9/lib/dns/include/dns/types.h
  stable/8/contrib/bind9/lib/dns/include/dns/validator.h
  stable/8/contrib/bind9/lib/dns/ncache.c
  stable/8/contrib/bind9/lib/dns/rbtdb.c
  stable/8/contrib/bind9/lib/dns/rdatalist.c
  stable/8/contrib/bind9/lib/dns/rdataset.c
  stable/8/contrib/bind9/lib/dns/rdataslab.c
  stable/8/contrib/bind9/lib/dns/resolver.c
  stable/8/contrib/bind9/lib/dns/result.c
  stable/8/contrib/bind9/lib/dns/sdb.c
  stable/8/contrib/bind9/lib/dns/sdlz.c
  stable/8/contrib/bind9/lib/dns/validator.c
  stable/8/contrib/bind9/lib/dns/view.c
  stable/8/contrib/bind9/lib/isc/api
  stable/8/contrib/bind9/lib/isc/include/isc/mem.h
  stable/8/contrib/bind9/lib/isc/mem.c
  stable/8/contrib/bind9/lib/lwres/man/lwres.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_buffer.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_config.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_context.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_gabn.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_gai_strerror.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_getaddrinfo.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_gethostent.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_getipnode.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_getnameinfo.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_getrrsetbyname.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_gnba.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_hstrerror.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_inetntop.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_noop.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_packet.html
  stable/8/contrib/bind9/lib/lwres/man/lwres_resutil.html
  stable/8/contrib/bind9/version
Directory Properties:
  stable/8/contrib/bind9/   (props changed)

Modified: stable/8/contrib/bind9/CHANGES
==============================================================================
--- stable/8/contrib/bind9/CHANGES	Thu Nov  4 21:47:28 2010	(r214810)
+++ stable/8/contrib/bind9/CHANGES	Thu Nov  4 21:48:39 2010	(r214811)
@@ -1,9 +1,48 @@
-	--- 9.6.2-P2 released ---
+	--- 9.6-ESV-R2 released ---
+
+2939.	[func]		Check that named successfully skips NSEC3 records
+			that fail to match the NSEC3PARAM record currently
+			in use. [RT# 21868]
+
+2937.	[bug]		Worked around an apparent race condition in over
+			memory conditions.  Without this fix a DNS cache DB or
+			ADB could incorrectly stay in an over memory state,
+			effectively refusing further caching, which
+			subsequently made a BIND 9 caching server unworkable.
+			This fix prevents this problem from happening by
+			polling the state of the memory context, rather than
+			making a copy of the state, which appeared to cause
+			a race.  This is a "workaround" in that it doesn't
+			solve the possible race per se, but several experiments
+			proved this change solves the symptom.  Also, the
+			polling overhead hasn't been reported to be an issue.
+			This bug should only affect a caching server that
+			specifies a finite max-cache-size.  It's also quite
+			likely that the bug happens only when enabling threads,
+			but it's not confirmed yet. [RT #21818]
+
+2925.	[bug]		Named failed to accept uncachable negative responses
+			from insecure zones. [RT# 21555]
+
+2921.	[bug]		The resolver could attempt to destroy a fetch context
+			too soon.  [RT #19878]
+
+2900.	[bug]		The placeholder negative caching element was not
+			properly constructed triggering a INSIST in 
+			dns_ncache_towire(). [RT #21346]
+			
+2890.	[bug]		Handle the introduction of new trusted-keys and
+			DS, DLV RRsets better. [RT #21097]
+
+2869.	[bug]		Fix arguments to dns_keytable_findnextkeynode() call.
+			[RT #20877]
+
+	--- 9.6-ESV-R1 released ---
 
 2876.	[bug]		Named could return SERVFAIL for negative responses
 			from unsigned zones. [RT #21131]
 
-	--- 9.6.2-P1 released ---
+	--- 9.6-ESV released ---
 
 2852.	[bug]		Handle broken DNSSEC trust chains better. [RT #15619]
 

Modified: stable/8/contrib/bind9/README
==============================================================================
--- stable/8/contrib/bind9/README	Thu Nov  4 21:47:28 2010	(r214810)
+++ stable/8/contrib/bind9/README	Thu Nov  4 21:48:39 2010	(r214811)
@@ -42,6 +42,12 @@ BIND 9
 		Stichting NLnet - NLnet Foundation
 		Nominum, Inc.
 
+BIND 9.6-ESV (Extended Support Version)
+
+	BIND 9.6-ESV will be supported until March 31, 2013, at
+	which time you will need to upgrade to the current release
+	of BIND.
+
 BIND 9.6.2
 
 	BIND 9.6.2 is a maintenance release, fixing bugs in 9.6.1.

Modified: stable/8/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html
==============================================================================
--- stable/8/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html	Thu Nov  4 21:47:28 2010	(r214810)
+++ stable/8/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html	Thu Nov  4 21:48:39 2010	(r214811)
@@ -1,5 +1,5 @@
 
 
-
+
 
 
 
@@ -33,14 +33,14 @@
 

dnssec-dsfromkey {-s} [-v level] [-1] [-2] [-a alg] [-c class] [-d dir] {dnsname}

-

DESCRIPTION

+

DESCRIPTION

dnssec-dsfromkey outputs the Delegation Signer (DS) resource record (RR), as defined in RFC 3658 and RFC 4509, for the given key(s).

-

OPTIONS

+

OPTIONS

-1

@@ -81,7 +81,7 @@

-

EXAMPLE

+

EXAMPLE

To build the SHA-256 DS RR from the Kexample.com.+003+26160 @@ -96,7 +96,7 @@

-

FILES

+

FILES

The keyfile can be designed by the key identification Knnnn.+aaa+iiiii or the full file name @@ -110,13 +110,13 @@

-

CAVEAT

+

CAVEAT

A keyfile error can give a "file not found" even if the file exists.

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), dnssec-signzone(8), BIND 9 Administrator Reference Manual, @@ -125,7 +125,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: stable/8/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html ============================================================================== --- stable/8/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html Thu Nov 4 21:48:39 2010 (r214811) @@ -13,7 +13,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -31,7 +31,7 @@

dnssec-keyfromlabel {-a algorithm} {-l label} [-c class] [-f flag] [-k] [-n nametype] [-p protocol] [-t type] [-v level] {name}

-

DESCRIPTION

+

DESCRIPTION

dnssec-keyfromlabel gets keys with the given label from a crypto hardware and builds key files for DNSSEC (Secure DNS), as defined in RFC 2535 @@ -39,7 +39,7 @@

-

OPTIONS

+

OPTIONS

-a algorithm
@@ -120,7 +120,7 @@
-

GENERATED KEY FILES

+

GENERATED KEY FILES

When dnssec-keyfromlabel completes successfully, @@ -161,7 +161,7 @@

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), dnssec-signzone(8), BIND 9 Administrator Reference Manual, @@ -169,7 +169,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: stable/8/contrib/bind9/bin/dnssec/dnssec-keygen.html ============================================================================== --- stable/8/contrib/bind9/bin/dnssec/dnssec-keygen.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/dnssec/dnssec-keygen.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -32,7 +32,7 @@

dnssec-keygen {-a algorithm} {-b keysize} {-n nametype} [-c class] [-e] [-f flag] [-g generator] [-h] [-k] [-p protocol] [-r randomdev] [-s strength] [-t type] [-v level] {name}

-

DESCRIPTION

+

DESCRIPTION

dnssec-keygen generates keys for DNSSEC (Secure DNS), as defined in RFC 2535 and RFC 4034. It can also generate keys for use with @@ -45,7 +45,7 @@

-

OPTIONS

+

OPTIONS

-a algorithm
@@ -155,7 +155,7 @@
-

GENERATED KEYS

+

GENERATED KEYS

When dnssec-keygen completes successfully, @@ -201,7 +201,7 @@

-

EXAMPLE

+

EXAMPLE

To generate a 768-bit DSA key for the domain example.com, the following command would be @@ -222,7 +222,7 @@

-

SEE ALSO

+

SEE ALSO

dnssec-signzone(8), BIND 9 Administrator Reference Manual, RFC 2539, @@ -231,7 +231,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: stable/8/contrib/bind9/bin/dnssec/dnssec-signzone.html ============================================================================== --- stable/8/contrib/bind9/bin/dnssec/dnssec-signzone.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/dnssec/dnssec-signzone.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -32,7 +32,7 @@

dnssec-signzone [-a] [-c class] [-d directory] [-e end-time] [-f output-file] [-g] [-h] [-k key] [-l domain] [-i interval] [-I input-format] [-j jitter] [-N soa-seria l-format] [-o origin] [-O output-format] [-p] [-P] [-r randomdev] [-s start-time] [-t] [-v level] [-z] [-3 salt] [-H iterations] [-A] {zonefile} [key...]

-

DESCRIPTION

+

DESCRIPTION

dnssec-signzone signs a zone. It generates NSEC and RRSIG records and produces a signed version of the @@ -43,7 +43,7 @@

-

OPTIONS

+

OPTIONS

-a

@@ -273,7 +273,7 @@

-

EXAMPLE

+

EXAMPLE

The following command signs the example.com zone with the DSA key generated by dnssec-keygen @@ -302,7 +302,7 @@ db.example.com.signed %

-

KNOWN BUGS

+

KNOWN BUGS

dnssec-signzone was designed so that it could sign a zone partially, using only a subset of the DNSSEC keys @@ -327,14 +327,14 @@ db.example.com.signed

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), BIND 9 Administrator Reference Manual, RFC 4033.

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: stable/8/contrib/bind9/bin/named/include/named/globals.h ============================================================================== --- stable/8/contrib/bind9/bin/named/include/named/globals.h Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/named/include/named/globals.h Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: globals.h,v 1.80 2008/11/16 22:49:18 marka Exp $ */ +/* $Id: globals.h,v 1.80.84.2 2010/06/26 23:46:15 tbox Exp $ */ #ifndef NAMED_GLOBALS_H #define NAMED_GLOBALS_H 1 @@ -132,6 +132,7 @@ EXTERN int ns_g_listen INIT(3); EXTERN isc_time_t ns_g_boottime; EXTERN isc_boolean_t ns_g_memstatistics INIT(ISC_FALSE); EXTERN isc_boolean_t ns_g_clienttest INIT(ISC_FALSE); +EXTERN isc_boolean_t ns_g_nosoa INIT(ISC_FALSE); #undef EXTERN #undef INIT Modified: stable/8/contrib/bind9/bin/named/main.c ============================================================================== --- stable/8/contrib/bind9/bin/named/main.c Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/named/main.c Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: main.c,v 1.166.34.3 2009/04/03 20:18:59 marka Exp $ */ +/* $Id: main.c,v 1.166.34.3.24.3 2010/09/06 03:58:32 marka Exp $ */ /*! \file */ @@ -446,13 +446,15 @@ parse_command_line(int argc, char *argv[ /* XXXJAB should we make a copy? */ ns_g_chrootdir = isc_commandline_argument; break; - case 'T': + case 'T': /* NOT DOCUMENTED */ /* * clienttest: make clients single shot with their * own memory context. */ if (strcmp(isc_commandline_argument, "clienttest") == 0) ns_g_clienttest = ISC_TRUE; + else if (!strcmp(isc_commandline_argument, "nosoa")) + ns_g_nosoa = ISC_TRUE; else fprintf(stderr, "unknown -T flag '%s\n", isc_commandline_argument); Modified: stable/8/contrib/bind9/bin/named/query.c ============================================================================== --- stable/8/contrib/bind9/bin/named/query.c Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/named/query.c Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.313.20.16 2009/12/30 08:34:29 jinmei Exp $ */ +/* $Id: query.c,v 1.313.20.16.10.2 2010/06/26 23:46:14 tbox Exp $ */ /*! \file */ @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -2038,7 +2039,7 @@ query_addrrset(ns_client_t *client, dns_ static inline isc_result_t query_addsoa(ns_client_t *client, dns_db_t *db, dns_dbversion_t *version, - isc_boolean_t zero_ttl) + isc_boolean_t zero_ttl, isc_boolean_t isassociated) { dns_name_t *name; dns_dbnode_t *node; @@ -2056,6 +2057,12 @@ query_addsoa(ns_client_t *client, dns_db node = NULL; /* + * Don't add the SOA record for test which set "-T nosoa". + */ + if (ns_g_nosoa && (!WANTDNSSEC(client) || !isassociated)) + return (ISC_R_SUCCESS); + + /* * Get resources and make 'name' be the database origin. */ result = dns_message_gettempname(client->message, &name); @@ -4324,7 +4331,8 @@ query_find(ns_client_t *client, dns_fetc /* * Add SOA. */ - result = query_addsoa(client, db, version, ISC_FALSE); + result = query_addsoa(client, db, version, ISC_FALSE, + dns_rdataset_isassociated(rdataset)); if (result != ISC_R_SUCCESS) { QUERY_ERROR(result); goto cleanup; @@ -4372,9 +4380,11 @@ query_find(ns_client_t *client, dns_fetc zone != NULL && #endif dns_zone_getzeronosoattl(zone)) - result = query_addsoa(client, db, version, ISC_TRUE); + result = query_addsoa(client, db, version, ISC_TRUE, + dns_rdataset_isassociated(rdataset)); else - result = query_addsoa(client, db, version, ISC_FALSE); + result = query_addsoa(client, db, version, ISC_FALSE, + dns_rdataset_isassociated(rdataset)); if (result != ISC_R_SUCCESS) { QUERY_ERROR(result); goto cleanup; @@ -4742,7 +4752,7 @@ query_find(ns_client_t *client, dns_fetc * Add SOA. */ result = query_addsoa(client, db, version, - ISC_FALSE); + ISC_FALSE, ISC_FALSE); if (result == ISC_R_SUCCESS) result = ISC_R_NOMORE; } else { Modified: stable/8/contrib/bind9/bin/named/server.c ============================================================================== --- stable/8/contrib/bind9/bin/named/server.c Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/named/server.c Thu Nov 4 21:48:39 2010 (r214811) @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.520.12.11.8.2 2010/02/25 10:57:11 tbox Exp $ */ +/* $Id: server.c,v 1.520.12.11.10.1 2010/03/03 22:06:36 marka Exp $ */ /*! \file */ Modified: stable/8/contrib/bind9/bin/nsupdate/nsupdate.html ============================================================================== --- stable/8/contrib/bind9/bin/nsupdate/nsupdate.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/bin/nsupdate/nsupdate.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -32,7 +32,7 @@

nsupdate [-d] [-D] [[-g] | [-o] | [-y [hmac:]keyname:secret] | [-k keyfile]] [-t timeout] [-u udptimeout] [-r udpretries] [-R randomdev] [-v] [filename]

-

DESCRIPTION

+

DESCRIPTION

nsupdate is used to submit Dynamic DNS Update requests as defined in RFC2136 to a name server. @@ -169,7 +169,7 @@

-

INPUT FORMAT

+

INPUT FORMAT

nsupdate reads input from filename @@ -433,7 +433,7 @@

-

EXAMPLES

+

EXAMPLES

The examples below show how nsupdate @@ -487,7 +487,7 @@

-

FILES

+

FILES

/etc/resolv.conf

@@ -506,7 +506,7 @@

-

SEE ALSO

+

SEE ALSO

RFC2136, RFC3007, RFC2104, @@ -519,7 +519,7 @@

-

BUGS

+

BUGS

The TSIG key is redundantly stored in two separate files. This is a consequence of nsupdate using the DST library Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM-book.xml ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM-book.xml Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM-book.xml Thu Nov 4 21:48:39 2010 (r214811) @@ -18,7 +18,7 @@ - PERFORMANCE OF THIS SOFTWARE. --> - + BIND 9 Administrator Reference Manual Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.ch06.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM.ch06.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM.ch06.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.ch07.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM.ch07.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM.ch07.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.ch08.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM.ch08.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM.ch08.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.ch09.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM.ch09.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM.ch09.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/Bv9ARM.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/Bv9ARM.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/Bv9ARM.pdf ============================================================================== Binary file (source and/or target). No diff available. Modified: stable/8/contrib/bind9/doc/arm/isc-logo.eps ============================================================================== Binary file (source and/or target). No diff available. Modified: stable/8/contrib/bind9/doc/arm/isc-logo.pdf ============================================================================== Binary file (source and/or target). No diff available. Modified: stable/8/contrib/bind9/doc/arm/man.dig.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.dig.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.dig.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.dnssec-dsfromkey.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.dnssec-dsfromkey.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.dnssec-dsfromkey.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.dnssec-keyfromlabel.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.dnssec-keyfromlabel.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.dnssec-keyfromlabel.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.dnssec-keygen.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.dnssec-keygen.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.dnssec-keygen.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.dnssec-signzone.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.dnssec-signzone.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.dnssec-signzone.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.host.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.host.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.host.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.named-checkconf.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.named-checkconf.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.named-checkconf.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.named-checkzone.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.named-checkzone.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.named-checkzone.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.named.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.named.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.named.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.nsupdate.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.nsupdate.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.nsupdate.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.rndc-confgen.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.rndc-confgen.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.rndc-confgen.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.rndc.conf.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.rndc.conf.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.rndc.conf.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/doc/arm/man.rndc.html ============================================================================== --- stable/8/contrib/bind9/doc/arm/man.rndc.html Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/doc/arm/man.rndc.html Thu Nov 4 21:48:39 2010 (r214811) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + Modified: stable/8/contrib/bind9/lib/dns/adb.c ============================================================================== --- stable/8/contrib/bind9/lib/dns/adb.c Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/lib/dns/adb.c Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: adb.c,v 1.243.42.4 2009/02/03 22:34:28 jinmei Exp $ */ +/* $Id: adb.c,v 1.243.42.4.24.2 2010/08/12 23:46:24 tbox Exp $ */ /*! \file * @@ -118,7 +118,6 @@ struct dns_adb { isc_taskmgr_t *taskmgr; isc_task_t *task; - isc_boolean_t overmem; isc_interval_t tick_interval; int next_cleanbucket; @@ -294,8 +293,8 @@ static inline void inc_adb_irefcnt(dns_a static inline void inc_adb_erefcnt(dns_adb_t *); static inline void inc_entry_refcnt(dns_adb_t *, dns_adbentry_t *, isc_boolean_t); -static inline isc_boolean_t dec_entry_refcnt(dns_adb_t *, dns_adbentry_t *, - isc_boolean_t); +static inline isc_boolean_t dec_entry_refcnt(dns_adb_t *, isc_boolean_t, + dns_adbentry_t *, isc_boolean_t); static inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *); static isc_boolean_t clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *); static void clean_target(dns_adb_t *, dns_name_t *); @@ -777,7 +776,7 @@ link_entry(dns_adb_t *adb, int bucket, d int i; dns_adbentry_t *e; - if (adb->overmem) { + if (isc_mem_isovermem(adb->mctx)) { for (i = 0; i < 2; i++) { e = ISC_LIST_TAIL(adb->entries[bucket]); if (e == NULL) @@ -943,6 +942,7 @@ clean_namehooks(dns_adb_t *adb, dns_adbn dns_adbnamehook_t *namehook; int addr_bucket; isc_boolean_t result = ISC_FALSE; + isc_boolean_t overmem = isc_mem_isovermem(adb->mctx); addr_bucket = DNS_ADB_INVALIDBUCKET; namehook = ISC_LIST_HEAD(*namehooks); @@ -963,7 +963,8 @@ clean_namehooks(dns_adb_t *adb, dns_adbn LOCK(&adb->entrylocks[addr_bucket]); } - result = dec_entry_refcnt(adb, entry, ISC_FALSE); + result = dec_entry_refcnt(adb, overmem, entry, + ISC_FALSE); } /* @@ -1235,7 +1236,9 @@ inc_entry_refcnt(dns_adb_t *adb, dns_adb } static inline isc_boolean_t -dec_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock) { +dec_entry_refcnt(dns_adb_t *adb, isc_boolean_t overmem, dns_adbentry_t *entry, + isc_boolean_t lock) +{ int bucket; isc_boolean_t destroy_entry; isc_boolean_t result = ISC_FALSE; @@ -1250,7 +1253,7 @@ dec_entry_refcnt(dns_adb_t *adb, dns_adb destroy_entry = ISC_FALSE; if (entry->refcnt == 0 && - (adb->entry_sd[bucket] || entry->expires == 0 || adb->overmem || + (adb->entry_sd[bucket] || entry->expires == 0 || overmem || (entry->flags & ENTRY_IS_DEAD) != 0)) { destroy_entry = ISC_TRUE; result = unlink_entry(adb, entry); @@ -1852,7 +1855,7 @@ check_stale_name(dns_adb_t *adb, int buc int victims, max_victims; isc_boolean_t result; dns_adbname_t *victim, *next_victim; - isc_boolean_t overmem = adb->overmem; + isc_boolean_t overmem = isc_mem_isovermem(adb->mctx); int scans = 0; INSIST(bucket != DNS_ADB_INVALIDBUCKET); @@ -2049,7 +2052,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_ adb, NULL, NULL); adb->cevent_sent = ISC_FALSE; adb->shutting_down = ISC_FALSE; - adb->overmem = ISC_FALSE; ISC_LIST_INIT(adb->whenshutdown); isc_mem_attach(mem, &adb->mctx); @@ -2616,6 +2618,7 @@ dns_adb_destroyfind(dns_adbfind_t **find dns_adbaddrinfo_t *ai; int bucket; dns_adb_t *adb; + isc_boolean_t overmem; REQUIRE(findp != NULL && DNS_ADBFIND_VALID(*findp)); find = *findp; @@ -2640,13 +2643,14 @@ dns_adb_destroyfind(dns_adbfind_t **find * Return the find to the memory pool, and decrement the adb's * reference count. */ + overmem = isc_mem_isovermem(adb->mctx); ai = ISC_LIST_HEAD(find->list); while (ai != NULL) { ISC_LIST_UNLINK(find->list, ai, publink); entry = ai->entry; ai->entry = NULL; INSIST(DNS_ADBENTRY_VALID(entry)); - RUNTIME_CHECK(dec_entry_refcnt(adb, entry, ISC_TRUE) == + RUNTIME_CHECK(dec_entry_refcnt(adb, overmem, entry, ISC_TRUE) == ISC_FALSE); free_adbaddrinfo(adb, &ai); ai = ISC_LIST_HEAD(find->list); @@ -3509,6 +3513,7 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns int bucket; isc_stdtime_t now; isc_boolean_t want_check_exit = ISC_FALSE; + isc_boolean_t overmem; REQUIRE(DNS_ADB_VALID(adb)); REQUIRE(addrp != NULL); @@ -3520,13 +3525,14 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns isc_stdtime_get(&now); *addrp = NULL; + overmem = isc_mem_isovermem(adb->mctx); bucket = addr->entry->lock_bucket; LOCK(&adb->entrylocks[bucket]); entry->expires = now + ADB_ENTRY_WINDOW; - want_check_exit = dec_entry_refcnt(adb, entry, ISC_FALSE); + want_check_exit = dec_entry_refcnt(adb, overmem, entry, ISC_FALSE); UNLOCK(&adb->entrylocks[bucket]); @@ -3591,6 +3597,14 @@ dns_adb_flushname(dns_adb_t *adb, dns_na static void water(void *arg, int mark) { + /* + * We're going to change the way to handle overmem condition: use + * isc_mem_isovermem() instead of storing the state via this callback, + * since the latter way tends to cause race conditions. + * To minimize the change, and in case we re-enable the callback + * approach, however, keep this function at the moment. + */ + dns_adb_t *adb = arg; isc_boolean_t overmem = ISC_TF(mark == ISC_MEM_HIWATER); @@ -3598,17 +3612,6 @@ water(void *arg, int mark) { DP(ISC_LOG_DEBUG(1), "adb reached %s water mark", overmem ? "high" : "low"); - - /* - * We can't use adb->lock as there is potential for water - * to be called when adb->lock is held. - */ - LOCK(&adb->overmemlock); - if (adb->overmem != overmem) { - adb->overmem = overmem; - isc_mem_waterack(adb->mctx, mark); - } - UNLOCK(&adb->overmemlock); } void Modified: stable/8/contrib/bind9/lib/dns/api ============================================================================== --- stable/8/contrib/bind9/lib/dns/api Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/lib/dns/api Thu Nov 4 21:48:39 2010 (r214811) @@ -1,3 +1,3 @@ -LIBINTERFACE = 56 -LIBREVISION = 1 -LIBAGE = 1 +LIBINTERFACE = 57 +LIBREVISION = 0 +LIBAGE = 2 Modified: stable/8/contrib/bind9/lib/dns/include/dns/diff.h ============================================================================== --- stable/8/contrib/bind9/lib/dns/include/dns/diff.h Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/lib/dns/include/dns/diff.h Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: diff.h,v 1.15.120.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: diff.h,v 1.15.120.2.24.2 2010/06/04 23:49:23 tbox Exp $ */ #ifndef DNS_DIFF_H #define DNS_DIFF_H 1 @@ -70,7 +70,7 @@ typedef enum { DNS_DIFFOP_DEL = 1, /*%< Delete an RR. */ DNS_DIFFOP_EXISTS = 2, /*%< Assert RR existence. */ DNS_DIFFOP_ADDRESIGN = 4, /*%< ADD + RESIGN. */ - DNS_DIFFOP_DELRESIGN = 5, /*%< DEL + RESIGN. */ + DNS_DIFFOP_DELRESIGN = 5 /*%< DEL + RESIGN. */ } dns_diffop_t; typedef struct dns_difftuple dns_difftuple_t; Modified: stable/8/contrib/bind9/lib/dns/include/dns/ncache.h ============================================================================== --- stable/8/contrib/bind9/lib/dns/include/dns/ncache.h Thu Nov 4 21:47:28 2010 (r214810) +++ stable/8/contrib/bind9/lib/dns/include/dns/ncache.h Thu Nov 4 21:48:39 2010 (r214811) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ncache.h,v 1.25.48.2 2009/12/30 23:47:31 tbox Exp $ */ +/* $Id: ncache.h,v 1.25.48.2.10.2 2010/05/14 23:48:44 tbox Exp $ */ #ifndef DNS_NCACHE_H #define DNS_NCACHE_H 1 @@ -161,6 +161,13 @@ dns_ncache_getrdataset(dns_rdataset_t *n * */ +isc_result_t +dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 5 02:12:19 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1EAC310656C4; Fri, 5 Nov 2010 02:12:19 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B42A8FC19; Fri, 5 Nov 2010 02:12:19 +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 oA52CIUj080484; Fri, 5 Nov 2010 02:12:18 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA52CIQD080481; Fri, 5 Nov 2010 02:12:18 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011050212.oA52CIQD080481@svn.freebsd.org> From: Rick Macklem Date: Fri, 5 Nov 2010 02:12:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214819 - in stable/8/sys/fs: nfs nfsclient X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 02:12:19 -0000 Author: rmacklem Date: Fri Nov 5 02:12:18 2010 New Revision: 214819 URL: http://svn.freebsd.org/changeset/base/214819 Log: MFC: r214406 Add a flag to the experimental NFSv4 client to indicate when delegations are being returned for reasons other than a Recall. Also, re-organize nfscl_recalldeleg() slightly, so that it leaves clearing NMODIFIED to the ncl_flush() call and invalidates the attribute cache after flushing. It is hoped that these changes might fix the problem others have seen when using the NFSv4 client with delegations enabled, since I can't reliably reproduce the problem. These changes only affect the client when doing NFSv4 mounts with delegations enabled. Modified: stable/8/sys/fs/nfs/nfsclstate.h stable/8/sys/fs/nfsclient/nfs_clstate.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfs/nfsclstate.h ============================================================================== --- stable/8/sys/fs/nfs/nfsclstate.h Fri Nov 5 01:50:18 2010 (r214818) +++ stable/8/sys/fs/nfs/nfsclstate.h Fri Nov 5 02:12:18 2010 (r214819) @@ -118,6 +118,7 @@ struct nfscldeleg { #define NFSCLDL_NEEDRECLAIM 0x08 #define NFSCLDL_ZAPPED 0x10 #define NFSCLDL_MODTIMESET 0x20 +#define NFSCLDL_DELEGRET 0x40 /* * MALLOC'd to the correct length to accommodate the file handle. Modified: stable/8/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clstate.c Fri Nov 5 01:50:18 2010 (r214818) +++ stable/8/sys/fs/nfsclient/nfs_clstate.c Fri Nov 5 02:12:18 2010 (r214819) @@ -929,8 +929,10 @@ nfscl_getbytelock(vnode_t vp, u_int64_t ldp = dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); /* Just sanity check for correct type of delegation */ - if (dp != NULL && ((dp->nfsdl_flags & NFSCLDL_RECALL) || - (type == F_WRLCK && !(dp->nfsdl_flags & NFSCLDL_WRITE)))) + if (dp != NULL && ((dp->nfsdl_flags & + (NFSCLDL_RECALL | NFSCLDL_DELEGRET)) != 0 || + (type == F_WRLCK && + (dp->nfsdl_flags & NFSCLDL_WRITE) == 0))) dp = NULL; } if (dp != NULL) { @@ -2495,8 +2497,8 @@ tryagain: if (dp->nfsdl_rwlock.nfslock_usecnt == 0 && dp->nfsdl_rwlock.nfslock_lock == 0 && dp->nfsdl_timestamp < NFSD_MONOSEC && - !(dp->nfsdl_flags & (NFSCLDL_RECALL | NFSCLDL_ZAPPED | - NFSCLDL_NEEDRECLAIM))) { + (dp->nfsdl_flags & (NFSCLDL_RECALL | NFSCLDL_ZAPPED | + NFSCLDL_NEEDRECLAIM | NFSCLDL_DELEGRET)) == 0) { clearok = 1; LIST_FOREACH(owp, &dp->nfsdl_owner, nfsow_list) { op = LIST_FIRST(&owp->nfsow_open); @@ -3086,7 +3088,8 @@ nfscl_docb(struct nfsrv_descript *nd, NF if (clp != NULL) { dp = nfscl_finddeleg(clp, nfhp->nfh_fh, nfhp->nfh_len); - if (dp != NULL) { + if (dp != NULL && (dp->nfsdl_flags & + NFSCLDL_DELEGRET) == 0) { dp->nfsdl_flags |= NFSCLDL_RECALL; wakeup((caddr_t)clp); @@ -3338,7 +3341,6 @@ nfscl_recalldeleg(struct nfsclclient *cl np = VTONFS(vp); } dp->nfsdl_flags &= ~NFSCLDL_MODTIMESET; - NFSINVALATTRCACHE(np); /* * Ok, if it's a write delegation, flush data to the server, so @@ -3347,21 +3349,14 @@ nfscl_recalldeleg(struct nfsclclient *cl ret = 0; NFSLOCKNODE(np); if ((dp->nfsdl_flags & NFSCLDL_WRITE) && (np->n_flag & NMODIFIED)) { -#ifdef APPLE - OSBitOrAtomic((u_int32_t)NDELEGRECALL, (UInt32 *)&np->n_flag); -#else np->n_flag |= NDELEGRECALL; -#endif NFSUNLOCKNODE(np); ret = ncl_flush(vp, MNT_WAIT, cred, p, 1, called_from_renewthread); NFSLOCKNODE(np); -#ifdef APPLE - OSBitAndAtomic((int32_t)~(NMODIFIED | NDELEGRECALL), (UInt32 *)&np->n_flag); -#else - np->n_flag &= ~(NMODIFIED | NDELEGRECALL); -#endif + np->n_flag &= ~NDELEGRECALL; } + NFSINVALATTRCACHE(np); NFSUNLOCKNODE(np); if (ret == EIO && called_from_renewthread != 0) { /* @@ -3534,8 +3529,10 @@ nfscl_totalrecall(struct nfsclclient *cl { struct nfscldeleg *dp; - TAILQ_FOREACH(dp, &clp->nfsc_deleg, nfsdl_list) - dp->nfsdl_flags |= NFSCLDL_RECALL; + TAILQ_FOREACH(dp, &clp->nfsc_deleg, nfsdl_list) { + if ((dp->nfsdl_flags & NFSCLDL_DELEGRET) == 0) + dp->nfsdl_flags |= NFSCLDL_RECALL; + } } /* @@ -3754,8 +3751,9 @@ nfscl_mustflush(vnode_t vp) return (1); } dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); - if (dp != NULL && (dp->nfsdl_flags & (NFSCLDL_WRITE | NFSCLDL_RECALL)) - == NFSCLDL_WRITE && + if (dp != NULL && (dp->nfsdl_flags & + (NFSCLDL_WRITE | NFSCLDL_RECALL | NFSCLDL_DELEGRET)) == + NFSCLDL_WRITE && (dp->nfsdl_sizelimit >= np->n_size || !NFSHASSTRICT3530(nmp))) { NFSUNLOCKCLSTATE(); @@ -3787,9 +3785,10 @@ nfscl_nodeleg(vnode_t vp, int writedeleg return (1); } dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); - if (dp != NULL && (dp->nfsdl_flags & NFSCLDL_RECALL) == 0 && - (writedeleg == 0 || (dp->nfsdl_flags & NFSCLDL_WRITE) - == NFSCLDL_WRITE)) { + if (dp != NULL && + (dp->nfsdl_flags & (NFSCLDL_RECALL | NFSCLDL_DELEGRET)) == 0 && + (writedeleg == 0 || (dp->nfsdl_flags & NFSCLDL_WRITE) == + NFSCLDL_WRITE)) { NFSUNLOCKCLSTATE(); return (0); } @@ -3860,6 +3859,7 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T } } if (needsrecall && !triedrecall) { + dp->nfsdl_flags |= NFSCLDL_DELEGRET; islept = 0; while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, @@ -3958,6 +3958,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stat } } if (needsrecall && !triedrecall) { + dp->nfsdl_flags |= NFSCLDL_DELEGRET; islept = 0; while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 5 02:33:27 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C576106566B; Fri, 5 Nov 2010 02:33:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 692958FC0C; Fri, 5 Nov 2010 02:33:27 +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 oA52XRQx081043; Fri, 5 Nov 2010 02:33:27 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA52XRb6081041; Fri, 5 Nov 2010 02:33:27 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011050233.oA52XRb6081041@svn.freebsd.org> From: Rick Macklem Date: Fri, 5 Nov 2010 02:33:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214820 - stable/8/sys/fs/nfsclient X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 02:33:27 -0000 Author: rmacklem Date: Fri Nov 5 02:33:27 2010 New Revision: 214820 URL: http://svn.freebsd.org/changeset/base/214820 Log: MFC: r214511 Add a call for nfsrpc_close() to ncl_reclaim() in the experimental NFSv4 client, since the call in ncl_inactive() might be missed because VOP_INACTIVE() is not guaranteed to be called before VOP_RECLAIM(). Modified: stable/8/sys/fs/nfsclient/nfs_clnode.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clnode.c Fri Nov 5 02:12:18 2010 (r214819) +++ stable/8/sys/fs/nfsclient/nfs_clnode.c Fri Nov 5 02:33:27 2010 (r214820) @@ -236,6 +236,15 @@ ncl_reclaim(struct vop_reclaim_args *ap) if (prtactive && vrefcnt(vp) != 0) vprint("ncl_reclaim: pushing active", vp); + if (NFS_ISV4(vp) && vp->v_type == VREG) + /* + * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 + * Close operations are delayed until ncl_inactive(). + * However, since VOP_INACTIVE() is not guaranteed to be + * called, we need to do it again here. + */ + (void) nfsrpc_close(vp, 1, ap->a_td); + /* * If the NLM is running, give it a chance to abort pending * locks. From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 5 02:45:13 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF4F61065673; Fri, 5 Nov 2010 02:45:13 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CBE288FC12; Fri, 5 Nov 2010 02:45:13 +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 oA52jDHU081355; Fri, 5 Nov 2010 02:45:13 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA52jDWG081353; Fri, 5 Nov 2010 02:45:13 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201011050245.oA52jDWG081353@svn.freebsd.org> From: Rick Macklem Date: Fri, 5 Nov 2010 02:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214821 - stable/8/sys/fs/nfsclient X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 02:45:14 -0000 Author: rmacklem Date: Fri Nov 5 02:45:13 2010 New Revision: 214821 URL: http://svn.freebsd.org/changeset/base/214821 Log: MFC: r214513 Modify nfs_open() in the experimental NFS client to be compatible with the regular NFS client. Also, fix a couple of mutex lock issues. Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Nov 5 02:33:27 2010 (r214820) +++ stable/8/sys/fs/nfsclient/nfs_clvnops.c Fri Nov 5 02:45:13 2010 (r214821) @@ -505,24 +505,46 @@ nfs_open(struct vop_open_args *ap) * Now, if this Open will be doing reading, re-validate/flush the * cache, so that Close/Open coherency is maintained. */ - if ((fmode & FREAD) != 0 && - (!NFS_ISV4(vp) || nfscl_mustflush(vp) != 0)) { + mtx_lock(&np->n_mtx); + if (np->n_flag & NMODIFIED) { + mtx_unlock(&np->n_mtx); + error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1); + if (error == EINTR || error == EIO) { + if (NFS_ISV4(vp)) + (void) nfsrpc_close(vp, 0, ap->a_td); + return (error); + } mtx_lock(&np->n_mtx); - if (np->n_flag & NMODIFIED) { - mtx_unlock(&np->n_mtx); - error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1); - if (error == EINTR || error == EIO) { - if (NFS_ISV4(vp)) - (void) nfsrpc_close(vp, 0, ap->a_td); - return (error); - } - mtx_lock(&np->n_mtx); - np->n_attrstamp = 0; + np->n_attrstamp = 0; + if (vp->v_type == VDIR) + np->n_direofoffset = 0; + mtx_unlock(&np->n_mtx); + error = VOP_GETATTR(vp, &vattr, ap->a_cred); + if (error) { + if (NFS_ISV4(vp)) + (void) nfsrpc_close(vp, 0, ap->a_td); + return (error); + } + mtx_lock(&np->n_mtx); + np->n_mtime = vattr.va_mtime; + if (NFS_ISV4(vp)) + np->n_change = vattr.va_filerev; + } else { + mtx_unlock(&np->n_mtx); + error = VOP_GETATTR(vp, &vattr, ap->a_cred); + if (error) { + if (NFS_ISV4(vp)) + (void) nfsrpc_close(vp, 0, ap->a_td); + return (error); + } + mtx_lock(&np->n_mtx); + if ((NFS_ISV4(vp) && np->n_change != vattr.va_filerev) || + NFS_TIMESPEC_COMPARE(&np->n_mtime, &vattr.va_mtime)) { if (vp->v_type == VDIR) np->n_direofoffset = 0; mtx_unlock(&np->n_mtx); - error = VOP_GETATTR(vp, &vattr, ap->a_cred); - if (error) { + error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1); + if (error == EINTR || error == EIO) { if (NFS_ISV4(vp)) (void) nfsrpc_close(vp, 0, ap->a_td); return (error); @@ -531,42 +553,16 @@ nfs_open(struct vop_open_args *ap) np->n_mtime = vattr.va_mtime; if (NFS_ISV4(vp)) np->n_change = vattr.va_filerev; - mtx_unlock(&np->n_mtx); - } else { - mtx_unlock(&np->n_mtx); - error = VOP_GETATTR(vp, &vattr, ap->a_cred); - if (error) { - if (NFS_ISV4(vp)) - (void) nfsrpc_close(vp, 0, ap->a_td); - return (error); - } - mtx_lock(&np->n_mtx); - if ((NFS_ISV4(vp) && np->n_change != vattr.va_filerev) || - NFS_TIMESPEC_COMPARE(&np->n_mtime, &vattr.va_mtime)) { - if (vp->v_type == VDIR) - np->n_direofoffset = 0; - mtx_unlock(&np->n_mtx); - error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1); - if (error == EINTR || error == EIO) { - if (NFS_ISV4(vp)) - (void) nfsrpc_close(vp, 0, - ap->a_td); - return (error); - } - mtx_lock(&np->n_mtx); - np->n_mtime = vattr.va_mtime; - if (NFS_ISV4(vp)) - np->n_change = vattr.va_filerev; - } - mtx_unlock(&np->n_mtx); } } /* * If the object has >= 1 O_DIRECT active opens, we disable caching. */ - if (newnfs_directio_enable && (fmode & O_DIRECT) && (vp->v_type == VREG)) { + if (newnfs_directio_enable && (fmode & O_DIRECT) && + (vp->v_type == VREG)) { if (np->n_directio_opens == 0) { + mtx_unlock(&np->n_mtx); error = ncl_vinvalbuf(vp, V_SAVE, ap->a_td, 1); if (error) { if (NFS_ISV4(vp)) @@ -575,12 +571,10 @@ nfs_open(struct vop_open_args *ap) } mtx_lock(&np->n_mtx); np->n_flag |= NNONCACHE; - } else { - mtx_lock(&np->n_mtx); } np->n_directio_opens++; - mtx_unlock(&np->n_mtx); } + mtx_unlock(&np->n_mtx); vnode_create_vobject(vp, vattr.va_size, ap->a_td); return (0); } From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 5 13:45:13 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A82A3106564A; Fri, 5 Nov 2010 13:45:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B7168FC1B; Fri, 5 Nov 2010 13:45:13 +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 oA5DjDRs098678; Fri, 5 Nov 2010 13:45:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA5DjDHv098676; Fri, 5 Nov 2010 13:45:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201011051345.oA5DjDHv098676@svn.freebsd.org> From: John Baldwin Date: Fri, 5 Nov 2010 13:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214836 - stable/8/share/man/man9 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 13:45:13 -0000 Author: jhb Date: Fri Nov 5 13:45:13 2010 New Revision: 214836 URL: http://svn.freebsd.org/changeset/base/214836 Log: MFC 214673: Fix a few typos and style nits in the example code. Modified: stable/8/share/man/man9/sysctl_ctx_init.9 Directory Properties: stable/8/share/man/man9/ (props changed) Modified: stable/8/share/man/man9/sysctl_ctx_init.9 ============================================================================== --- stable/8/share/man/man9/sysctl_ctx_init.9 Fri Nov 5 13:42:58 2010 (r214835) +++ stable/8/share/man/man9/sysctl_ctx_init.9 Fri Nov 5 13:45:13 2010 (r214836) @@ -188,27 +188,27 @@ This example uses contexts to keep track struct sysctl_ctx_list clist; struct sysctl_oid *oidp; int a_int; -char *string = "dynamic sysctl"; +const char *string = "dynamic sysctl"; ... sysctl_ctx_init(&clist); -oidp = SYSCTL_ADD_NODE( &clist, SYSCTL_STATIC_CHILDREN(/* tree top */), - OID_AUTO, "newtree", CTFLAG_RW, 0, "new top level tree"); -oidp = SYSCTL_ADD_INT( &clist, SYSCTL_CHILDREN(oidp), +oidp = SYSCTL_ADD_NODE(&clist, SYSCTL_STATIC_CHILDREN(/* tree top */), + OID_AUTO, "newtree", CTLFLAG_RW, 0, "new top level tree"); +oidp = SYSCTL_ADD_INT(&clist, SYSCTL_CHILDREN(oidp), OID_AUTO, "newint", CTLFLAG_RW, &a_int, 0, "new int leaf"); ... -oidp = SYSCTL_ADD_NODE( &clist, SYSCTL_STATIC_CHILDREN(_debug), - OID_AUTO, "newtree", CTFLAG_RW, 0, "new tree under debug"); -oidp = SYSCTL_ADD_STRING( &clist, SYSCTL_CHILDREN(oidp), - OID_AUTO, "newstring", CTLFLAG_R, string, 0, "new string leaf"); +oidp = SYSCTL_ADD_NODE(&clist, SYSCTL_STATIC_CHILDREN(_debug), + OID_AUTO, "newtree", CTLFLAG_RW, 0, "new tree under debug"); +oidp = SYSCTL_ADD_STRING(&clist, SYSCTL_CHILDREN(oidp), + OID_AUTO, "newstring", CTLFLAG_RD, string, 0, "new string leaf"); ... /* Now we can free up the oids */ -if(sysctl_ctx_free(&clist)) { +if (sysctl_ctx_free(&clist)) { printf("can't free this context - other oids depend on it"); - return(ENOTEMPTY); + return (ENOTEMPTY); } else { - printf("Success!\\n"): - return(0); + printf("Success!\\n"); + return (0); } .Ed .Pp From owner-svn-src-stable-8@FreeBSD.ORG Fri Nov 5 16:04:10 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0BD0106566B; Fri, 5 Nov 2010 16:04:10 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DD578FC08; Fri, 5 Nov 2010 16: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 oA5G4A79001840; Fri, 5 Nov 2010 16:04:10 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA5G4AR6001838; Fri, 5 Nov 2010 16:04:10 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201011051604.oA5G4AR6001838@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 5 Nov 2010 16:04:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214839 - stable/8/usr.sbin/freebsd-update X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 16:04:10 -0000 Author: jh Date: Fri Nov 5 16:04:10 2010 New Revision: 214839 URL: http://svn.freebsd.org/changeset/base/214839 Log: MFC r212505: In backup_kernel(), support backing up subdirectories and handle files with spaces correctly. Modified: stable/8/usr.sbin/freebsd-update/freebsd-update.sh Directory Properties: stable/8/usr.sbin/freebsd-update/ (props changed) Modified: stable/8/usr.sbin/freebsd-update/freebsd-update.sh ============================================================================== --- stable/8/usr.sbin/freebsd-update/freebsd-update.sh Fri Nov 5 13:46:58 2010 (r214838) +++ stable/8/usr.sbin/freebsd-update/freebsd-update.sh Fri Nov 5 16:04:10 2010 (r214839) @@ -2619,11 +2619,13 @@ backup_kernel () { # "not ours", backup_kernel_finddir would have exited, so # deleting the directory content is as safe as we can make it. if [ -d $BACKUPKERNELDIR ]; then - rm -f $BACKUPKERNELDIR/* + rm -fr $BACKUPKERNELDIR fi - # Create directory for backup if it doesn't exist. + # Create directories for backup. mkdir -p $BACKUPKERNELDIR + mtree -cdn -p "${KERNELDIR}" | \ + mtree -Ue -p "${BACKUPKERNELDIR}" > /dev/null # Mark the directory as having been created by freebsd-update. touch $BACKUPKERNELDIR/.freebsd-update @@ -2644,9 +2646,8 @@ backup_kernel () { fi # Backup all the kernel files using hardlinks. - find $KERNELDIR -type f $FINDFILTER | \ - sed -Ee "s,($KERNELDIR)/?(.*),\1/\2 ${BACKUPKERNELDIR}/\2," | \ - xargs -n 2 cp -pl + (cd $KERNELDIR && find . -type f $FINDFILTER -exec \ + cp -pl '{}' ${BACKUPKERNELDIR}/'{}' \;) # Re-enable patchname expansion. set +f From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 01:09:01 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FF88106564A; Sat, 6 Nov 2010 01:09:01 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1F778FC08; Sat, 6 Nov 2010 01:09:00 +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 oA6190Q9014690; Sat, 6 Nov 2010 01:09:00 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA61902B014688; Sat, 6 Nov 2010 01:09:00 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201011060109.oA61902B014688@svn.freebsd.org> From: Marius Strobl Date: Sat, 6 Nov 2010 01:09:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214856 - stable/8/sys/arm/mv X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 01:09:01 -0000 Author: marius Date: Sat Nov 6 01:09:00 2010 New Revision: 214856 URL: http://svn.freebsd.org/changeset/base/214856 Log: Fix an instance missed in r212892: MFC r212413: bus_add_child: change type of order parameter to u_int Modified: stable/8/sys/arm/mv/obio.c Modified: stable/8/sys/arm/mv/obio.c ============================================================================== --- stable/8/sys/arm/mv/obio.c Sat Nov 6 00:53:54 2010 (r214855) +++ stable/8/sys/arm/mv/obio.c Sat Nov 6 01:09:00 2010 (r214856) @@ -324,7 +324,7 @@ mbus_activate_resource(device_t dev, dev } static device_t -mbus_add_child(device_t bus, int order, const char *name, int unit) +mbus_add_child(device_t bus, u_int order, const char *name, int unit) { struct obio_device *od; device_t child; From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 09:23:50 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2EBAF106564A; Sat, 6 Nov 2010 09:23: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 0221F8FC0A; Sat, 6 Nov 2010 09:23: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 oA69NnwP025143; Sat, 6 Nov 2010 09:23:49 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA69NnOn025141; Sat, 6 Nov 2010 09:23:49 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011060923.oA69NnOn025141@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 09:23:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214858 - stable/8/sys/sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 09:23:50 -0000 Author: lstewart Date: Sat Nov 6 09:23:49 2010 New Revision: 214858 URL: http://svn.freebsd.org/changeset/base/214858 Log: MFC r209050 (originally committed by jhb): Add helper macros to iterate over available CPUs in the system. CPU_FOREACH(i) iterates over the CPU IDs of all available CPUs. The CPU_FIRST() and CPU_NEXT(i) macros can also be used to iterate over available CPU IDs. CPU_NEXT(i) wraps around to CPU_FIRST() rather than returning some sort of terminator. Requested by: rwatson Reviewed by: attilio Modified: stable/8/sys/sys/smp.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/sys/smp.h ============================================================================== --- stable/8/sys/sys/smp.h Sat Nov 6 03:59:21 2010 (r214857) +++ stable/8/sys/sys/smp.h Sat Nov 6 09:23:49 2010 (r214858) @@ -91,6 +91,44 @@ extern cpumask_t all_cpus; */ #define CPU_ABSENT(x_cpu) ((all_cpus & (1 << (x_cpu))) == 0) +/* + * Macros to iterate over non-absent CPUs. CPU_FOREACH() takes an + * integer iterator and iterates over the available set of CPUs. + * CPU_FIRST() returns the id of the first non-absent CPU. CPU_NEXT() + * returns the id of the next non-absent CPU. It will wrap back to + * CPU_FIRST() once the end of the list is reached. The iterators are + * currently implemented via inline functions. + */ +#define CPU_FOREACH(i) \ + for ((i) = 0; (i) <= mp_maxid; (i)++) \ + if (!CPU_ABSENT((i))) + +static __inline int +cpu_first(void) +{ + int i; + + for (i = 0;; i++) + if (!CPU_ABSENT(i)) + return (i); +} + +static __inline int +cpu_next(int i) +{ + + for (;;) { + i++; + if (i > mp_maxid) + i = 0; + if (!CPU_ABSENT(i)) + return (i); + } +} + +#define CPU_FIRST() cpu_first() +#define CPU_NEXT(i) cpu_next((i)) + #ifdef SMP /* * Machine dependent functions used to initialize MP support. From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 09:34:52 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FFE9106566B; Sat, 6 Nov 2010 09:34:52 +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 4AFE58FC08; Sat, 6 Nov 2010 09:34:52 +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 oA69Yq94025447; Sat, 6 Nov 2010 09:34:52 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA69Yq32025442; Sat, 6 Nov 2010 09:34:52 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011060934.oA69Yq32025442@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 09:34:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214859 - in stable/8: share/man/man4 sys/modules sys/modules/siftr sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 09:34:52 -0000 Author: lstewart Date: Sat Nov 6 09:34:51 2010 New Revision: 214859 URL: http://svn.freebsd.org/changeset/base/214859 Log: MFC r209662,209665: Import the Statistical Information For TCP Research (SIFTR) kernel module into FreeBSD. SIFTR logs a range of statistics on active TCP connections to a log file, providing the ability to make highly granular measurements of TCP connection state. The tool is aimed at system administrators, developers and researchers alike. Please take it for a spin and test it out - the man page should have all the information required to get you going. Many thanks go to the Cisco University Research Program Fund at Community Foundation Silicon Valley and the FreeBSD Foundation. Their support of our work at the Centre for Advanced Internet Architectures, Swinburne University of Technology is greatly appreciated. r209980: Catch up with the rename of DPCPU_SUM to DPCPU_VARSUM. r209982: The SIFTR DPCPU statistics struct was not being zeroed between enable/disable cycles so the values would accumulate rather than reset for each cycle. Sponsored by: Cisco URP (r209662), FreeBSD Foundation Reviewed by: dwmalone, gnn, rpaulo (r209662) Tested by: Many on freebsd-current@ and elsewhere over the years Added: stable/8/share/man/man4/siftr.4 - copied unchanged from r209662, head/share/man/man4/siftr.4 stable/8/sys/modules/siftr/ - copied from r209662, head/sys/modules/siftr/ stable/8/sys/netinet/siftr.c - copied, changed from r209662, head/sys/netinet/siftr.c Modified: stable/8/share/man/man4/Makefile stable/8/sys/modules/Makefile Directory Properties: stable/8/share/man/ (props changed) stable/8/share/man/man1/ (props changed) stable/8/share/man/man3/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man8/ (props changed) stable/8/share/man/man9/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/share/man/man4/Makefile ============================================================================== --- stable/8/share/man/man4/Makefile Sat Nov 6 09:23:49 2010 (r214858) +++ stable/8/share/man/man4/Makefile Sat Nov 6 09:34:51 2010 (r214859) @@ -353,8 +353,9 @@ MAN= aac.4 \ sf.4 \ sge.4 \ si.4 \ - sio.4 \ + siftr.4 \ siis.4 \ + sio.4 \ sis.4 \ sk.4 \ smb.4 \ Copied: stable/8/share/man/man4/siftr.4 (from r209662, head/share/man/man4/siftr.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/share/man/man4/siftr.4 Sat Nov 6 09:34:51 2010 (r214859, copy of r209662, head/share/man/man4/siftr.4) @@ -0,0 +1,752 @@ +.\" +.\" Copyright (c) 2010 The FreeBSD Foundation +.\" All rights reserved. +.\" +.\" Portions of this software were developed at the Centre for Advanced +.\" Internet Architectures, Swinburne University of Technology, Melbourne, +.\" Australia by Lawrence Stewart under sponsorship from the FreeBSD +.\" Foundation. +.\" +.\" 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, +.\" without modification, immediately at the beginning of the file. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" 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$ +.\" +.Dd June 23, 2010 +.Dt SIFTR 4 +.Os +.Sh NAME +.Nm SIFTR +.Nd Statistical Information For TCP Research +.Sh SYNOPSIS +To load +.Ns Nm +as a module at run-time, run the following command as root: +.Bd -literal -offset indent +kldload siftr +.Ed +.Pp +Alternatively, to load +.Ns Nm +as a module at boot time, add the following line into the +.Xr loader.conf 5 +file: +.Bd -literal -offset indent +siftr_load="YES" +.Ed +.Sh DESCRIPTION +.Nm +.Ns ( Em S Ns tatistical +.Em I Ns nformation +.Em F Ns or +.Em T Ns CP +.Em R Ns esearch ) +is a kernel module that logs a range of statistics on active TCP connections to +a log file. +It provides the ability to make highly granular measurements of TCP connection +state, aimed at system administrators, developers and researchers. +.Ss Compile-time Configuration +The default operation of +.Nm +is to capture IPv4 TCP/IP packets. +.Nm +can be configured to support IPv4 and IPv6 by uncommenting: +.Bd -literal -offset indent +CFLAGS+=-DSIFTR_IPV6 +.Ed +.Pp +in +.Aq sys/modules/siftr/Makefile +and recompiling. +.Pp +In the IPv4-only (default) mode, standard dotted decimal notation (e.g. +"136.186.229.95") is used to format IPv4 addresses for logging. +In IPv6 mode, standard dotted decimal notation is used to format IPv4 addresses, +and standard colon-separated hex notation (see RFC 4291) is used to format IPv6 +addresses for logging. Note that SIFTR uses uncompressed notation to format IPv6 +addresses. +For example, the address "fe80::20f:feff:fea2:531b" would be logged as +"fe80:0:0:0:20f:feff:fea2:531b". +.Ss Run-time Configuration +.Nm +utilises the +.Xr sysctl 8 +interface to export its configuration variables to user-space. +The following variables are available: +.Bl -tag -offset indent +.It Va net.inet.siftr.enabled +controls whether the module performs its +measurements or not. +By default, the value is set to 0, which means the module +will not be taking any measurements. +Having the module loaded with +.Va net.inet.siftr.enabled +set to 0 will have no impact on the performance of the network stack, as the +packet filtering hooks are only inserted when +.Va net.inet.siftr.enabled +is set to 1. +.El +.Bl -tag -offset indent +.It Va net.inet.siftr.ppl +controls how many inbound/outbound packets for a given TCP connection will cause +a log message to be generated for the connection. +By default, the value is set to 1, which means the module will log a message for +every packet of every TCP connection. +The value can be set to any integer in the range [1,2^32], and can be changed at +any time, even while the module is enabled. +.El +.Bl -tag -offset indent +.It Va net.inet.siftr.logfile +controls the path to the file that the module writes its log messages to. +By default, the file /var/log/siftr.log is used. +The path can be changed at any time, even while the module is enabled. +.El +.Bl -tag -offset indent +.It Va net.inet.siftr.genhashes +controls whether a hash is generated for each TCP packet seen by +.Nm . +By default, the value is set to 0, which means no hashes are generated. +The hashes are useful to correlate which TCP packet triggered the generation of +a particular log message, but calculating them adds additional computational +overhead into the fast path. +.El +.Ss Log Format +A typical +.Nm +log file will contain 3 different types of log message. +All messages are written in plain ASCII text. +.Pp +Note: The +.Qq \e +present in the example log messages in this section indicates a +line continuation and is not part of the actual log message +.Pp +The first type of log message is written to the file when the module is +enabled and starts collecting data from the running kernel. The text below +shows an example module enable log. The fields are tab delimited key-value +pairs which describe some basic information about the system. +.Bd -literal -offset indent +enable_time_secs=1238556193 enable_time_usecs=462104 \\ +siftrver=1.2.2 hz=1000 tcp_rtt_scale=32 \\ +sysname=FreeBSD sysver=604000 ipmode=4 +.Ed +.Pp +Field descriptions are as follows: +.Bl -tag -offset indent +.It Va enable_time_secs +time at which the module was enabled, in seconds since the UNIX epoch. +.El +.Bl -tag -offset indent +.It Va enable_time_usecs +time at which the module was enabled, in microseconds since enable_time_secs. +.El +.Bl -tag -offset indent +.It Va siftrver +version of +.Nm . +.El +.Bl -tag -offset indent +.It Va hz +tick rate of the kernel in ticks per second. +.El +.Bl -tag -offset indent +.It Va tcp_rtt_scale +smoothed RTT estimate scaling factor +.El +.Bl -tag -offset indent +.It Va sysname +operating system name +.El +.Bl -tag -offset indent +.It Va sysver +operating system version +.El +.Bl -tag -offset indent +.It Va ipmode +IP mode as defined at compile time. +An ipmode of "4" means IPv6 is not supported and IP addresses are logged in +regular dotted quad format. +An ipmode of "6" means IPv6 is supported, and IP addresses are logged in dotted +quad or hex format, as described in the +.Qq Compile-time Configuration +subsection. +.El +.Pp +The second type of log message is written to the file when a data log message +is generated. +The text below shows an example data log triggered by an IPv4 +TCP/IP packet. +The data is CSV formatted. +.Bd -literal -offset indent +o,0xbec491a5,1238556193.463551,172.16.7.28,22,172.16.2.5,55931, \\ +1073725440,172312,6144,66560,66608,8,1,4,1448,936,1,996,255, \\ +33304,208,66608,0,208 +.Ed +.Pp +Field descriptions are as follows: +.Bl -tag -offset indent +.It Va 1 +Direction of packet that triggered the log message. +Either +.Qq i +for in, or +.Qq o +for out. +.El +.Bl -tag -offset indent +.It Va 2 +Hash of the packet that triggered the log message. +.El +.Bl -tag -offset indent +.It Va 3 +Time at which the packet that triggered the log message was processed by +the +.Xr pfil 9 +hook function, in seconds and microseconds since the UNIX epoch. +.El +.Bl -tag -offset indent +.It Va 4 +The IPv4 or IPv6 address of the local host, in dotted quad (IPv4 packet) +or colon-separated hex (IPv6 packet) notation. +.El +.Bl -tag -offset indent +.It Va 5 +The TCP port that the local host is communicating via. +.El +.Bl -tag -offset indent +.It Va 6 +The IPv4 or IPv6 address of the foreign host, in dotted quad (IPv4 packet) +or colon-separated hex (IPv6 packet) notation. +.El +.Bl -tag -offset indent +.It Va 7 +The TCP port that the foreign host is communicating via. +.El +.Bl -tag -offset indent +.It Va 8 +The slow start threshold for the flow, in bytes. +.El +.Bl -tag -offset indent +.It Va 9 +The current congestion window for the flow, in bytes. +.El +.Bl -tag -offset indent +.It Va 10 +The current bandwidth-controlled window for the flow, in bytes. +.El +.Bl -tag -offset indent +.It Va 11 +The current sending window for the flow, in bytes. +The post scaled value is reported, except during the initial handshake (first +few packets), during which time the unscaled value is reported. +.El +.Bl -tag -offset indent +.It Va 12 +The current receive window for the flow, in bytes. +The post scaled value is always reported. +.El +.Bl -tag -offset indent +.It Va 13 +The current window scaling factor for the sending window. +.El +.Bl -tag -offset indent +.It Va 14 +The current window scaling factor for the receiving window. +.El +.Bl -tag -offset indent +.It Va 15 +The current state of the TCP finite state machine, as defined +in +.Aq Pa netinet/tcp_fsm.h . +.El +.Bl -tag -offset indent +.It Va 16 +The maximum segment size for the flow, in bytes. +.El +.Bl -tag -offset indent +.It Va 17 +The current smoothed RTT estimate for the flow, in units of TCP_RTT_SCALE * HZ, +where TCP_RTT_SCALE is a define found in tcp_var.h, and HZ is the kernel's tick +timer. +Divide by TCP_RTT_SCALE * HZ to get the RTT in secs. TCP_RTT_SCALE and HZ are +reported in the enable log message. +.El +.Bl -tag -offset indent +.It Va 18 +SACK enabled indicator. 1 if SACK enabled, 0 otherwise. +.El +.Bl -tag -offset indent +.It Va 19 +The current state of the TCP flags for the flow. +See +.Aq Pa netinet/tcp_var.h +for information about the various flags. +.El +.Bl -tag -offset indent +.It Va 20 +The current retransmission timeout length for the flow, in units of HZ, where HZ +is the kernel's tick timer. +Divide by HZ to get the timeout length in seconds. HZ is reported in the +enable log message. +.El +.Bl -tag -offset indent +.It Va 21 +The current size of the socket send buffer in bytes. +.El +.Bl -tag -offset indent +.It Va 22 +The current number of bytes in the socket send buffer. +.El +.Bl -tag -offset indent +.It Va 23 +The current size of the socket receive buffer in bytes. +.El +.Bl -tag -offset indent +.It Va 24 +The current number of bytes in the socket receive buffer. +.El +.Bl -tag -offset indent +.It Va 25 +The current number of unacknowledged bytes in-flight. +Bytes acknowledged via SACK are not excluded from this count. +.El +.Pp +The third type of log message is written to the file when the module is disabled +and ceases collecting data from the running kernel. +The text below shows an example module disable log. +The fields are tab delimited key-value pairs which provide statistics about +operations since the module was most recently enabled. +.Bd -literal -offset indent +disable_time_secs=1238556197 disable_time_usecs=933607 \\ +num_inbound_tcp_pkts=356 num_outbound_tcp_pkts=627 \\ +total_tcp_pkts=983 num_inbound_skipped_pkts_malloc=0 \\ +num_outbound_skipped_pkts_malloc=0 num_inbound_skipped_pkts_mtx=0 \\ +num_outbound_skipped_pkts_mtx=0 num_inbound_skipped_pkts_tcb=0 \\ +num_outbound_skipped_pkts_tcb=0 num_inbound_skipped_pkts_icb=0 \\ +num_outbound_skipped_pkts_icb=0 total_skipped_tcp_pkts=0 \\ +flow_list=172.16.7.28;22-172.16.2.5;55931, +.Ed +.Pp +Field descriptions are as follows: +.Bl -tag -offset indent +.It Va disable_time_secs +Time at which the module was disabled, in seconds since the UNIX epoch. +.El +.Bl -tag -offset indent +.It Va disable_time_usecs +Time at which the module was disabled, in microseconds since disable_time_secs. +.El +.Bl -tag -offset indent +.It Va num_inbound_tcp_pkts +Number of TCP packets that traversed up the network stack. +This only includes inbound TCP packets during the periods when +.Nm +was enabled. +.El +.Bl -tag -offset indent +.It Va num_outbound_tcp_pkts +Number of TCP packets that traversed down the network stack. +This only includes outbound TCP packets during the periods when +.Nm +was enabled. +.El +.Bl -tag -offset indent +.It Va total_tcp_pkts +The summation of num_inbound_tcp_pkts and num_outbound_tcp_pkts. +.El +.Bl -tag -offset indent +.It Va num_inbound_skipped_pkts_malloc +Number of inbound packets that were not processed because of failed malloc() calls. +.El +.Bl -tag -offset indent +.It Va num_outbound_skipped_pkts_malloc +Number of outbound packets that were not processed because of failed malloc() calls. +.El +.Bl -tag -offset indent +.It Va num_inbound_skipped_pkts_mtx +Number of inbound packets that were not processed because of failure to add the +packet to the packet processing queue. +.El +.Bl -tag -offset indent +.It Va num_outbound_skipped_pkts_mtx +Number of outbound packets that were not processed because of failure to add the +packet to the packet processing queue. +.El +.Bl -tag -offset indent +.It Va num_inbound_skipped_pkts_tcb +Number of inbound packets that were not processed because of failure to find the +TCP control block associated with the packet. +.El +.Bl -tag -offset indent +.It Va num_outbound_skipped_pkts_tcb +Number of outbound packets that were not processed because of failure to find +the TCP control block associated with the packet. +.El +.Bl -tag -offset indent +.It Va num_inbound_skipped_pkts_icb +Number of inbound packets that were not processed because of failure to find the +IP control block associated with the packet. +.El +.Bl -tag -offset indent +.It Va num_outbound_skipped_pkts_icb +Number of outbound packets that were not processed because of failure to find +the IP control block associated with the packet. +.El +.Bl -tag -offset indent +.It Va total_skipped_tcp_pkts +The summation of all skipped packet counters. +.El +.Bl -tag -offset indent +.It Va flow_list +A CSV list of TCP flows that triggered data log messages to be generated since +the module was loaded. +Each flow entry in the CSV list is +formatted as +.Qq local_ip;local_port-foreign_ip;foreign_port . +If there are no entries in the list (i.e. no data log messages were generated), +the value will be blank. +If there is at least one entry in the list, a trailing comma will always be +present. +.El +.Pp +The total number of data log messages found in the log file for a module +enable/disable cycle should equate to total_tcp_pkts - total_skipped_tcp_pkts. +.Sh IMPLEMENTATION NOTES +.Nm +hooks into the network stack using the +.Xr pfil 9 +interface. +In its current incarnation, it hooks into the AF_INET/AF_INET6 (IPv4/IPv6) +.Xr pfil 9 +filtering points, which means it sees packets at the IP layer of the network +stack. +This means that TCP packets inbound to the stack are intercepted before +they have been processed by the TCP layer. +Packets outbound from the stack are intercepted after they have been processed +by the TCP layer. +.Pp +The diagram below illustrates how +.Nm +inserts itself into the stack. +.Bd -literal -offset indent +---------------------------------- + Upper Layers +---------------------------------- + ^ | + | | + | | + | v + TCP in TCP out +---------------------------------- + ^ | + |________ _________| + | | + | v + --------- + | SIFTR | + --------- + ^ | + ________| |__________ + | | + | v +IPv{4/6} in IPv{4/6} out +---------------------------------- + ^ | + | | + | v +Layer 2 in Layer 2 out +---------------------------------- + Physical Layer +---------------------------------- +.Ed +.Pp +.Nm +uses the +.Xr alq 9 +interface to manage writing data to disk. +.Pp +At first glance, you might mistakenly think that +.Nm +extracts information from +individual TCP packets. +This is not the case. +.Nm +uses TCP packet events (inbound and outbound) for each TCP flow originating from +the system to trigger a dump of the state of the TCP control block for that +flow. +With the PPL set to 1, we are in effect sampling each TCP flow's control block +state as frequently as flow packets enter/leave the system. +For example, setting PPL to 2 halves the sampling rate i.e. every second flow +packet (inbound OR outbound) causes a dump of the control block state. +.Pp +The distinction between interrogating individual packets vs interrogating the +control block is important, because +.Nm +does not remove the need for packet capturing tools like +.Xr tcpdump 1 . +.Nm +allows you to correlate and observe the cause-and-affect relationship between +what you see on the wire (captured using a tool like +.Xr tcpdump 1 Ns ) +and changes in the TCP control block corresponding to the flow of interest. +It is therefore useful to use +.Nm +and a tool like +.Xr tcpdump 1 +to gather the necessary data to piece together the complete picture. +Use of either tool on its own will not be able to provide all of the necessary +data. +.Pp +As a result of needing to interrogate the TCP control block, certain packets +during the lifecycle of a connection are unable to trigger a +.Nm +log message. +The initial handshake takes place without the existence of a control block and +the final ACK is exchanged when the connection is in the TIMEWAIT state. +.Pp +.Nm +was designed to minimise the delay introduced to packets traversing the network +stack. +This design called for a highly optimised and minimal hook function that +extracted the minimal details necessary whilst holding the packet up, and +passing these details to another thread for actual processing and logging. +.Pp +This multithreaded design does introduce some contention issues when accessing +the data structure shared between the threads of operation. +When the hook function tries to place details in the structure, it must first +acquire an exclusive lock. +Likewise, when the processing thread tries to read details from the structure, +it must also acquire an exclusive lock to do so. +If one thread holds the lock, the other must wait before it can obtain it. +This does introduce some additional bounded delay into the kernel's packet +processing code path. +.Pp +In some cases (e.g. low memory, connection termination), TCP packets that enter +the +.Nm +.Xr pfil 9 +hook function will not trigger a log message to be generated. +.Nm +refers to this outcome as a +.Qq skipped packet . +Note that +.Nm +always ensures that packets are allowed to continue through the stack, even if +they could not successfully trigger a data log message. +.Nm +will therefore not introduce any packet loss for TCP/IP packets traversing the +network stack. +.Ss Important Behaviours +The behaviour of a log file path change whilst the module is enabled is as +follows: +.Bl -enum +.It +Attempt to open the new file path for writing. +If this fails, the path change will fail and the existing path will continue to +be used. +.It +Assuming the new path is valid and opened successfully: +.Bl -dash +.It +Flush all pending log messages to the old file path. +.It +Close the old file path. +.It +Switch the active log file pointer to point at the new file path. +.It +Commence logging to the new file. +.El +.El +.Pp +During the time between the flush of pending log messages to the old file and +commencing logging to the new file, new log messages will still be generated and +buffered. +As soon as the new file path is ready for writing, the accumulated log messages +will be written out to the file. +.Sh EXAMPLES +To enable the module's operations, run the following command as root: +sysctl net.inet.siftr.enabled=1 +.Pp +To change the granularity of log messages such that 1 log message is +generated for every 10 TCP packets per connection, run the following +command as root: +sysctl net.inet.siftr.ppl=10 +.Pp +To change the log file location to /tmp/siftr.log, run the following +command as root: +sysctl net.inet.siftr.logfile=/tmp/siftr.log +.Sh SEE ALSO +.Xr alq 9 , +.Xr pfil 9 +.Xr sysctl 8 , +.Xr tcp 4 , +.Xr tcpdump 1 , +.Sh ACKNOWLEDGEMENTS +Development of this software was made possible in part by grants from the +Cisco University Research Program Fund at Community Foundation Silicon Valley, +and the FreeBSD Foundation. +.Sh HISTORY +.Nm +first appeared in +.Fx 9.0 . +.Pp +.Nm +was first released in 2007 by Lawrence Stewart and James Healy 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: +.Pp +http://caia.swin.edu.au/urp/newtcp/ +.Pp +Work on +.Nm +v1.2.x was sponsored by the FreeBSD Foundation as part of +the +.Qq Enhancing the FreeBSD TCP Implementation +project 2008-2009. +More details are available at: +.Pp +http://www.freebsdfoundation.org/ +.Pp +http://caia.swin.edu.au/freebsd/etcp09/ +.Sh AUTHORS +.An -nosplit +.Nm +was written by +.An Lawrence Stewart Aq lstewart@FreeBSD.org +and +.An James Healy Aq jimmy@deefa.com . +.Pp +This manual page was written by +.An Lawrence Stewart Aq lstewart@FreeBSD.org . +.Sh BUGS +Current known limitations and any relevant workarounds are outlined below: +.Bl -dash +.It +The internal queue used to pass information between the threads of operation is +currently unbounded. +This allows +.Nm +to cope with bursty network traffic, but sustained high packet-per-second +traffic can cause exhaustion of kernel memory if the processing thread cannot +keep up with the packet rate. +.It +If using +.Nm +on a machine that is also running other modules utilising the +.Xr pfil 9 +framework e.g. +.Xr dummynet 4 , +.Xr ipfw 8 , +.Xr pf 4 Ns , +the order in which you load the modules is important. +You should kldload the other modules first, as this will ensure TCP packets +undergo any necessary manipulations before +.Nm +.Qq sees +and processes them. +.It +There is a known, harmless lock order reversal warning between the +.Xr pfil 9 +mutex and tcbinfo TCP lock reported by +.Xr witness 4 +when +.Nm +is enabled in a kernel compiled with +.Xr witness 4 +support. +.It +There is no way to filter which TCP flows you wish to capture data for. +Post processing is required to separate out data belonging to particular flows +of interest. +.It +The module does not detect deletion of the log file path. +New log messages will simply be lost if the log file being used by +.Nm +is deleted whilst the module is set to use the file. +Switching to a new log file using the +.Em net.inet.siftr.logfile +variable will create the new file and allow log messages to begin being written +to disk again. +The new log file path must differ from the path to the deleted file. +.It +The hash table used within the code is sized to hold 65536 flows. This is not a +hard limit, because chaining is used to handle collisions within the hash table +structure. +However, we suspect (based on analogies with other hash table performance data) +that the hash table look up performance (and therefore the module's packet +processing performance) will degrade in an exponential manner as the number of +unique flows handled in a module enable/disable cycle approaches and surpasses +65536. +.It +There is no garbage collection performed on the flow hash table. +The only way currently to flush it is to disable +.Nm . +.It +The PPL variable applies to packets that make it into the processing thread, +not total packets received in the hook function. +Packets are skipped before the PPL variable is applied, which means there may be +a slight discrepancy in the triggering of log messages. +For example, if PPL was set to 10, and the 8th packet since the last log message +is skipped, the 11th packet will actually trigger the log message to be +generated. +This is discussed in greater depth in CAIA technical report 070824A. +.It +At the time of writing, there was no simple way to hook into the TCP layer +to intercept packets. +.Nm Ap s +use of IP layer hook points means all IP +traffic will be processed by the +.Nm +.Xr pfil 9 +hook function, which introduces minor, but nonetheless unnecessary packet delay +and processing overhead on the system for non-TCP packets as well. +Hooking in at the IP layer is also not ideal from the data gathering point of +view. +Packets traversing up the stack will be intercepted and cause a log message +generation BEFORE they have been processed by the TCP layer, which means we +cannot observe the cause-and-affect relationship between inbound events and the +corresponding TCP control block as precisely as could be. +Ideally, +.Nm +should intercept packets after they have been processed by the TCP layer i.e. +intercept packets coming up the stack after they have been processed by +tcp_input(), and intercept packets coming down the stack after they have been +processed by tcp_output(). +The current code still gives satisfactory granularity though, as inbound events +tend to trigger outbound events, allowing the cause-and-effect to be observed +indirectly by capturing the state on outbound events as well. +.It +The +.Qq inflight bytes +value logged by +.Nm +does not take into account bytes that have been +.No SACK Ap ed +by the receiving host. +.It +Packet hash generation does not currently work for IPv6 based TCP packets. +.It +Compressed notation is not used for IPv6 address representation. +This consumes more bytes than is necessary in log output. +.El Modified: stable/8/sys/modules/Makefile ============================================================================== --- stable/8/sys/modules/Makefile Sat Nov 6 09:23:49 2010 (r214858) +++ stable/8/sys/modules/Makefile Sat Nov 6 09:34:51 2010 (r214859) @@ -258,6 +258,7 @@ SUBDIR= ${_3dfx} \ sf \ sge \ siba_bwn \ + siftr \ siis \ sis \ sk \ Copied and modified: stable/8/sys/netinet/siftr.c (from r209662, head/sys/netinet/siftr.c) ============================================================================== --- head/sys/netinet/siftr.c Sat Jul 3 13:32:39 2010 (r209662, copy source) +++ stable/8/sys/netinet/siftr.c Sat Nov 6 09:34:51 2010 (r214859) @@ -1233,6 +1233,8 @@ siftr_manage_ops(uint8_t action) STAILQ_INIT(&pkt_queue); + DPCPU_ZERO(ss); + siftr_exit_pkt_manager_thread = 0; ret = kthread_add(&siftr_pkt_manager_thread, NULL, NULL, @@ -1282,16 +1284,16 @@ siftr_manage_ops(uint8_t action) siftr_pkt_manager_thr = NULL; mtx_unlock(&siftr_pkt_mgr_mtx); - totalss.n_in = DPCPU_SUM(ss, n_in); - totalss.n_out = DPCPU_SUM(ss, n_out); - totalss.nskip_in_malloc = DPCPU_SUM(ss, nskip_in_malloc); - totalss.nskip_out_malloc = DPCPU_SUM(ss, nskip_out_malloc); - totalss.nskip_in_mtx = DPCPU_SUM(ss, nskip_in_mtx); - totalss.nskip_out_mtx = DPCPU_SUM(ss, nskip_out_mtx); - totalss.nskip_in_tcpcb = DPCPU_SUM(ss, nskip_in_tcpcb); - totalss.nskip_out_tcpcb = DPCPU_SUM(ss, nskip_out_tcpcb); - totalss.nskip_in_inpcb = DPCPU_SUM(ss, nskip_in_inpcb); - totalss.nskip_out_inpcb = DPCPU_SUM(ss, nskip_out_inpcb); + totalss.n_in = DPCPU_VARSUM(ss, n_in); + totalss.n_out = DPCPU_VARSUM(ss, n_out); + totalss.nskip_in_malloc = DPCPU_VARSUM(ss, nskip_in_malloc); + totalss.nskip_out_malloc = DPCPU_VARSUM(ss, nskip_out_malloc); + totalss.nskip_in_mtx = DPCPU_VARSUM(ss, nskip_in_mtx); + totalss.nskip_out_mtx = DPCPU_VARSUM(ss, nskip_out_mtx); + totalss.nskip_in_tcpcb = DPCPU_VARSUM(ss, nskip_in_tcpcb); + totalss.nskip_out_tcpcb = DPCPU_VARSUM(ss, nskip_out_tcpcb); + totalss.nskip_in_inpcb = DPCPU_VARSUM(ss, nskip_in_inpcb); + totalss.nskip_out_inpcb = DPCPU_VARSUM(ss, nskip_out_inpcb); total_skipped_pkts = totalss.nskip_in_malloc + totalss.nskip_out_malloc + totalss.nskip_in_mtx + From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 09:42:41 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9BE1106566C; Sat, 6 Nov 2010 09:42:41 +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 B6F558FC12; Sat, 6 Nov 2010 09:42: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 oA69gf1F025646; Sat, 6 Nov 2010 09:42:41 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA69gfYW025642; Sat, 6 Nov 2010 09:42:41 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011060942.oA69gfYW025642@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 09:42:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214860 - stable/8/sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 09:42:41 -0000 Author: lstewart Date: Sat Nov 6 09:42:41 2010 New Revision: 214860 URL: http://svn.freebsd.org/changeset/base/214860 Log: MFC r213158: Internalise reassembly queue related functionality and variables which should not be used outside of the reassembly queue implementation. Provide a new function to flush all segments from a reassembly queue and call it from the appropriate places instead of manipulating the queue directly. Sponsored by: FreeBSD Foundation Reviewed by: andre, gnn, rpaulo Modified: stable/8/sys/netinet/tcp_reass.c stable/8/sys/netinet/tcp_subr.c stable/8/sys/netinet/tcp_var.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/tcp_reass.c ============================================================================== --- stable/8/sys/netinet/tcp_reass.c Sat Nov 6 09:34:51 2010 (r214859) +++ stable/8/sys/netinet/tcp_reass.c Sat Nov 6 09:42:41 2010 (r214860) @@ -83,7 +83,8 @@ SYSCTL_VNET_INT(_net_inet_tcp_reass, OID &VNET_NAME(tcp_reass_maxseg), 0, "Global maximum number of TCP Segments in Reassembly Queue"); -VNET_DEFINE(int, tcp_reass_qsize) = 0; +static VNET_DEFINE(int, tcp_reass_qsize) = 0; +#define V_tcp_reass_qsize VNET(tcp_reass_qsize) SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, cursegments, CTLFLAG_RD, &VNET_NAME(tcp_reass_qsize), 0, "Global number of TCP Segments currently in Reassembly Queue"); @@ -100,6 +101,9 @@ SYSCTL_VNET_INT(_net_inet_tcp_reass, OID &VNET_NAME(tcp_reass_overflows), 0, "Global number of TCP Segment Reassembly Queue Overflows"); +static VNET_DEFINE(uma_zone_t, tcp_reass_zone); +#define V_tcp_reass_zone VNET(tcp_reass_zone) + /* Initialize TCP reassembly queue */ static void tcp_reass_zone_change(void *tag) @@ -109,8 +113,6 @@ tcp_reass_zone_change(void *tag) uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg); } -VNET_DEFINE(uma_zone_t, tcp_reass_zone); - void tcp_reass_init(void) { @@ -134,6 +136,26 @@ tcp_reass_destroy(void) } #endif +void +tcp_reass_flush(struct tcpcb *tp) +{ + struct tseg_qent *qe; + + INP_WLOCK_ASSERT(tp->t_inpcb); + + while ((qe = LIST_FIRST(&tp->t_segq)) != NULL) { + LIST_REMOVE(qe, tqe_q); + m_freem(qe->tqe_m); + uma_zfree(V_tcp_reass_zone, qe); + tp->t_segqlen--; + V_tcp_reass_qsize--; + } + + KASSERT((tp->t_segqlen == 0), + ("TCP reass queue %p segment count is %d instead of 0 after flush.", + tp, tp->t_segqlen)); +} + int tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) { Modified: stable/8/sys/netinet/tcp_subr.c ============================================================================== --- stable/8/sys/netinet/tcp_subr.c Sat Nov 6 09:34:51 2010 (r214859) +++ stable/8/sys/netinet/tcp_subr.c Sat Nov 6 09:42:41 2010 (r214860) @@ -775,7 +775,6 @@ tcp_drop(struct tcpcb *tp, int errno) void tcp_discardcb(struct tcpcb *tp) { - struct tseg_qent *q; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; #ifdef INET6 @@ -853,13 +852,7 @@ tcp_discardcb(struct tcpcb *tp) } /* free the reassembly queue, if any */ - while ((q = LIST_FIRST(&tp->t_segq)) != NULL) { - LIST_REMOVE(q, tqe_q); - m_freem(q->tqe_m); - uma_zfree(V_tcp_reass_zone, q); - tp->t_segqlen--; - V_tcp_reass_qsize--; - } + tcp_reass_flush(tp); /* Disconnect offload device, if any. */ tcp_offload_detach(tp); @@ -917,7 +910,6 @@ tcp_drain(void) CURVNET_SET(vnet_iter); struct inpcb *inpb; struct tcpcb *tcpb; - struct tseg_qent *te; /* * Walk the tcpbs, if existing, and flush the reassembly queue, @@ -933,14 +925,7 @@ tcp_drain(void) continue; INP_WLOCK(inpb); if ((tcpb = intotcpcb(inpb)) != NULL) { - while ((te = LIST_FIRST(&tcpb->t_segq)) - != NULL) { - LIST_REMOVE(te, tqe_q); - m_freem(te->tqe_m); - uma_zfree(V_tcp_reass_zone, te); - tcpb->t_segqlen--; - V_tcp_reass_qsize--; - } + tcp_reass_flush(tcpb); tcp_clean_sackreport(tcpb); } INP_WUNLOCK(inpb); Modified: stable/8/sys/netinet/tcp_var.h ============================================================================== --- stable/8/sys/netinet/tcp_var.h Sat Nov 6 09:34:51 2010 (r214859) +++ stable/8/sys/netinet/tcp_var.h Sat Nov 6 09:42:41 2010 (r214860) @@ -44,10 +44,6 @@ VNET_DECLARE(int, tcp_do_rfc1323); #define V_tcp_do_rfc1323 VNET(tcp_do_rfc1323) -VNET_DECLARE(int, tcp_reass_qsize); -VNET_DECLARE(struct uma_zone *, tcp_reass_zone); -#define V_tcp_reass_qsize VNET(tcp_reass_qsize) -#define V_tcp_reass_zone VNET(tcp_reass_zone) #endif /* _KERNEL */ /* TCP segment queue entry */ @@ -608,6 +604,7 @@ char *tcp_log_vain(struct in_conninfo *, const void *); int tcp_reass(struct tcpcb *, struct tcphdr *, int *, struct mbuf *); void tcp_reass_init(void); +void tcp_reass_flush(struct tcpcb *); #ifdef VIMAGE void tcp_reass_destroy(void); #endif From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 09:56:14 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 834C0106564A; Sat, 6 Nov 2010 09:56:14 +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 5662A8FC12; Sat, 6 Nov 2010 09:56: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 oA69uE6f025970; Sat, 6 Nov 2010 09:56:14 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA69uEjn025967; Sat, 6 Nov 2010 09:56:14 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011060956.oA69uEjn025967@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 09:56:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214861 - stable/8/sys/vm X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 09:56:14 -0000 Author: lstewart Date: Sat Nov 6 09:56:14 2010 New Revision: 214861 URL: http://svn.freebsd.org/changeset/base/214861 Log: MFC r211396 (originally committed by andre): Add uma_zone_get_max() to obtain the effective limit after a call to uma_zone_set_max(). The UMA zone limit is not exactly set to the value supplied but rounded up to completely fill the backing store increment (a page normally). This can lead to surprising situations where the number of elements allocated from UMA is higher than the supplied limit value. The new get function reads back the effective value so that the supplied limit value can be adjusted to the real limit. Reviewed by: jeffr Modified: stable/8/sys/vm/uma.h stable/8/sys/vm/uma_core.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/vm/uma.h ============================================================================== --- stable/8/sys/vm/uma.h Sat Nov 6 09:42:41 2010 (r214860) +++ stable/8/sys/vm/uma.h Sat Nov 6 09:56:14 2010 (r214861) @@ -459,6 +459,18 @@ int uma_zone_set_obj(uma_zone_t zone, st void uma_zone_set_max(uma_zone_t zone, int nitems); /* + * Obtains the effective limit on the number of items in a zone + * + * Arguments: + * zone The zone to obtain the effective limit from + * + * Return: + * 0 No limit + * int The effective limit of the zone + */ +int uma_zone_get_max(uma_zone_t zone); + +/* * The following two routines (uma_zone_set_init/fini) * are used to set the backend init/fini pair which acts on an * object as it becomes allocated and is placed in a slab within Modified: stable/8/sys/vm/uma_core.c ============================================================================== --- stable/8/sys/vm/uma_core.c Sat Nov 6 09:42:41 2010 (r214860) +++ stable/8/sys/vm/uma_core.c Sat Nov 6 09:56:14 2010 (r214861) @@ -2803,6 +2803,24 @@ uma_zone_set_max(uma_zone_t zone, int ni } /* See uma.h */ +int +uma_zone_get_max(uma_zone_t zone) +{ + int nitems; + uma_keg_t keg; + + ZONE_LOCK(zone); + keg = zone_first_keg(zone); + if (keg->uk_maxpages) + nitems = keg->uk_maxpages * keg->uk_ipers; + else + nitems = 0; + ZONE_UNLOCK(zone); + + return (nitems); +} + +/* See uma.h */ void uma_zone_set_init(uma_zone_t zone, uma_init uminit) { From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 10:06:59 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A0D0106564A; Sat, 6 Nov 2010 10:06:59 +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 06F438FC0C; Sat, 6 Nov 2010 10:06: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 oA6A6wvO026284; Sat, 6 Nov 2010 10:06:58 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6A6wps026280; Sat, 6 Nov 2010 10:06:58 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061006.oA6A6wps026280@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 10:06:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214862 - in stable/8: share/man/man9 sys/vm X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 10:06:59 -0000 Author: lstewart Date: Sat Nov 6 10:06:58 2010 New Revision: 214862 URL: http://svn.freebsd.org/changeset/base/214862 Log: MFC r213910: - Simplify implementation of uma_zone_get_max. - Add uma_zone_get_cur which returns the current approximate occupancy of a zone. This is useful for providing stats via sysctl amongst other things. Sponsored by: FreeBSD Foundation Reviewed by: gnn, jhb Modified: stable/8/share/man/man9/zone.9 stable/8/sys/vm/uma.h stable/8/sys/vm/uma_core.c Directory Properties: stable/8/share/man/ (props changed) stable/8/share/man/man1/ (props changed) stable/8/share/man/man3/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man8/ (props changed) stable/8/share/man/man9/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/share/man/man9/zone.9 ============================================================================== --- stable/8/share/man/man9/zone.9 Sat Nov 6 09:56:14 2010 (r214861) +++ stable/8/share/man/man9/zone.9 Sat Nov 6 10:06:58 2010 (r214862) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 19, 2008 +.Dd October 9, 2010 .Dt ZONE 9 .Os .Sh NAME @@ -35,7 +35,9 @@ .Nm uma_zfree , .Nm uma_zfree_arg , .Nm uma_zdestroy , -.Nm uma_zone_set_max +.Nm uma_zone_set_max, +.Nm uma_zone_get_max, +.Nm uma_zone_get_cur .Nd zone allocator .Sh SYNOPSIS .In sys/param.h @@ -59,6 +61,10 @@ .Fn uma_zdestroy "uma_zone_t zone" .Ft void .Fn uma_zone_set_max "uma_zone_t zone" "int nitems" +.Ft int +.Fn uma_zone_get_max "uma_zone_t zone" +.Ft int +.Fn uma_zone_get_cur "uma_zone_t zone" .Sh DESCRIPTION The zone allocator provides an efficient interface for managing dynamically-sized collections of items of similar size. @@ -177,21 +183,36 @@ must have been freed with .Fn uma_zfree before. .Pp -The purpose of +The .Fn uma_zone_set_max -is to limit the maximum amount of memory that the system can dedicated -toward the zone specified by the -.Fa zone -argument. +function limits the number of items +.Pq and therefore memory +that can be allocated to +.Fa zone . The .Fa nitems -argument gives the upper limit of items in the zone. -This limits the total number of items in the zone which includes: +argument specifies the requested upper limit number of items. +The effective limit may end up being higher than requested, as the +implementation will round up to ensure all memory pages allocated to the zone +are utilised to capacity. +The limit applies to the total number of items in the zone, which includes allocated items, free items and free items in the per-cpu caches. On systems with more than one CPU it may not be possible to allocate the specified number of items even when there is no shortage of memory, because all of the remaining free items may be in the caches of the other CPUs when the limit is hit. +.Pp +The +.Fn uma_zone_get_max +function returns the effective upper limit number of items for a zone. +.Pp +The +.Fn uma_zone_get_cur +function returns the approximate current occupancy of the zone. +The returned value is approximate because appropriate synchronisation to +determine an exact value is not performend by the implementation. +This ensures low overhead at the expense of potentially stale data being used +in the calculation. .Sh RETURN VALUES The .Fn uma_zalloc Modified: stable/8/sys/vm/uma.h ============================================================================== --- stable/8/sys/vm/uma.h Sat Nov 6 09:56:14 2010 (r214861) +++ stable/8/sys/vm/uma.h Sat Nov 6 10:06:58 2010 (r214862) @@ -471,6 +471,17 @@ void uma_zone_set_max(uma_zone_t zone, i int uma_zone_get_max(uma_zone_t zone); /* + * Obtains the approximate current number of items allocated from a zone + * + * Arguments: + * zone The zone to obtain the current allocation count from + * + * Return: + * int The approximate current number of items allocated from the zone + */ +int uma_zone_get_cur(uma_zone_t zone); + +/* * The following two routines (uma_zone_set_init/fini) * are used to set the backend init/fini pair which acts on an * object as it becomes allocated and is placed in a slab within Modified: stable/8/sys/vm/uma_core.c ============================================================================== --- stable/8/sys/vm/uma_core.c Sat Nov 6 09:56:14 2010 (r214861) +++ stable/8/sys/vm/uma_core.c Sat Nov 6 10:06:58 2010 (r214862) @@ -2811,16 +2811,36 @@ uma_zone_get_max(uma_zone_t zone) ZONE_LOCK(zone); keg = zone_first_keg(zone); - if (keg->uk_maxpages) - nitems = keg->uk_maxpages * keg->uk_ipers; - else - nitems = 0; + nitems = keg->uk_maxpages * keg->uk_ipers; ZONE_UNLOCK(zone); return (nitems); } /* See uma.h */ +int +uma_zone_get_cur(uma_zone_t zone) +{ + int64_t nitems; + u_int i; + + ZONE_LOCK(zone); + nitems = zone->uz_allocs - zone->uz_frees; + CPU_FOREACH(i) { + /* + * See the comment in sysctl_vm_zone_stats() regarding the + * safety of accessing the per-cpu caches. With the zone lock + * held, it is safe, but can potentially result in stale data. + */ + nitems += zone->uz_cpu[i].uc_allocs - + zone->uz_cpu[i].uc_frees; + } + ZONE_UNLOCK(zone); + + return (nitems < 0 ? 0 : nitems); +} + +/* See uma.h */ void uma_zone_set_init(uma_zone_t zone, uma_init uminit) { From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 10:17:43 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB9DF106566C; Sat, 6 Nov 2010 10:17:43 +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 B84AC8FC17; Sat, 6 Nov 2010 10:17:43 +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 oA6AHhnA026550; Sat, 6 Nov 2010 10:17:43 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6AHhS4026548; Sat, 6 Nov 2010 10:17:43 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061017.oA6AHhS4026548@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 10:17:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214863 - stable/8/sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 10:17:43 -0000 Author: lstewart Date: Sat Nov 6 10:17:43 2010 New Revision: 214863 URL: http://svn.freebsd.org/changeset/base/214863 Log: MFC r210203: - Move common code from the hook functions that fills in a packet node struct to a separate inline function. This further reduces duplicate code that didn't have a good reason to stay as it was. - Reorder the malloc of a pkt_node struct in the hook functions such that it only occurs if we managed to find a usable tcpcb associated with the packet. - Make the inp_locally_locked variable's type consistent with the prototype of siftr_siftdata(). Sponsored by: FreeBSD Foundation Modified: stable/8/sys/netinet/siftr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/siftr.c ============================================================================== --- stable/8/sys/netinet/siftr.c Sat Nov 6 10:06:58 2010 (r214862) +++ stable/8/sys/netinet/siftr.c Sat Nov 6 10:17:43 2010 (r214863) @@ -746,6 +746,67 @@ siftr_findinpcb(int ipver, struct ip *ip } +static inline void +siftr_siftdata(struct pkt_node *pn, struct inpcb *inp, struct tcpcb *tp, + int ipver, int dir, int inp_locally_locked) +{ +#ifdef SIFTR_IPV6 + if (ipver == INP_IPV4) { + pn->ip_laddr[3] = inp->inp_laddr.s_addr; + pn->ip_faddr[3] = inp->inp_faddr.s_addr; +#else + *((uint32_t *)pn->ip_laddr) = inp->inp_laddr.s_addr; + *((uint32_t *)pn->ip_faddr) = inp->inp_faddr.s_addr; +#endif +#ifdef SIFTR_IPV6 + } else { + pn->ip_laddr[0] = inp->in6p_laddr.s6_addr32[0]; + pn->ip_laddr[1] = inp->in6p_laddr.s6_addr32[1]; + pn->ip_laddr[2] = inp->in6p_laddr.s6_addr32[2]; + pn->ip_laddr[3] = inp->in6p_laddr.s6_addr32[3]; + pn->ip_faddr[0] = inp->in6p_faddr.s6_addr32[0]; + pn->ip_faddr[1] = inp->in6p_faddr.s6_addr32[1]; + pn->ip_faddr[2] = inp->in6p_faddr.s6_addr32[2]; + pn->ip_faddr[3] = inp->in6p_faddr.s6_addr32[3]; + } +#endif + pn->tcp_localport = inp->inp_lport; + pn->tcp_foreignport = inp->inp_fport; + pn->snd_cwnd = tp->snd_cwnd; + pn->snd_wnd = tp->snd_wnd; + pn->rcv_wnd = tp->rcv_wnd; + pn->snd_bwnd = tp->snd_bwnd; + pn->snd_ssthresh = tp->snd_ssthresh; + pn->snd_scale = tp->snd_scale; + pn->rcv_scale = tp->rcv_scale; + pn->conn_state = tp->t_state; + pn->max_seg_size = tp->t_maxseg; + pn->smoothed_rtt = tp->t_srtt; + pn->sack_enabled = (tp->t_flags & TF_SACK_PERMIT) != 0; + pn->flags = tp->t_flags; + pn->rxt_length = tp->t_rxtcur; + pn->snd_buf_hiwater = inp->inp_socket->so_snd.sb_hiwat; + pn->snd_buf_cc = inp->inp_socket->so_snd.sb_cc; + pn->rcv_buf_hiwater = inp->inp_socket->so_rcv.sb_hiwat; + pn->rcv_buf_cc = inp->inp_socket->so_rcv.sb_cc; + pn->sent_inflight_bytes = tp->snd_max - tp->snd_una; + + /* We've finished accessing the tcb so release the lock. */ + if (inp_locally_locked) + INP_RUNLOCK(inp); + + pn->ipver = ipver; + pn->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(&pn->tval); +} + + /* * pfil hook that is called for each IPv4 packet making its way through the * stack in either direction. @@ -758,13 +819,13 @@ static int siftr_chkpkt(void *arg, struct mbuf **m, struct ifnet *ifp, int dir, struct inpcb *inp) { - struct pkt_node *pkt_node; + struct pkt_node *pn; struct ip *ip; struct tcphdr *th; struct tcpcb *tp; struct siftr_stats *ss; unsigned int ip_hl; - uint8_t inp_locally_locked; + int inp_locally_locked; inp_locally_locked = 0; ss = DPCPU_PTR(ss); @@ -818,18 +879,6 @@ siftr_chkpkt(void *arg, struct mbuf **m, 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) - ss->nskip_in_malloc++; - else - ss->nskip_out_malloc++; - - goto inp_unlock; - } - /* Find the TCP control block that corresponds with this packet */ tp = intotcpcb(inp); @@ -844,53 +893,21 @@ siftr_chkpkt(void *arg, struct mbuf **m, else ss->nskip_out_tcpcb++; - 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->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; - pkt_node->sack_enabled = (tp->t_flags & TF_SACK_PERMIT) != 0; - 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; + pn = malloc(sizeof(struct pkt_node), M_SIFTR_PKTNODE, M_NOWAIT|M_ZERO); - /* We've finished accessing the tcb so release the lock. */ - if (inp_locally_locked) - INP_RUNLOCK(inp); + if (pn == NULL) { + if (dir == PFIL_IN) + ss->nskip_in_malloc++; + else + ss->nskip_out_malloc++; - /* These are safe to access without the inp lock. */ - pkt_node->ipver = INP_IPV4; - pkt_node->direction = dir; + goto inp_unlock; + } - /* - * 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)); + siftr_siftdata(pn, inp, tp, INP_IPV4, dir, inp_locally_locked); if (siftr_generate_hashes) { if ((*m)->m_pkthdr.csum_flags & CSUM_TCP) { @@ -950,11 +967,11 @@ siftr_chkpkt(void *arg, struct mbuf **m, * find a way to create the hash and checksum in the same pass * over the bytes. */ - pkt_node->hash = hash_pkt(*m, ip_hl); + pn->hash = hash_pkt(*m, ip_hl); } mtx_lock(&siftr_pkt_queue_mtx); - STAILQ_INSERT_TAIL(&pkt_queue, pkt_node, nodes); + STAILQ_INSERT_TAIL(&pkt_queue, pn, nodes); mtx_unlock(&siftr_pkt_queue_mtx); goto ret; @@ -973,13 +990,13 @@ static int siftr_chkpkt6(void *arg, struct mbuf **m, struct ifnet *ifp, int dir, struct inpcb *inp) { - struct pkt_node *pkt_node; + struct pkt_node *pn; struct ip6_hdr *ip6; struct tcphdr *th; struct tcpcb *tp; struct siftr_stats *ss; unsigned int ip6_hl; - uint8_t inp_locally_locked; + int inp_locally_locked; inp_locally_locked = 0; ss = DPCPU_PTR(ss); @@ -1037,18 +1054,6 @@ siftr_chkpkt6(void *arg, struct mbuf **m inp_locally_locked = 1; } - pkt_node = malloc(sizeof(struct pkt_node), M_SIFTR_PKTNODE, - M_NOWAIT | M_ZERO); - - if (pkt_node == NULL) { - if (dir == PFIL_IN) - ss->nskip_in_malloc++; - else - ss->nskip_out_malloc++; - - goto inp_unlock6; - } - /* Find the TCP control block that corresponds with this packet. */ tp = intotcpcb(inp); @@ -1063,59 +1068,26 @@ siftr_chkpkt6(void *arg, struct mbuf **m else ss->nskip_out_tcpcb++; - free(pkt_node, M_SIFTR_PKTNODE); goto inp_unlock6; } - /* Fill in pkt_node data. */ - pkt_node->ip_laddr[0] = inp->in6p_laddr.s6_addr32[0]; - pkt_node->ip_laddr[1] = inp->in6p_laddr.s6_addr32[1]; - pkt_node->ip_laddr[2] = inp->in6p_laddr.s6_addr32[2]; - pkt_node->ip_laddr[3] = inp->in6p_laddr.s6_addr32[3]; - pkt_node->ip_faddr[0] = inp->in6p_faddr.s6_addr32[0]; - pkt_node->ip_faddr[1] = inp->in6p_faddr.s6_addr32[1]; - pkt_node->ip_faddr[2] = inp->in6p_faddr.s6_addr32[2]; - pkt_node->ip_faddr[3] = inp->in6p_faddr.s6_addr32[3]; - 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; - pkt_node->sack_enabled = (tp->t_flags & TF_SACK_PERMIT) != 0; - 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; + pn = malloc(sizeof(struct pkt_node), M_SIFTR_PKTNODE, M_NOWAIT|M_ZERO); - /* We've finished accessing the tcb so release the lock. */ - if (inp_locally_locked) - INP_RUNLOCK(inp); + if (pn == NULL) { + if (dir == PFIL_IN) + ss->nskip_in_malloc++; + else + ss->nskip_out_malloc++; - /* These are safe to access without the inp lock. */ - pkt_node->ipver = INP_IPV6; - pkt_node->direction = dir; + goto inp_unlock6; + } - /* - * 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)); + siftr_siftdata(pn, inp, tp, INP_IPV6, dir, inp_locally_locked); - /* XXX: Figure out how to do hash calcs for IPv6 */ + /* XXX: Figure out how to generate hashes for IPv6 packets. */ mtx_lock(&siftr_pkt_queue_mtx); - STAILQ_INSERT_TAIL(&pkt_queue, pkt_node, nodes); + STAILQ_INSERT_TAIL(&pkt_queue, pn, nodes); mtx_unlock(&siftr_pkt_queue_mtx); goto ret6; From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 10:21:46 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3389106564A; Sat, 6 Nov 2010 10:21:46 +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 D00B78FC1D; Sat, 6 Nov 2010 10:21: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 oA6ALkYZ026689; Sat, 6 Nov 2010 10:21:46 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6ALk7x026686; Sat, 6 Nov 2010 10:21:46 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061021.oA6ALk7x026686@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 10:21:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214864 - in stable/8: share/man/man4 sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 10:21:47 -0000 Author: lstewart Date: Sat Nov 6 10:21:46 2010 New Revision: 214864 URL: http://svn.freebsd.org/changeset/base/214864 Log: MFC r213162: Log the number of segments currently in the reassembly queue. Sponsored by: FreeBSD Foundation Modified: stable/8/share/man/man4/siftr.4 stable/8/sys/netinet/siftr.c Directory Properties: stable/8/share/man/ (props changed) stable/8/share/man/man1/ (props changed) stable/8/share/man/man3/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man8/ (props changed) stable/8/share/man/man9/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/share/man/man4/siftr.4 ============================================================================== --- stable/8/share/man/man4/siftr.4 Sat Nov 6 10:17:43 2010 (r214863) +++ stable/8/share/man/man4/siftr.4 Sat Nov 6 10:21:46 2010 (r214864) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 23, 2010 +.Dd September 25, 2010 .Dt SIFTR 4 .Os .Sh NAME @@ -198,7 +198,7 @@ The data is CSV formatted. .Bd -literal -offset indent o,0xbec491a5,1238556193.463551,172.16.7.28,22,172.16.2.5,55931, \\ 1073725440,172312,6144,66560,66608,8,1,4,1448,936,1,996,255, \\ -33304,208,66608,0,208 +33304,208,66608,0,208,0 .Ed .Pp Field descriptions are as follows: @@ -328,6 +328,10 @@ The current number of bytes in the socke The current number of unacknowledged bytes in-flight. Bytes acknowledged via SACK are not excluded from this count. .El +.Bl -tag -offset indent +.It Va 26 +The current number of segments in the reassembly queue. +.El .Pp The third type of log message is written to the file when the module is disabled and ceases collecting data from the running kernel. Modified: stable/8/sys/netinet/siftr.c ============================================================================== --- stable/8/sys/netinet/siftr.c Sat Nov 6 10:17:43 2010 (r214863) +++ stable/8/sys/netinet/siftr.c Sat Nov 6 10:21:46 2010 (r214864) @@ -55,7 +55,7 @@ * SIFTR should be directed to him via email: lastewart@swin.edu.au * * Initial release date: June 2007 - * Most recent update: June 2010 + * Most recent update: September 2010 ******************************************************/ #include @@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$"); */ #define V_MAJOR 1 #define V_BACKBREAK 2 -#define V_BACKCOMPAT 3 +#define V_BACKCOMPAT 4 #define MODVERSION __CONCAT(V_MAJOR, __CONCAT(V_BACKBREAK, V_BACKCOMPAT)) #define MODVERSION_STR __XSTRING(V_MAJOR) "." __XSTRING(V_BACKBREAK) "." \ __XSTRING(V_BACKCOMPAT) @@ -226,6 +226,8 @@ struct pkt_node { u_int rcv_buf_cc; /* Number of bytes inflight that we are waiting on ACKs for. */ u_int sent_inflight_bytes; + /* Number of segments currently in the reassembly queue. */ + int t_segqlen; /* Link to next pkt_node in the list. */ STAILQ_ENTRY(pkt_node) nodes; }; @@ -442,7 +444,7 @@ siftr_process_pkt(struct pkt_node * pkt_ MAX_LOG_MSG_LEN, "%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", + "%u,%d,%u,%u,%u,%u,%u,%u\n", direction[pkt_node->direction], pkt_node->hash, pkt_node->tval.tv_sec, @@ -482,7 +484,8 @@ siftr_process_pkt(struct pkt_node * pkt_ pkt_node->snd_buf_cc, pkt_node->rcv_buf_hiwater, pkt_node->rcv_buf_cc, - pkt_node->sent_inflight_bytes); + pkt_node->sent_inflight_bytes, + pkt_node->t_segqlen); } 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]); @@ -498,7 +501,7 @@ siftr_process_pkt(struct pkt_node * pkt_ log_buf->ae_bytesused = snprintf(log_buf->ae_data, MAX_LOG_MSG_LEN, "%c,0x%08x,%jd.%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", + "%ld,%ld,%ld,%u,%u,%u,%u,%u,%u,%u,%d,%u,%u,%u,%u,%u,%u\n", direction[pkt_node->direction], pkt_node->hash, (intmax_t)pkt_node->tval.tv_sec, @@ -530,7 +533,8 @@ siftr_process_pkt(struct pkt_node * pkt_ pkt_node->snd_buf_cc, pkt_node->rcv_buf_hiwater, pkt_node->rcv_buf_cc, - pkt_node->sent_inflight_bytes); + pkt_node->sent_inflight_bytes, + pkt_node->t_segqlen); #ifdef SIFTR_IPV6 } #endif @@ -790,6 +794,7 @@ siftr_siftdata(struct pkt_node *pn, stru pn->rcv_buf_hiwater = inp->inp_socket->so_rcv.sb_hiwat; pn->rcv_buf_cc = inp->inp_socket->so_rcv.sb_cc; pn->sent_inflight_bytes = tp->snd_max - tp->snd_una; + pn->t_segqlen = tp->t_segqlen; /* We've finished accessing the tcb so release the lock. */ if (inp_locally_locked) From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 10:26:49 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5743106567A; Sat, 6 Nov 2010 10:26:49 +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 A2A158FC15; Sat, 6 Nov 2010 10:26:49 +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 oA6AQn4O027792; Sat, 6 Nov 2010 10:26:49 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6AQnW4027790; Sat, 6 Nov 2010 10:26:49 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061026.oA6AQnW4027790@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 10:26:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214865 - stable/8/sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 10:26:49 -0000 Author: lstewart Date: Sat Nov 6 10:26:49 2010 New Revision: 214865 URL: http://svn.freebsd.org/changeset/base/214865 Log: MFC r213912: - Switch the "net.inet.tcp.reass.cursegments" and "net.inet.tcp.reass.maxsegments" sysctl variables to be based on UMA zone stats. The value returned by the cursegments sysctl is approximate owing to the way in which uma_zone_get_cur is implemented. - Discontinue use of V_tcp_reass_qsize as a global reassembly segment count variable in the reassembly implementation. The variable was used without proper synchronisation and was duplicating accounting done by UMA already. The lack of synchronisation was particularly problematic on SMP systems terminating many TCP sessions, resulting in poor TCP performance for connections with non-zero packet loss. Sponsored by: FreeBSD Foundation Reviewed by: andre, gnn, rpaulo (as part of a larger patch) Modified: stable/8/sys/netinet/tcp_reass.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/tcp_reass.c ============================================================================== --- stable/8/sys/netinet/tcp_reass.c Sat Nov 6 10:21:46 2010 (r214864) +++ stable/8/sys/netinet/tcp_reass.c Sat Nov 6 10:26:49 2010 (r214865) @@ -74,19 +74,22 @@ __FBSDID("$FreeBSD$"); #include #endif /* TCPDEBUG */ +static int tcp_reass_sysctl_maxseg(SYSCTL_HANDLER_ARGS); +static int tcp_reass_sysctl_qsize(SYSCTL_HANDLER_ARGS); + SYSCTL_NODE(_net_inet_tcp, OID_AUTO, reass, CTLFLAG_RW, 0, "TCP Segment Reassembly Queue"); static VNET_DEFINE(int, tcp_reass_maxseg) = 0; #define V_tcp_reass_maxseg VNET(tcp_reass_maxseg) -SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, maxsegments, CTLFLAG_RDTUN, - &VNET_NAME(tcp_reass_maxseg), 0, +SYSCTL_VNET_PROC(_net_inet_tcp_reass, OID_AUTO, maxsegments, CTLFLAG_RDTUN, + &VNET_NAME(tcp_reass_maxseg), 0, &tcp_reass_sysctl_maxseg, "I", "Global maximum number of TCP Segments in Reassembly Queue"); static VNET_DEFINE(int, tcp_reass_qsize) = 0; #define V_tcp_reass_qsize VNET(tcp_reass_qsize) -SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, cursegments, CTLFLAG_RD, - &VNET_NAME(tcp_reass_qsize), 0, +SYSCTL_VNET_PROC(_net_inet_tcp_reass, OID_AUTO, cursegments, CTLFLAG_RD, + &VNET_NAME(tcp_reass_qsize), 0, &tcp_reass_sysctl_qsize, "I", "Global number of TCP Segments currently in Reassembly Queue"); static VNET_DEFINE(int, tcp_reass_maxqlen) = 48; @@ -148,7 +151,6 @@ tcp_reass_flush(struct tcpcb *tp) m_freem(qe->tqe_m); uma_zfree(V_tcp_reass_zone, qe); tp->t_segqlen--; - V_tcp_reass_qsize--; } KASSERT((tp->t_segqlen == 0), @@ -156,6 +158,20 @@ tcp_reass_flush(struct tcpcb *tp) tp, tp->t_segqlen)); } +static int +tcp_reass_sysctl_maxseg(SYSCTL_HANDLER_ARGS) +{ + V_tcp_reass_maxseg = uma_zone_get_max(V_tcp_reass_zone); + return (sysctl_handle_int(oidp, arg1, arg2, req)); +} + +static int +tcp_reass_sysctl_qsize(SYSCTL_HANDLER_ARGS) +{ + V_tcp_reass_qsize = uma_zone_get_cur(V_tcp_reass_zone); + return (sysctl_handle_int(oidp, arg1, arg2, req)); +} + int tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) { @@ -184,12 +200,10 @@ tcp_reass(struct tcpcb *tp, struct tcphd * Limit the number of segments in the reassembly queue to prevent * holding on to too many segments (and thus running out of mbufs). * Make sure to let the missing segment through which caused this - * queue. Always keep one global queue entry spare to be able to - * process the missing segment. + * queue. */ if (th->th_seq != tp->rcv_nxt && - (V_tcp_reass_qsize + 1 >= V_tcp_reass_maxseg || - tp->t_segqlen >= V_tcp_reass_maxqlen)) { + tp->t_segqlen >= V_tcp_reass_maxqlen) { V_tcp_reass_overflows++; TCPSTAT_INC(tcps_rcvmemdrop); m_freem(m); @@ -209,7 +223,6 @@ tcp_reass(struct tcpcb *tp, struct tcphd return (0); } tp->t_segqlen++; - V_tcp_reass_qsize++; /* * Find a segment which begins after this one does. @@ -236,7 +249,6 @@ tcp_reass(struct tcpcb *tp, struct tcphd m_freem(m); uma_zfree(V_tcp_reass_zone, te); tp->t_segqlen--; - V_tcp_reass_qsize--; /* * Try to present any queued data * at the left window edge to the user. @@ -273,7 +285,6 @@ tcp_reass(struct tcpcb *tp, struct tcphd m_freem(q->tqe_m); uma_zfree(V_tcp_reass_zone, q); tp->t_segqlen--; - V_tcp_reass_qsize--; q = nq; } @@ -310,7 +321,6 @@ present: sbappendstream_locked(&so->so_rcv, q->tqe_m); uma_zfree(V_tcp_reass_zone, q); tp->t_segqlen--; - V_tcp_reass_qsize--; q = nq; } while (q && q->tqe_th->th_seq == tp->rcv_nxt); ND6_HINT(tp); From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 10:31:52 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DFCE106566B; Sat, 6 Nov 2010 10:31:52 +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 6B4FE8FC17; Sat, 6 Nov 2010 10:31:52 +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 oA6AVqRa027939; Sat, 6 Nov 2010 10:31:52 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6AVqPr027937; Sat, 6 Nov 2010 10:31:52 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061031.oA6AVqPr027937@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 10:31:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214866 - stable/8/sys/netinet X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 10:31:52 -0000 Author: lstewart Date: Sat Nov 6 10:31:52 2010 New Revision: 214866 URL: http://svn.freebsd.org/changeset/base/214866 Log: MFC r213913: Retire the system-wide, per-reassembly queue segment limit. The mechanism is far too coarse grained to be useful and the default value significantly degrades TCP performance on moderate to high bandwidth-delay product paths with non-zero loss (e.g. 5+Mbps connections across the public Internet often suffer). Replace the outgoing mechanism with an individual per-queue limit based on the number of MSS segments that fit into the socket's receive buffer. This should strike a good balance between performance and the potential for resource exhaustion when FreeBSD is acting as a TCP receiver. With socket buffer autotuning (which is enabled by default), the reassembly queue tracks the socket buffer and benefits too. As the XXX comment suggests, my testing uncovered some unexpected behaviour which requires further investigation. By using so->so_rcv.sb_hiwat instead of sbspace(&so->so_rcv), we allow more segments to be held across both the socket receive buffer and reassembly queue than we probably should. The tradeoff is better performance in at least one common scenario, versus a devious sender's ability to consume more resources on a FreeBSD receiver. Sponsored by: FreeBSD Foundation Reviewed by: andre, gnn, rpaulo Modified: stable/8/sys/netinet/tcp_reass.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/tcp_reass.c ============================================================================== --- stable/8/sys/netinet/tcp_reass.c Sat Nov 6 10:26:49 2010 (r214865) +++ stable/8/sys/netinet/tcp_reass.c Sat Nov 6 10:31:52 2010 (r214866) @@ -92,12 +92,6 @@ SYSCTL_VNET_PROC(_net_inet_tcp_reass, OI &VNET_NAME(tcp_reass_qsize), 0, &tcp_reass_sysctl_qsize, "I", "Global number of TCP Segments currently in Reassembly Queue"); -static VNET_DEFINE(int, tcp_reass_maxqlen) = 48; -#define V_tcp_reass_maxqlen VNET(tcp_reass_maxqlen) -SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, maxqlen, CTLFLAG_RW, - &VNET_NAME(tcp_reass_maxqlen), 0, - "Maximum number of TCP Segments per individual Reassembly Queue"); - static VNET_DEFINE(int, tcp_reass_overflows) = 0; #define V_tcp_reass_overflows VNET(tcp_reass_overflows) SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, overflows, CTLFLAG_RD, @@ -197,13 +191,23 @@ tcp_reass(struct tcpcb *tp, struct tcphd goto present; /* - * Limit the number of segments in the reassembly queue to prevent - * holding on to too many segments (and thus running out of mbufs). - * Make sure to let the missing segment through which caused this - * queue. + * Limit the number of segments that can be queued to reduce the + * potential for mbuf exhaustion. For best performance, we want to be + * able to queue a full window's worth of segments. The size of the + * socket receive buffer determines our advertised window and grows + * automatically when socket buffer autotuning is enabled. Use it as the + * basis for our queue limit. + * Always let the missing segment through which caused this queue. + * NB: Access to the socket buffer is left intentionally unlocked as we + * can tolerate stale information here. + * + * XXXLAS: Using sbspace(so->so_rcv) instead of so->so_rcv.sb_hiwat + * should work but causes packets to be dropped when they shouldn't. + * Investigate why and re-evaluate the below limit after the behaviour + * is understood. */ if (th->th_seq != tp->rcv_nxt && - tp->t_segqlen >= V_tcp_reass_maxqlen) { + tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) { V_tcp_reass_overflows++; TCPSTAT_INC(tcps_rcvmemdrop); m_freem(m); From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 14:46:24 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1639106564A; Sat, 6 Nov 2010 14:46:24 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8EB5A8FC0A; Sat, 6 Nov 2010 14:46:24 +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 oA6EkOoX034370; Sat, 6 Nov 2010 14:46:24 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6EkOV9034364; Sat, 6 Nov 2010 14:46:24 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201011061446.oA6EkOV9034364@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 6 Nov 2010 14:46:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214882 - in stable/8/sys: netinet netinet6 netipsec X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 14:46:24 -0000 Author: bz Date: Sat Nov 6 14:46:24 2010 New Revision: 214882 URL: http://svn.freebsd.org/changeset/base/214882 Log: MFC r214250: Make the IPsec SADB embedded route cache a union to be able to hold both the legacy and IPv6 route destination address. Previously in case of IPv6, there was a memory overwrite due to not enough space for the IPv6 address. PR: kern/122565 Modified: stable/8/sys/netinet/ip_ipsec.c stable/8/sys/netinet6/ip6_ipsec.c stable/8/sys/netipsec/ipsec_output.c stable/8/sys/netipsec/key.c stable/8/sys/netipsec/keydb.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/ip_ipsec.c ============================================================================== --- stable/8/sys/netinet/ip_ipsec.c Sat Nov 6 14:38:57 2010 (r214881) +++ stable/8/sys/netinet/ip_ipsec.c Sat Nov 6 14:46:24 2010 (r214882) @@ -239,7 +239,7 @@ ip_ipsec_mtu(struct mbuf *m, int mtu) if (sp->req != NULL && sp->req->sav != NULL && sp->req->sav->sah != NULL) { - ro = &sp->req->sav->sah->sa_route; + ro = &sp->req->sav->sah->route_cache.sa_route; if (ro->ro_rt && ro->ro_rt->rt_ifp) { mtu = ro->ro_rt->rt_rmx.rmx_mtu ? Modified: stable/8/sys/netinet6/ip6_ipsec.c ============================================================================== --- stable/8/sys/netinet6/ip6_ipsec.c Sat Nov 6 14:38:57 2010 (r214881) +++ stable/8/sys/netinet6/ip6_ipsec.c Sat Nov 6 14:46:24 2010 (r214882) @@ -366,7 +366,7 @@ ip6_ipsec_mtu(struct mbuf *m) if (sp->req != NULL && sp->req->sav != NULL && sp->req->sav->sah != NULL) { - ro = &sp->req->sav->sah->sa_route; + ro = &sp->req->sav->sah->route_cache.sa_route; if (ro->ro_rt && ro->ro_rt->rt_ifp) { mtu = ro->ro_rt->rt_rmx.rmx_mtu ? Modified: stable/8/sys/netipsec/ipsec_output.c ============================================================================== --- stable/8/sys/netipsec/ipsec_output.c Sat Nov 6 14:38:57 2010 (r214881) +++ stable/8/sys/netipsec/ipsec_output.c Sat Nov 6 14:46:24 2010 (r214882) @@ -829,7 +829,8 @@ ipsec6_output_tunnel(struct ipsec_output } ip6 = mtod(m, struct ip6_hdr *); - state->ro = &isr->sav->sah->sa_route; + state->ro = + (struct route *)&isr->sav->sah->route_cache.sin6_route; state->dst = (struct sockaddr *)&state->ro->ro_dst; dst6 = (struct sockaddr_in6 *)state->dst; if (state->ro->ro_rt Modified: stable/8/sys/netipsec/key.c ============================================================================== --- stable/8/sys/netipsec/key.c Sat Nov 6 14:38:57 2010 (r214881) +++ stable/8/sys/netipsec/key.c Sat Nov 6 14:46:24 2010 (r214882) @@ -2767,9 +2767,9 @@ key_delsah(sah) /* remove from tree of SA index */ if (__LIST_CHAINED(sah)) LIST_REMOVE(sah, chain); - if (sah->sa_route.ro_rt) { - RTFREE(sah->sa_route.ro_rt); - sah->sa_route.ro_rt = (struct rtentry *)NULL; + if (sah->route_cache.sa_route.ro_rt) { + RTFREE(sah->route_cache.sa_route.ro_rt); + sah->route_cache.sa_route.ro_rt = (struct rtentry *)NULL; } free(sah, M_IPSEC_SAH); } @@ -7933,7 +7933,7 @@ key_sa_routechange(dst) SAHTREE_LOCK(); LIST_FOREACH(sah, &V_sahtree, chain) { - ro = &sah->sa_route; + ro = &sah->route_cache.sa_route; if (ro->ro_rt && dst->sa_len == ro->ro_dst.sa_len && bcmp(dst, &ro->ro_dst, dst->sa_len) == 0) { RTFREE(ro->ro_rt); Modified: stable/8/sys/netipsec/keydb.h ============================================================================== --- stable/8/sys/netipsec/keydb.h Sat Nov 6 14:38:57 2010 (r214881) +++ stable/8/sys/netipsec/keydb.h Sat Nov 6 14:46:24 2010 (r214882) @@ -85,6 +85,12 @@ struct seclifetime { u_int64_t usetime; }; +union sa_route_union { + struct route sa_route; + struct route sin_route; /* Duplicate for consistency. */ + struct route_in6 sin6_route; +}; + /* Security Association Data Base */ struct secashead { LIST_ENTRY(secashead) chain; @@ -100,7 +106,7 @@ struct secashead { /* SA chain */ /* The first of this list is newer SA */ - struct route sa_route; /* route cache */ + union sa_route_union route_cache; }; struct xformsw; From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 16:09:25 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AED15106564A; Sat, 6 Nov 2010 16:09:25 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C9948FC13; Sat, 6 Nov 2010 16:09:25 +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 oA6G9PXs036595; Sat, 6 Nov 2010 16:09:25 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6G9PIC036593; Sat, 6 Nov 2010 16:09:25 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201011061609.oA6G9PIC036593@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 6 Nov 2010 16:09:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214892 - stable/8/release/powerpc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 16:09:25 -0000 Author: marcel Date: Sat Nov 6 16:09:25 2010 New Revision: 214892 URL: http://svn.freebsd.org/changeset/base/214892 Log: MFC 213381: Replace an obsolete flag -L in an mkisofs(1) command line with -allow-leading-dots to fix "make release" for FreeBSD/powerpc. Author: hrs Modified: stable/8/release/powerpc/mkisoimages.sh Directory Properties: stable/8/release/powerpc/ (props changed) Modified: stable/8/release/powerpc/mkisoimages.sh ============================================================================== --- stable/8/release/powerpc/mkisoimages.sh Sat Nov 6 15:56:44 2010 (r214891) +++ stable/8/release/powerpc/mkisoimages.sh Sat Nov 6 16:09:25 2010 (r214892) @@ -54,4 +54,4 @@ fi LABEL=$1; shift NAME=$1; shift -mkisofs $bootable -r -hfs -part -no-desktop -hfs-volid $LABEL -l -J -L -o $NAME $* +mkisofs $bootable -r -hfs -part -no-desktop -hfs-volid $LABEL -l -J -allow-leading-dots -o $NAME $* From owner-svn-src-stable-8@FreeBSD.ORG Sat Nov 6 21:04:02 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77880106566B; Sat, 6 Nov 2010 21:04:02 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 649A78FC12; Sat, 6 Nov 2010 21:04:02 +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 oA6L42Gt048979; Sat, 6 Nov 2010 21:04:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6L42q7048976; Sat, 6 Nov 2010 21:04:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201011062104.oA6L42q7048976@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 6 Nov 2010 21:04:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214897 - stable/8/etc/periodic/security X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 21:04:02 -0000 Author: gabor Date: Sat Nov 6 21:04:01 2010 New Revision: 214897 URL: http://svn.freebsd.org/changeset/base/214897 Log: MFC r210254: - Add a periodic script, which can be used to find installed ports' files with mismatched checksum MFC r211141 - Fixes to the chkportsum script to handle better some special cases, like spaces in filename Approved by: delphij (mentor) Added: - copied unchanged from r214895, head/etc/periodic/security/460.chkportsum Directory Properties: stable/8/etc/periodic/security/460.chkportsum (props changed) Modified: stable/8/etc/periodic/security/Makefile Copied: stable/8/etc/periodic/security/460.chkportsum (from r214895, head/etc/periodic/security/460.chkportsum) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/etc/periodic/security/460.chkportsum Sat Nov 6 21:04:01 2010 (r214897, copy of r214895, head/etc/periodic/security/460.chkportsum) @@ -0,0 +1,68 @@ +#!/bin/sh - +# +# Copyright (c) 2010 The FreeBSD Project +# 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$ +# + +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +. /etc/periodic/security/security.functions + +rc=0 + +echo "" +echo 'Checking for ports with mismatched checksums:' + +case "${daily_status_security_chkportsum_enable}" in + [Yy][Ee][Ss]) + set -f + pkg_info -ga 2>/dev/null | \ + while IFS= read -r line; do + set -- $line + case $1 in + Information) + case $2 in + for) name="${3%%:}" ;; + *) name='??' ;; + esac + ;; + Mismatched|'') ;; + *) [ -n "${name}" ] && + echo "${name}: ${line%% fails the original MD5 checksum}" + ;; + esac + done + ;; + *) + rc=0 + ;; +esac + +exit $rc Modified: stable/8/etc/periodic/security/Makefile ============================================================================== --- stable/8/etc/periodic/security/Makefile Sat Nov 6 19:11:49 2010 (r214896) +++ stable/8/etc/periodic/security/Makefile Sat Nov 6 21:04:01 2010 (r214897) @@ -6,6 +6,7 @@ FILES= 100.chksetuid \ 200.chkmounts \ 300.chkuid0 \ 400.passwdless \ + 460.chkportsum \ 410.logincheck \ 700.kernelmsg \ 800.loginfail \