From owner-svn-src-stable-8@FreeBSD.ORG Sun Jun 26 07:12:49 2011 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 8FCA0106564A; Sun, 26 Jun 2011 07:12:49 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F4E38FC0C; Sun, 26 Jun 2011 07:12:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5Q7Cni5040531; Sun, 26 Jun 2011 07:12:49 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5Q7CnRu040529; Sun, 26 Jun 2011 07:12:49 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201106260712.p5Q7CnRu040529@svn.freebsd.org> From: Xin LI Date: Sun, 26 Jun 2011 07:12: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: r223560 - stable/8/sys/dev/safe 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, 26 Jun 2011 07:12:49 -0000 Author: delphij Date: Sun Jun 26 07:12:48 2011 New Revision: 223560 URL: http://svn.freebsd.org/changeset/base/223560 Log: Use swap32() right. Submitted by: gcopper Modified: stable/8/sys/dev/safe/safe.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) Modified: stable/8/sys/dev/safe/safe.c ============================================================================== --- stable/8/sys/dev/safe/safe.c Sun Jun 26 04:00:49 2011 (r223559) +++ stable/8/sys/dev/safe/safe.c Sun Jun 26 07:12:48 2011 (r223560) @@ -1580,9 +1580,12 @@ safe_callback(struct safe_softc *sc, str * SHA-1 ICV's are byte-swapped; fix 'em up * before copy them to their destination. */ - bswap32(re->re_sastate.sa_saved_indigest[0]); - bswap32(re->re_sastate.sa_saved_indigest[1]); - bswap32(re->re_sastate.sa_saved_indigest[2]); + re->re_sastate.sa_saved_indigest[0] = + bswap32(re->re_sastate.sa_saved_indigest[0]); + re->re_sastate.sa_saved_indigest[1] = + bswap32(re->re_sastate.sa_saved_indigest[1]); + re->re_sastate.sa_saved_indigest[2] = + bswap32(re->re_sastate.sa_saved_indigest[2]); } crypto_copyback(crp->crp_flags, crp->crp_buf, crd->crd_inject, From owner-svn-src-stable-8@FreeBSD.ORG Sun Jun 26 10:50:11 2011 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 9E8AF106566C; Sun, 26 Jun 2011 10:50:11 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 839B68FC16; Sun, 26 Jun 2011 10:50:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5QAoBON049945; Sun, 26 Jun 2011 10:50:11 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5QAoBDh049942; Sun, 26 Jun 2011 10:50:11 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201106261050.p5QAoBDh049942@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 26 Jun 2011 10:50: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: r223565 - stable/8/lib/libc/gen 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, 26 Jun 2011 10:50:11 -0000 Author: jilles Date: Sun Jun 26 10:50:11 2011 New Revision: 223565 URL: http://svn.freebsd.org/changeset/base/223565 Log: MFC r222511,r223206: posix_spawn(): Do not fail when trying to close an fd that is not open. As noted in Austin Group issue #370 (an interpretation has been issued), failing posix_spawn() because an fd specified with posix_spawn_file_actions_addclose() is not open is unnecessarily harsh, and there are existing implementations that do not fail posix_spawn() for this reason. Modified: stable/8/lib/libc/gen/posix_spawn.3 stable/8/lib/libc/gen/posix_spawn.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/gen/posix_spawn.3 ============================================================================== --- stable/8/lib/libc/gen/posix_spawn.3 Sun Jun 26 10:34:01 2011 (r223564) +++ stable/8/lib/libc/gen/posix_spawn.3 Sun Jun 26 10:50:11 2011 (r223565) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Mar 24, 2008 +.Dd June 17, 2011 .Dt POSIX_SPAWN 3 .Os .Sh NAME @@ -384,29 +384,28 @@ the child process exits with exit status .It If the .Fa file_actions -argument is not NULL, and specifies any close, dup2, or open actions to be +argument is not NULL, and specifies any dup2 or open actions to be performed, and if .Fn posix_spawn or .Fn posix_spawnp fails for any of the reasons that would cause -.Fn close , -.Fn dup2 , +.Fn dup2 or .Fn open to fail, an error value is returned as described by -.Fn close , -.Fn dup2 , +.Fn dup2 and .Fn open , respectively (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). An open file action may, by itself, result in any of the errors described by -.Fn close -or .Fn dup2 , in addition to those described by .Fn open . +This implementation ignores any errors from +.Fn close , +including trying to close a descriptor that is not open. .El .Sh SEE ALSO .Xr close 2 , @@ -443,7 +442,13 @@ The and .Fn posix_spawnp functions conform to -.St -p1003.1-2001 . +.St -p1003.1-2001 , +except that they ignore all errors from +.Fn close . +A future update of the Standard is expected to require that these functions +not fail because a file descriptor to be closed (via +.Fn posix_spawn_file_actions_addclose ) +is not open. .Sh HISTORY The .Fn posix_spawn Modified: stable/8/lib/libc/gen/posix_spawn.c ============================================================================== --- stable/8/lib/libc/gen/posix_spawn.c Sun Jun 26 10:34:01 2011 (r223564) +++ stable/8/lib/libc/gen/posix_spawn.c Sun Jun 26 10:50:11 2011 (r223565) @@ -163,11 +163,8 @@ process_file_actions_entry(posix_spawn_f return (errno); break; case FAE_CLOSE: - /* Perform a close() */ - if (_close(fae->fae_fildes) != 0) { - if (errno == EBADF) - return (EBADF); - } + /* Perform a close(), do not fail if already closed */ + (void)_close(fae->fae_fildes); break; } return (0); From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 11:10:15 2011 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 8C990106566C; Mon, 27 Jun 2011 11:10:15 +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 7C4F28FC1D; Mon, 27 Jun 2011 11:10:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RBAFOD095118; Mon, 27 Jun 2011 11:10:15 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RBAFq2095115; Mon, 27 Jun 2011 11:10:15 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201106271110.p5RBAFq2095115@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Mon, 27 Jun 2011 11:10: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: r223588 - 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: Mon, 27 Jun 2011 11:10:15 -0000 Author: bz Date: Mon Jun 27 11:10:15 2011 New Revision: 223588 URL: http://svn.freebsd.org/changeset/base/223588 Log: MFC r223223: gre(4) was using a field in the softc to detect possible recursion. On MP systems this is not a usable solution anymore and could easily lead to false positives triggering enough logging that even using the console was no longer usable (multiple parallel ping -f can do). Switch to the suggested solution of using mbuf tags to carry per packet state between gre_output() invocations. Contrary to the proposed solution modelled after gif(4) only allocate one mbuf tag per packet rather than per packet and per gre_output() pass through. As the sysctl to control the possible valid (gre in gre) nestings does no sanity checks, make sure to always allocate space in the mbuf tag for at least one, and at most 255 possible gre interfaces to detect loops in addition to the counter. Submitted by: Cristian KLEIN (cristi net.utcluj.ro) (original version) PR: kern/114714 Reviewed by: Cristian KLEIN (cristi net.utcluj.ro) Reviewed bu: Wooseog Choi (ben_choi hotmail.com) Sponsored by: Sandvine Incorporated Modified: stable/8/sys/net/if_gre.c stable/8/sys/net/if_gre.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) Modified: stable/8/sys/net/if_gre.c ============================================================================== --- stable/8/sys/net/if_gre.c Mon Jun 27 10:42:06 2011 (r223587) +++ stable/8/sys/net/if_gre.c Mon Jun 27 11:10:15 2011 (r223588) @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,14 @@ #define GRENAME "gre" +#define MTAG_COOKIE_GRE 1307983903 +#define MTAG_GRE_NESTING 1 +struct mtag_gre_nesting { + uint16_t count; + uint16_t max; + struct ifnet *ifp[]; +}; + /* * gre_mtx protects all global variables in if_gre.c. * XXX: gre_softc data not protected yet. @@ -203,7 +212,6 @@ gre_clone_create(ifc, unit, params) sc->g_proto = IPPROTO_GRE; GRE2IFP(sc)->if_flags |= IFF_LINK0; sc->encap = NULL; - sc->called = 0; sc->gre_fibnum = curthread->td_proc->p_fibnum; sc->wccp_ver = WCCP_V1; sc->key = 0; @@ -247,23 +255,77 @@ gre_output(struct ifnet *ifp, struct mbu struct gre_softc *sc = ifp->if_softc; struct greip *gh; struct ip *ip; + struct m_tag *mtag; + struct mtag_gre_nesting *gt; + size_t len; u_short gre_ip_id = 0; uint8_t gre_ip_tos = 0; u_int16_t etype = 0; struct mobile_h mob_h; u_int32_t af; - int extra = 0; + int extra = 0, max; /* - * gre may cause infinite recursion calls when misconfigured. - * We'll prevent this by introducing upper limit. + * gre may cause infinite recursion calls when misconfigured. High + * nesting level may cause stack exhaustion. We'll prevent this by + * detecting loops and by introducing upper limit. */ - if (++(sc->called) > max_gre_nesting) { - printf("%s: gre_output: recursively called too many " - "times(%d)\n", if_name(GRE2IFP(sc)), sc->called); - m_freem(m); - error = EIO; /* is there better errno? */ - goto end; + mtag = m_tag_locate(m, MTAG_COOKIE_GRE, MTAG_GRE_NESTING, NULL); + if (mtag != NULL) { + struct ifnet **ifp2; + + gt = (struct mtag_gre_nesting *)(mtag + 1); + gt->count++; + if (gt->count > min(gt->max,max_gre_nesting)) { + printf("%s: hit maximum recursion limit %u on %s\n", + __func__, gt->count - 1, ifp->if_xname); + m_freem(m); + error = EIO; /* is there better errno? */ + goto end; + } + + ifp2 = gt->ifp; + for (max = gt->count - 1; max > 0; max--) { + if (*ifp2 == ifp) + break; + ifp2++; + } + if (*ifp2 == ifp) { + printf("%s: detected loop with nexting %u on %s\n", + __func__, gt->count-1, ifp->if_xname); + m_freem(m); + error = EIO; /* is there better errno? */ + goto end; + } + *ifp2 = ifp; + + } else { + /* + * Given that people should NOT increase max_gre_nesting beyond + * their real needs, we allocate once per packet rather than + * allocating an mtag once per passing through gre. + * + * Note: the sysctl does not actually check for saneness, so we + * limit the maximum numbers of possible recursions here. + */ + max = imin(max_gre_nesting, 256); + /* If someone sets the sysctl <= 0, we want at least 1. */ + max = imax(max, 1); + len = sizeof(struct mtag_gre_nesting) + + max * sizeof(struct ifnet *); + mtag = m_tag_alloc(MTAG_COOKIE_GRE, MTAG_GRE_NESTING, len, + M_NOWAIT); + if (mtag == NULL) { + m_freem(m); + error = ENOMEM; + goto end; + } + gt = (struct mtag_gre_nesting *)(mtag + 1); + bzero(gt, len); + gt->count = 1; + gt->max = max; + *gt->ifp = ifp; + m_tag_prepend(m, mtag); } if (!((ifp->if_flags & IFF_UP) && @@ -451,7 +513,6 @@ gre_output(struct ifnet *ifp, struct mbu error = ip_output(m, NULL, &sc->route, IP_FORWARDING, (struct ip_moptions *)NULL, (struct inpcb *)NULL); end: - sc->called = 0; if (error) ifp->if_oerrors++; return (error); Modified: stable/8/sys/net/if_gre.h ============================================================================== --- stable/8/sys/net/if_gre.h Mon Jun 27 10:42:06 2011 (r223587) +++ stable/8/sys/net/if_gre.h Mon Jun 27 11:10:15 2011 (r223588) @@ -68,8 +68,6 @@ struct gre_softc { const struct encaptab *encap; /* encapsulation cookie */ - int called; /* infinite recursion preventer */ - uint32_t key; /* key included in outgoing GRE packets */ /* zero means none */ From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 11:13:26 2011 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 801FB1065670; Mon, 27 Jun 2011 11:13:26 +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 666158FC0C; Mon, 27 Jun 2011 11:13:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RBDQmo095314; Mon, 27 Jun 2011 11:13:26 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RBDQDf095306; Mon, 27 Jun 2011 11:13:26 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201106271113.p5RBDQDf095306@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Mon, 27 Jun 2011 11:13: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: r223590 - 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: Mon, 27 Jun 2011 11:13:26 -0000 Author: bz Date: Mon Jun 27 11:13:26 2011 New Revision: 223590 URL: http://svn.freebsd.org/changeset/base/223590 Log: MFC r223267: Add 'show logstate' to usage(). MFC r223345: Add global -d and -e options to either print device numbers (usually default) or enclosure:slot information as (Exx:Sxx) or both. Discussed with: jhb Reviewed by: jhb Sponsored by: Sandvine Incorporated Modified: stable/8/usr.sbin/mfiutil/mfi_config.c stable/8/usr.sbin/mfiutil/mfi_drive.c stable/8/usr.sbin/mfiutil/mfi_patrol.c stable/8/usr.sbin/mfiutil/mfi_show.c stable/8/usr.sbin/mfiutil/mfiutil.8 stable/8/usr.sbin/mfiutil/mfiutil.c stable/8/usr.sbin/mfiutil/mfiutil.h Directory Properties: stable/8/usr.sbin/mfiutil/ (props changed) Modified: stable/8/usr.sbin/mfiutil/mfi_config.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_config.c Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfi_config.c Mon Jun 27 11:13:26 2011 (r223590) @@ -419,8 +419,10 @@ build_array(int fd, char *arrayp, struct ar->array_ref = find_next_array(state); for (i = 0; i < array_info->drive_count; i++) { if (verbose) - printf("Adding drive %u to array %u\n", + printf("Adding drive %s to array %u\n", + mfi_drive_name(NULL, array_info->drives[i].ref.v.device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS), ar->array_ref); if (ar->size > array_info->drives[i].coerced_size) ar->size = array_info->drives[i].coerced_size; Modified: stable/8/usr.sbin/mfiutil/mfi_drive.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_drive.c Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfi_drive.c Mon Jun 27 11:13:26 2011 (r223590) @@ -45,6 +45,87 @@ MFI_TABLE(top, drive); +/* + * Print the name of a drive either by drive number as %2u or by enclosure:slot + * as Exx:Sxx (or both). Use default unless command line options override it + * and the command allows this (which we usually do unless we already print + * both). We prefer pinfo if given, otherwise try to look it up by device_id. + */ +const char * +mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id, uint32_t def) +{ + struct mfi_pd_info info; + static char buf[16]; + char *p; + int error, fd, len; + + if ((def & MFI_DNAME_HONOR_OPTS) != 0 && + (mfi_opts & (MFI_DNAME_ES|MFI_DNAME_DEVICE_ID)) != 0) + def = mfi_opts & (MFI_DNAME_ES|MFI_DNAME_DEVICE_ID); + + buf[0] = '\0'; + if (pinfo == NULL && def & MFI_DNAME_ES) { + /* Fallback in case of error, just ignore flags. */ + if (device_id == 0xffff) + snprintf(buf, sizeof(buf), "MISSING"); + else + snprintf(buf, sizeof(buf), "%2u", device_id); + + fd = mfi_open(mfi_unit); + if (fd < 0) { + warn("mfi_open"); + return (buf); + } + + /* Get the info for this drive. */ + if (mfi_pd_get_info(fd, device_id, &info, NULL) < 0) { + warn("Failed to fetch info for drive %2u", device_id); + close(fd); + return (buf); + } + + close(fd); + pinfo = &info; + } + + p = buf; + len = sizeof(buf); + if (def & MFI_DNAME_DEVICE_ID) { + if (device_id == 0xffff) + error = snprintf(p, len, "MISSING"); + else + error = snprintf(p, len, "%2u", device_id); + if (error >= 0) { + p += error; + len -= error; + } + } + if ((def & (MFI_DNAME_ES|MFI_DNAME_DEVICE_ID)) == + (MFI_DNAME_ES|MFI_DNAME_DEVICE_ID) && len >= 2) { + *p++ = ' '; + len--; + *p = '\0'; + len--; + } + if (def & MFI_DNAME_ES) { + if (pinfo->encl_device_id == 0xffff) + error = snprintf(p, len, "S%u", + pinfo->slot_number); + else if (pinfo->encl_device_id == pinfo->ref.v.device_id) + error = snprintf(p, len, "E%u", + pinfo->encl_index); + else + error = snprintf(p, len, "E%u:S%u", + pinfo->encl_index, pinfo->slot_number); + if (error >= 0) { + p += error; + len -= error; + } + } + + return (buf); +} + const char * mfi_pdstate(enum mfi_pd_state state) { @@ -547,7 +628,9 @@ drive_progress(int ac, char **av) mfi_display_progress("Clear", &info.prog_info.clear); if ((info.prog_info.active & (MFI_PD_PROGRESS_REBUILD | MFI_PD_PROGRESS_PATROL | MFI_PD_PROGRESS_CLEAR)) == 0) - printf("No activity in progress for drive %u.\n", device_id); + printf("No activity in progress for drive %s.\n", + mfi_drive_name(NULL, device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); return (0); } Modified: stable/8/usr.sbin/mfiutil/mfi_patrol.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_patrol.c Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfi_patrol.c Mon Jun 27 11:13:26 2011 (r223590) @@ -80,7 +80,7 @@ show_patrol(int ac, char **av) struct mfi_pr_status status; struct mfi_pd_list *list; struct mfi_pd_info info; - char label[16]; + char label[24]; time_t now; uint32_t at; int error, fd; @@ -174,8 +174,10 @@ show_patrol(int ac, char **av) return (error); } if (info.prog_info.active & MFI_PD_PROGRESS_PATROL) { - snprintf(label, sizeof(label), " Drive %u", - list->addr[i].device_id); + snprintf(label, sizeof(label), " Drive %s", + mfi_drive_name(NULL, + list->addr[i].device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); mfi_display_progress(label, &info.prog_info.patrol); } Modified: stable/8/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_show.c Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfi_show.c Mon Jun 27 11:13:26 2011 (r223590) @@ -258,7 +258,7 @@ print_ld(struct mfi_ld_info *info, int s } static void -print_pd(struct mfi_pd_info *info, int state_len, int location) +print_pd(struct mfi_pd_info *info, int state_len) { const char *s; char buf[6]; @@ -273,15 +273,6 @@ print_pd(struct mfi_pd_info *info, int s s = mfi_pd_inq_string(info); if (s != NULL) printf(" %s", s); - if (!location) - return; - if (info->encl_device_id == 0xffff) - printf(" slot %d", info->slot_number); - else if (info->encl_device_id == info->ref.v.device_id) - printf(" enclosure %d", info->encl_index); - else - printf(" enclosure %d, slot %d", info->encl_index, - info->slot_number); } static int @@ -329,16 +320,16 @@ show_config(int ac, char **av) ar->num_drives); for (j = 0; j < ar->num_drives; j++) { device_id = ar->pd[j].ref.v.device_id; - if (device_id == 0xffff) - printf(" drive MISSING\n"); - else { - printf(" drive %u ", device_id); + printf(" drive %s ", mfi_drive_name(NULL, + device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); + if (device_id != 0xffff) { if (mfi_pd_get_info(fd, device_id, &pinfo, NULL) < 0) printf("%s", mfi_pdstate(ar->pd[j].fw_state)); else - print_pd(&pinfo, -1, 1); + print_pd(&pinfo, -1); printf("\n"); } } @@ -367,13 +358,14 @@ show_config(int ac, char **av) for (i = 0; i < config->spares_count; i++) { sp = (struct mfi_spare *)p; - printf(" %s spare %u ", + printf(" %s spare %s ", sp->spare_type & MFI_SPARE_DEDICATED ? "dedicated" : - "global", sp->ref.v.device_id); + "global", mfi_drive_name(NULL, sp->ref.v.device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); if (mfi_pd_get_info(fd, sp->ref.v.device_id, &pinfo, NULL) < 0) printf("%s", mfi_pdstate(MFI_PD_STATE_HOT_SPARE)); else - print_pd(&pinfo, -1, 1); + print_pd(&pinfo, -1); if (sp->spare_type & MFI_SPARE_DEDICATED) { printf(" backs:\n"); for (j = 0; j < sp->array_count; j++) @@ -534,7 +526,11 @@ show_drives(int ac, char **av) goto error; } - print_pd(&info, state_len, 1); + printf("%s ", mfi_drive_name(&info, list->addr[i].device_id, + MFI_DNAME_DEVICE_ID)); + print_pd(&info, state_len); + printf(" %s", mfi_drive_name(&info, list->addr[i].device_id, + MFI_DNAME_ES)); printf("\n"); } error: @@ -719,18 +715,21 @@ show_progress(int ac, char **av) } if (pinfo.prog_info.active & MFI_PD_PROGRESS_REBUILD) { - printf("drive %u ", device_id); + printf("drive %s ", mfi_drive_name(NULL, device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); mfi_display_progress("Rebuild", &pinfo.prog_info.rbld); busy = 1; } if (pinfo.prog_info.active & MFI_PD_PROGRESS_PATROL) { - printf("drive %u ", device_id); + printf("drive %s ", mfi_drive_name(NULL, device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); mfi_display_progress("Patrol Read", &pinfo.prog_info.patrol); busy = 1; } if (pinfo.prog_info.active & MFI_PD_PROGRESS_CLEAR) { - printf("drive %u ", device_id); + printf("drive %s ", mfi_drive_name(NULL, device_id, + MFI_DNAME_DEVICE_ID|MFI_DNAME_HONOR_OPTS)); mfi_display_progress("Clear", &pinfo.prog_info.clear); busy = 1; } Modified: stable/8/usr.sbin/mfiutil/mfiutil.8 ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.8 Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfiutil.8 Mon Jun 27 11:13:26 2011 (r223590) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2011 +.Dd June 20, 2011 .Dt MFIUTIL 8 .Os .Sh NAME @@ -43,6 +43,8 @@ .Op Fl u Ar unit .Cm show battery .Nm +.Op Fl d +.Op Fl e .Op Fl u Ar unit .Cm show config .Nm @@ -63,9 +65,13 @@ .Op Fl u Ar unit .Cm show logstate .Nm +.Op Fl d +.Op Fl e .Op Fl u Ar unit .Cm show patrol .Nm +.Op Fl d +.Op Fl e .Op Fl u Ar unit .Cm show progress .Nm @@ -155,15 +161,19 @@ If no unit is specified, then unit 0 is used. .El .Pp -Volumes may be specified in two forms. -First, -a volume may be identified by its target ID. -Second, -on the volume may be specified by the corresponding -.Em mfidX -device, -such as -.Em mfid0 . +Various commands accept either or both of the two options: +.Bl -tag -width indent +.It Fl d +Print numeric device IDs as drive identifier. +This is the default. +Useful in combination with +.Fl e +to print both, numeric device IDs and enclosure:slot information. +.It Fl e +Print drive identifiers in enclosure:slot form. +See next paragraph on format details in context of input rather than +output. +.El .Pp Drives may be specified in two forms. First, @@ -184,6 +194,16 @@ and is the slot for each drive as displayed in .Cm show drives . .Pp +Volumes may be specified in two forms. +First, +a volume may be identified by its target ID. +Second, +on the volume may be specified by the corresponding +.Em mfidX +device, +such as +.Em mfid0 . +.Pp The .Nm utility supports several different groups of commands. Modified: stable/8/usr.sbin/mfiutil/mfiutil.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.c Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfiutil.c Mon Jun 27 11:13:26 2011 (r223590) @@ -45,11 +45,13 @@ MFI_TABLE(top, abort); int mfi_unit; +u_int mfi_opts; + static void usage(void) { - fprintf(stderr, "usage: mfiutil [-u unit] ...\n\n"); + fprintf(stderr, "usage: mfiutil [-de] [-u unit] ...\n\n"); fprintf(stderr, "Commands include:\n"); fprintf(stderr, " version\n"); fprintf(stderr, " show adapter - display controller information\n"); @@ -58,6 +60,7 @@ usage(void) fprintf(stderr, " show drives - list physical drives\n"); fprintf(stderr, " show events - display event log\n"); fprintf(stderr, " show firmware - list firmware images\n"); + fprintf(stderr, " show logstate - display event log sequence numbers\n"); fprintf(stderr, " show volumes - list logical volumes\n"); fprintf(stderr, " show patrol - display patrol read status\n"); fprintf(stderr, " show progress - display status of active operations\n"); @@ -107,8 +110,14 @@ main(int ac, char **av) struct mfiutil_command **cmd; int ch; - while ((ch = getopt(ac, av, "u:")) != -1) { + while ((ch = getopt(ac, av, "deu:")) != -1) { switch (ch) { + case 'd': + mfi_opts |= MFI_DNAME_DEVICE_ID; + break; + case 'e': + mfi_opts |= MFI_DNAME_ES; + break; case 'u': mfi_unit = atoi(optarg); break; Modified: stable/8/usr.sbin/mfiutil/mfiutil.h ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.h Mon Jun 27 11:11:19 2011 (r223589) +++ stable/8/usr.sbin/mfiutil/mfiutil.h Mon Jun 27 11:13:26 2011 (r223590) @@ -115,7 +115,13 @@ struct mfiutil_command { } \ MFI_COMMAND(set, name, mfiutil_ ## name ## _table_handler) +/* Drive name printing options */ +#define MFI_DNAME_ES 0x0001 /* E%u:S%u */ +#define MFI_DNAME_DEVICE_ID 0x0002 /* %u */ +#define MFI_DNAME_HONOR_OPTS 0x8000 /* Allow cmd line to override default */ + extern int mfi_unit; +extern u_int mfi_opts; void mbox_store_ldref(uint8_t *mbox, union mfi_ld_ref *ref); void mbox_store_pdref(uint8_t *mbox, union mfi_pd_ref *ref); @@ -143,5 +149,7 @@ int mfi_pd_get_info(int fd, uint16_t dev int mfi_pd_get_list(int fd, struct mfi_pd_list **listp, uint8_t *statusp); int mfi_reconfig_supported(void); const char *mfi_status(u_int status_code); +const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id, + uint32_t def); #endif /* !__MFIUTIL_H__ */ From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 11:49:59 2011 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 365491065670; Mon, 27 Jun 2011 11:49:59 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C7748FC23; Mon, 27 Jun 2011 11:49:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RBnw0u096487; Mon, 27 Jun 2011 11:49:58 GMT (envelope-from netchild@svn.freebsd.org) Received: (from netchild@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RBnwKw096485; Mon, 27 Jun 2011 11:49:58 GMT (envelope-from netchild@svn.freebsd.org) Message-Id: <201106271149.p5RBnwKw096485@svn.freebsd.org> From: Alexander Leidinger Date: Mon, 27 Jun 2011 11:49: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: r223592 - 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: Mon, 27 Jun 2011 11:50:00 -0000 Author: netchild Date: Mon Jun 27 11:49:58 2011 New Revision: 223592 URL: http://svn.freebsd.org/changeset/base/223592 Log: MFC r223173: Add 2-clause BSD license. Approved by: David Kirchner (initial author) Requested by: Otto Moerbeek Modified: stable/8/usr.bin/kdump/mksubr Directory Properties: stable/8/usr.bin/kdump/ (props changed) Modified: stable/8/usr.bin/kdump/mksubr ============================================================================== --- stable/8/usr.bin/kdump/mksubr Mon Jun 27 11:13:58 2011 (r223591) +++ stable/8/usr.bin/kdump/mksubr Mon Jun 27 11:49:58 2011 (r223592) @@ -1,5 +1,28 @@ #!/bin/sh # +# Copyright (c) 2006 "David Kirchner" . 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$ # # Generates kdump_subr.c From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 18:19:54 2011 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 79540106566B; Mon, 27 Jun 2011 18:19:54 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68F688FC0A; Mon, 27 Jun 2011 18:19:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RIJskd008438; Mon, 27 Jun 2011 18:19:54 GMT (envelope-from kan@svn.freebsd.org) Received: (from kan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RIJsXE008436; Mon, 27 Jun 2011 18:19:54 GMT (envelope-from kan@svn.freebsd.org) Message-Id: <201106271819.p5RIJsXE008436@svn.freebsd.org> From: Alexander Kabaev Date: Mon, 27 Jun 2011 18:19:54 +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: r223601 - stable/8/sys/conf 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, 27 Jun 2011 18:19:54 -0000 Author: kan Date: Mon Jun 27 18:19:54 2011 New Revision: 223601 URL: http://svn.freebsd.org/changeset/base/223601 Log: Add missing support to generate well-formed CTF data in dynamic modules. Modified: stable/8/sys/conf/kmod.mk Modified: stable/8/sys/conf/kmod.mk ============================================================================== --- stable/8/sys/conf/kmod.mk Mon Jun 27 16:54:59 2011 (r223600) +++ stable/8/sys/conf/kmod.mk Mon Jun 27 18:19:54 2011 (r223601) @@ -132,6 +132,10 @@ CFLAGS+= -mlongcall -fno-omit-frame-poin CFLAGS+= -G0 -fno-pic -mno-abicalls -mlong-calls .endif +.if defined(DEBUG) || defined(DEBUG_FLAGS) +CTFFLAGS+= -g +.endif + .if defined(FIRMWS) .if !exists(@) ${KMOD:S/$/.c/}: @ @@ -197,6 +201,9 @@ ${KMOD}.kld: ${OBJS} ${FULLPROG}: ${OBJS} .endif ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS} +.if defined(WITH_CTF) + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} +.endif .if defined(EXPORT_SYMS) .if ${EXPORT_SYMS} != YES .if ${EXPORT_SYMS} == NO From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 18:56:44 2011 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 367BC106564A; Mon, 27 Jun 2011 18:56:44 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 25D3E8FC0A; Mon, 27 Jun 2011 18:56:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RIui8F009588; Mon, 27 Jun 2011 18:56:44 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RIui0A009586; Mon, 27 Jun 2011 18:56:44 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201106271856.p5RIui0A009586@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 27 Jun 2011 18:56: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: r223602 - stable/8/sys/geom/gate 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, 27 Jun 2011 18:56:44 -0000 Author: trociny Date: Mon Jun 27 18:56:43 2011 New Revision: 223602 URL: http://svn.freebsd.org/changeset/base/223602 Log: MFC r222225 (pjd): Recognize BIO_FLUSH requests and pass them to userland. Approved by: pjd (mentor) Modified: stable/8/sys/geom/gate/g_gate.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) Modified: stable/8/sys/geom/gate/g_gate.c ============================================================================== --- stable/8/sys/geom/gate/g_gate.c Mon Jun 27 18:19:54 2011 (r223601) +++ stable/8/sys/geom/gate/g_gate.c Mon Jun 27 18:56:43 2011 (r223602) @@ -178,6 +178,7 @@ g_gate_start(struct bio *bp) break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: /* XXX: Hack to allow read-only mounts. */ if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) { g_io_deliver(bp, EPERM); @@ -578,6 +579,7 @@ g_gate_ioctl(struct cdev *dev, u_long cm switch (bp->bio_cmd) { case BIO_READ: case BIO_DELETE: + case BIO_FLUSH: break; case BIO_WRITE: error = copyout(bp->bio_data, ggio->gctl_data, @@ -641,6 +643,7 @@ start_end: break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: break; } } From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 20:04:13 2011 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 723151065677; Mon, 27 Jun 2011 20:04:13 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 601268FC12; Mon, 27 Jun 2011 20:04:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RK4DOn011628; Mon, 27 Jun 2011 20:04:13 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RK4D0V011620; Mon, 27 Jun 2011 20:04:13 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201106272004.p5RK4D0V011620@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 27 Jun 2011 20:04: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: r223603 - 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: Mon, 27 Jun 2011 20:04:13 -0000 Author: trociny Date: Mon Jun 27 20:04:13 2011 New Revision: 223603 URL: http://svn.freebsd.org/changeset/base/223603 Log: MFC r222087, r222108, r222115, r222116, r222117, r222118, r222119, r222120, r222121: r222087 (pjd): - Add support for AF_INET6 sockets for %S format character. - Use inet_ntop(3) instead of reimplementing it. - Use %hhu for unsigned char instead of casting it to unsigned int and using %u. r222108 (pjd): In preparation for IPv6 support allow to specify multiple addresses to listen on. r222115 (pjd): Rename proto_tcp4.c to proto_tcp.c in preparation for IPv6 support. r222116 (pjd): Rename tcp4 to tcp in preparation for IPv6 support. r222117 (pjd): Allow [ ] characters in strings. They might be used in IPv6 addresses. r222118 (pjd): Now that hell is fully frozen it is good time to add IPv6 support to HAST. r222119 (pjd): Rename ipv4/ipv6 to tcp4/tcp6. r222120 (pjd): If no listen address is specified, bind by default to: tcp4://0.0.0.0:8457 tcp6://[::]:8457 r222121 (pjd): Document IPv6 support. Approved by: pjd (mentor) Added: stable/8/sbin/hastd/proto_tcp.c - copied, changed from r222115, head/sbin/hastd/proto_tcp.c Deleted: stable/8/sbin/hastd/proto_tcp4.c Modified: stable/8/sbin/hastd/Makefile stable/8/sbin/hastd/hast.conf.5 stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/parse.y stable/8/sbin/hastd/pjdlog.c stable/8/sbin/hastd/token.l Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/Makefile ============================================================================== --- stable/8/sbin/hastd/Makefile Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/Makefile Mon Jun 27 20:04:13 2011 (r223603) @@ -12,7 +12,7 @@ SRCS+= metadata.c SRCS+= nv.c SRCS+= secondary.c SRCS+= parse.y pjdlog.c primary.c -SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp.c proto_uds.c SRCS+= rangelock.c SRCS+= subr.c SRCS+= token.l @@ -21,7 +21,7 @@ WARNS?= 6 MAN= hastd.8 hast.conf.5 NO_WFORMAT= -CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 +CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: stable/8/sbin/hastd/hast.conf.5 ============================================================================== --- stable/8/sbin/hastd/hast.conf.5 Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/hast.conf.5 Mon Jun 27 20:04:13 2011 (r223603) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 2, 2011 +.Dd May 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -159,8 +159,14 @@ tcp4://0.0.0.0 tcp4://0.0.0.0:8457 .Ed .Pp -The default value is -.Pa tcp4://0.0.0.0:8457 . +Multiple listen addresses can be specified. +By default +.Nm hastd +listens on +.Pa tcp4://0.0.0.0:8457 +and +.Pa tcp6://[::]:8457 +if kernel supports IPv4 and IPv6 respectively. .It Ic replication Aq mode .Pp Replication mode should be one of the following: @@ -364,26 +370,35 @@ daemon. .Sh EXAMPLES The example configuration file can look as follows: .Bd -literal -offset indent +listen tcp://0.0.0.0 + +on hasta { + listen tcp://2001:db8::1/64 +} +on hastb { + listen tcp://2001:db8::2/64 +} + resource shared { local /dev/da0 on hasta { - remote tcp4://10.0.0.2 + remote tcp://10.0.0.2 } on hastb { - remote tcp4://10.0.0.1 + remote tcp://10.0.0.1 } } resource tank { on hasta { local /dev/mirror/tanka - source tcp4://10.0.0.1 - remote tcp4://10.0.0.2 + source tcp://10.0.0.1 + remote tcp://10.0.0.2 } on hastb { local /dev/mirror/tankb - source tcp4://10.0.0.2 - remote tcp4://10.0.0.1 + source tcp://10.0.0.2 + remote tcp://10.0.0.1 } } .Ed Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/hast.h Mon Jun 27 20:04:13 2011 (r223603) @@ -82,12 +82,13 @@ #define HIO_FLUSH 4 #define HIO_KEEPALIVE 5 -#define HAST_USER "hast" -#define HAST_TIMEOUT 20 -#define HAST_CONFIG "/etc/hast.conf" -#define HAST_CONTROL "/var/run/hastctl" -#define HASTD_LISTEN "tcp4://0.0.0.0:8457" -#define HASTD_PIDFILE "/var/run/hastd.pid" +#define HAST_USER "hast" +#define HAST_TIMEOUT 20 +#define HAST_CONFIG "/etc/hast.conf" +#define HAST_CONTROL "/var/run/hastctl" +#define HASTD_LISTEN_TCP4 "tcp4://0.0.0.0:8457" +#define HASTD_LISTEN_TCP6 "tcp6://[::]:8457" +#define HASTD_PIDFILE "/var/run/hastd.pid" /* Default extent size. */ #define HAST_EXTENTSIZE 2097152 @@ -100,6 +101,14 @@ /* Number of seconds to sleep between reconnect retries or keepalive packets. */ #define HAST_KEEPALIVE 10 +struct hastd_listen { + /* Address to listen on. */ + char hl_addr[HAST_ADDRSIZE]; + /* Protocol-specific data. */ + struct proto_conn *hl_conn; + TAILQ_ENTRY(hastd_listen) hl_next; +}; + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; @@ -107,10 +116,8 @@ struct hastd_config { struct proto_conn *hc_controlconn; /* Incoming control connection. */ struct proto_conn *hc_controlin; - /* Address to listen on. */ - char hc_listenaddr[HAST_ADDRSIZE]; - /* Protocol-specific data. */ - struct proto_conn *hc_listenconn; + /* List of addresses to listen on. */ + TAILQ_HEAD(, hastd_listen) hc_listen; /* List of resources. */ TAILQ_HEAD(, hast_resource) hc_resources; }; Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/hastd.c Mon Jun 27 20:04:13 2011 (r223603) @@ -98,6 +98,7 @@ void descriptors_cleanup(struct hast_resource *res) { struct hast_resource *tres; + struct hastd_listen *lst; TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { if (tres == res) { @@ -120,7 +121,10 @@ descriptors_cleanup(struct hast_resource if (cfg->hc_controlin != NULL) proto_close(cfg->hc_controlin); proto_close(cfg->hc_controlconn); - proto_close(cfg->hc_listenconn); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn != NULL) + proto_close(lst->hl_conn); + } (void)pidfile_close(pfh); hook_fini(); pjdlog_fini(); @@ -462,6 +466,8 @@ hastd_reload(void) { struct hastd_config *newcfg; struct hast_resource *nres, *cres, *tres; + struct hastd_listen *nlst, *clst; + unsigned int nlisten; uint8_t role; pjdlog_info("Reloading configuration..."); @@ -483,19 +489,37 @@ hastd_reload(void) } } /* - * Check if listen address has changed. + * Check if any listen address has changed. */ - if (strcmp(cfg->hc_listenaddr, newcfg->hc_listenaddr) != 0) { - if (proto_server(newcfg->hc_listenaddr, - &newcfg->hc_listenconn) < 0) { - pjdlog_errno(LOG_ERR, "Unable to listen on address %s", - newcfg->hc_listenaddr); - goto failed; + nlisten = 0; + TAILQ_FOREACH(nlst, &newcfg->hc_listen, hl_next) { + TAILQ_FOREACH(clst, &cfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, clst->hl_addr) == 0) + break; + } + if (clst != NULL && clst->hl_conn != NULL) { + pjdlog_info("Keep listening on address %s.", + nlst->hl_addr); + nlst->hl_conn = clst->hl_conn; + nlisten++; + } else if (proto_server(nlst->hl_addr, &nlst->hl_conn) == 0) { + pjdlog_info("Listening on new address %s.", + nlst->hl_addr); + nlisten++; + } else { + pjdlog_errno(LOG_WARNING, + "Unable to listen on address %s", nlst->hl_addr); } } + if (nlisten == 0) { + pjdlog_error("No addresses to listen on."); + goto failed; + } + + /* No failures from now on. */ + /* - * Only when both control and listen sockets are successfully - * initialized switch them to new configuration. + * Switch to new control socket. */ if (newcfg->hc_controlconn != NULL) { pjdlog_info("Control socket changed from %s to %s.", @@ -506,15 +530,23 @@ hastd_reload(void) strlcpy(cfg->hc_controladdr, newcfg->hc_controladdr, sizeof(cfg->hc_controladdr)); } - if (newcfg->hc_listenconn != NULL) { - pjdlog_info("Listen socket changed from %s to %s.", - cfg->hc_listenaddr, newcfg->hc_listenaddr); - proto_close(cfg->hc_listenconn); - cfg->hc_listenconn = newcfg->hc_listenconn; - newcfg->hc_listenconn = NULL; - strlcpy(cfg->hc_listenaddr, newcfg->hc_listenaddr, - sizeof(cfg->hc_listenaddr)); + /* + * Switch to new listen addresses. Close all that were removed. + */ + while ((clst = TAILQ_FIRST(&cfg->hc_listen)) != NULL) { + TAILQ_FOREACH(nlst, &newcfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, clst->hl_addr) == 0) + break; + } + if (nlst == NULL && clst->hl_conn != NULL) { + proto_close(clst->hl_conn); + pjdlog_info("No longer listening on address %s.", + clst->hl_addr); + } + TAILQ_REMOVE(&cfg->hc_listen, clst, hl_next); + free(clst); } + TAILQ_CONCAT(&cfg->hc_listen, &newcfg->hc_listen, hl_next); /* * Stop and remove resources that were removed from the configuration. @@ -607,8 +639,20 @@ failed: if (newcfg != NULL) { if (newcfg->hc_controlconn != NULL) proto_close(newcfg->hc_controlconn); - if (newcfg->hc_listenconn != NULL) - proto_close(newcfg->hc_listenconn); + while ((nlst = TAILQ_FIRST(&newcfg->hc_listen)) != NULL) { + if (nlst->hl_conn != NULL) { + TAILQ_FOREACH(clst, &cfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, + clst->hl_addr) == 0) { + break; + } + } + if (clst == NULL || clst->hl_conn == NULL) + proto_close(nlst->hl_conn); + } + TAILQ_REMOVE(&newcfg->hc_listen, nlst, hl_next); + free(nlst); + } yy_config_free(newcfg); } pjdlog_warning("Configuration not reloaded."); @@ -634,7 +678,7 @@ terminate_workers(void) } static void -listen_accept(void) +listen_accept(struct hastd_listen *lst) { struct hast_resource *res; struct proto_conn *conn; @@ -646,10 +690,10 @@ listen_accept(void) pid_t pid; int status; - proto_local_address(cfg->hc_listenconn, laddr, sizeof(laddr)); + proto_local_address(lst->hl_conn, laddr, sizeof(laddr)); pjdlog_debug(1, "Accepting connection to %s.", laddr); - if (proto_accept(cfg->hc_listenconn, &conn) < 0) { + if (proto_accept(lst->hl_conn, &conn) < 0) { pjdlog_errno(LOG_ERR, "Unable to accept connection %s", laddr); return; } @@ -943,6 +987,7 @@ static void main_loop(void) { struct hast_resource *res; + struct hastd_listen *lst; struct timeval seltimeout; int fd, maxfd, ret; time_t lastcheck, now; @@ -952,9 +997,6 @@ main_loop(void) seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; - pjdlog_info("Started successfully, running protocol version %d.", - HAST_PROTO_VERSION); - for (;;) { check_signals(); @@ -963,10 +1005,14 @@ main_loop(void) maxfd = fd = proto_descriptor(cfg->hc_controlconn); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); - fd = proto_descriptor(cfg->hc_listenconn); - PJDLOG_ASSERT(fd >= 0); - FD_SET(fd, &rfds); - maxfd = fd > maxfd ? fd : maxfd; + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn == NULL) + continue; + fd = proto_descriptor(lst->hl_conn); + PJDLOG_ASSERT(fd >= 0); + FD_SET(fd, &rfds); + maxfd = fd > maxfd ? fd : maxfd; + } TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; @@ -1014,8 +1060,12 @@ main_loop(void) if (FD_ISSET(proto_descriptor(cfg->hc_controlconn), &rfds)) control_handle(cfg); - if (FD_ISSET(proto_descriptor(cfg->hc_listenconn), &rfds)) - listen_accept(); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn == NULL) + continue; + if (FD_ISSET(proto_descriptor(lst->hl_conn), &rfds)) + listen_accept(lst); + } TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; @@ -1053,6 +1103,7 @@ dummy_sighandler(int sig __unused) int main(int argc, char *argv[]) { + struct hastd_listen *lst; const char *pidfile; pid_t otherpid; bool foreground; @@ -1136,10 +1187,12 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } /* Listen for remote connections. */ - if (proto_server(cfg->hc_listenaddr, &cfg->hc_listenconn) < 0) { - KEEP_ERRNO((void)pidfile_remove(pfh)); - pjdlog_exit(EX_OSERR, "Unable to listen on address %s", - cfg->hc_listenaddr); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (proto_server(lst->hl_addr, &lst->hl_conn) < 0) { + KEEP_ERRNO((void)pidfile_remove(pfh)); + pjdlog_exit(EX_OSERR, "Unable to listen on address %s", + lst->hl_addr); + } } if (!foreground) { @@ -1158,6 +1211,14 @@ main(int argc, char *argv[]) } } + pjdlog_info("Started successfully, running protocol version %d.", + HAST_PROTO_VERSION); + + pjdlog_debug(1, "Listening on control address %s.", + cfg->hc_controladdr); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) + pjdlog_info("Listening on address %s.", lst->hl_addr); + hook_init(); main_loop(); Modified: stable/8/sbin/hastd/parse.y ============================================================================== --- stable/8/sbin/hastd/parse.y Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/parse.y Mon Jun 27 20:04:13 2011 (r223603) @@ -33,12 +33,14 @@ #include /* MAXHOSTNAMELEN */ #include +#include #include #include #include #include +#include #include #include #include @@ -59,7 +61,9 @@ static struct hast_resource *curres; static bool mynode, hadmynode; static char depth0_control[HAST_ADDRSIZE]; -static char depth0_listen[HAST_ADDRSIZE]; +static char depth0_listen_tcp4[HAST_ADDRSIZE]; +static char depth0_listen_tcp6[HAST_ADDRSIZE]; +static TAILQ_HEAD(, hastd_listen) depth0_listen; static int depth0_replication; static int depth0_checksum; static int depth0_compression; @@ -114,6 +118,19 @@ isitme(const char *name) return (0); } +static bool +family_supported(int family) +{ + int sock; + + sock = socket(family, SOCK_STREAM, 0); + if (sock == -1 && errno == EPROTONOSUPPORT) + return (false); + if (sock >= 0) + (void)close(sock); + return (true); +} + static int node_names(char **namesp) { @@ -175,7 +192,11 @@ yy_config_parse(const char *config, bool depth0_checksum = HAST_CHECKSUM_NONE; depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); - strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen)); + TAILQ_INIT(&depth0_listen); + strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4, + sizeof(depth0_listen_tcp4)); + strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6, + sizeof(depth0_listen_tcp6)); depth0_exec[0] = '\0'; lconfig = calloc(1, sizeof(*lconfig)); @@ -186,6 +207,7 @@ yy_config_parse(const char *config, bool return (NULL); } + TAILQ_INIT(&lconfig->hc_listen); TAILQ_INIT(&lconfig->hc_resources); yyin = fopen(config, "r"); @@ -214,9 +236,50 @@ yy_config_parse(const char *config, bool strlcpy(lconfig->hc_controladdr, depth0_control, sizeof(lconfig->hc_controladdr)); } - if (lconfig->hc_listenaddr[0] == '\0') { - strlcpy(lconfig->hc_listenaddr, depth0_listen, - sizeof(lconfig->hc_listenaddr)); + if (!TAILQ_EMPTY(&depth0_listen)) + TAILQ_CONCAT(&lconfig->hc_listen, &depth0_listen, hl_next); + if (TAILQ_EMPTY(&lconfig->hc_listen)) { + struct hastd_listen *lst; + + if (family_supported(AF_INET)) { + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } + (void)strlcpy(lst->hl_addr, depth0_listen_tcp4, + sizeof(lst->hl_addr)); + TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); + } else { + pjdlog_debug(1, + "No IPv4 support in the kernel, not listening on IPv4 address."); + } + if (family_supported(AF_INET6)) { + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } + (void)strlcpy(lst->hl_addr, depth0_listen_tcp6, + sizeof(lst->hl_addr)); + TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); + } else { + pjdlog_debug(1, + "No IPv6 support in the kernel, not listening on IPv6 address."); + } + if (TAILQ_EMPTY(&lconfig->hc_listen)) { + pjdlog_error("No address to listen on."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } } TAILQ_FOREACH(curres, &lconfig->hc_resources, hr_next) { assert(curres->hr_provname[0] != '\0'); @@ -274,8 +337,17 @@ yy_config_parse(const char *config, bool void yy_config_free(struct hastd_config *config) { + struct hastd_listen *lst; struct hast_resource *res; + while ((lst = TAILQ_FIRST(&depth0_listen)) != NULL) { + TAILQ_REMOVE(&depth0_listen, lst, hl_next); + free(lst); + } + while ((lst = TAILQ_FIRST(&config->hc_listen)) != NULL) { + TAILQ_REMOVE(&config->hc_listen, lst, hl_next); + free(lst); + } while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) { TAILQ_REMOVE(&config->hc_resources, res, hr_next); free(res); @@ -362,26 +434,30 @@ control_statement: CONTROL STR listen_statement: LISTEN STR { + struct hastd_listen *lst; + + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + free($2); + return (1); + } + if (strlcpy(lst->hl_addr, $2, sizeof(lst->hl_addr)) >= + sizeof(lst->hl_addr)) { + pjdlog_error("listen argument is too long."); + free($2); + free(lst); + return (1); + } switch (depth) { case 0: - if (strlcpy(depth0_listen, $2, - sizeof(depth0_listen)) >= - sizeof(depth0_listen)) { - pjdlog_error("listen argument is too long."); - free($2); - return (1); - } + TAILQ_INSERT_TAIL(&depth0_listen, lst, hl_next); break; case 1: - if (!mynode) - break; - if (strlcpy(lconfig->hc_listenaddr, $2, - sizeof(lconfig->hc_listenaddr)) >= - sizeof(lconfig->hc_listenaddr)) { - pjdlog_error("listen argument is too long."); - free($2); - return (1); - } + if (mynode) + TAILQ_INSERT_TAIL(&depth0_listen, lst, hl_next); + else + free(lst); break; default: assert(!"listen at wrong depth level"); Modified: stable/8/sbin/hastd/pjdlog.c ============================================================================== --- stable/8/sbin/hastd/pjdlog.c Mon Jun 27 18:56:43 2011 (r223602) +++ stable/8/sbin/hastd/pjdlog.c Mon Jun 27 20:04:13 2011 (r223603) @@ -31,8 +31,10 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include @@ -103,22 +105,39 @@ pjdlog_printf_render_sockaddr(struct __p switch (ss->ss_family) { case AF_INET: { + char addr[INET_ADDRSTRLEN]; const struct sockaddr_in *sin; - in_addr_t ip; unsigned int port; sin = (const struct sockaddr_in *)ss; - ip = ntohl(sin->sin_addr.s_addr); port = ntohs(sin->sin_port); + if (inet_ntop(ss->ss_family, &sin->sin_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "%s:%u", addr, port); + break; + } + case AF_INET6: + { + char addr[INET6_ADDRSTRLEN]; + const struct sockaddr_in6 *sin; + unsigned int port; - snprintf(buf, sizeof(buf), "%u.%u.%u.%u:%u", - ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), - ((ip >> 8) & 0xff), (ip & 0xff), port); + sin = (const struct sockaddr_in6 *)ss; + port = ntohs(sin->sin6_port); + if (inet_ntop(ss->ss_family, &sin->sin6_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET6) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "[%s]:%u", addr, port); break; } default: - snprintf(buf, sizeof(buf), "[unsupported family %u]", - (unsigned int)ss->ss_family); + snprintf(buf, sizeof(buf), "[unsupported family %hhu]", + ss->ss_family); break; } ret = __printf_out(io, pi, buf, strlen(buf)); Copied and modified: stable/8/sbin/hastd/proto_tcp.c (from r222115, head/sbin/hastd/proto_tcp.c) ============================================================================== --- head/sbin/hastd/proto_tcp.c Fri May 20 11:06:17 2011 (r222115, copy source) +++ stable/8/sbin/hastd/proto_tcp.c Mon Jun 27 20:04:13 2011 (r223603) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -51,37 +52,19 @@ __FBSDID("$FreeBSD$"); #include "proto_impl.h" #include "subr.h" -#define TCP4_CTX_MAGIC 0x7c441c -struct tcp4_ctx { +#define TCP_CTX_MAGIC 0x7c41c +struct tcp_ctx { int tc_magic; - struct sockaddr_in tc_sin; + struct sockaddr_storage tc_sa; int tc_fd; int tc_side; -#define TCP4_SIDE_CLIENT 0 -#define TCP4_SIDE_SERVER_LISTEN 1 -#define TCP4_SIDE_SERVER_WORK 2 +#define TCP_SIDE_CLIENT 0 +#define TCP_SIDE_SERVER_LISTEN 1 +#define TCP_SIDE_SERVER_WORK 2 }; -static int tcp4_connect_wait(void *ctx, int timeout); -static void tcp4_close(void *ctx); - -static in_addr_t -str2ip(const char *str) -{ - struct hostent *hp; - in_addr_t ip; - - ip = inet_addr(str); - if (ip != INADDR_NONE) { - /* It is a valid IP address. */ - return (ip); - } - /* Check if it is a valid host name. */ - hp = gethostbyname(str); - if (hp == NULL) - return (INADDR_NONE); - return (((struct in_addr *)(void *)hp->h_addr)->s_addr); -} +static int tcp_connect_wait(void *ctx, int timeout); +static void tcp_close(void *ctx); /* * Function converts the given string to unsigned number. @@ -114,70 +97,106 @@ invalid: } static int -tcp4_addr(const char *addr, int defport, struct sockaddr_in *sinp) +tcp_addr(const char *addr, int defport, struct sockaddr_storage *sap) { - char iporhost[MAXHOSTNAMELEN]; + char iporhost[MAXHOSTNAMELEN], portstr[6]; + struct addrinfo hints; + struct addrinfo *res; const char *pp; + intmax_t port; size_t size; - in_addr_t ip; + int error; if (addr == NULL) return (-1); - if (strncasecmp(addr, "tcp4://", 7) == 0) + bzero(&hints, sizeof(hints)); + hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + if (strncasecmp(addr, "tcp4://", 7) == 0) { + addr += 7; + hints.ai_family = PF_INET; + } else if (strncasecmp(addr, "tcp6://", 7) == 0) { addr += 7; - else if (strncasecmp(addr, "tcp://", 6) == 0) + hints.ai_family = PF_INET6; + } else if (strncasecmp(addr, "tcp://", 6) == 0) { addr += 6; - else { + } else { /* - * Because TCP4 is the default assume IP or host is given without + * Because TCP is the default assume IP or host is given without * prefix. */ } - sinp->sin_family = AF_INET; - sinp->sin_len = sizeof(*sinp); - /* Extract optional port. */ - pp = strrchr(addr, ':'); + /* + * Extract optional port. + * There are three cases to consider. + * 1. hostname with port, eg. freefall.freebsd.org:8457 + * 2. IPv4 address with port, eg. 192.168.0.101:8457 + * 3. IPv6 address with port, eg. [fe80::1]:8457 + * We discover IPv6 address by checking for two colons and if port is + * given, the address has to start with [. + */ + pp = NULL; + if (strchr(addr, ':') != strrchr(addr, ':')) { + if (addr[0] == '[') + pp = strrchr(addr, ':'); + } else { + pp = strrchr(addr, ':'); + } if (pp == NULL) { /* Port not given, use the default. */ - sinp->sin_port = htons(defport); + port = defport; } else { - intmax_t port; - if (numfromstr(pp + 1, 1, 65535, &port) < 0) return (errno); - sinp->sin_port = htons(port); } + (void)snprintf(portstr, sizeof(portstr), "%jd", (intmax_t)port); /* Extract host name or IP address. */ if (pp == NULL) { size = sizeof(iporhost); if (strlcpy(iporhost, addr, size) >= size) return (ENAMETOOLONG); + } else if (addr[0] == '[' && pp[-1] == ']') { + size = (size_t)(pp - addr - 2 + 1); + if (size > sizeof(iporhost)) + return (ENAMETOOLONG); + (void)strlcpy(iporhost, addr + 1, size); } else { size = (size_t)(pp - addr + 1); if (size > sizeof(iporhost)) return (ENAMETOOLONG); (void)strlcpy(iporhost, addr, size); } - /* Convert string (IP address or host name) to in_addr_t. */ - ip = str2ip(iporhost); - if (ip == INADDR_NONE) + + error = getaddrinfo(iporhost, portstr, &hints, &res); + if (error != 0) { + pjdlog_debug(1, "getaddrinfo(%s, %s) failed: %s.", iporhost, + portstr, gai_strerror(error)); return (EINVAL); - sinp->sin_addr.s_addr = ip; + } + if (res == NULL) + return (ENOENT); + + memcpy(sap, res->ai_addr, res->ai_addrlen); + + freeaddrinfo(res); return (0); } static int -tcp4_setup_new(const char *addr, int side, void **ctxp) +tcp_setup_new(const char *addr, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; int ret, nodelay; PJDLOG_ASSERT(addr != NULL); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_LISTEN); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_LISTEN); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -185,22 +204,21 @@ tcp4_setup_new(const char *addr, int sid return (errno); /* Parse given address. */ - if ((ret = tcp4_addr(addr, PROTO_TCP4_DEFAULT_PORT, - &tctx->tc_sin)) != 0) { + if ((ret = tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &tctx->tc_sa)) != 0) { free(tctx); return (ret); } - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); - tctx->tc_fd = socket(AF_INET, SOCK_STREAM, 0); + tctx->tc_fd = socket(tctx->tc_sa.ss_family, SOCK_STREAM, 0); if (tctx->tc_fd == -1) { ret = errno; free(tctx); return (ret); } - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); /* Socket settings. */ nodelay = 1; @@ -210,20 +228,20 @@ tcp4_setup_new(const char *addr, int sid } tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_setup_wrap(int fd, int side, void **ctxp) +tcp_setup_wrap(int fd, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; PJDLOG_ASSERT(fd >= 0); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_WORK); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_WORK); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -231,51 +249,51 @@ tcp4_setup_wrap(int fd, int side, void * return (errno); tctx->tc_fd = fd; - tctx->tc_sin.sin_family = AF_UNSPEC; + tctx->tc_sa.ss_family = AF_UNSPEC; tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_client(const char *srcaddr, const char *dstaddr, void **ctxp) +tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) { - struct tcp4_ctx *tctx; - struct sockaddr_in sin; + struct tcp_ctx *tctx; + struct sockaddr_storage sa; int ret; - ret = tcp4_setup_new(dstaddr, TCP4_SIDE_CLIENT, ctxp); + ret = tcp_setup_new(dstaddr, TCP_SIDE_CLIENT, ctxp); if (ret != 0) return (ret); tctx = *ctxp; if (srcaddr == NULL) return (0); - ret = tcp4_addr(srcaddr, 0, &sin); + ret = tcp_addr(srcaddr, 0, &sa); if (ret != 0) { - tcp4_close(tctx); + tcp_close(tctx); return (ret); } - if (bind(tctx->tc_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + if (bind(tctx->tc_fd, (struct sockaddr *)&sa, sa.ss_len) < 0) { ret = errno; - tcp4_close(tctx); + tcp_close(tctx); return (ret); } return (0); } static int -tcp4_connect(void *ctx, int timeout) +tcp_connect(void *ctx, int timeout) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; int error, flags; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); - PJDLOG_ASSERT(tctx->tc_side == TCP4_SIDE_CLIENT); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_CLIENT); PJDLOG_ASSERT(tctx->tc_fd >= 0); - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); PJDLOG_ASSERT(timeout >= -1); flags = fcntl(tctx->tc_fd, F_GETFL); @@ -295,8 +313,8 @@ tcp4_connect(void *ctx, int timeout) return (errno); } - if (connect(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sin, - sizeof(tctx->tc_sin)) == 0) { + if (connect(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, + tctx->tc_sa.ss_len) == 0) { if (timeout == -1) return (0); error = 0; @@ -309,7 +327,7 @@ tcp4_connect(void *ctx, int timeout) } if (timeout == -1) return (0); - return (tcp4_connect_wait(ctx, timeout)); + return (tcp_connect_wait(ctx, timeout)); done: flags &= ~O_NONBLOCK; if (fcntl(tctx->tc_fd, F_SETFL, flags) == -1) { @@ -322,17 +340,17 @@ done: } static int -tcp4_connect_wait(void *ctx, int timeout) +tcp_connect_wait(void *ctx, int timeout) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; struct timeval tv; fd_set fdset; socklen_t esize; int error, flags, ret; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); - PJDLOG_ASSERT(tctx->tc_side == TCP4_SIDE_CLIENT); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_CLIENT); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(timeout >= 0); @@ -387,12 +405,12 @@ done: } static int -tcp4_server(const char *addr, void **ctxp) +tcp_server(const char *addr, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; int ret, val; - ret = tcp4_setup_new(addr, TCP4_SIDE_SERVER_LISTEN, ctxp); + ret = tcp_setup_new(addr, TCP_SIDE_SERVER_LISTEN, ctxp); if (ret != 0) return (ret); @@ -403,17 +421,17 @@ tcp4_server(const char *addr, void **ctx (void)setsockopt(tctx->tc_fd, SOL_SOCKET, SO_REUSEADDR, &val, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 20:59:44 2011 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 BD48B1065672; Mon, 27 Jun 2011 20:59:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A85678FC0A; Mon, 27 Jun 2011 20:59:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RKxi1w013516; Mon, 27 Jun 2011 20:59:44 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RKxiKI013470; Mon, 27 Jun 2011 20:59:44 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201106272059.p5RKxiKI013470@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 27 Jun 2011 20:59: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: r223605 - in stable/8: etc/devd sys/dev/sound/usb sys/dev/usb sys/dev/usb/input sys/dev/usb/misc sys/dev/usb/net sys/dev/usb/serial sys/dev/usb/storage sys/dev/usb/wlan sys/netgraph/blu... 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, 27 Jun 2011 20:59:44 -0000 Author: hselasky Date: Mon Jun 27 20:59:43 2011 New Revision: 223605 URL: http://svn.freebsd.org/changeset/base/223605 Log: MFC r223486, r223489, r223490, r223511, r223512, r223513, r223515, r223518, r223519, r223521, r223534, r223535, r223536, r223537, r223538, r223543, r223288, r223604 and r223566: - Export all USB device ID's in so-called sections. - Fix duplicate occurence of a USB ID in if_urtw and if_zyd. - Add new tool to autogenerate nomatch entries for devd. - Add new usb.conf file to auto-load USB drivers. - Fix some issues related to the nomatch notifications. PR: misc/157903 Added: stable/8/etc/devd/usb.conf - copied, changed from r223543, head/etc/devd/usb.conf stable/8/tools/tools/bus_autoconf/ - copied from r223486, head/tools/tools/bus_autoconf/ stable/8/tools/tools/bus_autoconf/bus_autoconf_format_example.txt - copied unchanged from r223534, head/tools/tools/bus_autoconf/bus_autoconf_format_example.txt stable/8/tools/tools/bus_autoconf/bus_load_file.c - copied, changed from r223534, head/tools/tools/bus_autoconf/bus_load_file.c stable/8/tools/tools/bus_autoconf/bus_load_file.h - copied unchanged from r223534, head/tools/tools/bus_autoconf/bus_load_file.h stable/8/tools/tools/bus_autoconf/bus_sections.c - copied unchanged from r223534, head/tools/tools/bus_autoconf/bus_sections.c stable/8/tools/tools/bus_autoconf/bus_sections.h - copied unchanged from r223534, head/tools/tools/bus_autoconf/bus_sections.h stable/8/tools/tools/bus_autoconf/bus_usb.c - copied, changed from r223534, head/tools/tools/bus_autoconf/bus_usb.c stable/8/tools/tools/bus_autoconf/bus_usb.h - copied unchanged from r223534, head/tools/tools/bus_autoconf/bus_usb.h Modified: stable/8/etc/devd/Makefile stable/8/sys/dev/sound/usb/uaudio.c stable/8/sys/dev/usb/input/atp.c stable/8/sys/dev/usb/input/uep.c stable/8/sys/dev/usb/input/uhid.c stable/8/sys/dev/usb/input/ukbd.c stable/8/sys/dev/usb/input/ums.c stable/8/sys/dev/usb/misc/udbp.c stable/8/sys/dev/usb/misc/ufm.c stable/8/sys/dev/usb/net/if_aue.c stable/8/sys/dev/usb/net/if_axe.c stable/8/sys/dev/usb/net/if_cdce.c stable/8/sys/dev/usb/net/if_cue.c stable/8/sys/dev/usb/net/if_ipheth.c stable/8/sys/dev/usb/net/if_kue.c stable/8/sys/dev/usb/net/if_rue.c stable/8/sys/dev/usb/net/if_udav.c stable/8/sys/dev/usb/net/uhso.c stable/8/sys/dev/usb/serial/u3g.c stable/8/sys/dev/usb/serial/uark.c stable/8/sys/dev/usb/serial/ubsa.c stable/8/sys/dev/usb/serial/uchcom.c stable/8/sys/dev/usb/serial/ucycom.c stable/8/sys/dev/usb/serial/ufoma.c stable/8/sys/dev/usb/serial/uftdi.c stable/8/sys/dev/usb/serial/ugensa.c stable/8/sys/dev/usb/serial/uipaq.c stable/8/sys/dev/usb/serial/ulpt.c stable/8/sys/dev/usb/serial/umcs.c stable/8/sys/dev/usb/serial/umct.c stable/8/sys/dev/usb/serial/umodem.c stable/8/sys/dev/usb/serial/umoscom.c stable/8/sys/dev/usb/serial/uplcom.c stable/8/sys/dev/usb/serial/uslcom.c stable/8/sys/dev/usb/serial/uvisor.c stable/8/sys/dev/usb/serial/uvscom.c stable/8/sys/dev/usb/storage/umass.c stable/8/sys/dev/usb/storage/urio.c stable/8/sys/dev/usb/usb_device.c stable/8/sys/dev/usb/usb_hub.c stable/8/sys/dev/usb/usb_lookup.c stable/8/sys/dev/usb/usb_msctest.c stable/8/sys/dev/usb/usbdi.h stable/8/sys/dev/usb/wlan/if_rum.c stable/8/sys/dev/usb/wlan/if_run.c stable/8/sys/dev/usb/wlan/if_uath.c stable/8/sys/dev/usb/wlan/if_upgt.c stable/8/sys/dev/usb/wlan/if_ural.c stable/8/sys/dev/usb/wlan/if_urtw.c stable/8/sys/dev/usb/wlan/if_zyd.c stable/8/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c stable/8/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c stable/8/tools/tools/bus_autoconf/Makefile stable/8/tools/tools/bus_autoconf/bus_autoconf.c stable/8/tools/tools/bus_autoconf/bus_autoconf.h stable/8/tools/tools/bus_autoconf/bus_autoconf.sh Directory Properties: stable/8/etc/ (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/tools/tools/ (props changed) stable/8/tools/tools/aac/ (props changed) stable/8/tools/tools/ath/ (props changed) stable/8/tools/tools/ath/common/dumpregs.h (props changed) stable/8/tools/tools/ath/common/dumpregs_5210.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5211.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5212.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5416.c (props changed) stable/8/tools/tools/cfi/ (props changed) stable/8/tools/tools/ether_reflect/ (props changed) stable/8/tools/tools/iwi/ (props changed) stable/8/tools/tools/mctest/ (props changed) stable/8/tools/tools/nanobsd/ (props changed) stable/8/tools/tools/netrate/ (props changed) stable/8/tools/tools/netrate/tcpp/ (props changed) stable/8/tools/tools/termcap/termcap.pl (props changed) stable/8/tools/tools/umastat/ (props changed) stable/8/tools/tools/vimage/ (props changed) Modified: stable/8/etc/devd/Makefile ============================================================================== --- stable/8/etc/devd/Makefile Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/etc/devd/Makefile Mon Jun 27 20:59:43 2011 (r223605) @@ -1,6 +1,6 @@ # $FreeBSD$ -FILES= asus.conf uath.conf +FILES= asus.conf uath.conf usb.conf NO_OBJ= FILESDIR= /etc/devd Copied and modified: stable/8/etc/devd/usb.conf (from r223543, head/etc/devd/usb.conf) ============================================================================== --- head/etc/devd/usb.conf Sat Jun 25 17:01:46 2011 (r223543, copy source) +++ stable/8/etc/devd/usb.conf Mon Jun 27 20:59:43 2011 (r223605) @@ -1533,15 +1533,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x083a"; - match "product" "0x4506"; - action "kldload if_uath"; -}; - -nomatch 32 { - match "bus" "uhub[0-9]+"; - match "mode" "host"; - match "vendor" "0x083a"; - match "product" "0x4506"; + match "product" "(0x4505|0x4506)"; action "kldload if_zyd"; }; Modified: stable/8/sys/dev/sound/usb/uaudio.c ============================================================================== --- stable/8/sys/dev/sound/usb/uaudio.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/sound/usb/uaudio.c Mon Jun 27 20:59:43 2011 (r223605) @@ -531,6 +531,15 @@ static driver_t uaudio_driver = { .size = sizeof(struct uaudio_softc), }; +static const STRUCT_USB_HOST_ID __used uaudio_devs[] = { + /* Generic USB audio class match */ + {USB_IFACE_CLASS(UICLASS_AUDIO), + USB_IFACE_SUBCLASS(UISUBCLASS_AUDIOCONTROL),}, + /* Generic USB MIDI class match */ + {USB_IFACE_CLASS(UICLASS_AUDIO), + USB_IFACE_SUBCLASS(UISUBCLASS_MIDISTREAM),}, +}; + static int uaudio_probe(device_t dev) { Modified: stable/8/sys/dev/usb/input/atp.c ============================================================================== --- stable/8/sys/dev/usb/input/atp.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/input/atp.c Mon Jun 27 20:59:43 2011 (r223605) @@ -240,7 +240,7 @@ struct atp_dev_params { }, }; -static const struct usb_device_id atp_devs[] = { +static const STRUCT_USB_HOST_ID atp_devs[] = { /* Core Duo MacBook & MacBook Pro */ { USB_VPI(USB_VENDOR_APPLE, 0x0217, ATP_DEV_PARAMS_0) }, { USB_VPI(USB_VENDOR_APPLE, 0x0218, ATP_DEV_PARAMS_0) }, Modified: stable/8/sys/dev/usb/input/uep.c ============================================================================== --- stable/8/sys/dev/usb/input/uep.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/input/uep.c Mon Jun 27 20:59:43 2011 (r223605) @@ -288,6 +288,12 @@ static const struct usb_config uep_confi }, }; +static const STRUCT_USB_HOST_ID uep_devs[] = { + {USB_VPI(USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL, 0)}, + {USB_VPI(USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL2, 0)}, + {USB_VPI(USB_VENDOR_EGALAX2, USB_PRODUCT_EGALAX2_TPANEL, 0)}, +}; + static int uep_probe(device_t dev) { @@ -295,17 +301,12 @@ uep_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); + if (uaa->info.bConfigIndex != 0) + return (ENXIO); + if (uaa->info.bIfaceIndex != 0) + return (ENXIO); - if ((uaa->info.idVendor == USB_VENDOR_EGALAX) && - ((uaa->info.idProduct == USB_PRODUCT_EGALAX_TPANEL) || - (uaa->info.idProduct == USB_PRODUCT_EGALAX_TPANEL2))) - return (BUS_PROBE_SPECIFIC); - - if ((uaa->info.idVendor == USB_VENDOR_EGALAX2) && - (uaa->info.idProduct == USB_PRODUCT_EGALAX2_TPANEL)) - return (BUS_PROBE_SPECIFIC); - - return (ENXIO); + return (usbd_lookup_id_by_uaa(uep_devs, sizeof(uep_devs), uaa)); } static int Modified: stable/8/sys/dev/usb/input/uhid.c ============================================================================== --- stable/8/sys/dev/usb/input/uhid.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/input/uhid.c Mon Jun 27 20:59:43 2011 (r223605) @@ -607,29 +607,33 @@ uhid_ioctl(struct usb_fifo *fifo, u_long return (error); } +static const STRUCT_USB_HOST_ID uhid_devs[] = { + /* generic HID class */ + {USB_IFACE_CLASS(UICLASS_HID),}, + /* the Xbox 360 gamepad doesn't use the HID class */ + {USB_IFACE_CLASS(UICLASS_VENDOR), + USB_IFACE_SUBCLASS(UISUBCLASS_XBOX360_CONTROLLER), + USB_IFACE_PROTOCOL(UIPROTO_XBOX360_GAMEPAD),}, +}; + static int uhid_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + int error; DPRINTFN(11, "\n"); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } - if (uaa->info.bInterfaceClass != UICLASS_HID) { - /* the Xbox 360 gamepad doesn't use the HID class */ + error = usbd_lookup_id_by_uaa(uhid_devs, sizeof(uhid_devs), uaa); + if (error) + return (error); - if ((uaa->info.bInterfaceClass != UICLASS_VENDOR) || - (uaa->info.bInterfaceSubClass != UISUBCLASS_XBOX360_CONTROLLER) || - (uaa->info.bInterfaceProtocol != UIPROTO_XBOX360_GAMEPAD)) { - return (ENXIO); - } - } - if (usb_test_quirk(uaa, UQ_HID_IGNORE)) { + if (usb_test_quirk(uaa, UQ_HID_IGNORE)) return (ENXIO); - } + return (BUS_PROBE_GENERIC); } Modified: stable/8/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/8/sys/dev/usb/input/ukbd.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/input/ukbd.c Mon Jun 27 20:59:43 2011 (r223605) @@ -745,6 +745,13 @@ static const struct usb_config ukbd_conf }, }; +/* A match on these entries will load ukbd */ +static const STRUCT_USB_HOST_ID __used ukbd_devs[] = { + {USB_IFACE_CLASS(UICLASS_HID), + USB_IFACE_SUBCLASS(UISUBCLASS_BOOT), + USB_IFACE_PROTOCOL(UIPROTO_BOOT_KEYBOARD),}, +}; + static int ukbd_probe(device_t dev) { Modified: stable/8/sys/dev/usb/input/ums.c ============================================================================== --- stable/8/sys/dev/usb/input/ums.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/input/ums.c Mon Jun 27 20:59:43 2011 (r223605) @@ -355,6 +355,13 @@ static const struct usb_config ums_confi }, }; +/* A match on these entries will load ums */ +static const STRUCT_USB_HOST_ID __used ums_devs[] = { + {USB_IFACE_CLASS(UICLASS_HID), + USB_IFACE_SUBCLASS(UISUBCLASS_BOOT), + USB_IFACE_PROTOCOL(UIPROTO_MOUSE),}, +}; + static int ums_probe(device_t dev) { Modified: stable/8/sys/dev/usb/misc/udbp.c ============================================================================== --- stable/8/sys/dev/usb/misc/udbp.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/misc/udbp.c Mon Jun 27 20:59:43 2011 (r223605) @@ -288,40 +288,27 @@ udbp_modload(module_t mod, int event, vo return (error); } +static const STRUCT_USB_HOST_ID udbp_devs[] = { + {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_TURBOCONNECT, 0)}, + {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2301, 0)}, + {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2302, 0)}, + {USB_VPI(USB_VENDOR_ANCHOR, USB_PRODUCT_ANCHOR_EZLINK, 0)}, + {USB_VPI(USB_VENDOR_GENESYS, USB_PRODUCT_GENESYS_GL620USB, 0)}, +}; + static int udbp_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) + return (ENXIO); + if (uaa->info.bConfigIndex != 0) + return (ENXIO); + if (uaa->info.bIfaceIndex != 0) return (ENXIO); - } - /* - * XXX Julian, add the id of the device if you have one to test - * things with. run 'usbdevs -v' and note the 3 ID's that appear. - * The Vendor Id and Product Id are in hex and the Revision Id is in - * bcd. But as usual if the revision is 0x101 then you should - * compare the revision id in the device descriptor with 0x101 Or go - * search the file usbdevs.h. Maybe the device is already in there. - */ - if (((uaa->info.idVendor == USB_VENDOR_NETCHIP) && - (uaa->info.idProduct == USB_PRODUCT_NETCHIP_TURBOCONNECT))) - return (0); - - if (((uaa->info.idVendor == USB_VENDOR_PROLIFIC) && - ((uaa->info.idProduct == USB_PRODUCT_PROLIFIC_PL2301) || - (uaa->info.idProduct == USB_PRODUCT_PROLIFIC_PL2302)))) - return (0); - - if ((uaa->info.idVendor == USB_VENDOR_ANCHOR) && - (uaa->info.idProduct == USB_PRODUCT_ANCHOR_EZLINK)) - return (0); - - if ((uaa->info.idVendor == USB_VENDOR_GENESYS) && - (uaa->info.idProduct == USB_PRODUCT_GENESYS_GL620USB)) - return (0); - return (ENXIO); + return (usbd_lookup_id_by_uaa(udbp_devs, sizeof(udbp_devs), uaa)); } static int Modified: stable/8/sys/dev/usb/misc/ufm.c ============================================================================== --- stable/8/sys/dev/usb/misc/ufm.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/misc/ufm.c Mon Jun 27 20:59:43 2011 (r223605) @@ -118,19 +118,23 @@ DRIVER_MODULE(ufm, uhub, ufm_driver, ufm MODULE_DEPEND(ufm, usb, 1, 1, 1); MODULE_VERSION(ufm, 1); +static const STRUCT_USB_HOST_ID ufm_devs[] = { + {USB_VPI(USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_FMRADIO, 0)}, +}; + static int ufm_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } - if ((uaa->info.idVendor == USB_VENDOR_CYPRESS) && - (uaa->info.idProduct == USB_PRODUCT_CYPRESS_FMRADIO)) { - return (0); - } - return (ENXIO); + if (uaa->info.bConfigIndex != 0) + return (ENXIO); + if (uaa->info.bIfaceIndex != 0) + return (ENXIO); + + return (usbd_lookup_id_by_uaa(ufm_devs, sizeof(ufm_devs), uaa)); } static int Modified: stable/8/sys/dev/usb/net/if_aue.c ============================================================================== --- stable/8/sys/dev/usb/net/if_aue.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_aue.c Mon Jun 27 20:59:43 2011 (r223605) @@ -110,7 +110,7 @@ SYSCTL_INT(_hw_usb_aue, OID_AUTO, debug, /* * Various supported device vendors/products. */ -static const struct usb_device_id aue_devs[] = { +static const STRUCT_USB_HOST_ID aue_devs[] = { #define AUE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } AUE_DEV(3COM, 3C460B, AUE_FLAG_PII), AUE_DEV(ABOCOM, DSB650TX_PNA, 0), Modified: stable/8/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/8/sys/dev/usb/net/if_axe.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_axe.c Mon Jun 27 20:59:43 2011 (r223605) @@ -133,7 +133,7 @@ SYSCTL_INT(_hw_usb_axe, OID_AUTO, debug, /* * Various supported device vendors/products. */ -static const struct usb_device_id axe_devs[] = { +static const STRUCT_USB_HOST_ID axe_devs[] = { #define AXE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } AXE_DEV(ABOCOM, UF200, 0), AXE_DEV(ACERCM, EP1427X2, 0), Modified: stable/8/sys/dev/usb/net/if_cdce.c ============================================================================== --- stable/8/sys/dev/usb/net/if_cdce.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_cdce.c Mon Jun 27 20:59:43 2011 (r223605) @@ -263,7 +263,7 @@ static const struct usb_ether_methods cd .ue_setpromisc = cdce_setpromisc, }; -static const struct usb_device_id cdce_devs[] = { +static const STRUCT_USB_HOST_ID cdce_host_devs[] = { {USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX, CDCE_FLAG_NO_UNION)}, @@ -277,7 +277,9 @@ static const struct usb_device_id cdce_d {USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLA300, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC700, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC750, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, +}; +static const STRUCT_USB_DUAL_ID cdce_dual_devs[] = { {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)}, {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)}, {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_NETWORK_CONTROL_MODEL, 0)}, @@ -472,8 +474,12 @@ static int cdce_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + int error; - return (usbd_lookup_id_by_uaa(cdce_devs, sizeof(cdce_devs), uaa)); + error = usbd_lookup_id_by_uaa(cdce_host_devs, sizeof(cdce_host_devs), uaa); + if (error) + error = usbd_lookup_id_by_uaa(cdce_dual_devs, sizeof(cdce_dual_devs), uaa); + return (error); } static void Modified: stable/8/sys/dev/usb/net/if_cue.c ============================================================================== --- stable/8/sys/dev/usb/net/if_cue.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_cue.c Mon Jun 27 20:59:43 2011 (r223605) @@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$"); /* Belkin F5U111 adapter covered by NETMATE entry */ -static const struct usb_device_id cue_devs[] = { +static const STRUCT_USB_HOST_ID cue_devs[] = { #define CUE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } CUE_DEV(CATC, NETMATE), CUE_DEV(CATC, NETMATE2), Modified: stable/8/sys/dev/usb/net/if_ipheth.c ============================================================================== --- stable/8/sys/dev/usb/net/if_ipheth.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_ipheth.c Mon Jun 27 20:59:43 2011 (r223605) @@ -148,7 +148,7 @@ static const struct usb_ether_methods ip USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \ USB_IFACE_PROTOCOL(pt) -static const struct usb_device_id ipheth_devs[] = { +static const STRUCT_USB_HOST_ID ipheth_devs[] = { {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE, IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, IPHETH_USBINTF_PROTO)}, Modified: stable/8/sys/dev/usb/net/if_kue.c ============================================================================== --- stable/8/sys/dev/usb/net/if_kue.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_kue.c Mon Jun 27 20:59:43 2011 (r223605) @@ -100,7 +100,7 @@ __FBSDID("$FreeBSD$"); /* * Various supported device vendors/products. */ -static const struct usb_device_id kue_devs[] = { +static const STRUCT_USB_HOST_ID kue_devs[] = { #define KUE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } KUE_DEV(3COM, 3C19250), KUE_DEV(3COM, 3C460), Modified: stable/8/sys/dev/usb/net/if_rue.c ============================================================================== --- stable/8/sys/dev/usb/net/if_rue.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_rue.c Mon Jun 27 20:59:43 2011 (r223605) @@ -108,7 +108,7 @@ SYSCTL_INT(_hw_usb_rue, OID_AUTO, debug, * Various supported device vendors/products. */ -static const struct usb_device_id rue_devs[] = { +static const STRUCT_USB_HOST_ID rue_devs[] = { {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUAKTX, 0)}, {USB_VPI(USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_USBKR100, 0)}, {USB_VPI(USB_VENDOR_OQO, USB_PRODUCT_OQO_ETHER01, 0)}, Modified: stable/8/sys/dev/usb/net/if_udav.c ============================================================================== --- stable/8/sys/dev/usb/net/if_udav.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/if_udav.c Mon Jun 27 20:59:43 2011 (r223605) @@ -199,7 +199,7 @@ SYSCTL_INT(_hw_usb_udav, OID_AUTO, debug #define UDAV_CLRBIT(sc, reg, x) \ udav_csr_write1(sc, reg, udav_csr_read1(sc, reg) & ~(x)) -static const struct usb_device_id udav_devs[] = { +static const STRUCT_USB_HOST_ID udav_devs[] = { /* ShanTou DM9601 USB NIC */ {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_DM9601, 0)}, /* ShanTou ST268 USB NIC */ Modified: stable/8/sys/dev/usb/net/uhso.c ============================================================================== --- stable/8/sys/dev/usb/net/uhso.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/net/uhso.c Mon Jun 27 20:59:43 2011 (r223605) @@ -247,7 +247,7 @@ static char *uhso_port_type_sysctl[] = { /* ifnet device unit allocations */ static struct unrhdr *uhso_ifnet_unit = NULL; -static const struct usb_device_id uhso_devs[] = { +static const STRUCT_USB_HOST_ID uhso_devs[] = { #define UHSO_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } /* Option GlobeSurfer iCON 7.2 */ UHSO_DEV(OPTION, GSICON72, UHSO_STATIC_IFACE), Modified: stable/8/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/8/sys/dev/usb/serial/u3g.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/u3g.c Mon Jun 27 20:59:43 2011 (r223605) @@ -182,7 +182,7 @@ MODULE_DEPEND(u3g, ucom, 1, 1, 1); MODULE_DEPEND(u3g, usb, 1, 1, 1); MODULE_VERSION(u3g, 1); -static const struct usb_device_id u3g_devs[] = { +static const STRUCT_USB_HOST_ID u3g_devs[] = { #define U3G_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } U3G_DEV(ACERP, H10, 0), U3G_DEV(AIRPLUS, MCD650, 0), Modified: stable/8/sys/dev/usb/serial/uark.c ============================================================================== --- stable/8/sys/dev/usb/serial/uark.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uark.c Mon Jun 27 20:59:43 2011 (r223605) @@ -170,7 +170,7 @@ MODULE_DEPEND(uark, ucom, 1, 1, 1); MODULE_DEPEND(uark, usb, 1, 1, 1); MODULE_VERSION(uark, 1); -static const struct usb_device_id uark_devs[] = { +static const STRUCT_USB_HOST_ID uark_devs[] = { {USB_VPI(USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116, 0)}, }; Modified: stable/8/sys/dev/usb/serial/ubsa.c ============================================================================== --- stable/8/sys/dev/usb/serial/ubsa.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/ubsa.c Mon Jun 27 20:59:43 2011 (r223605) @@ -239,7 +239,7 @@ static const struct ucom_callback ubsa_c .ucom_poll = &ubsa_poll, }; -static const struct usb_device_id ubsa_devs[] = { +static const STRUCT_USB_HOST_ID ubsa_devs[] = { /* AnyData ADU-500A */ {USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_500A, 0)}, /* AnyData ADU-E100A/H */ Modified: stable/8/sys/dev/usb/serial/uchcom.c ============================================================================== --- stable/8/sys/dev/usb/serial/uchcom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uchcom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -204,7 +204,7 @@ static const struct uchcom_divider_recor #define NUM_DIVIDERS (sizeof (dividers) / sizeof (dividers[0])) -static const struct usb_device_id uchcom_devs[] = { +static const STRUCT_USB_HOST_ID uchcom_devs[] = { {USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)}, {USB_VPI(USB_VENDOR_WCH2, USB_PRODUCT_WCH2_CH341SER, 0)}, }; Modified: stable/8/sys/dev/usb/serial/ucycom.c ============================================================================== --- stable/8/sys/dev/usb/serial/ucycom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/ucycom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -180,7 +180,7 @@ MODULE_VERSION(ucycom, 1); /* * Supported devices */ -static const struct usb_device_id ucycom_devs[] = { +static const STRUCT_USB_HOST_ID ucycom_devs[] = { {USB_VPI(USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE, MODEL_CY7C64013)}, }; Modified: stable/8/sys/dev/usb/serial/ufoma.c ============================================================================== --- stable/8/sys/dev/usb/serial/ufoma.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/ufoma.c Mon Jun 27 20:59:43 2011 (r223605) @@ -327,6 +327,11 @@ MODULE_DEPEND(ufoma, ucom, 1, 1, 1); MODULE_DEPEND(ufoma, usb, 1, 1, 1); MODULE_VERSION(ufoma, 1); +static const STRUCT_USB_HOST_ID ufoma_devs[] = { + {USB_IFACE_CLASS(UICLASS_CDC), + USB_IFACE_SUBCLASS(UISUBCLASS_MCPC),}, +}; + static int ufoma_probe(device_t dev) { @@ -334,30 +339,31 @@ ufoma_probe(device_t dev) struct usb_interface_descriptor *id; struct usb_config_descriptor *cd; usb_mcpc_acm_descriptor *mad; + int error; - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } + + error = usbd_lookup_id_by_uaa(ufoma_devs, sizeof(ufoma_devs), uaa); + if (error) + return (error); + id = usbd_get_interface_descriptor(uaa->iface); cd = usbd_get_config_descriptor(uaa->device); - if ((id == NULL) || - (cd == NULL) || - (id->bInterfaceClass != UICLASS_CDC) || - (id->bInterfaceSubClass != UISUBCLASS_MCPC)) { + if (id == NULL || cd == NULL) return (ENXIO); - } + mad = ufoma_get_intconf(cd, id, UDESC_VS_INTERFACE, UDESCSUB_MCPC_ACM); - if (mad == NULL) { + if (mad == NULL) return (ENXIO); - } + #ifndef UFOMA_HANDSFREE if ((mad->bType == UMCPC_ACM_TYPE_AB5) || - (mad->bType == UMCPC_ACM_TYPE_AB6)) { + (mad->bType == UMCPC_ACM_TYPE_AB6)) return (ENXIO); - } #endif - return (0); + return (BUS_PROBE_GENERIC); } static int Modified: stable/8/sys/dev/usb/serial/uftdi.c ============================================================================== --- stable/8/sys/dev/usb/serial/uftdi.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uftdi.c Mon Jun 27 20:59:43 2011 (r223605) @@ -206,7 +206,7 @@ MODULE_DEPEND(uftdi, ucom, 1, 1, 1); MODULE_DEPEND(uftdi, usb, 1, 1, 1); MODULE_VERSION(uftdi, 1); -static struct usb_device_id uftdi_devs[] = { +static STRUCT_USB_HOST_ID uftdi_devs[] = { #define UFTDI_DEV(v,p,t) \ { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, UFTDI_TYPE_##t) } UFTDI_DEV(ATMEL, STK541, 8U232AM), Modified: stable/8/sys/dev/usb/serial/ugensa.c ============================================================================== --- stable/8/sys/dev/usb/serial/ugensa.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/ugensa.c Mon Jun 27 20:59:43 2011 (r223605) @@ -154,7 +154,7 @@ MODULE_DEPEND(ugensa, ucom, 1, 1, 1); MODULE_DEPEND(ugensa, usb, 1, 1, 1); MODULE_VERSION(ugensa, 1); -static const struct usb_device_id ugensa_devs[] = { +static const STRUCT_USB_HOST_ID ugensa_devs[] = { {USB_VPI(USB_VENDOR_AIRPRIME, USB_PRODUCT_AIRPRIME_PC5220, 0)}, {USB_VPI(USB_VENDOR_CMOTECH, USB_PRODUCT_CMOTECH_CDMA_MODEM1, 0)}, {USB_VPI(USB_VENDOR_KYOCERA2, USB_PRODUCT_KYOCERA2_CDMA_MSM_K, 0)}, Modified: stable/8/sys/dev/usb/serial/uipaq.c ============================================================================== --- stable/8/sys/dev/usb/serial/uipaq.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uipaq.c Mon Jun 27 20:59:43 2011 (r223605) @@ -153,7 +153,7 @@ static const struct ucom_callback uipaq_ * support the same hardware. Numeric values are used where no usbdevs * entries exist. */ -static const struct usb_device_id uipaq_devs[] = { +static const STRUCT_USB_HOST_ID uipaq_devs[] = { /* Socket USB Sync */ {USB_VPI(0x0104, 0x00be, 0)}, /* USB Sync 0301 */ Modified: stable/8/sys/dev/usb/serial/ulpt.c ============================================================================== --- stable/8/sys/dev/usb/serial/ulpt.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/ulpt.c Mon Jun 27 20:59:43 2011 (r223605) @@ -483,24 +483,39 @@ ulpt_ioctl(struct usb_fifo *fifo, u_long return (ENODEV); } +static const STRUCT_USB_HOST_ID ulpt_devs[] = { + /* Uni-directional USB printer */ + {USB_IFACE_CLASS(UICLASS_PRINTER), + USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER), + USB_IFACE_PROTOCOL(UIPROTO_PRINTER_UNI)}, + + /* Bi-directional USB printer */ + {USB_IFACE_CLASS(UICLASS_PRINTER), + USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER), + USB_IFACE_PROTOCOL(UIPROTO_PRINTER_BI)}, + + /* 1284 USB printer */ + {USB_IFACE_CLASS(UICLASS_PRINTER), + USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER), + USB_IFACE_PROTOCOL(UIPROTO_PRINTER_1284)}, +}; + static int ulpt_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + int error; DPRINTFN(11, "\n"); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } - if ((uaa->info.bInterfaceClass == UICLASS_PRINTER) && - (uaa->info.bInterfaceSubClass == UISUBCLASS_PRINTER) && - ((uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_UNI) || - (uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_BI) || - (uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_1284))) { - return (0); - } - return (ENXIO); + + error = usbd_lookup_id_by_uaa(ulpt_devs, sizeof(ulpt_devs), uaa); + if (error) + return (error); + + return (BUS_PROBE_GENERIC); } static int Modified: stable/8/sys/dev/usb/serial/umcs.c ============================================================================== --- stable/8/sys/dev/usb/serial/umcs.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/umcs.c Mon Jun 27 20:59:43 2011 (r223605) @@ -253,7 +253,7 @@ static struct ucom_callback umcs7840_cal .ucom_poll = &umcs7840_poll, }; -static const struct usb_device_id umcs7840_devs[] = { +static const STRUCT_USB_HOST_ID umcs7840_devs[] = { {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7820, 0)}, {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7840, 0)}, }; Modified: stable/8/sys/dev/usb/serial/umct.c ============================================================================== --- stable/8/sys/dev/usb/serial/umct.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/umct.c Mon Jun 27 20:59:43 2011 (r223605) @@ -192,7 +192,7 @@ static const struct ucom_callback umct_c .ucom_poll = &umct_poll, }; -static const struct usb_device_id umct_devs[] = { +static const STRUCT_USB_HOST_ID umct_devs[] = { {USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0)}, {USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_SITECOM_USB232, 0)}, {USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_DU_H3SP_USB232, 0)}, Modified: stable/8/sys/dev/usb/serial/umodem.c ============================================================================== --- stable/8/sys/dev/usb/serial/umodem.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/umodem.c Mon Jun 27 20:59:43 2011 (r223605) @@ -123,7 +123,7 @@ SYSCTL_INT(_hw_usb_umodem, OID_AUTO, deb &umodem_debug, 0, "Debug level"); #endif -static const struct usb_device_id umodem_devs[] = { +static const STRUCT_USB_HOST_ID umodem_devs[] = { /* Generic Modem class match */ {USB_IFACE_CLASS(UICLASS_CDC), USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL), @@ -276,11 +276,14 @@ umodem_probe(device_t dev) DPRINTFN(11, "\n"); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } + error = usbd_lookup_id_by_uaa(umodem_devs, sizeof(umodem_devs), uaa); - return (error); + if (error) + return (error); + + return (BUS_PROBE_GENERIC); } static int Modified: stable/8/sys/dev/usb/serial/umoscom.c ============================================================================== --- stable/8/sys/dev/usb/serial/umoscom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/umoscom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -280,7 +280,7 @@ MODULE_DEPEND(umoscom, ucom, 1, 1, 1); MODULE_DEPEND(umoscom, usb, 1, 1, 1); MODULE_VERSION(umoscom, 1); -static const struct usb_device_id umoscom_devs[] = { +static const STRUCT_USB_HOST_ID umoscom_devs[] = { {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703, 0)} }; Modified: stable/8/sys/dev/usb/serial/uplcom.c ============================================================================== --- stable/8/sys/dev/usb/serial/uplcom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uplcom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -247,7 +247,7 @@ static struct ucom_callback uplcom_callb #define UPLCOM_DEV(v,p) \ { USB_VENDOR(USB_VENDOR_##v), USB_PRODUCT(USB_PRODUCT_##v##_##p) } -static const struct usb_device_id uplcom_devs[] = { +static const STRUCT_USB_HOST_ID uplcom_devs[] = { UPLCOM_DEV(ACERP, S81), /* BenQ S81 phone */ UPLCOM_DEV(ADLINK, ND6530), /* ADLINK ND-6530 USB-Serial */ UPLCOM_DEV(ALCATEL, OT535), /* Alcatel One Touch 535/735 */ Modified: stable/8/sys/dev/usb/serial/uslcom.c ============================================================================== --- stable/8/sys/dev/usb/serial/uslcom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uslcom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -173,7 +173,7 @@ static struct ucom_callback uslcom_callb .ucom_poll = &uslcom_poll, }; -static const struct usb_device_id uslcom_devs[] = { +static const STRUCT_USB_HOST_ID uslcom_devs[] = { #define USLCOM_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } USLCOM_DEV(BALTECH, CARDREADER), USLCOM_DEV(CLIPSAL, 5500PCU), Modified: stable/8/sys/dev/usb/serial/uvisor.c ============================================================================== --- stable/8/sys/dev/usb/serial/uvisor.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uvisor.c Mon Jun 27 20:59:43 2011 (r223605) @@ -253,7 +253,7 @@ MODULE_DEPEND(uvisor, ucom, 1, 1, 1); MODULE_DEPEND(uvisor, usb, 1, 1, 1); MODULE_VERSION(uvisor, 1); -static const struct usb_device_id uvisor_devs[] = { +static const STRUCT_USB_HOST_ID uvisor_devs[] = { #define UVISOR_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } UVISOR_DEV(ACEECA, MEZ1000, UVISOR_FLAG_PALM4), UVISOR_DEV(ALPHASMART, DANA_SYNC, UVISOR_FLAG_PALM4), Modified: stable/8/sys/dev/usb/serial/uvscom.c ============================================================================== --- stable/8/sys/dev/usb/serial/uvscom.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/serial/uvscom.c Mon Jun 27 20:59:43 2011 (r223605) @@ -233,7 +233,7 @@ static const struct ucom_callback uvscom .ucom_poll = &uvscom_poll, }; -static const struct usb_device_id uvscom_devs[] = { +static const STRUCT_USB_HOST_ID uvscom_devs[] = { /* SUNTAC U-Cable type A4 */ {USB_VPI(USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_AS144L4, 0)}, /* SUNTAC U-Cable type D2 */ Modified: stable/8/sys/dev/usb/storage/umass.c ============================================================================== --- stable/8/sys/dev/usb/storage/umass.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/storage/umass.c Mon Jun 27 20:59:43 2011 (r223605) @@ -721,6 +721,11 @@ MODULE_VERSION(umass, 1); * USB device probe/attach/detach */ +static const STRUCT_USB_HOST_ID __used umass_devs[] = { + /* generic mass storage class */ + {USB_IFACE_CLASS(UICLASS_MASS),}, +}; + static uint16_t umass_get_proto(struct usb_interface *iface) { Modified: stable/8/sys/dev/usb/storage/urio.c ============================================================================== --- stable/8/sys/dev/usb/storage/urio.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/storage/urio.c Mon Jun 27 20:59:43 2011 (r223605) @@ -198,22 +198,25 @@ DRIVER_MODULE(urio, uhub, urio_driver, u MODULE_DEPEND(urio, usb, 1, 1, 1); MODULE_VERSION(urio, 1); +static const STRUCT_USB_HOST_ID urio_devs[] = { + {USB_VPI(USB_VENDOR_DIAMOND, USB_PRODUCT_DIAMOND_RIO500USB, 0)}, + {USB_VPI(USB_VENDOR_DIAMOND2, USB_PRODUCT_DIAMOND2_RIO600USB, 0)}, + {USB_VPI(USB_VENDOR_DIAMOND2, USB_PRODUCT_DIAMOND2_RIO800USB, 0)}, +}; + static int urio_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); - if (uaa->usb_mode != USB_MODE_HOST) { + if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - } - if ((((uaa->info.idVendor == USB_VENDOR_DIAMOND) && - (uaa->info.idProduct == USB_PRODUCT_DIAMOND_RIO500USB)) || - ((uaa->info.idVendor == USB_VENDOR_DIAMOND2) && - ((uaa->info.idProduct == USB_PRODUCT_DIAMOND2_RIO600USB) || - (uaa->info.idProduct == USB_PRODUCT_DIAMOND2_RIO800USB))))) - return (0); - else + if (uaa->info.bConfigIndex != 0) return (ENXIO); + if (uaa->info.bIfaceIndex != 0) + return (ENXIO); + + return (usbd_lookup_id_by_uaa(urio_devs, sizeof(urio_devs), uaa)); } static int Modified: stable/8/sys/dev/usb/usb_device.c ============================================================================== --- stable/8/sys/dev/usb/usb_device.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/usb_device.c Mon Jun 27 20:59:43 2011 (r223605) @@ -1297,6 +1297,21 @@ usb_probe_and_attach(struct usb_device * usb_init_attach_arg(udev, &uaa); + /* + * If the whole USB device is targeted, invoke the USB event + * handler(s): + */ + if (iface_index == USB_IFACE_INDEX_ANY) { + + EVENTHANDLER_INVOKE(usb_dev_configured, udev, &uaa); + + if (uaa.dev_state != UAA_DEV_READY) { + /* leave device unconfigured */ + usb_unconfigure(udev, 0); + goto done; + } + } + /* Check if only one interface should be probed: */ if (iface_index != USB_IFACE_INDEX_ANY) { i = iface_index; @@ -1343,17 +1358,18 @@ usb_probe_and_attach(struct usb_device * uaa.info.bIfaceIndex, uaa.info.bIfaceNum); - if (usb_probe_and_attach_sub(udev, &uaa)) { - /* ignore */ - } - } + usb_probe_and_attach_sub(udev, &uaa); - if (uaa.temp_dev) { - /* remove the last created child; it is unused */ - - if (device_delete_child(udev->parent_dev, uaa.temp_dev)) { + /* + * Remove the leftover child, if any, to enforce that + * a new nomatch devd event is generated for the next + * interface if no driver is found: + */ + if (uaa.temp_dev == NULL) + continue; + if (device_delete_child(udev->parent_dev, uaa.temp_dev)) DPRINTFN(0, "device delete child failed\n"); - } + uaa.temp_dev = NULL; } done: if (do_unlock) @@ -1526,7 +1542,7 @@ usb_alloc_device(device_t parent_dev, st /* initialise our SX-lock */ sx_init_flags(&udev->enum_sx, "USB config SX lock", SX_DUPOK); - sx_init_flags(&udev->sr_sx, "USB suspend and resume SX lock", SX_DUPOK); + sx_init_flags(&udev->sr_sx, "USB suspend and resume SX lock", SX_NOWITNESS); cv_init(&udev->ctrlreq_cv, "WCTRL"); cv_init(&udev->ref_cv, "UGONE"); @@ -1834,11 +1850,6 @@ repeat_set_config: } } } - EVENTHANDLER_INVOKE(usb_dev_configured, udev, &uaa); - if (uaa.dev_state != UAA_DEV_READY) { - /* leave device unconfigured */ - usb_unconfigure(udev, 0); - } config_done: DPRINTF("new dev (addr %d), udev=%p, parent_hub=%p\n", Modified: stable/8/sys/dev/usb/usb_hub.c ============================================================================== --- stable/8/sys/dev/usb/usb_hub.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/usb_hub.c Mon Jun 27 20:59:43 2011 (r223605) @@ -1334,15 +1334,19 @@ uhub_child_pnpinfo_string(device_t paren "devclass=0x%02x devsubclass=0x%02x " "sernum=\"%s\" " "release=0x%04x " - "intclass=0x%02x intsubclass=0x%02x" "%s%s", + "mode=%s " + "intclass=0x%02x intsubclass=0x%02x " + "intprotocol=0x%02x " "%s%s", UGETW(res.udev->ddesc.idVendor), UGETW(res.udev->ddesc.idProduct), res.udev->ddesc.bDeviceClass, res.udev->ddesc.bDeviceSubClass, usb_get_serial(res.udev), UGETW(res.udev->ddesc.bcdDevice), + (res.udev->flags.usb_mode == USB_MODE_HOST) ? "host" : "device", iface->idesc->bInterfaceClass, iface->idesc->bInterfaceSubClass, + iface->idesc->bInterfaceProtocol, iface->pnpinfo ? " " : "", iface->pnpinfo ? iface->pnpinfo : ""); } else { Modified: stable/8/sys/dev/usb/usb_lookup.c ============================================================================== --- stable/8/sys/dev/usb/usb_lookup.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/usb_lookup.c Mon Jun 27 20:59:43 2011 (r223605) @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include @@ -105,13 +107,6 @@ usbd_lookup_id_by_info(const struct usb_ (id->bDeviceProtocol != info->bDeviceProtocol)) { continue; } - if ((info->bDeviceClass == 0xFF) && - (!(id->match_flag_vendor)) && - ((id->match_flag_int_class) || - (id->match_flag_int_subclass) || - (id->match_flag_int_protocol))) { - continue; - } if ((id->match_flag_int_class) && (id->bInterfaceClass != info->bInterfaceClass)) { continue; @@ -151,3 +146,108 @@ usbd_lookup_id_by_uaa(const struct usb_d } return (ENXIO); } + +/*------------------------------------------------------------------------* + * Export the USB device ID format we use to userspace tools. + *------------------------------------------------------------------------*/ +#if BYTE_ORDER == BIG_ENDIAN +#define U16_XOR "8" +#define U32_XOR "12" +#define U64_XOR "56" +#define U8_BITFIELD_XOR "7" +#define U16_BITFIELD_XOR "15" +#define U32_BITFIELD_XOR "31" +#define U64_BITFIELD_XOR "63" +#else +#define U16_XOR "0" +#define U32_XOR "0" +#define U64_XOR "0" +#define U8_BITFIELD_XOR "0" +#define U16_BITFIELD_XOR "0" +#define U32_BITFIELD_XOR "0" +#define U64_BITFIELD_XOR "0" +#endif + +#if USB_HAVE_COMPAT_LINUX +#define MFL_SIZE "1" +#else +#define MFL_SIZE "0" +#endif + +#ifdef KLD_MODULE +static const char __section("bus_autoconf_format") __used usb_id_format[] = { + + /* Declare that three different sections use the same format */ + + "usb_host_id{256,:}" + "usb_device_id{256,:}" + "usb_dual_id{256,:}" + + /* List size of fields in the usb_device_id structure */ + +#if ULONG_MAX >= 0xFFFFFFFFUL + "unused{0,8}" + "unused{0,8}" + "unused{0,8}" + "unused{0,8}" +#if ULONG_MAX >= 0xFFFFFFFFFFFFFFFFULL + "unused{0,8}" + "unused{0,8}" + "unused{0,8}" + "unused{0,8}" +#endif +#else +#error "Please update code." +#endif + + "idVendor[0]{" U16_XOR ",8}" + "idVendor[1]{" U16_XOR ",8}" + "idProduct[0]{" U16_XOR ",8}" + "idProduct[1]{" U16_XOR ",8}" + "bcdDevice_lo[0]{" U16_XOR ",8}" + "bcdDevice_lo[1]{" U16_XOR ",8}" + "bcdDevice_hi[0]{" U16_XOR ",8}" + "bcdDevice_hi[1]{" U16_XOR ",8}" + + "bDeviceClass{0,8}" + "bDeviceSubClass{0,8}" + "bDeviceProtocol{0,8}" + "bInterfaceClass{0,8}" + "bInterfaceSubClass{0,8}" + "bInterfaceProtocol{0,8}" + + "mf_vendor{" U8_BITFIELD_XOR ",1}" + "mf_product{" U8_BITFIELD_XOR ",1}" + "mf_dev_lo{" U8_BITFIELD_XOR ",1}" + "mf_dev_hi{" U8_BITFIELD_XOR ",1}" + + "mf_dev_class{" U8_BITFIELD_XOR ",1}" + "mf_dev_subclass{" U8_BITFIELD_XOR ",1}" + "mf_dev_protocol{" U8_BITFIELD_XOR ",1}" + "mf_int_class{" U8_BITFIELD_XOR ",1}" + + "mf_int_subclass{" U8_BITFIELD_XOR ",1}" + "mf_int_protocol{" U8_BITFIELD_XOR ",1}" + "unused{" U8_BITFIELD_XOR ",6}" + + "mfl_vendor{" U16_XOR "," MFL_SIZE "}" + "mfl_product{" U16_XOR "," MFL_SIZE "}" + "mfl_dev_lo{" U16_XOR "," MFL_SIZE "}" + "mfl_dev_hi{" U16_XOR "," MFL_SIZE "}" + + "mfl_dev_class{" U16_XOR "," MFL_SIZE "}" + "mfl_dev_subclass{" U16_XOR "," MFL_SIZE "}" + "mfl_dev_protocol{" U16_XOR "," MFL_SIZE "}" + "mfl_int_class{" U16_XOR "," MFL_SIZE "}" + + "mfl_int_subclass{" U16_XOR "," MFL_SIZE "}" + "mfl_int_protocol{" U16_XOR "," MFL_SIZE "}" + "unused{" U16_XOR "," MFL_SIZE "}" + "unused{" U16_XOR "," MFL_SIZE "}" + + "unused{" U16_XOR "," MFL_SIZE "}" + "unused{" U16_XOR "," MFL_SIZE "}" + "unused{" U16_XOR "," MFL_SIZE "}" + "unused{" U16_XOR "," MFL_SIZE "}" +}; +#endif Modified: stable/8/sys/dev/usb/usb_msctest.c ============================================================================== --- stable/8/sys/dev/usb/usb_msctest.c Mon Jun 27 20:32:19 2011 (r223604) +++ stable/8/sys/dev/usb/usb_msctest.c Mon Jun 27 20:59:43 2011 (r223605) @@ -489,6 +489,24 @@ bbb_attach(struct usb_device *udev, uint struct usb_interface_descriptor *id; struct bbb_transfer *sc; usb_error_t err; + uint8_t do_unlock; + + /* automatic locking */ + if (usbd_enum_is_locked(udev)) { + do_unlock = 0; + } else { + do_unlock = 1; + usbd_enum_lock(udev); + } + + /* + * Make sure any driver which is hooked up to this interface, + * like umass is gone: + */ + usb_detach_device(udev, iface_index, 0); + + if (do_unlock) + usbd_enum_unlock(udev); iface = usbd_get_iface(udev, iface_index); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 21:04:35 2011 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 9DA731065674; Mon, 27 Jun 2011 21:04:35 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8AD358FC0C; Mon, 27 Jun 2011 21:04:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RL4Zej013732; Mon, 27 Jun 2011 21:04:35 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RL4Zhh013719; Mon, 27 Jun 2011 21:04:35 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201106272104.p5RL4Zhh013719@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 27 Jun 2011 21:04:35 +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: r223606 - in stable/8/sys: conf dev/usb dev/usb/template modules/usb/template 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, 27 Jun 2011 21:04:35 -0000 Author: hselasky Date: Mon Jun 27 21:04:35 2011 New Revision: 223606 URL: http://svn.freebsd.org/changeset/base/223606 Log: MFC r223467 and r223472: - Add more USB templates for various USB device classes - Add basic template support for USB 3.0 - Export definition of template sysctl numbers through usb_ioctl.h Added: stable/8/sys/dev/usb/template/usb_template_audio.c - copied, changed from r223467, head/sys/dev/usb/template/usb_template_audio.c stable/8/sys/dev/usb/template/usb_template_kbd.c - copied, changed from r223467, head/sys/dev/usb/template/usb_template_kbd.c stable/8/sys/dev/usb/template/usb_template_modem.c - copied unchanged from r223467, head/sys/dev/usb/template/usb_template_modem.c stable/8/sys/dev/usb/template/usb_template_mouse.c - copied, changed from r223467, head/sys/dev/usb/template/usb_template_mouse.c Modified: stable/8/sys/conf/files stable/8/sys/dev/usb/template/usb_template.c stable/8/sys/dev/usb/template/usb_template.h stable/8/sys/dev/usb/template/usb_template_cdce.c stable/8/sys/dev/usb/template/usb_template_msc.c stable/8/sys/dev/usb/template/usb_template_mtp.c stable/8/sys/dev/usb/usb_ioctl.h stable/8/sys/modules/usb/template/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) Modified: stable/8/sys/conf/files ============================================================================== --- stable/8/sys/conf/files Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/conf/files Mon Jun 27 21:04:35 2011 (r223606) @@ -1855,8 +1855,12 @@ dev/usb/quirk/usb_quirk.c optional usb # # USB templates # -dev/usb/template/usb_template.c optional usb_template +dev/usb/template/usb_template.c optional usb_template +dev/usb/template/usb_template_audio.c optional usb_template dev/usb/template/usb_template_cdce.c optional usb_template +dev/usb/template/usb_template_kbd.c optional usb_template +dev/usb/template/usb_template_modem.c optional usb_template +dev/usb/template/usb_template_mouse.c optional usb_template dev/usb/template/usb_template_msc.c optional usb_template dev/usb/template/usb_template_mtp.c optional usb_template # Modified: stable/8/sys/dev/usb/template/usb_template.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template.c Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/template/usb_template.c Mon Jun 27 21:04:35 2011 (r223606) @@ -49,6 +49,7 @@ #include #include +#include #include #include #include "usbdevs.h" @@ -141,6 +142,31 @@ usb_make_raw_desc(struct usb_temp_setup ud->bSlaveInterface[0] += temp->bInterfaceNumber; } + + /* check if we have got an interface association descriptor */ + + if ((raw[0] >= sizeof(struct usb_interface_assoc_descriptor)) && + (raw[1] == UDESC_IFACE_ASSOC)) { + struct usb_interface_assoc_descriptor *iad = (void *)dst; + + /* update the interface number */ + + iad->bFirstInterface += + temp->bInterfaceNumber; + } + + /* check if we have got a call management descriptor */ + + if ((raw[0] >= sizeof(struct usb_cdc_cm_descriptor)) && + (raw[1] == UDESC_CS_INTERFACE) && + (raw[2] == UDESCSUB_CDC_CM)) { + struct usb_cdc_cm_descriptor *ccd = (void *)dst; + + /* update the interface number */ + + ccd->bDataInterface += + temp->bInterfaceNumber; + } } temp->size += len; } @@ -476,6 +502,10 @@ usb_make_device_desc(struct usb_temp_set USETW(utd->udd.bcdUSB, 0x0250); utd->udd.bMaxPacketSize = 255; /* 512 bytes */ break; + case USB_SPEED_SUPER: + USETW(utd->udd.bcdUSB, 0x0300); + utd->udd.bMaxPacketSize = 9; /* 2**9 = 512 bytes */ + break; default: temp->err = USB_ERR_INVAL; break; @@ -1303,15 +1333,27 @@ usb_temp_setup_by_index(struct usb_devic usb_error_t err; switch (index) { - case 0: + case USB_TEMP_MSC: err = usb_temp_setup(udev, &usb_template_msc); break; - case 1: + case USB_TEMP_CDCE: err = usb_temp_setup(udev, &usb_template_cdce); break; - case 2: + case USB_TEMP_MTP: err = usb_temp_setup(udev, &usb_template_mtp); break; + case USB_TEMP_MODEM: + err = usb_temp_setup(udev, &usb_template_modem); + break; + case USB_TEMP_AUDIO: + err = usb_temp_setup(udev, &usb_template_audio); + break; + case USB_TEMP_KBD: + err = usb_temp_setup(udev, &usb_template_kbd); + break; + case USB_TEMP_MOUSE: + err = usb_temp_setup(udev, &usb_template_mouse); + break; default: return (USB_ERR_INVAL); } Modified: stable/8/sys/dev/usb/template/usb_template.h ============================================================================== --- stable/8/sys/dev/usb/template/usb_template.h Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/template/usb_template.h Mon Jun 27 21:04:35 2011 (r223606) @@ -30,6 +30,10 @@ #ifndef _USB_TEMPLATE_H_ #define _USB_TEMPLATE_H_ +#ifndef USB_TEMPLATE_VENDOR +#define USB_TEMPLATE_VENDOR 0x0001 +#endif + typedef const void *(usb_temp_get_string_desc_t)(uint16_t lang_id, uint8_t string_index); typedef const void *(usb_temp_get_vendor_desc_t)(const struct usb_device_request *req, uint16_t *plen); @@ -94,10 +98,14 @@ struct usb_temp_data { /* prototypes */ +extern const struct usb_temp_device_desc usb_template_audio; extern const struct usb_temp_device_desc usb_template_cdce; -extern const struct usb_temp_device_desc usb_template_msc; /* Mass Storage Class */ -extern const struct usb_temp_device_desc usb_template_mtp; /* Message Transfer - * Protocol */ +extern const struct usb_temp_device_desc usb_template_kbd; +extern const struct usb_temp_device_desc usb_template_modem; +extern const struct usb_temp_device_desc usb_template_mouse; +extern const struct usb_temp_device_desc usb_template_msc; +extern const struct usb_temp_device_desc usb_template_mtp; + usb_error_t usb_temp_setup(struct usb_device *, const struct usb_temp_device_desc *); void usb_temp_unsetup(struct usb_device *); Copied and modified: stable/8/sys/dev/usb/template/usb_template_audio.c (from r223467, head/sys/dev/usb/template/usb_template_audio.c) ============================================================================== --- head/sys/dev/usb/template/usb_template_audio.c Thu Jun 23 07:54:03 2011 (r223467, copy source) +++ stable/8/sys/dev/usb/template/usb_template_audio.c Mon Jun 27 21:04:35 2011 (r223606) @@ -95,7 +95,12 @@ USB_MAKE_STRING_DESC(STRING_AUDIO_PRODUC /* prototypes */ -/* Audio Mixer description structures */ +/* + * Audio Mixer description structures + * + * Some of the audio descriptors were dumped + * from a Creative Labs USB audio device. + */ static const uint8_t audio_raw_desc_0[] = { 0x0a, 0x24, 0x01, 0x00, 0x01, 0xa9, 0x00, 0x02, Modified: stable/8/sys/dev/usb/template/usb_template_cdce.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template_cdce.c Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/template/usb_template_cdce.c Mon Jun 27 21:04:35 2011 (r223606) @@ -264,7 +264,7 @@ static const struct usb_temp_config_desc const struct usb_temp_device_desc usb_template_cdce = { .getStringDesc = ð_get_string_desc, .ppConfigDesc = eth_configs, - .idVendor = 0x0001, + .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x0001, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, Copied and modified: stable/8/sys/dev/usb/template/usb_template_kbd.c (from r223467, head/sys/dev/usb/template/usb_template_kbd.c) ============================================================================== --- head/sys/dev/usb/template/usb_template_kbd.c Thu Jun 23 07:54:03 2011 (r223467, copy source) +++ stable/8/sys/dev/usb/template/usb_template_kbd.c Mon Jun 27 21:04:35 2011 (r223606) @@ -94,6 +94,8 @@ static const struct usb_temp_interval ke .bInterval[USB_SPEED_HIGH] = 2 * 8, }; +/* The following HID descriptor was dumped from a HP keyboard. */ + static uint8_t keyboard_hid_descriptor[] = { 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, Copied: stable/8/sys/dev/usb/template/usb_template_modem.c (from r223467, head/sys/dev/usb/template/usb_template_modem.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/dev/usb/template/usb_template_modem.c Mon Jun 27 21:04:35 2011 (r223606, copy of r223467, head/sys/dev/usb/template/usb_template_modem.c) @@ -0,0 +1,252 @@ +#include +__FBSDID("$FreeBSD$"); + +/*- + * Copyright (c) 2010 Hans Petter Selasky. 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. + */ + +/* + * This file contains the USB template for an USB Modem Device. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +enum { + INDEX_LANG, + INDEX_MODEM, + INDEX_PRODUCT, + INDEX_MAX, +}; + +#define STRING_LANG \ + 0x09, 0x04, /* American English */ + +#define STRING_PRODUCT \ + 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \ + 'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \ + 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0, + +#define STRING_MODEM \ + 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \ + 'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0, + +/* make the real string descriptors */ + +USB_MAKE_STRING_DESC(STRING_LANG, string_lang); +USB_MAKE_STRING_DESC(STRING_MODEM, string_modem); +USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); + +#define MODEM_IFACE_0 0 +#define MODEM_IFACE_1 1 + +/* prototypes */ + +static const struct usb_temp_packet_size modem_bulk_mps = { + .mps[USB_SPEED_LOW] = 8, + .mps[USB_SPEED_FULL] = 64, + .mps[USB_SPEED_HIGH] = 512, +}; + +static const struct usb_temp_packet_size modem_intr_mps = { + .mps[USB_SPEED_LOW] = 8, + .mps[USB_SPEED_FULL] = 8, + .mps[USB_SPEED_HIGH] = 8, +}; + +static const struct usb_temp_interval modem_intr_interval = { + .bInterval[USB_SPEED_LOW] = 10, + .bInterval[USB_SPEED_FULL] = 10, + .bInterval[USB_SPEED_HIGH] = 10 * 8, +}; + +static const struct usb_temp_endpoint_desc modem_ep_0 = { + .pPacketSize = &modem_intr_mps, + .pIntervals = &modem_intr_interval, + .bEndpointAddress = UE_DIR_IN, + .bmAttributes = UE_INTERRUPT, +}; + +static const struct usb_temp_endpoint_desc modem_ep_1 = { + .pPacketSize = &modem_bulk_mps, + .bEndpointAddress = UE_DIR_OUT, + .bmAttributes = UE_BULK, +}; + +static const struct usb_temp_endpoint_desc modem_ep_2 = { + .pPacketSize = &modem_bulk_mps, + .bEndpointAddress = UE_DIR_IN, + .bmAttributes = UE_BULK, +}; + +static const struct usb_temp_endpoint_desc *modem_iface_0_ep[] = { + &modem_ep_0, + NULL, +}; + +static const struct usb_temp_endpoint_desc *modem_iface_1_ep[] = { + &modem_ep_1, + &modem_ep_2, + NULL, +}; + +static const uint8_t modem_raw_desc_0[] = { + 0x05, 0x24, 0x00, 0x10, 0x01 +}; + +static const uint8_t modem_raw_desc_1[] = { + 0x05, 0x24, 0x06, MODEM_IFACE_0, MODEM_IFACE_1 +}; + +static const uint8_t modem_raw_desc_2[] = { + 0x05, 0x24, 0x01, 0x03, MODEM_IFACE_1 +}; + +static const uint8_t modem_raw_desc_3[] = { + 0x04, 0x24, 0x02, 0x07 +}; + +static const void *modem_iface_0_desc[] = { + &modem_raw_desc_0, + &modem_raw_desc_1, + &modem_raw_desc_2, + &modem_raw_desc_3, + NULL, +}; + +static const struct usb_temp_interface_desc modem_iface_0 = { + .ppRawDesc = modem_iface_0_desc, + .ppEndpoints = modem_iface_0_ep, + .bInterfaceClass = 2, + .bInterfaceSubClass = 2, + .bInterfaceProtocol = 1, + .iInterface = INDEX_MODEM, +}; + +static const struct usb_temp_interface_desc modem_iface_1 = { + .ppEndpoints = modem_iface_1_ep, + .bInterfaceClass = 10, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0, + .iInterface = INDEX_MODEM, +}; + +static const struct usb_temp_interface_desc *modem_interfaces[] = { + &modem_iface_0, + &modem_iface_1, + NULL, +}; + +static const struct usb_temp_config_desc modem_config_desc = { + .ppIfaceDesc = modem_interfaces, + .bmAttributes = UC_BUS_POWERED, + .bMaxPower = 25, /* 50 mA */ + .iConfiguration = INDEX_PRODUCT, +}; + +static const struct usb_temp_config_desc *modem_configs[] = { + &modem_config_desc, + NULL, +}; + +static usb_temp_get_string_desc_t modem_get_string_desc; +static usb_temp_get_vendor_desc_t modem_get_vendor_desc; + +const struct usb_temp_device_desc usb_template_modem = { + .getStringDesc = &modem_get_string_desc, + .getVendorDesc = &modem_get_vendor_desc, + .ppConfigDesc = modem_configs, + .idVendor = USB_TEMPLATE_VENDOR, + .idProduct = 0x000E, + .bcdDevice = 0x0100, + .bDeviceClass = UDCLASS_COMM, + .bDeviceSubClass = 0, + .bDeviceProtocol = 0, + .iManufacturer = 0, + .iProduct = INDEX_PRODUCT, + .iSerialNumber = 0, +}; + +/*------------------------------------------------------------------------* + * modem_get_vendor_desc + * + * Return values: + * NULL: Failure. No such vendor descriptor. + * Else: Success. Pointer to vendor descriptor is returned. + *------------------------------------------------------------------------*/ +static const void * +modem_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) +{ + return (NULL); +} + +/*------------------------------------------------------------------------* + * modem_get_string_desc + * + * Return values: + * NULL: Failure. No such string. + * Else: Success. Pointer to string descriptor is returned. + *------------------------------------------------------------------------*/ +static const void * +modem_get_string_desc(uint16_t lang_id, uint8_t string_index) +{ + static const void *ptr[INDEX_MAX] = { + [INDEX_LANG] = &string_lang, + [INDEX_MODEM] = &string_modem, + [INDEX_PRODUCT] = &string_product, + }; + + if (string_index == 0) { + return (&string_lang); + } + if (lang_id != 0x0409) { + return (NULL); + } + if (string_index < INDEX_MAX) { + return (ptr[string_index]); + } + return (NULL); +} Copied and modified: stable/8/sys/dev/usb/template/usb_template_mouse.c (from r223467, head/sys/dev/usb/template/usb_template_mouse.c) ============================================================================== --- head/sys/dev/usb/template/usb_template_mouse.c Thu Jun 23 07:54:03 2011 (r223467, copy source) +++ stable/8/sys/dev/usb/template/usb_template_mouse.c Mon Jun 27 21:04:35 2011 (r223606) @@ -82,6 +82,8 @@ USB_MAKE_STRING_DESC(STRING_PRODUCT, str /* prototypes */ +/* The following HID descriptor was dumped from a HP mouse. */ + static uint8_t mouse_hid_descriptor[] = { 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, Modified: stable/8/sys/dev/usb/template/usb_template_msc.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template_msc.c Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/template/usb_template_msc.c Mon Jun 27 21:04:35 2011 (r223606) @@ -173,8 +173,8 @@ static const struct usb_temp_config_desc const struct usb_temp_device_desc usb_template_msc = { .getStringDesc = &msc_get_string_desc, .ppConfigDesc = msc_configs, - .idVendor = 0x0001, - .idProduct = 0x0001, + .idVendor = USB_TEMPLATE_VENDOR, + .idProduct = 0x0012, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, Modified: stable/8/sys/dev/usb/template/usb_template_mtp.c ============================================================================== --- stable/8/sys/dev/usb/template/usb_template_mtp.c Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/template/usb_template_mtp.c Mon Jun 27 21:04:35 2011 (r223606) @@ -191,8 +191,8 @@ const struct usb_temp_device_desc usb_te .getStringDesc = &mtp_get_string_desc, .getVendorDesc = &mtp_get_vendor_desc, .ppConfigDesc = mtp_configs, - .idVendor = 0x0001, - .idProduct = 0x0001, + .idVendor = USB_TEMPLATE_VENDOR, + .idProduct = 0x0011, .bcdDevice = 0x0100, .bDeviceClass = 0, .bDeviceSubClass = 0, Modified: stable/8/sys/dev/usb/usb_ioctl.h ============================================================================== --- stable/8/sys/dev/usb/usb_ioctl.h Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/dev/usb/usb_ioctl.h Mon Jun 27 21:04:35 2011 (r223606) @@ -39,6 +39,20 @@ #define USB_DEVICE_NAME "usbctl" #define USB_DEVICE_DIR "usb" #define USB_GENERIC_NAME "ugen" +#define USB_TEMPLATE_SYSCTL "hw.usb.template" /* integer type */ + +/* Definition of valid template sysctl values */ + +enum { + USB_TEMP_MSC, /* USB Mass Storage */ + USB_TEMP_CDCE, /* USB CDC Ethernet */ + USB_TEMP_MTP, /* Message Transfer Protocol */ + USB_TEMP_MODEM, /* USB CDC Modem */ + USB_TEMP_AUDIO, /* USB Audio */ + USB_TEMP_KBD, /* USB Keyboard */ + USB_TEMP_MOUSE, /* USB Mouse */ + USB_TEMP_MAX, +}; struct usb_read_dir { #ifdef COMPAT_32BIT Modified: stable/8/sys/modules/usb/template/Makefile ============================================================================== --- stable/8/sys/modules/usb/template/Makefile Mon Jun 27 20:59:43 2011 (r223605) +++ stable/8/sys/modules/usb/template/Makefile Mon Jun 27 21:04:35 2011 (r223606) @@ -31,6 +31,13 @@ S= ${.CURDIR}/../../.. KMOD= usb_template SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \ - usb_template.c usb_template_cdce.c usb_template_msc.c usb_template_mtp.c + usb_template.c \ + usb_template_audio.c \ + usb_template_cdce.c \ + usb_template_kbd.c \ + usb_template_modem.c \ + usb_template_mouse.c \ + usb_template_msc.c \ + usb_template_mtp.c .include From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 21:14:25 2011 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 73B82106566B; Mon, 27 Jun 2011 21:14:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5B9C28FC08; Mon, 27 Jun 2011 21:14:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RLEP05014075; Mon, 27 Jun 2011 21:14:25 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RLEPIN014073; Mon, 27 Jun 2011 21:14:25 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201106272114.p5RLEPIN014073@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 27 Jun 2011 21:14: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: r223607 - stable/8/sys/dev/usb/serial 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, 27 Jun 2011 21:14:25 -0000 Author: hselasky Date: Mon Jun 27 21:14:25 2011 New Revision: 223607 URL: http://svn.freebsd.org/changeset/base/223607 Log: Add missing chunk in MFC of r215095. Modified: stable/8/sys/dev/usb/serial/u3g.c Modified: stable/8/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/8/sys/dev/usb/serial/u3g.c Mon Jun 27 21:04:35 2011 (r223606) +++ stable/8/sys/dev/usb/serial/u3g.c Mon Jun 27 21:14:25 2011 (r223607) @@ -684,9 +684,9 @@ u3g_test_autoinst(void *arg, struct usb_ return; /* no device match */ if (bootverbose) { - printf("Ejecting 0x%04x:0x%04x using method %ld\n", - uaa->info.idVendor, uaa->info.idProduct, - USB_GET_DRIVER_INFO(uaa)); + printf("Ejecting %s %s using method %ld\n", + usb_get_manufacturer(udev), + usb_get_product(udev), method); } switch (method) { From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 21:30:05 2011 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 733401065673; Mon, 27 Jun 2011 21:30:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C21A8FC0A; Mon, 27 Jun 2011 21:30:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RLU5K5014639; Mon, 27 Jun 2011 21:30:05 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RLU5og014637; Mon, 27 Jun 2011 21:30:05 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201106272130.p5RLU5og014637@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 27 Jun 2011 21:30: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: r223609 - in stable/8/sys/dev/usb: . wlan 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, 27 Jun 2011 21:30:05 -0000 Author: hselasky Date: Mon Jun 27 21:30:04 2011 New Revision: 223609 URL: http://svn.freebsd.org/changeset/base/223609 Log: MFC r219257: Add new USB ID. PR: usb/155229 Modified: stable/8/sys/dev/usb/usbdevs stable/8/sys/dev/usb/wlan/if_run.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) Modified: stable/8/sys/dev/usb/usbdevs ============================================================================== --- stable/8/sys/dev/usb/usbdevs Mon Jun 27 21:27:12 2011 (r223608) +++ stable/8/sys/dev/usb/usbdevs Mon Jun 27 21:30:04 2011 (r223609) @@ -2160,6 +2160,7 @@ product MELCO WLIUCG 0x0137 WLI-UC-G product MELCO RT2870_1 0x0148 RT2870 product MELCO RT2870_2 0x0150 RT2870 product MELCO WLIUCGN 0x015d WLI-UC-GN +product MELCO WLIUCG301N 0x016f WLI-UC-G301N /* Merlin products */ product MERLIN V620 0x1110 Merlin V620 Modified: stable/8/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_run.c Mon Jun 27 21:27:12 2011 (r223608) +++ stable/8/sys/dev/usb/wlan/if_run.c Mon Jun 27 21:30:04 2011 (r223609) @@ -210,6 +210,7 @@ static const STRUCT_USB_HOST_ID run_devs RUN_DEV(MELCO, RT2870_2), RUN_DEV(MELCO, WLIUCAG300N), RUN_DEV(MELCO, WLIUCG300N), + RUN_DEV(MELCO, WLIUCG301N), RUN_DEV(MELCO, WLIUCGN), RUN_DEV(MOTOROLA4, RT2770), RUN_DEV(MOTOROLA4, RT3070), From owner-svn-src-stable-8@FreeBSD.ORG Mon Jun 27 21:45:36 2011 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 341DB106564A; Mon, 27 Jun 2011 21:45:36 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2244E8FC17; Mon, 27 Jun 2011 21:45:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5RLjavd015231; Mon, 27 Jun 2011 21:45:36 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5RLja4X015226; Mon, 27 Jun 2011 21:45:36 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201106272145.p5RLja4X015226@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 27 Jun 2011 21:45: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: r223612 - stable/8/lib/libusb 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, 27 Jun 2011 21:45:36 -0000 Author: hselasky Date: Mon Jun 27 21:45:35 2011 New Revision: 223612 URL: http://svn.freebsd.org/changeset/base/223612 Log: MFC r223495: - Add two new API's to libusb20 which can be used to retrive information about the parent USB device (which is usually an USB HUB): - libusb20_dev_get_parent_address - libusb20_dev_get_parent_port - Rename libusb20_compat01.c into libusb01.c Added: stable/8/lib/libusb/libusb01.c - copied unchanged from r223495, head/lib/libusb/libusb01.c Deleted: stable/8/lib/libusb/libusb20_compat01.c Modified: stable/8/lib/libusb/Makefile stable/8/lib/libusb/libusb20.3 stable/8/lib/libusb/libusb20.c stable/8/lib/libusb/libusb20.h stable/8/lib/libusb/libusb20_int.h stable/8/lib/libusb/libusb20_ugen20.c Directory Properties: stable/8/lib/libusb/ (props changed) stable/8/lib/libusb/usb.h (props changed) Modified: stable/8/lib/libusb/Makefile ============================================================================== --- stable/8/lib/libusb/Makefile Mon Jun 27 21:43:56 2011 (r223611) +++ stable/8/lib/libusb/Makefile Mon Jun 27 21:45:35 2011 (r223612) @@ -20,7 +20,7 @@ MLINKS+= libusb.3 usb.3 # libusb 0.1 compat INCS+= usb.h -SRCS+= libusb20_compat01.c +SRCS+= libusb01.c # libusb 1.0 compat INCS+= libusb.h @@ -182,6 +182,8 @@ MLINKS += libusb20.3 libusb20_dev_get_de MLINKS += libusb20.3 libusb20_dev_alloc_config.3 MLINKS += libusb20.3 libusb20_dev_alloc.3 MLINKS += libusb20.3 libusb20_dev_get_address.3 +MLINKS += libusb20.3 libusb20_dev_get_parent_address.3 +MLINKS += libusb20.3 libusb20_dev_get_parent_port.3 MLINKS += libusb20.3 libusb20_dev_get_bus_number.3 MLINKS += libusb20.3 libusb20_dev_get_mode.3 MLINKS += libusb20.3 libusb20_dev_get_speed.3 Copied: stable/8/lib/libusb/libusb01.c (from r223495, head/lib/libusb/libusb01.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/lib/libusb/libusb01.c Mon Jun 27 21:45:35 2011 (r223612, copy of r223495, head/lib/libusb/libusb01.c) @@ -0,0 +1,945 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2008 Hans Petter Selasky. 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. + */ + +/* + * This file contains the emulation layer for LibUSB v0.1 from sourceforge. + */ + +#include + +#include +#include +#include + +#include "libusb20.h" +#include "libusb20_desc.h" +#include "libusb20_int.h" +#include "usb.h" + +/* + * The two following macros were taken from the original LibUSB v0.1 + * for sake of compatibility: + */ +#define LIST_ADD(begin, ent) \ + do { \ + if (begin) { \ + ent->next = begin; \ + ent->next->prev = ent; \ + } else { \ + ent->next = NULL; \ + } \ + ent->prev = NULL; \ + begin = ent; \ + } while(0) + +#define LIST_DEL(begin, ent) \ + do { \ + if (ent->prev) { \ + ent->prev->next = ent->next; \ + } else { \ + begin = ent->next; \ + } \ + if (ent->next) { \ + ent->next->prev = ent->prev; \ + } \ + ent->prev = NULL; \ + ent->next = NULL; \ + } while (0) + +struct usb_bus *usb_busses = NULL; + +static struct usb_bus usb_global_bus = { + .dirname = {"/dev/usb"}, + .root_dev = NULL, + .devices = NULL, +}; + +static struct libusb20_backend *usb_backend = NULL; + +struct usb_parse_state { + + struct { + struct libusb20_endpoint *currep; + struct libusb20_interface *currifc; + struct libusb20_config *currcfg; + struct libusb20_me_struct *currextra; + } a; + + struct { + struct usb_config_descriptor *currcfg; + struct usb_interface_descriptor *currifc; + struct usb_endpoint_descriptor *currep; + struct usb_interface *currifcw; + uint8_t *currextra; + } b; + + uint8_t preparse; +}; + +static struct libusb20_transfer * +usb_get_transfer_by_ep_no(usb_dev_handle * dev, uint8_t ep_no) +{ + struct libusb20_device *pdev = (void *)dev; + struct libusb20_transfer *xfer; + int err; + uint32_t bufsize; + uint8_t x; + uint8_t speed; + + x = (ep_no & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 2; + + if (ep_no & LIBUSB20_ENDPOINT_DIR_MASK) { + /* this is an IN endpoint */ + x |= 1; + } + speed = libusb20_dev_get_speed(pdev); + + /* select a sensible buffer size */ + if (speed == LIBUSB20_SPEED_LOW) { + bufsize = 256; + } else if (speed == LIBUSB20_SPEED_FULL) { + bufsize = 4096; + } else { + bufsize = 16384; + } + + xfer = libusb20_tr_get_pointer(pdev, x); + + if (xfer == NULL) + return (xfer); + + err = libusb20_tr_open(xfer, bufsize, 1, ep_no); + if (err == LIBUSB20_ERROR_BUSY) { + /* already opened */ + return (xfer); + } else if (err) { + return (NULL); + } + /* success */ + return (xfer); +} + +usb_dev_handle * +usb_open(struct usb_device *dev) +{ + int err; + + err = libusb20_dev_open(dev->dev, 16 * 2); + if (err == LIBUSB20_ERROR_BUSY) { + /* + * Workaround buggy USB applications which open the USB + * device multiple times: + */ + return (dev->dev); + } + if (err) + return (NULL); + + /* + * Dequeue USB device from backend queue so that it does not get + * freed when the backend is re-scanned: + */ + libusb20_be_dequeue_device(usb_backend, dev->dev); + + return (dev->dev); +} + +int +usb_close(usb_dev_handle * udev) +{ + struct usb_device *dev; + int err; + + err = libusb20_dev_close((void *)udev); + + if (err) + return (-1); + + if (usb_backend != NULL) { + /* + * Enqueue USB device to backend queue so that it gets freed + * when the backend is re-scanned: + */ + libusb20_be_enqueue_device(usb_backend, (void *)udev); + } else { + /* + * The backend is gone. Free device data so that we + * don't start leaking memory! + */ + dev = usb_device(udev); + libusb20_dev_free((void *)udev); + LIST_DEL(usb_global_bus.devices, dev); + free(dev); + } + return (0); +} + +int +usb_get_string(usb_dev_handle * dev, int strindex, + int langid, char *buf, size_t buflen) +{ + int err; + + err = libusb20_dev_req_string_sync((void *)dev, + strindex, langid, buf, buflen); + + if (err) + return (-1); + + return (0); +} + +int +usb_get_string_simple(usb_dev_handle * dev, int strindex, + char *buf, size_t buflen) +{ + int err; + + err = libusb20_dev_req_string_simple_sync((void *)dev, + strindex, buf, buflen); + + if (err) + return (-1); + + return (strlen(buf)); +} + +int +usb_get_descriptor_by_endpoint(usb_dev_handle * udev, int ep, uint8_t type, + uint8_t ep_index, void *buf, int size) +{ + memset(buf, 0, size); + + return (usb_control_msg(udev, ep | USB_ENDPOINT_IN, + USB_REQ_GET_DESCRIPTOR, (type << 8) + ep_index, 0, + buf, size, 1000)); +} + +int +usb_get_descriptor(usb_dev_handle * udev, uint8_t type, uint8_t desc_index, + void *buf, int size) +{ + memset(buf, 0, size); + + return (usb_control_msg(udev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, + (type << 8) + desc_index, 0, buf, size, 1000)); +} + +int +usb_parse_descriptor(uint8_t *source, char *description, void *dest) +{ + uint8_t *sp = source; + uint8_t *dp = dest; + uint16_t w; + uint32_t d; + char *cp; + + for (cp = description; *cp; cp++) { + switch (*cp) { + case 'b': /* 8-bit byte */ + *dp++ = *sp++; + break; + /* + * 16-bit word, convert from little endian to CPU + */ + case 'w': + w = (sp[1] << 8) | sp[0]; + sp += 2; + /* Align to word boundary */ + dp += ((dp - (uint8_t *)0) & 1); + *((uint16_t *)dp) = w; + dp += 2; + break; + /* + * 32-bit dword, convert from little endian to CPU + */ + case 'd': + d = (sp[3] << 24) | (sp[2] << 16) | + (sp[1] << 8) | sp[0]; + sp += 4; + /* Align to word boundary */ + dp += ((dp - (uint8_t *)0) & 1); + /* Align to double word boundary */ + dp += ((dp - (uint8_t *)0) & 2); + *((uint32_t *)dp) = d; + dp += 4; + break; + } + } + return (sp - source); +} + +static void +usb_parse_extra(struct usb_parse_state *ps, uint8_t **pptr, int *plen) +{ + void *ptr; + uint16_t len; + + ptr = ps->a.currextra->ptr; + len = ps->a.currextra->len; + + if (ps->preparse == 0) { + memcpy(ps->b.currextra, ptr, len); + *pptr = ps->b.currextra; + *plen = len; + } + ps->b.currextra += len; + return; +} + +static void +usb_parse_endpoint(struct usb_parse_state *ps) +{ + struct usb_endpoint_descriptor *bep; + struct libusb20_endpoint *aep; + + aep = ps->a.currep; + bep = ps->b.currep++; + + if (ps->preparse == 0) { + /* copy descriptor fields */ + bep->bLength = aep->desc.bLength; + bep->bDescriptorType = aep->desc.bDescriptorType; + bep->bEndpointAddress = aep->desc.bEndpointAddress; + bep->bmAttributes = aep->desc.bmAttributes; + bep->wMaxPacketSize = aep->desc.wMaxPacketSize; + bep->bInterval = aep->desc.bInterval; + bep->bRefresh = aep->desc.bRefresh; + bep->bSynchAddress = aep->desc.bSynchAddress; + } + ps->a.currextra = &aep->extra; + usb_parse_extra(ps, &bep->extra, &bep->extralen); + return; +} + +static void +usb_parse_iface_sub(struct usb_parse_state *ps) +{ + struct libusb20_interface *aifc; + struct usb_interface_descriptor *bifc; + uint8_t x; + + aifc = ps->a.currifc; + bifc = ps->b.currifc++; + + if (ps->preparse == 0) { + /* copy descriptor fields */ + bifc->bLength = aifc->desc.bLength; + bifc->bDescriptorType = aifc->desc.bDescriptorType; + bifc->bInterfaceNumber = aifc->desc.bInterfaceNumber; + bifc->bAlternateSetting = aifc->desc.bAlternateSetting; + bifc->bNumEndpoints = aifc->num_endpoints; + bifc->bInterfaceClass = aifc->desc.bInterfaceClass; + bifc->bInterfaceSubClass = aifc->desc.bInterfaceSubClass; + bifc->bInterfaceProtocol = aifc->desc.bInterfaceProtocol; + bifc->iInterface = aifc->desc.iInterface; + bifc->endpoint = ps->b.currep; + } + for (x = 0; x != aifc->num_endpoints; x++) { + ps->a.currep = aifc->endpoints + x; + usb_parse_endpoint(ps); + } + + ps->a.currextra = &aifc->extra; + usb_parse_extra(ps, &bifc->extra, &bifc->extralen); + return; +} + +static void +usb_parse_iface(struct usb_parse_state *ps) +{ + struct libusb20_interface *aifc; + struct usb_interface *bifc; + uint8_t x; + + aifc = ps->a.currifc; + bifc = ps->b.currifcw++; + + if (ps->preparse == 0) { + /* initialise interface wrapper */ + bifc->altsetting = ps->b.currifc; + bifc->num_altsetting = aifc->num_altsetting + 1; + } + usb_parse_iface_sub(ps); + + for (x = 0; x != aifc->num_altsetting; x++) { + ps->a.currifc = aifc->altsetting + x; + usb_parse_iface_sub(ps); + } + return; +} + +static void +usb_parse_config(struct usb_parse_state *ps) +{ + struct libusb20_config *acfg; + struct usb_config_descriptor *bcfg; + uint8_t x; + + acfg = ps->a.currcfg; + bcfg = ps->b.currcfg; + + if (ps->preparse == 0) { + /* initialise config wrapper */ + bcfg->bLength = acfg->desc.bLength; + bcfg->bDescriptorType = acfg->desc.bDescriptorType; + bcfg->wTotalLength = acfg->desc.wTotalLength; + bcfg->bNumInterfaces = acfg->num_interface; + bcfg->bConfigurationValue = acfg->desc.bConfigurationValue; + bcfg->iConfiguration = acfg->desc.iConfiguration; + bcfg->bmAttributes = acfg->desc.bmAttributes; + bcfg->MaxPower = acfg->desc.bMaxPower; + bcfg->interface = ps->b.currifcw; + } + for (x = 0; x != acfg->num_interface; x++) { + ps->a.currifc = acfg->interface + x; + usb_parse_iface(ps); + } + + ps->a.currextra = &acfg->extra; + usb_parse_extra(ps, &bcfg->extra, &bcfg->extralen); + return; +} + +int +usb_parse_configuration(struct usb_config_descriptor *config, + uint8_t *buffer) +{ + struct usb_parse_state ps; + uint8_t *ptr; + uint32_t a; + uint32_t b; + uint32_t c; + uint32_t d; + + if ((buffer == NULL) || (config == NULL)) { + return (-1); + } + memset(&ps, 0, sizeof(ps)); + + ps.a.currcfg = libusb20_parse_config_desc(buffer); + ps.b.currcfg = config; + if (ps.a.currcfg == NULL) { + /* could not parse config or out of memory */ + return (-1); + } + /* do the pre-parse */ + ps.preparse = 1; + usb_parse_config(&ps); + + a = ((uint8_t *)(ps.b.currifcw) - ((uint8_t *)0)); + b = ((uint8_t *)(ps.b.currifc) - ((uint8_t *)0)); + c = ((uint8_t *)(ps.b.currep) - ((uint8_t *)0)); + d = ((uint8_t *)(ps.b.currextra) - ((uint8_t *)0)); + + /* allocate memory for our configuration */ + ptr = malloc(a + b + c + d); + if (ptr == NULL) { + /* free config structure */ + free(ps.a.currcfg); + return (-1); + } + + /* "currifcw" must be first, hence this pointer is freed */ + ps.b.currifcw = (void *)(ptr); + ps.b.currifc = (void *)(ptr + a); + ps.b.currep = (void *)(ptr + a + b); + ps.b.currextra = (void *)(ptr + a + b + c); + + /* generate a libusb v0.1 compatible structure */ + ps.preparse = 0; + usb_parse_config(&ps); + + /* free config structure */ + free(ps.a.currcfg); + + return (0); /* success */ +} + +void +usb_destroy_configuration(struct usb_device *dev) +{ + uint8_t c; + + if (dev->config == NULL) { + return; + } + for (c = 0; c != dev->descriptor.bNumConfigurations; c++) { + struct usb_config_descriptor *cf = &dev->config[c]; + + if (cf->interface != NULL) { + free(cf->interface); + cf->interface = NULL; + } + } + + free(dev->config); + dev->config = NULL; + return; +} + +void +usb_fetch_and_parse_descriptors(usb_dev_handle * udev) +{ + struct usb_device *dev; + struct libusb20_device *pdev; + uint8_t *ptr; + int error; + uint32_t size; + uint16_t len; + uint8_t x; + + if (udev == NULL) { + /* be NULL safe */ + return; + } + dev = usb_device(udev); + pdev = (void *)udev; + + if (dev->descriptor.bNumConfigurations == 0) { + /* invalid device */ + return; + } + size = dev->descriptor.bNumConfigurations * + sizeof(struct usb_config_descriptor); + + dev->config = malloc(size); + if (dev->config == NULL) { + /* out of memory */ + return; + } + memset(dev->config, 0, size); + + for (x = 0; x != dev->descriptor.bNumConfigurations; x++) { + + error = (pdev->methods->get_config_desc_full) ( + pdev, &ptr, &len, x); + + if (error) { + usb_destroy_configuration(dev); + return; + } + usb_parse_configuration(dev->config + x, ptr); + + /* free config buffer */ + free(ptr); + } + return; +} + +static int +usb_std_io(usb_dev_handle * dev, int ep, char *bytes, int size, + int timeout, int is_intr) +{ + struct libusb20_transfer *xfer; + uint32_t temp; + uint32_t maxsize; + uint32_t actlen; + char *oldbytes; + + xfer = usb_get_transfer_by_ep_no(dev, ep); + if (xfer == NULL) + return (-1); + + if (libusb20_tr_pending(xfer)) { + /* there is already a transfer ongoing */ + return (-1); + } + maxsize = libusb20_tr_get_max_total_length(xfer); + oldbytes = bytes; + + /* + * We allow transferring zero bytes which is the same + * equivalent to a zero length USB packet. + */ + do { + + temp = size; + if (temp > maxsize) { + /* find maximum possible length */ + temp = maxsize; + } + if (is_intr) + libusb20_tr_setup_intr(xfer, bytes, temp, timeout); + else + libusb20_tr_setup_bulk(xfer, bytes, temp, timeout); + + libusb20_tr_start(xfer); + + while (1) { + + if (libusb20_dev_process((void *)dev) != 0) { + /* device detached */ + return (-1); + } + if (libusb20_tr_pending(xfer) == 0) { + /* transfer complete */ + break; + } + /* wait for USB event from kernel */ + libusb20_dev_wait_process((void *)dev, -1); + } + + switch (libusb20_tr_get_status(xfer)) { + case 0: + /* success */ + break; + case LIBUSB20_TRANSFER_TIMED_OUT: + /* transfer timeout */ + return (-ETIMEDOUT); + default: + /* other transfer error */ + return (-ENXIO); + } + actlen = libusb20_tr_get_actual_length(xfer); + + bytes += actlen; + size -= actlen; + + if (actlen != temp) { + /* short transfer */ + break; + } + } while (size > 0); + + return (bytes - oldbytes); +} + +int +usb_bulk_write(usb_dev_handle * dev, int ep, char *bytes, + int size, int timeout) +{ + return (usb_std_io(dev, ep & ~USB_ENDPOINT_DIR_MASK, + bytes, size, timeout, 0)); +} + +int +usb_bulk_read(usb_dev_handle * dev, int ep, char *bytes, + int size, int timeout) +{ + return (usb_std_io(dev, ep | USB_ENDPOINT_DIR_MASK, + bytes, size, timeout, 0)); +} + +int +usb_interrupt_write(usb_dev_handle * dev, int ep, char *bytes, + int size, int timeout) +{ + return (usb_std_io(dev, ep & ~USB_ENDPOINT_DIR_MASK, + bytes, size, timeout, 1)); +} + +int +usb_interrupt_read(usb_dev_handle * dev, int ep, char *bytes, + int size, int timeout) +{ + return (usb_std_io(dev, ep | USB_ENDPOINT_DIR_MASK, + bytes, size, timeout, 1)); +} + +int +usb_control_msg(usb_dev_handle * dev, int requesttype, int request, + int value, int wIndex, char *bytes, int size, int timeout) +{ + struct LIBUSB20_CONTROL_SETUP_DECODED req; + int err; + uint16_t actlen; + + LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &req); + + req.bmRequestType = requesttype; + req.bRequest = request; + req.wValue = value; + req.wIndex = wIndex; + req.wLength = size; + + err = libusb20_dev_request_sync((void *)dev, &req, bytes, + &actlen, timeout, 0); + + if (err) + return (-1); + + return (actlen); +} + +int +usb_set_configuration(usb_dev_handle * udev, int bConfigurationValue) +{ + struct usb_device *dev; + int err; + uint8_t i; + + /* + * Need to translate from "bConfigurationValue" to + * configuration index: + */ + + if (bConfigurationValue == 0) { + /* unconfigure */ + i = 255; + } else { + /* lookup configuration index */ + dev = usb_device(udev); + + /* check if the configuration array is not there */ + if (dev->config == NULL) { + return (-1); + } + for (i = 0;; i++) { + if (i == dev->descriptor.bNumConfigurations) { + /* "bConfigurationValue" not found */ + return (-1); + } + if ((dev->config + i)->bConfigurationValue == + bConfigurationValue) { + break; + } + } + } + + err = libusb20_dev_set_config_index((void *)udev, i); + + if (err) + return (-1); + + return (0); +} + +int +usb_claim_interface(usb_dev_handle * dev, int interface) +{ + struct libusb20_device *pdev = (void *)dev; + + pdev->claimed_interface = interface; + + return (0); +} + +int +usb_release_interface(usb_dev_handle * dev, int interface) +{ + /* do nothing */ + return (0); +} + +int +usb_set_altinterface(usb_dev_handle * dev, int alternate) +{ + struct libusb20_device *pdev = (void *)dev; + int err; + uint8_t iface; + + iface = pdev->claimed_interface; + + err = libusb20_dev_set_alt_index((void *)dev, iface, alternate); + + if (err) + return (-1); + + return (0); +} + +int +usb_resetep(usb_dev_handle * dev, unsigned int ep) +{ + /* emulate an endpoint reset through clear-STALL */ + return (usb_clear_halt(dev, ep)); +} + +int +usb_clear_halt(usb_dev_handle * dev, unsigned int ep) +{ + struct libusb20_transfer *xfer; + + xfer = usb_get_transfer_by_ep_no(dev, ep); + if (xfer == NULL) + return (-1); + + libusb20_tr_clear_stall_sync(xfer); + + return (0); +} + +int +usb_reset(usb_dev_handle * dev) +{ + int err; + + err = libusb20_dev_reset((void *)dev); + + if (err) + return (-1); + + /* + * Be compatible with LibUSB from sourceforge and close the + * handle after reset! + */ + return (usb_close(dev)); +} + +int +usb_check_connected(usb_dev_handle * dev) +{ + int err; + + err = libusb20_dev_check_connected((void *)dev); + + if (err) + return (-1); + + return (0); +} + +const char * +usb_strerror(void) +{ + /* TODO */ + return ("Unknown error"); +} + +void +usb_init(void) +{ + /* nothing to do */ + return; +} + +void +usb_set_debug(int level) +{ + /* use kernel UGEN debugging if you need to see what is going on */ + return; +} + +int +usb_find_busses(void) +{ + usb_busses = &usb_global_bus; + return (1); +} + +int +usb_find_devices(void) +{ + struct libusb20_device *pdev; + struct usb_device *udev; + struct LIBUSB20_DEVICE_DESC_DECODED *ddesc; + int devnum; + int err; + + /* cleanup after last device search */ + /* close all opened devices, if any */ + + while ((pdev = libusb20_be_device_foreach(usb_backend, NULL))) { + udev = pdev->privLuData; + libusb20_be_dequeue_device(usb_backend, pdev); + libusb20_dev_free(pdev); + if (udev != NULL) { + LIST_DEL(usb_global_bus.devices, udev); + free(udev); + } + } + + /* free old USB backend, if any */ + + libusb20_be_free(usb_backend); + + /* do a new backend device search */ + usb_backend = libusb20_be_alloc_default(); + if (usb_backend == NULL) { + return (-1); + } + /* iterate all devices */ + + devnum = 1; + pdev = NULL; + while ((pdev = libusb20_be_device_foreach(usb_backend, pdev))) { + udev = malloc(sizeof(*udev)); + if (udev == NULL) + break; + + memset(udev, 0, sizeof(*udev)); + + udev->bus = &usb_global_bus; + + snprintf(udev->filename, sizeof(udev->filename), + "/dev/ugen%u.%u", + libusb20_dev_get_bus_number(pdev), + libusb20_dev_get_address(pdev)); + + ddesc = libusb20_dev_get_device_desc(pdev); + + udev->descriptor.bLength = sizeof(udev->descriptor); + udev->descriptor.bDescriptorType = ddesc->bDescriptorType; + udev->descriptor.bcdUSB = ddesc->bcdUSB; + udev->descriptor.bDeviceClass = ddesc->bDeviceClass; + udev->descriptor.bDeviceSubClass = ddesc->bDeviceSubClass; + udev->descriptor.bDeviceProtocol = ddesc->bDeviceProtocol; + udev->descriptor.bMaxPacketSize0 = ddesc->bMaxPacketSize0; + udev->descriptor.idVendor = ddesc->idVendor; + udev->descriptor.idProduct = ddesc->idProduct; + udev->descriptor.bcdDevice = ddesc->bcdDevice; + udev->descriptor.iManufacturer = ddesc->iManufacturer; + udev->descriptor.iProduct = ddesc->iProduct; + udev->descriptor.iSerialNumber = ddesc->iSerialNumber; + udev->descriptor.bNumConfigurations = + ddesc->bNumConfigurations; + if (udev->descriptor.bNumConfigurations > USB_MAXCONFIG) { + /* truncate number of configurations */ + udev->descriptor.bNumConfigurations = USB_MAXCONFIG; + } + udev->devnum = devnum++; + /* link together the two structures */ + udev->dev = pdev; + pdev->privLuData = udev; + + err = libusb20_dev_open(pdev, 0); + if (err == 0) { + /* XXX get all config descriptors by default */ + usb_fetch_and_parse_descriptors((void *)pdev); + libusb20_dev_close(pdev); + } + LIST_ADD(usb_global_bus.devices, udev); + } + + return (devnum - 1); /* success */ +} + +struct usb_device * +usb_device(usb_dev_handle * dev) +{ + struct libusb20_device *pdev; + + pdev = (void *)dev; + + return (pdev->privLuData); +} + +struct usb_bus * +usb_get_busses(void) +{ + return (usb_busses); +} Modified: stable/8/lib/libusb/libusb20.3 ============================================================================== --- stable/8/lib/libusb/libusb20.3 Mon Jun 27 21:43:56 2011 (r223611) +++ stable/8/lib/libusb/libusb20.3 Mon Jun 27 21:45:35 2011 (r223612) @@ -159,6 +159,10 @@ USB access library (libusb -lusb) .Ft uint8_t .Fn libusb20_dev_get_address "struct libusb20_device *pdev" .Ft uint8_t +.Fn libusb20_dev_get_parent_address "struct libusb20_device *pdev" +.Ft uint8_t +.Fn libusb20_dev_get_parent_port "struct libusb20_device *pdev" +.Ft uint8_t .Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev" .Ft uint8_t .Fn libusb20_dev_get_mode "struct libusb20_device *pdev" @@ -756,12 +760,31 @@ is an internal function to allocate a ne .Fn libusb20_dev_get_address returns the internal and not necessarily the real hardware address of the given USB device. +Valid addresses start at one. +. +.Pp +. +.Fn libusb20_dev_get_parent_address +returns the internal and not necessarily the real hardware address of +the given parent USB HUB device. +This value is zero for the root HUB which usually has a device address +equal to one. +Valid addresses start at one. +. +.Pp +. +.Fn libusb20_dev_get_parent_port +returns the port number on the parent USB HUB device. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-8@FreeBSD.ORG Tue Jun 28 04:57:53 2011 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 7F1B8106564A; Tue, 28 Jun 2011 04:57:53 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6ECE98FC13; Tue, 28 Jun 2011 04:57:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5S4vr33029003; Tue, 28 Jun 2011 04:57:53 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5S4vrDj029001; Tue, 28 Jun 2011 04:57:53 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201106280457.p5S4vrDj029001@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 28 Jun 2011 04:57:53 +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: r223618 - stable/8/sbin/geom/class/part 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, 28 Jun 2011 04:57:53 -0000 Author: ae Date: Tue Jun 28 04:57:53 2011 New Revision: 223618 URL: http://svn.freebsd.org/changeset/base/223618 Log: MFC r223364: When user specifies the bootcode with size smaller than VTOC_BOOTSIZE, gpart_write_partcode_vtoc8 does access out of range of allocated memory. Check size of bootcode before writing it. Pointed out by: ru Modified: stable/8/sbin/geom/class/part/geom_part.c Directory Properties: stable/8/sbin/geom/class/part/ (props changed) Modified: stable/8/sbin/geom/class/part/geom_part.c ============================================================================== --- stable/8/sbin/geom/class/part/geom_part.c Tue Jun 28 01:32:18 2011 (r223617) +++ stable/8/sbin/geom/class/part/geom_part.c Tue Jun 28 04:57:53 2011 (r223618) @@ -1187,8 +1187,11 @@ gpart_bootcode(struct gctl_req *req, uns if (idx == 0) errx(EXIT_FAILURE, "missing -i option"); gpart_write_partcode(gp, idx, partcode, partsize); - } else + } else { + if (partsize != VTOC_BOOTSIZE) + errx(EXIT_FAILURE, "invalid bootcode"); gpart_write_partcode_vtoc8(gp, idx, partcode); + } } else if (bootcode == NULL) errx(EXIT_FAILURE, "no -b nor -p"); From owner-svn-src-stable-8@FreeBSD.ORG Tue Jun 28 10:27:49 2011 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 95E781065672; Tue, 28 Jun 2011 10:27:49 +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 84B488FC16; Tue, 28 Jun 2011 10:27:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5SARnVa041680; Tue, 28 Jun 2011 10:27:49 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5SARn2C041674; Tue, 28 Jun 2011 10:27:49 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201106281027.p5SARn2C041674@svn.freebsd.org> From: Edwin Groothuis Date: Tue, 28 Jun 2011 10:27: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: r223630 - 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: Tue, 28 Jun 2011 10:27:49 -0000 Author: edwin Date: Tue Jun 28 10:27:49 2011 New Revision: 223630 URL: http://svn.freebsd.org/changeset/base/223630 Log: MFC of tzdata2011h, r223629 - Russia scraps DST in 2011 - Remove Netherlands Antilles, add Bonaire, Curacao, Sint Maarten Modified: stable/8/share/zoneinfo/antarctica stable/8/share/zoneinfo/asia stable/8/share/zoneinfo/europe stable/8/share/zoneinfo/southamerica stable/8/share/zoneinfo/zone.tab Directory Properties: stable/8/share/zoneinfo/ (props changed) Modified: stable/8/share/zoneinfo/antarctica ============================================================================== --- stable/8/share/zoneinfo/antarctica Tue Jun 28 10:24:01 2011 (r223629) +++ stable/8/share/zoneinfo/antarctica Tue Jun 28 10:27:49 2011 (r223630) @@ -1,5 +1,5 @@ #
-# @(#)antarctica	8.8
+# @(#)antarctica	8.9
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -19,18 +19,6 @@
 # I made up all time zone abbreviations mentioned here; corrections welcome!
 # FORMAT is `zzz' and GMTOFF is 0 for locations while uninhabited.
 
-# These rules are stolen from the `europe' file.
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	RussAQ	1981	1984	-	Apr	 1	 0:00	1:00	S
-Rule	RussAQ	1981	1983	-	Oct	 1	 0:00	0	-
-Rule	RussAQ	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule	RussAQ	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
-Rule	RussAQ	1992	only	-	Mar	lastSat	 23:00	1:00	S
-Rule	RussAQ	1992	only	-	Sep	lastSat	 23:00	0	-
-Rule	RussAQ	1993	max	-	Mar	lastSun	 2:00s	1:00	S
-Rule	RussAQ	1993	1995	-	Sep	lastSun	 2:00s	0	-
-Rule	RussAQ	1996	max	-	Oct	lastSun	 2:00s	0	-
-
 # These rules are stolen from the `southamerica' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	ArgAQ	1964	1966	-	Mar	 1	0:00	0	-

Modified: stable/8/share/zoneinfo/asia
==============================================================================
--- stable/8/share/zoneinfo/asia	Tue Jun 28 10:24:01 2011	(r223629)
+++ stable/8/share/zoneinfo/asia	Tue Jun 28 10:27:49 2011	(r223630)
@@ -1,4 +1,4 @@
-# @(#)asia	8.64
+# @(#)asia	8.65
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -77,6 +77,10 @@ Rule RussiaAsia	1993	max	-	Mar	lastSun	 
 Rule RussiaAsia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule RussiaAsia	1996	max	-	Oct	lastSun	 2:00s	0	-
 
+# From Arthur David Olson (2011-06-15):
+# While Russia abandoned DST in 2011, Armenia may choose to
+# follow Russia's "old" rules.
+
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kabul	4:36:48 -	LMT	1890

Modified: stable/8/share/zoneinfo/europe
==============================================================================
--- stable/8/share/zoneinfo/europe	Tue Jun 28 10:24:01 2011	(r223629)
+++ stable/8/share/zoneinfo/europe	Tue Jun 28 10:27:49 2011	(r223630)
@@ -1,5 +1,5 @@
 # 
-# @(#)europe	8.32
+# @(#)europe	8.33
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -565,6 +565,26 @@ Rule	Russia	1993	max	-	Mar	lastSun	 2:00
 Rule	Russia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule	Russia	1996	max	-	Oct	lastSun	 2:00s	0	-
 
+# From Alexander Krivenyshev (2011-06-14):
+# According to Kremlin press service, Russian President Dmitry Medvedev
+# signed a federal law "On calculation of time" on June 9, 2011.
+# According to the law Russia is abolishing daylight saving time.
+# 
+# Medvedev signed a law "On the Calculation of Time" (in russian): 
+# 
+# http://bmockbe.ru/events/?ID=7583
+# 
+# 
+# Medvedev signed a law on the calculation of the time (in russian):
+# 
+# http://www.regnum.ru/news/polit/1413906.html
+# 
+
+# From Arthur David Olson (2011-06-15):
+# Take "abolishing daylight saving time" to mean that time is now considered
+# to be standard.
+# At least for now, keep the "old" Russia rules for the benefit of Belarus.
+
 # These are for backward compatibility with older versions.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2013,7 +2033,8 @@ Zone Europe/Kaliningrad	 1:22:00 -	LMT	1
 			 1:00	C-Eur	CE%sT	1945
 			 2:00	Poland	CE%sT	1946
 			 3:00	Russia	MSK/MSD	1991 Mar 31 2:00s
-			 2:00	Russia	EE%sT
+			 2:00	Russia	EE%sT	2011 Mar 27 2:00s
+			 3:00	-	EET
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Adygeya, Arkhangel'skaya oblast',
@@ -2042,7 +2063,8 @@ Zone Europe/Moscow	 2:30:20 -	LMT	1880
 			 2:00	-	EET	1930 Jun 21
 			 3:00	Russia	MSK/MSD	1991 Mar 31 2:00s
 			 2:00	Russia	EE%sT	1992 Jan 19 2:00s
-			 3:00	Russia	MSK/MSD
+			 3:00	Russia	MSK/MSD	2011 Mar 27 2:00s
+			 4:00	-	MSK
 #
 # Astrakhanskaya oblast', Kirovskaya oblast', Saratovskaya oblast',
 # Volgogradskaya oblast'.  Shanks & Pottenger say Kirov is still at +0400
@@ -2055,7 +2077,8 @@ Zone Europe/Volgograd	 2:57:40 -	LMT	192
 			 4:00	Russia	VOL%sT	1989 Mar 26 2:00s # Volgograd T
 			 3:00	Russia	VOL%sT	1991 Mar 31 2:00s
 			 4:00	-	VOLT	1992 Mar 29 2:00s
-			 3:00	Russia	VOL%sT
+			 3:00	Russia	VOL%sT	2011 Mar 27 2:00s
+			 4:00	-	VOLT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Samarskaya oblast', Udmyrtskaya respublika
@@ -2067,7 +2090,8 @@ Zone Europe/Samara	 3:20:36 -	LMT	1919 J
 			 2:00	Russia	KUY%sT	1991 Sep 29 2:00s
 			 3:00	-	KUYT	1991 Oct 20 3:00
 			 4:00	Russia	SAM%sT	2010 Mar 28 2:00s # Samara Time
-			 3:00	Russia	SAM%sT
+			 3:00	Russia	SAM%sT	2011 Mar 27 2:00s
+			 4:00	-	SAMT
 
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
@@ -2080,7 +2104,8 @@ Zone Asia/Yekaterinburg	 4:02:24 -	LMT	1
 			 4:00	-	SVET	1930 Jun 21 # Sverdlovsk Time
 			 5:00	Russia	SVE%sT	1991 Mar 31 2:00s
 			 4:00	Russia	SVE%sT	1992 Jan 19 2:00s
-			 5:00	Russia	YEK%sT	# Yekaterinburg Time
+			 5:00	Russia	YEK%sT	2011 Mar 27 2:00s
+			 6:00	-	YEKT	# Yekaterinburg Time
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Altaj, Altajskij kraj, Omskaya oblast'.
@@ -2088,7 +2113,8 @@ Zone Asia/Omsk		 4:53:36 -	LMT	1919 Nov 
 			 5:00	-	OMST	1930 Jun 21 # Omsk TIme
 			 6:00	Russia	OMS%sT	1991 Mar 31 2:00s
 			 5:00	Russia	OMS%sT	1992 Jan 19 2:00s
-			 6:00	Russia	OMS%sT
+			 6:00	Russia	OMS%sT	2011 Mar 27 2:00s
+			 7:00	-	OMST
 #
 # From Paul Eggert (2006-08-19): I'm guessing about Tomsk here; it's
 # not clear when it switched from +7 to +6.
@@ -2098,7 +2124,8 @@ Zone Asia/Novosibirsk	 5:31:40 -	LMT	191
 			 7:00	Russia	NOV%sT	1991 Mar 31 2:00s
 			 6:00	Russia	NOV%sT	1992 Jan 19 2:00s
 			 7:00	Russia	NOV%sT	1993 May 23 # say Shanks & P.
-			 6:00	Russia	NOV%sT
+			 6:00	Russia	NOV%sT	2011 Mar 27 2:00s
+			 7:00	-	NOVT
 
 # From Alexander Krivenyshev (2009-10-13):
 # Kemerovo oblast' (Kemerovo region) in Russia will change current time zone on
@@ -2131,7 +2158,8 @@ Zone Asia/Novokuznetsk	 5:48:48 -	NMT	19
 			 7:00	Russia	KRA%sT	1991 Mar 31 2:00s
 			 6:00	Russia	KRA%sT	1992 Jan 19 2:00s
 			 7:00	Russia	KRA%sT	2010 Mar 28 2:00s
-			 6:00	Russia	NOV%sT # Novosibirsk/Novokuznetsk Time
+			 6:00	Russia	NOV%sT	2011 Mar 27 2:00s
+			 7:00	-	NOVT # Novosibirsk/Novokuznetsk Time
 
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
@@ -2142,7 +2170,8 @@ Zone Asia/Krasnoyarsk	 6:11:20 -	LMT	192
 			 6:00	-	KRAT	1930 Jun 21 # Krasnoyarsk Time
 			 7:00	Russia	KRA%sT	1991 Mar 31 2:00s
 			 6:00	Russia	KRA%sT	1992 Jan 19 2:00s
-			 7:00	Russia	KRA%sT
+			 7:00	Russia	KRA%sT	2011 Mar 27 2:00s
+			 8:00	-	KRAT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Buryatiya, Irkutskaya oblast',
@@ -2152,7 +2181,8 @@ Zone Asia/Irkutsk	 6:57:20 -	LMT	1880
 			 7:00	-	IRKT	1930 Jun 21 # Irkutsk Time
 			 8:00	Russia	IRK%sT	1991 Mar 31 2:00s
 			 7:00	Russia	IRK%sT	1992 Jan 19 2:00s
-			 8:00	Russia	IRK%sT
+			 8:00	Russia	IRK%sT	2011 Mar 27 2:00s
+			 9:00	-	IRKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Aginskij Buryatskij avtonomnyj okrug, Amurskaya oblast',
@@ -2175,7 +2205,8 @@ Zone Asia/Yakutsk	 8:38:40 -	LMT	1919 De
 			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
 			 9:00	Russia	YAK%sT	1991 Mar 31 2:00s
 			 8:00	Russia	YAK%sT	1992 Jan 19 2:00s
-			 9:00	Russia	YAK%sT
+			 9:00	Russia	YAK%sT	2011 Mar 27 2:00s
+			 10:00	-	YAKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Evrejskaya avtonomnaya oblast', Khabarovskij kraj, Primorskij kraj,
@@ -2188,7 +2219,8 @@ Zone Asia/Vladivostok	 8:47:44 -	LMT	192
 			 9:00	-	VLAT	1930 Jun 21 # Vladivostok Time
 			10:00	Russia	VLA%sT	1991 Mar 31 2:00s
 			 9:00	Russia	VLA%sST	1992 Jan 19 2:00s
-			10:00	Russia	VLA%sT
+			10:00	Russia	VLA%sT	2011 Mar 27 2:00s
+			11:00	-	VLAT
 #
 # Sakhalinskaya oblast'.
 # The Zone name should be Yuzhno-Sakhalinsk, but that's too long.
@@ -2198,7 +2230,8 @@ Zone Asia/Sakhalin	 9:30:48 -	LMT	1905 A
 			11:00	Russia	SAK%sT	1991 Mar 31 2:00s # Sakhalin T.
 			10:00	Russia	SAK%sT	1992 Jan 19 2:00s
 			11:00	Russia	SAK%sT	1997 Mar lastSun 2:00s
-			10:00	Russia	SAK%sT
+			10:00	Russia	SAK%sT	2011 Mar 27 2:00s
+			11:00	-	SAKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Magadanskaya oblast', Respublika Sakha (Yakutiya).
@@ -2211,7 +2244,8 @@ Zone Asia/Magadan	10:03:12 -	LMT	1924 Ma
 			10:00	-	MAGT	1930 Jun 21 # Magadan Time
 			11:00	Russia	MAG%sT	1991 Mar 31 2:00s
 			10:00	Russia	MAG%sT	1992 Jan 19 2:00s
-			11:00	Russia	MAG%sT
+			11:00	Russia	MAG%sT	2011 Mar 27 2:00s
+			12:00	-	MAGT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Kamchatskaya oblast', Koryakskij avtonomnyj okrug.
@@ -2222,7 +2256,8 @@ Zone Asia/Kamchatka	10:34:36 -	LMT	1922 
 			12:00	Russia	PET%sT	1991 Mar 31 2:00s
 			11:00	Russia	PET%sT	1992 Jan 19 2:00s
 			12:00	Russia	PET%sT	2010 Mar 28 2:00s
-			11:00	Russia	PET%sT
+			11:00	Russia	PET%sT	2011 Mar 27 2:00s
+			12:00	-	PETT
 #
 # Chukotskij avtonomnyj okrug
 Zone Asia/Anadyr	11:49:56 -	LMT	1924 May  2
@@ -2231,7 +2266,8 @@ Zone Asia/Anadyr	11:49:56 -	LMT	1924 May
 			12:00	Russia	ANA%sT	1991 Mar 31 2:00s
 			11:00	Russia	ANA%sT	1992 Jan 19 2:00s
 			12:00	Russia	ANA%sT	2010 Mar 28 2:00s
-			11:00	Russia	ANA%sT
+			11:00	Russia	ANA%sT	2011 Mar 27 2:00s
+			12:00	-	ANAT
 
 # Serbia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]

Modified: stable/8/share/zoneinfo/southamerica
==============================================================================
--- stable/8/share/zoneinfo/southamerica	Tue Jun 28 10:24:01 2011	(r223629)
+++ stable/8/share/zoneinfo/southamerica	Tue Jun 28 10:27:49 2011	(r223630)
@@ -1,5 +1,5 @@
 # 
-# @(#)southamerica	8.49
+# @(#)southamerica	8.50
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -1276,6 +1276,14 @@ Zone	America/Curacao	-4:35:44 -	LMT	1912
 			-4:30	-	ANT	1965 # Netherlands Antilles Time
 			-4:00	-	AST
 
+# From Arthur David Olson (2011-06-15):
+# At least for now, use links for places with new iso3166 codes.
+# The name "Lower Prince's Quarter" is both longer than fourteen charaters
+# and contains an apostrophe; use "Lower_Princes" below.
+
+Link	America/Curacao	America/Lower_Princes # Sint Maarten
+Link	America/Curacao	America/Kralendijk # Bonaire, Sint Estatius and Saba
+
 # Ecuador
 #
 # From Paul Eggert (2007-03-04):

Modified: stable/8/share/zoneinfo/zone.tab
==============================================================================
--- stable/8/share/zoneinfo/zone.tab	Tue Jun 28 10:24:01 2011	(r223629)
+++ stable/8/share/zoneinfo/zone.tab	Tue Jun 28 10:27:49 2011	(r223630)
@@ -1,5 +1,5 @@
 # 
-# @(#)zone.tab	8.43
+# @(#)zone.tab	8.45
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
@@ -32,7 +32,6 @@ AG	+1703-06148	America/Antigua
 AI	+1812-06304	America/Anguilla
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
-AN	+1211-06900	America/Curacao
 AO	-0848+01314	Africa/Luanda
 AQ	-7750+16636	Antarctica/McMurdo	McMurdo Station, Ross Island
 AQ	-9000+00000	Antarctica/South_Pole	Amundsen-Scott Station, South Pole
@@ -87,6 +86,7 @@ BL	+1753-06251	America/St_Barthelemy
 BM	+3217-06446	Atlantic/Bermuda
 BN	+0456+11455	Asia/Brunei
 BO	-1630-06809	America/La_Paz
+BQ	+120903-0681636	America/Kralendijk
 BR	-0351-03225	America/Noronha	Atlantic islands
 BR	-0127-04829	America/Belem	Amapa, E Para
 BR	-0343-03830	America/Fortaleza	NE Brazil (MA, PI, CE, RN, PB)
@@ -155,6 +155,7 @@ CO	+0436-07405	America/Bogota
 CR	+0956-08405	America/Costa_Rica
 CU	+2308-08222	America/Havana
 CV	+1455-02331	Atlantic/Cape_Verde
+CW	+1211-06900	America/Curacao
 CX	-1025+10543	Indian/Christmas
 CY	+3510+03322	Asia/Nicosia
 CZ	+5005+01426	Europe/Prague
@@ -362,6 +363,7 @@ SO	+0204+04522	Africa/Mogadishu
 SR	+0550-05510	America/Paramaribo
 ST	+0020+00644	Africa/Sao_Tome
 SV	+1342-08912	America/El_Salvador
+SX	+180305-0630250	America/Lower_Princes
 SY	+3330+03618	Asia/Damascus
 SZ	-2618+03106	Africa/Mbabane
 TC	+2128-07108	America/Grand_Turk

From owner-svn-src-stable-8@FreeBSD.ORG  Tue Jun 28 10:46:02 2011
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 B40F0106566B;
	Tue, 28 Jun 2011 10:46:02 +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 A30AE8FC15;
	Tue, 28 Jun 2011 10:46:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5SAk25H042496;
	Tue, 28 Jun 2011 10:46:02 GMT (envelope-from edwin@svn.freebsd.org)
Received: (from edwin@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5SAk2Sn042494;
	Tue, 28 Jun 2011 10:46:02 GMT (envelope-from edwin@svn.freebsd.org)
Message-Id: <201106281046.p5SAk2Sn042494@svn.freebsd.org>
From: Edwin Groothuis 
Date: Tue, 28 Jun 2011 10:46: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: r223634 - stable/8/share/misc
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, 28 Jun 2011 10:46:02 -0000

Author: edwin
Date: Tue Jun 28 10:46:02 2011
New Revision: 223634
URL: http://svn.freebsd.org/changeset/base/223634

Log:
  Bring iso3166 file in sync with HEAD
  
  MFC of recent updates on the ISO3166 file:
  
  r223633
  - Remove AN again now that tzdata2011h has been imported.
  
  r222094
  - Put AN back after finding out that tzsetup(1) will complain that
    it doesn't exist. It will be removed again once the tzdata distribution
    files have been updated with the replacements for AN.
  
  r222014
  - Revert change to "MF" I made in r189767.  I bet that at the time of r189767
    I checked with http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm
    and "MF" was officially spelled in English as "Saint Martin" there, but now
    that "SX" exists (for "Sint Maarten (Dutch part)") (nice official "English"
    spelling!) they seem to have added a "(French part)" suffix to "MF".  Since
    this is also in line with Newsletter VI-1 (2007-09-21), catch up.
  
  r222011
  - ISO3166: Update for newsletters VI-7 and VI-8 from 2010
    - Name change for SH
    - BQ, CW, and SX replace AN
  
    Reviewed by:	ru
  
  r222010
  - Whitespace and typo fixes.
  
    Found by:	codespell
    Reviewed by:	ru

Modified:
  stable/8/share/misc/iso3166
Directory Properties:
  stable/8/share/misc/   (props changed)

Modified: stable/8/share/misc/iso3166
==============================================================================
--- stable/8/share/misc/iso3166	Tue Jun 28 10:38:12 2011	(r223633)
+++ stable/8/share/misc/iso3166	Tue Jun 28 10:46:02 2011	(r223634)
@@ -45,7 +45,8 @@ BZ	BLZ	084	Belize
 BJ	BEN	204	Benin
 BM	BMU	060	Bermuda
 BT	BTN	064	Bhutan
-BO	BOL	068	Bolivia
+BO	BOL	068	Bolivia, Plurinational State of
+BQ	BES	535	Bonaire, Saint Eustatius and Saba
 BA	BIH	070	Bosnia and Herzegovina
 BW	BWA	072	Botswana
 BV	BVT	074	Bouvet Island
@@ -75,6 +76,7 @@ CR	CRI	188	Costa Rica
 CI	CIV	384	Cote d'Ivoire
 HR	HRV	191	Croatia
 CU	CUB	192	Cuba
+CW	CUW	531	Curacao
 CY	CYP	196	Cyprus
 CZ	CZE	203	Czech Republic
 DK	DNK	208	Denmark
@@ -174,7 +176,6 @@ NA	NAM	516	Namibia
 NR	NRU	520	Nauru
 NP	NPL	524	Nepal
 NL	NLD	528	Netherlands
-AN	ANT	530	Netherlands Antilles
 NC	NCL	540	New Caledonia
 NZ	NZL	554	New Zealand
 NI	NIC	558	Nicaragua
@@ -205,7 +206,7 @@ RW	RWA	646	Rwanda
 BL	BLM	652	Saint Barthelemy
 KN	KNA	659	Saint Kitts and Nevis
 LC	LCA	662	Saint Lucia
-MF	MAF	663	Saint Martin
+MF	MAF	663	Saint Martin (French Part)
 VC	VCT	670	Saint Vincent and the Grenadines
 WS	WSM	882	Samoa
 SM	SMR	674	San Marino
@@ -216,6 +217,7 @@ RS	SRB	688	Serbia
 SC	SYC	690	Seychelles
 SL	SLE	694	Sierra Leone
 SG	SGP	702	Singapore
+SX	SXM	534	Sint Maarten (Dutch part)
 SK	SVK	703	Slovakia
 SI	SVN	705	Slovenia
 SB	SLB	090	Solomon Islands
@@ -224,7 +226,7 @@ ZA	ZAF	710	South Africa
 GS	SGS	239	South Georgia and the South Sandwich Islands
 ES	ESP	724	Spain
 LK	LKA	144	Sri Lanka
-SH	SHN	654	Saint Helena
+SH	SHN	654	Saint Helena, Ascension and Tristan da Cunha
 PM	SPM	666	Saint Pierre and Miquelon
 SD	SDN	736	Sudan
 SR	SUR	740	Suriname
@@ -256,7 +258,7 @@ UY	URY	858	Uruguay
 UZ	UZB	860	Uzbekistan
 VU	VUT	548	Vanuatu
 VA	VAT	336	Holy See (Vatican City State)
-VE	VEN	862	Venezuela
+VE	VEN	862	Venezuela, Bolivarian Republic of
 VN	VNM	704	Viet Nam
 VG	VGB	092	Virgin Islands, British
 VI	VIR	850	Virgin Islands, U.S.
@@ -395,7 +397,7 @@ ZW	ZWE	716	Zimbabwe
 # Newsletter III-41 1993-07-28
 #   MAURITIUS, changes outside this document
 #
-# Newletter III-42 1993-07-12
+# Newsletter III-42 1993-07-12
 #   SAINT VINCENT AND THE GRENADINES, changes outside this document
 #
 # Newsletter III-43 1993-07-12
@@ -426,15 +428,15 @@ ZW	ZWE	716	Zimbabwe
 #   Czechoslovakia officially deleted
 #
 # Newsletter III-52, 1993-07-02
-#   Angola, changing information not included in this file. Offical name
+#   Angola, changing information not included in this file. Official name
 #   change to Republic of Angola
 #
 # Newsletter III-53, 1993-07-12
-#   Madagascar, changing information not included in this file. Official 
+#   Madagascar, changing information not included in this file. Official
 #   name change to Republic of Madagascar
 #
 # Newsletter III-54, 1993-07-23
-#   South Georgia and the South Sandwich Islands, previously covered by 
+#   South Georgia and the South Sandwich Islands, previously covered by
 #   Falkland Islands
 #
 # Newsletter III-55, 1993-07-16
@@ -450,23 +452,23 @@ ZW	ZWE	716	Zimbabwe
 #
 # Newsletter III-58, 1993-07-16
 #   Afghanistan, changing information not included in this file
-#   Official name change to Islamic State of Afghanistan  
+#   Official name change to Islamic State of Afghanistan
 #
-# Newsletter III-32, 1993-07-25 ammendment
-#   Kyrgyzstan, changing information not included in this file. Offical name
+# Newsletter III-32, 1993-07-25 amendment
+#   Kyrgyzstan, changing information not included in this file. Official name
 #   change to Kyrgyz Republic
 #
 # Newsletter III-59, 1994-01-26
-#   Andorra, changing information not included in this file. Offical name
+#   Andorra, changing information not included in this file. Official name
 #   change to Pricipality of Andorra
 #
 # Newsletter III-60, 1994-01-26
-#   Cambodia, changing information not included in this file. Offical name
+#   Cambodia, changing information not included in this file. Official name
 #   change to Kingdom of Cambodia
 #
 # Thu Feb 10 1994
 # At this point the fourth edition of ISO 3166 appears. It can *now* be
-# ordered from national standards institutions. The RIPE NCC will continue 
+# ordered from national standards institutions. The RIPE NCC will continue
 # tracking changes.
 #
 # [deletia]
@@ -521,3 +523,27 @@ ZW	ZWE	716	Zimbabwe
 #
 # Newsletter VI-1 2007-09-21
 #  Added SAINT BARTHELEMY (BL) and SAINT MARTIN (MF).
+#
+# Newsletter VI-2 2008-04-25
+#  Name changes for Moldova, Montenegro and other minor corrections.
+#
+# Newsletter VI-3 2008-09-09
+#  Name change for Nepal and other minor corrections.
+#  Not relevant to this file.
+#
+# Newsletter VI-4 2009-01-07
+#  Name change for the Republic of Moldova and other minor corrections.
+#
+# Newsletter VI-5 2009-03-03
+#  Name change for Bolivarian Republic of Venezuela and other minor corrections.
+#
+# Newsletter VI-6 2009-05-08
+#  Name change for Plurinational State of Bolivia.
+#
+# Newsletter VI-7 2010-02-22
+#  Name change for Saint Helena, Ascension and Tristan da Cunha
+#
+# Newsletter VI-8 2010-12-15
+#  BONAIRE, SAINT EUSTATIUS AND SABA (BQ), CURACAO (CW) and
+#  SINT MAARTEN (DUTCH PART) (SX) added as new entries.
+#  NETHERLANDS ANTILLES (AN) removed.

From owner-svn-src-stable-8@FreeBSD.ORG  Tue Jun 28 14:10:39 2011
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 A0C811065670;
	Tue, 28 Jun 2011 14:10:39 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 905BF8FC12;
	Tue, 28 Jun 2011 14:10:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5SEAdSw052716;
	Tue, 28 Jun 2011 14:10:39 GMT
	(envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5SEAdEr052714;
	Tue, 28 Jun 2011 14:10:39 GMT
	(envelope-from hselasky@svn.freebsd.org)
Message-Id: <201106281410.p5SEAdEr052714@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Tue, 28 Jun 2011 14:10: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: r223643 - stable/8/lib/libusb
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, 28 Jun 2011 14:10:39 -0000

Author: hselasky
Date: Tue Jun 28 14:10:39 2011
New Revision: 223643
URL: http://svn.freebsd.org/changeset/base/223643

Log:
  MFC r223642.
  LibUSB v1.0 clear stall bugfix.

Modified:
  stable/8/lib/libusb/libusb10.c
Directory Properties:
  stable/8/lib/libusb/   (props changed)
  stable/8/lib/libusb/usb.h   (props changed)

Modified: stable/8/lib/libusb/libusb10.c
==============================================================================
--- stable/8/lib/libusb/libusb10.c	Tue Jun 28 14:07:28 2011	(r223642)
+++ stable/8/lib/libusb/libusb10.c	Tue Jun 28 14:10:39 2011	(r223643)
@@ -636,7 +636,7 @@ libusb_clear_halt(struct libusb20_device
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
 	CTX_LOCK(dev->ctx);
-	err = libusb20_tr_open(xfer, 0, 0, endpoint);
+	err = libusb20_tr_open(xfer, 0, 1, endpoint);
 	CTX_UNLOCK(dev->ctx);
 
 	if (err != 0 && err != LIBUSB20_ERROR_BUSY)

From owner-svn-src-stable-8@FreeBSD.ORG  Tue Jun 28 19:27:34 2011
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 7DF12106564A;
	Tue, 28 Jun 2011 19:27:34 +0000 (UTC)
	(envelope-from trociny@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6C2148FC0C;
	Tue, 28 Jun 2011 19:27:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5SJRY7a062339;
	Tue, 28 Jun 2011 19:27:34 GMT (envelope-from trociny@svn.freebsd.org)
Received: (from trociny@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5SJRYK9062333;
	Tue, 28 Jun 2011 19:27:34 GMT (envelope-from trociny@svn.freebsd.org)
Message-Id: <201106281927.p5SJRYK9062333@svn.freebsd.org>
From: Mikolaj Golub 
Date: Tue, 28 Jun 2011 19:27: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: r223651 - in stable/8/sbin: hastctl 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, 28 Jun 2011 19:27:34 -0000

Author: trociny
Date: Tue Jun 28 19:27:34 2011
New Revision: 223651
URL: http://svn.freebsd.org/changeset/base/223651

Log:
  MFC r222164, r222228, r222467, r223181:
  
  r222164 (pjd):
  
  Recognize HIO_FLUSH requests.
  
  r222228 (pjd):
  
  Keep statistics on number of BIO_READ, BIO_WRITE, BIO_DELETE and BIO_FLUSH
  requests as well as number of activemap updates.
  
  Number of BIO_WRITEs and activemap updates are especially interesting, because
  if those two are too close to each other, it means that your workload needs
  bigger number of dirty extents. Activemap should be updated as rarely as
  possible.
  
  r222467:
  
  If READ from the local node failed we send the request to the remote
  node. There is no use in doing this for synchronization requests.
  
  r223181:
  
  In HAST we use two sockets - one for only sending the data and one for
  only receiving the data. In r220271 the unused directions were
  disabled using shutdown(2).
  
  Unfortunately, this broke automatic receive buffer sizing, which
  currently works only for connections in ETASBLISHED state. It was a
  root cause of the issue reported by users, when connection between
  primary and secondary could get stuck.
  
  Disable the code introduced in r220271 until the issue with automatic
  buffer sizing is not resolved.
  
  Reported by:	Daniel Kalchev , danger, sobomax
  Tested by:	Daniel Kalchev , danger
  
  Approved by:	pjd (mentor)

Modified:
  stable/8/sbin/hastctl/hastctl.c
  stable/8/sbin/hastd/control.c
  stable/8/sbin/hastd/hast.h
  stable/8/sbin/hastd/primary.c
  stable/8/sbin/hastd/secondary.c
Directory Properties:
  stable/8/sbin/hastctl/   (props changed)
  stable/8/sbin/hastd/   (props changed)

Modified: stable/8/sbin/hastctl/hastctl.c
==============================================================================
--- stable/8/sbin/hastctl/hastctl.c	Tue Jun 28 17:51:47 2011	(r223650)
+++ stable/8/sbin/hastctl/hastctl.c	Tue Jun 28 19:27:34 2011	(r223651)
@@ -341,6 +341,17 @@ control_status(struct nv *nv)
 		printf("  dirty: %ju (%NB)\n",
 		    (uintmax_t)nv_get_uint64(nv, "dirty%u", ii),
 		    (intmax_t)nv_get_uint64(nv, "dirty%u", ii));
+		printf("  statistics:\n");
+		printf("    reads: %ju\n",
+		    (uint64_t)nv_get_uint64(nv, "stat_read%u", ii));
+		printf("    writes: %ju\n",
+		    (uint64_t)nv_get_uint64(nv, "stat_write%u", ii));
+		printf("    deletes: %ju\n",
+		    (uint64_t)nv_get_uint64(nv, "stat_delete%u", ii));
+		printf("    flushes: %ju\n",
+		    (uint64_t)nv_get_uint64(nv, "stat_flush%u", ii));
+		printf("    activemap updates: %ju\n",
+		    (uint64_t)nv_get_uint64(nv, "stat_activemap_update%u", ii));
 	}
 	return (ret);
 }

Modified: stable/8/sbin/hastd/control.c
==============================================================================
--- stable/8/sbin/hastd/control.c	Tue Jun 28 17:51:47 2011	(r223650)
+++ stable/8/sbin/hastd/control.c	Tue Jun 28 19:27:34 2011	(r223651)
@@ -199,6 +199,16 @@ control_status_worker(struct hast_resour
 	    "extentsize%u", no);
 	nv_add_uint32(nvout, nv_get_uint32(cnvin, "keepdirty"),
 	    "keepdirty%u", no);
+	nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_read"),
+	    "stat_read%u", no);
+	nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_write"),
+	    "stat_write%u", no);
+	nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_delete"),
+	    "stat_delete%u", no);
+	nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_flush"),
+	    "stat_flush%u", no);
+	nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_activemap_update"),
+	    "stat_activemap_update%u", no);
 end:
 	if (cnvin != NULL)
 		nv_free(cnvin);
@@ -446,6 +456,13 @@ ctrl_thread(void *arg)
 				nv_add_uint32(nvout, (uint32_t)0, "keepdirty");
 				nv_add_uint64(nvout, (uint64_t)0, "dirty");
 			}
+			nv_add_uint64(nvout, res->hr_stat_read, "stat_read");
+			nv_add_uint64(nvout, res->hr_stat_write, "stat_write");
+			nv_add_uint64(nvout, res->hr_stat_delete,
+			    "stat_delete");
+			nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush");
+			nv_add_uint64(nvout, res->hr_stat_activemap_update,
+			    "stat_activemap_update");
 			nv_add_int16(nvout, 0, "error");
 			break;
 		case CONTROL_RELOAD:

Modified: stable/8/sbin/hastd/hast.h
==============================================================================
--- stable/8/sbin/hastd/hast.h	Tue Jun 28 17:51:47 2011	(r223650)
+++ stable/8/sbin/hastd/hast.h	Tue Jun 28 19:27:34 2011	(r223651)
@@ -218,6 +218,17 @@ struct hast_resource {
 	/* Locked used to synchronize access to hr_amp. */
 	pthread_mutex_t hr_amp_lock;
 
+	/* Number of BIO_READ requests. */
+	uint64_t	hr_stat_read;
+	/* Number of BIO_WRITE requests. */
+	uint64_t	hr_stat_write;
+	/* Number of BIO_DELETE requests. */
+	uint64_t	hr_stat_delete;
+	/* Number of BIO_FLUSH requests. */
+	uint64_t	hr_stat_flush;
+	/* Number of activemap updates. */
+	uint64_t	hr_stat_activemap_update;
+
 	/* Next resource. */
 	TAILQ_ENTRY(hast_resource) hr_next;
 };

Modified: stable/8/sbin/hastd/primary.c
==============================================================================
--- stable/8/sbin/hastd/primary.c	Tue Jun 28 17:51:47 2011	(r223650)
+++ stable/8/sbin/hastd/primary.c	Tue Jun 28 19:27:34 2011	(r223651)
@@ -726,11 +726,13 @@ init_remote(struct hast_resource *res, s
 		(void)hast_activemap_flush(res);
 	}
 	nv_free(nvin);
+#ifdef notyet
 	/* Setup directions. */
 	if (proto_send(out, NULL, 0) == -1)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
 	if (proto_recv(in, NULL, 0) == -1)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
 	pjdlog_info("Connected to %s.", res->hr_remoteaddr);
 	if (inp != NULL && outp != NULL) {
 		*inp = in;
@@ -1117,6 +1119,7 @@ ggate_recv_thread(void *arg)
 		 */
 		switch (ggio->gctl_cmd) {
 		case BIO_READ:
+			res->hr_stat_read++;
 			pjdlog_debug(2,
 			    "ggate_recv: (%p) Moving request to the send queue.",
 			    hio);
@@ -1145,6 +1148,7 @@ ggate_recv_thread(void *arg)
 			QUEUE_INSERT1(hio, send, ncomp);
 			break;
 		case BIO_WRITE:
+			res->hr_stat_write++;
 			if (res->hr_resuid == 0) {
 				/*
 				 * This is first write, initialize localcnt and
@@ -1183,12 +1187,21 @@ ggate_recv_thread(void *arg)
 			mtx_lock(&res->hr_amp_lock);
 			if (activemap_write_start(res->hr_amp,
 			    ggio->gctl_offset, ggio->gctl_length)) {
+				res->hr_stat_activemap_update++;
 				(void)hast_activemap_flush(res);
 			}
 			mtx_unlock(&res->hr_amp_lock);
 			/* FALLTHROUGH */
 		case BIO_DELETE:
 		case BIO_FLUSH:
+			switch (ggio->gctl_cmd) {
+			case BIO_DELETE:
+				res->hr_stat_delete++;
+				break;
+			case BIO_FLUSH:
+				res->hr_stat_flush++;
+				break;
+			}
 			pjdlog_debug(2,
 			    "ggate_recv: (%p) Moving request to the send queues.",
 			    hio);
@@ -1232,7 +1245,7 @@ local_send_thread(void *arg)
 			    ggio->gctl_offset + res->hr_localoff);
 			if (ret == ggio->gctl_length)
 				hio->hio_errors[ncomp] = 0;
-			else {
+			else if (!ISSYNCREQ(hio)) {
 				/*
 				 * If READ failed, try to read from remote node.
 				 */

Modified: stable/8/sbin/hastd/secondary.c
==============================================================================
--- stable/8/sbin/hastd/secondary.c	Tue Jun 28 17:51:47 2011	(r223650)
+++ stable/8/sbin/hastd/secondary.c	Tue Jun 28 19:27:34 2011	(r223651)
@@ -183,9 +183,11 @@ init_remote(struct hast_resource *res, s
 	unsigned char *map;
 	size_t mapsize;
 
+#ifdef notyet
 	/* Setup direction. */
 	if (proto_send(res->hr_remoteout, NULL, 0) == -1)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
 
 	map = NULL;
 	mapsize = 0;
@@ -351,9 +353,11 @@ init_remote(struct hast_resource *res, s
 	if (map != NULL)
 		free(map);
 	nv_free(nvout);
+#ifdef notyet
 	/* Setup direction. */
 	if (proto_recv(res->hr_remotein, NULL, 0) == -1)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
 	if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&
 	     res->hr_primary_localcnt > res->hr_secondary_remotecnt) {
 		/* Exit on split-brain. */
@@ -514,6 +518,7 @@ requnpack(struct hast_resource *res, str
 		goto end;
 	}
 	switch (hio->hio_cmd) {
+	case HIO_FLUSH:
 	case HIO_KEEPALIVE:
 		break;
 	case HIO_READ:
@@ -611,6 +616,20 @@ recv_thread(void *arg)
 			QUEUE_INSERT(send, hio);
 			continue;
 		}
+		switch (hio->hio_cmd) {
+		case HIO_READ:
+			res->hr_stat_read++;
+			break;
+		case HIO_WRITE:
+			res->hr_stat_write++;
+			break;
+		case HIO_DELETE:
+			res->hr_stat_delete++;
+			break;
+		case HIO_FLUSH:
+			res->hr_stat_flush++;
+			break;
+		}
 		reqlog(LOG_DEBUG, 2, -1, hio,
 		    "recv: (%p) Got request header: ", hio);
 		if (hio->hio_cmd == HIO_KEEPALIVE) {

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Jun 29 15:58:26 2011
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 C8096106567D;
	Wed, 29 Jun 2011 15:58:26 +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 B4B948FC08;
	Wed, 29 Jun 2011 15:58:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5TFwQwq004150;
	Wed, 29 Jun 2011 15:58:26 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5TFwQNC004137;
	Wed, 29 Jun 2011 15:58:26 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201106291558.p5TFwQNC004137@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 29 Jun 2011 15:58: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: r223674 - in stable/8/sys: amd64/pci conf dev/acpica
	dev/pci i386/pci sparc64/pci x86/pci x86/x86
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, 29 Jun 2011 15:58:26 -0000

Author: jhb
Date: Wed Jun 29 15:58:26 2011
New Revision: 223674
URL: http://svn.freebsd.org/changeset/base/223674

Log:
  MFC 221393,222930:
  Reimplement how PCI-PCI bridges manage their I/O windows.  Previously the
  driver would verify that requests for child devices were confined to any
  existing I/O windows, but the driver relied on the firmware to initialize
  the windows and would never grow the windows for new requests.  Now the
  driver actively manages the I/O windows.
  
  This is implemented by allocating a bus resource for each I/O window from
  the parent PCI bus and suballocating that resource to child devices.  The
  suballocations are managed by creating an rman for each I/O window.  The
  suballocated resources are mapped by passing the bus_activate_resource()
  call up to the parent PCI bus.  Windows are grown when needed by using
  bus_adjust_resource() to adjust the resource allocated from the parent PCI
  bus.  If the adjust request succeeds, the window is adjusted and the
  suballocation request for the child device is retried.
  
  When growing a window, the rman_first_free_region() and
  rman_last_free_region() routines are used to determine if the front or
  end of the existing I/O window is free.  From using that, the smallest
  ranges that need to be added to either the front or back of the window
  are computed.  The driver will first try to grow the window in whichever
  direction requires the smallest growth first followed by the other
  direction if that fails.
  
  Subtractive bridges will first attempt to satisfy requests for child
  resources from I/O windows (including attempts to grow the windows).  If
  that fails, the request is passed up to the parent PCI bus directly
  however.
  
  The PCI-PCI bridge driver will try to use firmware-assigned ranges for
  child BARs first and only allocate a "fresh" range if that specific range
  cannot be accommodated in the I/O window.  This allows systems where the
  firmware assigns resources during boot but later wipes the I/O windows
  (some ACPI BIOSen are known to do this) to "rediscover" the original I/O
  window ranges.
  
  The ACPI Host-PCI bridge driver has been adjusted to correctly honor
  hw.acpi.host_mem_start and the I/O port equivalent when a PCI-PCI bridge
  makes a wildcard request for an I/O window range.
  
  The new PCI-PCI bridge driver is only enabled if the NEW_PCIB kernel option
  is enabled.

Modified:
  stable/8/sys/amd64/pci/pci_bus.c
  stable/8/sys/conf/options
  stable/8/sys/dev/acpica/acpi_pcib_acpi.c
  stable/8/sys/dev/acpica/acpi_pcib_pci.c
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/pci/pci_pci.c
  stable/8/sys/dev/pci/pcib_private.h
  stable/8/sys/i386/pci/pci_bus.c
  stable/8/sys/sparc64/pci/apb.c
  stable/8/sys/sparc64/pci/ofw_pcib.c
  stable/8/sys/x86/pci/qpi.c
  stable/8/sys/x86/x86/mptable_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)

Modified: stable/8/sys/amd64/pci/pci_bus.c
==============================================================================
--- stable/8/sys/amd64/pci/pci_bus.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/amd64/pci/pci_bus.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: stable/8/sys/conf/options
==============================================================================
--- stable/8/sys/conf/options	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/conf/options	Wed Jun 29 15:58:26 2011	(r223674)
@@ -134,6 +134,7 @@ MFI_DEBUG	opt_mfi.h
 MFI_DECODE_LOG	opt_mfi.h
 MPROF_BUFFERS	opt_mprof.h
 MPROF_HASH_SIZE	opt_mprof.h
+NEW_PCIB	opt_global.h
 NO_ADAPTIVE_MUTEXES	opt_adaptive_mutexes.h
 NO_ADAPTIVE_RWLOCKS
 NO_ADAPTIVE_SX

Modified: stable/8/sys/dev/acpica/acpi_pcib_acpi.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_pcib_acpi.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/dev/acpica/acpi_pcib_acpi.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -369,11 +370,17 @@ acpi_pcib_acpi_alloc_resource(device_t d
      * Hardcoding like this sucks, so a more MD/MI way needs to be
      * found to do it.  This is typically only used on older laptops
      * that don't have pci busses behind pci bridge, so assuming > 32MB
-     * is liekly OK.
+     * is likely OK.
+     *
+     * PCI-PCI bridges may allocate smaller ranges for their windows,
+     * but the heuristics here should apply to those, so we allow
+     * several different end addresses.
      */
-    if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
+    if (type == SYS_RES_MEMORY && start == 0UL && (end == ~0UL ||
+	end == 0xffffffff))
 	start = acpi_host_mem_start;
-    if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL)
+    if (type == SYS_RES_IOPORT && start == 0UL && (end == ~0UL ||
+	end == 0xffff || end == 0xffffffff))
 	start = 0x1000;
     return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
 	count, flags));

Modified: stable/8/sys/dev/acpica/acpi_pcib_pci.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_pcib_pci.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/dev/acpica/acpi_pcib_pci.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/dev/pci/pci.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -3757,6 +3757,26 @@ pci_alloc_resource(device_t dev, device_
 		break;
 	case SYS_RES_IOPORT:
 	case SYS_RES_MEMORY:
+#ifdef NEW_PCIB
+		/*
+		 * PCI-PCI bridge I/O window resources are not BARs.
+		 * For those allocations just pass the request up the
+		 * tree.
+		 */
+		if (cfg->hdrtype == PCIM_HDRTYPE_BRIDGE) {
+			switch (*rid) {
+			case PCIR_IOBASEL_1:
+			case PCIR_MEMBASE_1:
+			case PCIR_PMBASEL_1:
+				/*
+				 * XXX: Should we bother creating a resource
+				 * list entry?
+				 */
+				return (bus_generic_alloc_resource(dev, child,
+				    type, rid, start, end, count, flags));
+			}
+		}
+#endif
 		/* Allocate resources for this BAR if needed. */
 		rle = resource_list_find(rl, type, *rid);
 		if (rle == NULL) {

Modified: stable/8/sys/dev/pci/pci_pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci_pci.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/dev/pci/pci_pci.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -36,14 +36,16 @@ __FBSDID("$FreeBSD$");
  */
 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
 
+#include 
 #include 
 
 #include 
@@ -68,8 +70,13 @@ static device_method_t pcib_methods[] = 
     DEVMETHOD(bus_read_ivar,		pcib_read_ivar),
     DEVMETHOD(bus_write_ivar,		pcib_write_ivar),
     DEVMETHOD(bus_alloc_resource,	pcib_alloc_resource),
+#ifdef NEW_PCIB
+    DEVMETHOD(bus_adjust_resource,	pcib_adjust_resource),
+    DEVMETHOD(bus_release_resource,	pcib_release_resource),
+#else
     DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
     DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
+#endif
     DEVMETHOD(bus_activate_resource,	bus_generic_activate_resource),
     DEVMETHOD(bus_deactivate_resource,	bus_generic_deactivate_resource),
     DEVMETHOD(bus_setup_intr,		bus_generic_setup_intr),
@@ -94,6 +101,243 @@ static devclass_t pcib_devclass;
 DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc));
 DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0);
 
+#ifdef NEW_PCIB
+/*
+ * XXX Todo:
+ * - properly handle the ISA enable bit.  If it is set, we should change
+ *   the behavior of the I/O window resource and rman to not allocate the
+ *   blocked ranges (upper 768 bytes of each 1K in the first 64k of the
+ *   I/O port address space).
+ */
+
+/*
+ * Is a resource from a child device sub-allocated from one of our
+ * resource managers?
+ */
+static int
+pcib_is_resource_managed(struct pcib_softc *sc, int type, struct resource *r)
+{
+
+	switch (type) {
+	case SYS_RES_IOPORT:
+		return (rman_is_region_manager(r, &sc->io.rman));
+	case SYS_RES_MEMORY:
+		/* Prefetchable resources may live in either memory rman. */
+		if (rman_get_flags(r) & RF_PREFETCHABLE &&
+		    rman_is_region_manager(r, &sc->pmem.rman))
+			return (1);
+		return (rman_is_region_manager(r, &sc->mem.rman));
+	}
+	return (0);
+}
+
+static int
+pcib_is_window_open(struct pcib_window *pw)
+{
+
+	return (pw->valid && pw->base < pw->limit);
+}
+
+/*
+ * XXX: If RF_ACTIVE did not also imply allocating a bus space tag and
+ * handle for the resource, we could pass RF_ACTIVE up to the PCI bus
+ * when allocating the resource windows and rely on the PCI bus driver
+ * to do this for us.
+ */
+static void
+pcib_activate_window(struct pcib_softc *sc, int type)
+{
+
+	PCI_ENABLE_IO(device_get_parent(sc->dev), sc->dev, type);
+}
+
+static void
+pcib_write_windows(struct pcib_softc *sc, int mask)
+{
+	device_t dev;
+	uint32_t val;
+
+	dev = sc->dev;
+	if (sc->io.valid && mask & WIN_IO) {
+		val = pci_read_config(dev, PCIR_IOBASEL_1, 1);
+		if ((val & PCIM_BRIO_MASK) == PCIM_BRIO_32) {
+			pci_write_config(dev, PCIR_IOBASEH_1,
+			    sc->io.base >> 16, 2);
+			pci_write_config(dev, PCIR_IOLIMITH_1,
+			    sc->io.limit >> 16, 2);
+		}
+		pci_write_config(dev, PCIR_IOBASEL_1, sc->io.base >> 8, 1);
+		pci_write_config(dev, PCIR_IOLIMITL_1, sc->io.limit >> 8, 1);
+	}
+
+	if (mask & WIN_MEM) {
+		pci_write_config(dev, PCIR_MEMBASE_1, sc->mem.base >> 16, 2);
+		pci_write_config(dev, PCIR_MEMLIMIT_1, sc->mem.limit >> 16, 2);
+	}
+
+	if (sc->pmem.valid && mask & WIN_PMEM) {
+		val = pci_read_config(dev, PCIR_PMBASEL_1, 2);
+		if ((val & PCIM_BRPM_MASK) == PCIM_BRPM_64) {
+			pci_write_config(dev, PCIR_PMBASEH_1,
+			    sc->pmem.base >> 32, 4);
+			pci_write_config(dev, PCIR_PMLIMITH_1,
+			    sc->pmem.limit >> 32, 4);
+		}
+		pci_write_config(dev, PCIR_PMBASEL_1, sc->pmem.base >> 16, 2);
+		pci_write_config(dev, PCIR_PMLIMITL_1, sc->pmem.limit >> 16, 2);
+	}
+}
+
+static void
+pcib_alloc_window(struct pcib_softc *sc, struct pcib_window *w, int type,
+    int flags, pci_addr_t max_address)
+{
+	char buf[64];
+	int error, rid;
+
+	if (max_address != (u_long)max_address)
+		max_address = ~0ul;
+	w->rman.rm_start = 0;
+	w->rman.rm_end = max_address;
+	w->rman.rm_type = RMAN_ARRAY;
+	snprintf(buf, sizeof(buf), "%s %s window",
+	    device_get_nameunit(sc->dev), w->name);
+	w->rman.rm_descr = strdup(buf, M_DEVBUF);
+	error = rman_init(&w->rman);
+	if (error)
+		panic("Failed to initialize %s %s rman",
+		    device_get_nameunit(sc->dev), w->name);
+
+	if (!pcib_is_window_open(w))
+		return;
+
+	if (w->base > max_address || w->limit > max_address) {
+		device_printf(sc->dev,
+		    "initial %s window has too many bits, ignoring\n", w->name);
+		return;
+	}
+	rid = w->reg;
+	w->res = bus_alloc_resource(sc->dev, type, &rid, w->base, w->limit,
+	    w->limit - w->base + 1, flags);
+	if (w->res == NULL) {
+		device_printf(sc->dev,
+		    "failed to allocate initial %s window: %#jx-%#jx\n",
+		    w->name, (uintmax_t)w->base, (uintmax_t)w->limit);
+		w->base = max_address;
+		w->limit = 0;
+		pcib_write_windows(sc, w->mask);
+		return;
+	}
+	pcib_activate_window(sc, type);
+
+	error = rman_manage_region(&w->rman, rman_get_start(w->res),
+	    rman_get_end(w->res));
+	if (error)
+		panic("Failed to initialize rman with resource");
+}
+
+/*
+ * Initialize I/O windows.
+ */
+static void
+pcib_probe_windows(struct pcib_softc *sc)
+{
+	pci_addr_t max;
+	device_t dev;
+	uint32_t val;
+
+	dev = sc->dev;
+
+	/* Determine if the I/O port window is implemented. */
+	val = pci_read_config(dev, PCIR_IOBASEL_1, 1);
+	if (val == 0) {
+		/*
+		 * If 'val' is zero, then only 16-bits of I/O space
+		 * are supported.
+		 */
+		pci_write_config(dev, PCIR_IOBASEL_1, 0xff, 1);
+		if (pci_read_config(dev, PCIR_IOBASEL_1, 1) != 0) {
+			sc->io.valid = 1;
+			pci_write_config(dev, PCIR_IOBASEL_1, 0, 1);
+		}
+	} else
+		sc->io.valid = 1;
+
+	/* Read the existing I/O port window. */
+	if (sc->io.valid) {
+		sc->io.reg = PCIR_IOBASEL_1;
+		sc->io.step = 12;
+		sc->io.mask = WIN_IO;
+		sc->io.name = "I/O port";
+		if ((val & PCIM_BRIO_MASK) == PCIM_BRIO_32) {
+			sc->io.base = PCI_PPBIOBASE(
+			    pci_read_config(dev, PCIR_IOBASEH_1, 2), val);
+			sc->io.limit = PCI_PPBIOLIMIT(
+			    pci_read_config(dev, PCIR_IOLIMITH_1, 2),
+			    pci_read_config(dev, PCIR_IOLIMITL_1, 1));
+			max = 0xffffffff;
+		} else {
+			sc->io.base = PCI_PPBIOBASE(0, val);
+			sc->io.limit = PCI_PPBIOLIMIT(0,
+			    pci_read_config(dev, PCIR_IOLIMITL_1, 1));
+			max = 0xffff;
+		}
+		pcib_alloc_window(sc, &sc->io, SYS_RES_IOPORT, 0, max);
+	}
+
+	/* Read the existing memory window. */
+	sc->mem.valid = 1;
+	sc->mem.reg = PCIR_MEMBASE_1;
+	sc->mem.step = 20;
+	sc->mem.mask = WIN_MEM;
+	sc->mem.name = "memory";
+	sc->mem.base = PCI_PPBMEMBASE(0,
+	    pci_read_config(dev, PCIR_MEMBASE_1, 2));
+	sc->mem.limit = PCI_PPBMEMLIMIT(0,
+	    pci_read_config(dev, PCIR_MEMLIMIT_1, 2));
+	pcib_alloc_window(sc, &sc->mem, SYS_RES_MEMORY, 0, 0xffffffff);
+
+	/* Determine if the prefetchable memory window is implemented. */
+	val = pci_read_config(dev, PCIR_PMBASEL_1, 2);
+	if (val == 0) {
+		/*
+		 * If 'val' is zero, then only 32-bits of memory space
+		 * are supported.
+		 */
+		pci_write_config(dev, PCIR_PMBASEL_1, 0xffff, 2);
+		if (pci_read_config(dev, PCIR_PMBASEL_1, 2) != 0) {
+			sc->pmem.valid = 1;
+			pci_write_config(dev, PCIR_PMBASEL_1, 0, 2);
+		}
+	} else
+		sc->pmem.valid = 1;
+
+	/* Read the existing prefetchable memory window. */
+	if (sc->pmem.valid) {
+		sc->pmem.reg = PCIR_PMBASEL_1;
+		sc->pmem.step = 20;
+		sc->pmem.mask = WIN_PMEM;
+		sc->pmem.name = "prefetch";
+		if ((val & PCIM_BRPM_MASK) == PCIM_BRPM_64) {
+			sc->pmem.base = PCI_PPBMEMBASE(
+			    pci_read_config(dev, PCIR_PMBASEH_1, 4), val);
+			sc->pmem.limit = PCI_PPBMEMLIMIT(
+			    pci_read_config(dev, PCIR_PMLIMITH_1, 4),
+			    pci_read_config(dev, PCIR_PMLIMITL_1, 2));
+			max = 0xffffffffffffffff;
+		} else {
+			sc->pmem.base = PCI_PPBMEMBASE(0, val);
+			sc->pmem.limit = PCI_PPBMEMLIMIT(0,
+			    pci_read_config(dev, PCIR_PMLIMITL_1, 2));
+			max = 0xffffffff;
+		}
+		pcib_alloc_window(sc, &sc->pmem, SYS_RES_MEMORY,
+		    RF_PREFETCHABLE, max);
+	}
+}
+
+#else
+
 /*
  * Is the prefetch window open (eg, can we allocate memory in it?)
  */
@@ -120,6 +364,7 @@ pcib_is_io_open(struct pcib_softc *sc)
 {
 	return (sc->iobase > 0 && sc->iobase < sc->iolimit);
 }
+#endif
 
 /*
  * Generic device interface
@@ -139,7 +384,9 @@ void
 pcib_attach_common(device_t dev)
 {
     struct pcib_softc	*sc;
+#ifndef NEW_PCIB
     uint8_t		iolow;
+#endif
     struct sysctl_ctx_list *sctx;
     struct sysctl_oid	*soid;
 
@@ -172,6 +419,7 @@ pcib_attach_common(device_t dev)
     SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus",
       CTLFLAG_RD, &sc->subbus, 0, "Subordinate bus number");
 
+#ifndef NEW_PCIB
     /*
      * Determine current I/O decode.
      */
@@ -216,6 +464,7 @@ pcib_attach_common(device_t dev)
 	    sc->pmemlimit = PCI_PPBMEMLIMIT(0,
 		pci_read_config(dev, PCIR_PMLIMITL_1, 2));
     }
+#endif
 
     /*
      * Quirk handling.
@@ -286,18 +535,35 @@ pcib_attach_common(device_t dev)
     if ((pci_get_devid(dev) & 0xff00ffff) == 0x24008086 ||
       pci_read_config(dev, PCIR_PROGIF, 1) == PCIP_BRIDGE_PCI_SUBTRACTIVE)
 	sc->flags |= PCIB_SUBTRACTIVE;
-	
+
+#ifdef NEW_PCIB
+    pcib_probe_windows(sc);
+#endif
     if (bootverbose) {
 	device_printf(dev, "  domain            %d\n", sc->domain);
 	device_printf(dev, "  secondary bus     %d\n", sc->secbus);
 	device_printf(dev, "  subordinate bus   %d\n", sc->subbus);
-	device_printf(dev, "  I/O decode        0x%x-0x%x\n", sc->iobase, sc->iolimit);
+#ifdef NEW_PCIB
+	if (pcib_is_window_open(&sc->io))
+	    device_printf(dev, "  I/O decode        0x%jx-0x%jx\n",
+	      (uintmax_t)sc->io.base, (uintmax_t)sc->io.limit);
+	if (pcib_is_window_open(&sc->mem))
+	    device_printf(dev, "  memory decode     0x%jx-0x%jx\n",
+	      (uintmax_t)sc->mem.base, (uintmax_t)sc->mem.limit);
+	if (pcib_is_window_open(&sc->pmem))
+	    device_printf(dev, "  prefetched decode 0x%jx-0x%jx\n",
+	      (uintmax_t)sc->pmem.base, (uintmax_t)sc->pmem.limit);
+#else
+	if (pcib_is_io_open(sc))
+	    device_printf(dev, "  I/O decode        0x%x-0x%x\n",
+	      sc->iobase, sc->iolimit);
 	if (pcib_is_nonprefetch_open(sc))
 	    device_printf(dev, "  memory decode     0x%jx-0x%jx\n",
 	      (uintmax_t)sc->membase, (uintmax_t)sc->memlimit);
 	if (pcib_is_prefetch_open(sc))
 	    device_printf(dev, "  prefetched decode 0x%jx-0x%jx\n",
 	      (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit);
+#endif
 	else
 	    device_printf(dev, "  no prefetched decode\n");
 	if (sc->flags & PCIB_SUBTRACTIVE)
@@ -368,6 +634,378 @@ pcib_write_ivar(device_t dev, device_t c
     return(ENOENT);
 }
 
+#ifdef NEW_PCIB
+static const char *
+pcib_child_name(device_t child)
+{
+	static char buf[64];
+
+	if (device_get_nameunit(child) != NULL)
+		return (device_get_nameunit(child));
+	snprintf(buf, sizeof(buf), "pci%d:%d:%d:%d", pci_get_domain(child),
+	    pci_get_bus(child), pci_get_slot(child), pci_get_function(child));
+	return (buf);
+}
+
+/*
+ * Attempt to allocate a resource from the existing resources assigned
+ * to a window.
+ */
+static struct resource *
+pcib_suballoc_resource(struct pcib_softc *sc, struct pcib_window *w,
+    device_t child, int type, int *rid, u_long start, u_long end, u_long count,
+    u_int flags)
+{
+	struct resource *res;
+
+	if (!pcib_is_window_open(w))
+		return (NULL);
+
+	res = rman_reserve_resource(&w->rman, start, end, count,
+	    flags & ~RF_ACTIVE, child);
+	if (res == NULL)
+		return (NULL);
+
+	if (bootverbose)
+		device_printf(sc->dev,
+		    "allocated %s range (%#lx-%#lx) for rid %x of %s\n",
+		    w->name, rman_get_start(res), rman_get_end(res), *rid,
+		    pcib_child_name(child));
+	rman_set_rid(res, *rid);
+
+	/*
+	 * If the resource should be active, pass that request up the
+	 * tree.  This assumes the parent drivers can handle
+	 * activating sub-allocated resources.
+	 */
+	if (flags & RF_ACTIVE) {
+		if (bus_activate_resource(child, type, *rid, res) != 0) {
+			rman_release_resource(res);
+			return (NULL);
+		}
+	}
+
+	return (res);
+}
+
+/*
+ * Attempt to grow a window to make room for a given resource request.
+ * The 'step' parameter is log_2 of the desired I/O window's alignment.
+ */
+static int
+pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type,
+    u_long start, u_long end, u_long count, u_int flags)
+{
+	u_long align, start_free, end_free, front, back;
+	int error, rid;
+
+	/*
+	 * Clamp the desired resource range to the maximum address
+	 * this window supports.  Reject impossible requests.
+	 */
+	if (!w->valid)
+		return (EINVAL);
+	if (end > w->rman.rm_end)
+		end = w->rman.rm_end;
+	if (start + count - 1 > end || start + count < start)
+		return (EINVAL);
+
+	/*
+	 * If there is no resource at all, just try to allocate enough
+	 * aligned space for this resource.
+	 */
+	if (w->res == NULL) {
+		if (RF_ALIGNMENT(flags) < w->step) {
+			flags &= ~RF_ALIGNMENT_MASK;
+			flags |= RF_ALIGNMENT_LOG2(w->step);
+		}
+		start &= ~((1ul << w->step) - 1);
+		end |= ((1ul << w->step) - 1);
+		count = roundup2(count, 1ul << w->step);
+		rid = w->reg;
+		w->res = bus_alloc_resource(sc->dev, type, &rid, start, end,
+		    count, flags & ~RF_ACTIVE);
+		if (w->res == NULL) {
+			if (bootverbose)
+				device_printf(sc->dev,
+		    "failed to allocate initial %s window (%#lx-%#lx,%#lx)\n",
+				    w->name, start, end, count);
+			return (ENXIO);
+		}
+		if (bootverbose)
+			device_printf(sc->dev,
+			    "allocated initial %s window of %#lx-%#lx\n",
+			    w->name, rman_get_start(w->res),
+			    rman_get_end(w->res));
+		error = rman_manage_region(&w->rman, rman_get_start(w->res),
+		    rman_get_end(w->res));
+		if (error) {
+			if (bootverbose)
+				device_printf(sc->dev,
+				    "failed to add initial %s window to rman\n",
+				    w->name);
+			bus_release_resource(sc->dev, type, w->reg, w->res);
+			w->res = NULL;
+			return (error);
+		}
+		pcib_activate_window(sc, type);
+		goto updatewin;
+	}
+
+	/*
+	 * See if growing the window would help.  Compute the minimum
+	 * amount of address space needed on both the front and back
+	 * ends of the existing window to satisfy the allocation.
+	 *
+	 * For each end, build a candidate region adjusting for the
+	 * required alignment, etc.  If there is a free region at the
+	 * edge of the window, grow from the inner edge of the free
+	 * region.  Otherwise grow from the window boundary.
+	 *
+	 * XXX: Special case: if w->res is completely empty and the
+	 * request size is larger than w->res, we should find the
+	 * optimal aligned buffer containing w->res and allocate that.
+	 */
+	if (bootverbose)
+		device_printf(sc->dev,
+		    "attempting to grow %s window for (%#lx-%#lx,%#lx)\n",
+		    w->name, start, end, count);
+	align = 1ul << RF_ALIGNMENT(flags);
+	if (start < rman_get_start(w->res)) {
+		if (rman_first_free_region(&w->rman, &start_free, &end_free) !=
+		    0 || start_free != rman_get_start(w->res))
+			end_free = rman_get_start(w->res) - 1;
+		if (end_free > end)
+			end_free = end;
+
+		/* Move end_free down until it is properly aligned. */
+		end_free &= ~(align - 1);
+		end_free--;
+		front = end_free - (count - 1);
+
+		/*
+		 * The resource would now be allocated at (front,
+		 * end_free).  Ensure that fits in the (start, end)
+		 * bounds.  end_free is checked above.  If 'front' is
+		 * ok, ensure it is properly aligned for this window.
+		 * Also check for underflow.
+		 */
+		if (front >= start && front <= end_free) {
+			if (bootverbose)
+				printf("\tfront candidate range: %#lx-%#lx\n",
+				    front, end_free);
+			front &= (1ul << w->step) - 1;
+			front = rman_get_start(w->res) - front;
+		} else
+			front = 0;
+	} else
+		front = 0;
+	if (end > rman_get_end(w->res)) {
+		if (rman_last_free_region(&w->rman, &start_free, &end_free) !=
+		    0 || end_free != rman_get_end(w->res))
+			start_free = rman_get_end(w->res) + 1;
+		if (start_free < start)
+			start_free = start;
+
+		/* Move start_free up until it is properly aligned. */
+		start_free = roundup2(start_free, align);
+		back = start_free + count - 1;
+
+		/*
+		 * The resource would now be allocated at (start_free,
+		 * back).  Ensure that fits in the (start, end)
+		 * bounds.  start_free is checked above.  If 'back' is
+		 * ok, ensure it is properly aligned for this window.
+		 * Also check for overflow.
+		 */
+		if (back <= end && start_free <= back) {
+			if (bootverbose)
+				printf("\tback candidate range: %#lx-%#lx\n",
+				    start_free, back);
+			back = roundup2(back + 1, w->step) - 1;
+			back -= rman_get_end(w->res);
+		} else
+			back = 0;
+	} else
+		back = 0;
+
+	/*
+	 * Try to allocate the smallest needed region first.
+	 * If that fails, fall back to the other region.
+	 */
+	error = ENOSPC;
+	while (front != 0 || back != 0) {
+		if (front != 0 && (front <= back || back == 0)) {
+			error = bus_adjust_resource(sc->dev, type, w->res,
+			    rman_get_start(w->res) - front,
+			    rman_get_end(w->res));
+			if (error == 0)
+				break;
+			front = 0;
+		} else {
+			error = bus_adjust_resource(sc->dev, type, w->res,
+			    rman_get_start(w->res),
+			    rman_get_end(w->res) + back);
+			if (error == 0)
+				break;
+			back = 0;
+		}
+	}
+
+	if (error)
+		return (error);
+	if (bootverbose)
+		device_printf(sc->dev, "grew %s window to %#lx-%#lx\n",
+		    w->name, rman_get_start(w->res), rman_get_end(w->res));
+
+	/* Add the newly allocated region to the resource manager. */
+	if (w->base != rman_get_start(w->res)) {
+		KASSERT(w->limit == rman_get_end(w->res), ("both ends moved"));
+		error = rman_manage_region(&w->rman, rman_get_start(w->res),
+		    w->base - 1);
+	} else {
+		KASSERT(w->limit != rman_get_end(w->res),
+		    ("neither end moved"));
+		error = rman_manage_region(&w->rman, w->limit + 1,
+		    rman_get_end(w->res));
+	}
+	if (error) {
+		if (bootverbose)
+			device_printf(sc->dev,
+			    "failed to expand %s resource manager\n", w->name);
+		bus_adjust_resource(sc->dev, type, w->res, w->base, w->limit);
+		return (error);
+	}
+
+updatewin:
+	/* Save the new window. */
+	w->base = rman_get_start(w->res);
+	w->limit = rman_get_end(w->res);
+	KASSERT((w->base & ((1ul << w->step) - 1)) == 0,
+	    ("start address is not aligned"));
+	KASSERT((w->limit & ((1ul << w->step) - 1)) == (1ul << w->step) - 1,
+	    ("end address is not aligned"));
+	pcib_write_windows(sc, w->mask);
+	return (0);
+}
+
+/*
+ * We have to trap resource allocation requests and ensure that the bridge
+ * is set up to, or capable of handling them.
+ */
+struct resource *
+pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
+    u_long start, u_long end, u_long count, u_int flags)
+{
+	struct pcib_softc *sc;
+	struct resource *r;
+
+	sc = device_get_softc(dev);
+
+	/*
+	 * VGA resources are decoded iff the VGA enable bit is set in
+	 * the bridge control register.  VGA resources do not fall into
+	 * the resource windows and are passed up to the parent.
+	 */
+	if ((type == SYS_RES_IOPORT && pci_is_vga_ioport_range(start, end)) ||
+	    (type == SYS_RES_MEMORY && pci_is_vga_memory_range(start, end))) {
+		if (sc->bridgectl & PCIB_BCR_VGA_ENABLE)
+			return (bus_generic_alloc_resource(dev, child, type,
+			    rid, start, end, count, flags));
+		else
+			return (NULL);
+	}
+
+	switch (type) {
+	case SYS_RES_IOPORT:
+		r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start,
+		    end, count, flags);
+		if (r != NULL)
+			break;
+		if (pcib_grow_window(sc, &sc->io, type, start, end, count,
+		    flags) == 0)
+			r = pcib_suballoc_resource(sc, &sc->io, child, type,
+			    rid, start, end, count, flags);
+		break;
+	case SYS_RES_MEMORY:
+		/*
+		 * For prefetchable resources, prefer the prefetchable
+		 * memory window, but fall back to the regular memory
+		 * window if that fails.  Try both windows before
+		 * attempting to grow a window in case the firmware
+		 * has used a range in the regular memory window to
+		 * map a prefetchable BAR.
+		 */
+		if (flags & RF_PREFETCHABLE) {
+			r = pcib_suballoc_resource(sc, &sc->pmem, child, type,
+			    rid, start, end, count, flags);
+			if (r != NULL)
+				break;
+		}
+		r = pcib_suballoc_resource(sc, &sc->mem, child, type, rid,
+		    start, end, count, flags);
+		if (r != NULL)
+			break;
+		if (flags & RF_PREFETCHABLE) {
+			if (pcib_grow_window(sc, &sc->pmem, type, start, end,
+			    count, flags) == 0) {
+				r = pcib_suballoc_resource(sc, &sc->pmem, child,
+				    type, rid, start, end, count, flags);
+				if (r != NULL)
+					break;
+			}
+		}
+		if (pcib_grow_window(sc, &sc->mem, type, start, end, count,
+		    flags & ~RF_PREFETCHABLE) == 0)
+			r = pcib_suballoc_resource(sc, &sc->mem, child, type,
+			    rid, start, end, count, flags);
+		break;
+	default:
+		return (bus_generic_alloc_resource(dev, child, type, rid,
+		    start, end, count, flags));
+	}
+
+	/*
+	 * If attempts to suballocate from the window fail but this is a
+	 * subtractive bridge, pass the request up the tree.
+	 */
+	if (sc->flags & PCIB_SUBTRACTIVE && r == NULL)
+		return (bus_generic_alloc_resource(dev, child, type, rid,
+		    start, end, count, flags));
+	return (r);
+}
+
+int
+pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
+    u_long start, u_long end)
+{
+	struct pcib_softc *sc;
+
+	sc = device_get_softc(bus);
+	if (pcib_is_resource_managed(sc, type, r))
+		return (rman_adjust_resource(r, start, end));
+	return (bus_generic_adjust_resource(bus, child, type, r, start, end));
+}
+
+int
+pcib_release_resource(device_t dev, device_t child, int type, int rid,
+    struct resource *r)
+{
+	struct pcib_softc *sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	if (pcib_is_resource_managed(sc, type, r)) {
+		if (rman_get_flags(r) & RF_ACTIVE) {
+			error = bus_deactivate_resource(child, type, rid, r);
+			if (error)
+				return (error);
+		}
+		return (rman_release_resource(r));
+	}
+	return (bus_generic_release_resource(dev, child, type, rid, r));
+}
+#else
 /*
  * We have to trap resource allocation requests and ensure that the bridge
  * is set up to, or capable of handling them.
@@ -523,6 +1161,7 @@ pcib_alloc_resource(device_t dev, device
 	return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
 	    count, flags));
 }
+#endif
 
 /*
  * PCIB interface.

Modified: stable/8/sys/dev/pci/pcib_private.h
==============================================================================
--- stable/8/sys/dev/pci/pcib_private.h	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/dev/pci/pcib_private.h	Wed Jun 29 15:58:26 2011	(r223674)
@@ -39,6 +39,24 @@
  */
 DECLARE_CLASS(pcib_driver);
 
+#ifdef NEW_PCIB
+#define	WIN_IO		0x1
+#define	WIN_MEM		0x2
+#define	WIN_PMEM	0x4
+
+struct pcib_window {
+	pci_addr_t	base;		/* base address */
+	pci_addr_t	limit;		/* topmost address */
+	struct rman	rman;
+	struct resource *res;
+	int		reg;		/* resource id from parent */
+	int		valid;
+	int		mask;		/* WIN_* bitmask of this window */
+	int		step;		/* log_2 of window granularity */
+	const char	*name;
+};
+#endif
+
 /*
  * Bridge-specific data.
  */
@@ -53,12 +71,18 @@ struct pcib_softc 
     u_int	pribus;		/* primary bus number */
     u_int	secbus;		/* secondary bus number */
     u_int	subbus;		/* subordinate bus number */
+#ifdef NEW_PCIB
+    struct pcib_window io;	/* I/O port window */
+    struct pcib_window mem;	/* memory window */
+    struct pcib_window pmem;	/* prefetchable memory window */
+#else
     pci_addr_t	pmembase;	/* base address of prefetchable memory */
     pci_addr_t	pmemlimit;	/* topmost address of prefetchable memory */
     pci_addr_t	membase;	/* base address of memory window */
     pci_addr_t	memlimit;	/* topmost address of memory window */
     uint32_t	iobase;		/* base address of port window */
     uint32_t	iolimit;	/* topmost address of port window */
+#endif
     uint16_t	secstat;	/* secondary bus status register */
     uint16_t	bridgectl;	/* bridge control register */
     uint8_t	seclat;		/* secondary bus latency timer */
@@ -74,6 +98,12 @@ int		pcib_read_ivar(device_t dev, device
 int		pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value);
 struct resource *pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, 
 					    u_long start, u_long end, u_long count, u_int flags);
+#ifdef NEW_PCIB
+int		pcib_adjust_resource(device_t bus, device_t child, int type,
+    struct resource *r, u_long start, u_long end);
+int		pcib_release_resource(device_t dev, device_t child, int type, int rid,
+    struct resource *r);
+#endif
 int		pcib_maxslots(device_t dev);
 uint32_t	pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width);
 void		pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width);

Modified: stable/8/sys/i386/pci/pci_bus.c
==============================================================================
--- stable/8/sys/i386/pci/pci_bus.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/i386/pci/pci_bus.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: stable/8/sys/sparc64/pci/apb.c
==============================================================================
--- stable/8/sys/sparc64/pci/apb.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/sparc64/pci/apb.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Modified: stable/8/sys/sparc64/pci/ofw_pcib.c
==============================================================================
--- stable/8/sys/sparc64/pci/ofw_pcib.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/sparc64/pci/ofw_pcib.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Modified: stable/8/sys/x86/pci/qpi.c
==============================================================================
--- stable/8/sys/x86/pci/qpi.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/x86/pci/qpi.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 

Modified: stable/8/sys/x86/x86/mptable_pci.c
==============================================================================
--- stable/8/sys/x86/x86/mptable_pci.c	Wed Jun 29 15:17:29 2011	(r223673)
+++ stable/8/sys/x86/x86/mptable_pci.c	Wed Jun 29 15:58:26 2011	(r223674)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Jun 29 16:16:59 2011
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 E0B5C106566C;
	Wed, 29 Jun 2011 16:16:59 +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 CF15B8FC08;
	Wed, 29 Jun 2011 16:16:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5TGGxJ6004732;
	Wed, 29 Jun 2011 16:16:59 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5TGGxOn004729;
	Wed, 29 Jun 2011 16:16:59 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201106291616.p5TGGxOn004729@svn.freebsd.org>
From: John Baldwin 
Date: Wed, 29 Jun 2011 16:16: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: r223675 - stable/8/sys/dev/e1000
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, 29 Jun 2011 16:17:00 -0000

Author: jhb
Date: Wed Jun 29 16:16:59 2011
New Revision: 223675
URL: http://svn.freebsd.org/changeset/base/223675

Log:
  MFC 223198:
  - Use a dedicated task to handle deferred transmits from the if_transmit
    method instead of reusing the existing per-queue interrupt task.
    Reusing the per-queue interrupt task could result in both an interrupt
    thread and the taskqueue thread trying to handle received packets on a
    single queue resulting in out-of-order packet processing.
  - Don't define igb_start() at all on 8.0 and where if_transmit is used.
    Replace last remaining call to igb_start() with a loop to kick off
    transmit on each queue instead.
  - Call ether_ifdetach() earlier in igb_detach().
  - Drain tasks and free taskqueues during igb_detach().

Modified:
  stable/8/sys/dev/e1000/if_igb.c
  stable/8/sys/dev/e1000/if_igb.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)

Modified: stable/8/sys/dev/e1000/if_igb.c
==============================================================================
--- stable/8/sys/dev/e1000/if_igb.c	Wed Jun 29 15:58:26 2011	(r223674)
+++ stable/8/sys/dev/e1000/if_igb.c	Wed Jun 29 16:16:59 2011	(r223675)
@@ -170,13 +170,15 @@ static int	igb_detach(device_t);
 static int	igb_shutdown(device_t);
 static int	igb_suspend(device_t);
 static int	igb_resume(device_t);
-static void	igb_start(struct ifnet *);
-static void	igb_start_locked(struct tx_ring *, struct ifnet *ifp);
 #if __FreeBSD_version >= 800000
 static int	igb_mq_start(struct ifnet *, struct mbuf *);
 static int	igb_mq_start_locked(struct ifnet *,
 		    struct tx_ring *, struct mbuf *);
 static void	igb_qflush(struct ifnet *);
+static void	igb_deferred_mq_start(void *, int);
+#else
+static void	igb_start(struct ifnet *);
+static void	igb_start_locked(struct tx_ring *, struct ifnet *ifp);
 #endif
 static int	igb_ioctl(struct ifnet *, u_long, caddr_t);
 static void	igb_init(void *);
@@ -693,6 +695,8 @@ igb_detach(device_t dev)
 		return (EBUSY);
 	}
 
+	ether_ifdetach(adapter->ifp);
+
 	if (adapter->led_dev != NULL)
 		led_destroy(adapter->led_dev);
 
@@ -724,8 +728,6 @@ igb_detach(device_t dev)
 	if (adapter->vlan_detach != NULL)
 		EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach);
 
-	ether_ifdetach(adapter->ifp);
-
 	callout_drain(&adapter->timer);
 
 	igb_free_pci_resources(adapter);
@@ -784,14 +786,27 @@ igb_resume(device_t dev)
 {
 	struct adapter *adapter = device_get_softc(dev);
 	struct ifnet *ifp = adapter->ifp;
+#if __FreeBSD_version >= 800000
+	struct tx_ring *txr = adapter->tx_rings;
+#endif
 
 	IGB_CORE_LOCK(adapter);
 	igb_init_locked(adapter);
 	igb_init_manageability(adapter);
 
 	if ((ifp->if_flags & IFF_UP) &&
-	    (ifp->if_drv_flags & IFF_DRV_RUNNING))
+	    (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+#if __FreeBSD_version < 800000
 		igb_start(ifp);
+#else
+		for (int i = 0; i < adapter->num_queues; i++, txr++) {
+			IGB_TX_LOCK(txr);
+			if (!drbr_empty(ifp, txr->br))
+				igb_mq_start_locked(ifp, txr, NULL);
+			IGB_TX_UNLOCK(txr);
+		}
+#endif
+	}
 
 	IGB_CORE_UNLOCK(adapter);
 
@@ -799,6 +814,7 @@ igb_resume(device_t dev)
 }
 
 
+#if __FreeBSD_version < 800000
 /*********************************************************************
  *  Transmit entry point
  *
@@ -875,7 +891,7 @@ igb_start(struct ifnet *ifp)
 	return;
 }
 
-#if __FreeBSD_version >= 800000
+#else /* __FreeBSD_version >= 800000 */
 /*
 ** Multiqueue Transmit driver
 **
@@ -900,7 +916,7 @@ igb_mq_start(struct ifnet *ifp, struct m
 		IGB_TX_UNLOCK(txr);
 	} else {
 		err = drbr_enqueue(ifp, txr->br, m);
-		taskqueue_enqueue(que->tq, &que->que_task);
+		taskqueue_enqueue(que->tq, &txr->txq_task);
 	}
 
 	return (err);
@@ -961,6 +977,22 @@ igb_mq_start_locked(struct ifnet *ifp, s
 }
 
 /*
+ * Called from a taskqueue to drain queued transmit packets.
+ */
+static void
+igb_deferred_mq_start(void *arg, int pending)
+{
+	struct tx_ring *txr = arg;
+	struct adapter *adapter = txr->adapter;
+	struct ifnet *ifp = adapter->ifp;
+
+	IGB_TX_LOCK(txr);
+	if (!drbr_empty(ifp, txr->br))
+		igb_mq_start_locked(ifp, txr, NULL);
+	IGB_TX_UNLOCK(txr);
+}
+
+/*
 ** Flush all ring buffers
 */
 static void
@@ -978,7 +1010,7 @@ igb_qflush(struct ifnet *ifp)
 	}
 	if_qflush(ifp);
 }
-#endif /* __FreeBSD_version >= 800000 */
+#endif /* __FreeBSD_version < 800000 */
 
 /*********************************************************************
  *  Ioctl entry point
@@ -2180,6 +2212,7 @@ igb_allocate_legacy(struct adapter *adap
 {
 	device_t		dev = adapter->dev;
 	struct igb_queue	*que = adapter->queues;
+	struct tx_ring		*txr = adapter->tx_rings;
 	int			error, rid = 0;
 
 	/* Turn off all interrupts */
@@ -2198,6 +2231,10 @@ igb_allocate_legacy(struct adapter *adap
 		return (ENXIO);
 	}
 
+#if __FreeBSD_version >= 800000
+	TASK_INIT(&txr->txq_task, 0, igb_deferred_mq_start, txr);
+#endif
+
 	/*
 	 * Try allocating a fast interrupt and the associated deferred
 	 * processing contexts.
@@ -2268,9 +2305,13 @@ igb_allocate_msix(struct adapter *adapte
 		*/
 		if (adapter->num_queues > 1)
 			bus_bind_intr(dev, que->res, i);
+#if __FreeBSD_version >= 800000
+		TASK_INIT(&que->txr->txq_task, 0, igb_deferred_mq_start,
+		    que->txr);
+#endif
 		/* Make tasklet for deferred handling */
 		TASK_INIT(&que->que_task, 0, igb_handle_que, que);
-		que->tq = taskqueue_create_fast("igb_que", M_NOWAIT,
+		que->tq = taskqueue_create("igb_que", M_NOWAIT,
 		    taskqueue_thread_enqueue, &que->tq);
 		taskqueue_start_threads(&que->tq, 1, PI_NET, "%s que",
 		    device_get_nameunit(adapter->dev));
@@ -2477,13 +2518,24 @@ igb_free_pci_resources(struct adapter *a
 	else
 		(adapter->msix != 0) ? (rid = 1):(rid = 0);
 
+	que = adapter->queues;
 	if (adapter->tag != NULL) {
+		taskqueue_drain(que->tq, &adapter->link_task);
 		bus_teardown_intr(dev, adapter->res, adapter->tag);
 		adapter->tag = NULL;
 	}
 	if (adapter->res != NULL)
 		bus_release_resource(dev, SYS_RES_IRQ, rid, adapter->res);
 
+	for (int i = 0; i < adapter->num_queues; i++, que++) {
+		if (que->tq != NULL) {
+#if __FreeBSD_version >= 800000
+			taskqueue_drain(que->tq, &que->txr->txq_task);
+#endif
+			taskqueue_drain(que->tq, &que->que_task);
+			taskqueue_free(que->tq);
+		}
+	}
 mem:
 	if (adapter->msix)
 		pci_release_msi(dev);
@@ -2744,10 +2796,11 @@ igb_setup_interface(device_t dev, struct
 	ifp->if_softc = adapter;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = igb_ioctl;
-	ifp->if_start = igb_start;
 #if __FreeBSD_version >= 800000
 	ifp->if_transmit = igb_mq_start;
 	ifp->if_qflush = igb_qflush;
+#else
+	ifp->if_start = igb_start;
 #endif
 	IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
 	ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1;

Modified: stable/8/sys/dev/e1000/if_igb.h
==============================================================================
--- stable/8/sys/dev/e1000/if_igb.h	Wed Jun 29 15:58:26 2011	(r223674)
+++ stable/8/sys/dev/e1000/if_igb.h	Wed Jun 29 16:16:59 2011	(r223675)
@@ -297,6 +297,7 @@ struct tx_ring {
 	struct buf_ring		*br;
 #endif
 	bus_dma_tag_t		txtag;
+	struct task		txq_task;
 
 	u32			bytes;
 	u32			packets;

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Jun 29 16:43:45 2011
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 3D9F5106566C;
	Wed, 29 Jun 2011 16:43:45 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2CD6E8FC1A;
	Wed, 29 Jun 2011 16:43:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5TGhjwX005672;
	Wed, 29 Jun 2011 16:43:45 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5TGhjiA005670;
	Wed, 29 Jun 2011 16:43:45 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201106291643.p5TGhjiA005670@svn.freebsd.org>
From: Dimitry Andric 
Date: Wed, 29 Jun 2011 16:43:45 +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: r223678 - stable/8/contrib/traceroute
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, 29 Jun 2011 16:43:45 -0000

Author: dim
Date: Wed Jun 29 16:43:44 2011
New Revision: 223678
URL: http://svn.freebsd.org/changeset/base/223678

Log:
  MFC r223579:
  
  For some reason, contrib/traceroute/traceroute.c ensures MAXHOSTNAMELEN
  is defined, but then proceeds to use a hardcoded maximum hostname length
  of 64 anyway.  Fix this by checking against MAXHOSTNAMELEN instead.
  
  PR:	bin/157732

Modified:
  stable/8/contrib/traceroute/traceroute.c
Directory Properties:
  stable/8/contrib/traceroute/   (props changed)

Modified: stable/8/contrib/traceroute/traceroute.c
==============================================================================
--- stable/8/contrib/traceroute/traceroute.c	Wed Jun 29 16:40:41 2011	(r223677)
+++ stable/8/contrib/traceroute/traceroute.c	Wed Jun 29 16:43:44 2011	(r223678)
@@ -1625,7 +1625,7 @@ gethostinfo(register char *hostname)
 	register char **p;
 	register u_int32_t addr, *ap;
 
-	if (strlen(hostname) > 64) {
+	if (strlen(hostname) >= MAXHOSTNAMELEN) {
 		Fprintf(stderr, "%s: hostname \"%.32s...\" is too long\n",
 		    prog, hostname);
 		exit(1);

From owner-svn-src-stable-8@FreeBSD.ORG  Wed Jun 29 17:18:33 2011
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 C70731065679;
	Wed, 29 Jun 2011 17:18: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 576FC8FC14;
	Wed, 29 Jun 2011 17:18:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5THIXn0006895;
	Wed, 29 Jun 2011 17:18:33 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5THIXib006892;
	Wed, 29 Jun 2011 17:18:33 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201106291718.p5THIXib006892@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Wed, 29 Jun 2011 17:18: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: r223681 - stable/8/sys/dev/vr
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, 29 Jun 2011 17:18:34 -0000

Author: yongari
Date: Wed Jun 29 17:18:33 2011
New Revision: 223681
URL: http://svn.freebsd.org/changeset/base/223681

Log:
  MFC r223405:
    Remove link state change callback handler.  There is no need to
    register both status change and link state change callbacks.
    Implement checking valid link in state change callback and poll
    active link state in vr_tick().  This allows immediate detection of
    lost link as well as protecting driver from frequent link flips during
    link renegotiation.  taskq implementation was removed because driver
    now needs to poll link state in vr_tick().
    While I'm here do not report current link state if interface is not
    running.
  
    Tested by:	n_hibma

Modified:
  stable/8/sys/dev/vr/if_vr.c
  stable/8/sys/dev/vr/if_vrreg.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)

Modified: stable/8/sys/dev/vr/if_vr.c
==============================================================================
--- stable/8/sys/dev/vr/if_vr.c	Wed Jun 29 16:58:27 2011	(r223680)
+++ stable/8/sys/dev/vr/if_vr.c	Wed Jun 29 17:18:33 2011	(r223681)
@@ -185,7 +185,6 @@ static int vr_miibus_readreg(device_t, i
 static int vr_miibus_writereg(device_t, int, int, int);
 static void vr_miibus_statchg(device_t);
 
-static void vr_link_task(void *, int);
 static void vr_cam_mask(struct vr_softc *, uint32_t, int);
 static int vr_cam_data(struct vr_softc *, int, int, uint8_t *);
 static void vr_set_filter(struct vr_softc *);
@@ -226,7 +225,6 @@ static device_method_t vr_methods[] = {
 	DEVMETHOD(miibus_readreg,	vr_miibus_readreg),
 	DEVMETHOD(miibus_writereg,	vr_miibus_writereg),
 	DEVMETHOD(miibus_statchg,	vr_miibus_statchg),
-	DEVMETHOD(miibus_linkchg,	vr_miibus_statchg),
 
 	{ NULL, NULL }
 };
@@ -290,22 +288,13 @@ vr_miibus_writereg(device_t dev, int phy
 	return (0);
 }
 
-static void
-vr_miibus_statchg(device_t dev)
-{
-	struct vr_softc		*sc;
-
-	sc = device_get_softc(dev);
-	taskqueue_enqueue(taskqueue_swi, &sc->vr_link_task);
-}
-
 /*
  * In order to fiddle with the
  * 'full-duplex' and '100Mbps' bits in the netconfig register, we
  * first have to put the transmit and/or receive logic in the idle state.
  */
 static void
-vr_link_task(void *arg, int pending)
+vr_miibus_statchg(device_t dev)
 {
 	struct vr_softc		*sc;
 	struct mii_data		*mii;
@@ -313,22 +302,25 @@ vr_link_task(void *arg, int pending)
 	int			lfdx, mfdx;
 	uint8_t			cr0, cr1, fc;
 
-	sc = (struct vr_softc *)arg;
-
-	VR_LOCK(sc);
+	sc = device_get_softc(dev);
 	mii = device_get_softc(sc->vr_miibus);
 	ifp = sc->vr_ifp;
 	if (mii == NULL || ifp == NULL ||
-	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
-		VR_UNLOCK(sc);
+	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
 		return;
-	}
 
-	if (mii->mii_media_status & IFM_ACTIVE) {
-		if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
+	sc->vr_link = 0;
+	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->vr_link = 1;
-	} else
-		sc->vr_link = 0;
+			break;
+		default:
+			break;
+		}
+	}
 
 	if (sc->vr_link != 0) {
 		cr0 = CSR_READ_1(sc, VR_CR0);
@@ -384,11 +376,8 @@ vr_link_task(void *arg, int pending)
 			    "%s: Tx/Rx shutdown error -- resetting\n",
 			    __func__);
 			sc->vr_flags |= VR_F_RESTART;
-			VR_UNLOCK(sc);
-			return;
 		}
 	}
-	VR_UNLOCK(sc);
 }
 
 
@@ -621,7 +610,6 @@ vr_attach(device_t dev)
 	mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
 	    MTX_DEF);
 	callout_init_mtx(&sc->vr_stat_callout, &sc->vr_mtx, 0);
-	TASK_INIT(&sc->vr_link_task, 0, vr_link_task, sc);
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
 	    OID_AUTO, "stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
@@ -841,7 +829,6 @@ vr_detach(device_t dev)
 		vr_stop(sc);
 		VR_UNLOCK(sc);
 		callout_drain(&sc->vr_stat_callout);
-		taskqueue_drain(taskqueue_swi, &sc->vr_link_task);
 		ether_ifdetach(ifp);
 	}
 	if (sc->vr_miibus)
@@ -1559,6 +1546,8 @@ vr_tick(void *xsc)
 
 	mii = device_get_softc(sc->vr_miibus);
 	mii_tick(mii);
+	if (sc->vr_link == 0)
+		vr_miibus_statchg(sc->vr_dev);
 	vr_watchdog(sc);
 	callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc);
 }
@@ -2163,6 +2152,10 @@ vr_ifmedia_sts(struct ifnet *ifp, struct
 	sc = ifp->if_softc;
 	mii = device_get_softc(sc->vr_miibus);
 	VR_LOCK(sc);
+	if ((ifp->if_flags & IFF_UP) == 0) {
+		VR_UNLOCK(sc);
+		return;
+	}
 	mii_pollstat(mii);
 	VR_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;

Modified: stable/8/sys/dev/vr/if_vrreg.h
==============================================================================
--- stable/8/sys/dev/vr/if_vrreg.h	Wed Jun 29 16:58:27 2011	(r223680)
+++ stable/8/sys/dev/vr/if_vrreg.h	Wed Jun 29 17:18:33 2011	(r223681)
@@ -723,7 +723,6 @@ struct vr_softc {
 	uint8_t			vr_flags;	/* See VR_F_* below */
 #define	VR_F_RESTART		0x01		/* Restart unit on next tick */
 	int			vr_if_flags;
-	struct task		vr_link_task;
 	struct vr_chain_data	vr_cdata;
 	struct vr_ring_data	vr_rdata;
 	struct vr_statistics	vr_stat;

From owner-svn-src-stable-8@FreeBSD.ORG  Fri Jul  1 10:25:48 2011
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 E57FD106564A;
	Fri,  1 Jul 2011 10:25:48 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D551A8FC17;
	Fri,  1 Jul 2011 10:25:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p61APmGE083533;
	Fri, 1 Jul 2011 10:25:48 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p61APmp1083531;
	Fri, 1 Jul 2011 10:25:48 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201107011025.p61APmp1083531@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Fri, 1 Jul 2011 10:25: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: r223707 - stable/8/sys/compat/linprocfs
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, 01 Jul 2011 10:25:49 -0000

Author: pluknet
Date: Fri Jul  1 10:25:48 2011
New Revision: 223707
URL: http://svn.freebsd.org/changeset/base/223707

Log:
  MFC r223182:
  
   Return empty cmdline/environ string for processes with kernel address
   space. This is consistent with the behavior in linux.
  
  PR:		kern/157871

Modified:
  stable/8/sys/compat/linprocfs/linprocfs.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)

Modified: stable/8/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- stable/8/sys/compat/linprocfs/linprocfs.c	Fri Jul  1 08:27:03 2011	(r223706)
+++ stable/8/sys/compat/linprocfs/linprocfs.c	Fri Jul  1 10:25:48 2011	(r223707)
@@ -1046,6 +1046,15 @@ linprocfs_doproccmdline(PFS_FILL_ARGS)
 		PROC_UNLOCK(p);
 		return (ret);
 	}
+
+	/*
+	 * Mimic linux behavior and pass only processes with usermode
+	 * address space as valid.  Return zero silently otherwize.
+	 */
+	if (p->p_vmspace == &vmspace0) {
+		PROC_UNLOCK(p);
+		return (0);
+	}
 	if (p->p_args != NULL) {
 		sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length);
 		PROC_UNLOCK(p);
@@ -1070,6 +1079,15 @@ linprocfs_doprocenviron(PFS_FILL_ARGS)
 		PROC_UNLOCK(p);
 		return (ret);
 	}
+
+	/*
+	 * Mimic linux behavior and pass only processes with usermode
+	 * address space as valid.  Return zero silently otherwize.
+	 */
+	if (p->p_vmspace == &vmspace0) {
+		PROC_UNLOCK(p);
+		return (0);
+	}
 	PROC_UNLOCK(p);
 
 	ret = linprocfs_doargv(td, p, sb, ps_string_env);

From owner-svn-src-stable-8@FreeBSD.ORG  Fri Jul  1 12:30:34 2011
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 D94F6106566B;
	Fri,  1 Jul 2011 12:30:34 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AF9598FC13;
	Fri,  1 Jul 2011 12:30:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p61CUYZQ091287;
	Fri, 1 Jul 2011 12:30:34 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p61CUYGc091285;
	Fri, 1 Jul 2011 12:30:34 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201107011230.p61CUYGc091285@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Fri, 1 Jul 2011 12:30: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: r223711 - stable/8/bin/sh
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, 01 Jul 2011 12:30:35 -0000

Author: jilles
Date: Fri Jul  1 12:30:34 2011
New Revision: 223711
URL: http://svn.freebsd.org/changeset/base/223711

Log:
  MFC r223522: sh(1): Improve documentation of shell patterns:
  
  * Shell patterns are also for ${var#pat} and the like.
  * An '!' by itself will not trigger pathname generation so do not call it a
    meta-character, even though it has a special meaning directly after an
    '['.
  * Character ranges are locale-dependent.
  * A '^' will complement a character class like '!' but is non-standard.

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

Modified: stable/8/bin/sh/sh.1
==============================================================================
--- stable/8/bin/sh/sh.1	Fri Jul  1 12:13:48 2011	(r223710)
+++ stable/8/bin/sh/sh.1	Fri Jul  1 12:30:34 2011	(r223711)
@@ -32,7 +32,7 @@
 .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd December 3, 2010
+.Dd June 24, 2011
 .Dt SH 1
 .Os
 .Sh NAME
@@ -1521,15 +1521,15 @@ There are two restrictions on this: firs
 a string containing a slash, and second,
 a pattern cannot match a string starting with a period
 unless the first character of the pattern is a period.
-The next section describes the patterns used for both
-Pathname Expansion and the
+The next section describes the patterns used for
+Pathname Expansion,
+the four varieties of parameter expansion for substring processing and the
 .Ic case
 command.
 .Ss Shell Patterns
 A pattern consists of normal characters, which match themselves,
 and meta-characters.
 The meta-characters are
-.Ql \&! ,
 .Ql * ,
 .Ql \&? ,
 and
@@ -1559,16 +1559,21 @@ matches a
 .Ql \&[
 rather than introducing a character class.
 A character class matches any of the characters between the square brackets.
-A range of characters may be specified using a minus sign.
+A locale-dependent range of characters may be specified using a minus sign.
 The character class may be complemented by making an exclamation point
 .Pq Ql !\&
 the first character of the character class.
+A caret
+.Pq Ql ^
+has the same effect but is non-standard.
 .Pp
 To include a
 .Ql \&]
 in a character class, make it the first character listed
 (after the
-.Ql \&! ,
+.Ql \&!
+or
+.Ql ^ ,
 if any).
 To include a
 .Ql - ,

From owner-svn-src-stable-8@FreeBSD.ORG  Sat Jul  2 00:34:02 2011
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 7C245106566B;
	Sat,  2 Jul 2011 00:34:02 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6B1A98FC08;
	Sat,  2 Jul 2011 00:34:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p620Y2dm012656;
	Sat, 2 Jul 2011 00:34:02 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p620Y2t9012654;
	Sat, 2 Jul 2011 00:34:02 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <201107020034.p620Y2t9012654@svn.freebsd.org>
From: Xin LI 
Date: Sat, 2 Jul 2011 00:34: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: r223716 - stable/8/lib/libc/db/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: Sat, 02 Jul 2011 00:34:02 -0000

Author: delphij
Date: Sat Jul  2 00:34:02 2011
New Revision: 223716
URL: http://svn.freebsd.org/changeset/base/223716

Log:
  MFC r223214:
  
  The flags argument of mpool_get() is meaningful, document it.

Modified:
  stable/8/lib/libc/db/man/mpool.3
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)

Modified: stable/8/lib/libc/db/man/mpool.3
==============================================================================
--- stable/8/lib/libc/db/man/mpool.3	Fri Jul  1 20:45:55 2011	(r223715)
+++ stable/8/lib/libc/db/man/mpool.3	Sat Jul  2 00:34:02 2011	(r223716)
@@ -28,7 +28,7 @@
 .\"	@(#)mpool.3	8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd February 25, 1999
+.Dd June 17, 2011
 .Dt MPOOL 3
 .Os
 .Sh NAME
@@ -147,7 +147,14 @@ is returned and
 is set.
 The
 .Fa flags
-argument is not currently used.
+argument is specified by
+.Em or Ns 'ing
+any of the following values:
+.Bl -tag -width indent
+.It Dv MPOOL_IGNOREPIN
+The page returned is not pinned;
+page will otherwise be pinned on return.
+.El
 .Pp
 The
 .Fn mpool_put

From owner-svn-src-stable-8@FreeBSD.ORG  Sat Jul  2 00:38:11 2011
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 4834D106566C;
	Sat,  2 Jul 2011 00:38:11 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3776E8FC13;
	Sat,  2 Jul 2011 00:38:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p620cBjn012811;
	Sat, 2 Jul 2011 00:38:11 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p620cBr6012809;
	Sat, 2 Jul 2011 00:38:11 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <201107020038.p620cBr6012809@svn.freebsd.org>
From: Xin LI 
Date: Sat, 2 Jul 2011 00:38: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: r223717 - stable/8/lib/libc/gen
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, 02 Jul 2011 00:38:11 -0000

Author: delphij
Date: Sat Jul  2 00:38:10 2011
New Revision: 223717
URL: http://svn.freebsd.org/changeset/base/223717

Log:
  MFC r223216:
  
  Sync with OpenBSD (zap rcsid).

Modified:
  stable/8/lib/libc/gen/ftw.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)

Modified: stable/8/lib/libc/gen/ftw.c
==============================================================================
--- stable/8/lib/libc/gen/ftw.c	Sat Jul  2 00:34:02 2011	(r223716)
+++ stable/8/lib/libc/gen/ftw.c	Sat Jul  2 00:38:10 2011	(r223717)
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $	*/
+/*	$OpenBSD: ftw.c,v 1.5 2005/08/08 08:05:34 espie Exp $	*/
 
 /*
  * Copyright (c) 2003, 2004 Todd C. Miller 
@@ -20,12 +20,6 @@
  * Materiel Command, USAF, under agreement number F39502-99-1-0512.
  */
 
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-#endif
-
 #include 
 __FBSDID("$FreeBSD$");
 

From owner-svn-src-stable-8@FreeBSD.ORG  Sat Jul  2 16:20:58 2011
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 8140C106566B;
	Sat,  2 Jul 2011 16:20:58 +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 709068FC16;
	Sat,  2 Jul 2011 16:20:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p62GKwP3047280;
	Sat, 2 Jul 2011 16:20:58 GMT (envelope-from uqs@svn.freebsd.org)
Received: (from uqs@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p62GKw6n047277;
	Sat, 2 Jul 2011 16:20:58 GMT (envelope-from uqs@svn.freebsd.org)
Message-Id: <201107021620.p62GKw6n047277@svn.freebsd.org>
From: Ulrich Spoerlein 
Date: Sat, 2 Jul 2011 16:20: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: r223724 - in stable/8: tools usr.bin/xinstall
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, 02 Jul 2011 16:20:58 -0000

Author: uqs
Date: Sat Jul  2 16:20:58 2011
New Revision: 223724
URL: http://svn.freebsd.org/changeset/base/223724

Log:
  MFH r218940:     Teach tools/install.sh the -d directory mode.
  
  Sync up with flags understood by install(1) [1], and make install(1)'s
  usage output not hide the clearly documented -M flag.

Modified:
  stable/8/tools/install.sh
  stable/8/usr.bin/xinstall/xinstall.c
Directory Properties:
  stable/8/tools/   (props changed)
  stable/8/usr.bin/xinstall/   (props changed)

Modified: stable/8/tools/install.sh
==============================================================================
--- stable/8/tools/install.sh	Sat Jul  2 15:41:22 2011	(r223723)
+++ stable/8/tools/install.sh	Sat Jul  2 16:20:58 2011	(r223724)
@@ -29,14 +29,30 @@
 # $FreeBSD$
 
 # parse install's options and ignore them completely.
+dirmode=""
 while [ $# -gt 0 ]; do
     case $1 in
-    -[bCcMpSs]) shift;;
+    -d) dirmode="YES"; shift;;
+    -[bCcMpSsv]) shift;;
     -[Bfgmo]) shift; shift;;
     -[Bfgmo]*) shift;;
     *) break;
     esac
 done
 
+if [ "$#" -eq 0 ]; then
+	echo "$0: no files/dirs specified" >&2
+	exit 1
+fi
+
+if [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
+	echo "$0: no target specified" >&2
+	exit 1
+fi
+
 # the remaining arguments are assumed to be files/dirs only.
-exec install -p $*
+if [ -z "$dirmode" ]; then
+	exec install -p "$@"
+else
+	exec install -d "$@"
+fi

Modified: stable/8/usr.bin/xinstall/xinstall.c
==============================================================================
--- stable/8/usr.bin/xinstall/xinstall.c	Sat Jul  2 15:41:22 2011	(r223723)
+++ stable/8/usr.bin/xinstall/xinstall.c	Sat Jul  2 16:20:58 2011	(r223724)
@@ -774,9 +774,9 @@ void
 usage()
 {
 	(void)fprintf(stderr,
-"usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
+"usage: install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 "               [-o owner] file1 file2\n"
-"       install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
+"       install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 "               [-o owner] file1 ... fileN directory\n"
 "       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n");
 	exit(EX_USAGE);

From owner-svn-src-stable-8@FreeBSD.ORG  Sat Jul  2 18:43:36 2011
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 1AAF31065670;
	Sat,  2 Jul 2011 18:43:36 +0000 (UTC) (envelope-from ae@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 09E228FC08;
	Sat,  2 Jul 2011 18:43:36 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p62IhZqk051491;
	Sat, 2 Jul 2011 18:43:35 GMT (envelope-from ae@svn.freebsd.org)
Received: (from ae@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id p62IhZOq051489;
	Sat, 2 Jul 2011 18:43:35 GMT (envelope-from ae@svn.freebsd.org)
Message-Id: <201107021843.p62IhZOq051489@svn.freebsd.org>
From: "Andrey V. Elsukov" 
Date: Sat, 2 Jul 2011 18:43:35 +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: r223725 - stable/8/sbin/geom/class/part
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, 02 Jul 2011 18:43:36 -0000

Author: ae
Date: Sat Jul  2 18:43:35 2011
New Revision: 223725
URL: http://svn.freebsd.org/changeset/base/223725

Log:
  Since head/ and stable/8 have different handling for geom control request
  parameters, r215941 should be modified to allow use -F option in the
  "gpart restore" command - "force" parameter should be ascii string.
  
  This is direct commit to stable/8.
  
  Reported by:	Maxim Ignatenko

Modified:
  stable/8/sbin/geom/class/part/geom_part.c

Modified: stable/8/sbin/geom/class/part/geom_part.c
==============================================================================
--- stable/8/sbin/geom/class/part/geom_part.c	Sat Jul  2 16:20:58 2011	(r223724)
+++ stable/8/sbin/geom/class/part/geom_part.c	Sat Jul  2 18:43:35 2011	(r223725)
@@ -828,8 +828,8 @@ gpart_restore(struct gctl_req *req, unsi
 				    classp->lg_name);
 				gctl_ro_param(r, "verb", -1, "destroy");
 				gctl_ro_param(r, "flags", -1, "restore");
-				gctl_ro_param(r, "force", sizeof(forced),
-				    &forced);
+				gctl_ro_param(r, "force", -1,
+				    forced ? "1": "0");
 				gctl_ro_param(r, "geom", -1, s);
 				errstr = gctl_issue(r);
 				if (errstr != NULL && errstr[0] != '\0') {